diff --git a/backend/controllers/TransferController.php b/backend/controllers/TransferController.php index d19769c..b768be5 100644 --- a/backend/controllers/TransferController.php +++ b/backend/controllers/TransferController.php @@ -17,6 +17,7 @@ use common\models\Product; use backend\models\TransferListUserGroupedSearch; use backend\models\TransferLaterSearch; use yii\helpers\Url; +use common\components\Helper; /** * TransferController implements the CRUD actions for Transfer model. @@ -26,6 +27,14 @@ class TransferController extends \backend\controllers\BackendController public function behaviors() { return [ + 'verbs' => [ + 'class' => VerbFilter::className (), + 'actions' => [ + 'unstorno' => [ + 'post' + ] + ] + ], 'access' => [ 'class' => \yii\filters\AccessControl::className(), 'rules' => [ @@ -38,10 +47,17 @@ class TransferController extends \backend\controllers\BackendController "sale", "sale-pdf" , 'list-user-grouped', - 'payment-later'], + 'payment-later' + ], 'allow' => true, 'roles' => ['admin','employee','reception'], ], + [ + 'actions' => [ 'unstorno', + ], + 'allow' => true, + 'roles' => ['admin' ], + ], // everything else is denied ], ], @@ -296,6 +312,18 @@ class TransferController extends \backend\controllers\BackendController 'model' => $this->findModel($id), ]); } + + + public function actionUnstorno($id) + { + $model = $this->findModel($id); + + $model->unstorono(); + + Helper::flash("success", "Bérlet visszaállítva"); + + return $this->redirect( ['view' ,'id' => $model->id_transfer]); + } /** diff --git a/backend/models/TicketSearch.php b/backend/models/TicketSearch.php index 963be67..3c2d59e 100644 --- a/backend/models/TicketSearch.php +++ b/backend/models/TicketSearch.php @@ -39,10 +39,10 @@ class TicketSearch extends Ticket public function rules() { return [ - [[ 'id_ticket', 'id_user', 'id_ticket_type', 'id_account','status'], 'integer'], + [[ 'id_ticket', 'id_user', 'id_ticket_type', 'id_account','status'], 'integer'], [[ 'start', ], 'date' , 'timestampAttribute' => 'timestampStart' ,'timestampAttributeFormat' => 'yyyy-MM-dd' ], [[ 'end' , ], 'date' , 'timestampAttribute' => 'timestampEnd' ,'timestampAttributeFormat' => 'yyyy-MM-dd' ], - [['valid_in_interval','created_in_interval','expire_in_interval'],'boolean'] , + [[ 'valid_in_interval','created_in_interval','expire_in_interval'],'boolean'] , ]; } diff --git a/backend/models/TransferSearch.php b/backend/models/TransferSearch.php index 20126bc..016809e 100644 --- a/backend/models/TransferSearch.php +++ b/backend/models/TransferSearch.php @@ -34,6 +34,8 @@ class TransferSearch extends Transfer public $types; public $totals; + public $customer_name; + /** * @inheritdoc */ @@ -41,6 +43,7 @@ class TransferSearch extends Transfer { return [ [[ 'id_account','id_user', 'type','status','payment_method'], 'integer'], + [['customer_name'],'safe'], // [[ 'searchObjectName' ], 'string'], // [[ 'start', ], 'date' , 'timestampAttribute' => 'timestampStart' ,'timestampAttributeFormat' => 'yyyy-MM-dd' ], // [[ 'end' , ], 'date' , 'timestampAttribute' => 'timestampEnd' ,'timestampAttributeFormat' => 'yyyy-MM-dd' ], @@ -149,6 +152,7 @@ class TransferSearch extends Transfer 'transfer.type' => $this->type, 'transfer.status' => $this->status, 'transfer.payment_method' => $this->payment_method, + 'customer.name' => $this->customer_name ]); $query->andFilterWhere(['in' ,'transfer.type', $this->types]); diff --git a/backend/views/transfer/_search.php b/backend/views/transfer/_search.php index b229135..b3fd8d8 100644 --- a/backend/views/transfer/_search.php +++ b/backend/views/transfer/_search.php @@ -57,6 +57,9 @@ use kartik\widgets\DateTimePicker;
field($model, 'payment_method')->dropDownList( ['' => "Mind"] + Transfer::paymentMethods() ) ?>
+
+ field($model, 'customer_name')->label("Vendég") ?> +
diff --git a/backend/views/transfer/view.php b/backend/views/transfer/view.php index 6b1ac83..453e37a 100644 --- a/backend/views/transfer/view.php +++ b/backend/views/transfer/view.php @@ -1,56 +1,61 @@ title = $model->id_transfer; -$this->params['breadcrumbs'][] = ['label' => Yii::t('frontend/transfer', 'Transfers'), 'url' => ['index']]; -$this->params['breadcrumbs'][] = $this->title; +$this->params ['breadcrumbs'] [] = [ + 'label' => Yii::t ( 'frontend/transfer', 'Transfers' ), + 'url' => [ + 'index' + ] +]; +$this->params ['breadcrumbs'] [] = $this->title; ?>
-

title) ?>

- - $model, - 'attributes' => [ - [ - 'attribute' => 'id_transfer', - ], - [ - 'attribute' => 'id_account', - 'value' => $model->accountName - ], - [ - 'attribute' => 'type', - 'value' => $model->transferTypeName, - ], - [ - 'attribute' => 'id_object', - 'value' => $model->objectName, - ], - [ - 'attribute' => 'id_user', - 'value' => $model->userName, - ], - [ - 'attribute' => 'id_discount', - 'value' => $model->discountName, - ], - [ - 'attribute' => 'payment_method', - 'value' => $model->paymentMethodName, - ], - 'item_price', - 'count', - 'money', - 'comment', - 'created_at', - 'paid_at', - ], - ]) ?> +

