add ticket installment

This commit is contained in:
Roland Schneider 2016-01-22 14:45:56 +01:00
parent bb5978c1df
commit a2a6b1f240
51 changed files with 1498 additions and 113 deletions

5
.gitignore vendored
View File

@ -34,3 +34,8 @@ phpunit.phar
/frontend/web/profile/** /frontend/web/profile/**
!/frontend/web/profile/.gitkeep !/frontend/web/profile/.gitkeep
/frontend/web/uploads/** /frontend/web/uploads/**
/backend/web/giro/megbizas/**
!/backend/web/giro/megbizas/.gitkeep
/backend/web/giro/valasz/**
!/backend/web/giro/valasz/.gitkeep

5
backend/0209ch7z.det Normal file
View File

@ -0,0 +1,5 @@
01DETSTA8A24237545 201501270001201502094542162957
020000010000014097201501270020150204201502031104 03916201502031001307001595 0015520150127321538700000000000000000000000340
020000020000015240201501275020150204 1117 73377201502033417908001595 0015520150127321538800000000000000000000000347
020000030000015240201501270020150204201502031120 94002201502030005151001595 0015520150127321538900000000000000000000000176
03000002000000000002933700000100000000000152400000000000000000000000

View File

@ -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ö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öteg létrehozás', 'url' => ['/ticket-installment-request/download-giro' ] ];
$items[] = ['label' => 'GIRO kötegek', 'url' => ['/ugiro/index' ] ]; $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' => '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' => 'Napi bevételek', 'url' => ['/transfer/list', 'TransferListSearch[start]' =>$todayDatetime,'TransferListSearch[end]' => $tomorrowDatetime ] ];
// $items[] = ['label' => 'Kassza müveletek', 'url' => ['/account-state/index'] ]; // $items[] = ['label' => 'Kassza müveletek', 'url' => ['/account-state/index'] ];

View File

@ -25,6 +25,7 @@ class TicketInstallmentRequestController extends Controller
'class' => VerbFilter::className(), 'class' => VerbFilter::className(),
'actions' => [ 'actions' => [
'delete' => ['post'], '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. * Lists pending TicketInstallmentRequest models.
* @return mixed * @return mixed

View File

@ -8,6 +8,9 @@ use backend\models\UgiroSearch;
use yii\web\Controller; use yii\web\Controller;
use yii\web\NotFoundHttpException; use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter; use yii\filters\VerbFilter;
use common\components\DetStatProcessor;
use backend\models\DestaUploadForm;
use yii\web\UploadedFile;
/** /**
* UgiroController implements the CRUD actions for Ugiro model. * UgiroController implements the CRUD actions for Ugiro model.
@ -40,6 +43,24 @@ class UgiroController extends Controller
'dataProvider' => $dataProvider, '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. * Displays a single Ugiro model.
@ -48,6 +69,20 @@ class UgiroController extends Controller
*/ */
public function actionView($id) 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', [ return $this->render('view', [
'model' => $this->findModel($id), 'model' => $this->findModel($id),
]); ]);
@ -103,6 +138,35 @@ class UgiroController extends Controller
return $this->redirect(['index']); 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. * Finds the Ugiro model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown. * If the model is not found, a 404 HTTP exception will be thrown.

5
backend/detsta.txt Normal file
View File

@ -0,0 +1,5 @@
01DETSTA8A24237545 201501270001201502094542162957
020000010000014097201501270020150204201502031104 03916201502031001307001595 0015520150127321538700000000000000000000000340
020000020000015240201501275020150204 1117 73377201502033417908001595 0015520150127321538800000000000000000000000347
020000030000015240201501270020150204201502031120 94002201502030005151001595 0015520150127321538900000000000000000000000176
03000002000000000002933700000100000000000152400000000000000000000000

View File

