From fdbd39b059a3adf005296daf8c2496c770ea897e Mon Sep 17 00:00:00 2001 From: Roland Schneider Date: Wed, 27 Jul 2016 07:20:47 +0200 Subject: [PATCH] detsta processing -> move to cart if not successfull, transfer/paymentLater changes --- backend/components/AdminMenuStructure.php | 2 +- backend/controllers/TransferController.php | 155 +++++++++++++++- backend/controllers/UgiroController.php | 171 +++++++++++++++++- .../models/TicketInstallmentRequestSearch.php | 2 + backend/models/TransferLaterSearch.php | 90 +++++++-- backend/views/message-detsta/view.php | 4 + .../_index_view.php | 3 +- .../views/transfer/_search_payment_later.php | 19 ++ backend/views/transfer/payment_later.php | 10 +- backend/views/ugiro/view.php | 2 +- changelog.txt | 3 + common/components/DetStaDBSave.php | 2 - common/components/DetStatProcessor.php | 20 +- common/components/DetStatTetelProcessor.php | 89 ++++++--- common/components/TicketSale.php | 8 +- common/components/TransferPayout.php | 7 +- common/components/giro/GiroBankszamla.php | 2 +- common/components/giro/GiroBase.php | 56 +++++- common/components/giro/GiroBeszed.php | 57 ++++-- common/components/giro/GiroDETSTA.php | 11 +- common/components/giro/GiroDETSTAFej.php | 10 +- common/components/giro/GiroDETSTATetel.php | 6 +- common/config/params.php | 2 +- common/models/Contract.php | 3 + common/models/Customer.php | 8 +- common/models/TicketInstallmentRequest.php | 12 +- common/models/Ugiro.php | 2 + .../controllers/DetstaConsoleController.php | 63 ++++++- frontend/controllers/ContractController.php | 5 +- 29 files changed, 700 insertions(+), 124 deletions(-) diff --git a/backend/components/AdminMenuStructure.php b/backend/components/AdminMenuStructure.php index 2fd0e27..5a1f7f0 100644 --- a/backend/components/AdminMenuStructure.php +++ b/backend/components/AdminMenuStructure.php @@ -108,7 +108,7 @@ class AdminMenuStructure{ // $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'] ]; - $items[] = ['label' => 'Későbbi utalások', 'url' => ['/transfer/payment-later','TransferLaterSearch[start]' =>$todayDatetime,'TransferLaterSearch[end]' => $tomorrowDatetime ] ]; + $items[] = ['label' => 'Későbbi utalások', 'url' => ['/transfer/payment-later','TransferLaterSearch[start]' =>$todayDatetime,'TransferLaterSearch[end]' => $tomorrowDatetime ,'TransferLaterSearch[enterStart]' =>$todayDatetime,'TransferLaterSearch[enterEnd]' => $tomorrowDatetime ] ]; //$items[] = ['label' => 'Zárások', 'url' => ['/collection/index' , 'CollectionSearch[start]' =>$todayDatetime,'CollectionSearch[end]' => $tomorrowDatetime ] ]; $this->menuItems[] = ['label' => 'Pénzügy', 'url' => $this->emptyUrl, 'items' => $items diff --git a/backend/controllers/TransferController.php b/backend/controllers/TransferController.php index 2ad7a9a..a5ece8f 100644 --- a/backend/controllers/TransferController.php +++ b/backend/controllers/TransferController.php @@ -1,9 +1,12 @@ output =='pdf'){ - $this->downloadPaymentLater($dataProvider); + $this->downloadPaymentLaterPDF($dataProvider); + }else if ( $searchModel->output =='xls'){ + $this->downloadPaymentLaterXLS($searchModel, $dataProvider); } - + $accounts = Account::read(); $users = User::read(); @@ -96,8 +101,152 @@ class TransferController extends \backend\controllers\BackendController 'users' => $users, ]); } + + + protected function getEnterCount($start,$end,$idCustomer){ + + + + $query = new Query(); + + $query->select([ + 'card.number as card_number', + 'card.id_card as card_id_card', + 'count(*) as enter', + new Expression('EXTRACT( YEAR_MONTH FROM door_log.created_at) as ym'), + new Expression('EXTRACT( YEAR FROM door_log.created_at ) as year'), + new Expression('EXTRACT( MONTH FROM door_log.created_at ) as month ') + + ]); + + $query->from('door_log'); + $query->innerJoin('card','card.id_card = door_log.id_card'); + $query->andWhere(['in','door_log.direction',[3,7]]); + $query->groupBy([ + 'card.number', + 'card.id_card', + 'ym', + 'year', + 'month' + ]); + + $query->andWhere(['door_log.id_customer' => $idCustomer]); + + + $query->andWhere([ '>=','door_log.created_at',$start]); + $query->andWhere([ '<','door_log.created_at',$end]); + + $customerStatistic = $query->one(); + + $moveInCount = $customerStatistic['enter']; + + return $moveInCount; + } + + + + /** + * @param \backend\models\TransferLaterSearch $searchModel + * @param \yii\data\ActiveDataProvider $dataProvider + */ + protected function downloadPaymentLaterXLS( $searchModel, $dataProvider) { + + $fn = "kesobbi_utalasok.xls"; + + $objPHPExcel = new \PHPExcel (); + $sheet = $objPHPExcel->setActiveSheetIndex ( 0 ); + $formatter = \Yii::$app->formatter; + + + + $row = 1; + $sheet->setCellValue('A'.$row, 'Csoportos beszedés'); + + $row++; + $sheet->setCellValue('A'.$row, 'Időszak kezdete'); + $sheet->setCellValue('B'.$row, $searchModel->start); + $sheet->setCellValue('C'.$row, 'Időszak vége'); + $sheet->setCellValue('D'.$row, $searchModel->end); + $row++; + $sheet->setCellValue('A'.$row, 'Belépési Időszak kezdete'); + $sheet->setCellValue('B'.$row, $searchModel->enterStart); + $sheet->setCellValue('C'.$row, 'Belépési Időszak vége'); + $sheet->setCellValue('D'.$row, $searchModel->enterEnd); + $row++; + $sheet->setCellValue('A'.$row, 'Bérlettípus'); + $sheet->setCellValue('B'.$row, $searchModel->id_ticket_type); + $sheet->setCellValue('C'.$row, 'Felhasználó'); + $sheet->setCellValue('D'.$row, $searchModel->id_user); + + $row++; + $sheet->setCellValue('A'.$row, 'Kártyaszám') + ->setCellValue('B'.$row, 'Vendég') + ->setCellValue('C'.$row, 'Kiadva') + ->setCellValue('D'.$row, 'Bérlet típus') + ->setCellValue('E'.$row, 'Összeg') + ->setCellValue('F'.$row, 'Megjegyzés') + ->setCellValue('G'.$row, 'Belépések az időszakban'); + ; + + foreach ( $dataProvider->getModels() as $model ) { + $row ++; + + $sheet + ->setCellValue('A'.$row, $model['card_number']) + ->setCellValue('B'.$row, $model['customer_name']) + ->setCellValue('C'.$row, $model['transfer_created_at']) + ->setCellValue('D'.$row, ($model['ticket_type_name'])) + ->setCellValue('E'.$row, $model['transfer_money']) + ->setCellValue('F'.$row, $model['ticket_comment']) + ->setCellValue('G'.$row, $model['enter']) +// ->setCellValue('F'.$row, $processedTime) +// ->setCellValue('G'.$row, $status) + ; + } + + $styleArray = array ( + 'font' => array ( + 'bold' => true + ) + ); + + $sheet->getStyle ( 'A1' )->applyFromArray ( $styleArray ); + + foreach ( range ( 'A', 'G' ) as $columnID ) { + $sheet->getColumnDimension ( $columnID )->setAutoSize ( true ); + $sheet->getStyle ( $columnID . '5' )->applyFromArray ( $styleArray ); + } + + foreach ( ['A','C'] as $columnID ) { + $sheet->getColumnDimension ( $columnID )->setAutoSize ( true ); + $sheet->getStyle ( $columnID . '2' )->applyFromArray ( $styleArray ); + $sheet->getStyle ( $columnID . '3' )->applyFromArray ( $styleArray ); + $sheet->getStyle ( $columnID . '4' )->applyFromArray ( $styleArray ); + } + + + $fileName = $fn; + + // Redirect output to a client’s web browser (Excel5) + header ( 'Content-Type: application/vnd.ms-excel' ); + header ( 'Content-Disposition: attachment;filename="' . $fileName . '"' ); + header ( 'Cache-Control: max-age=0' ); + // If you're serving to IE 9, then the following may be needed + header ( 'Cache-Control: max-age=1' ); + // If you're serving to IE over SSL, then the following may be needed + header ( 'Expires: Mon, 26 Jul 1997 05:00:00 GMT' ); // Date in the past + header ( 'Last-Modified: ' . gmdate ( 'D, d M Y H:i:s' ) . ' GMT' ); // always modified + header ( 'Cache-Control: cache, must-revalidate' ); // HTTP/1.1 + header ( 'Pragma: public' ); // HTTP/1.0 + $objWriter = \PHPExcel_IOFactory::createWriter ( $objPHPExcel, 'Excel5' ); + $objWriter->save ( 'php://output' ); + + + exit (); + + } - protected function downloadPaymentLater($dataProvider) { + protected function downloadPaymentLaterPDF($dataProvider) { // $mpdf = new \mPDF ( 'utf-8', 'A4' ); $mpdf = new \mPDF ( 'utf-8', 'A4-L' ); diff --git a/backend/controllers/UgiroController.php b/backend/controllers/UgiroController.php index fbb8a0f..dcc9d44 100644 --- a/backend/controllers/UgiroController.php +++ b/backend/controllers/UgiroController.php @@ -2,6 +2,7 @@ namespace backend\controllers; +use common\models\TicketInstallmentRequest; use Yii; use common\models\Ugiro; use backend\models\UgiroSearch; @@ -108,7 +109,9 @@ class UgiroController extends Controller { $output = $_GET ['output']; if ($output == 'pdf') { - $this->downloadUgiro ( $model ); + $this->downloadUgiroPdf ( $model ); + }else if ($output == 'xls') { + $this->downloadUgiroXls ( $model ); } } } @@ -128,17 +131,165 @@ class UgiroController extends Controller { 'detstaDp' => $detstaDp ] ); } - protected function downloadUgiro($model) { + + /** + * @param \common\models\Ugiro $model + */ + protected function downloadUgiroXls($model) { -// $mpdf = new \mPDF ( 'utf-8', 'A4' ); + $fn = "köteg.". $model->id_ugiro . ".xls"; + + $query = new Query(); + $query->select([ + 'card.number as card_number', + 'customer.id_customer as customer_id_customer', + 'customer.name as customer_name', + 'customer.bank_account as customer_bank_account', + 'ticket_installment_request.money as request_money', + 'ticket_installment_request.status as request_status', + 'ticket_installment_request.request_target_time_at as request_request_target_time_at', + 'ticket_installment_request.request_processed_at as request_request_processed_at', + ]); + $query->from('ticket_installment_request'); + $query->innerJoin('ugiro_request_assignment','ticket_installment_request.id_ticket_installment_request = ugiro_request_assignment.id_request'); + $query->innerJoin('customer','customer.id_customer = ticket_installment_request.id_customer'); + $query->innerJoin('card','customer.id_customer_card = card.id_card'); + $query->andWhere(['ugiro_request_assignment.id_ugiro' => $model->id_ugiro]); + $query->orderBy(['customer.name' => SORT_ASC]); + + $dataProvider = new ActiveDataProvider( + [ + 'query' => $query, + 'sort' => false, + 'pagination' => false + ] + ); + + + + $objPHPExcel = new \PHPExcel (); + $sheet = $objPHPExcel->setActiveSheetIndex ( 0 ); + $formatter = \Yii::$app->formatter; + + + $row = 1; + + $sheet->setCellValue('A'.$row, 'Csoportos beszedés'); + + $row++; + $sheet->setCellValue('A'.$row, 'Köteg azonosító'); + $sheet->setCellValue('B'.$row, $model->id_ugiro); + $sheet->setCellValue('C'.$row, 'Üzenetsorszám'); + $sheet->setCellValue('D'.$row, $model->number); + $row++; + $sheet->setCellValue('A'.$row, 'Összeállítási dáutm'); + $sheet->setCellValue('B'.$row, $model->datum); + $sheet->setCellValue('C'.$row, 'Terhelési dáutm'); + $sheet->setCellValue('D'.$row, $model->terhelesi_datum); + + $row++; + $sheet->setCellValue('A'.$row, 'Kártyaszám') + ->setCellValue('B'.$row, 'Vendég') + ->setCellValue('C'.$row, 'Bankszámlaszám') + ->setCellValue('D'.$row, 'Összeg') + ->setCellValue('E'.$row, 'Esedékességi dátum') + ->setCellValue('F'.$row, 'Feldolgozás dátum') + ->setCellValue('G'.$row, 'Státusz') + ; + + + foreach ( $dataProvider->getModels() as $model ) { + $row ++; + $status = ""; + switch ($model['request_status']){ + case TicketInstallmentRequest::$STATUS_ACCEPTED: + $status = "Fizetve"; + break; + case TicketInstallmentRequest::$STATUS_REJECTED: + $status = "Kosár"; + break; + case TicketInstallmentRequest::$STATUS_ACCEPTED_MANUAL: + $status = "Kosár"; + break; + case TicketInstallmentRequest::$STATUS_CANCELED: + $status = "Sztornó"; + break; + case TicketInstallmentRequest::$STATUS_MARKED_TO_SEND: + $status = "Küldésre jelölve"; + break; + case TicketInstallmentRequest::$STATUS_PENDING: + $status = "Feldolgozás alatt"; + break; + case TicketInstallmentRequest::$STATUS_SENT: + $status = "Elküldve"; + break; + default: + $status = ""; + } + + $targetTime = isset( $model['request_request_target_time_at'] ) ? $formatter->asDate($model['request_request_target_time_at']) :""; + $processedTime = isset( $model['request_request_processed_at'] ) ? $formatter->asDatetime($model['request_request_processed_at']) :""; + $sheet + ->setCellValue('A'.$row, $model['card_number']) + ->setCellValue('B'.$row, $model['customer_name']) + ->setCellValue('C'.$row, $model['customer_bank_account']) + ->setCellValue('D'.$row, ($model['request_money'])) + ->setCellValue('E'.$row, $targetTime) + ->setCellValue('F'.$row, $processedTime) + ->setCellValue('G'.$row, $status) + ; + } + + $styleArray = array ( + 'font' => array ( + 'bold' => true + ) + ); + + $sheet->getStyle ( 'A1' )->applyFromArray ( $styleArray ); + + foreach ( range ( 'A', 'G' ) as $columnID ) { + $sheet->getColumnDimension ( $columnID )->setAutoSize ( true ); + $sheet->getStyle ( $columnID . '4' )->applyFromArray ( $styleArray ); + } + + foreach ( ['A','C'] as $columnID ) { + $sheet->getColumnDimension ( $columnID )->setAutoSize ( true ); + $sheet->getStyle ( $columnID . '2' )->applyFromArray ( $styleArray ); + $sheet->getStyle ( $columnID . '3' )->applyFromArray ( $styleArray ); + } + + + $fileName = $fn; + + // Redirect output to a client’s web browser (Excel5) + header ( 'Content-Type: application/vnd.ms-excel' ); + header ( 'Content-Disposition: attachment;filename="' . $fileName . '"' ); + header ( 'Cache-Control: max-age=0' ); + // If you're serving to IE 9, then the following may be needed + header ( 'Cache-Control: max-age=1' ); + // If you're serving to IE over SSL, then the following may be needed + header ( 'Expires: Mon, 26 Jul 1997 05:00:00 GMT' ); // Date in the past + header ( 'Last-Modified: ' . gmdate ( 'D, d M Y H:i:s' ) . ' GMT' ); // always modified + header ( 'Cache-Control: cache, must-revalidate' ); // HTTP/1.1 + header ( 'Pragma: public' ); // HTTP/1.0 + $objWriter = \PHPExcel_IOFactory::createWriter ( $objPHPExcel, 'Excel5' ); + $objWriter->save ( 'php://output' ); + + + exit (); + + } + protected function downloadUgiroPdf($model) { + $mpdf = new \mPDF ( 'utf-8', 'A4-L' ); $fn = "köteg.". $model->id_ugiro . ".pdf"; - + $mpdf->useSubstitutions = false; $mpdf->simpleTables = true; $mpdf->SetHeader ( "" ); $mpdf->setFooter ( '{PAGENO} / {nb}' ); - + $query = new Query(); $query->select([ 'customer.id_customer as customer_id_customer', @@ -153,24 +304,24 @@ class UgiroController extends Controller { $query->andWhere(['ugiro_request_assignment.id_ugiro' => $model->id_ugiro]); $dataProvider = new ActiveDataProvider( [ - 'query' => $query, + 'query' => $query, 'sort' => false, 'pagination' => false ] ); - + $stylesheet = file_get_contents ( \Yii::getAlias ( '@vendor' . '/bower/bootstrap/dist/css/bootstrap.css' ) ); // external css $mpdf->WriteHTML ( $stylesheet, 1 ); - + $mpdf->WriteHTML ( $this->renderPartial ( '_view_pdf.php', [ 'model' => $model, 'dataProvider' => $dataProvider ] ) ); $mpdf->Output ( $fn, 'D' ); exit (); - + } - + /** * Creates a new Ugiro model. * If creation is successful, the browser will be redirected to the 'view' page. diff --git a/backend/models/TicketInstallmentRequestSearch.php b/backend/models/TicketInstallmentRequestSearch.php index b73cd39..236ad3c 100644 --- a/backend/models/TicketInstallmentRequestSearch.php +++ b/backend/models/TicketInstallmentRequestSearch.php @@ -94,9 +94,11 @@ class TicketInstallmentRequestSearch extends TicketInstallmentRequest '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ó + 'card.number as card_number' ]); $query->from("ticket_installment_request"); $query->innerJoin("customer","customer.id_customer = ticket_installment_request.id_customer"); + $query->leftJoin("card","card.id_card = customer.id_customer_card"); $query->leftJoin("ticket","ticket.id_ticket = ticket_installment_request.id_ticket"); $query->leftJoin("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"); diff --git a/backend/models/TransferLaterSearch.php b/backend/models/TransferLaterSearch.php index f758632..8eae458 100644 --- a/backend/models/TransferLaterSearch.php +++ b/backend/models/TransferLaterSearch.php @@ -10,9 +10,7 @@ use yii\db\Expression; use yii\base\Object; use yii\db\Query; use yii\helpers\ArrayHelper; -use common\models\Account; use common\components\Helper; -use common\components\RoleDefinition; /** * TransferSearch represents the model behind the search form about `common\models\Transfer`. @@ -24,7 +22,13 @@ class TransferLaterSearch extends Transfer public $timestampStart; public $timestampEnd; - + + public $enterStart; + public $enterEnd; + + public $timestampEnterStart; + public $timestampEnterEnd; + public $id_ticket_type; @@ -45,6 +49,8 @@ class TransferLaterSearch extends Transfer [[ 'id_ticket_type','id_user'], 'integer'], [[ 'start', ], 'date', 'format' =>Yii::$app->formatter->datetimeFormat , 'timestampAttribute' => 'timestampStart' ,'timestampAttributeFormat' => 'yyyy-MM-dd HH:mm' ,'timeZone' => 'UTC' ], [[ 'end' , ], 'date' ,'format' =>Yii::$app->formatter->datetimeFormat , 'timestampAttribute' => 'timestampEnd' ,'timestampAttributeFormat' => 'yyyy-MM-dd HH:mm' ,'timeZone' => 'UTC' ], + [[ 'enterStart', ], 'date', 'format' =>Yii::$app->formatter->datetimeFormat , 'timestampAttribute' => 'timestampEnterStart' ,'timestampAttributeFormat' => 'yyyy-MM-dd HH:mm' ,'timeZone' => 'UTC' ], + [[ 'enterEnd' , ], 'date' ,'format' =>Yii::$app->formatter->datetimeFormat , 'timestampAttribute' => 'timestampEnterEnd' ,'timestampAttributeFormat' => 'yyyy-MM-dd HH:mm' ,'timeZone' => 'UTC' ], ['selected', 'each', 'rule' => ['integer']], ]; } @@ -58,7 +64,7 @@ class TransferLaterSearch extends Transfer return Model::scenarios(); } - /** + /**1 * Creates data provider instance with search query applied * * @param array $params @@ -68,6 +74,9 @@ class TransferLaterSearch extends Transfer public function search($params) { $query = new Query(); + $this->load($params); + + $valid = $this->validate(); $query->select([ 'transfer.id_transfer as transfer_id_transfer', @@ -83,26 +92,49 @@ class TransferLaterSearch extends Transfer 'ticket.start as ticket_start', 'ticket.end as ticket_end', 'ticket.comment as ticket_comment', + 'card.number as card_number', + new Expression('count(door_log.id_door_log) as enter'), ]); $query->from("transfer"); $query->innerJoin('user', " user.id = transfer.id_user"); $query->leftJoin('customer', " transfer.id_customer = customer.id_customer"); + $query->leftJoin('card', " customer.id_customer_card = card.id_card"); $query->leftJoin('ticket', " transfer.type = ".Transfer::TYPE_TICKET." and transfer.id_object = ticket.id_ticket"); $query->leftJoin('ticket_type', " ticket.id_ticket_type = ticket_type.id_ticket_type"); $query->leftJoin('sale', " transfer.type = ".Transfer::TYPE_PRODUCT." and transfer.id_object = sale.id_sale"); $query->leftJoin('product', " product.id_product = sale.id_product"); - + $query->leftJoin('door_log', + "door_log.id_customer = transfer.id_customer and door_log.direction in (3,7) + and door_log.created_at >= :start and door_log.created_at < :end ", + [':start' => $this->timestampEnterStart, + ':end' => $this->timestampEnterEnd]); + $query->groupBy( + [ + 'transfer.id_transfer', + 'transfer.created_at', + 'transfer.money', + 'transfer.status', + 'user.username', + 'customer.id_customer', + 'customer.name', + 'customer.description', + 'ticket_type.name', + 'product.name', + 'ticket.start', + 'ticket.end', + 'ticket.comment', + 'card.number' + ] + ); + $query->andWhere(["transfer.payment_method" => Transfer::PAYMENT_METHOD_TRANSFER_LATER ]); $query->andWhere(['transfer.status' => Transfer::STATUS_NOT_PAID]); - $this->load($params); - $valid = $this->validate(); - $dataProvider = new ActiveDataProvider([ 'query' => $query, - 'pagination' => $this->output == 'pdf' ? false : [], + 'pagination' => ( $this->output == 'pdf' || $this->output == 'xls' ) ? false : [], 'sort' => [ 'defaultOrder' =>[ 'transfer_created_at' => SORT_DESC @@ -119,6 +151,8 @@ class TransferLaterSearch extends Transfer ['ticket_end'], ['ticket_comment'], ['customer_description'], + ['enter'], + ['card_number'] ]) ] @@ -149,8 +183,42 @@ class TransferLaterSearch extends Transfer return $dataProvider; } - - + + + /** + * TODO: DASAP + * @param $start + * @param $end + * @param $idCustomer + */ + protected function getEnterCount($start,$end,$idCustomer){ + $query = new Query(); + $query->select([ + 'card.number as card_number', + 'card.id_card as card_id_card', + 'count(*) as enter', + new Expression('EXTRACT( YEAR_MONTH FROM door_log.created_at) as ym'), + new Expression('EXTRACT( YEAR FROM door_log.created_at ) as year'), + new Expression('EXTRACT( MONTH FROM door_log.created_at ) as month ') + + ]); + $query->from('door_log'); + $query->innerJoin('card','card.id_card = door_log.id_card'); + $query->andWhere(['in','door_log.direction',[3,7]]); + $query->groupBy([ + 'card.number', + 'card.id_card', + 'ym', + 'year', + 'month' + ]); + $query->andWhere(['door_log.id_customer' => $idCustomer]); + $query->andWhere([ '>=','door_log.created_at',$start]); + $query->andWhere([ '<','door_log.created_at',$end]); + $query->all(); + } + + public function totalsTransfers( ){ diff --git a/backend/views/message-detsta/view.php b/backend/views/message-detsta/view.php index 38132c1..9f50c08 100644 --- a/backend/views/message-detsta/view.php +++ b/backend/views/message-detsta/view.php @@ -159,6 +159,10 @@ echo Html::a("Vissza a köteghez",['ugiro/view', 'id' => $model->id_ugiro] ,[ ' 'value' => $tetel->request->customer->name , 'label' => 'Vendég' ], +[ + 'value' => $tetel->request->customer->card->number , + 'label' => 'Vendég' + ], ] ]); diff --git a/backend/views/ticket-installment-request/_index_view.php b/backend/views/ticket-installment-request/_index_view.php index 6b869cf..f07aac2 100644 --- a/backend/views/ticket-installment-request/_index_view.php +++ b/backend/views/ticket-installment-request/_index_view.php @@ -89,7 +89,6 @@ use yii\helpers\Html; - @@ -105,8 +104,10 @@ use yii\helpers\Html; + Kártyaszám + diff --git a/backend/views/transfer/_search_payment_later.php b/backend/views/transfer/_search_payment_later.php index 345af63..2c16414 100644 --- a/backend/views/transfer/_search_payment_later.php +++ b/backend/views/transfer/_search_payment_later.php @@ -46,6 +46,25 @@ use common\models\User; ]) ?> +
+
+ field($model, 'enterStart')->widget(DateTimePicker::classname(), [ + 'pluginOptions' => [ + 'autoclose'=>true, + 'format' => 'yyyy.mm.dd hh:ii' + ] + ])->label("Belépések -tól") ?> + +
+
+ field($model, 'enterEnd') ->widget(DateTimePicker::classname(), [ + 'pluginOptions' => [ + 'autoclose'=>true, + 'format' => 'yyyy.mm.dd hh:ii' + ] + ])->label("Belépések -ig") ?> +
+
field($model, 'id_ticket_type')->dropDownList($ticketTypeOptions)->label("Bérlet típus") ?> diff --git a/backend/views/transfer/payment_later.php b/backend/views/transfer/payment_later.php index b47086c..3a53d06 100644 --- a/backend/views/transfer/payment_later.php +++ b/backend/views/transfer/payment_later.php @@ -38,7 +38,7 @@ $this->params['breadcrumbs'][] = $this->title;
'pdf']), ['class' => 'btn btn-primary' ]); +echo Html::a("XLS",Url::current(['TransferLaterSearch[output]'=>'xls']), ['class' => 'btn btn-primary' ]); ?>
@@ -85,6 +85,10 @@ echo Html::a("Egyiket sem",null, ['class' => 'btn btn-primary deselect-all', 'attribute' => 'customer_name', 'label' => 'Vendég' ], +[ + 'attribute' => 'card_number', + 'label' => 'Kártyaszám' + ], [ 'attribute' => 'ticket_type_name', 'label' => 'Bérlet típus' @@ -126,6 +130,10 @@ echo Html::a("Egyiket sem",null, ['class' => 'btn btn-primary deselect-all', [ 'attribute' => 'ticket_comment', 'label' => 'Megj' + ], + [ + 'attribute' => 'enter', + 'label' => 'Belépések' ], ], ]); ?> diff --git a/backend/views/ugiro/view.php b/backend/views/ugiro/view.php index 4b51b3e..1ac8443 100644 --- a/backend/views/ugiro/view.php +++ b/backend/views/ugiro/view.php @@ -125,7 +125,7 @@ $attributes = [ //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']); - echo Html::a("PDF", Url::current(['output' => 'pdf']) ,[ 'class' => 'btn btn-primary']); + echo Html::a("Xls", Url::current(['output' => 'xls']) ,[ 'class' => 'btn btn-primary']); $detstaMessage = $model->messageDetsta; if ( isset($detstaMessage)){ diff --git a/changelog.txt b/changelog.txt index ae9d0b2..4f02570 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,6 @@ +-0.0.80 + - csoportos beszedés: kosár ha nem sikerült + - későbbi utalások: xls, belépések száma -0.0.79 - add frontend confirm on delete, - add transfer changes diff --git a/common/components/DetStaDBSave.php b/common/components/DetStaDBSave.php index fa92eed..d914e7c 100644 --- a/common/components/DetStaDBSave.php +++ b/common/components/DetStaDBSave.php @@ -52,8 +52,6 @@ class DetStaDBSave extends Object /** * - * @param common\models\Ugiro; - * @param common\models\giro\GiroDETSTA $giroDETSTA * */ protected function saveMessageDetsta( ) { $this->message = new MessageDetsta(); diff --git a/common/components/DetStatProcessor.php b/common/components/DetStatProcessor.php index 91d30d8..22771d7 100644 --- a/common/components/DetStatProcessor.php +++ b/common/components/DetStatProcessor.php @@ -3,20 +3,15 @@ namespace common\components; use yii\base\Object; -use common\models\TicketInstallmentRequest; -use common\components\giro\GiroDETSTATetel; use common\models\Ugiro; use common\components\giro\GiroDETSTA; -use common\components\giro\GiroDETSTAFej; -use common\components\giro\GiroDETSTALab; -use common\components\DetStaDBSave; /** * This is the model class for table "ticket". * - * @property common\components\giro\GiroDETSTA $detstatUzenet - * @property common\models\UGiro $koteg + * @property \common\components\giro\GiroDETSTA $detstatUzenet + * @property \common\models\UGiro $koteg * * */ class DetStatProcessor extends Object{ @@ -120,14 +115,19 @@ class DetStatProcessor extends Object{ } - - + + + /** + * + */ public function readKoteg(){ $this->koteg = Ugiro::findOne($this->idKoteg ); if ( !isset($this->koteg) ){ - $this->errors [] = "Kötege nem található! (".$this->detstatUzenet->fej." )"; + /** @var DetStatProcessor $this */ + $this->errors [] = "Köteg nem található! (".$this->detstatUzenet->fej ." )"; } } + public function readKotegMegbizasok(){ $this->megbizasok = $this->koteg->requests; } diff --git a/common/components/DetStatTetelProcessor.php b/common/components/DetStatTetelProcessor.php index 3f2f280..081a1ed 100644 --- a/common/components/DetStatTetelProcessor.php +++ b/common/components/DetStatTetelProcessor.php @@ -2,6 +2,7 @@ namespace common\components; +use common\models\Transfer; use yii\base\Object; use common\models\TicketInstallmentRequest; use common\components\giro\GiroDETSTATetel; @@ -11,10 +12,10 @@ use common\models\Contract; /** * This is the model class for table "ticket". * - * @property common\components\giro\GiroDETSTATetel $tetel - * @property common\models\TicketInstallmentRequest $megbizas - * @property common\models\Ticket $ticket - * @property common\models\Contract $contract + * @property \common\components\giro\GiroDETSTATetel $tetel + * @property \common\models\TicketInstallmentRequest $megbizas + * @property \common\models\Ticket $ticket + * @property \common\models\Contract $contract * * */ @@ -44,7 +45,7 @@ class DetStatTetelProcessor extends Object { * */ protected $comment; /** - * A bérlet objectkum, amit elmentettünk + * A bérlet objektum, amit elmentettünk * */ protected $ticket; /** @@ -58,13 +59,13 @@ class DetStatTetelProcessor extends Object { \Yii::info('Megbízás feldolgozása: megbízás azonosító=' .$this->megbizas->id_ticket_installment_request); - if ($this->isAlreadeyAccepted ()) { + if ($this->isAlreadyAccepted ()) { \Yii::info('A megbízás feldolgozásának megszakítása. A megbízás már elfogadott: megbízás azonosító=' .$this->megbizas->id_ticket_installment_request); return; } if ( !isset($this->tetel)){ - \Yii::info('A megbízás feldolgozásának megszakítása. Nincs valaszsor a detsta üzenetben'); + \Yii::info('A megbízás feldolgozásának megszakítása. Nincs válasz sor a detsta üzenetben'); return; } @@ -75,6 +76,8 @@ class DetStatTetelProcessor extends Object { if ( $this->status == TicketInstallmentRequest::$STATUS_ACCEPTED ){ $this->buyNewTicket(); + }else if ( $this->status == TicketInstallmentRequest::$STATUS_ACCEPTED_MANUAL ){ + $this->putTicketToCustomerCart(); }else{ $this->doRejectRequest(); } @@ -85,23 +88,26 @@ class DetStatTetelProcessor extends Object { protected function rememberEredetiMegbizasStatus(){ $this->eredetiMegbizasStatus = $this->megbizas->status; } - - protected function isEredetiMegbizasStatusFinished(){ - return $this->eredetiMegbizasStatus == TicketInstallmentRequest::$STATUS_ACCEPTED || - $this->eredetiMegbizasStatus == TicketInstallmentRequest::$STATUS_ACCEPTED_MANUAL || - $this->eredetiMegbizasStatus == TicketInstallmentRequest::$STATUS_REJECTED; + + /** + * @return bool + */ + protected function isEredetiMegbizasStatusFinished(){ + return TicketInstallmentRequest::$STATUS_ACCEPTED == $this->eredetiMegbizasStatus || + TicketInstallmentRequest::$STATUS_ACCEPTED_MANUAL == $this->eredetiMegbizasStatus || + TicketInstallmentRequest::$STATUS_REJECTED == $this->eredetiMegbizasStatus; } protected function buyNewTicket(){ - \Yii::info('Új bérlet vásárlás folyamant indítása' ); - + \Yii::info('Új bérlet vásárlás folyamat indítása' ); + $megbizas = $this->megbizas; $customer = $this->contract->customer; $card = $customer->card; $account = Account::findOne(1); $ticketType = $this->contract->ticketType; $discount = $this->contract->discount; - + $ticketSale = new TicketSale( [ 'ticketType'=> $ticketType, @@ -111,20 +117,53 @@ class DetStatTetelProcessor extends Object { 'discount'=> $discount, 'contract'=> $this->contract, 'ticketInstallmentRequest' => $megbizas - ] + ] ); - + $ticketSale->doSale(); \Yii::info('Bérlet és tranzakció elmentve' ); - + $this->transfer = $ticketSale->transfer; $this->ticket = $ticketSale->ticket; - + $this->updateContractOnSuccess(); $this->updateMegbizasOnSuccess(); - + } - + protected function putTicketToCustomerCart(){ + \Yii::info('Új bérlet vásárló kosarába helyezés folyamat indítása' ); + + $megbizas = $this->megbizas; + $customer = $this->contract->customer; + $card = $customer->card; + $account = Account::findOne(1); + $ticketType = $this->contract->ticketType; + $discount = $this->contract->discount; + + $ticketSale = new TicketSale( + [ + 'ticketType'=> $ticketType, + 'customer'=> $customer, + 'account'=> $account, + 'card'=> $card, + 'discount'=> $discount, + 'contract'=> $this->contract, + 'ticketInstallmentRequest' => $megbizas, + 'transferStatus' => Transfer::STATUS_NOT_PAID + ] + ); + + $ticketSale->doSale(); + \Yii::info('Bérlet és tranzakció elmentve' ); + + $this->transfer = $ticketSale->transfer; + $this->ticket = $ticketSale->ticket; + + $this->updateContractOnSuccess(); + $this->updateMegbizasOnSuccess(); + + } + /** * A szerződés betöltése * */ @@ -139,7 +178,7 @@ class DetStatTetelProcessor extends Object { * */ protected function updateMegbizasOnSuccess(){ - \Yii::info('Megbízás frissítése - megbizás elfogadva ' ); + \Yii::info('Megbízás frissítése - megbízás elfogadva ' ); $this->megbizas->status = $this->status; $this->megbizas->id_transfer = $this->transfer->id_transfer; @@ -161,7 +200,7 @@ class DetStatTetelProcessor extends Object { * */ protected function updateMegbizasOnFail(){ - \Yii::info('Megbázás frissítése - megbízás visszautasítva ' ); + \Yii::info('Megbízás frissítése - megbízás visszautasítva ' ); $this->megbizas->status = $this->status; $this->megbizas->detsta_answer = $this->kod; @@ -269,12 +308,12 @@ class DetStatTetelProcessor extends Object { if ($this->kod == GiroDETSTATetel::$INFORMACIO_TELJESITETT) { $this->status = TicketInstallmentRequest::$STATUS_ACCEPTED; } else { - $this->status = TicketInstallmentRequest::$STATUS_REJECTED; + $this->status = TicketInstallmentRequest::$STATUS_ACCEPTED_MANUAL; } \Yii::info('Visszajelző kód kiolvasva: kod=' .$this->kod); \Yii::info('Visszajelző kód kiolvasva: statusz=' .$this->status. " (" . TicketInstallmentRequest::toStatusName($this->status) .")"); } - protected function isAlreadeyAccepted() { + protected function isAlreadyAccepted() { return $this->megbizas->isStatusAccepted (); } public function hasError() { diff --git a/common/components/TicketSale.php b/common/components/TicketSale.php index d5437c0..e5c038c 100644 --- a/common/components/TicketSale.php +++ b/common/components/TicketSale.php @@ -1,7 +1 @@ -readMoney(); $this->readStartDate(); $this->readEndDate(); $this->mkTicket(); $this->mkTransfer(); $this->addToCustomerCart(); } protected function mkTicket( ) { $this->ticket = new Ticket (); $this->ticket->id_user = \Yii::$app->user->id; $this->ticket->id_ticket_type = $this->ticketType->id_ticket_type; // save to contract $this->ticket->id_account = $this->account->id_account; $this->ticket->id_discount = isset($this->discount) ? $this->discount->id_discount : null; // contract.id_discount $this->ticket->start = $this->start; $this->ticket->end = $this->end; $this->ticket->max_usage_count = $this->ticketType->max_usage_count; $this->ticket->usage_count = 0; $this->ticket->status = Ticket::STATUS_ACTIVE; $this->ticket->price_brutto = $this->money; $this->ticket->id_card = $this->card->id_card; if ( isset( $this->ticketInstallmentRequest ) ){ $this->ticket->part = $this->ticketInstallmentRequest->priority; } if (isset($this->contract)){ $this->ticket->id_contract = $this->contract->id_contract; } if ( !$this->ticket->save ( false ) ){ \Yii::error("Nem sikerült menteni a bérletet!"); throw new \Exception("Bérlet mentése nem sikerült"); } \Yii::info("Bérlet elmentve: id=" . $this->ticket->id_ticket); } protected function mkTransfer( ) { $this->transfer = new Transfer (); $this->transfer->status = $this->transferStatus; $this->transfer->type = Transfer::TYPE_TICKET; $this->transfer->direction = Transfer::DIRECTION_IN; $this->transfer->id_object = $this->ticket->id_ticket; $this->transfer->item_price = $this->ticketType->price_brutto; $this->transfer->money = $this->money; $this->transfer->id_account = $this->account->id_account; $this->transfer->count = 1; if ($this->transferStatus == Transfer::STATUS_PAID) { $this->transfer->paid_at = date ( 'Y-m-d H:i:s' ); $this->transfer->paid_by = \Yii::$app->user->id; } $this->transfer->payment_method = $this->paymentMethod; $this->transfer->comment = ""; if ( isset($this->ticketInstallmentRequest)){ $this->transfer->comment = "Csoportos megbízással"; } $this->transfer->id_user = \Yii::$app->user->id; $this->transfer->id_customer = $this->customer->id_customer; if ( !$this->transfer->save (false) ){ \Yii::error("Nem sikerült menteni a tranzakciót!"); throw new \Exception("Tranzakció mentése nem sikerült"); } \Yii::info("tranzakció elmentve: id=" . $this->transfer->id_transfer); } protected function addToCustomerCart( ) { } protected function readMoney(){ if ( !isset($this->money)){ $this->money = $this->ticketType->price_brutto; if (isset($this->discount)){ $this->money = Discount::applyDiscount($this->money, $this->discount); } if ( isset($this->ticketInstallmentRequest)){ $this->money = $this->ticketInstallmentRequest->money; } } } protected function readStartDate(){ if ( !isset($this->start)){ $this->start = Helper::getDateString(); if ( isset($this->ticketInstallmentRequest)){ $this->start = $this->ticketInstallmentRequest->request_target_time_at; } } } protected function readEndDate(){ if ( !isset($this->end)){ $unit = "month"; if ( $this->ticketType->time_unit_type == TicketType::TIME_UNIT_DAY ) { $unit = "day"; } $count = $this->ticketType->time_unit_count; $this->end = date( 'Y-m-d', strtotime( $this->start . " +$count $unit -1 day")); if ( isset($this->ticketInstallmentRequest)){ $this->end = date( 'Y-m-d', strtotime( $this->ticketInstallmentRequest->request_target_time_at . " +1 month -1 day")); } } } - -} \ No newline at end of file +readMoney(); $this->readStartDate(); $this->readEndDate(); $this->mkTicket(); $this->mkTransfer(); $this->addToCustomerCart(); } protected function mkTicket( ) { $this->ticket = new Ticket (); $this->ticket->id_user = \Yii::$app->user->id; $this->ticket->id_ticket_type = $this->ticketType->id_ticket_type; // save to contract $this->ticket->id_account = $this->account->id_account; $this->ticket->id_discount = isset($this->discount) ? $this->discount->id_discount : null; // contract.id_discount $this->ticket->start = $this->start; $this->ticket->end = $this->end; $this->ticket->max_usage_count = $this->ticketType->max_usage_count; $this->ticket->usage_count = 0; $this->ticket->status = $this->transferStatus == Transfer::STATUS_PAID ? Ticket::STATUS_ACTIVE : Ticket::STATUS_INACTIVE ; $this->ticket->price_brutto = $this->money; $this->ticket->id_card = $this->card->id_card; if ( isset( $this->ticketInstallmentRequest ) ){ $this->ticket->part = $this->ticketInstallmentRequest->priority; } if (isset($this->contract)){ $this->ticket->id_contract = $this->contract->id_contract; } if ( !$this->ticket->save ( false ) ){ \Yii::error("Nem sikerült menteni a bérletet!"); throw new \Exception("Bérlet mentése nem sikerült"); } \Yii::info("Bérlet elmentve: id=" . $this->ticket->id_ticket); } protected function mkTransfer( ) { $this->transfer = new Transfer (); $this->transfer->status = $this->transferStatus; $this->transfer->type = Transfer::TYPE_TICKET; $this->transfer->direction = Transfer::DIRECTION_IN; $this->transfer->id_object = $this->ticket->id_ticket; $this->transfer->item_price = $this->ticketType->price_brutto; $this->transfer->money = $this->money; $this->transfer->id_account = $this->account->id_account; $this->transfer->count = 1; if ($this->transferStatus == Transfer::STATUS_PAID) { $this->transfer->paid_at = date ( 'Y-m-d H:i:s' ); $this->transfer->paid_by = \Yii::$app->user->id; } $this->transfer->payment_method = $this->paymentMethod; $this->transfer->comment = ""; if ( isset($this->ticketInstallmentRequest)){ $this->transfer->comment = "Csoportos megbízással"; } $this->transfer->id_user = \Yii::$app->user->id; $this->transfer->id_customer = $this->customer->id_customer; if ( !$this->transfer->save (false) ){ \Yii::error("Nem sikerült menteni a tranzakciót!"); throw new \Exception("Tranzakció mentése nem sikerült"); } \Yii::info("tranzakció elmentve: id=" . $this->transfer->id_transfer); } protected function addToCustomerCart( ) { if ( isset( $this->customer ) ){ if ( $this->transferStatus == Transfer::STATUS_NOT_PAID ){ $cartItem = new ShoppingCart(); $cartItem->id_customer = $this->customer->id_customer; $cartItem->id_transfer = $this->transfer->id_transfer; $cartItem->save(false); } } } protected function readMoney(){ if ( !isset($this->money)){ $this->money = $this->ticketType->price_brutto; if (isset($this->discount)){ $this->money = Discount::applyDiscount($this->money, $this->discount); } if ( isset($this->ticketInstallmentRequest)){ $this->money = $this->ticketInstallmentRequest->money; } } } protected function readStartDate(){ if ( !isset($this->start)){ $this->start = Helper::getDateString(); if ( isset($this->ticketInstallmentRequest)){ $this->start = $this->ticketInstallmentRequest->request_target_time_at; } } } protected function readEndDate(){ if ( !isset($this->end)){ $unit = "month"; if ( $this->ticketType->time_unit_type == TicketType::TIME_UNIT_DAY ) { $unit = "day"; } $count = $this->ticketType->time_unit_count; $this->end = date( 'Y-m-d', strtotime( $this->start . " +$count $unit -1 day")); if ( isset($this->ticketInstallmentRequest)){ $this->end = date( 'Y-m-d', strtotime( $this->ticketInstallmentRequest->request_target_time_at . " +1 month -1 day")); } } } } \ No newline at end of file diff --git a/common/components/TransferPayout.php b/common/components/TransferPayout.php index 5e78160..d4bad9e 100644 --- a/common/components/TransferPayout.php +++ b/common/components/TransferPayout.php @@ -75,10 +75,11 @@ class TransferPayout extends \yii\base\Object{ public function isTransferCountMatchWithRequestesTransferCount(){ return count($this->transfers) == count($this->idTransfers); } - + /** - * @param common\models\Transfer $transfer the transfer to payout - * */ + * @param \common\models\Transfer $transfer the transfer to payout + * @throws Exception + */ protected function payoutTransfer($transfer){ $transfer->paid_by = $this->idUser; diff --git a/common/components/giro/GiroBankszamla.php b/common/components/giro/GiroBankszamla.php index ae2331e..423ae43 100644 --- a/common/components/giro/GiroBankszamla.php +++ b/common/components/giro/GiroBankszamla.php @@ -1,7 +1,7 @@ duplumKod = \Yii::$app->params['ugiro_duplom_kod']; @@ -44,8 +55,13 @@ class GiroBeszed extends GiroBase { return $fej->toString (); } - - public static function createTetelek($requests,$terhelesiDatum){ + + /** + * @param $requests + * @param $terhelesiDatum + * @return string + */ + public static function createTetelek($requests, $terhelesiDatum){ $s = ""; $i = 0; foreach ($requests as $request){ @@ -54,10 +70,12 @@ class GiroBeszed extends GiroBase { } return $s; } - + /** - * @param common\models\TicketInstallmentRequest $request - * */ + * @param \common\models\TicketInstallmentRequest $request + * + * @return string + */ public static function createTetel($request,$sorszam,$terhelesiDatum) { $tetel = new GiroBeszedTetel (); $customer = $request->customer; @@ -74,7 +92,11 @@ class GiroBeszed extends GiroBase { return $tetel->toString(); } - + + /** + * @param $requests + * @return string + */ public static function createLab($requests) { $lab = new GiroBeszedLab (); @@ -88,8 +110,11 @@ class GiroBeszed extends GiroBase { return $lab->toString (); } - - + + + /** + * @return string + */ public function toString( ) { $s = ""; $s .= $this->fej->toString(); diff --git a/common/components/giro/GiroDETSTA.php b/common/components/giro/GiroDETSTA.php index 488d3e7..a29dfc2 100644 --- a/common/components/giro/GiroDETSTA.php +++ b/common/components/giro/GiroDETSTA.php @@ -2,13 +2,12 @@ namespace common\components\giro; -use common\components\giro\GiroBase; /** * - * @property common\components\giro\GiroDETSTAFej $fej - * @property common\components\giro\GiroDETSTALab $lab - * @property common\components\giro\GiroDETSTATetel $tetelek + * @property \common\components\giro\GiroDETSTAFej $fej + * @property \common\components\giro\GiroDETSTALab $lab + * @property \common\components\giro\GiroDETSTATetel $tetelek * */ class GiroDETSTA extends GiroBase { @@ -48,11 +47,11 @@ class GiroDETSTA extends GiroBase { } /** - * @param common\components\giro\GiroBeszed $beszed + * @param \common\components\giro\GiroBeszed $beszed * */ public static function createBeszedAnswer($beszed){ // /**@var common\components\giro\GiroBeszed $beszed*/ - $beszed = new GiroBeszed(); + //$beszed = new GiroBeszed(); $detsta = new GiroDETSTA(); $detsta->fej = new GiroDETSTAFej(); diff --git a/common/components/giro/GiroDETSTAFej.php b/common/components/giro/GiroDETSTAFej.php index 913b906..ba5b5df 100644 --- a/common/components/giro/GiroDETSTAFej.php +++ b/common/components/giro/GiroDETSTAFej.php @@ -3,8 +3,8 @@ namespace common\components\giro; /** - * @property common\components\giro\GiroUzenetsorszam $csoportosUzenetSorszam - * @property common\components\giro\GiroBankszamla $kezdemenyezoBankszamla + * @property \common\components\giro\GiroUzenetsorszam $csoportosUzenetSorszam + * @property \common\components\giro\GiroBankszamla $kezdemenyezoBankszamla * */ class GiroDETSTAFej extends GiroBase{ @@ -34,7 +34,11 @@ class GiroDETSTAFej extends GiroBase{ . $this->rekordVege() ; } - + + /** + * @param $row + * @return GiroDETSTAFej + */ public static function parse($row){ $fej = new GiroDETSTAFej(); diff --git a/common/components/giro/GiroDETSTATetel.php b/common/components/giro/GiroDETSTATetel.php index af958cf..7fa5276 100644 --- a/common/components/giro/GiroDETSTATetel.php +++ b/common/components/giro/GiroDETSTATetel.php @@ -4,8 +4,8 @@ namespace common\components\giro; /** * - * @property common\components\giro\GiroUzenetsorszam $csoportosUzenetSorszam - * @property common\components\giro\GiroBankszamla $kezdemenyezoBankszamla + * @property \common\components\giro\GiroUzenetsorszam $csoportosUzenetSorszam + * @property \common\components\giro\GiroBankszamla $kezdemenyezoBankszamla * */ class GiroDETSTATetel extends GiroBase { @@ -23,7 +23,7 @@ class GiroDETSTATetel extends GiroBase { '99' => "egyéb hiba" ]; - public $recordTipus = "01"; + public $recordTipus = "02"; public $tetelSorszam = "0"; public $osszeg = "0"; public $eredetiTetelElszamolasiDatuma = ""; diff --git a/common/config/params.php b/common/config/params.php index 987889d..97d1ede 100644 --- a/common/config/params.php +++ b/common/config/params.php @@ -5,7 +5,7 @@ return [ 'supportEmail' => 'rocho02@gmail.com', 'infoEmail' => 'info@rocho-net.hu', 'user.passwordResetTokenExpire' => 3600, - 'version' => 'v0.0.79', + 'version' => 'v0.0.80', 'company' => 'movar',//gyor 'company_name' => "Freimann Kft.", 'product_visiblity' => 'account',// on reception which products to display. account or global diff --git a/common/models/Contract.php b/common/models/Contract.php index 3c65874..0462d69 100644 --- a/common/models/Contract.php +++ b/common/models/Contract.php @@ -23,6 +23,9 @@ use common\components\Helper; * @property string $created_at * @property string $updated_at * @property string $started_at + * @property \common\models\Discount discount + * @property \common\models\Customer customer + * @property \common\models\TicketType ticketType */ class Contract extends \yii\db\ActiveRecord { diff --git a/common/models/Customer.php b/common/models/Customer.php index 92716ac..c533445 100644 --- a/common/models/Customer.php +++ b/common/models/Customer.php @@ -1,9 +1,7 @@ status); + $s = self::statuses( ); if ( array_key_exists($this->status, $s)){ $result = $s[$this->status]; } diff --git a/common/models/TicketInstallmentRequest.php b/common/models/TicketInstallmentRequest.php index 7c67837..453d43d 100644 --- a/common/models/TicketInstallmentRequest.php +++ b/common/models/TicketInstallmentRequest.php @@ -28,8 +28,10 @@ use common\components\Helper; * @property string $updated_at * @property string $detsta_answer * @property string $comment - * @property string $updated_at - * @property common\components\giro\GiroDETSTATetel $detstaTetel GiroDetstaTetel record a DetSta fájlból + * @property \common\components\giro\GiroDETSTATetel $detstaTetel GiroDetstaTetel record a DetSta fájlból + * @property \common\models\Contract contract + * @property \common\models\Customer customer + * @property string number */ class TicketInstallmentRequest extends \yii\db\ActiveRecord { @@ -242,9 +244,9 @@ class TicketInstallmentRequest extends \yii\db\ActiveRecord /** - * @param common\models\Ticket $ticket - * @param common\models\TicketType $type - * @return common\models\TicketInstallmentRequest[] + * @param \common\models\Ticket $ticket + * @param \common\models\TicketType $type + * @return \common\models\TicketInstallmentRequest[] * */ public static function createInstallments($ticket,$type,$customer,$contract){ $result = []; diff --git a/common/models/Ugiro.php b/common/models/Ugiro.php index 34435a4..74e7bbb 100644 --- a/common/models/Ugiro.php +++ b/common/models/Ugiro.php @@ -18,6 +18,8 @@ use yii\helpers\ArrayHelper; * @property string $created_at * @property string $updated_at * @property string $terhelesi_datum + * @property mixed requests + * @property int status */ class Ugiro extends \yii\db\ActiveRecord { diff --git a/console/controllers/DetstaConsoleController.php b/console/controllers/DetstaConsoleController.php index c458016..874c147 100644 --- a/console/controllers/DetstaConsoleController.php +++ b/console/controllers/DetstaConsoleController.php @@ -2,6 +2,11 @@ namespace console\controllers; +use common\components\giro\GiroDETSTA; +use common\components\giro\GiroDETSTAFej; +use common\components\giro\GiroDETSTALab; +use common\components\giro\GiroDETSTATetel; +use common\models\Ugiro; use yii\console\Controller; use frontend\models\ContractForm; use common\models\TicketType; @@ -37,7 +42,61 @@ class DetstaConsoleController extends Controller{ $contractForm->make(); } - - + + + /** + * @param integer $id_ugiro + */ + public function actionDetstaAnswer($id_ugiro,$accepted = 1){ + + /** @var \common\models\Ugiro $ugiro */ + $ugiro = Ugiro::findOne($id_ugiro); + /** @var \common\components\giro\\GiroDETSTA $detsta */ + $detsta = new GiroDETSTA(); + /** @var \common\components\giro\GiroDETSTAFej $detsta */ + $detsta->fej = new GiroDETSTAFej(); + + + $detsta->fej->jelentesJelzo = 8; + $detsta->fej->kezdemenyezoAzonosito =\Yii::$app->params['ugiro_kezdemenyezo_azonosito']; + $detsta->fej->csoportosUzenetSorszam->osszeallitasDatuma = $ugiro->datum; + $detsta->fej->csoportosUzenetSorszam->sorszam = $ugiro->number; + $detsta->fej->detstaUzenetSorszam->osszeallitasDatuma = $ugiro->datum; + $detsta->fej->detstaUzenetSorszam->sorszam = $ugiro->number; + + + + $detsta->lab = new GiroDETSTALab(); + + $tetelek = $ugiro->requests; + /** @var \common\models\TicketInstallmentRequest $tetel */ + foreach ($tetelek as $tetel ){ + $detstaTetel = new GiroDETSTATetel(); + + $detstaTetel->tetelSorszam = $tetel->number; + $detstaTetel->osszeg = $tetel->money; + $detstaTetel->eredetiTetelElszamolasiDatuma = $ugiro->datum; + if ( $accepted == "1"){ + $detstaTetel->visszajelzesInformacio = GiroDETSTATetel::$INFORMACIO_TELJESITETT; + }else{ + $detstaTetel->visszajelzesInformacio = '50'; + } + $detstaTetel->feldolgozasDatum = $ugiro->datum; + $detstaTetel->terhelesiDatum = $ugiro->datum; + $detstaTetel->valaszHivatkozasiKod = '1234'; + $detstaTetel->eredetiHivatkozasiKod = '1234'; + $detstaTetel->ugyfelAzonosito = $tetel->customer->id_customer; + + $detsta->tetelek[] = $detstaTetel; + + + } + + $content = $detsta->toString(); + + file_put_contents('c:\tmp\detsta.txt',$content); + + } + } \ No newline at end of file diff --git a/frontend/controllers/ContractController.php b/frontend/controllers/ContractController.php index 400e170..b520b57 100644 --- a/frontend/controllers/ContractController.php +++ b/frontend/controllers/ContractController.php @@ -42,11 +42,12 @@ class ContractController extends Controller { ] ]; } - + /** * Lists all Contract models. - * + * @param $id_card * @return mixed + * @throws \Yii\web\NotFoundHttpException */ public function actionIndex($id_card) { $card = Card::findOne ( $id_card );