change cart to plain post from ajax
This commit is contained in:
42
frontend/models/CustomerCartPayoutForm.php
Normal file
42
frontend/models/CustomerCartPayoutForm.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace frontend\models;
|
||||
|
||||
use Yii;
|
||||
use yii\base\Model;
|
||||
use common\models\Card;
|
||||
use common\models\Customer;
|
||||
use common\models\Ticket;
|
||||
use common\models\Account;
|
||||
|
||||
/**
|
||||
* ContactForm is the model behind the contact form.
|
||||
*/
|
||||
class CustomerCartPayoutForm extends Model
|
||||
{
|
||||
public $transfers;
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
['transfers', 'each', 'rule' => ['integer']],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function attributeLabels()
|
||||
{
|
||||
return [
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -209,6 +209,12 @@ class ProductSaleForm extends Model
|
||||
|
||||
|
||||
$this->transfer->id_user = Yii::$app->user->id;
|
||||
|
||||
if ( $status == Transfer::STATUS_PAID){
|
||||
$this->transfer->paid_by = Yii::$app->user->id;
|
||||
}
|
||||
|
||||
|
||||
$this->transfer->save();
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ use yii\base\Model;
|
||||
use common\models\Card;
|
||||
use common\models\Customer;
|
||||
use common\models\Ticket;
|
||||
use common\models\Account;
|
||||
|
||||
/**
|
||||
* ContactForm is the model behind the contact form.
|
||||
@@ -17,7 +18,7 @@ class ReceptionForm extends Model
|
||||
public $card;
|
||||
public $customer;
|
||||
public $tickets;
|
||||
|
||||
public $defaultAccount;
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
@@ -44,11 +45,25 @@ class ReceptionForm extends Model
|
||||
|
||||
$this->number = str_replace("ö", "0", $this->number);
|
||||
|
||||
$this->card = Card::find()->andWhere(['or', [ 'in','number' , [$this->number]], ['and', ['in','rfid_key' ,[ $this->number] ],"trim(coalesce(rfid_key, '')) <>'' "]])->one();
|
||||
$this->card = Card::find()->andWhere(['or', ['and',[ 'in','number' , [$this->number]],"trim(coalesce(number, '')) <>'' " ], ['and', ['in','rfid_key' ,[ $this->number] ],"trim(coalesce(rfid_key, '')) <>'' "]])->one();
|
||||
if ( $this->card != null ){
|
||||
$this->customer = $this->card->customer;
|
||||
$this->readValidTickets();
|
||||
}
|
||||
|
||||
$defaultAccount = Account::readDefault();
|
||||
if ( isset($defaultAccount)){
|
||||
$this->defaultAccount = Account::findOne($defaultAccount);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function getDefaultAccountName(){
|
||||
$result = "";
|
||||
if ( $this->defaultAccount ){
|
||||
$result = $this->defaultAccount->name;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function readValidTickets(){
|
||||
|
||||
@@ -120,6 +120,7 @@ class TicketCreate extends Ticket{
|
||||
}else {
|
||||
$status = Transfer::STATUS_PAID;
|
||||
$transfer->paid_at = date('Y-m-d H:i:s' ) ;
|
||||
$transfer->paid_by = \Yii::$app->user->id;
|
||||
}
|
||||
$transfer->status = $status;
|
||||
|
||||
|
||||
42
frontend/models/UserCartPayoutForm.php
Normal file
42
frontend/models/UserCartPayoutForm.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace frontend\models;
|
||||
|
||||
use Yii;
|
||||
use yii\base\Model;
|
||||
use common\models\Card;
|
||||
use common\models\Customer;
|
||||
use common\models\Ticket;
|
||||
use common\models\Account;
|
||||
|
||||
/**
|
||||
* ContactForm is the model behind the contact form.
|
||||
*/
|
||||
class UserCartPayoutForm extends Model
|
||||
{
|
||||
public $transfers;
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
['transfers', 'each', 'rule' => ['integer']],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function attributeLabels()
|
||||
{
|
||||
return [
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user