@ -0,0 +1,68 @@
<?php
namespace backend\models;
use yii\base\Model;
use yii\web\UploadedFile;
use common\components\giro\GiroDETSTA;
use common\models\Ugiro;
class DestaUploadForm extends Model
{
/**
* @var UploadedFile
*/
public $destaFile;
public $koteg;
public function rules()
{
return [
[['destaFile'], 'file', 'skipOnEmpty' => 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;
}
}
}

View File

@ -16,6 +16,7 @@ use yii\helpers\FileHelper;
use yii\helpers\Inflector; use yii\helpers\Inflector;
use yii\helpers\BaseInflector; use yii\helpers\BaseInflector;
use common\models\UgiroRequestAssignment; use common\models\UgiroRequestAssignment;
use yii\db\Query;
/** /**
* ContactForm is the model behind the contact form. * ContactForm is the model behind the contact form.
@ -91,14 +92,31 @@ class GiroKotegForm extends Model{
$this->koteg = new Ugiro(); $this->koteg = new Ugiro();
$this->koteg->status = Ugiro::$STATUS_SENT; $this->koteg->status = Ugiro::$STATUS_SENT;
$this->koteg->id_user = \Yii::$app->user->id; $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); $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(){ public function readRequests(){
$this->requests = TicketInstallmentRequest::find()->andWhere(['status' => TicketInstallmentRequest::$STATUS_MARKED_TO_SEND])->all(); $this->requests = TicketInstallmentRequest::find()->andWhere(['status' => TicketInstallmentRequest::$STATUS_MARKED_TO_SEND])->all();
} }
public function generateFileContent(){ 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( ) { public function saveFile( ) {

View File

@ -30,13 +30,15 @@ class TicketInstallmentRequestSearch extends TicketInstallmentRequest
public $customer_name; public $customer_name;
public $id_ticket_type; public $id_ticket_type;
public $id_ugiro;
/** /**
* @inheritdoc * @inheritdoc
*/ */
public function rules() public function rules()
{ {
return [ 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'], [['customer_name' ], 'safe'],
[[ 'start', ], 'date' , 'timestampAttribute' => 'timestampStart' ,'timestampAttributeFormat' => 'yyyy-MM-dd' ], [[ 'start', ], 'date' , 'timestampAttribute' => 'timestampStart' ,'timestampAttributeFormat' => 'yyyy-MM-dd' ],
[[ 'end' , ], 'date' , 'timestampAttribute' => 'timestampEnd' ,'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.start as ticket_start',//ticket_start
'ticket.end as ticket_end',//ticket_send 'ticket.end as ticket_end',//ticket_send
'ticket.id_ticket as ticket_id_ticket',//id_ticket '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->from("ticket_installment_request");
$query->innerJoin("customer","customer.id_customer = ticket_installment_request.id_customer"); $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","ticket.id_ticket = ticket_installment_request.id_ticket");
$query->innerJoin("ticket_type","ticket.id_ticket_type = ticket_type.id_ticket_type"); $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]); $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->timestampProcessedStart]);
$query->andFilterWhere(['<', 'ticket_installment_request.request_processed_at', $this->timestampProcessedEnd]); $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([ $dataProvider = new ArrayDataProvider([
'allModels' => $query->all(), 'allModels' => $query->all(),
// 'sort' => [ // 'sort' => [

View File

@ -37,7 +37,7 @@ class TicketSearch extends Ticket
public function rules() public function rules()
{ {
return [ 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' ], [[ 'start', ], 'date' , 'timestampAttribute' => 'timestampStart' ,'timestampAttributeFormat' => 'yyyy-MM-dd' ],
[[ 'end' , ], 'date' , 'timestampAttribute' => 'timestampEnd' ,'timestampAttributeFormat' => 'yyyy-MM-dd' ], [[ 'end' , ], 'date' , 'timestampAttribute' => 'timestampEnd' ,'timestampAttributeFormat' => 'yyyy-MM-dd' ],
[['valid_in_interval','created_in_interval','expire_in_interval'],'boolean'] , [['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_ticket_type' => $this->id_ticket_type,
'id_account' => $this->id_account, 'id_account' => $this->id_account,
'id_card' => $this->id_card, 'id_card' => $this->id_card,
'id_ticket' => $this->id_ticket 'id_ticket' => $this->id_ticket,
'status' => $this->status
]); ]);

View File

@ -3,8 +3,31 @@
use common\models\TicketInstallmentRequest; use common\models\TicketInstallmentRequest;
use common\models\Ticket; use common\models\Ticket;
use yii\helpers\Html;
?> ?>
<?php
$statusStyle = "";
if ( $model['request_status'] == TicketInstallmentRequest::$STATUS_ACCEPTED || $model['request_status'] == TicketInstallmentRequest::$STATUS_ACCEPTED_MANUAL ){
$statusStyle = "accepted";
}else if ($model['request_status'] == TicketInstallmentRequest::$STATUS_REJECTED ){
$statusStyle = "rejected";
}
?>
<style>
.accepted table td.status {
background-color: green;
}
.rejected table td.status {
background-color: #dd4b39;
}
</style>
<div class="panel panel-default">
<div class="panel-body">
<div class="request-view <?= $statusStyle ?>">
<table class="table table-striped"> <table class="table table-striped">
<tr> <tr>
<th> <th>
@ -16,7 +39,7 @@ use common\models\Ticket;
<th> <th>
Megbízás státusza Megbízás státusza
</th> </th>
<td> <td class="status">
<?php echo TicketInstallmentRequest::toStatusName( $model['request_status'] );?> <?php echo TicketInstallmentRequest::toStatusName( $model['request_status'] );?>
</td> </td>
<th> <th>
@ -25,8 +48,7 @@ use common\models\Ticket;
<td> <td>
<?php echo $model['request_money'] ." Ft";?> <?php echo $model['request_money'] ." Ft";?>
</td> </td>
</tr>
<tr>
<tr> <tr>
<th> <th>
Megbízás inditására irányzott dátum Megbízás inditására irányzott dátum
@ -47,7 +69,7 @@ use common\models\Ticket;
<?php echo \Yii::$app->formatter->asDatetime( $model['request_processed_at'] );?> <?php echo \Yii::$app->formatter->asDatetime( $model['request_processed_at'] );?>
</td> </td>
<tr> </tr>
<tr> <tr>
<th> <th>
Megbízás prioritása Megbízás prioritása
@ -56,15 +78,17 @@ use common\models\Ticket;
<?php echo $model['request_priority'] ;?> <?php echo $model['request_priority'] ;?>
</td> </td>
<th> <th>
Köteg azonosító
</th> </th>
<td> <td>
<?php echo $model['ugiro_id_ugiro'] ;?>
</td> </td>
<th> <th>
</th> </th>
<td> <td>
</td> </td>
<tr> </tr>
<tr> <tr>
<th> <th>
Vendég azonosító Vendég azonosító
@ -82,7 +106,7 @@ use common\models\Ticket;
</th> </th>
<td> <td>
</td> </td>
<tr> </tr>
<tr> <tr>
<th> <th>
Bérlet azonosító Bérlet azonosító
@ -102,7 +126,7 @@ use common\models\Ticket;
<td> <td>
<?php echo Ticket::toStatusName( $model['ticket_status'] );?> <?php echo Ticket::toStatusName( $model['ticket_status'] );?>
</td> </td>
<tr> </tr>
<tr> <tr>
<th> <th>
Bérlet érvényességének kezdete Bérlet érvényességének kezdete
@ -120,5 +144,19 @@ use common\models\Ticket;
</th> </th>
<td> <td>
</td> </td>
<tr> </tr>
</table> </table>
<div >
<?php
if ( !empty( $model['ugiro_id_ugiro'] )){
echo Html::a("Köteg",['ugiro/view', 'id' => $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']);
}
?>
</div>
</div>
</div>
</div>

View File

@ -28,7 +28,9 @@ $ticketTypeOptions = ['' => 'Mind'] + ArrayHelper::map(TicketType::read(), 'i
<div class="col-md-3"> <div class="col-md-3">
<?= $form->field($model, 'id_ticket_installment_request')->label("Megbízás azonosító") ?> <?= $form->field($model, 'id_ticket_installment_request')->label("Megbízás azonosító") ?>
</div> </div>
<div class="col-md-3">
<?= $form->field($model, 'id_ugiro')->label("Köteg azonosító") ?>
</div>
<div class="col-md-3"> <div class="col-md-3">
<?= $form->field($model, 'id_ticket')->label("Bérlet azonosító") ?> <?= $form->field($model, 'id_ticket')->label("Bérlet azonosító") ?>
</div> </div>
@ -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 )') ?> ])->label('Megbízás inditására irányzott dátum vége ( exklúzív )') ?>
</div> </div>
</div> </div>
<?php /*?>
<div class="row"> <div class="row">
<div class="col-md-3"> <div class="col-md-3">
<?= $form->field($model, 'sentStart')->widget(DatePicker::classname(), [ <?= $form->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 )') ?> ])->label('Megbízás elindításának időszak vége ( exklúzív )') ?>
</div> </div>
</div> </div>
<?php */ ?>
<div class="row"> <div class="row">
<div class="col-md-3"> <div class="col-md-3">
<?= $form->field($model, 'processedStart')->widget(DatePicker::classname(), [ <?= $form->field($model, 'processedStart')->widget(DatePicker::classname(), [
@ -128,8 +132,7 @@ $ticketTypeOptions = ['' => 'Mind'] + ArrayHelper::map(TicketType::read(), 'i
<?php // echo $form->field($model, 'updated_at') ?> <?php // echo $form->field($model, 'updated_at') ?>
<div class="form-group"> <div class="form-group">
<?= Html::submitButton(Yii::t('common/ticket_installment_request', 'Search'), ['class' => 'btn btn-primary']) ?> <?= Html::submitButton("Keresés", ['class' => 'btn btn-primary']) ?>
<?= Html::resetButton(Yii::t('common/ticket_installment_request', 'Reset'), ['class' => 'btn btn-default']) ?>
</div> </div>
<?php ActiveForm::end(); ?> <?php ActiveForm::end(); ?>

View File

@ -12,6 +12,13 @@ use yii\base\Widget;
$this->title = Yii::t('common/ticket_installment_request', 'Bérlet fizetési megbízások'); $this->title = Yii::t('common/ticket_installment_request', 'Bérlet fizetési megbízások');
$this->params['breadcrumbs'][] = $this->title; $this->params['breadcrumbs'][] = $this->title;
?> ?>
<style>
a.btn{
margin-right: 6px;
}
</style>
<div class="ticket-installment-request-index"> <div class="ticket-installment-request-index">
<h1><?= Html::encode($this->title) ?></h1> <h1><?= Html::encode($this->title) ?></h1>

View File

@ -2,49 +2,207 @@
use yii\helpers\Html; use yii\helpers\Html;
use yii\widgets\DetailView; use yii\widgets\DetailView;
use common\models\TicketInstallmentRequest;
use common\models\Ticket;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */ /* @var $this yii\web\View */
/* @var $model common\models\TicketInstallmentRequest */ /* @var $model common\models\TicketInstallmentRequest */
$this->title = $model->id_ticket_installment_request; $this->title = "Megbízás: " . $model->id_ticket_installment_request;
$this->params['breadcrumbs'][] = ['label' => Yii::t('common/ticket_installment_request', 'Ticket Installment Requests'), 'url' => ['index']]; $this->params['breadcrumbs'][] = ['label' => "Megbízások", 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title; $this->params['breadcrumbs'][] = $this->title;
?> ?>
<?php
$statusStyle = "";
if ( $model->isStatusAccepted() ){
$statusStyle = "accepted";
}else if ( $model->isStatusRejected() ){
$statusStyle = "rejected";
}
?>
<style>
.accepted table td.status {
background-color: green;
}
.rejected table td.status {
background-color: #dd4b39;
}
a.btn{
margin-right: 6px;
}
</style>
<div class="ticket-installment-request-view"> <div class="ticket-installment-request-view">
<h1><?= Html::encode($this->title) ?></h1> <h1><?= Html::encode($this->title) ?></h1>
<p>
<?= Html::a(Yii::t('common/ticket_installment_request', 'Update'), ['update', 'id' => $model->id_ticket_installment_request], ['class' => 'btn btn-primary']) ?>
<?= Html::a(Yii::t('common/ticket_installment_request', 'Delete'), ['delete', 'id' => $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',
],
]) ?>
</p>
<?= DetailView::widget([
'model' => $model,
'attributes' => [ <div class="panel panel-default">
'id_ticket_installment_request', <div class="panel-body">
'id_ticket', <?php
'id_customer', if ( $model->isStatusRejected()){
'id_transfer', echo Html::a("Teljesítettnek jelölés",['accept', 'id' => $model->id_ticket_installment_request] ,['data-method' =>'post', 'class' => 'btn btn-danger']);
'status', }
'money', ?>
'customer_name', <div class="request-view <?= $statusStyle ?>">
'bank_name',
'bank_address', <table class="table table-striped">
'bank_account', <tr>
'priority', <th>
'request_sent_at', Megbízás azonosító
'request_processed_at', </th>
'request_target_time_at', <td>
'created_at', <?php echo "".$model->id_ticket_installment_request;?>
'updated_at', </td>
], <th>
]) ?> Megbízás státusza
</th>
<td class="status">
<?php echo TicketInstallmentRequest::toStatusName( $model->status );?>
</td>
<th>
Megbízás összege
</th>
<td>
<?php echo $model->money." Ft";?>
</td>
</tr>
<tr>
<th>
Megbízás inditására irányzott dátum
</th>
<td>
<?php echo \Yii::$app->formatter->asDatetime( $model->request_target_time_at );?>
</td>
<th>
Megbízás elindításának ideje
</th>
<td>
<?php echo \Yii::$app->formatter->asDatetime( $model->request_sent_at);?>
</td>
<th>
Megbízás feldoglozásának ideje
</th>
<td>
<?php echo \Yii::$app->formatter->asDatetime( $model->request_processed_at );?>
</td>
</tr>
<tr>
<th>
Megbízás prioritása (Sorszám)
</th>
<td>
<?php echo $model->priority ;?>
</td>
<th>
Köteg azonosító
</th>
<td>
<?php echo $model->idGiro ;?>
</td>
<th>
</th>
<td>
</td>
</tr>
<tr>
<th>
Vendég azonosító
</th>
<td>
<?php echo "". $model->customer->id_customer;?>
</td>
<th>
Vendég neve
</th>
<td>
<?php echo "". $model->customer->name;?>
</td>
<th>
</th>
<td>
</td>
</tr>
<tr>
<th>
Bérlet azonosító
</th>
<td>
<?php echo "". $model->ticket->id_ticket;?>
</td>
<th>
Bérlet típus
</th>
<td>
<?php echo $model->ticket->ticketTypeName;?>
</td>
<th>
Bérlet státusza
</th>
<td>
<?php echo Ticket::toStatusName( $model->ticket->status );?>
</td>
</tr>
<tr>
<th>
Bérlet érvényességének kezdete
</th>
<td>
<?php echo \Yii::$app->formatter->asDate( $model->ticket->start) ;?>
</td>
<th>
Bérlet érvényességének vége
</th>
<td>
<?php echo \Yii::$app->formatter->asDate( $model->ticket->end ) ;?>
</td>
<th>
</th>
<td>
</td>
</tr>
<tr>
<th>
Bérlet részletek száma
</th>
<td>
<?php echo $model->ticket->part_count ;?>
</td>
<th>
Bérlet esedékes részlet
</th>
<td>
<?php echo $model->ticket->part ;?>
</td>
<th>
Bérlet utoljára fizetett részlet
</th>
<td>
<?php echo $model->ticket->part_paid ;?>
</td>
</tr>
</table>
<?php
if ( !empty( $model->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']);
?>
</div> </div>
</div>
</div>
</div>

View File

@ -4,6 +4,7 @@ use yii\helpers\Html;
use yii\widgets\ActiveForm; use yii\widgets\ActiveForm;
use yii\helpers\ArrayHelper; use yii\helpers\ArrayHelper;
use kartik\widgets\DatePicker; use kartik\widgets\DatePicker;
use common\models\Ticket;
/* @var $this yii\web\View */ /* @var $this yii\web\View */
/* @var $model backend\models\TicketSearch */ /* @var $model backend\models\TicketSearch */
@ -36,6 +37,15 @@ $userOptions = ['' => 'Mind'] + ArrayHelper::map($model->users, 'id', 'userna
<?= $form->field($model, 'id_account')->dropDownList($accountOptions) ?> <?= $form->field($model, 'id_account')->dropDownList($accountOptions) ?>
</div> </div>
</div> </div>
<div class='row'>
<div class='col-md-4'>
<?= $form->field($model, 'status')->dropDownList( ["" =>"Mind"]+ Ticket::statuses()) ?>
</div>
<div class='col-md-4'>
</div>
<div class='col-md-4'>
</div>
</div>
<div class="row"> <div class="row">
<div class="col-md-4"> <div class="col-md-4">

View File

@ -104,6 +104,10 @@ $this->params['breadcrumbs'][] = $this->title;
'attribute' => 'id_account', 'attribute' => 'id_account',
'value' => 'accountName' 'value' => 'accountName'
], ],
[
'attribute' => 'status',
'value' => 'statusName'
],
// 'max_usage_count', // 'max_usage_count',
// 'usage_count', // 'usage_count',

View File

@ -19,17 +19,36 @@ $this->params['breadcrumbs'][] = $this->title;
'model' => $model, 'model' => $model,
'attributes' => [ 'attributes' => [
'id_ticket', 'id_ticket',
'id_user', [
'id_ticket_type', 'attribute' => 'id_user',
'id_account', 'value' => $model->user->username,
'id_discount',
'start', ],
'end', [
'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', 'max_usage_count',
'usage_count', 'usage_count',
'status', [
'attribute' => 'status',
'value' => $model->statusName
],
'price_brutto', 'price_brutto',
'comment', 'comment:raw',
'created_at', 'created_at',
'updated_at', 'updated_at',
], ],

View File

@ -0,0 +1,26 @@
<?php
/* @var $this yii\web\View */
/* @var $model common\components\DetStatProcessor */
?>
detsta
<?php
echo $model->koteg->id_ugiro;
$model->run();
$megbizasok = $model->megbizasok;
echo "<br>Megbízások száma:". count($megbizasok);
foreach ($megbizasok as $m){
echo "<br>". $m->id_ticket_installment_request . " - " . ($m->detstaTetel->toString());
}
echo "<br>" . nl2br( $model->detstatUzenet->toString());
print_r($model->errors);
?>

View File

@ -0,0 +1,27 @@
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model common\models\Ugiro */
/* @var $form yii\widgets\ActiveForm */
?>
<h1>DetSta Fájl Feltöltés</h1>
<p>
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
</p>
<div class="ugiro-form">
<?php $form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data']]) ?>
<?= $form->field($model, 'destaFile')->fileInput() ?>
<div class="form-group">
<?= Html::submitButton( "Feltöltés" , ['class' => 'btn btn-primary']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>

View File

@ -4,6 +4,7 @@ use yii\helpers\Html;
use yii\widgets\DetailView; use yii\widgets\DetailView;
use yii\helpers\Url; use yii\helpers\Url;
use common\models\Ugiro; use common\models\Ugiro;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */ /* @var $this yii\web\View */
/* @var $model common\models\Ugiro */ /* @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'][] = ['label' => "Kötegek", 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title; $this->params['breadcrumbs'][] = $this->title;
?> ?>
<style >
.btns a{
margin-right: 6px;
}
a.btn{
margin-right: 6px;
}
</style>
<div class="ugiro-view"> <div class="ugiro-view">
<h1><?= Html::encode($this->title) ?></h1> <h1><?= Html::encode($this->title) ?></h1>
<?php <?php
$attributes = [ $attributes = [
[ [
'attribute' => 'id_ugiro', 'attribute' => 'id_ugiro',
'label' => 'Köteg azonosító' 'label' => 'Köteg azonosító'
], ],
[
'attribute' => 'number',
'label' => 'Üzenet sorszám'
],
[
'attribute' => 'datum',
'label' => 'Üzenet összeállítási dátum'
],
[ [
'attribute' => 'user.username', 'attribute' => 'user.username',
'label' => 'Felhasználó' 'label' => 'Felhasználó'
@ -38,13 +55,21 @@ $attributes = [
], ],
[ [
'attribute' => 'path', '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 ] ), 'value' => Html::a( "Letöltés" , Url::base() ."/". $model->path , ['target' =>'_blank' ,'download' =>'CS-BESZED.' .$model->id_ugiro ] ),
'format' => 'raw' '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 = [
]) ?> ]) ?>
</div> </div>
<div class="btns">
<?php
if ( $model->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']);
?>
</div>

View File

View File

View File

@ -0,0 +1,137 @@
<?php
namespace common\components;
use yii\base\Object;
use common\models\TicketInstallmentRequest;
use common\components\giro\GiroDETSTATetel;
use backend\models\TicketInstallmentMarkForSendForm;
use common\models\Ugiro;
use yii\db\Query;
use common\components\giro\GiroDETSTA;
use common\components\giro\GiroDETSTAFej;
use common\components\giro\GiroDETSTALab;
/**
* This is the model class for table "ticket".
*
* @property common\components\giro\GiroDETSTA $detstatUzenet
* @property common\models\UGiro $koteg
*
* */
class DetStatProcessor extends Object{
/**aktuális koteg, config paraméterként kapju*/
public $koteg;
public $idKoteg;
public $detstatUzenet;
public $megbizasok;
public $errors = [];
public function run(){
// $this->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;
}
}

View File

@ -0,0 +1,129 @@
<?php
namespace common\components;
use yii\base\Object;
use common\models\TicketInstallmentRequest;
use common\components\giro\GiroDETSTATetel;
use backend\models\TicketInstallmentMarkForSendForm;
use common\models\Transfer;
use common\models\Account;
use common\models\Discount;
/**
* This is the model class for table "ticket".
*
* @property common\components\giro\GiroDETSTATetel $tetel
* @property common\models\TicketInstallmentRequest $megbizas
* @property common\models\Ticket $ticket
*
*
*/
class DetStatTetelProcessor extends Object {
public $tetel; // config
public $megbizas; // config
public $ticket;
public $errors = [ ];
public $dryRun = false; // for testing, to not to persist the changes
public function run() {
// $this->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;
}
}

View File

@ -29,11 +29,11 @@ class GiroBase {
return $data; return $data;
} }
public function szovegOlvas($row,$start,$length, $padchar = " "){ public static function szovegOlvas($row,$start,$length, $padchar = " "){
return rtrim(substr($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); return ltrim(substr($row, $start,$length),$padchar);
} }

View File

@ -15,19 +15,24 @@ class GiroBeszed extends GiroBase {
public function __construct() { 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); $s .= self::createLab($requests);
return $s; return $s;
} }
public static function createFej($id) { public static function createFej($number, $daturm) {
$fej = new GiroBeszedFej (); $fej = new GiroBeszedFej ();
$fej->duplumKod = \Yii::$app->params['ugiro_duplom_kod']; $fej->duplumKod = \Yii::$app->params['ugiro_duplom_kod'];
$fej->kezdemenyezoAzonosito = \Yii::$app->params['ugiro_kezdemenyezo_azonosito'];//"A25366936T244"; // "66658092128"; $fej->kezdemenyezoAzonosito = \Yii::$app->params['ugiro_kezdemenyezo_azonosito'];//"A25366936T244"; // "66658092128";
$fej->uzenetSorszam->osszeallitasDatuma = date('Ymd' ); $fej->uzenetSorszam->osszeallitasDatuma = $daturm;
$fej->uzenetSorszam->sorszam = $id; $fej->uzenetSorszam->sorszam = $number;
$fej->kezdemenyezoBankszamla->szamlaszam = \Yii::$app->params['ugiro_kezdemenyezo_szamlaszam']; // "5860025215371128"; $fej->kezdemenyezoBankszamla->szamlaszam = \Yii::$app->params['ugiro_kezdemenyezo_szamlaszam']; // "5860025215371128";
// $fej->kezdemenyezoBankszamla->bankszerv = "58600252"; // "TAKBHUHB"; // $fej->kezdemenyezoBankszamla->bankszerv = "58600252"; // "TAKBHUHB";
$fej->ertesitesiHatarido = ""; $fej->ertesitesiHatarido = "";
@ -36,10 +41,12 @@ class GiroBeszed extends GiroBase {
return $fej->toString (); return $fej->toString ();
} }
public static function createTetelek($requests){ public static function createTetelek($requests,$terhelesiDatum){
$s = ""; $s = "";
$i = 0;
foreach ($requests as $request){ foreach ($requests as $request){
$s .= self::createTetel($request); $i++;
$s .= self::createTetel($request,$i,$terhelesiDatum);
} }
return $s; return $s;
} }
@ -47,19 +54,19 @@ class GiroBeszed extends GiroBase {
/** /**
* @param common\models\TicketInstallmentRequest $request * @param common\models\TicketInstallmentRequest $request
* */ * */
public static function createTetel($request) { public static function createTetel($request,$sorszam,$terhelesiDatum) {
$tetel = new GiroBeszedTetel (); $tetel = new GiroBeszedTetel ();
$customer = $request->customer; $customer = $request->customer;
$tetel->tetelSorszam = $request->id_ticket_installment_request; $tetel->tetelSorszam = $sorszam;
$tetel->terhelesiDatum = date('Ymd' ,strtotime("+5 day"));; $tetel->terhelesiDatum = $terhelesiDatum;
$tetel->osszeg = $request->money; $tetel->osszeg = $request->money;
// $tetel->kotelezettBankszamla->bankszerv = "58600252"; // $tetel->kotelezettBankszamla->bankszerv = "58600252";
$tetel->kotelezettBankszamla->szamlaszam = $customer->bank_account; $tetel->kotelezettBankszamla->szamlaszam = $customer->bank_account;
$tetel->ugyfelazonositoAKezdemenyezonel = $customer->id_customer; $tetel->ugyfelazonositoAKezdemenyezonel = $request->id_ticket_installment_request;
// $tetel->ugyfelNeve = "Schneider Roland"; // $tetel->ugyfelNeve = "Schneider Roland";
// $tetel->ugyfelCime = "Mosonmagyarovar, Gardonyi 31"; // $tetel->ugyfelCime = "Mosonmagyarovar, Gardonyi 31";
$tetel->szamlaTulajdonosNeve = $customer->name; $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(); return $tetel->toString();
} }

View File

@ -6,8 +6,9 @@ use common\components\giro\GiroBase;
/** /**
* *
* @property common\components\giro\GiroUzenetsorszam $uzenetSorszam * @property common\components\giro\GiroDETSTAFej $fej
* @property common\components\giro\GiroBankszamla $kezdemenyezoBankszamla * @property common\components\giro\GiroDETSTALab $lab
* @property common\components\giro\GiroDETSTATetel $tetelek
* *
*/ */
class GiroDETSTA extends GiroBase { 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){ public static function parse($content){
$detsta = new GiroDETSTA(); $detsta = new GiroDETSTA();
$array = preg_split("/\r\n|\n|\r/", $content); $array = preg_split("/\r\n|\n|\r/", $content);
$detsta->fej = GiroDETSTAFej::parse($array[0]); $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]; $row = $array[$i];
$tetel = GiroDETSTATetel::parse($row); $tetel = GiroDETSTATetel::parse($row);
$detsta->tetelek[] = $tetel; $detsta->tetelek[] = $tetel;

View File

@ -43,7 +43,7 @@ class GiroDETSTAFej extends GiroBase{
$fej->jelentesJelzo = substr($row, 8,1); $fej->jelentesJelzo = substr($row, 8,1);
$fej->kezdemenyezoAzonosito = substr($row, 9,13); $fej->kezdemenyezoAzonosito = substr($row, 9,13);
$fej->csoportosUzenetSorszam ->osszeallitasDatuma = substr($row, 22, 8); $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 ->osszeallitasDatuma = substr($row, 34,8);
$fej->detstaUzenetSorszam->sorszam = substr($row, 42,4); $fej->detstaUzenetSorszam->sorszam = substr($row, 42,4);
$fej->ido = substr($row, 46,6); $fej->ido = substr($row, 46,6);

View File

@ -17,8 +17,10 @@ class GiroDETSTALab extends GiroBase {
public $visszautasitottTetelekOsszerteke = "0"; public $visszautasitottTetelekOsszerteke = "0";
public $megNemValaszoltTetelekSzama = "0"; public $megNemValaszoltTetelekSzama = "0";
public $megNemValaszoltTetelekOsszerteke = "0"; public $megNemValaszoltTetelekOsszerteke = "0";
public function __construct() { public function __construct() {
} }
public function toString() { public function toString() {
return $this->recordTipus return $this->recordTipus
. $this->szamKitolt ( $this->teljesitettTetelekSzama, 6 ) . $this->szamKitolt ( $this->teljesitettTetelekSzama, 6 )

View File

@ -39,7 +39,17 @@ class GiroDETSTATetel extends GiroBase {
$this->detstaUzenetSorszam = new GiroUzenetsorszam (); $this->detstaUzenetSorszam = new GiroUzenetsorszam ();
} }
public function toString() { 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) { public static function parse($row) {

View File

@ -233,7 +233,8 @@ class AccountState extends \common\models\BaseFitnessActiveRecord
$this->prev_state = $lastOpen->id_account_state; $this->prev_state = $lastOpen->id_account_state;
$this->prev_money = $lastOpen->money; $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); $this->collection_money = Transfer::readPaid($start, $end, Yii::$app->user->id);

View File

@ -29,6 +29,9 @@ class MoneyMovement extends \yii\db\ActiveRecord
const TYPE_OUT = 10; const TYPE_OUT = 10;
const TYPE_IN = 20; const TYPE_IN = 20;
const STATUS_PAID = 20;
const STATUS_STORNO = 30;
public $_account; public $_account;
/** /**
@ -140,4 +143,23 @@ class MoneyMovement extends \yii\db\ActiveRecord
return self::typeName($this->type); 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);
}
} }

View File

@ -37,6 +37,7 @@ class Sale extends \yii\db\ActiveRecord
const STATUS_NOT_PAID = 10; const STATUS_NOT_PAID = 10;
const STATUS_PAID = 20; const STATUS_PAID = 20;
const STATUS_DELETED= 30;
/** /**
* @inheritdoc * @inheritdoc
@ -140,4 +141,26 @@ class Sale extends \yii\db\ActiveRecord
return $sale; 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);
}
} }

View File

@ -23,6 +23,9 @@ use common\components\Helper;
* @property integer $usage_count * @property integer $usage_count
* @property integer $status * @property integer $status
* @property integer $price_brutto * @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 $comment
* @property string $created_at * @property string $created_at
* @property string $updated_at * @property string $updated_at
@ -31,6 +34,7 @@ class Ticket extends \common\models\BaseFitnessActiveRecord
{ {
const STATUS_DELETED = 0; const STATUS_DELETED = 0;
const STATUS_ACTIVE = 10; const STATUS_ACTIVE = 10;
const STATUS_INACTIVE = 20;
/** /**
* @inheritdoc * @inheritdoc
@ -200,10 +204,10 @@ class Ticket extends \common\models\BaseFitnessActiveRecord
new Expression( 'ticket_type.name as name'), new Expression( 'ticket_type.name as name'),
new Expression( 'coalesce( count(ticket.id_ticket),0) as total'), 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 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 ". 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 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 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 " . 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::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 [ return [
Ticket::STATUS_ACTIVE => 'Aktív', Ticket::STATUS_ACTIVE => 'Aktív',
Ticket::STATUS_DELETED => 'Törölve', Ticket::STATUS_DELETED => 'Törölve',
Ticket::STATUS_INACTIVE => 'Inaktív',
]; ];
} }
@ -249,4 +254,62 @@ class Ticket extends \common\models\BaseFitnessActiveRecord
return $result; 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;
}
}
}
} }

View File

@ -25,6 +25,7 @@ use yii\behaviors\TimestampBehavior;
* @property string $request_target_time_at * @property string $request_target_time_at
* @property string $created_at * @property string $created_at
* @property string $updated_at * @property string $updated_at
* @property common\components\giro\GiroDETSTATetel $detstaTetel GiroDetstaTetel record a DetSta fájlból
*/ */
class TicketInstallmentRequest extends \yii\db\ActiveRecord class TicketInstallmentRequest extends \yii\db\ActiveRecord
{ {
@ -36,6 +37,12 @@ class TicketInstallmentRequest extends \yii\db\ActiveRecord
public static $STATUS_CANCELED = 30; public static $STATUS_CANCELED = 30;
public static $STATUS_REJECTED = 40; public static $STATUS_REJECTED = 40;
public static $STATUS_ACCEPTED = 50; public static $STATUS_ACCEPTED = 50;
public static $STATUS_ACCEPTED_MANUAL = 60;
/**
* GiroDetstaTetel record a DetSta fájlból
* */
public $detstaTetel;
/** /**
* @inheritdoc * @inheritdoc
@ -98,6 +105,90 @@ class TicketInstallmentRequest extends \yii\db\ActiveRecord
return $this->hasOne( Customer::className(), ["id_customer" =>"id_customer" ] ); 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\Ticket $ticket
* @param common\models\TicketType $type * @param common\models\TicketType $type
@ -107,8 +198,12 @@ class TicketInstallmentRequest extends \yii\db\ActiveRecord
$result = []; $result = [];
if ( $type->isInstallment() ){ if ( $type->isInstallment() ){
$count = $type->installment_count; $count = $type->installment_count;
$ticketCreatedAt = time(); $discount = $ticket->discount;
$money = $type->price_brutto; $money = $type->price_brutto;
if ( isset($discount ) ){
$money = Discount::applyDiscount($money, $discount);
}
$ticketCreatedAt = time();
for ( $i = 1; $i <= $count; $i++){ for ( $i = 1; $i <= $count; $i++){
$request = TicketInstallmentRequest::createInstallment($ticket, $type, $customer, $money, $ticketCreatedAt, $i); $request = TicketInstallmentRequest::createInstallment($ticket, $type, $customer, $money, $ticketCreatedAt, $i);
$result[] = $request; $result[] = $request;
@ -140,6 +235,7 @@ class TicketInstallmentRequest extends \yii\db\ActiveRecord
TicketInstallmentRequest::$STATUS_CANCELED=> 'Törölve', TicketInstallmentRequest::$STATUS_CANCELED=> 'Törölve',
TicketInstallmentRequest::$STATUS_REJECTED=> 'Visszautasítva', TicketInstallmentRequest::$STATUS_REJECTED=> 'Visszautasítva',
TicketInstallmentRequest::$STATUS_ACCEPTED=> 'Sikeresen végrehajtva', TicketInstallmentRequest::$STATUS_ACCEPTED=> 'Sikeresen végrehajtva',
TicketInstallmentRequest::$STATUS_ACCEPTED_MANUAL=> 'Manuálisan elfogadva',
]; ];
} }

View File

@ -46,6 +46,7 @@ class Transfer extends \common\models\BaseFitnessActiveRecord
const STATUS_NOT_PAID = 10; const STATUS_NOT_PAID = 10;
const STATUS_PAID = 20; const STATUS_PAID = 20;
const STATUS_STORNO = 30;
const DIRECTION_OUT = 10;// MONEY GOES OUT FROM ACCOUNT ( COMPANY LOST MONEY ) 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 ) const DIRECTION_IN = 20;//MONEY GOES IN TO THE ACCOUNT ( COMPANY EARN MONEY )
@ -477,6 +478,7 @@ class Transfer extends \common\models\BaseFitnessActiveRecord
return [ return [
self::STATUS_NOT_PAID => Yii::t('common/transfer','Nincs fizetve'), self::STATUS_NOT_PAID => Yii::t('common/transfer','Nincs fizetve'),
self::STATUS_PAID => Yii::t('common/transfer','Fizetve'), self::STATUS_PAID => Yii::t('common/transfer','Fizetve'),
self::STATUS_STORNO => Yii::t('common/transfer','Törölve'),
]; ];
} }
public function getStatusName( ) { 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);
}
}
} }

View File

@ -11,6 +11,10 @@ use yii\helpers\ArrayHelper;
* *
* @property integer $id_ugiro * @property integer $id_ugiro
* @property integer $id_user * @property integer $id_user
* @property string $path
* @property string $desta_path
* @property string $datum
* @property integer $number
* @property string $created_at * @property string $created_at
* @property string $updated_at * @property string $updated_at
*/ */
@ -18,8 +22,10 @@ class Ugiro extends \yii\db\ActiveRecord
{ {
public static $PATH_MEGBIZAS = "giro/megbizas"; public static $PATH_MEGBIZAS = "giro/megbizas";
public static $PATH_VALASZ = "giro/valasz";
public static $STATUS_SENT = 0; public static $STATUS_SENT = 0;
public static $STATUS_FINISHED = 1; public static $STATUS_RECIEVED = 10;
public static $STATUS_FINISHED = 20;
/** /**
* @inheritdoc * @inheritdoc
@ -66,10 +72,19 @@ class Ugiro extends \yii\db\ActiveRecord
return $this->hasOne( User::className(), ["id" =>"id_user" ] ); 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() { public static function statuses() {
return [ return [
static::$STATUS_SENT =>"Folyamatban", static::$STATUS_SENT =>"Folyamatban",
static::$STATUS_FINISHED =>"Befejezve", static::$STATUS_FINISHED =>"Befejezve",
static::$STATUS_RECIEVED =>"Detsta fájl feltöltve",
] ]
; ;
} }

View File

@ -0,0 +1,30 @@
<?php
use yii\db\Schema;
use yii\db\Migration;
class m160120_224044_alter__table__money_movement__add_column__status extends Migration
{
public function up()
{
$this->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()
{
}
*/
}

View File

@ -0,0 +1,32 @@
<?php
use yii\db\Schema;
use yii\db\Migration;
class m160121_083841_alter__table__ticket__add_part__and__parts_paid extends Migration
{
public function up()
{
$this->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()
{
}
*/
}

View File

@ -0,0 +1,30 @@
<?php
use yii\db\Schema;
use yii\db\Migration;
class m160121_183512_alter__table__ugiro__add__desta_path extends Migration
{
public function up()
{
$this->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()
{
}
*/
}

View File

@ -0,0 +1,28 @@
<?php
use yii\db\Schema;
use yii\db\Migration;
class m160121_192759_alter__table__ugiro__uzenet__sorszam extends Migration
{
public function up()
{
$this->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()
{
}
*/
}

View File

@ -162,7 +162,7 @@ class AccountStateController extends Controller {
$total += $cassaOpen->money; $total += $cassaOpen->money;
$openDate = $cassaOpen->created_at; $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; return $total;
} }

View File

@ -21,6 +21,7 @@ use common\models\UserSoldItem;
use frontend\components\FrontendController; use frontend\components\FrontendController;
use frontend\components\DefaultAccountBehavior; use frontend\components\DefaultAccountBehavior;
use frontend\components\CassaOpenBehavior; use frontend\components\CassaOpenBehavior;
use frontend\models\TicketUpdate;
/** /**
* TicketController implements the CRUD actions for Ticket model. * TicketController implements the CRUD actions for Ticket model.
@ -38,7 +39,7 @@ class TicketController extends FrontendController
], ],
'access' => [ 'access' => [
'class' => \yii\filters\AccessControl::className(), 'class' => \yii\filters\AccessControl::className(),
'only' => ['create', 'index' ], 'only' => ['create', 'index','update' ],
'rules' => [ 'rules' => [
// allow authenticated users // 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. * Deletes an existing Transfer model.
* If deletion is successful, the browser will be redirected to the 'index' page. * If deletion is successful, the browser will be redirected to the 'index' page.
@ -152,12 +168,21 @@ class TicketController extends FrontendController
try { try {
ShoppingCart::deleteAll([ 'id_transfer' => $transfer->id_transfer]); ShoppingCart::deleteAll([ 'id_transfer' => $transfer->id_transfer]);
UserSoldItem::deleteAll([ 'id_transfer' => $transfer->id_transfer]); UserSoldItem::deleteAll([ 'id_transfer' => $transfer->id_transfer]);
if ( $transfer->delete() ){ // $transfer->status = Transfer::STATUS_STORNO;
\Yii::$app->session->setFlash( 'success','Bérlet törölve' ); // $transfer->save(false);
// $ticket->status = Ticket::STATUS_DELETED;
// $ticket->save(false);
$transfer->storno();
$transaction->commit(); $transaction->commit();
}else{ \Yii::$app->session->setFlash( 'success','Bérlet törölve' );
throw new \Exception("Failed to save");
} // $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) { } catch(Exception $e) {
$transaction->rollback(); $transaction->rollback();

View File

@ -222,12 +222,13 @@ class TransferController extends Controller
try { try {
ShoppingCart::deleteAll([ 'id_transfer' => $transfer->id_transfer]); ShoppingCart::deleteAll([ 'id_transfer' => $transfer->id_transfer]);
UserSoldItem::deleteAll([ 'id_transfer' => $transfer->id_transfer]); UserSoldItem::deleteAll([ 'id_transfer' => $transfer->id_transfer]);
if ( $transfer->delete() ){ $transfer->storno();
// if ( $transfer->delete() ){
\Yii::$app->session->setFlash( 'success','Tranzakció törölve' ); \Yii::$app->session->setFlash( 'success','Tranzakció törölve' );
$transaction->commit(); $transaction->commit();
}else{ // }else{
throw new \Exception("Failed to save"); // throw new \Exception("Failed to save");
} // }
} catch(Exception $e) { } catch(Exception $e) {
$transaction->rollback(); $transaction->rollback();

View File

@ -83,6 +83,7 @@ class TicketCreate extends Ticket{
//cart //cart
///////////////////// /////////////////////
[['cart'], 'string', 'max' => 10] [['cart'], 'string', 'max' => 10]
]; ];
} }
@ -91,6 +92,18 @@ class TicketCreate extends Ticket{
$type = TicketType::findOne($this->id_ticket_type); $type = TicketType::findOne($this->id_ticket_type);
if ( !isset($type)) { if ( !isset($type)) {
$this->addError($attribute,Yii::t('frontend/ticket' , 'Invalid ticket 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){ public function afterSave($insert, $changedAttributes){
$this->addTransfer(); $this->addTransfer();
$this->appendToUserCart(); $this->appendToUserCart();

View File

@ -0,0 +1,25 @@
<?php
namespace frontend\models;
use common\models\Ticket;
class TicketUpdate extends Ticket{
public function rules(){
return [
////////////////
//status
////////////////
[['status',], 'integer'],
[['status',], 'in', 'range' => [ static ::STATUS_ACTIVE, static ::STATUS_INACTIVE ]],
];
}
}
?>

View File

@ -36,6 +36,11 @@ $this->params['breadcrumbs'][] = $this->title;
'attribute' => 'comment', 'attribute' => 'comment',
'format' => 'html' 'format' => 'html'
], ],
[
'attribute' => 'status',
'value' => 'statusName',
'label' => "Státusz"
],
['class' => 'yii\grid\ActionColumn', ['class' => 'yii\grid\ActionColumn',
'template' => '{view}' 'template' => '{view}'

View File

@ -0,0 +1,84 @@
<?php
use yii\widgets\DetailView;
use common\models\Ticket;
use yii\widgets\ActiveForm;
use yii\helpers\Html;
?>
<div class="ticket-form">
<?php if ( $model->status != Ticket::STATUS_DELETED){?>
<?php
$form = ActiveForm::begin ( [ ] )
// 'id' => 'ticket_form',
;
?>
<?php
$options = Ticket::statuses ();
unset ( $options [Ticket::STATUS_DELETED] );
echo $form->field ( $model, 'status' )->dropDownList ( $options );
?>
<div class="form-group">
<?= Html::submitButton( "Módosítás", ['class' => 'btn btn-success' ]) ?>
</div>
<?php ActiveForm::end(); ?>
<?php } else{ echo "Törölt bérlet"; }?>
</div>
<?php
$attributes = [
'id_ticket',
[
'attribute' => 'id_user',
'value' => $model->user->username
]
,
[
'attribute' => 'id_ticket_type',
'value' => $model->ticketTypeName
]
,
[
'attribute' => 'id_account',
'value' => $model->accountName
]
,
[
'attribute' => 'id_discount',
'value' => $model->discountName
]
,
'start:datetime',
'end:datetime',
'max_usage_count',
'usage_count',
// [
// 'attribute' => 'status',
// 'value' => $model->statusName
// ],
'price_brutto',
'comment:raw',
'created_at',
'updated_at'
];
if ( $model->status == Ticket::STATUS_DELETED ){
$attributes[] = [
'attribute' => 'status',
'value' => $model->statusName
];
}
?>
<?=DetailView::widget ( [ 'model' => $model,'attributes' => $attributes ] )?>

View File

@ -6,6 +6,7 @@ use frontend\components\ReceptionMenuWidget;
use frontend\components\ReceptionCardNumberWidget; use frontend\components\ReceptionCardNumberWidget;
use frontend\components\ReceptionWidget; use frontend\components\ReceptionWidget;
use yii\base\Widget; use yii\base\Widget;
use common\models\Ticket;
/* @var $this yii\web\View */ /* @var $this yii\web\View */
/* @var $searchModel frontend\models\TicketSearch */ /* @var $searchModel frontend\models\TicketSearch */
@ -34,7 +35,11 @@ $this->params['breadcrumbs'][] = $this->title;
<?= GridView::widget([ <?= GridView::widget([
'dataProvider' => $dataProvider, 'dataProvider' => $dataProvider,
'columns' => [ 'columns' => [
[
'attribute' => 'id_ticket',
'value' => 'id_ticket',
'label' => "B. Azonosító"
],
[ [
'attribute' => 'id_account', 'attribute' => 'id_account',
'value' => 'accountName' 'value' => 'accountName'
@ -50,6 +55,10 @@ $this->params['breadcrumbs'][] = $this->title;
[ [
'attribute' => 'id_user', 'attribute' => 'id_user',
'value' => 'userName' 'value' => 'userName'
],
[
'attribute' => 'status',
'value' => 'statusName'
], ],
/* /*
[ [
@ -58,9 +67,31 @@ $this->params['breadcrumbs'][] = $this->title;
], ],
*/ */
'price_brutto', 'price_brutto',
'created_at:datetime', 'created_at:datetime',
['class' => 'yii\grid\ActionColumn', ['class' => 'yii\grid\ActionColumn',
'template' =>'{delete}', 'template' =>'{delete} {update}',
'buttons' => [
'update' => function($url, $model, $key){
return $model->status == Ticket::STATUS_DELETED ? "" : Html::a('<span class="glyphicon glyphicon-pencil"></span>', $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('<span class="glyphicon glyphicon-trash"></span>', $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}'" ;},
], ],
], ],
]); ?> ]); ?>

View File

@ -5,9 +5,7 @@ use yii\helpers\Html;
/* @var $this yii\web\View */ /* @var $this yii\web\View */
/* @var $model common\models\Ticket */ /* @var $model common\models\Ticket */
$this->title = Yii::t('common/ticket', 'Update {modelClass}: ', [ $this->title = "Bérlet módosítása:" . ' ' . $model->id_ticket;
'modelClass' => 'Ticket',
]) . ' ' . $model->id_ticket;
$this->params['breadcrumbs'][] = ['label' => Yii::t('common/ticket', 'Tickets'), 'url' => ['index']]; $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'][] = ['label' => $model->id_ticket, 'url' => ['view', 'id' => $model->id_ticket]];
$this->params['breadcrumbs'][] = Yii::t('common/ticket', 'Update'); $this->params['breadcrumbs'][] = Yii::t('common/ticket', 'Update');
@ -16,7 +14,7 @@ $this->params['breadcrumbs'][] = Yii::t('common/ticket', 'Update');
<h1><?= Html::encode($this->title) ?></h1> <h1><?= Html::encode($this->title) ?></h1>
<?= $this->render('_form', [ <?= $this->render('_form_update', [
'model' => $model, 'model' => $model,
]) ?> ]) ?>

View File

@ -69,13 +69,15 @@ $formatter = Yii::$app->formatter;
</div> </div>
<div class="row"> <div class="row">
<div class="col-md-11 text-right"> <div class="col-md-11 text-right">
<?php echo Html::a('<span class="glyphicon glyphicon-trash"></span>Törlés', Url::toRoute(['delete','id' =>$model->id_transfer]), [ <?php
if ( $model->status != Transfer::STATUS_STORNO){
echo Html::a('<span class="glyphicon glyphicon-trash"></span>Törlés', Url::toRoute(['delete','id' =>$model->id_transfer]), [
'title' => Yii::t('yii', 'Delete'), 'title' => Yii::t('yii', 'Delete'),
'data-confirm' => Yii::t('yii', 'Are you sure to delete this item?'), 'data-confirm' => Yii::t('yii', 'Are you sure to delete this item?'),
'data-method' => 'post', 'data-method' => 'post',
'class' => 'btn btn-danger', 'class' => 'btn btn-danger',
// 'style' =>'margin-right: 12px;' // 'style' =>'margin-right: 12px;'
]);?> ]);}?>
</div> </div>
</div> </div>
</div> </div>