change cart to plain post from ajax

This commit is contained in:
2016-01-04 22:02:59 +01:00
parent 2d9b527909
commit 1e206011d0
27 changed files with 622 additions and 349 deletions

View 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 [
];
}
}

View File

@@ -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();
}

View File

@@ -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(){

View File

@@ -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;

View 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 [
];
}
}