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){ + + ?> +