add ticket installment
This commit is contained in:
@@ -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( ) {
|
||||
|
||||
Reference in New Issue
Block a user