diff --git a/backend/controllers/TicketController.php b/backend/controllers/TicketController.php
index ae33b86..1d1505b 100644
--- a/backend/controllers/TicketController.php
+++ b/backend/controllers/TicketController.php
@@ -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
] );
}
+
+
}
/**
diff --git a/backend/models/TicketUpdate.php b/backend/models/TicketUpdate.php
new file mode 100644
index 0000000..c98b9d0
--- /dev/null
+++ b/backend/models/TicketUpdate.php
@@ -0,0 +1,43 @@
+ 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;
+ }
+
+
+}
\ No newline at end of file
diff --git a/backend/models/TransferSearch.php b/backend/models/TransferSearch.php
index 16b1ace..20126bc 100644
--- a/backend/models/TransferSearch.php
+++ b/backend/models/TransferSearch.php
@@ -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']);
}
diff --git a/backend/views/ticket/_form.php b/backend/views/ticket/_form.php
index d984294..df04240 100644
--- a/backend/views/ticket/_form.php
+++ b/backend/views/ticket/_form.php
@@ -1,7 +1,8 @@
- = $form->field($model, 'id_user')->textInput() ?>
- = $form->field($model, 'id_ticket_type')->textInput() ?>
+
+
+
+
+ =$form->field ( $model, 'startDate' )
+ ->widget ( DatePicker::classname (), [ 'pluginOptions' => [ 'autoclose' => true,'format' => 'yyyy.mm.dd' ] ] )?>
+
+
+
+
+ =$form->field ( $model, 'endDate' )->widget ( DatePicker::classname (), [ 'pluginOptions' => [ 'autoclose' => true,'format' => 'yyyy.mm.dd' ] ] )?>
+
+
- = $form->field($model, 'id_account')->textInput() ?>
+
+
+ = $form->field($model, 'status')->dropDownList(Ticket::statuses())?>
+
+
+
+
+ = $form->field($model, 'comment')->textInput(['maxlength' => true])?>
+
+
- = $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() ?>
-
-
- = Html::submitButton($model->isNewRecord ? Yii::t('common/ticket', 'Create') : Yii::t('common/ticket', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
+
+ = Html::submitButton($model->isNewRecord ? Yii::t('common/ticket', 'Create') : Yii::t('common/ticket', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary'])?>
diff --git a/backend/views/ticket/index_customer.php b/backend/views/ticket/index_customer.php
index 24bd598..9c68e4f 100644
--- a/backend/views/ticket/index_customer.php
+++ b/backend/views/ticket/index_customer.php
@@ -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;
},
diff --git a/backend/views/ticket/update.php b/backend/views/ticket/update.php
index 09f838a..0c99c15 100644
--- a/backend/views/ticket/update.php
+++ b/backend/views/ticket/update.php
@@ -1,13 +1,12 @@
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');
= Html::encode($this->title) ?>
-
- = $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',
+ ],
+ ]) ?>
+
+
+
diff --git a/changelog.txt b/changelog.txt
index 86e9b1e..740691f 100644
--- a/changelog.txt
+++ b/changelog.txt
@@ -1,3 +1,5 @@
+-0.0.63
+ - admin edit ticket date
-0.0.62
- add botond daily
-0.0.61
diff --git a/common/components/DetStatTetelProcessor.php b/common/components/DetStatTetelProcessor.php
index 07b6e57..3f2f280 100644
--- a/common/components/DetStatTetelProcessor.php
+++ b/common/components/DetStatTetelProcessor.php
@@ -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 ();
diff --git a/common/config/params.php b/common/config/params.php
index 3c3bad0..4eb044b 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.62',
+ 'version' => 'v0.0.63',
'company' => 'movar',//gyor
'company_name' => "Freimann Kft.",
'product_visiblity' => 'account',// on reception which products to display. account or global
diff --git a/common/models/Card.php b/common/models/Card.php
index eda0f6a..f6160ea 100644
--- a/common/models/Card.php
+++ b/common/models/Card.php
@@ -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();
diff --git a/common/models/MessageDetsta.php b/common/models/MessageDetsta.php
index 76f5497..08071b4 100644
--- a/common/models/MessageDetsta.php
+++ b/common/models/MessageDetsta.php
@@ -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
diff --git a/common/models/Ticket.php b/common/models/Ticket.php
index 2da5f06..7a25bb4 100644
--- a/common/models/Ticket.php
+++ b/common/models/Ticket.php
@@ -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);;
}
+
+
}
diff --git a/console/migrations/m160409_173920_add_flag_out.php b/console/migrations/m160409_173920_add_flag_out.php
new file mode 100644
index 0000000..515ceba
--- /dev/null
+++ b/console/migrations/m160409_173920_add_flag_out.php
@@ -0,0 +1,31 @@
+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()
+ {
+ }
+ */
+}