add admin edit ticket date
This commit is contained in:
@@ -20,6 +20,11 @@ use common\components\TicketSale;
|
||||
use common\models\Contract;
|
||||
use common\components\giro\GiroDETSTATetel;
|
||||
use common\components\DetStatTetelProcessor;
|
||||
use yii\helpers\VarDumper;
|
||||
use backend\models\TicketUpdate;
|
||||
use yii\helpers\Url;
|
||||
use frontend\components\HtmlHelper;
|
||||
use common\components\Helper;
|
||||
|
||||
/**
|
||||
* TicketController implements the CRUD actions for Ticket model.
|
||||
@@ -143,6 +148,8 @@ class TicketController extends \backend\controllers\BackendController {
|
||||
$searchModel->accounts = Account::read ();
|
||||
$searchModel->ticketTypes = TicketType::read ();
|
||||
|
||||
Url::remember(Url::current(),"ticket_index_customer");
|
||||
|
||||
return $this->render ( 'index_customer', [
|
||||
'searchModel' => $searchModel,
|
||||
'dataProvider' => $dataProvider,
|
||||
@@ -199,9 +206,28 @@ class TicketController extends \backend\controllers\BackendController {
|
||||
* @return mixed
|
||||
*/
|
||||
public function actionUpdate($id) {
|
||||
$model = $this->findModel ( $id );
|
||||
$model = TicketUpdate::findOne( $id );
|
||||
|
||||
|
||||
$model->startDate = substr( $model->start ,0 ,10 );
|
||||
$model->endDate = substr( $model->end ,0 ,10 );
|
||||
|
||||
$model->startDate = \Yii::$app->formatter->asDate($model->startDate);
|
||||
$model->endDate = \Yii::$app->formatter->asDate($model->endDate);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if ($model->load ( Yii::$app->request->post () ) && $model->save ()) {
|
||||
|
||||
Helper::flash("success", "Bérlet sikeresen módosítva");
|
||||
|
||||
$url = Url::previous("ticket_index_customer");
|
||||
|
||||
if ( isset($url) ){
|
||||
return $this->redirect($url);
|
||||
}
|
||||
return $this->redirect ( [
|
||||
'view',
|
||||
'id' => $model->id_ticket
|
||||
@@ -211,6 +237,8 @@ class TicketController extends \backend\controllers\BackendController {
|
||||
'model' => $model
|
||||
] );
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
43
backend/models/TicketUpdate.php
Normal file
43
backend/models/TicketUpdate.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
namespace backend\models;
|
||||
|
||||
|
||||
use common\models\Ticket;
|
||||
class TicketUpdate extends Ticket{
|
||||
|
||||
|
||||
public $startDate;
|
||||
public $endDate;
|
||||
|
||||
public $timestampStart;
|
||||
public $timestampEnd;
|
||||
|
||||
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['comment'], 'required'],
|
||||
[['comment'], 'string', 'max' => 255],
|
||||
[[ 'startDate','endDate' ], 'required'],
|
||||
[[ 'startDate', ], 'date' , 'timestampAttribute' => 'timestampStart' ,'timestampAttributeFormat' => 'yyyy-MM-dd' ],
|
||||
[[ 'endDate' , ], 'date' , 'timestampAttribute' => 'timestampEnd' ,'timestampAttributeFormat' => 'yyyy-MM-dd' ],
|
||||
[['status',], 'integer'],
|
||||
[['status',], 'in', 'range' => [ static ::STATUS_ACTIVE, static ::STATUS_INACTIVE ]],
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
public function beforeSave($insert){
|
||||
if ( $insert ){
|
||||
return false;
|
||||
}
|
||||
if ( parent::beforeSave($insert)){
|
||||
$this->start = $this->startDate;
|
||||
$this->end = $this->endDate;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -147,7 +147,6 @@ class TransferSearch extends Transfer
|
||||
$query->andFilterWhere([
|
||||
'transfer.id_account' => $this->id_account,
|
||||
'transfer.type' => $this->type,
|
||||
'transfer.id_user' => $this->id_user,
|
||||
'transfer.status' => $this->status,
|
||||
'transfer.payment_method' => $this->payment_method,
|
||||
]);
|
||||
@@ -159,6 +158,15 @@ class TransferSearch extends Transfer
|
||||
|
||||
$query->andFilterWhere(['or' , $created_condition , $paid_condition]);
|
||||
|
||||
if ( isset($this->id_user)){
|
||||
$query->andFilterWhere([
|
||||
'or',
|
||||
['transfer.id_user' => $this->id_user],
|
||||
['transfer.paid_by' => $this->id_user],
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
if (!RoleDefinition::isAdmin()){
|
||||
Helper::restrictIfNotAdminTheStartDate($query, $this->timestampStart,['transfer.created_at','transfer.paid_at']);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
use yii\widgets\ActiveForm;
|
||||
use kartik\widgets\DatePicker;
|
||||
use common\models\Ticket;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model common\models\Ticket */
|
||||
@@ -12,34 +13,35 @@ use yii\widgets\ActiveForm;
|
||||
|
||||
<?php $form = ActiveForm::begin(); ?>
|
||||
|
||||
<?= $form->field($model, 'id_user')->textInput() ?>
|
||||
|
||||
<?= $form->field($model, 'id_ticket_type')->textInput() ?>
|
||||
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<?=$form->field ( $model, 'startDate' )
|
||||
->widget ( DatePicker::classname (), [ 'pluginOptions' => [ 'autoclose' => true,'format' => 'yyyy.mm.dd' ] ] )?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<?=$form->field ( $model, 'endDate' )->widget ( DatePicker::classname (), [ 'pluginOptions' => [ 'autoclose' => true,'format' => 'yyyy.mm.dd' ] ] )?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?= $form->field($model, 'id_account')->textInput() ?>
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<?= $form->field($model, 'status')->dropDownList(Ticket::statuses())?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<?= $form->field($model, 'comment')->textInput(['maxlength' => true])?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?= $form->field($model, 'id_discount')->textInput() ?>
|
||||
|
||||
<?= $form->field($model, 'start')->textInput() ?>
|
||||
|
||||
<?= $form->field($model, 'end')->textInput() ?>
|
||||
|
||||
<?= $form->field($model, 'max_usage_count')->textInput() ?>
|
||||
|
||||
<?= $form->field($model, 'usage_count')->textInput() ?>
|
||||
|
||||
<?= $form->field($model, 'status')->textInput() ?>
|
||||
|
||||
<?= $form->field($model, 'price_brutto')->textInput() ?>
|
||||
|
||||
<?= $form->field($model, 'comment')->textInput(['maxlength' => true]) ?>
|
||||
|
||||
<?= $form->field($model, 'created_at')->textInput() ?>
|
||||
|
||||
<?= $form->field($model, 'updated_at')->textInput() ?>
|
||||
|
||||
<div class="form-group">
|
||||
<?= Html::submitButton($model->isNewRecord ? Yii::t('common/ticket', 'Create') : Yii::t('common/ticket', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
|
||||
<div class="form-group">
|
||||
<?= Html::submitButton($model->isNewRecord ? Yii::t('common/ticket', 'Create') : Yii::t('common/ticket', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary'])?>
|
||||
</div>
|
||||
|
||||
<?php ActiveForm::end(); ?>
|
||||
|
||||
@@ -134,10 +134,12 @@ $this->params['breadcrumbs'][] = "Befizetések";
|
||||
// 'usage_count',
|
||||
|
||||
['class' => 'yii\grid\ActionColumn',
|
||||
'template' => '{view}' ,
|
||||
'template' => '{view} {update}' ,
|
||||
'urlCreator' => function($action, $model, $key, $index){
|
||||
if ( $action == 'view' ){
|
||||
return Url::toRoute( [ 'ticket/view' , 'id' => $model['ticket_id_ticket' ] ] );
|
||||
}else if ( $action == 'update' ){
|
||||
return Url::toRoute( [ 'ticket/update' , 'id' => $model['ticket_id_ticket' ] ] );
|
||||
}
|
||||
return null;
|
||||
},
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
use yii\widgets\DetailView;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model common\models\Ticket */
|
||||
|
||||
$this->title = Yii::t('common/ticket', 'Update {modelClass}: ', [
|
||||
'modelClass' => 'Ticket',
|
||||
]) . ' ' . $model->id_ticket;
|
||||
$this->title = Yii::t('common/ticket', 'Bérlet módosítása');
|
||||
$this->params['breadcrumbs'][] = ['label' => Yii::t('common/ticket', 'Tickets'), 'url' => ['index']];
|
||||
$this->params['breadcrumbs'][] = ['label' => $model->id_ticket, 'url' => ['view', 'id' => $model->id_ticket]];
|
||||
$this->params['breadcrumbs'][] = Yii::t('common/ticket', 'Update');
|
||||
@@ -15,9 +14,51 @@ $this->params['breadcrumbs'][] = Yii::t('common/ticket', 'Update');
|
||||
<div class="ticket-update">
|
||||
|
||||
<h1><?= Html::encode($this->title) ?></h1>
|
||||
|
||||
<?= $this->render('_form', [
|
||||
|
||||
<?= $this->render('_form', [
|
||||
'model' => $model,
|
||||
]) ?>
|
||||
|
||||
<?= DetailView::widget([
|
||||
'model' => $model,
|
||||
'attributes' => [
|
||||
'id_ticket',
|
||||
[
|
||||
'attribute' => 'id_user',
|
||||
'value' => $model->user->username,
|
||||
|
||||
],
|
||||
[
|
||||
'attribute' => 'id_ticket_type',
|
||||
'value' => $model->ticketTypeName,
|
||||
|
||||
],
|
||||
[
|
||||
'attribute' => 'id_account',
|
||||
'value' => $model->accountName,
|
||||
|
||||
],
|
||||
[
|
||||
'attribute' => 'id_discount',
|
||||
'value' => $model->discountName,
|
||||
|
||||
],
|
||||
'start:datetime',
|
||||
'end:datetime',
|
||||
'max_usage_count',
|
||||
'usage_count',
|
||||
[
|
||||
'attribute' => 'status',
|
||||
'value' => $model->statusName
|
||||
],
|
||||
'price_brutto',
|
||||
'comment:raw',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
],
|
||||
]) ?>
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user