From a2a6b1f24073604ba36708231da2f248c483f221 Mon Sep 17 00:00:00 2001 From: Roland Schneider Date: Fri, 22 Jan 2016 14:45:56 +0100 Subject: [PATCH] add ticket installment --- .gitignore | 7 +- backend/0209ch7z.det | 5 + backend/components/AdminMenuStructure.php | 2 + .../TicketInstallmentRequestController.php | 20 ++ backend/controllers/UgiroController.php | 64 +++++ backend/detsta.txt | 5 + backend/models/DestaUploadForm.php | 68 ++++++ backend/models/GiroKotegForm.php | 20 +- .../models/TicketInstallmentRequestSearch.php | 10 +- backend/models/TicketSearch.php | 5 +- .../_index_view.php | 56 ++++- .../ticket-installment-request/_search.php | 9 +- .../ticket-installment-request/index.php | 7 + .../views/ticket-installment-request/view.php | 224 +++++++++++++++--- backend/views/ticket/_search.php | 10 + backend/views/ticket/index.php | 4 + backend/views/ticket/view.php | 35 ++- backend/views/ugiro/detsta.php | 26 ++ backend/views/ugiro/upload.php | 27 +++ backend/views/ugiro/view.php | 43 +++- backend/web/giro/megbizas/.gitkeep | 0 backend/web/giro/valasz/.gitkeep | 0 common/components/DetStatProcessor.php | 137 +++++++++++ common/components/DetStatTetelProcessor.php | 129 ++++++++++ common/components/giro/GiroBase.php | 4 +- common/components/giro/GiroBeszed.php | 33 ++- common/components/giro/GiroDETSTA.php | 20 +- common/components/giro/GiroDETSTAFej.php | 2 +- common/components/giro/GiroDETSTALab.php | 2 + common/components/giro/GiroDETSTATetel.php | 12 +- common/models/AccountState.php | 3 +- common/models/MoneyMovement.php | 22 ++ common/models/Sale.php | 23 ++ common/models/Ticket.php | 71 +++++- common/models/TicketInstallmentRequest.php | 98 +++++++- common/models/Transfer.php | 26 +- common/models/Ugiro.php | 17 +- ...le__money_movement__add_column__status.php | 30 +++ ...ble__ticket__add_part__and__parts_paid.php | 32 +++ ...2_alter__table__ugiro__add__desta_path.php | 30 +++ ...9_alter__table__ugiro__uzenet__sorszam.php | 28 +++ .../controllers/AccountStateController.php | 2 +- frontend/controllers/TicketController.php | 39 ++- frontend/controllers/TransferController.php | 13 +- frontend/models/TicketCreate.php | 30 +++ frontend/models/TicketUpdate.php | 25 ++ frontend/views/money-movement/index.php | 5 + frontend/views/ticket/_form_update.php | 84 +++++++ frontend/views/ticket/index.php | 35 ++- frontend/views/ticket/update.php | 6 +- frontend/views/transfer/_view.php | 6 +- 51 files changed, 1498 insertions(+), 113 deletions(-) create mode 100644 backend/0209ch7z.det create mode 100644 backend/detsta.txt create mode 100644 backend/models/DestaUploadForm.php create mode 100644 backend/views/ugiro/detsta.php create mode 100644 backend/views/ugiro/upload.php create mode 100644 backend/web/giro/megbizas/.gitkeep create mode 100644 backend/web/giro/valasz/.gitkeep create mode 100644 common/components/DetStatProcessor.php create mode 100644 common/components/DetStatTetelProcessor.php create mode 100644 console/migrations/m160120_224044_alter__table__money_movement__add_column__status.php create mode 100644 console/migrations/m160121_083841_alter__table__ticket__add_part__and__parts_paid.php create mode 100644 console/migrations/m160121_183512_alter__table__ugiro__add__desta_path.php create mode 100644 console/migrations/m160121_192759_alter__table__ugiro__uzenet__sorszam.php create mode 100644 frontend/models/TicketUpdate.php create mode 100644 frontend/views/ticket/_form_update.php diff --git a/.gitignore b/.gitignore index 1d62e63..4f9d1fa 100644 --- a/.gitignore +++ b/.gitignore @@ -33,4 +33,9 @@ phpunit.phar /frontend/web/profile/** !/frontend/web/profile/.gitkeep -/frontend/web/uploads/** \ No newline at end of file +/frontend/web/uploads/** + +/backend/web/giro/megbizas/** +!/backend/web/giro/megbizas/.gitkeep +/backend/web/giro/valasz/** +!/backend/web/giro/valasz/.gitkeep \ No newline at end of file diff --git a/backend/0209ch7z.det b/backend/0209ch7z.det new file mode 100644 index 0000000..20598c0 --- /dev/null +++ b/backend/0209ch7z.det @@ -0,0 +1,5 @@ +01DETSTA8A24237545 201501270001201502094542162957 +020000010000014097201501270020150204201502031104 03916201502031001307001595 0015520150127321538700000000000000000000000340 +020000020000015240201501275020150204 1117 73377201502033417908001595 0015520150127321538800000000000000000000000347 +020000030000015240201501270020150204201502031120 94002201502030005151001595 0015520150127321538900000000000000000000000176 +03000002000000000002933700000100000000000152400000000000000000000000 diff --git a/backend/components/AdminMenuStructure.php b/backend/components/AdminMenuStructure.php index 159836c..9ce79b9 100644 --- a/backend/components/AdminMenuStructure.php +++ b/backend/components/AdminMenuStructure.php @@ -111,6 +111,8 @@ class AdminMenuStructure{ $items[] = ['label' => 'Giro kötegbe jelölés', 'url' => ['/ticket-installment-request/pending' , 'TicketInstallmentRequestSearchPending[end]' => $tomorrow ] ]; $items[] = ['label' => 'GIRO köteg létrehozás', 'url' => ['/ticket-installment-request/download-giro' ] ]; $items[] = ['label' => 'GIRO kötegek', 'url' => ['/ugiro/index' ] ]; + $items[] = ['label' => 'Detsta feltöltés', 'url' => ['/ugiro/upload' ] ]; + $items[] = ['label' => 'Részletek aktiválása', 'url' => ['/ugiro/parts' ] ]; // $items[] = ['label' => 'Bevétel', 'url' => ['/transfer/summary' , 'TransferSummarySearch[start]' =>$today,'TransferSummarySearch[end]' => $tomorrow ] ]; // $items[] = ['label' => 'Napi bevételek', 'url' => ['/transfer/list', 'TransferListSearch[start]' =>$todayDatetime,'TransferListSearch[end]' => $tomorrowDatetime ] ]; // $items[] = ['label' => 'Kassza müveletek', 'url' => ['/account-state/index'] ]; diff --git a/backend/controllers/TicketInstallmentRequestController.php b/backend/controllers/TicketInstallmentRequestController.php index 7263a9a..7254588 100644 --- a/backend/controllers/TicketInstallmentRequestController.php +++ b/backend/controllers/TicketInstallmentRequestController.php @@ -25,6 +25,7 @@ class TicketInstallmentRequestController extends Controller 'class' => VerbFilter::className(), 'actions' => [ 'delete' => ['post'], + 'accept' => ['post'], ], ], ]; @@ -65,6 +66,25 @@ class TicketInstallmentRequestController extends Controller ]); } + + public function actionAccept( $id ) + { + $model = $this->findModel($id); + + if ( !$model->isStatusAccepted() ){ + $model->applyStatus(TicketInstallmentRequest::$STATUS_ACCEPTED_MANUAL,true); + \Yii::$app->session->setFlash('success',"Megbízás teljesítve"); + } +// else{ + +// } + +// echo "asdff"; + + return $this->redirect(['ticket-installment-request/view', + 'id' => $model->id_ticket_installment_request, + ]); + } /** * Lists pending TicketInstallmentRequest models. * @return mixed diff --git a/backend/controllers/UgiroController.php b/backend/controllers/UgiroController.php index 535c7fc..01e515a 100644 --- a/backend/controllers/UgiroController.php +++ b/backend/controllers/UgiroController.php @@ -8,6 +8,9 @@ use backend\models\UgiroSearch; use yii\web\Controller; use yii\web\NotFoundHttpException; use yii\filters\VerbFilter; +use common\components\DetStatProcessor; +use backend\models\DestaUploadForm; +use yii\web\UploadedFile; /** * UgiroController implements the CRUD actions for Ugiro model. @@ -40,7 +43,25 @@ class UgiroController extends Controller 'dataProvider' => $dataProvider, ]); } + /** + * Lists all Ugiro models. + * @return mixed + */ + public function actionItems($id) + { + $searchModel = new UgiroSearch(); + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); + return $this->render('index', [ + 'searchModel' => $searchModel, + 'dataProvider' => $dataProvider, + ]); + } + + public function actionActivate(){ + + } + /** * Displays a single Ugiro model. * @param integer $id @@ -48,6 +69,20 @@ class UgiroController extends Controller */ public function actionView($id) { + $model = $this->findModel($id); + if (Yii::$app->request->isPost) { + if ($model->status == Ugiro::$STATUS_RECIEVED){ + set_time_limit(1200);//20 perc + $processor = new DetStatProcessor( + ['koteg' => $model] + ); + $processor->run(); + }else{ + \Yii::$app->session->setFlash('danger','Nem lehet futtatni a fájlt'); + \Yii::error("a koteg státusza nem STATUS_RECIEVED. A koteg azonosíótja:" . $model->id_ugiro ); + } + } + return $this->render('view', [ 'model' => $this->findModel($id), ]); @@ -102,6 +137,35 @@ class UgiroController extends Controller return $this->redirect(['index']); } + + public function actionDetsta(){ + + $ugiro = Ugiro::findOne(31); + $model = new DetStatProcessor( + ['koteg' => $ugiro] + ); + + + return $this->render('detsta', [ + 'model' => $model, + ]); + } + + public function actionUpload(){ + $model = new DestaUploadForm(); + + if (Yii::$app->request->isPost) { + $model->destaFile = UploadedFile::getInstance($model, 'destaFile'); + if ($model->upload()) { + // file is uploaded successfully + return $this->redirect(['view', 'id' => $model->koteg->id_ugiro]); + } + } + + return $this->render('upload', ['model' => $model]); + + } + /** * Finds the Ugiro model based on its primary key value. diff --git a/backend/detsta.txt b/backend/detsta.txt new file mode 100644 index 0000000..20598c0 --- /dev/null +++ b/backend/detsta.txt @@ -0,0 +1,5 @@ +01DETSTA8A24237545 201501270001201502094542162957 +020000010000014097201501270020150204201502031104 03916201502031001307001595 0015520150127321538700000000000000000000000340 +020000020000015240201501275020150204 1117 73377201502033417908001595 0015520150127321538800000000000000000000000347 +020000030000015240201501270020150204201502031120 94002201502030005151001595 0015520150127321538900000000000000000000000176 +03000002000000000002933700000100000000000152400000000000000000000000 diff --git a/backend/models/DestaUploadForm.php b/backend/models/DestaUploadForm.php new file mode 100644 index 0000000..11cd999 --- /dev/null +++ b/backend/models/DestaUploadForm.php @@ -0,0 +1,68 @@ + false, ], + [['destaFile'], 'validateKoteg', ], + ]; + } + + public function attributeLabels(){ + return [ + "destaFile" => "Desta fájl" + ]; + } + + + public function validateKoteg($attribute,$params){ + if ( !$this->hasErrors()){ + $content = file_get_contents($this->destaFile->tempName); + $destaUzenet = GiroDETSTA::parse($content); + $number = $destaUzenet->fej->csoportosUzenetSorszam->sorszam; + $datum = $destaUzenet->fej->csoportosUzenetSorszam->osszeallitasDatuma; + $koteg = Ugiro::find()->andWhere(['number' =>$number,'datum' => $datum ])->one(); + $this->koteg = $koteg; + $idKoteg = $this->koteg->id_ugiro; + if (!isset($koteg)){ + $this->addError($attribute,"Nincs ilyen köteg! ( Datum: $datum, Sorszam: $number )"); + }else{ + if ( $koteg->status != Ugiro::$STATUS_SENT ){ + $this->addError($attribute,"A köteg detsta fájl-ja már fel van töltve !( Köteg azonosító: $idKoteg )"); + } + } + + + } + } + + public function upload() + { + if ($this->validate()) { + $path = 'giro/valasz/' . $this->destaFile->baseName . '.' . $this->destaFile->extension; + $this->destaFile->saveAs( $path ); + $this->koteg->desta_path = $path; + $this->koteg->status = Ugiro::$STATUS_RECIEVED; + $this->koteg->save(false); + return true; + } else { + return false; + } + } +} diff --git a/backend/models/GiroKotegForm.php b/backend/models/GiroKotegForm.php index 590fbfc..400e236 100644 --- a/backend/models/GiroKotegForm.php +++ b/backend/models/GiroKotegForm.php @@ -16,6 +16,7 @@ use yii\helpers\FileHelper; use yii\helpers\Inflector; use yii\helpers\BaseInflector; use common\models\UgiroRequestAssignment; +use yii\db\Query; /** * ContactForm is the model behind the contact form. @@ -91,14 +92,31 @@ class GiroKotegForm extends Model{ $this->koteg = new Ugiro(); $this->koteg->status = Ugiro::$STATUS_SENT; $this->koteg->id_user = \Yii::$app->user->id; + + $this->koteg->datum = date('Ymd'); + + $lastNumber = $this->loadLastNumber($this->koteg->datum); + $nextNumber = $lastNumber+1; + $this->koteg->number = $nextNumber; + $this->success &= $this->koteg->save(false); } + + + public function loadLastNumber($datum){ + $query = new Query(); + $query->select(['coalesce(max(number),0)']); + $query->from('ugiro'); + $query->andWhere(["datum" => $datum]); + return $query->scalar(); + } + public function readRequests(){ $this->requests = TicketInstallmentRequest::find()->andWhere(['status' => TicketInstallmentRequest::$STATUS_MARKED_TO_SEND])->all(); } public function generateFileContent(){ - $this->content = GiroBeszed::createFileContent($this->koteg->id_ugiro, $this->requests); + $this->content = GiroBeszed::createFileContent($this->koteg->number, $this->koteg->datum, $this->requests); } public function saveFile( ) { diff --git a/backend/models/TicketInstallmentRequestSearch.php b/backend/models/TicketInstallmentRequestSearch.php index d4f42bb..0d5ce27 100644 --- a/backend/models/TicketInstallmentRequestSearch.php +++ b/backend/models/TicketInstallmentRequestSearch.php @@ -30,13 +30,15 @@ class TicketInstallmentRequestSearch extends TicketInstallmentRequest public $customer_name; public $id_ticket_type; + public $id_ugiro; + /** * @inheritdoc */ public function rules() { return [ - [['id_ticket_installment_request', 'id_ticket', 'id_customer', 'status' ,'id_ticket_type'], 'integer'], + [['id_ticket_installment_request', 'id_ticket', 'id_customer', 'status' ,'id_ticket_type','id_ugiro'], 'integer'], [['customer_name' ], 'safe'], [[ 'start', ], 'date' , 'timestampAttribute' => 'timestampStart' ,'timestampAttributeFormat' => 'yyyy-MM-dd' ], [[ 'end' , ], 'date' , 'timestampAttribute' => 'timestampEnd' ,'timestampAttributeFormat' => 'yyyy-MM-dd' ], @@ -89,11 +91,13 @@ class TicketInstallmentRequestSearch extends TicketInstallmentRequest 'ticket.start as ticket_start',//ticket_start 'ticket.end as ticket_end',//ticket_send 'ticket.id_ticket as ticket_id_ticket',//id_ticket + 'ugiro_request_assignment.id_ugiro as ugiro_id_ugiro' ,//köteg azonosító ]); $query->from("ticket_installment_request"); $query->innerJoin("customer","customer.id_customer = ticket_installment_request.id_customer"); $query->innerJoin("ticket","ticket.id_ticket = ticket_installment_request.id_ticket"); $query->innerJoin("ticket_type","ticket.id_ticket_type = ticket_type.id_ticket_type"); + $query->leftJoin("ugiro_request_assignment","ticket_installment_request.id_ticket_installment_request = ugiro_request_assignment.id_request"); $query->orderBy(["ticket_installment_request.request_target_time_at" => SORT_ASC]); @@ -115,6 +119,10 @@ class TicketInstallmentRequestSearch extends TicketInstallmentRequest $query->andFilterWhere(['>=', 'ticket_installment_request.request_processed_at', $this->timestampProcessedStart]); $query->andFilterWhere(['<', 'ticket_installment_request.request_processed_at', $this->timestampProcessedEnd]); + if ( isset($this->id_ugiro ) && !empty($this->id_ugiro)){ + $query->andWhere(["ugiro_request_assignment.id_ugiro" => $this->id_ugiro]); + } + $dataProvider = new ArrayDataProvider([ 'allModels' => $query->all(), // 'sort' => [ diff --git a/backend/models/TicketSearch.php b/backend/models/TicketSearch.php index 30a587b..a0e7922 100644 --- a/backend/models/TicketSearch.php +++ b/backend/models/TicketSearch.php @@ -37,7 +37,7 @@ class TicketSearch extends Ticket public function rules() { return [ - [[ 'id_ticket', 'id_user', 'id_ticket_type', 'id_account'], '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'] , @@ -117,7 +117,8 @@ class TicketSearch extends Ticket 'id_ticket_type' => $this->id_ticket_type, 'id_account' => $this->id_account, 'id_card' => $this->id_card, - 'id_ticket' => $this->id_ticket + 'id_ticket' => $this->id_ticket, + 'status' => $this->status ]); diff --git a/backend/views/ticket-installment-request/_index_view.php b/backend/views/ticket-installment-request/_index_view.php index 3df8fc7..f793404 100644 --- a/backend/views/ticket-installment-request/_index_view.php +++ b/backend/views/ticket-installment-request/_index_view.php @@ -3,8 +3,31 @@ use common\models\TicketInstallmentRequest; use common\models\Ticket; +use yii\helpers\Html; ?> + + +
+
+
- - - + + - + - + - + - -
@@ -16,7 +39,7 @@ use common\models\Ticket; Megbízás státusza + @@ -25,8 +48,7 @@ use common\models\Ticket;
Megbízás inditására irányzott dátum @@ -47,7 +69,7 @@ use common\models\Ticket; formatter->asDatetime( $model['request_processed_at'] );?> -
Megbízás prioritása @@ -56,15 +78,17 @@ use common\models\Ticket; + Köteg azonosító +
Vendég azonosító @@ -82,7 +106,7 @@ use common\models\Ticket;
Bérlet azonosító @@ -102,7 +126,7 @@ use common\models\Ticket;
Bérlet érvényességének kezdete @@ -120,5 +144,19 @@ use common\models\Ticket;
\ No newline at end of file + + +
+ $model['ugiro_id_ugiro']] ,[ 'class' => 'btn btn-primary']); + } + echo Html::a("Megbízás részletek",['ticket-installment-request/view', 'id' => $model['request_id_ticket_installment_request']] ,[ 'class' => 'btn btn-primary']); + if ( !empty( $model['ticket_id_ticket'] )){ + echo Html::a("Bérlet részletei",['ticket-installment-request/index', 'TicketInstallmentRequestSearch[id_ticket]' => $model['ticket_id_ticket']] ,[ 'class' => 'btn btn-primary']); + } + ?> +
+
+
+
\ No newline at end of file diff --git a/backend/views/ticket-installment-request/_search.php b/backend/views/ticket-installment-request/_search.php index e2b53e8..d4a7091 100644 --- a/backend/views/ticket-installment-request/_search.php +++ b/backend/views/ticket-installment-request/_search.php @@ -28,7 +28,9 @@ $ticketTypeOptions = ['' => 'Mind'] + ArrayHelper::map(TicketType::read(), 'i
field($model, 'id_ticket_installment_request')->label("Megbízás azonosító") ?>
- +
+ field($model, 'id_ugiro')->label("Köteg azonosító") ?> +
field($model, 'id_ticket')->label("Bérlet azonosító") ?>
@@ -65,6 +67,7 @@ $ticketTypeOptions = ['' => 'Mind'] + ArrayHelper::map(TicketType::read(), 'i ])->label('Megbízás inditására irányzott dátum vége ( exklúzív )') ?> +
field($model, 'sentStart')->widget(DatePicker::classname(), [ @@ -83,6 +86,7 @@ $ticketTypeOptions = ['' => 'Mind'] + ArrayHelper::map(TicketType::read(), 'i ])->label('Megbízás elindításának időszak vége ( exklúzív )') ?>
+
field($model, 'processedStart')->widget(DatePicker::classname(), [ @@ -128,8 +132,7 @@ $ticketTypeOptions = ['' => 'Mind'] + ArrayHelper::map(TicketType::read(), 'i field($model, 'updated_at') ?>
- 'btn btn-primary']) ?> - 'btn btn-default']) ?> + 'btn btn-primary']) ?>
diff --git a/backend/views/ticket-installment-request/index.php b/backend/views/ticket-installment-request/index.php index 9112d61..fbc0f4b 100644 --- a/backend/views/ticket-installment-request/index.php +++ b/backend/views/ticket-installment-request/index.php @@ -12,6 +12,13 @@ use yii\base\Widget; $this->title = Yii::t('common/ticket_installment_request', 'Bérlet fizetési megbízások'); $this->params['breadcrumbs'][] = $this->title; ?> + + +

title) ?>

diff --git a/backend/views/ticket-installment-request/view.php b/backend/views/ticket-installment-request/view.php index 11bb934..98f3dc4 100644 --- a/backend/views/ticket-installment-request/view.php +++ b/backend/views/ticket-installment-request/view.php @@ -2,49 +2,207 @@ use yii\helpers\Html; use yii\widgets\DetailView; +use common\models\TicketInstallmentRequest; +use common\models\Ticket; +use yii\widgets\ActiveForm; /* @var $this yii\web\View */ /* @var $model common\models\TicketInstallmentRequest */ -$this->title = $model->id_ticket_installment_request; -$this->params['breadcrumbs'][] = ['label' => Yii::t('common/ticket_installment_request', 'Ticket Installment Requests'), 'url' => ['index']]; +$this->title = "Megbízás: " . $model->id_ticket_installment_request; +$this->params['breadcrumbs'][] = ['label' => "Megbízások", 'url' => ['index']]; $this->params['breadcrumbs'][] = $this->title; ?> +isStatusAccepted() ){ + $statusStyle = "accepted"; + }else if ( $model->isStatusRejected() ){ + $statusStyle = "rejected"; + } + +?> +

