diff --git a/common/models/Transfer.php b/common/models/Transfer.php index 6785ea1..87c1e1f 100644 --- a/common/models/Transfer.php +++ b/common/models/Transfer.php @@ -471,6 +471,32 @@ class Transfer extends \common\models\BaseFitnessActiveRecord return $status; } + public function beforeDelete(){ + parent::beforeDelete(); + if ( $this->type == Transfer::TYPE_TICKET){ + $ticket = $this->ticket; + if ( $ticket != null ){ + $ticket->delete(); + } + }else if ($this->type == Transfer::TYPE_MONEY_MOVEMENT_OUT){ + $mm = $this->moneyMovement; + $mm->delete(); + }else if ($this->type == Transfer::TYPE_PRODUCT){ + $sale = $this->sale; + $product = $this->product; + + $product->stock = $product->stock + $this->count; + + $product->save(); + $sale->delete(); + } + + ShoppingCart::deleteAll(['id_transfer' =>$this->id_transfer]); + UserSoldItem::deleteAll(['id_transfer' =>$this->id_transfer]); + + return true; + } + /** * @param string $mode The mode to load * Available modes diff --git a/frontend/assets/AppAsset.php b/frontend/assets/AppAsset.php index c37175f..221935a 100644 --- a/frontend/assets/AppAsset.php +++ b/frontend/assets/AppAsset.php @@ -21,7 +21,7 @@ class AppAsset extends AssetBundle 'css/site.css', ]; public $js = [ - + 'js/app.js', ]; public $depends = [ 'yii\web\YiiAsset', diff --git a/frontend/components/AccountStateBanknoteCountWidget.php b/frontend/components/AccountStateBanknoteCountWidget.php index 154867e..d824430 100644 --- a/frontend/components/AccountStateBanknoteCountWidget.php +++ b/frontend/components/AccountStateBanknoteCountWidget.php @@ -8,11 +8,13 @@ use yii\widgets\DetailView; use yii\grid\GridView; use yii\base\Object; use yii\data\ArrayDataProvider; +use yii\helpers\Url; class AccountStateBanknoteCountWidget extends Widget{ public $model; public $layout; + public $index; public function run(){ @@ -77,6 +79,21 @@ class AccountStateBanknoteCountWidget extends Widget{ } $s .= $this->generateComment(); + + $s .= Html::beginTag("div", ['class' => 'row', 'style' => 'margin-top: 6px;']); + $s .= Html::beginTag("div", ['class' => 'col-md-12 text-right']); + + $s .= Html::a('Törlés', Url::toRoute(['delete','id' =>$this->model->id_account_state]), [ + 'title' => \Yii::t('yii', 'Delete'), + 'data-confirm' =>\Yii::t('yii', 'Are you sure to delete this item?'), + 'data-method' => 'post', + 'class' => 'btn btn-danger', + 'style' =>'margin-bottom: 12px;' + ]); + + $s .= Html::endTag("div");//end col + $s .= Html::endTag("div");//end row + $s .= Html::endTag("div"); $s .= Html::endTag("div"); diff --git a/frontend/controllers/AccountStateController.php b/frontend/controllers/AccountStateController.php index 4974f2e..1be2f4f 100644 --- a/frontend/controllers/AccountStateController.php +++ b/frontend/controllers/AccountStateController.php @@ -163,13 +163,13 @@ class AccountStateController extends Controller * If deletion is successful, the browser will be redirected to the 'index' page. * @param integer $id * @return mixed + */ public function actionDelete($id) { $this->findModel($id)->delete(); - - return $this->redirect(['index']); + \Yii::$app->session->setFlash( 'success','Kassza művelet törölve' ); + return $this->redirect(Yii::$app->request->referrer); } - */ /** * Displays a single AccountState model. * @param integer $id diff --git a/frontend/controllers/TransferController.php b/frontend/controllers/TransferController.php index 2d57342..36a3bca 100644 --- a/frontend/controllers/TransferController.php +++ b/frontend/controllers/TransferController.php @@ -159,11 +159,26 @@ class TransferController extends Controller * If deletion is successful, the browser will be redirected to the 'index' page. * @param integer $id * @return mixed + */ public function actionDelete($id) { - $this->findModel($id)->delete(); + $transfer = $this->findModel($id); + $connection = \Yii::$app->db; + $transaction = $connection->beginTransaction(); + try { + if ( $transfer->delete() ){ + \Yii::$app->session->setFlash( 'success','Tranzakció törölve' ); + $transaction->commit(); + }else{ + throw new \Exception("Failed to save"); + } + + } catch(Exception $e) { + $transaction->rollback(); + \Yii::$app->session->setFlash( 'danger','Tranzakció törlése nem sikerült' ); + } - return $this->redirect(['index']); + + return $this->redirect(Yii::$app->request->referrer); } - */ } diff --git a/frontend/models/ReceptionForm.php b/frontend/models/ReceptionForm.php index 618d275..434af1e 100644 --- a/frontend/models/ReceptionForm.php +++ b/frontend/models/ReceptionForm.php @@ -42,7 +42,9 @@ class ReceptionForm extends Model public function readCard(){ - $this->card = Card::find()->andWhere(['or',[ 'in','number' , [$this->number]],['in','rfid_key' ,[ $this->number]]])->one(); + $this->number = str_replace("ö", "0", $this->number); + + $this->card = Card::find()->andWhere(['or',[ 'in','number' , [$this->number]], ['in','rfid_key' ,[ $this->number]]])->one(); if ( $this->card != null ){ $this->customer = $this->card->customer; $this->readValidTickets(); diff --git a/frontend/views/account-state/_item_view.php b/frontend/views/account-state/_item_view.php index 7c58dce..2a6a080 100644 --- a/frontend/views/account-state/_item_view.php +++ b/frontend/views/account-state/_item_view.php @@ -1,13 +1,29 @@ $model, + 'index' => $index ]); + + + if ( $index == 0){ + + ?> +
+
+ +
+
+ diff --git a/frontend/views/layouts/main.php b/frontend/views/layouts/main.php index 121b260..677f614 100644 --- a/frontend/views/layouts/main.php +++ b/frontend/views/layouts/main.php @@ -12,6 +12,7 @@ use common\widgets\Alert; use common\components\FrotnendMenuStructure; use frontend\components\FrontendMenuStructure; use kartik\widgets\AlertBlock; +use yii\helpers\Url; AppAsset::register($this); ?> @@ -23,6 +24,9 @@ AppAsset::register($this); <?= Html::encode($this->title) ?> + head() ?> diff --git a/frontend/views/product/_customer_cart.php b/frontend/views/product/_customer_cart.php index 551d3d0..4efe0e1 100644 --- a/frontend/views/product/_customer_cart.php +++ b/frontend/views/product/_customer_cart.php @@ -37,4 +37,7 @@ use yii\bootstrap\Html;
'btn_pay_customer_cart', 'class' => 'btn btn-primary btn-block' , 'name' => 'payout_customer_cart']) ?>
+
+ 'btn btn-primary btn-block' , 'onclick' => 'location.reload();']) ?> +
\ No newline at end of file diff --git a/frontend/views/product/_user_cart.php b/frontend/views/product/_user_cart.php index 62416d5..d86edc8 100644 --- a/frontend/views/product/_user_cart.php +++ b/frontend/views/product/_user_cart.php @@ -40,4 +40,7 @@ use kartik\widgets\ActiveForm; 'btn_pay_user_cart', 'class' => 'btn btn-primary btn-block' , 'name' => 'payout_user_cart']) ?> +
+ 'btn btn-primary btn-block' , 'onclick' => 'location.reload();']) ?> +
\ No newline at end of file diff --git a/frontend/views/transfer/_view.php b/frontend/views/transfer/_view.php index d4d11e4..6417d0c 100644 --- a/frontend/views/transfer/_view.php +++ b/frontend/views/transfer/_view.php @@ -2,6 +2,7 @@ use yii\helpers\Html; use common\models\Transfer; +use yii\helpers\Url; /* @var $this yii\web\View */ @@ -63,6 +64,17 @@ $formatter = Yii::$app->formatter; +
+
+ Törlés', Url::toRoute(['delete','id' =>$model->id_transfer]), [ + 'title' => Yii::t('yii', 'Delete'), + 'data-confirm' => Yii::t('yii', 'Are you sure to delete this item?'), + 'data-method' => 'post', + 'class' => 'btn btn-danger', +// 'style' =>'margin-right: 12px;' + ]);?> +
+
diff --git a/frontend/web/js/app.js b/frontend/web/js/app.js new file mode 100644 index 0000000..d5184ea --- /dev/null +++ b/frontend/web/js/app.js @@ -0,0 +1,71 @@ +var enterPressed; +var keyDate; +var seq = ''; +$(document).ready( + function(){ + + $("input[name='number']").on('focus', function (e) { + $(this) + .one('mouseup', function () { + $(this).select(); + return false; + }) + .select(); + }); + + addDocumentKeypressedListener(); + } +); + + +function addDocumentKeypressedListener(){ + $( document ).keypress(function( event ) { + var tag = event.target.tagName.toLowerCase(); + if ( tag != 'input' && tag != 'textarea' && tag != 'select') { + + resetSequenceIfToMuchTimePassedOrEnterWasPressed(event); + + if ( event.which == 13 ) { + enterPressed = 1; + if ( seq ){ + $( document ).trigger( "wordtyped", [ { originalEvent: event, 'word': seq } ] ); + } + }else { + appendCharToSeq(event); + } + } + }); + + $( document ).on( "wordtyped", function( event, data ) { + var word; + word = data.word; + if ( word && word.length > 0){ + + location.href= reception_card_url +'&number=' + word; + + + } + }); + + function resetSequenceIfToMuchTimePassedOrEnterWasPressed(){ + var prevDate, timePassed; + prevDate= keyDate; + keyDate = new Date().getTime(); + timePassed = keyDate - prevDate; + if ( enterPressed > 0 || timePassed > 2000 ){ + seq = ''; + enterPressed = 0; + } + } + + function appendCharToSeq(event){ + var code,s; + code = event.which; + if ( code ){ + s = String.fromCharCode(code); + if ( s ) + seq += s; + } + } + +} diff --git a/frontend/web/js/product.sell.js b/frontend/web/js/product.sell.js index 0de8079..4972f0d 100644 --- a/frontend/web/js/product.sell.js +++ b/frontend/web/js/product.sell.js @@ -52,7 +52,7 @@ function ProductSell(o){ addPayoutButtons(); productChanged(); - addDocumentKeypressedListener(); +// addDocumentKeypressedListener(); initAutocomplete(); }