add editable giro pay date
This commit is contained in:
@@ -31,13 +31,45 @@ class GiroKotegForm extends Model{
|
||||
public $koteg;
|
||||
public $success;
|
||||
|
||||
public $timestamp_teljesites_datum;
|
||||
public $teljesitesi_datum;
|
||||
|
||||
public function rules(){
|
||||
return [
|
||||
[['action'], 'safe']
|
||||
[['action'], 'safe'] ,
|
||||
[[ 'teljesitesi_datum', ], 'required'],
|
||||
[[ 'teljesitesi_datum', ], 'date', 'format' =>Yii::$app->formatter->dateFormat , 'timestampAttribute' => 'timestamp_teljesites_datum' ,'timestampAttributeFormat' => 'yyyy-MM-dd' ,'timeZone' => 'UTC' ],
|
||||
|
||||
['teljesitesi_datum', "validateRequestCount"],
|
||||
['teljesitesi_datum', "validateMaxPlusDay"],
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
public function validateRequestCount($a,$p){
|
||||
$this->readRequests();
|
||||
if ( count( $this->requests ) == 0 ){
|
||||
$this->addError("teljesitesi_datum", "Megbízások száma 0!" );
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* A teljesítési dátum max 8 nappal lehet a létrehozás dátumán túl
|
||||
* */
|
||||
public function validateMaxPlusDay(){
|
||||
$date = new \DateTime('now');
|
||||
$date->add(new \DateInterval('P8D'));
|
||||
$date->setTime(0,0,0);
|
||||
|
||||
$td = new \DateTime();
|
||||
$td->setTimestamp( strtotime( $this->timestamp_teljesites_datum ) );
|
||||
$date->setTime(0,0,0);
|
||||
|
||||
if ( $td > $date){
|
||||
$this->addError( "teljesitesi_datum", "Érvénytelen terhelési dátum. A terhelési dátum max +8 nap lehet");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function createKoteg(){
|
||||
$this->readRequests();
|
||||
@@ -98,6 +130,7 @@ class GiroKotegForm extends Model{
|
||||
$this->koteg->id_user = \Yii::$app->user->id;
|
||||
|
||||
$this->koteg->datum = date('Ymd');
|
||||
$this->koteg->terhelesi_datum = $this->teljesitesi_datum;
|
||||
|
||||
$lastNumber = $this->loadLastNumber($this->koteg->datum);
|
||||
$nextNumber = $lastNumber+1;
|
||||
@@ -120,7 +153,8 @@ class GiroKotegForm extends Model{
|
||||
}
|
||||
|
||||
public function generateFileContent(){
|
||||
$this->content = GiroBeszed::createFileContent($this->koteg->number, $this->koteg->datum, $this->requests);
|
||||
$terhelesi_datum =\Yii::$app->formatter->asDate($this->timestamp_teljesites_datum, 'php:Ymd');
|
||||
$this->content = GiroBeszed::createFileContent($this->koteg->number, $this->koteg->datum, $this->requests,$terhelesi_datum);
|
||||
}
|
||||
|
||||
public function saveFile( ) {
|
||||
|
||||
Reference in New Issue
Block a user