title) ?>

-

- $model->id_ticket_installment_request], ['class' => 'btn btn-primary']) ?> - $model->id_ticket_installment_request], [ - 'class' => 'btn btn-danger', - 'data' => [ - 'confirm' => Yii::t('common/ticket_installment_request', 'Are you sure you want to delete this item?'), - 'method' => 'post', - ], - ]) ?> -

+ - $model, - 'attributes' => [ - 'id_ticket_installment_request', - 'id_ticket', - 'id_customer', - 'id_transfer', - 'status', - 'money', - 'customer_name', - 'bank_name', - 'bank_address', - 'bank_account', - 'priority', - 'request_sent_at', - 'request_processed_at', - 'request_target_time_at', - 'created_at', - 'updated_at', - ], - ]) ?> + +
+
+ isStatusRejected()){ + echo Html::a("Teljesítettnek jelölés",['accept', 'id' => $model->id_ticket_installment_request] ,['data-method' =>'post', 'class' => 'btn btn-danger']); + } + ?> +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ Megbízás azonosító + + id_ticket_installment_request;?> + + Megbízás státusza + + status );?> + + Megbízás összege + + money." Ft";?> +
+ Megbízás inditására irányzott dátum + + formatter->asDatetime( $model->request_target_time_at );?> + + Megbízás elindításának ideje + + formatter->asDatetime( $model->request_sent_at);?> + + Megbízás feldoglozásának ideje + + formatter->asDatetime( $model->request_processed_at );?> +
+ Megbízás prioritása (Sorszám) + + priority ;?> + + Köteg azonosító + + idGiro ;?> + + +
+ Vendég azonosító + + customer->id_customer;?> + + Vendég neve + + customer->name;?> + + +
+ Bérlet azonosító + + ticket->id_ticket;?> + + Bérlet típus + + ticket->ticketTypeName;?> + + Bérlet státusza + + ticket->status );?> +
+ Bérlet érvényességének kezdete + + formatter->asDate( $model->ticket->start) ;?> + + Bérlet érvényességének vége + + formatter->asDate( $model->ticket->end ) ;?> + + +
+ Bérlet részletek száma + + ticket->part_count ;?> + + Bérlet esedékes részlet + + ticket->part ;?> + + Bérlet utoljára fizetett részlet + + ticket->part_paid ;?> +
+ +idGiro )){ + echo Html::a("Köteg",['ugiro/view', 'id' => $model->idGiro] ,[ 'class' => 'btn btn-primary']); + echo Html::a("Részletek a kötegben",['ticket-installment-request/index', 'TicketInstallmentRequestSearch[id_ugiro]' => $model->idGiro] ,[ 'class' => 'btn btn-primary']); +} +echo Html::a("Bérlet fizetési részletei",['ticket-installment-request/index', 'TicketInstallmentRequestSearch[id_ticket]' => $model->id_ticket] ,[ 'class' => 'btn btn-primary']); + +?>
+
+
+
diff --git a/backend/views/ticket/_search.php b/backend/views/ticket/_search.php index de41150..651cc72 100644 --- a/backend/views/ticket/_search.php +++ b/backend/views/ticket/_search.php @@ -4,6 +4,7 @@ use yii\helpers\Html; use yii\widgets\ActiveForm; use yii\helpers\ArrayHelper; use kartik\widgets\DatePicker; +use common\models\Ticket; /* @var $this yii\web\View */ /* @var $model backend\models\TicketSearch */ @@ -36,6 +37,15 @@ $userOptions = ['' => 'Mind'] + ArrayHelper::map($model->users, 'id', 'userna field($model, 'id_account')->dropDownList($accountOptions) ?>
+
+
+ field($model, 'status')->dropDownList( ["" =>"Mind"]+ Ticket::statuses()) ?> +
+
+
+
+
+
diff --git a/backend/views/ticket/index.php b/backend/views/ticket/index.php index 5121848..d0bb127 100644 --- a/backend/views/ticket/index.php +++ b/backend/views/ticket/index.php @@ -104,6 +104,10 @@ $this->params['breadcrumbs'][] = $this->title; 'attribute' => 'id_account', 'value' => 'accountName' ], + [ + 'attribute' => 'status', + 'value' => 'statusName' + ], // 'max_usage_count', // 'usage_count', diff --git a/backend/views/ticket/view.php b/backend/views/ticket/view.php index 2cf4115..5a6e79e 100644 --- a/backend/views/ticket/view.php +++ b/backend/views/ticket/view.php @@ -19,17 +19,36 @@ $this->params['breadcrumbs'][] = $this->title; 'model' => $model, 'attributes' => [ 'id_ticket', - 'id_user', - 'id_ticket_type', - 'id_account', - 'id_discount', - 'start', - 'end', + [ + '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', - 'status', + [ + 'attribute' => 'status', + 'value' => $model->statusName + ], 'price_brutto', - 'comment', + 'comment:raw', 'created_at', 'updated_at', ], diff --git a/backend/views/ugiro/detsta.php b/backend/views/ugiro/detsta.php new file mode 100644 index 0000000..dc9a242 --- /dev/null +++ b/backend/views/ugiro/detsta.php @@ -0,0 +1,26 @@ + + +detsta + +koteg->id_ugiro; + $model->run(); + + $megbizasok = $model->megbizasok; + + echo "
Megbízások száma:". count($megbizasok); + + foreach ($megbizasok as $m){ + echo "
". $m->id_ticket_installment_request . " - " . ($m->detstaTetel->toString()); + } + + echo "
" . nl2br( $model->detstatUzenet->toString()); + + + print_r($model->errors); + +?> \ No newline at end of file diff --git a/backend/views/ugiro/upload.php b/backend/views/ugiro/upload.php new file mode 100644 index 0000000..e42779c --- /dev/null +++ b/backend/views/ugiro/upload.php @@ -0,0 +1,27 @@ + + +

