add admin edit ticket date
This commit is contained in:
parent
440b7bb787
commit
1d95d37373
@ -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() ?>
|
||||
|
||||
<?= $form->field($model, 'id_account')->textInput() ?>
|
||||
|
||||
<?= $form->field($model, 'id_discount')->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, 'start')->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, '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');
|
||||
@ -16,8 +15,50 @@ $this->params['breadcrumbs'][] = Yii::t('common/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>
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
-0.0.63
|
||||
- admin edit ticket date
|
||||
-0.0.62
|
||||
- add botond daily
|
||||
-0.0.61
|
||||
|
||||
@ -63,6 +63,11 @@ class DetStatTetelProcessor extends Object {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( !isset($this->tetel)){
|
||||
\Yii::info('A megbízás feldolgozásának megszakítása. Nincs valaszsor a detsta üzenetben');
|
||||
return;
|
||||
}
|
||||
|
||||
$this->rememberEredetiMegbizasStatus();
|
||||
$this->readContract();
|
||||
$this->extractKodAndStatus ();
|
||||
|
||||
@ -4,7 +4,7 @@ return [
|
||||
'supportEmail' => 'rocho02@gmail.com',
|
||||
'infoEmail' => 'info@rocho-net.hu',
|
||||
'user.passwordResetTokenExpire' => 3600,
|
||||
'version' => 'v0.0.62',
|
||||
'version' => 'v0.0.63',
|
||||
'company' => 'movar',//gyor
|
||||
'company_name' => "Freimann Kft.",
|
||||
'product_visiblity' => 'account',// on reception which products to display. account or global
|
||||
|
||||
@ -171,6 +171,9 @@ class Card extends \common\models\BaseFitnessActiveRecord
|
||||
}
|
||||
|
||||
public static function updateCardFlagTicket($id){
|
||||
if ( !isset($id)){
|
||||
return ;
|
||||
}
|
||||
$db = \Yii::$app->db;
|
||||
$command = $db->createCommand(Ticket::$SQL_UPDATE_CARD,[':id' => $id]);
|
||||
$command->execute();
|
||||
|
||||
@ -4,6 +4,7 @@ namespace common\models;
|
||||
|
||||
use Yii;
|
||||
use common\components\giro\GiroDETSTA;
|
||||
use yii\db\BaseActiveRecord;
|
||||
|
||||
/**
|
||||
* This is the model class for table "message_detsta".
|
||||
@ -14,7 +15,7 @@ use common\components\giro\GiroDETSTA;
|
||||
* @property string $created_at
|
||||
* @property string $updated_at
|
||||
*/
|
||||
class MessageDetsta extends \yii\db\ActiveRecord
|
||||
class MessageDetsta extends BaseFitnessActiveRecord
|
||||
{
|
||||
/**
|
||||
* @inheritdoc
|
||||
|
||||
@ -85,7 +85,12 @@ class Ticket extends \common\models\BaseFitnessActiveRecord
|
||||
[[ 'id_user', 'id_ticket_type', 'id_account', 'id_discount', 'max_usage_count', 'usage_count', 'status', 'price_brutto'], 'integer'],
|
||||
[['start', 'end', 'created_at', 'updated_at'], 'safe'],
|
||||
[['comment'], 'required'],
|
||||
[['comment'], 'string', 'max' => 255]
|
||||
[['comment'], 'string', 'max' => 255],
|
||||
|
||||
[[ 'start', ], 'date' , 'timestampAttribute' => 'timestampStart' ,'timestampAttributeFormat' => 'yyyy-MM-dd' ],
|
||||
[[ 'end' , ], 'date' , 'timestampAttribute' => 'timestampEnd' ,'timestampAttributeFormat' => 'yyyy-MM-dd' ],
|
||||
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
@ -215,20 +220,7 @@ class Ticket extends \common\models\BaseFitnessActiveRecord
|
||||
|
||||
|
||||
public static function mkStatisticQuery($start,$end,$id_card = null){
|
||||
// $sql = "select
|
||||
// ticket_type.name,
|
||||
// count(ticket.id_ticket) as total ,
|
||||
// sum(case when ticket.end > '2015-11-05' and ticket.start <= '2015-11-05' then 1 else 0 end) as valid,
|
||||
// sum(case when ticket.created_at < '2015-11-06' and ticket.created_at >= '2015-11-05' then 1 else 0 end) as created,
|
||||
// sum(case when ticket.created_at < '2015-11-06' and ticket.created_at >= '2015-11-05' then transfer.money else 0 end) as created_money,
|
||||
// sum(case when ticket.created_at < '2015-11-06' and ticket.created_at >= '2015-11-05' and transfer.paid_at is not null then transfer.money else 0 end) as created_money_paid,
|
||||
// sum(case when ticket.created_at < '2015-11-06' and ticket.created_at >= '2015-11-05' and transfer.paid_at is null then transfer.money else 0 end) as created_money_not_paid,
|
||||
// sum(case when ticket.created_at >= '2015-11-06' and ticket.created_at < '2015-11-05' and transfer.paid_at < '2015-11-06' and transfer.paid_at >= '2015-11-05' then transfer.money else 0 end) as dept_paid,
|
||||
// sum(case when ticket.end < '2015-11-06' and ticket.created_at >= '2015-11-05' then 1 else 0 end) as expired
|
||||
// from ticket_type
|
||||
// inner join ticket on ticket.id_ticket_type = ticket_type.id_ticket_type
|
||||
// inner join transfer on ticket.id_ticket = transfer.id_object and transfer.type = 20
|
||||
// group by ticket_type.name;";
|
||||
|
||||
|
||||
$query = new Query();
|
||||
$query->addSelect( [
|
||||
@ -353,4 +345,6 @@ class Ticket extends \common\models\BaseFitnessActiveRecord
|
||||
Card::updateCardFlagTicket($this->id_card);;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
31
console/migrations/m160409_173920_add_flag_out.php
Normal file
31
console/migrations/m160409_173920_add_flag_out.php
Normal file
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
use yii\db\Schema;
|
||||
use yii\db\Migration;
|
||||
|
||||
class m160409_173920_add_flag_out extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
$this->addColumn("door_log", "flag_out", "int default 0");
|
||||
$this->addColumn("card", "flag_out", "int default 0");
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
echo "m160409_173920_add_flag_out cannot be reverted.\n";
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
// Use safeUp/safeDown to run migration code within a transaction
|
||||
public function safeUp()
|
||||
{
|
||||
}
|
||||
|
||||
public function safeDown()
|
||||
{
|
||||
}
|
||||
*/
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user