change cart to plain post from ajax
This commit is contained in:
parent
2d9b527909
commit
1e206011d0
@ -61,15 +61,23 @@ class ProductSearch extends Product
|
|||||||
return $dataProvider;
|
return $dataProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( !empty($this->barcode)){
|
||||||
|
$this->barcode = strtolower($this->barcode);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !empty($this->product_number)){
|
||||||
|
$this->product_number = strtolower($this->product_number);
|
||||||
|
}
|
||||||
|
|
||||||
$query->andFilterWhere([
|
$query->andFilterWhere([
|
||||||
'product.id_product_category' => $this->id_product_category,
|
'product.id_product_category' => $this->id_product_category,
|
||||||
'product.id_account' => $this->id_account,
|
'product.id_account' => $this->id_account,
|
||||||
'product.status' => $this->status,
|
'product.status' => $this->status,
|
||||||
|
'lower(product.product_number)' => $this->product_number,
|
||||||
|
'lower(product.barcode)' => $this->barcode,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$query->andFilterWhere(['like', 'product_number', $this->product_number])
|
$query->andFilterWhere(['like', 'name', $this->name]);
|
||||||
->andFilterWhere(['like', 'barcode', $this->barcode])
|
|
||||||
->andFilterWhere(['like', 'name', $this->name]);
|
|
||||||
|
|
||||||
return $dataProvider;
|
return $dataProvider;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -85,5 +85,11 @@ class Helper
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static function fixAsciiChars($in){
|
||||||
|
$out = str_replace("ö", "0", $in);
|
||||||
|
$out = str_replace("Ö", "0", $in);
|
||||||
|
return $out;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -3,6 +3,7 @@
|
|||||||
namespace common\models;
|
namespace common\models;
|
||||||
|
|
||||||
use Yii;
|
use Yii;
|
||||||
|
use common\components\Helper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is the model class for table "card".
|
* This is the model class for table "card".
|
||||||
@ -67,7 +68,7 @@ class Card extends \common\models\BaseFitnessActiveRecord
|
|||||||
|
|
||||||
public function validateAscii($attribute,$params){
|
public function validateAscii($attribute,$params){
|
||||||
if ( !$this->hasErrors($this->$attribute)){
|
if ( !$this->hasErrors($this->$attribute)){
|
||||||
$this->$attribute = str_replace("ö", "0", $this->$attribute);
|
$this->attribute = Helper::fixAsciiChars($this->attributes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -4,6 +4,7 @@ namespace common\models;
|
|||||||
|
|
||||||
use Yii;
|
use Yii;
|
||||||
use yii\helpers\ArrayHelper;
|
use yii\helpers\ArrayHelper;
|
||||||
|
use common\components\Helper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is the model class for table "product".
|
* This is the model class for table "product".
|
||||||
@ -52,6 +53,12 @@ class Product extends \common\models\BaseFitnessActiveRecord {
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function validateAscii($attribute,$params){
|
||||||
|
if ( !$this->hasErrors($this->$attribute)){
|
||||||
|
$this->attribute = Helper::fixAsciiChars($this->attributes);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -63,19 +63,26 @@ class ShoppingCart extends \yii\db\ActiveRecord
|
|||||||
return $transfers;
|
return $transfers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function payout( $customer) {
|
public static function payout( $customer, $idTransfers) {
|
||||||
//apply transfer object
|
//apply transfer object
|
||||||
//delete cart
|
//delete cart
|
||||||
$sql = "UPDATE transfer AS t
|
$sql = "UPDATE transfer AS t
|
||||||
INNER JOIN shopping_cart AS s ON t.id_transfer = s.id_transfer
|
INNER JOIN shopping_cart AS s ON t.id_transfer = s.id_transfer
|
||||||
SET t.status = " . Transfer::STATUS_PAID . ", t.paid_at = '" . date('Y-m-d H:i:s' ) ."'"
|
SET t.paid_by = ".\Yii::$app->user->id.", t.status = " . Transfer::STATUS_PAID . ", t.paid_at = '" . date('Y-m-d H:i:s' ) ."'"
|
||||||
. " WHERE t.status = " . Transfer::STATUS_NOT_PAID
|
. " WHERE t.status = " . Transfer::STATUS_NOT_PAID
|
||||||
. " and s.id_customer = " . $customer->id_customer ;
|
. " and s.id_customer = " . $customer->id_customer
|
||||||
|
. " and t.id_transfer in ( '" . implode("','", $idTransfers )."' )";
|
||||||
|
|
||||||
$q1 = Yii::$app->db->createCommand($sql);
|
$q1 = Yii::$app->db->createCommand($sql);
|
||||||
$q1->execute();
|
$q1->execute();
|
||||||
|
|
||||||
|
// ShoppingCart::deleteAll(['id_customer' => $customer->id_customer]);
|
||||||
|
|
||||||
|
if ( isset($idTransfers) ){
|
||||||
|
ShoppingCart::deleteAll(['and' ,['id_customer' => $customer->id_customer] ,['in','id_transfer',$idTransfers] ]);
|
||||||
|
}else{
|
||||||
ShoppingCart::deleteAll(['id_customer' => $customer->id_customer]);
|
ShoppingCart::deleteAll(['id_customer' => $customer->id_customer]);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -541,7 +541,10 @@ class Transfer extends \common\models\BaseFitnessActiveRecord
|
|||||||
if ( !RoleDefinition::isAdmin() ){
|
if ( !RoleDefinition::isAdmin() ){
|
||||||
$query->innerJoin("user_account_assignment", 'transfer.id_account = user_account_assignment.id_account' );
|
$query->innerJoin("user_account_assignment", 'transfer.id_account = user_account_assignment.id_account' );
|
||||||
$query->andWhere(['user_account_assignment.id_user' => Yii::$app->user->id ]);
|
$query->andWhere(['user_account_assignment.id_user' => Yii::$app->user->id ]);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
$query->innerJoin("account", 'transfer.id_account = account.id_account' );
|
||||||
|
$query->andWhere(['account.type' => Account::TYPE_ALL]);
|
||||||
|
|
||||||
$query->andFilterWhere([
|
$query->andFilterWhere([
|
||||||
'transfer.id_account' => $idAccount,
|
'transfer.id_account' => $idAccount,
|
||||||
|
|||||||
@ -89,19 +89,27 @@ class UserSoldItem extends \yii\db\ActiveRecord
|
|||||||
/**
|
/**
|
||||||
* @param common\models\User $user
|
* @param common\models\User $user
|
||||||
* */
|
* */
|
||||||
public static function payout( $user ) {
|
public static function payout( $user, $idTransfers = null ) {
|
||||||
//apply transfer object
|
//apply transfer object
|
||||||
//delete cart
|
//delete cart
|
||||||
$sql = "UPDATE transfer AS t
|
$sql = "UPDATE transfer AS t
|
||||||
INNER JOIN user_sold_item AS s ON t.id_transfer = s.id_transfer
|
INNER JOIN user_sold_item AS s ON t.id_transfer = s.id_transfer
|
||||||
SET t.status = " . Transfer::STATUS_PAID . ", t.paid_at = '" . date('Y-m-d H:i:s' ) ."'"
|
SET t.paid_by = ".$user->id.", t.status = " . Transfer::STATUS_PAID . ", t.paid_at = '" . date('Y-m-d H:i:s' ) ."'"
|
||||||
. " WHERE t.status = " . Transfer::STATUS_NOT_PAID
|
. " WHERE t.status = " . Transfer::STATUS_NOT_PAID
|
||||||
. " and s.id_user =" . $user->id ;
|
. " and s.id_user =" . $user->id ;
|
||||||
|
|
||||||
|
if ( isset($idTransfers)){
|
||||||
|
$sql .= " and t.id_transfer in ( '" . implode("','", $idTransfers )."' )";
|
||||||
|
}
|
||||||
|
|
||||||
$q1 = Yii::$app->db->createCommand($sql);
|
$q1 = Yii::$app->db->createCommand($sql);
|
||||||
$q1->execute();
|
$q1->execute();
|
||||||
|
|
||||||
|
if ( isset($idTransfers) ){
|
||||||
|
UserSoldItem::deleteAll(['and' ,['id_user' => Yii::$app->user->id] ,['in','id_transfer',$idTransfers] ]);
|
||||||
|
}else{
|
||||||
UserSoldItem::deleteAll(['id_user' => Yii::$app->user->id]);
|
UserSoldItem::deleteAll(['id_user' => Yii::$app->user->id]);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use yii\db\Schema;
|
||||||
|
use yii\db\Migration;
|
||||||
|
|
||||||
|
class m160104_155510_alter__table__transaction__add__column__paid_by extends Migration
|
||||||
|
{
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
$this->addColumn("transfer", "paid_by", "int");
|
||||||
|
$this->execute("update transfer set paid_by = id_user where paid_at is not null");
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
echo "m160104_155510_alter__table__transaction__add__column__paid_by cannot be reverted.\n";
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
// Use safeUp/safeDown to run migration code within a transaction
|
||||||
|
public function safeUp()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public function safeDown()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
@ -8,6 +8,7 @@ use common\models\MoneyMovement;
|
|||||||
use yii\db\Query;
|
use yii\db\Query;
|
||||||
use common\models\AccountState;
|
use common\models\AccountState;
|
||||||
use backend\models\AccountSearch;
|
use backend\models\AccountSearch;
|
||||||
|
use common\models\Account;
|
||||||
|
|
||||||
class FrontendMenuStructure{
|
class FrontendMenuStructure{
|
||||||
|
|
||||||
@ -68,13 +69,13 @@ class FrontendMenuStructure{
|
|||||||
['label' => Yii::t('frontend/account-state','Open account state'), 'url' => ['/account-state/open'] ],
|
['label' => Yii::t('frontend/account-state','Open account state'), 'url' => ['/account-state/open'] ],
|
||||||
['label' => Yii::t('frontend/account-state','Close account state'), 'url' => ['/account-state/close'] ],
|
['label' => Yii::t('frontend/account-state','Close account state'), 'url' => ['/account-state/close'] ],
|
||||||
['label' => Yii::t('frontend/money-movement','Money movements'), 'url' => [ '/money-movement/index', 'MoneyMovementSearch[start]' => $this->start, 'MoneyMovementSearch[end]' => $this->tomorrow ] ],
|
['label' => Yii::t('frontend/money-movement','Money movements'), 'url' => [ '/money-movement/index', 'MoneyMovementSearch[start]' => $this->start, 'MoneyMovementSearch[end]' => $this->tomorrow ] ],
|
||||||
['label' => Yii::t('frontend/transfer','Daily transfers'), 'url' => [ '/transfer/list', 'TransferListSearch[start]' => $this->start, 'TransferListSearch[end]' => $this->tomorrow ] ],
|
['label' => Yii::t('frontend/transfer','Daily transfers'), 'url' => [ '/transfer/list', 'TransferListSearch[id_account]' => Account::readDefault(), 'TransferListSearch[start]' => $this->start, 'TransferListSearch[end]' => $this->tomorrow ] ],
|
||||||
['label' => Yii::t('frontend/transfer','Sales detailed'), 'url' => [ '/transfer/sale', 'TransferSaleSearch[start]' => $this->start, 'TransferSaleSearch[end]' => $this->tomorrow ] ],
|
['label' => Yii::t('frontend/transfer','Sales detailed'), 'url' => [ '/transfer/sale', 'TransferSaleSearch[id_user]' =>\Yii::$app->user->id, 'TransferSaleSearch[id_account]' => Account::readDefault(), 'TransferSaleSearch[start]' => $this->start, 'TransferSaleSearch[end]' => $this->tomorrow ] ],
|
||||||
['label' => Yii::t('frontend/transfer','Ticket sale detailed'), 'url' => [ '/transfer/tickets', 'TransferTicketSearch[start]' => $this->start, 'TransferTicketSearch[end]' => $this->tomorrow ] ],
|
['label' => Yii::t('frontend/transfer','Ticket sale detailed'), 'url' => [ '/transfer/tickets','TransferTicketSearch[id_user]' =>\Yii::$app->user->id, 'TransferTicketSearch[id_account]' => Account::readDefault(), 'TransferTicketSearch[start]' => $this->start, 'TransferTicketSearch[end]' => $this->tomorrow ] ],
|
||||||
];
|
];
|
||||||
|
|
||||||
if ( $isadmin || Yii::$app->user->can('reception.transfers') ){
|
if ( $isadmin || Yii::$app->user->can('reception.transfers') ){
|
||||||
$items[] = ['label' => Yii::t('frontend/transfer','Transfers'), 'url' => ['/transfer/index', 'TransferSearch[start]' => $this->start, 'TransferSearch[end]' => $this->tomorrow ] ];
|
$items[] = ['label' => Yii::t('frontend/transfer','Transfers'), 'url' => ['/transfer/index', 'TransferSearch[id_user]' =>\Yii::$app->user->id, 'TransferSearch[id_account]' => Account::readDefault(), 'TransferSearch[start]' => $this->start, 'TransferSearch[end]' => $this->tomorrow ] ];
|
||||||
}
|
}
|
||||||
|
|
||||||
$items[] = ['label' => Yii::t('frontend/collection','Collections'), 'url' => ['/collection/index' , 'CollectionSearch[start]' =>$this->start,'CollectionSearch[end]' => $this->tomorrow ] ];
|
$items[] = ['label' => Yii::t('frontend/collection','Collections'), 'url' => ['/collection/index' , 'CollectionSearch[start]' =>$this->start,'CollectionSearch[end]' => $this->tomorrow ] ];
|
||||||
|
|||||||
@ -63,6 +63,7 @@ class AccountStateController extends Controller
|
|||||||
$model = new AccountState();
|
$model = new AccountState();
|
||||||
$model->type = AccountState::TYPE_OPEN;
|
$model->type = AccountState::TYPE_OPEN;
|
||||||
$model->id_user = Yii::$app->user->id;
|
$model->id_user = Yii::$app->user->id;
|
||||||
|
$model->id_account = Account::readDefault();
|
||||||
if ($model->load(Yii::$app->request->post()) && $model->save()) {
|
if ($model->load(Yii::$app->request->post()) && $model->save()) {
|
||||||
// return $this->redirect(['view', 'id' => $model->id_account_state]);
|
// return $this->redirect(['view', 'id' => $model->id_account_state]);
|
||||||
return $this->redirect(['index' ]);
|
return $this->redirect(['index' ]);
|
||||||
@ -89,6 +90,7 @@ class AccountStateController extends Controller
|
|||||||
$model = new AccountState();
|
$model = new AccountState();
|
||||||
$model->type = AccountState::TYPE_CLOSE;
|
$model->type = AccountState::TYPE_CLOSE;
|
||||||
$model->id_user = Yii::$app->user->id;
|
$model->id_user = Yii::$app->user->id;
|
||||||
|
$model->id_account = Account::readDefault();
|
||||||
if ($model->load(Yii::$app->request->post()) && $model->save()) {
|
if ($model->load(Yii::$app->request->post()) && $model->save()) {
|
||||||
return $this->redirect(['index' ]);
|
return $this->redirect(['index' ]);
|
||||||
// return $this->redirect(['view', 'id' => $model->id_account_state]);
|
// return $this->redirect(['view', 'id' => $model->id_account_state]);
|
||||||
|
|||||||
@ -22,68 +22,75 @@ use common\models\User;
|
|||||||
use common\models\UserSoldItem;
|
use common\models\UserSoldItem;
|
||||||
use common\models\ShoppingCart;
|
use common\models\ShoppingCart;
|
||||||
use frontend\models\ReceptionForm;
|
use frontend\models\ReceptionForm;
|
||||||
|
use frontend\models\CustomerCartPayoutForm;
|
||||||
|
use frontend\models\UserCartPayoutForm;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ProductController implements the CRUD actions for Product model.
|
* ProductController implements the CRUD actions for Product model.
|
||||||
*/
|
*/
|
||||||
class ProductController extends Controller
|
class ProductController extends Controller {
|
||||||
{
|
|
||||||
|
|
||||||
protected $card;
|
protected $card;
|
||||||
protected $customer;
|
protected $customer;
|
||||||
|
public function behaviors() {
|
||||||
public function behaviors()
|
|
||||||
{
|
|
||||||
return [
|
return [
|
||||||
'verbs' => [
|
'verbs' => [
|
||||||
'class' => VerbFilter::className(),
|
'class' => VerbFilter::className (),
|
||||||
'actions' => [
|
'actions' => [
|
||||||
'delete' => ['post'],
|
'delete' => [
|
||||||
],
|
'post'
|
||||||
|
]
|
||||||
|
]
|
||||||
],
|
],
|
||||||
'access' => [
|
'access' => [
|
||||||
'class' => \yii\filters\AccessControl::className(),
|
'class' => \yii\filters\AccessControl::className (),
|
||||||
'only' => [ 'sale','payout-customer-cart','payout-user-cart', 'lookup','find'],
|
'only' => [
|
||||||
|
'sale',
|
||||||
|
'payout-customer-cart',
|
||||||
|
'payout-user-cart',
|
||||||
|
'lookup',
|
||||||
|
'find'
|
||||||
|
],
|
||||||
'rules' => [
|
'rules' => [
|
||||||
// allow authenticated users
|
// allow authenticated users
|
||||||
[
|
[
|
||||||
'allow' => true,
|
'allow' => true,
|
||||||
'roles' => ['@'],
|
'roles' => [
|
||||||
],
|
'@'
|
||||||
|
]
|
||||||
|
]
|
||||||
|
]
|
||||||
// everything else is denied
|
// everything else is denied
|
||||||
],
|
|
||||||
],
|
]
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
public function actionSale($number = null) {
|
||||||
|
|
||||||
|
// $this->findByNumber($number);
|
||||||
public function actionSale( $number = null){
|
$receptionForm = new ReceptionForm ();
|
||||||
|
|
||||||
// $this->findByNumber($number);
|
|
||||||
|
|
||||||
$receptionForm = new ReceptionForm() ;
|
|
||||||
$receptionForm->number = $number;
|
$receptionForm->number = $number;
|
||||||
$receptionForm->readCard();
|
$receptionForm->readCard ();
|
||||||
|
|
||||||
$this->card = $receptionForm->card;
|
$this->card = $receptionForm->card;
|
||||||
$this->customer = $receptionForm->customer;
|
$this->customer = $receptionForm->customer;
|
||||||
|
|
||||||
$model = new ProductSaleForm();
|
$model = new ProductSaleForm ();
|
||||||
|
|
||||||
$lookupModel = new ProductLookupForm();
|
$lookupModel = new ProductLookupForm ();
|
||||||
|
|
||||||
$currencies = Currency::find()->all();
|
$currencies = Currency::find ()->all ();
|
||||||
|
|
||||||
$accounts = Account::read();
|
$accounts = Account::read ();
|
||||||
|
|
||||||
$discounts = Discount::read();
|
$discounts = Discount::read ();
|
||||||
|
|
||||||
$user = User::findOne(Yii::$app->user->id );
|
$user = User::findOne ( Yii::$app->user->id );
|
||||||
|
|
||||||
$model->customer = $this->customer;
|
$model->customer = $this->customer;
|
||||||
$model->card = $this->card;
|
$model->card = $this->card;
|
||||||
|
|
||||||
$products = Product::readForDefaultAccount();
|
$products = Product::readForDefaultAccount ();
|
||||||
$products = Product::modelToMapIdName($products);
|
$products = Product::modelToMapIdName ( $products );
|
||||||
|
|
||||||
$model->products = $products;
|
$model->products = $products;
|
||||||
|
|
||||||
@ -95,248 +102,286 @@ class ProductController extends Controller
|
|||||||
$model->accounts = $accounts;
|
$model->accounts = $accounts;
|
||||||
$model->discounts = $discounts;
|
$model->discounts = $discounts;
|
||||||
|
|
||||||
$model->id_account = Account::readDefault();
|
$model->id_account = Account::readDefault ();
|
||||||
|
|
||||||
$result = [];
|
$result = [ ];
|
||||||
$result['code'] = 'unknown';
|
$result ['code'] = 'unknown';
|
||||||
if ($model->load(Yii::$app->request->post()) ) {
|
if ($model->load ( Yii::$app->request->post () )) {
|
||||||
if ( $model->save()){
|
if ($model->save ()) {
|
||||||
|
|
||||||
|
$result ['code'] = 'success';
|
||||||
$result['code'] = 'success';
|
$result ['message'] = Yii::t ( 'common/product', "Sold: {product}", [
|
||||||
$result['message'] = Yii::t('common/product',"Sold: {product}" ,[ 'product' => $model->transfer->toProductSoldString() ]);
|
'product' => $model->transfer->toProductSoldString ()
|
||||||
}else{
|
] );
|
||||||
$result['code'] = 'invalid';
|
} else {
|
||||||
$result['errors'] = $model->getErrors();
|
$result ['code'] = 'invalid';
|
||||||
|
$result ['errors'] = $model->getErrors ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$userTransfers = Transfer::modelsToArray( Transfer::readUserSoldTransfers( $user ) );
|
$userTransfers = Transfer::modelsToArray ( Transfer::readUserSoldTransfers ( $user ) );
|
||||||
$customerCart = Transfer::modelsToArray( Transfer::readCustomerCart( $this->customer ) );
|
$customerCart = Transfer::modelsToArray ( Transfer::readCustomerCart ( $this->customer ) );
|
||||||
$result['transfers'] = $userTransfers;
|
$result ['transfers'] = $userTransfers;
|
||||||
$result['customer_cart'] = $customerCart;
|
$result ['customer_cart'] = $customerCart;
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
|
} else {
|
||||||
|
|
||||||
}else{
|
// $userTransfers = Transfer::readUserSoldTransfers( $user );
|
||||||
|
$model->customerCart = Transfer::modelsToArray ( Transfer::readCustomerCart ( $this->customer ) );
|
||||||
|
$userTransfers = Transfer::modelsToArray ( Transfer::readUserSoldTransfers ( $user ) );
|
||||||
|
|
||||||
// $userTransfers = Transfer::readUserSoldTransfers( $user );
|
return $this->render ( "sale", [
|
||||||
$model->customerCart = Transfer::modelsToArray( Transfer::readCustomerCart($this->customer) );
|
|
||||||
$userTransfers = Transfer::modelsToArray( Transfer::readUserSoldTransfers($user) );
|
|
||||||
|
|
||||||
return $this->render("sale",[
|
|
||||||
'customer' => $this->customer,
|
'customer' => $this->customer,
|
||||||
'card' => $this->card,
|
'card' => $this->card,
|
||||||
'model' => $model,
|
'model' => $model,
|
||||||
'lookupModel' =>$lookupModel,
|
'lookupModel' => $lookupModel,
|
||||||
'currencies' => $currencies,
|
'currencies' => $currencies,
|
||||||
'accounts' => $accounts,
|
'accounts' => $accounts,
|
||||||
'discounts' => $discounts,
|
'discounts' => $discounts,
|
||||||
'userTransfers' => $userTransfers,
|
'userTransfers' => $userTransfers,
|
||||||
'receptionForm' => $receptionForm,
|
'receptionForm' => $receptionForm
|
||||||
]);
|
] );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
public function actionPayoutUserCart() {
|
||||||
public function actionPayoutUserCart(){
|
|
||||||
|
|
||||||
if (Yii::$app->request->isAjax) {
|
if (Yii::$app->request->isAjax) {
|
||||||
$result = [];
|
$result = [ ];
|
||||||
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
|
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
|
||||||
|
|
||||||
$user = User::findOne(Yii::$app->user->id );
|
$user = User::findOne ( Yii::$app->user->id );
|
||||||
UserSoldItem::payout($user);
|
UserSoldItem::payout ( $user );
|
||||||
|
|
||||||
$userTransfers = Transfer::modelsToArray( Transfer::readUserSoldTransfers($user) );
|
$userTransfers = Transfer::modelsToArray ( Transfer::readUserSoldTransfers ( $user ) );
|
||||||
$result['transfers'] = $userTransfers;
|
$result ['transfers'] = $userTransfers;
|
||||||
$result['code'] = 'success';
|
$result ['code'] = 'success';
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
|
} else {
|
||||||
|
$model = new UserCartPayoutForm ();
|
||||||
|
$user = User::findOne ( Yii::$app->user->id );
|
||||||
|
|
||||||
|
if ( $model->load ( Yii::$app->request->post () ) && $model->validate () &&isset ( $user ) && count ( $model->transfers ) > 0) {
|
||||||
|
|
||||||
|
$connection = \Yii::$app->db;
|
||||||
|
$transaction = $connection->beginTransaction ();
|
||||||
|
try {
|
||||||
|
UserSoldItem::payout ( $user, $model->transfers );
|
||||||
|
$transaction->commit ();
|
||||||
|
\Yii::$app->session->setFlash ( 'success', 'Recepicó kosár fizetve' );
|
||||||
|
} catch ( Exception $e ) {
|
||||||
|
$transaction->rollback ();
|
||||||
|
Yii::error ( "faled to save :" . $e->getMessage () );
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Yii::error ( "faled to save : transfer" );
|
||||||
|
\Yii::$app->session->setFlash ( 'warning', 'Nem történt változás' );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return $this->redirect ( Yii::$app->request->referrer );
|
||||||
}
|
}
|
||||||
public function actionPayoutCustomerCart($number){
|
public function actionPayoutCustomerCart($number) {
|
||||||
|
$cart = [ ];
|
||||||
$cart = [];
|
|
||||||
$code = 'error';
|
$code = 'error';
|
||||||
$message = 'Hiba történt';
|
$message = 'Hiba történt';
|
||||||
|
|
||||||
if (Yii::$app->request->isAjax) {
|
if (Yii::$app->request->isAjax) {
|
||||||
$result = [];
|
$result = [ ];
|
||||||
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
|
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
|
||||||
|
|
||||||
$this->findByNumber($number);
|
$this->findByNumber ( $number );
|
||||||
|
|
||||||
if ( isset($this->customer)){
|
if (isset ( $this->customer )) {
|
||||||
$connection = \Yii::$app->db;
|
$connection = \Yii::$app->db;
|
||||||
$transaction = $connection->beginTransaction();
|
$transaction = $connection->beginTransaction ();
|
||||||
try {
|
try {
|
||||||
ShoppingCart::payout($this->customer);
|
ShoppingCart::payout ( $this->customer );
|
||||||
$transaction->commit();
|
$transaction->commit ();
|
||||||
$cart = Transfer::modelsToArray( Transfer::readCustomerCart($this->customer) );
|
$cart = Transfer::modelsToArray ( Transfer::readCustomerCart ( $this->customer ) );
|
||||||
$code = 'success';
|
$code = 'success';
|
||||||
$message = 'Bevásárlókoosár fizetve: ' .$this->card->number;
|
$message = 'Bevásárlókosár fizetve: ' . $this->card->number;
|
||||||
} catch(Exception $e) {
|
} catch ( Exception $e ) {
|
||||||
$transaction->rollback();
|
$transaction->rollback ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$result['customer_cart'] = $cart;
|
$result ['customer_cart'] = $cart;
|
||||||
$result['code'] = $code;
|
$result ['code'] = $code;
|
||||||
$result['message'] = $message;
|
$result ['message'] = $message;
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
|
} else {
|
||||||
|
// post
|
||||||
|
$model = new CustomerCartPayoutForm ();
|
||||||
|
|
||||||
|
if ($model->load ( Yii::$app->request->post () ) && $model->validate ()) {
|
||||||
|
|
||||||
|
$this->findByNumber ( $number );
|
||||||
|
|
||||||
|
if (isset ( $this->customer ) && count ( $model->transfers ) > 0) {
|
||||||
|
$connection = \Yii::$app->db;
|
||||||
|
$transaction = $connection->beginTransaction ();
|
||||||
|
try {
|
||||||
|
ShoppingCart::payout ( $this->customer, $model->transfers );
|
||||||
|
$transaction->commit ();
|
||||||
|
\Yii::$app->session->setFlash ( 'success', 'Vendég kosár kifizetve' );
|
||||||
|
} catch ( Exception $e ) {
|
||||||
|
$transaction->rollback ();
|
||||||
|
Yii::error ( "faled to save :" . $e->getMessage () );
|
||||||
|
\Yii::$app->session->setFlash ( 'danger', 'Hiba történt a mentés során' );
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Yii::error ( "faled to save : no customer or transfer" );
|
||||||
|
\Yii::$app->session->setFlash ( 'warning', 'Nem történt változás' );
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
\Yii::$app->session->setFlash ( 'warning', 'Nem történt változás' );
|
||||||
|
}
|
||||||
|
return $this->redirect ( Yii::$app->request->referrer );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
public function actionLookup($query = null)
|
public function actionLookup($query = null) {
|
||||||
{
|
$result = [ ];
|
||||||
$result = [];
|
$product = Product::findProduct ( $query, Account::readDefault () );
|
||||||
$product = Product::findProduct($query, Account::readDefault());
|
$product = Product::modelToArray ( $product );
|
||||||
$product = Product::modelToArray($product);
|
|
||||||
|
|
||||||
$result['product'] = $product;
|
$result ['product'] = $product;
|
||||||
|
|
||||||
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
|
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
|
||||||
|
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
public function actionFind($id=null)
|
public function actionFind($id = null) {
|
||||||
{
|
$result = [ ];
|
||||||
$result = [];
|
$product = Product::findOne ( $id );
|
||||||
$product = Product::findOne($id);
|
$product = Product::modelToArray ( $product );
|
||||||
$product = Product::modelToArray($product);
|
|
||||||
|
|
||||||
$result['product'] = $product;
|
$result ['product'] = $product;
|
||||||
|
|
||||||
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
|
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Finds the Product model based on its primary key value.
|
* Finds the Product model based on its primary key value.
|
||||||
* If the model is not found, a 404 HTTP exception will be thrown.
|
* If the model is not found, a 404 HTTP exception will be thrown.
|
||||||
|
*
|
||||||
* @param integer $id
|
* @param integer $id
|
||||||
* @return Product the loaded model
|
* @return Product the loaded model
|
||||||
* @throws NotFoundHttpException if the model cannot be found
|
* @throws NotFoundHttpException if the model cannot be found
|
||||||
*/
|
*/
|
||||||
protected function findModel($id)
|
protected function findModel($id) {
|
||||||
{
|
if (($model = Product::findOne ( $id )) !== null) {
|
||||||
if (($model = Product::findOne($id)) !== null) {
|
|
||||||
return $model;
|
return $model;
|
||||||
} else {
|
} else {
|
||||||
throw new NotFoundHttpException('The requested page does not exist.');
|
throw new NotFoundHttpException ( 'The requested page does not exist.' );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
protected function findByNumber($number) {
|
||||||
protected function findByNumber($number){
|
|
||||||
$this->card = null;
|
$this->card = null;
|
||||||
$this->customer = null;
|
$this->customer = null;
|
||||||
if ( $number != null ){
|
if ($number != null) {
|
||||||
$this->card = Card::readCard($number);
|
$this->card = Card::readCard ( $number );
|
||||||
if ( $this->card != null ){
|
if ($this->card != null) {
|
||||||
$this->customer = Customer::find()->innerJoin(Card::tableName(), "customer.id_customer_card = card.id_card")->andWhere( [ 'customer.id_customer_card' => $this->card->id_card ])->one();
|
$this->customer = Customer::find ()->innerJoin ( Card::tableName (), "customer.id_customer_card = card.id_card" )->andWhere ( [
|
||||||
|
'customer.id_customer_card' => $this->card->id_card
|
||||||
|
] )->one ();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Lists all Product models.
|
* Lists all Product models.
|
||||||
|
*
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
/*
|
/*
|
||||||
public function actionIndex()
|
* public function actionIndex()
|
||||||
{
|
* {
|
||||||
$searchModel = new ProductSearch();
|
* $searchModel = new ProductSearch();
|
||||||
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
|
* $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
|
||||||
|
*
|
||||||
return $this->render('index', [
|
* return $this->render('index', [
|
||||||
'searchModel' => $searchModel,
|
* 'searchModel' => $searchModel,
|
||||||
'dataProvider' => $dataProvider,
|
* 'dataProvider' => $dataProvider,
|
||||||
]);
|
* ]);
|
||||||
}
|
* }
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* Displays a single Product model.
|
* Displays a single Product model.
|
||||||
|
*
|
||||||
* @param integer $id
|
* @param integer $id
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
/*
|
/*
|
||||||
public function actionView($id)
|
* public function actionView($id)
|
||||||
{
|
* {
|
||||||
return $this->render('view', [
|
* return $this->render('view', [
|
||||||
'model' => $this->findModel($id),
|
* 'model' => $this->findModel($id),
|
||||||
]);
|
* ]);
|
||||||
}
|
* }
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* Updates an existing Product model.
|
* Updates an existing Product model.
|
||||||
* If update is successful, the browser will be redirected to the 'view' page.
|
* If update is successful, the browser will be redirected to the 'view' page.
|
||||||
|
*
|
||||||
* @param integer $id
|
* @param integer $id
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
/*
|
/*
|
||||||
public function actionUpdate($id)
|
* public function actionUpdate($id)
|
||||||
{
|
* {
|
||||||
$model = $this->findModel($id);
|
* $model = $this->findModel($id);
|
||||||
|
*
|
||||||
if ($model->load(Yii::$app->request->post()) && $model->save()) {
|
* if ($model->load(Yii::$app->request->post()) && $model->save()) {
|
||||||
return $this->redirect(['view', 'id' => $model->id_product]);
|
* return $this->redirect(['view', 'id' => $model->id_product]);
|
||||||
} else {
|
* } else {
|
||||||
return $this->render('update', [
|
* return $this->render('update', [
|
||||||
'model' => $model,
|
* 'model' => $model,
|
||||||
]);
|
* ]);
|
||||||
}
|
* }
|
||||||
}
|
* }
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* Deletes an existing Product model.
|
* Deletes an existing Product model.
|
||||||
* If deletion is successful, the browser will be redirected to the 'index' page.
|
* If deletion is successful, the browser will be redirected to the 'index' page.
|
||||||
|
*
|
||||||
* @param integer $id
|
* @param integer $id
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
/*
|
/*
|
||||||
public function actionDelete($id)
|
* public function actionDelete($id)
|
||||||
{
|
* {
|
||||||
$this->findModel($id)->delete();
|
* $this->findModel($id)->delete();
|
||||||
|
*
|
||||||
return $this->redirect(['index']);
|
* return $this->redirect(['index']);
|
||||||
}
|
* }
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* Creates a new Product model.
|
* Creates a new Product model.
|
||||||
* If creation is successful, the browser will be redirected to the 'view' page.
|
* If creation is successful, the browser will be redirected to the 'view' page.
|
||||||
|
*
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
/*
|
/*
|
||||||
public function actionCreate()
|
* public function actionCreate()
|
||||||
{
|
* {
|
||||||
$model = new Product();
|
* $model = new Product();
|
||||||
|
*
|
||||||
if ($model->load(Yii::$app->request->post()) && $model->save()) {
|
* if ($model->load(Yii::$app->request->post()) && $model->save()) {
|
||||||
return $this->redirect(['view', 'id' => $model->id_product]);
|
* return $this->redirect(['view', 'id' => $model->id_product]);
|
||||||
} else {
|
* } else {
|
||||||
return $this->render('create', [
|
* return $this->render('create', [
|
||||||
'model' => $model,
|
* 'model' => $model,
|
||||||
]);
|
* ]);
|
||||||
}
|
* }
|
||||||
}
|
* }
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|||||||
@ -189,6 +189,7 @@ class TransferController extends Controller
|
|||||||
try {
|
try {
|
||||||
$transfer->status = Transfer::STATUS_PAID;
|
$transfer->status = Transfer::STATUS_PAID;
|
||||||
$transfer->paid_at = date('Y-m-d H:i:s' ) ;
|
$transfer->paid_at = date('Y-m-d H:i:s' ) ;
|
||||||
|
$transfer->paid_by = \Yii::$app->user->id;
|
||||||
ShoppingCart::deleteAll([ 'id_transfer' => $transfer->id_transfer]);
|
ShoppingCart::deleteAll([ 'id_transfer' => $transfer->id_transfer]);
|
||||||
UserSoldItem::deleteAll([ 'id_transfer' => $transfer->id_transfer]);
|
UserSoldItem::deleteAll([ 'id_transfer' => $transfer->id_transfer]);
|
||||||
if ( $transfer->save() ){
|
if ( $transfer->save() ){
|
||||||
|
|||||||
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;
|
$this->transfer->id_user = Yii::$app->user->id;
|
||||||
|
|
||||||
|
if ( $status == Transfer::STATUS_PAID){
|
||||||
|
$this->transfer->paid_by = Yii::$app->user->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$this->transfer->save();
|
$this->transfer->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -7,6 +7,7 @@ use yii\base\Model;
|
|||||||
use common\models\Card;
|
use common\models\Card;
|
||||||
use common\models\Customer;
|
use common\models\Customer;
|
||||||
use common\models\Ticket;
|
use common\models\Ticket;
|
||||||
|
use common\models\Account;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ContactForm is the model behind the contact form.
|
* ContactForm is the model behind the contact form.
|
||||||
@ -17,7 +18,7 @@ class ReceptionForm extends Model
|
|||||||
public $card;
|
public $card;
|
||||||
public $customer;
|
public $customer;
|
||||||
public $tickets;
|
public $tickets;
|
||||||
|
public $defaultAccount;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
@ -44,11 +45,25 @@ class ReceptionForm extends Model
|
|||||||
|
|
||||||
$this->number = str_replace("ö", "0", $this->number);
|
$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 ){
|
if ( $this->card != null ){
|
||||||
$this->customer = $this->card->customer;
|
$this->customer = $this->card->customer;
|
||||||
$this->readValidTickets();
|
$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(){
|
public function readValidTickets(){
|
||||||
|
|||||||
@ -120,6 +120,7 @@ class TicketCreate extends Ticket{
|
|||||||
}else {
|
}else {
|
||||||
$status = Transfer::STATUS_PAID;
|
$status = Transfer::STATUS_PAID;
|
||||||
$transfer->paid_at = date('Y-m-d H:i:s' ) ;
|
$transfer->paid_at = date('Y-m-d H:i:s' ) ;
|
||||||
|
$transfer->paid_by = \Yii::$app->user->id;
|
||||||
}
|
}
|
||||||
$transfer->status = $status;
|
$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 [
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -7,6 +7,13 @@ use yii\base\Widget;
|
|||||||
use frontend\components\ReceptionTicketWidget;
|
use frontend\components\ReceptionTicketWidget;
|
||||||
use frontend\components\ReceptionCustomerWidget;
|
use frontend\components\ReceptionCustomerWidget;
|
||||||
?>
|
?>
|
||||||
|
<div class='row'>
|
||||||
|
<div class='col-md-4'>
|
||||||
|
<div class="alert alert-info">
|
||||||
|
Aktuális kassza: <?php echo $model->getDefaultAccountName();?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class='row'>
|
<div class='row'>
|
||||||
<div class='col-md-3'>
|
<div class='col-md-3'>
|
||||||
<?php echo ReceptionMenuWidget::widget( [ 'model' => $model ] ) ?>
|
<?php echo ReceptionMenuWidget::widget( [ 'model' => $model ] ) ?>
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
use yii\bootstrap\Html;
|
use yii\bootstrap\Html;
|
||||||
|
use yii\widgets\ActiveForm;
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
|
||||||
@ -35,7 +36,7 @@ use yii\bootstrap\Html;
|
|||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class='col-md-3 '>
|
<div class='col-md-3 '>
|
||||||
<?php echo Html::a(Yii::t('frontend/product', "Paid"),null,[ 'id' => 'btn_pay_customer_cart', 'class' => 'btn btn-primary btn-block' , 'name' => 'payout_customer_cart']) ?>
|
<?php echo Html::a(Yii::t('frontend/product', "Paid"),"javascript: $('#frm_customer_cart').submit()",[ 'id' => 'btn_pay_customer_cart', 'class' => 'btn btn-primary btn-block' , 'name' => 'payout_customer_cart']) ?>
|
||||||
</div>
|
</div>
|
||||||
<div class='col-md-3 '>
|
<div class='col-md-3 '>
|
||||||
<?php echo Html::a(Yii::t('frontend/product', "Frissít"),null,[ 'class' => 'btn btn-primary btn-block' , 'onclick' => 'location.reload();']) ?>
|
<?php echo Html::a(Yii::t('frontend/product', "Frissít"),null,[ 'class' => 'btn btn-primary btn-block' , 'onclick' => 'location.reload();']) ?>
|
||||||
|
|||||||
@ -39,9 +39,7 @@ use kartik\widgets\ActiveForm;
|
|||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class='col-md-3 '>
|
<div class='col-md-3 '>
|
||||||
<?php $form = ActiveForm::begin([]); ?>
|
<?php echo Html::a( Yii::t('frontend/product', "Paid"), "javascript: $('#frm_user_cart').submit()",[ 'id' => 'btn_pay_user_cart', 'class' => 'btn btn-primary btn-block' , 'name' => 'payout_user_cart']) ?>
|
||||||
<?php echo Html::submitButton( Yii::t('frontend/product', "Paid"), [ 'id' => 'btn_pay_user_cart', 'class' => 'btn btn-primary btn-block' , 'name' => 'payout_user_cart']) ?>
|
|
||||||
<?php ActiveForm::end(); ?>
|
|
||||||
</div>
|
</div>
|
||||||
<div class='col-md-3 '>
|
<div class='col-md-3 '>
|
||||||
<?php echo Html::a(Yii::t('frontend/product', "Frissít"),null,[ 'class' => 'btn btn-primary btn-block' , 'onclick' => 'location.reload();']) ?>
|
<?php echo Html::a(Yii::t('frontend/product', "Frissít"),null,[ 'class' => 'btn btn-primary btn-block' , 'onclick' => 'location.reload();']) ?>
|
||||||
|
|||||||
@ -18,7 +18,7 @@ $options = [];
|
|||||||
|
|
||||||
$options['lookup_product_url'] = Url::toRoute(['product/lookup']);
|
$options['lookup_product_url'] = Url::toRoute(['product/lookup']);
|
||||||
$options['find_product_url'] = Url::toRoute(['product/find']);
|
$options['find_product_url'] = Url::toRoute(['product/find']);
|
||||||
$options['url_pay_user_cart'] = Url::toRoute(['product/payout-user-cart']);
|
$options['url_pay_user_cart'] = Url::toRoute(['product/payout-user-cart' , 'number' =>isset($model->card) ? $model->card->number : '']);
|
||||||
$options['url_delete_transaction'] = Url::toRoute(['transfer/delete']);
|
$options['url_delete_transaction'] = Url::toRoute(['transfer/delete']);
|
||||||
$options['url_pay_transaction'] = Url::toRoute(['transfer/payout']);
|
$options['url_pay_transaction'] = Url::toRoute(['transfer/payout']);
|
||||||
$options['user_cart'] = $userTransfers;
|
$options['user_cart'] = $userTransfers;
|
||||||
@ -95,7 +95,7 @@ $this->params['breadcrumbs'][] = Yii::t('frontend/product', 'Sale');
|
|||||||
</div>
|
</div>
|
||||||
<div class='col-md-6'>
|
<div class='col-md-6'>
|
||||||
<?php if ( $receptionForm->isCardWithCustomer() ){ ?>
|
<?php if ( $receptionForm->isCardWithCustomer() ){ ?>
|
||||||
<?php echo $this->render('_customer_cart' ) ?>
|
<?php echo $this->render('_customer_cart' , ['model' => $model]) ?>
|
||||||
<?php }?>
|
<?php }?>
|
||||||
<?php echo $this->render('_user_cart' ) ?>
|
<?php echo $this->render('_user_cart' ) ?>
|
||||||
|
|
||||||
|
|||||||
@ -34,8 +34,9 @@ use kartik\widgets\ActiveForm;
|
|||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class='col-md-3 '>
|
<div class='col-md-3 '>
|
||||||
<?php $form = ActiveForm::begin([]); ?>
|
<?php echo Html::a(Yii::t('frontend/product', "Paid"),"javascript: $('#frm_customer_cart').submit()",[ 'id' => 'btn_pay_customer_cart', 'class' => 'btn btn-primary btn-block' , 'name' => 'payout_customer_cart']) ?>
|
||||||
<?php echo Html::submitButton( Yii::t('frontend/product', "Paid") , [ 'id' => 'btn_pay_user_cart', 'class' => 'btn btn-primary btn-block', 'name' => 'payout_customer_cart' ] ) ?>
|
</div>
|
||||||
<?php ActiveForm::end(); ?>
|
<div class='col-md-3 '>
|
||||||
|
<?php echo Html::a(Yii::t('frontend/product', "Frissít"),null,[ 'class' => 'btn btn-primary btn-block' , 'onclick' => 'location.reload();']) ?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -36,8 +36,9 @@ use kartik\widgets\ActiveForm;
|
|||||||
</div>
|
</div>
|
||||||
<div class='row' >
|
<div class='row' >
|
||||||
<div class='col-md-3'>
|
<div class='col-md-3'>
|
||||||
<?php $form = ActiveForm::begin([]); ?>
|
<?php echo Html::a( Yii::t('frontend/product', "Paid"), "javascript: $('#frm_user_cart').submit()",[ 'id' => 'btn_pay_user_cart', 'class' => 'btn btn-primary btn-block' , 'name' => 'payout_user_cart']) ?>
|
||||||
<?php echo Html::submitButton(Yii::t('frontend/product', "Paid"),[ 'id' => 'btn_pay_user_cart', 'class' => 'btn btn-primary btn-block' , 'name' => 'payout_user_cart']) ?>
|
</div>
|
||||||
<?php ActiveForm::end(); ?>
|
<div class='col-md-3 '>
|
||||||
|
<?php echo Html::a(Yii::t('frontend/product', "Frissít"),null,[ 'class' => 'btn btn-primary btn-block' , 'onclick' => 'location.reload();']) ?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -29,10 +29,16 @@ $options = [];
|
|||||||
$options['clear_cart_url'] = Url::toRoute(['product/clear-list']);
|
$options['clear_cart_url'] = Url::toRoute(['product/clear-list']);
|
||||||
$options['types'] = TicketType::modelsToArray($ticketTypes);
|
$options['types'] = TicketType::modelsToArray($ticketTypes);
|
||||||
$options['user_cart'] = $model->userCart;
|
$options['user_cart'] = $model->userCart;
|
||||||
$options['customer_cart'] = $model->customerCart;
|
// $options['customer_cart'] = $model->customerCart;
|
||||||
$options['selected_type'] = count($ticketTypes) > 0 ? $ticketTypes[0]->id_ticket_type : 0;
|
$options['selected_type'] = count($ticketTypes) > 0 ? $ticketTypes[0]->id_ticket_type : 0;
|
||||||
$options['url_delete_transaction'] = Url::toRoute(['transfer/delete']);
|
$options['url_delete_transaction'] = Url::toRoute(['transfer/delete']);
|
||||||
$options['url_pay_transaction'] = Url::toRoute(['transfer/payout']);
|
$options['url_pay_transaction'] = Url::toRoute(['transfer/payout']);
|
||||||
|
$options['url_pay_user_cart'] = Url::toRoute(['product/payout-user-cart' , 'number' =>isset($receptionForm->card) ? $receptionForm->card->number : '']);
|
||||||
|
|
||||||
|
if ( isset($receptionForm->card) ){
|
||||||
|
$options['url_pay_customer_card'] = Url::toRoute(['product/payout-customer-cart','number' => $receptionForm->card->number]);
|
||||||
|
$options['customer_cart'] = $model->customerCart;
|
||||||
|
}
|
||||||
|
|
||||||
$this->registerJs ( 'new TicketSell( '. json_encode($options).');' );
|
$this->registerJs ( 'new TicketSell( '. json_encode($options).');' );
|
||||||
?>
|
?>
|
||||||
|
|||||||
@ -25,13 +25,15 @@ function ProductSell(o){
|
|||||||
form_invalid: 'Az ürlap hibákat tartalmaz',
|
form_invalid: 'Az ürlap hibákat tartalmaz',
|
||||||
message_paid: 'Tételek fizetve',
|
message_paid: 'Tételek fizetve',
|
||||||
/**list of sold items by current user*/
|
/**list of sold items by current user*/
|
||||||
user_cart: [],
|
user_cart: [],// the user cart items
|
||||||
discounts: [],
|
discounts: [],
|
||||||
customer_cart: [],
|
customer_cart: [], //the customer cart items
|
||||||
id_account: null,
|
id_account: null,
|
||||||
products : [],
|
products : [],
|
||||||
url_delete_transaction : '',
|
url_delete_transaction : '',
|
||||||
url_pay_transaction : '',
|
url_pay_transaction : '',
|
||||||
|
value_number: '',
|
||||||
|
name_number: '',
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -70,8 +72,8 @@ function ProductSell(o){
|
|||||||
* payout out user or customer cart
|
* payout out user or customer cart
|
||||||
* */
|
* */
|
||||||
function addPayoutButtons(){
|
function addPayoutButtons(){
|
||||||
addBehaviourPayoutUserCart();
|
// addBehaviourPayoutUserCart();
|
||||||
addBehaviourPayoutCustomerCart();
|
// addBehaviourPayoutCustomerCart();
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* display user and customer cart on page load
|
* display user and customer cart on page load
|
||||||
@ -464,7 +466,6 @@ function ProductSell(o){
|
|||||||
}
|
}
|
||||||
function addBehaviourPayoutCustomerCart( ){
|
function addBehaviourPayoutCustomerCart( ){
|
||||||
$( app.defaults.selector_btn_pay_customer_cart ).on('click',function(){
|
$( app.defaults.selector_btn_pay_customer_cart ).on('click',function(){
|
||||||
alert('ok');
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: app.defaults.url_pay_customer_card,
|
url: app.defaults.url_pay_customer_card,
|
||||||
type: 'post',
|
type: 'post',
|
||||||
@ -489,6 +490,11 @@ function ProductSell(o){
|
|||||||
'transfers' : app.defaults.user_cart,
|
'transfers' : app.defaults.user_cart,
|
||||||
'url_delete' : app.defaults.url_delete_transaction,
|
'url_delete' : app.defaults.url_delete_transaction,
|
||||||
'url_pay' : app.defaults.url_pay_transaction,
|
'url_pay' : app.defaults.url_pay_transaction,
|
||||||
|
'url_pay_all_visible' : app.defaults.url_pay_user_cart,
|
||||||
|
'name_transfers' : 'UserCartPayoutForm[transfers][]',
|
||||||
|
'id_form' : 'frm_user_cart',
|
||||||
|
// 'value_number': app.defaults.value_number,
|
||||||
|
// 'name_number':app.defaults.name_number,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
function createCustomerCartTable(){
|
function createCustomerCartTable(){
|
||||||
@ -496,6 +502,11 @@ function ProductSell(o){
|
|||||||
'transfers' : app.defaults.customer_cart,
|
'transfers' : app.defaults.customer_cart,
|
||||||
'url_delete' : app.defaults.url_delete_transaction,
|
'url_delete' : app.defaults.url_delete_transaction,
|
||||||
'url_pay' : app.defaults.url_pay_transaction,
|
'url_pay' : app.defaults.url_pay_transaction,
|
||||||
|
'url_pay_all_visible' : app.defaults.url_pay_customer_card,
|
||||||
|
'name_transfers' : 'CustomerCartPayoutForm[transfers][]',
|
||||||
|
'id_form' : 'frm_customer_cart',
|
||||||
|
// 'value_number': app.defaults.value_number,
|
||||||
|
// 'name_number':app.defaults.name_number,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -79,8 +79,8 @@ function TicketSell(o){
|
|||||||
* payout out user or customer cart
|
* payout out user or customer cart
|
||||||
* */
|
* */
|
||||||
function addPayoutButtons(){
|
function addPayoutButtons(){
|
||||||
addBehaviourPayoutUserCart();
|
// addBehaviourPayoutUserCart();
|
||||||
addBehaviourPayoutCustomerCart();
|
// addBehaviourPayoutCustomerCart();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -96,6 +96,9 @@ function TicketSell(o){
|
|||||||
'transfers' : app.defaults.user_cart,
|
'transfers' : app.defaults.user_cart,
|
||||||
'url_delete' : app.defaults.url_delete_transaction,
|
'url_delete' : app.defaults.url_delete_transaction,
|
||||||
'url_pay' : app.defaults.url_pay_transaction,
|
'url_pay' : app.defaults.url_pay_transaction,
|
||||||
|
'url_pay_all_visible' : app.defaults.url_pay_user_cart,
|
||||||
|
'name_transfers' : 'UserCartPayoutForm[transfers][]',
|
||||||
|
'id_form' : 'frm_user_cart',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
function createCustomerCartTable(){
|
function createCustomerCartTable(){
|
||||||
@ -103,6 +106,9 @@ function TicketSell(o){
|
|||||||
'transfers' : app.defaults.customer_cart,
|
'transfers' : app.defaults.customer_cart,
|
||||||
'url_delete' : app.defaults.url_delete_transaction,
|
'url_delete' : app.defaults.url_delete_transaction,
|
||||||
'url_pay' : app.defaults.url_pay_transaction,
|
'url_pay' : app.defaults.url_pay_transaction,
|
||||||
|
'url_pay_all_visible' : app.defaults.url_pay_customer_card,
|
||||||
|
'name_transfers' : 'CustomerCartPayoutForm[transfers][]',
|
||||||
|
'id_form' : 'frm_customer_cart',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -3,6 +3,9 @@ $.widget( "fitness.transferList", {
|
|||||||
transfers: [],
|
transfers: [],
|
||||||
url_delete : '',
|
url_delete : '',
|
||||||
url_pay : '',
|
url_pay : '',
|
||||||
|
url_pay_all_visible: '',
|
||||||
|
name_transfers: '',//name to use for transfer id in form
|
||||||
|
id_form: '',
|
||||||
columns: [
|
columns: [
|
||||||
|
|
||||||
{ 'label' : 'Idő' },
|
{ 'label' : 'Idő' },
|
||||||
@ -42,6 +45,7 @@ $.widget( "fitness.transferList", {
|
|||||||
_refresh: function(){
|
_refresh: function(){
|
||||||
var s;
|
var s;
|
||||||
s = this._render('table',{ 'columns' : this.options.columns, 'transfers' : this.options.transfers,'footer': this.options.footers });
|
s = this._render('table',{ 'columns' : this.options.columns, 'transfers' : this.options.transfers,'footer': this.options.footers });
|
||||||
|
s += this.makeForm();
|
||||||
this.element.html(s);
|
this.element.html(s);
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -159,7 +163,19 @@ $.widget( "fitness.transferList", {
|
|||||||
// Fire event
|
// Fire event
|
||||||
// this._triggerOptionChanged(key, prev, value);
|
// this._triggerOptionChanged(key, prev, value);
|
||||||
}
|
}
|
||||||
|
}, makeForm: function(){
|
||||||
|
var s;
|
||||||
|
s = "";
|
||||||
|
s += "<form method='post' action='"+ this.options.url_pay_all_visible + "' id='"+this.options.id_form+"'>";
|
||||||
|
// s += "<input type='hidden' name='"+this.options.name_number+"' value='"+this.options.value_number+"'>";
|
||||||
|
for( var i = 0; i < this.options.transfers.length; i++){
|
||||||
|
s += "<input type='hidden' name='"+this.options.name_transfers+"' value='"+this.options.transfers[i].id_transfer+"'>";
|
||||||
|
}
|
||||||
|
s += "</form>";
|
||||||
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
Loading…
Reference in New Issue
Block a user