DetSta Fájl Feltöltés

+

+ Ezen a felületen csak a fájl feltöltés törénik meg, a fájl feldolgozása a köteg nézet-ben lehetséges +

+
+ + ['enctype' => 'multipart/form-data']]) ?> + + field($model, 'destaFile')->fileInput() ?> + +
+ 'btn btn-primary']) ?> +
+ + + +
diff --git a/backend/views/ugiro/view.php b/backend/views/ugiro/view.php index 047dd47..f3904e1 100644 --- a/backend/views/ugiro/view.php +++ b/backend/views/ugiro/view.php @@ -4,6 +4,7 @@ use yii\helpers\Html; use yii\widgets\DetailView; use yii\helpers\Url; use common\models\Ugiro; +use yii\widgets\ActiveForm; /* @var $this yii\web\View */ /* @var $model common\models\Ugiro */ @@ -12,17 +13,33 @@ $this->title = "Köteg részletei"; $this->params['breadcrumbs'][] = ['label' => "Kötegek", 'url' => ['index']]; $this->params['breadcrumbs'][] = $this->title; ?> +

title) ?>

- 'id_ugiro', 'label' => 'Köteg azonosító' ], + [ + 'attribute' => 'number', + 'label' => 'Üzenet sorszám' + ], + [ + 'attribute' => 'datum', + 'label' => 'Üzenet összeállítási dátum' + ], [ 'attribute' => 'user.username', 'label' => 'Felhasználó' @@ -38,13 +55,21 @@ $attributes = [ ], [ 'attribute' => 'path', - 'label' => 'Köteg Fájl', + 'label' => 'Beszed Fájl', 'value' => Html::a( "Letöltés" , Url::base() ."/". $model->path , ['target' =>'_blank' ,'download' =>'CS-BESZED.' .$model->id_ugiro ] ), 'format' => 'raw' ], ]; - if ( $model->status == Ugiro::$STATUS_FINISHED){ - + + + + if ( $model->status == Ugiro::$STATUS_RECIEVED || $model->status == Ugiro::$STATUS_FINISHED ){ + $attributes[] = [ + 'attribute' => 'desta_path', + 'label' => 'Detsta Fájl', + 'value' => Html::a( "Letöltés" , Url::base() ."/". $model->desta_path , ['target' =>'_blank' ,'download' =>'CS-BESZED.' .$model->id_ugiro ] ), + 'format' => 'raw' + ]; } ?> @@ -56,3 +81,13 @@ $attributes = [ ]) ?>
+
+status == Ugiro::$STATUS_RECIEVED ){ + echo Html::a("DetSta Fájl Feldoglozás",['view', 'id' => $model->id_ugiro] ,['data-method' =>'post', 'class' => 'btn btn-danger']); + } + echo Html::a("Megbízások a kötegben",['ticket-installment-request/index', 'TicketInstallmentRequestSearch[id_ugiro]' => $model->id_ugiro] ,[ 'class' => 'btn btn-primary']); +?> +
+ + diff --git a/backend/web/giro/megbizas/.gitkeep b/backend/web/giro/megbizas/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/backend/web/giro/valasz/.gitkeep b/backend/web/giro/valasz/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/common/components/DetStatProcessor.php b/common/components/DetStatProcessor.php new file mode 100644 index 0000000..e9141fa --- /dev/null +++ b/common/components/DetStatProcessor.php @@ -0,0 +1,137 @@ +readKoteg(); + $this->readKotegMegbizasok(); + $this->readDetstaUzenet(); + $this->createMegbizasTetelHozzarendelesek(); + $this->processMegbizasok(); + $this->markKotegFinished(); + } + + public function markKotegFinished(){ + $this->koteg->status = Ugiro::$STATUS_FINISHED; + $this->koteg->save(); + } + + public function processMegbizasok(){ + foreach ($this->megbizasok as $megbizas){ + $processor = new DetStatTetelProcessor( + [ + 'tetel' => $megbizas->detstaTetel, + 'megbizas' => $megbizas + ] + ); + $processor->run(); + $this->errors = $this->errors + $processor->errors; + } + } + + public function readDetstaUzenet(){ + + $filename = \Yii::getAlias("@webroot") ."/" .$this->koteg->desta_path; + $content = file_get_contents($filename); + $this->detstatUzenet = GiroDETSTA::parse($content); + + + + + $this->detstatUzenet = new GiroDETSTA(); + $this->idKoteg = 33; + + $fej = new GiroDETSTAFej(); + + $this->detstatUzenet->fej = $fej; + + $tetel = new GiroDETSTATetel(); + $tetel->ugyfelAzonosito = 12; + $tetel->visszajelzesInformacio = "00"; + $tetel->visszajelzesInformacio = "02"; + + $this->detstatUzenet->tetelek[] = $tetel; + + $lab = new GiroDETSTALab(); + $this->detstatUzenet->lab = $lab; + + } + + public function createMegbizasTetelHozzarendelesek(){ + $mapTetel = []; + foreach ($this->detstatUzenet->tetelek as $tetel ){ + $mapTetel[$tetel->ugyfelAzonosito] = $tetel; + } + + foreach ($this->megbizasok as $megbizas){ + if ( array_key_exists($megbizas->id_ticket_installment_request, $mapTetel)){ + $megbizas->detstaTetel = $mapTetel[$megbizas->id_ticket_installment_request]; + } + } + + + } + + + public function readKoteg(){ + $this->koteg = Ugiro::findOne($this->idKoteg ); + if ( !isset($this->koteg) ){ + $this->errors [] = "Kötege nem található! (".$this->detstatUzenet->fej." )"; + } + } + public function readKotegMegbizasok(){ + $this->megbizasok = $this->koteg->requests; + } + + public function applyNewMegbizasState(){ + $kod = $this->tetel->valaszHivatkozasiKod; + + if ( $kod == GiroDETSTATetel::$INFORMACIO_TELJESITETT){ + $this->megbizas->status = TicketInstallmentRequest::$STATUS_ACCEPTED; + }else{ + $this->megbizas->status = TicketInstallmentRequest::$STATUS_REJECTED; + } + $this->megbizas->save(false); + } + + public function applyNewTicketState(){ + $this->ticket->applyTicketInstallmentRequest($this->megbizas); + $this->ticket->save(false); + } + + + public function hasError(){ + return count($this->errors) > 0; + } + + +} \ No newline at end of file diff --git a/common/components/DetStatTetelProcessor.php b/common/components/DetStatTetelProcessor.php new file mode 100644 index 0000000..e986bb3 --- /dev/null +++ b/common/components/DetStatTetelProcessor.php @@ -0,0 +1,129 @@ +readMegbizas(); + if ($this->megbizas->isStatusAccepted()) { +// return; + } + $status = TicketInstallmentRequest::$STATUS_REJECTED; + $kod = 'xx'; + $comment = ""; + if (isset ( $this->tetel )) { + $kod = $this->tetel->visszajelzesInformacio; + } + + if ($kod == GiroDETSTATetel::$INFORMACIO_TELJESITETT) { + $status = TicketInstallmentRequest::$STATUS_ACCEPTED; + } else { + $status = TicketInstallmentRequest::$STATUS_REJECTED; + + if ( $kod == "xx"){ + $comment = "Nem található a detsta fájlban a tétel válasza"; + }else{ + if ( array_key_exists($kod, GiroDETSTATetel::$INFORMACIOK)){ + $comment = "Hiba kód: ".$kod ." - " .GiroDETSTATetel::$INFORMACIOK[$kod]; + }else{ + $comment = "Ismeretlen hiba kód: " .$kod; + } + } + } + + $this->megbizas->applyStatus($status,true,$kod,$comment); + + + // $this->readTicket(); + // if ( !$this->hasError() ){ + // $this->applyNewMegbizasState(); + // $this->applyNewTicketState(); + // $this->addTransfer(); + // } + } + + // public function readMegbizas(){ + // $this->megbizas = TicketInstallmentRequest::findOne($this->tetel->ugyfelAzonosito); + // if ( !isset($this->megbizas) ){ + // $this->errors [] = "Válaszban jelölt megbízás nem található! (".$this->tetel->ugyfelAzonosito." )"; + // } + // } + // public function readTicket(){ + // $this->ticket = $this->megbizas->ticket; + // if ( !isset($this->ticket) ){ + // $this->errors [] = "Válaszban jelölt bérlet nem található! (".$this->megbizas->id_ticket." )"; + // } + // } + + // public function applyNewMegbizasState(){ + // $kod = 'xx'; + // if ( isset($this->tetel ) ) { + // $kod = $this->tetel->visszajelzesInformacio; + // } + + // if ( $kod == GiroDETSTATetel::$INFORMACIO_TELJESITETT){ + // $this->megbizas->status = TicketInstallmentRequest::$STATUS_ACCEPTED; + // }else{ + // $this->megbizas->status = TicketInstallmentRequest::$STATUS_REJECTED; + // } + // if ( !$this->isDryRun() ){ + // $this->megbizas->save(false); + // } + // } + + // public function applyNewTicketState(){ + // $this->ticket->applyTicketInstallmentRequest($this->megbizas); + // if ( !$this->isDryRun() ){ + // $this->ticket->save(false); + // } + // } + + // protected function addTransfer(){ + + // $account = Account::findOne($this->ticket->id_account); + // $discount = null; + // if ( isset($this->ticket->id_account)){ + // $discount = Discount::findOne( $this->ticket->id_discount ); + // } + + // $transfer = Transfer::createTicketTransfer($account, $discount, null, 1, $this->ticket); + + // $transfer->status = Transfer::STATUS_PAID; + // $transfer->paid_at = date('Y-m-d H:i:s' ) ; + // $transfer->paid_by = \Yii::$app->user->id; + // $transfer->payment_method = Transfer::PAYMENT_METHOD_TRANSFER; + // $transfer->money = $this->megbizas->money; + // $transfer->comment = "Csoportos beszedes"; + // $transfer->id_user = \Yii::$app->user->id; + // $transfer->id_customer = $this->ticket->id_customer; + // $transfer->save(false); + // } + public function hasError() { + return count ( $this->errors ) > 0; + } + public function isDryRun() { + return $this->dryRun; + } +} \ No newline at end of file diff --git a/common/components/giro/GiroBase.php b/common/components/giro/GiroBase.php index 075d55e..60971c0 100644 --- a/common/components/giro/GiroBase.php +++ b/common/components/giro/GiroBase.php @@ -29,11 +29,11 @@ class GiroBase { return $data; } - public function szovegOlvas($row,$start,$length, $padchar = " "){ + public static function szovegOlvas($row,$start,$length, $padchar = " "){ return rtrim(substr($row, $start,$length),$padchar); } - public function szamOlvas($row,$start,$length, $padchar = "0"){ + public static function szamOlvas($row,$start,$length, $padchar = "0"){ return ltrim(substr($row, $start,$length),$padchar); } diff --git a/common/components/giro/GiroBeszed.php b/common/components/giro/GiroBeszed.php index 2605ce7..3d3ba31 100644 --- a/common/components/giro/GiroBeszed.php +++ b/common/components/giro/GiroBeszed.php @@ -15,19 +15,24 @@ class GiroBeszed extends GiroBase { public function __construct() { } - public static function createFileContent($id, $requests) { - $s = self::createFej($id); - $s .= self::createTetelek($requests); + + + public static function createFileContent($number,$datum /**összeállítás dátum*/, $requests, $terhelesiDatum = null) { + if ( !isset($terhelesiDatum)){ + $terhelesiDatum = date('Ymd' ,strtotime("+5 day")); + } + $s = self::createFej($number, $datum); + $s .= self::createTetelek($requests,$terhelesiDatum); $s .= self::createLab($requests); return $s; } - public static function createFej($id) { + public static function createFej($number, $daturm) { $fej = new GiroBeszedFej (); $fej->duplumKod = \Yii::$app->params['ugiro_duplom_kod']; $fej->kezdemenyezoAzonosito = \Yii::$app->params['ugiro_kezdemenyezo_azonosito'];//"A25366936T244"; // "66658092128"; - $fej->uzenetSorszam->osszeallitasDatuma = date('Ymd' ); - $fej->uzenetSorszam->sorszam = $id; + $fej->uzenetSorszam->osszeallitasDatuma = $daturm; + $fej->uzenetSorszam->sorszam = $number; $fej->kezdemenyezoBankszamla->szamlaszam = \Yii::$app->params['ugiro_kezdemenyezo_szamlaszam']; // "5860025215371128"; // $fej->kezdemenyezoBankszamla->bankszerv = "58600252"; // "TAKBHUHB"; $fej->ertesitesiHatarido = ""; @@ -36,10 +41,12 @@ class GiroBeszed extends GiroBase { return $fej->toString (); } - public static function createTetelek($requests){ + public static function createTetelek($requests,$terhelesiDatum){ $s = ""; + $i = 0; foreach ($requests as $request){ - $s .= self::createTetel($request); + $i++; + $s .= self::createTetel($request,$i,$terhelesiDatum); } return $s; } @@ -47,19 +54,19 @@ class GiroBeszed extends GiroBase { /** * @param common\models\TicketInstallmentRequest $request * */ - public static function createTetel($request) { + public static function createTetel($request,$sorszam,$terhelesiDatum) { $tetel = new GiroBeszedTetel (); $customer = $request->customer; - $tetel->tetelSorszam = $request->id_ticket_installment_request; - $tetel->terhelesiDatum = date('Ymd' ,strtotime("+5 day"));; + $tetel->tetelSorszam = $sorszam; + $tetel->terhelesiDatum = $terhelesiDatum; $tetel->osszeg = $request->money; // $tetel->kotelezettBankszamla->bankszerv = "58600252"; $tetel->kotelezettBankszamla->szamlaszam = $customer->bank_account; - $tetel->ugyfelazonositoAKezdemenyezonel = $customer->id_customer; + $tetel->ugyfelazonositoAKezdemenyezonel = $request->id_ticket_installment_request; // $tetel->ugyfelNeve = "Schneider Roland"; // $tetel->ugyfelCime = "Mosonmagyarovar, Gardonyi 31"; $tetel->szamlaTulajdonosNeve = $customer->name; - $tetel->kozlemeny = "Berlet :" . $request->id_ticket; + $tetel->kozlemeny = "Berlet:" . $request->id_ticket .";MegbizasAzo:" . $request->id_ticket_installment_request; return $tetel->toString(); } diff --git a/common/components/giro/GiroDETSTA.php b/common/components/giro/GiroDETSTA.php index 22cc26b..3dab266 100644 --- a/common/components/giro/GiroDETSTA.php +++ b/common/components/giro/GiroDETSTA.php @@ -6,8 +6,9 @@ use common\components\giro\GiroBase; /** * - * @property common\components\giro\GiroUzenetsorszam $uzenetSorszam - * @property common\components\giro\GiroBankszamla $kezdemenyezoBankszamla + * @property common\components\giro\GiroDETSTAFej $fej + * @property common\components\giro\GiroDETSTALab $lab + * @property common\components\giro\GiroDETSTATetel $tetelek * */ class GiroDETSTA extends GiroBase { @@ -20,14 +21,25 @@ class GiroDETSTA extends GiroBase { } + public function toString(){ + $s = ""; + $s .= $this->fej->toString(); + foreach ($this->tetelek as $tetel ){ + $s .= $tetel->toString(); + } + $s .= $this->lab->toString(); + + return $s; + } + public static function parse($content){ $detsta = new GiroDETSTA(); $array = preg_split("/\r\n|\n|\r/", $content); $detsta->fej = GiroDETSTAFej::parse($array[0]); - $detsta->lab = GiroDETSTALab::parse($array[count($array) -1]); + $detsta->lab = GiroDETSTALab::parse($array[count($array) -2]); - for ( $i = 1 ; $i < count($array) -1; $i++ ){ + for ( $i = 1 ; $i < count($array) -2; $i++ ){ $row = $array[$i]; $tetel = GiroDETSTATetel::parse($row); $detsta->tetelek[] = $tetel; diff --git a/common/components/giro/GiroDETSTAFej.php b/common/components/giro/GiroDETSTAFej.php index 13bf96b..1a509c0 100644 --- a/common/components/giro/GiroDETSTAFej.php +++ b/common/components/giro/GiroDETSTAFej.php @@ -43,7 +43,7 @@ class GiroDETSTAFej extends GiroBase{ $fej->jelentesJelzo = substr($row, 8,1); $fej->kezdemenyezoAzonosito = substr($row, 9,13); $fej->csoportosUzenetSorszam ->osszeallitasDatuma = substr($row, 22, 8); - $fej->csoportosUzenetSorszam->sorszam = substr($row, 30, 4); + $fej->csoportosUzenetSorszam->sorszam = static::szamOlvas($row, 30, 4); $fej->detstaUzenetSorszam ->osszeallitasDatuma = substr($row, 34,8); $fej->detstaUzenetSorszam->sorszam = substr($row, 42,4); $fej->ido = substr($row, 46,6); diff --git a/common/components/giro/GiroDETSTALab.php b/common/components/giro/GiroDETSTALab.php index ae18a12..d015963 100644 --- a/common/components/giro/GiroDETSTALab.php +++ b/common/components/giro/GiroDETSTALab.php @@ -17,8 +17,10 @@ class GiroDETSTALab extends GiroBase { public $visszautasitottTetelekOsszerteke = "0"; public $megNemValaszoltTetelekSzama = "0"; public $megNemValaszoltTetelekOsszerteke = "0"; + public function __construct() { } + public function toString() { return $this->recordTipus . $this->szamKitolt ( $this->teljesitettTetelekSzama, 6 ) diff --git a/common/components/giro/GiroDETSTATetel.php b/common/components/giro/GiroDETSTATetel.php index f2bf20c..f59afc8 100644 --- a/common/components/giro/GiroDETSTATetel.php +++ b/common/components/giro/GiroDETSTATetel.php @@ -39,7 +39,17 @@ class GiroDETSTATetel extends GiroBase { $this->detstaUzenetSorszam = new GiroUzenetsorszam (); } public function toString() { - return $this->recordTipus . $this->szamKitolt ( $this->tetelSorszam, 6 ) . $this->szamKitolt ( $this->osszeg, 10 ) . $this->eredetiTetelElszamolasiDatuma . $this->visszajelzesInformacio . $this->feldolgozasDatum . $this->terhelesiDatum . $this->szovegKitolt ( $this->valaszHivatkozasiKod, 29 ) . $this->szovegKitolt ( $this->eredetiHivatkozasiKod, 29 ) . $this->szovegKitolt ( $this->ugyfelAzonosito, 29 ); + return $this->recordTipus + . $this->szamKitolt ( $this->tetelSorszam, 6 ) + . $this->szamKitolt ( $this->osszeg, 10 ) + . $this->eredetiTetelElszamolasiDatuma + . $this->visszajelzesInformacio + . $this->feldolgozasDatum + . $this->terhelesiDatum + . $this->szovegKitolt ( $this->valaszHivatkozasiKod, 29 ) + . $this->szovegKitolt ( $this->eredetiHivatkozasiKod, 29 ) + . $this->szovegKitolt ( $this->ugyfelAzonosito, 24 ) + . $this->rekordVege(); } public static function parse($row) { diff --git a/common/models/AccountState.php b/common/models/AccountState.php index 3936121..0ec2689 100644 --- a/common/models/AccountState.php +++ b/common/models/AccountState.php @@ -233,7 +233,8 @@ class AccountState extends \common\models\BaseFitnessActiveRecord $this->prev_state = $lastOpen->id_account_state; $this->prev_money = $lastOpen->money; } - $end = date("Y-m-d H:i:s"); + $end = date('Y-m-d H:i:s' ); +// $end = Yii::$app->formatter->asDatetime(strtotime("now"), "php:Y-m-d H:i:s"); $this->collection_money = Transfer::readPaid($start, $end, Yii::$app->user->id); diff --git a/common/models/MoneyMovement.php b/common/models/MoneyMovement.php index 9024c0a..b111181 100644 --- a/common/models/MoneyMovement.php +++ b/common/models/MoneyMovement.php @@ -29,6 +29,9 @@ class MoneyMovement extends \yii\db\ActiveRecord const TYPE_OUT = 10; const TYPE_IN = 20; + const STATUS_PAID = 20; + const STATUS_STORNO = 30; + public $_account; /** @@ -140,4 +143,23 @@ class MoneyMovement extends \yii\db\ActiveRecord return self::typeName($this->type); } + public static function statuses( ) { + return [ + MoneyMovement::STATUS_PAID => 'Fizetve', + MoneyMovement::STATUS_STORNO => 'Törölve', + ]; + } + + public static function toStatusName($id_status){ + $result = "Ismeretlen"; + $statuses = Ticket::statuses(); + if ( array_key_exists($id_status, $statuses)){ + $result = $statuses[$id_status]; + } + return $result; + } + + public function getStatusName(){ + return static::toStatusName($this->status); + } } diff --git a/common/models/Sale.php b/common/models/Sale.php index d3a6e5c..6ed7abe 100644 --- a/common/models/Sale.php +++ b/common/models/Sale.php @@ -37,6 +37,7 @@ class Sale extends \yii\db\ActiveRecord const STATUS_NOT_PAID = 10; const STATUS_PAID = 20; + const STATUS_DELETED= 30; /** * @inheritdoc @@ -140,4 +141,26 @@ class Sale extends \yii\db\ActiveRecord return $sale; } + + public static function statuses( ) { + return [ + Sale::STATUS_PAID => 'Aktív', + Sale::STATUS_DELETED => 'Törölve', + Sale::STATUS_NOT_PAID => 'Nincs fizetve', + ]; + } + + public static function toStatusName($id_status){ + $result = "Ismeretlen"; + $statuses = Sale::statuses(); + if ( array_key_exists($id_status, $statuses)){ + $result = $statuses[$id_status]; + } + return $result; + } + + public function getStatusName(){ + return static::toStatusName($this->status); + } + } diff --git a/common/models/Ticket.php b/common/models/Ticket.php index d82aef5..e15eaf7 100644 --- a/common/models/Ticket.php +++ b/common/models/Ticket.php @@ -23,6 +23,9 @@ use common\components\Helper; * @property integer $usage_count * @property integer $status * @property integer $price_brutto + * @property integer $part eddig a részletig kell kifizetve lenni + * @property integer $part_count ennyi részlet van összesen + * @property integer $part_paid ennyi részlet van kifizetve * @property string $comment * @property string $created_at * @property string $updated_at @@ -31,6 +34,7 @@ class Ticket extends \common\models\BaseFitnessActiveRecord { const STATUS_DELETED = 0; const STATUS_ACTIVE = 10; + const STATUS_INACTIVE = 20; /** * @inheritdoc @@ -200,10 +204,10 @@ class Ticket extends \common\models\BaseFitnessActiveRecord new Expression( 'ticket_type.name as name'), new Expression( 'coalesce( count(ticket.id_ticket),0) as total'), - new Expression( "coalesce( sum( case when ". Helper::sqlValidRule('ticket.start', 'ticket.end', ':start', ':end') . " then 1 else 0 end) , 0) as valid" ), //valid - new Expression( "coalesce( sum( case when ". Helper::sqlInIntervalRule('ticket.created_at', ':start', ':end') . " then 1 else 0 end) , 0) as created" ),//created - new Expression( "coalesce( sum( case when ". Helper::sqlInIntervalRule('ticket.created_at', ':start', ':end') . " then transfer.money else 0 end) , 0) as created_money" ),//created_money - new Expression( "coalesce( sum( case when " . Helper::sqlExpireRule('ticket.start', 'ticket.end', ':start', ":end") . " then 1 else 0 end) , 0) as expired" ), + new Expression( "coalesce( sum( case when ticket.status <> " .Ticket::STATUS_DELETED ." AND ". Helper::sqlValidRule('ticket.start', 'ticket.end', ':start', ':end') . " then 1 else 0 end) , 0) as valid" ), //valid + new Expression( "coalesce( sum( case when ticket.status <> " .Ticket::STATUS_DELETED ." AND ". Helper::sqlInIntervalRule('ticket.created_at', ':start', ':end') . " then 1 else 0 end) , 0) as created" ),//created + new Expression( "coalesce( sum( case when ticket.status <> " .Ticket::STATUS_DELETED ." AND ". Helper::sqlInIntervalRule('ticket.created_at', ':start', ':end') . " then transfer.money else 0 end) , 0) as created_money" ),//created_money + new Expression( "coalesce( sum( case when ticket.status <> " .Ticket::STATUS_DELETED ." AND " . Helper::sqlExpireRule('ticket.start', 'ticket.end', ':start', ":end") . " then 1 else 0 end) , 0) as expired" ), ]); @@ -237,6 +241,7 @@ class Ticket extends \common\models\BaseFitnessActiveRecord return [ Ticket::STATUS_ACTIVE => 'Aktív', Ticket::STATUS_DELETED => 'Törölve', + Ticket::STATUS_INACTIVE => 'Inaktív', ]; } @@ -249,4 +254,62 @@ class Ticket extends \common\models\BaseFitnessActiveRecord return $result; } + public function getStatusName(){ + return static::toStatusName($this->status); + } + + public function isDeleted(){ + return $this->status == Ticket::STATUS_DELETED; + } + + /**csoportos beszedéses a bérlet*/ + public function isInstallmentTicket(){ + return ( isset($this->part_count) && $this->part_count > 0 ); + } + + /** + * Apply request + * + * @var common\models\TicketInstallmentRequest $request megbízás + * */ + public function applyTicketInstallmentRequest( $request ) { + //ha csoportos beszedéses + if ( $this->isInstallmentTicket() ){ + if ( $request->isStatusAccepted() ){ + if ( $this->part_paid < $request->priority ){ + $this->part_paid = $request->priority; + } + $this->recalclulate(); + }else if ( $request->isStatusRejected() ){ + $this->status = static::STATUS_INACTIVE; + } + } + } + /* + * * + * @param common\models\TicketInstallmentRequest $request megbízás + */ + public function setPartRequired($request){ + // ha keveseb a részlet sorszám mint a bérlet max sorszáma + if ( $request->priority <= $this->part_count ){ + //ha az aktuális elvárt részlet kisebb , mint a megbízása + if ( $this->part < $request-> priority ){ + $this->part = $request->priority; + } + } + } + + /** + * Csoportos beszedéses bérlet érvényességének újraszámolása + * */ + public function recalclulate( ) { + if ( $this->isInstallmentTicket() ){ + $enabled = $this->part_paid >= $this->part; + if ( $enabled == true ){ + $this->status = static::STATUS_ACTIVE; + }else{ + $this->status = static::STATUS_INACTIVE; + } + } + } } diff --git a/common/models/TicketInstallmentRequest.php b/common/models/TicketInstallmentRequest.php index f38cf18..4f7fc7f 100644 --- a/common/models/TicketInstallmentRequest.php +++ b/common/models/TicketInstallmentRequest.php @@ -25,6 +25,7 @@ use yii\behaviors\TimestampBehavior; * @property string $request_target_time_at * @property string $created_at * @property string $updated_at + * @property common\components\giro\GiroDETSTATetel $detstaTetel GiroDetstaTetel record a DetSta fájlból */ class TicketInstallmentRequest extends \yii\db\ActiveRecord { @@ -36,6 +37,12 @@ class TicketInstallmentRequest extends \yii\db\ActiveRecord public static $STATUS_CANCELED = 30; public static $STATUS_REJECTED = 40; public static $STATUS_ACCEPTED = 50; + public static $STATUS_ACCEPTED_MANUAL = 60; + + /** + * GiroDetstaTetel record a DetSta fájlból + * */ + public $detstaTetel; /** * @inheritdoc @@ -98,6 +105,90 @@ class TicketInstallmentRequest extends \yii\db\ActiveRecord return $this->hasOne( Customer::className(), ["id_customer" =>"id_customer" ] ); } + public function getTicket(){ + return $this->hasOne( Ticket::className(), ["id_ticket" =>"id_ticket", ] ) ; + } + + public function getUgiro() + { + return $this->hasOne(Ugiro::className(), [ 'id_ugiro' => 'id_ugiro' ]) + ->viaTable('ugiro_request_assignment', [ 'id_request' => 'id_ticket_installment_request' ]); + } + + public function isStatusAccepted(){ + return $this->status == static::$STATUS_ACCEPTED || $this->status == static::$STATUS_ACCEPTED_MANUAL; + } + public function isStatusRejected(){ + return $this->status == static::$STATUS_REJECTED ; + } + + public function getIdGiro(){ + $result = null; + $giro = $this->ugiro; + if ( isset($giro) ){ + $result = $giro->id_ugiro; + } + return $result; + } + + /** + * Megbízás státuszának beállítása + * + * Létrehozza a szükséges ticket/transfer objectumokat + * + * @param boolean $partRequired ha igaz, a bérleten a part mezőt változtatjuk + * */ + public function applyStatus($status, $partRequired = false, $visszajelzes = "", $comment = ""){ + if ( $status == static::$STATUS_ACCEPTED || $status == static::$STATUS_ACCEPTED_MANUAL){ + if ( !$this->isStatusAccepted() ){ + $this->status = $status; + $tranfer = $this->addTransfer(); + $this->id_transfer = $tranfer->id_transfer; + $this->save(false); + $this->applyNewTicketState($partRequired); + return true; + }else{ + return false; + } + }else{ + $this->status = $status; + $this->save(false); + $this->applyNewTicketState($partRequired); + return true; + } + } + + protected function applyNewTicketState($partRequired = false){ + if ( $partRequired ){ + $this->ticket->setPartRequired($this); + } + $this->ticket->applyTicketInstallmentRequest($this); + $this->ticket->save(false); + } + + protected function addTransfer(){ + + $account = Account::findOne($this->ticket->id_account); + $discount = null; + if ( isset($this->ticket->id_account)){ + $discount = Discount::findOne( $this->ticket->id_discount ); + } + + $transfer = Transfer::createTicketTransfer($account, $discount, null, 1, $this->ticket); + + $transfer->status = Transfer::STATUS_PAID; + $transfer->paid_at = date('Y-m-d H:i:s' ) ; + $transfer->paid_by = \Yii::$app->user->id; + $transfer->payment_method = Transfer::PAYMENT_METHOD_TRANSFER; + $transfer->money = $this->money; + $transfer->comment = "Csoportos beszedes"; + $transfer->id_user = \Yii::$app->user->id; + $transfer->id_customer = $this->ticket->card->customer->id_customer; + $transfer->save(false); + return $transfer; + } + + /** * @param common\models\Ticket $ticket * @param common\models\TicketType $type @@ -107,8 +198,12 @@ class TicketInstallmentRequest extends \yii\db\ActiveRecord $result = []; if ( $type->isInstallment() ){ $count = $type->installment_count; - $ticketCreatedAt = time(); + $discount = $ticket->discount; $money = $type->price_brutto; + if ( isset($discount ) ){ + $money = Discount::applyDiscount($money, $discount); + } + $ticketCreatedAt = time(); for ( $i = 1; $i <= $count; $i++){ $request = TicketInstallmentRequest::createInstallment($ticket, $type, $customer, $money, $ticketCreatedAt, $i); $result[] = $request; @@ -140,6 +235,7 @@ class TicketInstallmentRequest extends \yii\db\ActiveRecord TicketInstallmentRequest::$STATUS_CANCELED=> 'Törölve', TicketInstallmentRequest::$STATUS_REJECTED=> 'Visszautasítva', TicketInstallmentRequest::$STATUS_ACCEPTED=> 'Sikeresen végrehajtva', + TicketInstallmentRequest::$STATUS_ACCEPTED_MANUAL=> 'Manuálisan elfogadva', ]; } diff --git a/common/models/Transfer.php b/common/models/Transfer.php index c92eca5..ff8847b 100644 --- a/common/models/Transfer.php +++ b/common/models/Transfer.php @@ -46,6 +46,7 @@ class Transfer extends \common\models\BaseFitnessActiveRecord const STATUS_NOT_PAID = 10; const STATUS_PAID = 20; + const STATUS_STORNO = 30; const DIRECTION_OUT = 10;// MONEY GOES OUT FROM ACCOUNT ( COMPANY LOST MONEY ) const DIRECTION_IN = 20;//MONEY GOES IN TO THE ACCOUNT ( COMPANY EARN MONEY ) @@ -477,6 +478,7 @@ class Transfer extends \common\models\BaseFitnessActiveRecord return [ self::STATUS_NOT_PAID => Yii::t('common/transfer','Nincs fizetve'), self::STATUS_PAID => Yii::t('common/transfer','Fizetve'), + self::STATUS_STORNO => Yii::t('common/transfer','Törölve'), ]; } public function getStatusName( ) { @@ -751,6 +753,28 @@ class Transfer extends \common\models\BaseFitnessActiveRecord } - + public function storno(){ + $this->status = Transfer::STATUS_STORNO; + $this->save(false); + if ( $this->type == Transfer::TYPE_TICKET){ + $ticket = $this->ticket; + $ticket->status = Ticket::STATUS_DELETED; + $ticket->save(false); + + TicketInstallmentRequest::updateAll( + ['status' => TicketInstallmentRequest::$STATUS_CANCELED ], + ['id_ticket' => $this->ticket->id_ticket ] + ); + + }else if ( $this->type == Transfer::TYPE_PRODUCT ){ + $sale = $this->sale; + $sale->status = Sale::STATUS_DELETED; + $sale->save(false); + }else if ( $this->type == Transfer::TYPE_MONEY_MOVEMENT_OUT ){ + $mm = $this->moneyMovement; + $mm->status = MoneyMovement::STATUS_STORNO; + $mm->save(false); + } + } } diff --git a/common/models/Ugiro.php b/common/models/Ugiro.php index 8423407..7544e9b 100644 --- a/common/models/Ugiro.php +++ b/common/models/Ugiro.php @@ -11,6 +11,10 @@ use yii\helpers\ArrayHelper; * * @property integer $id_ugiro * @property integer $id_user + * @property string $path + * @property string $desta_path + * @property string $datum + * @property integer $number * @property string $created_at * @property string $updated_at */ @@ -18,8 +22,10 @@ class Ugiro extends \yii\db\ActiveRecord { public static $PATH_MEGBIZAS = "giro/megbizas"; + public static $PATH_VALASZ = "giro/valasz"; public static $STATUS_SENT = 0; - public static $STATUS_FINISHED = 1; + public static $STATUS_RECIEVED = 10; + public static $STATUS_FINISHED = 20; /** * @inheritdoc @@ -66,10 +72,19 @@ class Ugiro extends \yii\db\ActiveRecord return $this->hasOne( User::className(), ["id" =>"id_user" ] ); } + + public function getRequests() + { + return $this->hasMany(TicketInstallmentRequest::className(), ['id_ticket_installment_request' => 'id_request']) + ->viaTable('ugiro_request_assignment', ['id_ugiro' => 'id_ugiro']); + } + + public static function statuses() { return [ static::$STATUS_SENT =>"Folyamatban", static::$STATUS_FINISHED =>"Befejezve", + static::$STATUS_RECIEVED =>"Detsta fájl feltöltve", ] ; } diff --git a/console/migrations/m160120_224044_alter__table__money_movement__add_column__status.php b/console/migrations/m160120_224044_alter__table__money_movement__add_column__status.php new file mode 100644 index 0000000..689630f --- /dev/null +++ b/console/migrations/m160120_224044_alter__table__money_movement__add_column__status.php @@ -0,0 +1,30 @@ +addColumn("money_movement", "status", "int"); + } + + public function down() + { + echo "m160120_224044_alter__table__money_movement__add_column__status cannot be reverted.\n"; + + return false; + } + + /* + // Use safeUp/safeDown to run migration code within a transaction + public function safeUp() + { + } + + public function safeDown() + { + } + */ +} diff --git a/console/migrations/m160121_083841_alter__table__ticket__add_part__and__parts_paid.php b/console/migrations/m160121_083841_alter__table__ticket__add_part__and__parts_paid.php new file mode 100644 index 0000000..da724bf --- /dev/null +++ b/console/migrations/m160121_083841_alter__table__ticket__add_part__and__parts_paid.php @@ -0,0 +1,32 @@ +addColumn("ticket", "part", "int"); + $this->addColumn("ticket", "part_count", "int"); + $this->addColumn("ticket", "part_paid", "int"); + } + + public function down() + { + echo "m160121_083841_alter__table__ticket__add_part__and__parts_paid cannot be reverted.\n"; + + return false; + } + + /* + // Use safeUp/safeDown to run migration code within a transaction + public function safeUp() + { + } + + public function safeDown() + { + } + */ +} diff --git a/console/migrations/m160121_183512_alter__table__ugiro__add__desta_path.php b/console/migrations/m160121_183512_alter__table__ugiro__add__desta_path.php new file mode 100644 index 0000000..e4c34ca --- /dev/null +++ b/console/migrations/m160121_183512_alter__table__ugiro__add__desta_path.php @@ -0,0 +1,30 @@ +addColumn("ugiro", "desta_path", "string"); + } + + public function down() + { + echo "m160121_183512_alter__table__ugiro__add__desta_path cannot be reverted.\n"; + + return false; + } + + /* + // Use safeUp/safeDown to run migration code within a transaction + public function safeUp() + { + } + + public function safeDown() + { + } + */ +} diff --git a/console/migrations/m160121_192759_alter__table__ugiro__uzenet__sorszam.php b/console/migrations/m160121_192759_alter__table__ugiro__uzenet__sorszam.php new file mode 100644 index 0000000..a8cb534 --- /dev/null +++ b/console/migrations/m160121_192759_alter__table__ugiro__uzenet__sorszam.php @@ -0,0 +1,28 @@ +addColumn("ugiro", "datum", "string"); + $this->addColumn("ugiro", "number", "integer"); + } + + public function down() + { + } + + /* + // Use safeUp/safeDown to run migration code within a transaction + public function safeUp() + { + } + + public function safeDown() + { + } + */ +} diff --git a/frontend/controllers/AccountStateController.php b/frontend/controllers/AccountStateController.php index 2b15d45..9e73d51 100644 --- a/frontend/controllers/AccountStateController.php +++ b/frontend/controllers/AccountStateController.php @@ -162,7 +162,7 @@ class AccountStateController extends Controller { $total += $cassaOpen->money; $openDate = $cassaOpen->created_at; } - $total += Transfer::readPaid($openDate, date('Y-m-d h:i:s'), \Yii::$app->user->id); + $total += Transfer::readPaid($openDate, date('Y-m-d H:i:s'), \Yii::$app->user->id); return $total; } diff --git a/frontend/controllers/TicketController.php b/frontend/controllers/TicketController.php index c98cea8..9260c96 100644 --- a/frontend/controllers/TicketController.php +++ b/frontend/controllers/TicketController.php @@ -21,6 +21,7 @@ use common\models\UserSoldItem; use frontend\components\FrontendController; use frontend\components\DefaultAccountBehavior; use frontend\components\CassaOpenBehavior; +use frontend\models\TicketUpdate; /** * TicketController implements the CRUD actions for Ticket model. @@ -38,7 +39,7 @@ class TicketController extends FrontendController ], 'access' => [ 'class' => \yii\filters\AccessControl::className(), - 'only' => ['create', 'index' ], + 'only' => ['create', 'index','update' ], 'rules' => [ // allow authenticated users [ @@ -135,6 +136,21 @@ class TicketController extends FrontendController ]); } + public function actionUpdate($id){ + $model = TicketUpdate::findOne($id); + + if ( !isset($model)){ + throw new NotFoundHttpException('The requested page does not exist.'); + } + + if ($model->load(Yii::$app->request->post()) && $model->save()) { + return $this->redirect(['index', 'number' => $model->card->number]); + } + + return $this->render('update',['model' => $model]); + + } + /** * Deletes an existing Transfer model. * If deletion is successful, the browser will be redirected to the 'index' page. @@ -152,12 +168,21 @@ class TicketController extends FrontendController try { ShoppingCart::deleteAll([ 'id_transfer' => $transfer->id_transfer]); UserSoldItem::deleteAll([ 'id_transfer' => $transfer->id_transfer]); - if ( $transfer->delete() ){ - \Yii::$app->session->setFlash( 'success','Bérlet törölve' ); - $transaction->commit(); - }else{ - throw new \Exception("Failed to save"); - } +// $transfer->status = Transfer::STATUS_STORNO; +// $transfer->save(false); +// $ticket->status = Ticket::STATUS_DELETED; +// $ticket->save(false); + $transfer->storno(); + $transaction->commit(); + \Yii::$app->session->setFlash( 'success','Bérlet törölve' ); + + // $transaction->commit(); +// if ( $transfer->delete() ){ +// \Yii::$app->session->setFlash( 'success','Bérlet törölve' ); +// $transaction->commit(); +// }else{ +// throw new \Exception("Failed to save"); +// } } catch(Exception $e) { $transaction->rollback(); diff --git a/frontend/controllers/TransferController.php b/frontend/controllers/TransferController.php index f5cac04..14729b8 100644 --- a/frontend/controllers/TransferController.php +++ b/frontend/controllers/TransferController.php @@ -222,12 +222,13 @@ class TransferController extends Controller try { ShoppingCart::deleteAll([ 'id_transfer' => $transfer->id_transfer]); UserSoldItem::deleteAll([ 'id_transfer' => $transfer->id_transfer]); - if ( $transfer->delete() ){ - \Yii::$app->session->setFlash( 'success','Tranzakció törölve' ); - $transaction->commit(); - }else{ - throw new \Exception("Failed to save"); - } + $transfer->storno(); +// if ( $transfer->delete() ){ + \Yii::$app->session->setFlash( 'success','Tranzakció törölve' ); + $transaction->commit(); +// }else{ +// throw new \Exception("Failed to save"); +// } } catch(Exception $e) { $transaction->rollback(); diff --git a/frontend/models/TicketCreate.php b/frontend/models/TicketCreate.php index 181aa9f..3c6e33d 100644 --- a/frontend/models/TicketCreate.php +++ b/frontend/models/TicketCreate.php @@ -83,6 +83,7 @@ class TicketCreate extends Ticket{ //cart ///////////////////// [['cart'], 'string', 'max' => 10] + ]; } @@ -91,6 +92,18 @@ class TicketCreate extends Ticket{ $type = TicketType::findOne($this->id_ticket_type); if ( !isset($type)) { $this->addError($attribute,Yii::t('frontend/ticket' , 'Invalid ticket type' )); + }else{ + if ( $type->isInstallment()){ + $bankAccount = trim($this->customer->bank_account); + if ( !isset($bankAccount) || empty($bankAccount)){ + $this->addError($attribute,"Nincs bankszámlaszám vagy érvénytelen"); + return; + } + if ( !( strlen($bankAccount) == 16 || strlen($bankAccount) == 24 ) ){ + $this->addError($attribute,"Vendég bankszámlaszáma nem 16 vagy 24 hosszú"); + return; + } + } } } @@ -108,6 +121,23 @@ class TicketCreate extends Ticket{ } } + public function beforeSave($insert){ + $result = parent::beforeSave($insert); + if ( $result ){ + if ($insert){ + $ticketType = TicketType::findOne($this->id_ticket_type); + if ( isset($ticketType) && $ticketType->isInstallment() ){ + $this->part = 0; + $this->part_paid = 0; + $this->part_count = $ticketType->installment_count; + }else{ + $this->part_count = 0; + } + } + } + return $result; + } + public function afterSave($insert, $changedAttributes){ $this->addTransfer(); $this->appendToUserCart(); diff --git a/frontend/models/TicketUpdate.php b/frontend/models/TicketUpdate.php new file mode 100644 index 0000000..c1e3a0f --- /dev/null +++ b/frontend/models/TicketUpdate.php @@ -0,0 +1,25 @@ + [ static ::STATUS_ACTIVE, static ::STATUS_INACTIVE ]], + + ]; + } + + + + } + + +?> \ No newline at end of file diff --git a/frontend/views/money-movement/index.php b/frontend/views/money-movement/index.php index 1e985dd..0067de3 100644 --- a/frontend/views/money-movement/index.php +++ b/frontend/views/money-movement/index.php @@ -36,6 +36,11 @@ $this->params['breadcrumbs'][] = $this->title; 'attribute' => 'comment', 'format' => 'html' ], + [ + 'attribute' => 'status', + 'value' => 'statusName', + 'label' => "Státusz" + ], ['class' => 'yii\grid\ActionColumn', 'template' => '{view}' diff --git a/frontend/views/ticket/_form_update.php b/frontend/views/ticket/_form_update.php new file mode 100644 index 0000000..28a498f --- /dev/null +++ b/frontend/views/ticket/_form_update.php @@ -0,0 +1,84 @@ + + +
+ + status != Ticket::STATUS_DELETED){?> + + 'ticket_form', + ; + ?> + + field ( $model, 'status' )->dropDownList ( $options ); + + ?> + +
+ 'btn btn-success' ]) ?> +
+ + + + +
+ + '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' +]; + + +if ( $model->status == Ticket::STATUS_DELETED ){ + $attributes[] = [ + 'attribute' => 'status', + 'value' => $model->statusName + ]; +} + +?> + + $model,'attributes' => $attributes ] )?> diff --git a/frontend/views/ticket/index.php b/frontend/views/ticket/index.php index 3386bba..131152f 100644 --- a/frontend/views/ticket/index.php +++ b/frontend/views/ticket/index.php @@ -6,6 +6,7 @@ use frontend\components\ReceptionMenuWidget; use frontend\components\ReceptionCardNumberWidget; use frontend\components\ReceptionWidget; use yii\base\Widget; +use common\models\Ticket; /* @var $this yii\web\View */ /* @var $searchModel frontend\models\TicketSearch */ @@ -34,7 +35,11 @@ $this->params['breadcrumbs'][] = $this->title; $dataProvider, 'columns' => [ - + [ + 'attribute' => 'id_ticket', + 'value' => 'id_ticket', + 'label' => "B. Azonosító" + ], [ 'attribute' => 'id_account', 'value' => 'accountName' @@ -51,6 +56,10 @@ $this->params['breadcrumbs'][] = $this->title; 'attribute' => 'id_user', 'value' => 'userName' ], + [ + 'attribute' => 'status', + 'value' => 'statusName' + ], /* [ 'attribute' => 'id_discount', @@ -58,9 +67,31 @@ $this->params['breadcrumbs'][] = $this->title; ], */ 'price_brutto', + 'created_at:datetime', ['class' => 'yii\grid\ActionColumn', - 'template' =>'{delete}', + 'template' =>'{delete} {update}', + 'buttons' => [ + 'update' => function($url, $model, $key){ + return $model->status == Ticket::STATUS_DELETED ? "" : Html::a('', $url, + [ 'title' => "Bérlet törlése", 'class'=>'btn btn-primary btn-xs', ]) ; + }, + 'delete' => function($url, $model, $key){ + return $model->status == Ticket::STATUS_DELETED ? "" : Html::a('', $url, + [ 'title' => "Bérlet módosítása", 'class'=>'btn btn-primary btn-xs', 'data-method' =>'post']) ; + }, + ], +// 'buttons ' => [ + +// 'update' =>function ($url, $model, $key){ +// return "update"; +// }, +// 'delete' =>function ($url, $model, $key){ +// return "delete"; + +// } +// ] +// 'template' => function($model){ return $model->status == Ticket::STATUS_DELETED ? "" : "'{delete} {update}'" ;}, ], ], ]); ?> diff --git a/frontend/views/ticket/update.php b/frontend/views/ticket/update.php index 09f838a..422c44d 100644 --- a/frontend/views/ticket/update.php +++ b/frontend/views/ticket/update.php @@ -5,9 +5,7 @@ use yii\helpers\Html; /* @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 = "Bérlet módosítása:" . ' ' . $model->id_ticket; $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,7 +14,7 @@ $this->params['breadcrumbs'][] = Yii::t('common/ticket', 'Update');

title) ?>

- render('_form', [ + render('_form_update', [ 'model' => $model, ]) ?> diff --git a/frontend/views/transfer/_view.php b/frontend/views/transfer/_view.php index f04328b..836357c 100644 --- a/frontend/views/transfer/_view.php +++ b/frontend/views/transfer/_view.php @@ -69,13 +69,15 @@ $formatter = Yii::$app->formatter;
- Törlés', Url::toRoute(['delete','id' =>$model->id_transfer]), [ + status != Transfer::STATUS_STORNO){ + echo Html::a('Törlés', Url::toRoute(['delete','id' =>$model->id_transfer]), [ 'title' => Yii::t('yii', 'Delete'), 'data-confirm' => Yii::t('yii', 'Are you sure to delete this item?'), 'data-method' => 'post', 'class' => 'btn btn-danger', // 'style' =>'margin-right: 12px;' - ]);?> + ]);}?>