add editable giro pay date
This commit is contained in:
parent
bd5406f8be
commit
2647ca6aa6
@ -112,7 +112,7 @@ class TicketInstallmentRequestController extends Controller
|
||||
{
|
||||
$model = new GiroKotegForm();
|
||||
|
||||
if ($model->load(Yii::$app->request->post()) ) {
|
||||
if ($model->load(Yii::$app->request->post()) && $model->validate() ) {
|
||||
$model->createKoteg();
|
||||
return $this->redirect(['ugiro/view', 'id' => $model->koteg->id_ugiro]);
|
||||
}
|
||||
|
||||
@ -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( ) {
|
||||
|
||||
@ -7,6 +7,8 @@ use yii\base\Widget;
|
||||
use kartik\widgets\ActiveForm;
|
||||
use backend\assets\PendingRequestAsset;
|
||||
use yii\helpers\Url;
|
||||
use kartik\widgets\DateTimePicker;
|
||||
use kartik\widgets\DatePicker;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $searchModel backend\models\TicketInstallmentRequestSearch */
|
||||
@ -23,22 +25,33 @@ PendingRequestAsset::register($this);
|
||||
<h1><?= Html::encode($this->title) ?></h1>
|
||||
|
||||
|
||||
<?php
|
||||
echo ListView::widget([
|
||||
'dataProvider' => $dataProvider,
|
||||
'itemView' => '_download_giro_view'
|
||||
]);
|
||||
?>
|
||||
|
||||
<?php $form = ActiveForm::begin([
|
||||
'action' => Url::current(),
|
||||
'method' => 'post',
|
||||
]); ?>
|
||||
<?php echo $form->field($model, 'action')->hiddenInput()->label(false) ?>
|
||||
<div class="row">
|
||||
<div class="col-md-3">
|
||||
<?= $form->field($model, 'teljesitesi_datum')->widget(DatePicker::classname(), [
|
||||
'pluginOptions' => [
|
||||
'autoclose'=>true,
|
||||
'format' => 'yyyy.mm.dd'
|
||||
]
|
||||
]) ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<?= Html::submitButton("Köteg létrehozása", ['class' => 'btn btn-primary']) ?>
|
||||
</div>
|
||||
|
||||
<?php ActiveForm::end(); ?>
|
||||
|
||||
<?php
|
||||
echo ListView::widget([
|
||||
'dataProvider' => $dataProvider,
|
||||
'itemView' => '_download_giro_view'
|
||||
]);
|
||||
?>
|
||||
|
||||
</div>
|
||||
|
||||
@ -52,6 +52,11 @@ $attributes = [
|
||||
'attribute' => 'created_at',
|
||||
'label' => 'Létrehozva',
|
||||
'format' =>'datetime'
|
||||
],
|
||||
[
|
||||
'attribute' => 'terhelesi_datum',
|
||||
'label' => 'Terhelési dátum',
|
||||
'format' =>'datetime'
|
||||
],
|
||||
[
|
||||
'attribute' => 'path',
|
||||
|
||||
3
backend/web/info.php
Normal file
3
backend/web/info.php
Normal file
@ -0,0 +1,3 @@
|
||||
<?php
|
||||
phpinfo();
|
||||
?>
|
||||
@ -24,6 +24,7 @@ class GiroBeszed extends GiroBase {
|
||||
if ( !isset($terhelesiDatum)){
|
||||
$terhelesiDatum = date('Ymd' ,strtotime("+5 day"));
|
||||
}
|
||||
|
||||
$s = self::createFej($number, $datum);
|
||||
$s .= self::createTetelek($requests,$terhelesiDatum);
|
||||
$s .= self::createLab($requests);
|
||||
|
||||
@ -17,6 +17,7 @@ use yii\helpers\ArrayHelper;
|
||||
* @property integer $number
|
||||
* @property string $created_at
|
||||
* @property string $updated_at
|
||||
* @property string $terhelesi_datum
|
||||
*/
|
||||
class Ugiro extends \yii\db\ActiveRecord
|
||||
{
|
||||
|
||||
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
use yii\db\Schema;
|
||||
use yii\db\Migration;
|
||||
|
||||
class m160331_184302_add_ugiro_terhelesi_datum extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
$this->addColumn("ugiro", "terhelesi_datum", "datetime");
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
echo "m160331_184302_add_ugiro_terhelesi_datum cannot be reverted.\n";
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
// Use safeUp/safeDown to run migration code within a transaction
|
||||
public function safeUp()
|
||||
{
|
||||
}
|
||||
|
||||
public function safeDown()
|
||||
{
|
||||
}
|
||||
*/
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user