add transfer unstorno

This commit is contained in:
Roland Schneider 2016-04-11 21:21:47 +02:00
parent 1d95d37373
commit 01ada90e8c
8 changed files with 120 additions and 47 deletions

View File

@ -17,6 +17,7 @@ use common\models\Product;
use backend\models\TransferListUserGroupedSearch; use backend\models\TransferListUserGroupedSearch;
use backend\models\TransferLaterSearch; use backend\models\TransferLaterSearch;
use yii\helpers\Url; use yii\helpers\Url;
use common\components\Helper;
/** /**
* TransferController implements the CRUD actions for Transfer model. * TransferController implements the CRUD actions for Transfer model.
@ -26,6 +27,14 @@ class TransferController extends \backend\controllers\BackendController
public function behaviors() public function behaviors()
{ {
return [ return [
'verbs' => [
'class' => VerbFilter::className (),
'actions' => [
'unstorno' => [
'post'
]
]
],
'access' => [ 'access' => [
'class' => \yii\filters\AccessControl::className(), 'class' => \yii\filters\AccessControl::className(),
'rules' => [ 'rules' => [
@ -38,10 +47,17 @@ class TransferController extends \backend\controllers\BackendController
"sale", "sale",
"sale-pdf" , "sale-pdf" ,
'list-user-grouped', 'list-user-grouped',
'payment-later'], 'payment-later'
],
'allow' => true, 'allow' => true,
'roles' => ['admin','employee','reception'], 'roles' => ['admin','employee','reception'],
], ],
[
'actions' => [ 'unstorno',
],
'allow' => true,
'roles' => ['admin' ],
],
// everything else is denied // everything else is denied
], ],
], ],
@ -298,6 +314,18 @@ class TransferController extends \backend\controllers\BackendController
} }
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]);
}
/** /**
* Updates an existing Transfer model. * Updates an existing Transfer model.
* If update is successful, the browser will be redirected to the 'view' page. * If update is successful, the browser will be redirected to the 'view' page.

View File

@ -39,10 +39,10 @@ class TicketSearch extends Ticket
public function rules() public function rules()
{ {
return [ 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' ], [[ 'start', ], 'date' , 'timestampAttribute' => 'timestampStart' ,'timestampAttributeFormat' => 'yyyy-MM-dd' ],
[[ 'end' , ], 'date' , 'timestampAttribute' => 'timestampEnd' ,'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'] ,
]; ];
} }

View File

@ -34,6 +34,8 @@ class TransferSearch extends Transfer
public $types; public $types;
public $totals; public $totals;
public $customer_name;
/** /**
* @inheritdoc * @inheritdoc
*/ */
@ -41,6 +43,7 @@ class TransferSearch extends Transfer
{ {
return [ return [
[[ 'id_account','id_user', 'type','status','payment_method'], 'integer'], [[ 'id_account','id_user', 'type','status','payment_method'], 'integer'],
[['customer_name'],'safe'],
// [[ 'searchObjectName' ], 'string'], // [[ 'searchObjectName' ], 'string'],
// [[ 'start', ], 'date' , 'timestampAttribute' => 'timestampStart' ,'timestampAttributeFormat' => 'yyyy-MM-dd' ], // [[ 'start', ], 'date' , 'timestampAttribute' => 'timestampStart' ,'timestampAttributeFormat' => 'yyyy-MM-dd' ],
// [[ 'end' , ], 'date' , 'timestampAttribute' => 'timestampEnd' ,'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.type' => $this->type,
'transfer.status' => $this->status, 'transfer.status' => $this->status,
'transfer.payment_method' => $this->payment_method, 'transfer.payment_method' => $this->payment_method,
'customer.name' => $this->customer_name
]); ]);
$query->andFilterWhere(['in' ,'transfer.type', $this->types]); $query->andFilterWhere(['in' ,'transfer.type', $this->types]);

View File

@ -57,6 +57,9 @@ use kartik\widgets\DateTimePicker;
<div class='col-md-3'> <div class='col-md-3'>
<?= $form->field($model, 'payment_method')->dropDownList( ['' => "Mind"] + Transfer::paymentMethods() ) ?> <?= $form->field($model, 'payment_method')->dropDownList( ['' => "Mind"] + Transfer::paymentMethods() ) ?>
</div> </div>
<div class='col-md-3'>
<?= $form->field($model, 'customer_name')->label("Vendég") ?>
</div>
</div> </div>
<div class="form-group"> <div class="form-group">

