add contract started_at field
This commit is contained in:
@@ -39,6 +39,8 @@ class ContractForm extends Model {
|
||||
private $ticketType;
|
||||
private $money;
|
||||
private $discount;
|
||||
public $started_at;
|
||||
public $timestampStart;
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
@@ -59,7 +61,9 @@ class ContractForm extends Model {
|
||||
"bank_name",
|
||||
'phone',
|
||||
'email',
|
||||
'payment_method'
|
||||
'payment_method' ,
|
||||
'started_at',
|
||||
'started_at'
|
||||
],
|
||||
'required'
|
||||
],
|
||||
@@ -124,7 +128,8 @@ class ContractForm extends Model {
|
||||
'ticket_type'
|
||||
],
|
||||
'validateTicketType'
|
||||
]
|
||||
] ,
|
||||
[[ 'started_at', ], 'date', 'format' =>Yii::$app->formatter->dateFormat , 'timestampAttribute' => 'timestampStart' ,'timestampAttributeFormat' => 'yyyy-MM-dd' ,'timeZone' => 'UTC' ],
|
||||
];
|
||||
}
|
||||
public function validateTicketType($attribute, $params) {
|
||||
@@ -162,6 +167,7 @@ class ContractForm extends Model {
|
||||
'ticket_type' => 'Bérlet típus' ,
|
||||
'payment_method' => 'Fizetési mód (első bérlet)' ,
|
||||
'id_discount' => 'Kedvezmény' ,
|
||||
'started_at' => 'Érvényesség kezdete' ,
|
||||
];
|
||||
}
|
||||
public function fillOut() {
|
||||
@@ -223,8 +229,8 @@ class ContractForm extends Model {
|
||||
$ticket->id_user = \Yii::$app->user->id;
|
||||
$ticket->id_account = Account::readDefault ();
|
||||
$ticket->id_discount = $this->id_discount;
|
||||
$ticket->start = date ( 'Y-m-d' );
|
||||
$date = new \DateTime ();
|
||||
$ticket->start = $this->started_at;
|
||||
$date = new \DateTime ( $this->timestampStart);
|
||||
$date->modify ( '+1 month' );
|
||||
$date->modify ( '-1 day' );
|
||||
$ticket->end = $date->format ( 'Y-m-d H:i:s' );
|
||||
@@ -283,7 +289,12 @@ class ContractForm extends Model {
|
||||
$contract->part_count = $this->ticketType->installment_count;
|
||||
$contract->part_paid = 0;
|
||||
$contract->part_required = 0;
|
||||
$contract->expired_at = date ( 'Y-m-d', strtotime ( "today +12 month -1 day" ) );
|
||||
$contract->started_at = $this->started_at;
|
||||
$date = new \DateTime( $this->timestampStart );
|
||||
$date->modify ( '+1 year' );
|
||||
$date->modify ( '-1 day' );
|
||||
$date->setTime(0, 0, 0);
|
||||
$contract->expired_at = $date->format ( 'Y-m-d H:i:s' );
|
||||
$contract->id_ticket_type = $this->ticketType->id_ticket_type;
|
||||
|
||||
if (! $contract->save ( false )) {
|
||||
|
||||
Reference in New Issue
Block a user