add ticket installment
This commit is contained in:
68
backend/models/DestaUploadForm.php
Normal file
68
backend/models/DestaUploadForm.php
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,7 @@ use yii\helpers\FileHelper;
|
||||
use yii\helpers\Inflector;
|
||||
use yii\helpers\BaseInflector;
|
||||
use common\models\UgiroRequestAssignment;
|
||||
use yii\db\Query;
|
||||
|
||||
/**
|
||||
* ContactForm is the model behind the contact form.
|
||||
@@ -91,14 +92,31 @@ class GiroKotegForm extends Model{
|
||||
$this->koteg = new Ugiro();
|
||||
$this->koteg->status = Ugiro::$STATUS_SENT;
|
||||
$this->koteg->id_user = \Yii::$app->user->id;
|
||||
|
||||
$this->koteg->datum = date('Ymd');
|
||||
|
||||
$lastNumber = $this->loadLastNumber($this->koteg->datum);
|
||||
$nextNumber = $lastNumber+1;
|
||||
$this->koteg->number = $nextNumber;
|
||||
|
||||
$this->success &= $this->koteg->save(false);
|
||||
}
|
||||
|
||||
|
||||
public function loadLastNumber($datum){
|
||||
$query = new Query();
|
||||
$query->select(['coalesce(max(number),0)']);
|
||||
$query->from('ugiro');
|
||||
$query->andWhere(["datum" => $datum]);
|
||||
return $query->scalar();
|
||||
}
|
||||
|
||||
public function readRequests(){
|
||||
$this->requests = TicketInstallmentRequest::find()->andWhere(['status' => TicketInstallmentRequest::$STATUS_MARKED_TO_SEND])->all();
|
||||
}
|
||||
|
||||
public function generateFileContent(){
|
||||
$this->content = GiroBeszed::createFileContent($this->koteg->id_ugiro, $this->requests);
|
||||
$this->content = GiroBeszed::createFileContent($this->koteg->number, $this->koteg->datum, $this->requests);
|
||||
}
|
||||
|
||||
public function saveFile( ) {
|
||||
|
||||
@@ -30,13 +30,15 @@ class TicketInstallmentRequestSearch extends TicketInstallmentRequest
|
||||
public $customer_name;
|
||||
public $id_ticket_type;
|
||||
|
||||
public $id_ugiro;
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['id_ticket_installment_request', 'id_ticket', 'id_customer', 'status' ,'id_ticket_type'], 'integer'],
|
||||
[['id_ticket_installment_request', 'id_ticket', 'id_customer', 'status' ,'id_ticket_type','id_ugiro'], 'integer'],
|
||||
[['customer_name' ], 'safe'],
|
||||
[[ 'start', ], 'date' , 'timestampAttribute' => 'timestampStart' ,'timestampAttributeFormat' => 'yyyy-MM-dd' ],
|
||||
[[ 'end' , ], 'date' , 'timestampAttribute' => 'timestampEnd' ,'timestampAttributeFormat' => 'yyyy-MM-dd' ],
|
||||
@@ -89,11 +91,13 @@ class TicketInstallmentRequestSearch extends TicketInstallmentRequest
|
||||
'ticket.start as ticket_start',//ticket_start
|
||||
'ticket.end as ticket_end',//ticket_send
|
||||
'ticket.id_ticket as ticket_id_ticket',//id_ticket
|
||||
'ugiro_request_assignment.id_ugiro as ugiro_id_ugiro' ,//köteg azonosító
|
||||
]);
|
||||
$query->from("ticket_installment_request");
|
||||
$query->innerJoin("customer","customer.id_customer = ticket_installment_request.id_customer");
|
||||
$query->innerJoin("ticket","ticket.id_ticket = ticket_installment_request.id_ticket");
|
||||
$query->innerJoin("ticket_type","ticket.id_ticket_type = ticket_type.id_ticket_type");
|
||||
$query->leftJoin("ugiro_request_assignment","ticket_installment_request.id_ticket_installment_request = ugiro_request_assignment.id_request");
|
||||
|
||||
$query->orderBy(["ticket_installment_request.request_target_time_at" => SORT_ASC]);
|
||||
|
||||
@@ -115,6 +119,10 @@ class TicketInstallmentRequestSearch extends TicketInstallmentRequest
|
||||
$query->andFilterWhere(['>=', 'ticket_installment_request.request_processed_at', $this->timestampProcessedStart]);
|
||||
$query->andFilterWhere(['<', 'ticket_installment_request.request_processed_at', $this->timestampProcessedEnd]);
|
||||
|
||||
if ( isset($this->id_ugiro ) && !empty($this->id_ugiro)){
|
||||
$query->andWhere(["ugiro_request_assignment.id_ugiro" => $this->id_ugiro]);
|
||||
}
|
||||
|
||||
$dataProvider = new ArrayDataProvider([
|
||||
'allModels' => $query->all(),
|
||||
// 'sort' => [
|
||||
|
||||
@@ -37,7 +37,7 @@ class TicketSearch extends Ticket
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[[ 'id_ticket', 'id_user', 'id_ticket_type', 'id_account'], 'integer'],
|
||||
[[ 'id_ticket', 'id_user', 'id_ticket_type', 'id_account','status'], 'integer'],
|
||||
[[ 'start', ], 'date' , 'timestampAttribute' => 'timestampStart' ,'timestampAttributeFormat' => 'yyyy-MM-dd' ],
|
||||
[[ 'end' , ], 'date' , 'timestampAttribute' => 'timestampEnd' ,'timestampAttributeFormat' => 'yyyy-MM-dd' ],
|
||||
[['valid_in_interval','created_in_interval','expire_in_interval'],'boolean'] ,
|
||||
@@ -117,7 +117,8 @@ class TicketSearch extends Ticket
|
||||
'id_ticket_type' => $this->id_ticket_type,
|
||||
'id_account' => $this->id_account,
|
||||
'id_card' => $this->id_card,
|
||||
'id_ticket' => $this->id_ticket
|
||||
'id_ticket' => $this->id_ticket,
|
||||
'status' => $this->status
|
||||
]);
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user