title) ?>

+
+
+ $model, + 'attributes' => [ + [ 'attribute' => 'id_transfer' ], + [ 'attribute' => 'id_account','value' => $model->accountName ], + [ 'attribute' => 'type','value' => $model->transferTypeName ], + [ 'attribute' => 'id_object','value' => $model->objectName ], + [ 'attribute' => 'id_user','value' => $model->userName ], + [ 'attribute' => 'id_discount','value' => $model->discountName ], + [ 'attribute' => 'payment_method','value' => $model->paymentMethodName ], + [ 'attribute' => 'status','value' => $model->statusName ], + 'item_price', + 'count', + 'money', + 'comment', + 'created_at', + 'paid_at' ] ] )?> +
+
+ +status == Transfer::STATUS_STORNO) { + echo Html::a ( "Bérlet fizetetlennek jelölése és vásárló kosarába helyezése", [ + 'transfer/unstorno', + 'id' => $model->id_transfer + ], [ + 'class' => 'btn btn-danger', + 'data-confirm' => "Figyelem, a bérlet fizetetlennek lesz jelölve !!", + 'data-method' => 'post' + ] ); + } +} +?> diff --git a/changelog.txt b/changelog.txt index 740691f..6d8dfe9 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,6 @@ +-0.0.64 + - admin add unstorno ticket + - admin transfer search by customer name -0.0.63 - admin edit ticket date -0.0.62 diff --git a/common/config/params.php b/common/config/params.php index 4eb044b..338a0c8 100644 --- a/common/config/params.php +++ b/common/config/params.php @@ -4,7 +4,7 @@ return [ 'supportEmail' => 'rocho02@gmail.com', 'infoEmail' => 'info@rocho-net.hu', 'user.passwordResetTokenExpire' => 3600, - 'version' => 'v0.0.63', + 'version' => 'v0.0.64', 'company' => 'movar',//gyor 'company_name' => "Freimann Kft.", 'product_visiblity' => 'account',// on reception which products to display. account or global diff --git a/common/models/Transfer.php b/common/models/Transfer.php index 8a18981..3894daa 100644 --- a/common/models/Transfer.php +++ b/common/models/Transfer.php @@ -960,6 +960,36 @@ class Transfer extends \common\models\BaseFitnessActiveRecord { ShoppingCart::deleteAll(['id_transfer' => $this->id_transfer]); UserSoldItem::deleteAll(['id_transfer' => $this->id_transfer]); } + + public function unstorono(){ + + if ($this->type != Transfer::TYPE_TICKET) { + throw new NotAcceptableHttpException("Csak bérletet lehet visszaállítani"); + } + + $this->status = Transfer::STATUS_NOT_PAID; + $this->paid_at = null; + $this->paid_by = null; + $this->save ( false ); + + $ticket = $this->ticket; + $ticket->status = Ticket::STATUS_ACTIVE; + + $ticket->save ( false ); + + TicketInstallmentRequest::updateAll ( [ + 'status' => TicketInstallmentRequest::$STATUS_ACCEPTED_MANUAL + ], [ + 'id_ticket' => $ticket->id_ticket + ] ); + + + $item = new ShoppingCart(); + $item->id_customer = $this->id_customer; + $item->id_transfer = $this->id_transfer; + $item->save(false); + } + public function payout($id_account = null) { if ($this->status != Transfer::STATUS_NOT_PAID) {