View File

@ -1,56 +1,61 @@
<?php <?php
use yii\helpers\Html; use yii\helpers\Html;
use yii\widgets\DetailView; use yii\widgets\DetailView;
use common\components\RoleDefinition;
use common\models\Ticket;
use common\models\Transfer;
/* @var $this yii\web\View */ /* @var $this yii\web\View */
/* @var $model common\models\Transfer */ /* @var $model common\models\Transfer */
$this->title = $model->id_transfer; $this->title = $model->id_transfer;
$this->params['breadcrumbs'][] = ['label' => Yii::t('frontend/transfer', 'Transfers'), 'url' => ['index']]; $this->params ['breadcrumbs'] [] = [
$this->params['breadcrumbs'][] = $this->title; 'label' => Yii::t ( 'frontend/transfer', 'Transfers' ),
'url' => [
'index'
]
];
$this->params ['breadcrumbs'] [] = $this->title;
?> ?>
<div class="transfer-view"> <div class="transfer-view">
<h1><?= Html::encode($this->title) ?></h1> <h1><?= Html::encode($this->title) ?></h1>
<div class="row">
<?= DetailView::widget([ <div class="col-md-6">
'model' => $model, <?=DetailView::widget (
'attributes' => [ [ 'model' => $model,
[ 'attributes' => [
'attribute' => 'id_transfer', [ 'attribute' => 'id_transfer' ],
], [ 'attribute' => 'id_account','value' => $model->accountName ],
[ [ 'attribute' => 'type','value' => $model->transferTypeName ],
'attribute' => 'id_account', [ 'attribute' => 'id_object','value' => $model->objectName ],
'value' => $model->accountName [ 'attribute' => 'id_user','value' => $model->userName ],
], [ 'attribute' => 'id_discount','value' => $model->discountName ],
[ [ 'attribute' => 'payment_method','value' => $model->paymentMethodName ],
'attribute' => 'type', [ 'attribute' => 'status','value' => $model->statusName ],
'value' => $model->transferTypeName, 'item_price',
], 'count',
[ 'money',
'attribute' => 'id_object', 'comment',
'value' => $model->objectName, 'created_at',
], 'paid_at' ] ] )?>
[ </div>
'attribute' => 'id_user', </div>
'value' => $model->userName,
],
[
'attribute' => 'id_discount',
'value' => $model->discountName,
],
[
'attribute' => 'payment_method',
'value' => $model->paymentMethodName,
],
'item_price',
'count',
'money',
'comment',
'created_at',
'paid_at',
],
]) ?>
</div> </div>
<?php
if (RoleDefinition::isAdmin ()) {
if ($model->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'
] );
}
}
?>

View File

@ -1,3 +1,6 @@
-0.0.64
- admin add unstorno ticket
- admin transfer search by customer name
-0.0.63 -0.0.63
- admin edit ticket date - admin edit ticket date
-0.0.62 -0.0.62

View File

@ -4,7 +4,7 @@ return [
'supportEmail' => 'rocho02@gmail.com', 'supportEmail' => 'rocho02@gmail.com',
'infoEmail' => 'info@rocho-net.hu', 'infoEmail' => 'info@rocho-net.hu',
'user.passwordResetTokenExpire' => 3600, 'user.passwordResetTokenExpire' => 3600,
'version' => 'v0.0.63', 'version' => 'v0.0.64',
'company' => 'movar',//gyor 'company' => 'movar',//gyor
'company_name' => "Freimann Kft.", 'company_name' => "Freimann Kft.",
'product_visiblity' => 'account',// on reception which products to display. account or global 'product_visiblity' => 'account',// on reception which products to display. account or global

View File

@ -960,6 +960,36 @@ class Transfer extends \common\models\BaseFitnessActiveRecord {
ShoppingCart::deleteAll(['id_transfer' => $this->id_transfer]); ShoppingCart::deleteAll(['id_transfer' => $this->id_transfer]);
UserSoldItem::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) { public function payout($id_account = null) {
if ($this->status != Transfer::STATUS_NOT_PAID) { if ($this->status != Transfer::STATUS_NOT_PAID) {