Add waste
This commit is contained in:
@@ -293,7 +293,9 @@ class ContractController extends Controller {
|
||||
|
||||
|
||||
$model = new ContractForm ( [
|
||||
'customer' => $customer
|
||||
'customer' => $customer ,
|
||||
'idUser' => \Yii::$app->user->id,
|
||||
'idAccount' => Account::readDefault ()
|
||||
] );
|
||||
|
||||
$model->started_at = date(date('Y.m.d'));
|
||||
|
||||
@@ -9,12 +9,10 @@ use frontend\models\CustomerSearch;
|
||||
use yii\web\Controller;
|
||||
use yii\web\NotFoundHttpException;
|
||||
use yii\filters\VerbFilter;
|
||||
use yii\base\Object;
|
||||
use common\models\Card;
|
||||
use frontend\models\CustomerUpdate;
|
||||
use frontend\models\CustomerCreate;
|
||||
use common\models\Image;
|
||||
use frontend\models\ContractForm;
|
||||
use yii\base\Exception;
|
||||
use common\models\Log;
|
||||
|
||||
|
||||
@@ -114,7 +114,8 @@ class TicketController extends FrontendController
|
||||
|
||||
$model->customer = $receptionForm->customer;
|
||||
$model->id_user = \Yii::$app->user->id;
|
||||
$model->status = Ticket::STATUS_ACTIVE;
|
||||
|
||||
|
||||
$model->usage_count = 0;
|
||||
$model->id_card = $receptionForm->card->id_card;
|
||||
$model->id_account = Account::readDefault();
|
||||
|
||||
@@ -36,11 +36,13 @@ class ContractForm extends Model {
|
||||
private $ticket;
|
||||
private $transfer;
|
||||
public $contract;
|
||||
private $ticketType;
|
||||
public $ticketType;
|
||||
private $money;
|
||||
private $discount;
|
||||
public $started_at;
|
||||
public $timestampStart;
|
||||
public $idUser;
|
||||
public $idAccount;
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
@@ -244,8 +246,9 @@ class ContractForm extends Model {
|
||||
public function createTicket() {
|
||||
|
||||
$ticket = new Ticket ();
|
||||
$ticket->id_user = \Yii::$app->user->id;
|
||||
$ticket->id_account = Account::readDefault ();
|
||||
$ticket->id_user = $this->getUserId();
|
||||
$ticket->id_account = $this->getAccountId();
|
||||
|
||||
$ticket->id_discount = $this->id_discount;
|
||||
$ticket->start = $this->started_at;
|
||||
$date = new \DateTime ( $this->timestampStart);
|
||||
@@ -278,9 +281,9 @@ class ContractForm extends Model {
|
||||
$transfer->item_price = $this->money;
|
||||
$transfer->count = 1;
|
||||
$transfer->money = $this->money;
|
||||
$transfer->id_user = \Yii::$app->user->id;
|
||||
$transfer->id_user = $this->getUserId();
|
||||
$transfer->comment = "Szerződéses bérlet";
|
||||
$transfer->id_account = Account::readDefault ();
|
||||
$transfer->id_account = $this->getAccountId();
|
||||
$transfer->direction = Transfer::DIRECTION_IN;
|
||||
$transfer->id_customer = $this->customer->id_customer;
|
||||
$transfer->payment_method = $this->payment_method;
|
||||
@@ -301,7 +304,7 @@ class ContractForm extends Model {
|
||||
|
||||
$contract = new Contract ();
|
||||
$contract->id_customer = $this->customer->id_customer;
|
||||
$contract->id_user = \Yii::$app->user->id;
|
||||
$contract->id_user = $this->getUserId();
|
||||
$contract->status = Contract::$STATUS_PAID;
|
||||
$contract->flag = Contract::$FLAG_ACTIVE;
|
||||
$contract->part_count = $this->ticketType->installment_count;
|
||||
@@ -342,4 +345,21 @@ class ContractForm extends Model {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
protected function getUserId(){
|
||||
if ( isset($this->idUser)){
|
||||
return $this->idUser;
|
||||
}
|
||||
return \Yii::$app->user->id;
|
||||
}
|
||||
|
||||
|
||||
protected function getAccountId(){
|
||||
if ( isset($this->idAccount)){
|
||||
return $this->idAccount;
|
||||
}
|
||||
return Account::readDefault();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -141,6 +141,13 @@ class TicketCreate extends Ticket{
|
||||
$result = parent::beforeSave($insert);
|
||||
if ( $result ){
|
||||
if ($insert){
|
||||
|
||||
if ( $this->isAppendToCustomerCart() || $this->isAppendToUserCart()){
|
||||
$this->status = Ticket::STATUS_INACTIVE;
|
||||
}else{
|
||||
$this->status = Ticket::STATUS_ACTIVE;
|
||||
}
|
||||
|
||||
$ticketType = TicketType::findOne($this->id_ticket_type);
|
||||
if ( isset($ticketType) && $ticketType->isInstallment() ){
|
||||
$this->part = 0;
|
||||
|
||||
Reference in New Issue
Block a user