diff --git a/backend/models/TransferSearch.php b/backend/models/TransferSearch.php index e6a1b2e..7f9e7e7 100644 --- a/backend/models/TransferSearch.php +++ b/backend/models/TransferSearch.php @@ -37,7 +37,7 @@ class TransferSearch extends Transfer return [ [[ 'id_account','id_user', 'type'], 'integer'], // [[ 'searchObjectName' ], 'string'], - [[ 'start', ], 'date' , 'timestampAttribute' => 'timestampStart' ,'timestampAttributeFormat' => 'yyyy-MM-dd' ], + [[ 'start', ], 'date' , 'timestampAttribute' => 'timestampStart' ,'timestampAttributeFormat' => 'yyyy-MM-dd' ], [[ 'end' , ], 'date' , 'timestampAttribute' => 'timestampEnd' ,'timestampAttributeFormat' => 'yyyy-MM-dd' ], ]; } @@ -92,8 +92,8 @@ class TransferSearch extends Transfer 'transfer.id_user' => $this->id_user, ]); - $query->andFilterWhere([ '>=', 'transfer.created_at', $this->timestampStart ] ); - $query->andFilterWhere([ '<', 'transfer.created_at', $this->timestampEnd ] ); + $query->andFilterWhere([ '>=', 'transfer.created_at' , $this->timestampStart ] ); + $query->andFilterWhere([ '<' , 'transfer.created_at' , $this->timestampEnd ] ); // if ( isset($this->searchObjectName)) // $query->andWhere( new Expression(" case when transfer.type = " .self::TYPE_PRODUCT ." then product.name else ticket_type.name end like '%" . $this->searchObjectName ."%'")); diff --git a/common/components/CustomerAwareBehavior.php b/common/components/CustomerAwareBehavior.php new file mode 100644 index 0000000..30b02f9 --- /dev/null +++ b/common/components/CustomerAwareBehavior.php @@ -0,0 +1,24 @@ +owner->customer; + if (isset($customer)){ + $result = $customer->name; + } + return $result; + } + + + public function getCustomer(){ + return $this->owner->hasOne( Customer::className(), ["id_customer" =>"id_customer" ] ) ; + } + +} \ No newline at end of file diff --git a/common/messages/hu/common/transfer.php b/common/messages/hu/common/transfer.php index 18ef6f3..43caddd 100644 --- a/common/messages/hu/common/transfer.php +++ b/common/messages/hu/common/transfer.php @@ -27,7 +27,7 @@ return [ 'Id Currency' => 'Valuta', 'Id Discount' => 'Kedvezmény', 'Id Object' => 'Termék', - 'Id Transfer' => 'Pénzmozgás', + 'Id Transfer' => 'Tranzakció', 'Id User' => 'Felhasználó', 'Item Price' => 'Termék ár', 'Money' => 'Összeg', diff --git a/common/messages/hu/frontend/money-movement.php b/common/messages/hu/frontend/money-movement.php new file mode 100644 index 0000000..f6f0126 --- /dev/null +++ b/common/messages/hu/frontend/money-movement.php @@ -0,0 +1,24 @@ + 'Kassza', + 'User' => 'Felhasználó', + 'End' => 'Időintervallum vége', + 'Start' => 'Időintervallum kezdete', +]; diff --git a/common/messages/hu/frontend/product.php b/common/messages/hu/frontend/product.php index 3d0864d..6df19ec 100644 --- a/common/messages/hu/frontend/product.php +++ b/common/messages/hu/frontend/product.php @@ -20,7 +20,7 @@ return [ 'Customer cart' => 'Vendég kosár', 'Fizetve' => 'Fizetve', 'To cart' => 'Kosárba', - 'User Cart' => 'Kosárba', + 'User Cart' => 'Recepció kosár', 'Write up' => 'Felír', 'Account' => 'Kassza', 'Are you sure you want to delete this item?' => 'Biztosan törölni szeretné ezt a vendéget?', diff --git a/common/models/MoneyMovement.php b/common/models/MoneyMovement.php index fb22fca..4c45d40 100644 --- a/common/models/MoneyMovement.php +++ b/common/models/MoneyMovement.php @@ -95,6 +95,8 @@ class MoneyMovement extends \yii\db\ActiveRecord 'comment' => Yii::t('common/money-movement', 'Comment'), 'created_at' => Yii::t('common/money-movement', 'Created At'), 'updated_at' => Yii::t('common/money-movement', 'Updated At'), + 'accountName' => Yii::t('frontend/money-movement', 'Account'), + 'userName' => Yii::t('frontend/money-movement', 'User'), ]; } diff --git a/common/models/ShoppingCart.php b/common/models/ShoppingCart.php index a955c0b..af46e66 100644 --- a/common/models/ShoppingCart.php +++ b/common/models/ShoppingCart.php @@ -68,8 +68,9 @@ class ShoppingCart extends \yii\db\ActiveRecord //delete cart $sql = "UPDATE transfer AS t 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' ) - . " WHERE t.status = " . Transfer::STATUS_NOT_PAID; + SET t.status = " . Transfer::STATUS_PAID . ", t.paid_at = '" . date('Y-m-d H:i:s' ) ."'" + . " WHERE t.status = " . Transfer::STATUS_NOT_PAID + . " and s.id_customer = " . $customer->id_customer ; $q1 = Yii::$app->db->createCommand($sql); $q1->execute(); diff --git a/common/models/Transfer.php b/common/models/Transfer.php index 7c4b6cb..a06a8ba 100644 --- a/common/models/Transfer.php +++ b/common/models/Transfer.php @@ -8,6 +8,8 @@ use yii\helpers\ArrayHelper; use yii\behaviors\TimestampBehavior; use common\components\AccountAwareBehavior; use common\components\UserAwareBehavior; +use common\components\DiscountAwareBehavior; +use common\components\CustomerAwareBehavior; /** * This is the model class for table "transfer". @@ -29,6 +31,8 @@ use common\components\UserAwareBehavior; * @property string $created_at * @property string $updated_at * @property integer $direction + * @property string $paid_at + * @property integer $id_customer */ class Transfer extends \common\models\BaseFitnessActiveRecord { @@ -54,12 +58,12 @@ class Transfer extends \common\models\BaseFitnessActiveRecord 'class' => TimestampBehavior::className(), 'value' => function(){ return date('Y-m-d H:i:s' ); } ], -// [ -// 'class' => AccountAwareBehavior::className(), -// ], -// [ -// 'class' => UserAwareBehavior::className(), -// ], + [ + 'class' => DiscountAwareBehavior::className(), + ], + [ + 'class' => CustomerAwareBehavior::className(), + ], ], parent::behaviors()); } @@ -103,9 +107,11 @@ class Transfer extends \common\models\BaseFitnessActiveRecord 'money_currency' => Yii::t('common/transfer', 'Money Currency'), 'rate' => Yii::t('common/transfer', 'Rate'), 'id_user' => Yii::t('common/transfer', 'Id User'), + 'id_customer' => Yii::t('common/transfer', 'Customer'), 'comment' => Yii::t('common/transfer', 'Comment'), 'created_at' => Yii::t('common/transfer', 'Created At'), 'updated_at' => Yii::t('common/transfer', 'Updated At'), + 'paid_at' => Yii::t('common/transfer', 'Paid At'), ]; } @@ -136,9 +142,9 @@ class Transfer extends \common\models\BaseFitnessActiveRecord return $this->hasOne( Currency::className(), ["id_currency" =>"id_currency" ] ); } - public function getDiscount(){ - return $this->hasOne( Discount::className(), ["id_discount" =>"id_discount" ] ); - } +// public function getDiscount(){ +// return $this->hasOne( Discount::className(), ["id_discount" =>"id_discount" ] ); +// } public function getUserSoldItem(){ return $this->hasOne( UserSoldItem::className(), ["id_transfer" =>"id_transfer" ] ); @@ -256,8 +262,9 @@ class Transfer extends \common\models\BaseFitnessActiveRecord * @param $discount common\models\Discount * @param $currency common\models\Currency * @param $product common\models\Product + * @param $customer common\models\Customer * */ - public static function createProductTransfer($sale,$account, $discount, $currency, $count,$product , $status = Transfer::STATUS_PAID){ + public static function createProductTransfer($sale,$account, $discount, $currency, $count,$product , $status = Transfer::STATUS_PAID,$customer = null){ $transfer = new Transfer(); $transfer->type = Transfer::TYPE_PRODUCT; @@ -287,6 +294,10 @@ class Transfer extends \common\models\BaseFitnessActiveRecord $transfer->id_account = $account->id_account; + if ( isset( $customer ) ){ + $transfer->id_customer = $customer->id_customer; + } + return $transfer; } @@ -309,6 +320,8 @@ class Transfer extends \common\models\BaseFitnessActiveRecord $transfer->id_account = $account->id_account; + $transfer->paid_at = date('Y-m-d H:i:s' ) ; + return $transfer; } /** @@ -317,9 +330,10 @@ class Transfer extends \common\models\BaseFitnessActiveRecord * @param $currency common\models\Currency * @param $ticket common\models\Ticket * */ - public static function createTicketTransfer($account, $discount, $currency, $count,$ticket ){ + public static function createTicketTransfer($account, $discount, $currency, $count,$ticket ,$status = Transfer::STATUS_NOT_PAID){ $transfer = new Transfer(); + $transfer->status = $status; $transfer->type = Transfer::TYPE_TICKET; $transfer->id_object = $ticket->id_ticket; @@ -422,6 +436,20 @@ class Transfer extends \common\models\BaseFitnessActiveRecord self::TYPE_TICKET => Yii::t('common/transfer','Ticket'), ]; } + public static function statuses( ) { + return [ + self::STATUS_NOT_PAID => Yii::t('common/transfer','Nincs fizetve'), + self::STATUS_PAID => Yii::t('common/transfer','Fizetve'), + ]; + } + public function getStatusName( ) { + $status = null; + $statuses = self::statuses(); + if ( array_key_exists($this->status, $statuses)){ + $status = $statuses[$this->status]; + } + return $status; + } diff --git a/common/models/UserSoldItem.php b/common/models/UserSoldItem.php index 2d3ad74..ff40dd0 100644 --- a/common/models/UserSoldItem.php +++ b/common/models/UserSoldItem.php @@ -61,5 +61,24 @@ class UserSoldItem extends \yii\db\ActiveRecord } + /** + * @param common\models\User $user + * */ + public static function payout( $user ) { + //apply transfer object + //delete cart + $sql = "UPDATE transfer AS t + 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' ) ."'" + . " WHERE t.status = " . Transfer::STATUS_NOT_PAID + . " and s.id_user =" . $user->id ; + + $q1 = Yii::$app->db->createCommand($sql); + $q1->execute(); + + UserSoldItem::deleteAll(['id_user' => Yii::$app->user->id]); + + } + } diff --git a/console/migrations/m151029_090850_alter__table__transfer__add__column__id_customer.php b/console/migrations/m151029_090850_alter__table__transfer__add__column__id_customer.php new file mode 100644 index 0000000..899b057 --- /dev/null +++ b/console/migrations/m151029_090850_alter__table__transfer__add__column__id_customer.php @@ -0,0 +1,30 @@ +addColumn("transfer", 'id_customer"', 'int(11)'); + } + + public function down() + { + echo "m151029_090850_alter__table__transfer__add__column__id_customer cannot be reverted.\n"; + + return false; + } + + /* + // Use safeUp/safeDown to run migration code within a transaction + public function safeUp() + { + } + + public function safeDown() + { + } + */ +} diff --git a/console/migrations/m151029_095915_alter__table__transfer__fix__id_customer__column__name.php b/console/migrations/m151029_095915_alter__table__transfer__fix__id_customer__column__name.php new file mode 100644 index 0000000..b8b66f5 --- /dev/null +++ b/console/migrations/m151029_095915_alter__table__transfer__fix__id_customer__column__name.php @@ -0,0 +1,30 @@ +renameColumn("transfer", 'id_customer"', "id_customer"); + } + + public function down() + { + echo "m151029_095915_alter__table__transfer__fix__id_customer__column__name cannot be reverted.\n"; + + return false; + } + + /* + // Use safeUp/safeDown to run migration code within a transaction + public function safeUp() + { + } + + public function safeDown() + { + } + */ +} diff --git a/frontend/components/FrontendController.php b/frontend/components/FrontendController.php new file mode 100644 index 0000000..02a148d --- /dev/null +++ b/frontend/components/FrontendController.php @@ -0,0 +1,62 @@ +number = $number; + $receptionForm->readCard(); + return $receptionForm; + } + + + protected function payoutCustomerCart($receptionForm){ + $result = false; + if ( isset($receptionForm->customer)){ + $connection = \Yii::$app->db; + $transaction = $connection->beginTransaction(); + try { + ShoppingCart::payout($receptionForm->customer); + $transaction->commit(); + Yii::$app->session->setFlash('success', Yii::t('frontend/ticket', 'Customer cart paid!') ); + $result = true; + } catch(Exception $e) { + $transaction->rollback(); + } + } + return $result; + } + + protected function payoutUserCart($receptionForm){ + $connection = \Yii::$app->db; + $transaction = $connection->beginTransaction(); + try { + $user = User::findOne(Yii::$app->user->id ); + UserSoldItem::payout($user); + $transaction->commit(); + Yii::$app->session->setFlash('success', Yii::t('frontend/ticket', 'User cart paid!') ); + return $this->redirect(['customer/reception' ]); + } catch(Exception $e) { + $transaction->rollback(); + } + return true; + } + +} \ No newline at end of file diff --git a/frontend/components/FrontendMenuStructure.php b/frontend/components/FrontendMenuStructure.php index 6e61ed1..85bbe5e 100644 --- a/frontend/components/FrontendMenuStructure.php +++ b/frontend/components/FrontendMenuStructure.php @@ -11,15 +11,19 @@ use common\models\AccountState; class FrontendMenuStructure{ public $menuItems; - public $start; - public $tomorrow; + public $start;//start date and time + public $tomorrow;//tomorrow date and time + + public $startDate;//start date + public $tomorrowDate;//tomorrow date public function __construct(){ $this->menuItems = []; -// print('abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
'); $this->start = Yii::$app->formatter->asDatetime( strtotime('today UTC') ); $this->tomorrow = Yii::$app->formatter->asDatetime( strtotime('tomorrow UTC') ); + $this->startDate = Yii::$app->formatter->asDate( strtotime('today UTC') ); + $this->tomorrowDate = Yii::$app->formatter->asDate( strtotime('tomorrow UTC') ); Yii::info("Start date is : ". $this->start); @@ -57,13 +61,15 @@ class FrontendMenuStructure{ if ( $this->isLogged() ){ $this->menuItems[] = ['label' => 'Recepcio', 'url' => ['/customer/reception'] ]; // , 'MoneyMovementSearch[start]' => $this->start, 'MoneyMovementSearch[end]' => $this->tomorrow - $this->menuItems[] = ['label' => 'Pénzmozgások', 'url' => [ '/money-movement/index', 'MoneyMovementSearch[start]' => $this->start, 'MoneyMovementSearch[end]' => $this->tomorrow ] ]; +// $this->menuItems[] = ['label' => 'Pénzmozgások', 'url' => [ '/money-movement/index', 'MoneyMovementSearch[start]' => $this->start, 'MoneyMovementSearch[end]' => $this->tomorrow ] ]; $this->menuItems[] = ['label' => 'Kassza', 'items' => [ ['label' => Yii::t('frontend/account-state','Default account'), 'url' => ['/account/select'] ], ['label' => Yii::t('frontend/account-state', 'Account states'), 'url' => ['/account-state/index'] ], ['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' => 'Pénzmozgások', 'url' => [ '/money-movement/index', 'MoneyMovementSearch[start]' => $this->start, 'MoneyMovementSearch[end]' => $this->tomorrow ] ], + ['label' => Yii::t('frontend/transfer','Transfers'), 'url' => ['/transfer/index', 'TransferSearch[start]' => $this->start, 'TransferSearch[end]' => $this->tomorrow ] ], ] ]; diff --git a/frontend/controllers/AccountController.php b/frontend/controllers/AccountController.php index 31088de..f1d44e9 100644 --- a/frontend/controllers/AccountController.php +++ b/frontend/controllers/AccountController.php @@ -43,6 +43,7 @@ class AccountController extends Controller if ($model->load(Yii::$app->request->post()) && $model->writeToSession()) { Yii::$app->session->setFlash('success', Yii::t('frontend/ticket', 'Default account is set!') ); + return $this->redirect(['product/sale']); } return $this->render('select', [ 'model' => $model, diff --git a/frontend/controllers/ProductController.php b/frontend/controllers/ProductController.php index 77299a0..19942ea 100644 --- a/frontend/controllers/ProductController.php +++ b/frontend/controllers/ProductController.php @@ -141,8 +141,7 @@ class ProductController extends Controller \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; $user = User::findOne(Yii::$app->user->id ); - - UserSoldItem::deleteAll(['id_user' => Yii::$app->user->id]); + UserSoldItem::payout($user); $userTransfers = Transfer::modelsToArray( Transfer::readUserSoldTransfers($user) ); $result['transfers'] = $userTransfers; diff --git a/frontend/controllers/SiteController.php b/frontend/controllers/SiteController.php index cf691ae..66882c3 100644 --- a/frontend/controllers/SiteController.php +++ b/frontend/controllers/SiteController.php @@ -88,11 +88,10 @@ class SiteController extends Controller $model = new LoginForm(); if ($model->load(Yii::$app->request->post()) && $model->login()) { - return $this->goBack(); +// return $this->goBack(); + return $this->redirect(['account/select']); } else { - return $this->render('login', [ - 'model' => $model, - ]); + return $this->render('login', ['model' => $model,]); } } diff --git a/frontend/controllers/TicketController.php b/frontend/controllers/TicketController.php index 890af5e..0e72397 100644 --- a/frontend/controllers/TicketController.php +++ b/frontend/controllers/TicketController.php @@ -16,11 +16,14 @@ use common\models\Account; use yii\base\Object; use common\models\Transfer; use common\models\User; +use common\models\ShoppingCart; +use common\models\UserSoldItem; +use frontend\components\FrontendController; /** * TicketController implements the CRUD actions for Ticket model. */ -class TicketController extends Controller +class TicketController extends FrontendController { public function behaviors() { @@ -52,9 +55,7 @@ class TicketController extends Controller */ public function actionIndex($number = null) { - $receptionForm = new ReceptionForm(); - $receptionForm->number = $number; - $receptionForm->readCard(); + $receptionForm = $this->mkReceptionForm($number); if ( !isset($receptionForm->card ) ){ @@ -79,14 +80,19 @@ class TicketController extends Controller public function actionCreate($number = null) { - $receptionForm = new ReceptionForm(); - $receptionForm->number = $number; - $receptionForm->readCard(); + $receptionForm =$this->mkReceptionForm($number); if ( !isset($receptionForm->card ) ){ throw new NotFoundHttpException( Yii::t('frontend/ticket', 'The requested card does not exist.')); } + if ( isset($_POST['payout_customer_cart']) && $this->payoutCustomerCart($receptionForm) ){ + return $this->redirect(['customer/reception' ]); + }else if ( isset($_POST['payout_user_cart']) && $this->payoutUserCart($receptionForm)){ + return $this->redirect(['customer/reception' ]); + } + + $model = new TicketCreate(); $discounts = Discount::read(); @@ -97,7 +103,7 @@ class TicketController extends Controller $user = User::findOne( [ 'id' => Yii::$app->user->id ] ); - + $model->customer = $receptionForm->customer; $model->id_user = \Yii::$app->user->id; $model->status = Ticket::STATUS_ACTIVE; $model->usage_count = 0; @@ -107,9 +113,10 @@ class TicketController extends Controller if ($model->load(Yii::$app->request->post()) && $model->save()) { Yii::$app->session->setFlash('success', Yii::t('frontend/ticket', 'Ticket added to customer') ); return $this->redirect(['product/sale', 'number' => $receptionForm->card->number]); - } else { + } - $userTransfers = Transfer::modelsToArray( Transfer::readUserSoldTransfers($user) ); + $model->userCart = Transfer::modelsToArray( Transfer::readUserSoldTransfers($user) ); + $model->customerCart = Transfer::modelsToArray( Transfer::readCustomerCart( $receptionForm->customer ) ); return $this->render('create', [ 'model' => $model, @@ -117,71 +124,7 @@ class TicketController extends Controller 'ticketTypes' => $ticketTypes, 'accounts' => $accounts, 'receptionForm' => $receptionForm, - 'userTransfers' => $userTransfers, ]); - } } - - /** - * Finds the Ticket model based on its primary key value. - * If the model is not found, a 404 HTTP exception will be thrown. - * @param integer $id - * @return Ticket the loaded model - * @throws NotFoundHttpException if the model cannot be found - */ - protected function findModel($id) - { - if (($model = Ticket::findOne($id)) !== null) { - return $model; - } else { - throw new NotFoundHttpException('The requested page does not exist.'); - } - } - /** - * Displays a single Ticket model. - * @param integer $id - * @return mixed - */ - /* - public function actionView($id) - { - return $this->render('view', [ - 'model' => $this->findModel($id), - ]); - } - */ - /** - * Deletes an existing Ticket model. - * If deletion is successful, the browser will be redirected to the 'index' page. - * @param integer $id - * @return mixed - */ - /* - public function actionDelete($id) - { - $this->findModel($id)->delete(); - - return $this->redirect(['index']); - } - */ - /** - * Updates an existing Ticket model. - * If update is successful, the browser will be redirected to the 'view' page. - * @param integer $id - * @return mixed - */ - /* - public function actionUpdate($id) - { - $model = $this->findModel($id); - - if ($model->load(Yii::$app->request->post()) && $model->save()) { - return $this->redirect(['view', 'id' => $model->id_ticket]); - } else { - return $this->render('update', [ - 'model' => $model, - ]); - } - } -*/ + } diff --git a/frontend/controllers/TransferController.php b/frontend/controllers/TransferController.php index 03bebad..11ae4f6 100644 --- a/frontend/controllers/TransferController.php +++ b/frontend/controllers/TransferController.php @@ -9,6 +9,7 @@ use yii\web\Controller; use yii\web\NotFoundHttpException; use yii\filters\VerbFilter; use frontend\models\TransferMoneyMovementSearch; +use common\models\Account; /** * TransferController implements the CRUD actions for Transfer model. @@ -41,6 +42,27 @@ class TransferController extends Controller 'dataProvider' => $dataProvider, ]); } + /** + * Lists all Transfer models. + * @return mixed + */ + public function actionIndex() + { + $searchModel = new TransferSearch(); + $searchModel->accounts = Account::read(); + $searchModel->load(Yii::$app->request->queryParams); + + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); + + $searchModel->totalsTransfers(Yii::$app->request->queryParams); + + + + return $this->render('index', [ + 'searchModel' => $searchModel, + 'dataProvider' => $dataProvider, + ]); + } /** * Displays a single Transfer model. diff --git a/frontend/models/AccountSelect.php b/frontend/models/AccountSelect.php index 49ada27..9be8e0a 100644 --- a/frontend/models/AccountSelect.php +++ b/frontend/models/AccountSelect.php @@ -38,5 +38,13 @@ class AccountSelect extends Model Account::writeDefault($account); return true; } + + /* */ + + public function attributeLabels(){ + return [ + 'id_account' =>Yii::t('frontend/account', 'Account') + ]; + } } diff --git a/frontend/models/MoneyMovementSearch.php b/frontend/models/MoneyMovementSearch.php index e51e175..45896ea 100644 --- a/frontend/models/MoneyMovementSearch.php +++ b/frontend/models/MoneyMovementSearch.php @@ -6,6 +6,7 @@ use Yii; use yii\base\Model; use yii\data\ActiveDataProvider; use common\models\MoneyMovement; +use yii\helpers\ArrayHelper; /** * MoneyMovementSearch represents the model behind the search form about `common\models\MoneyMovement`. @@ -69,4 +70,13 @@ class MoneyMovementSearch extends MoneyMovement return $dataProvider; } + + public function attributeLabels( ) { + return ArrayHelper::merge(parent::attributeLabels(), + [ + 'start' => Yii::t('frontend/money-movement', 'Start'), + 'end' => Yii::t('frontend/money-movement', 'End'), + ] + ); + } } diff --git a/frontend/models/ProductSaleForm.php b/frontend/models/ProductSaleForm.php index a71254f..4516c38 100644 --- a/frontend/models/ProductSaleForm.php +++ b/frontend/models/ProductSaleForm.php @@ -184,14 +184,16 @@ class ProductSaleForm extends Model } protected function saveTransfer(){ + $customer = null; $status = Transfer::STATUS_PAID; if ( $this->isAppendToUserCart() ){ $status = Transfer::STATUS_NOT_PAID; }else if ( $this->isAppendToCustomerCart() ){ $status = Transfer::STATUS_NOT_PAID; + $customer = $this->customer; } - $this->transfer = Transfer::createProductTransfer($this->sale,$this->account, $this->discount, $this->currency, $this->count, $this->product,$status); + $this->transfer = Transfer::createProductTransfer($this->sale,$this->account, $this->discount, $this->currency, $this->count, $this->product,$status,$customer); if ( isset($this->comment)){ $this->transfer->comment = $this->comment; } @@ -229,8 +231,6 @@ class ProductSaleForm extends Model } public function appendToCustomerCart(){ -// print_r("cart: ".$this->cart ); -// print_r("customer:: ".$this->customer ); if ( $this->isAppendToCustomerCart() && isset($this->customer) ){ $item = new ShoppingCart(); $item->id_customer = $this->customer->id_customer; diff --git a/frontend/models/TicketCreate.php b/frontend/models/TicketCreate.php index 97be293..2824943 100644 --- a/frontend/models/TicketCreate.php +++ b/frontend/models/TicketCreate.php @@ -7,8 +7,16 @@ use common\models\Account; use common\models\Discount; use common\models\Transfer; use common\models\UserSoldItem; +use common\models\ShoppingCart; use yii\base\Object; +/** + * @property $cart string name of cart, into we put the ticket + * @property $userCart common\models\Transfer[] items in user cart + * @property $customerCart common\models\Transfer[] items in customer cart + * @property $customer common\models\Customer selected customer + * + * */ class TicketCreate extends Ticket{ public $_currency; @@ -16,6 +24,12 @@ class TicketCreate extends Ticket{ public $_discount; public $_transfer; + + public $customer; + public $userCart; + public $customerCart; + + public $cart; public function rules() @@ -88,14 +102,15 @@ class TicketCreate extends Ticket{ public function afterSave($insert, $changedAttributes){ $this->addTransfer(); - $this->addToCart(); + $this->appendToUserCart(); + $this->appendToCustomerCart(); } protected function addTransfer(){ $transfer = Transfer::createTicketTransfer($this->_account, $this->_discount, null, 1, $this); - $transfer->status = Transfer::STATUS_PAID; +// $transfer->status = Transfer::STATUS_PAID; if ( isset($this->comment)){ $transfer->comment = $this->comment; } @@ -114,12 +129,41 @@ class TicketCreate extends Ticket{ } - public function isAddToCart(){ - $result = false; - if ( isset( $this->cart ) && $this->cart == 'add' ){ - $result = true; - } - return $result; - } + public function isAppendToUserCart(){ + $result = false; + if ( isset( $this->cart ) && $this->cart == 'user' ){ + $result = true; + } + return $result; + } + + public function isAppendToCustomerCart(){ + $result = false; + if ( isset( $this->cart ) && $this->cart == 'customer' ){ + $result = true; + } + return $result; + } + + + public function appendToUserCart(){ + if ( $this->isAppendToUserCart() ){ + $item = new UserSoldItem(); + $item->id_transfer = $this->_transfer->id_transfer; + $item->id_user = \Yii::$app->user->id; + $item->save(false); + } + } + + public function appendToCustomerCart(){ + if ( $this->isAppendToCustomerCart() && isset($this->customer) ){ + $item = new ShoppingCart(); + $item->id_customer = $this->customer->id_customer; + $item->id_transfer = $this->_transfer->id_transfer; + $item->save(false); + } + } + + } \ No newline at end of file diff --git a/frontend/models/TransferSearch.php b/frontend/models/TransferSearch.php index e920478..4080b91 100644 --- a/frontend/models/TransferSearch.php +++ b/frontend/models/TransferSearch.php @@ -6,31 +6,56 @@ use Yii; use yii\base\Model; use yii\data\ActiveDataProvider; use common\models\Transfer; +use yii\base\Object; +use yii\db\Query; +use yii\db\Expression; +use common\models\Account; +use yii\helpers\ArrayHelper; /** * TransferSearch represents the model behind the search form about `common\models\Transfer`. */ class TransferSearch extends Transfer { + + public $start; + public $end; + + public $timestampStart; + public $timestampEnd; + + public $totalsCreatedAt = ['total' => 0, 'accounts' =>[] ]; + public $totalsCreatedAtNotPaid= ['total' => 0, 'accounts' =>[]]; + public $totalsCreatedAtPaid= ['total' => 0, 'accounts' =>[]]; + public $totalsPaidAt= ['total' => 0, 'accounts' =>[]]; + + + public $accounts; + + public $types; + /** * @inheritdoc */ public function rules() { return [ - [['id_transfer', 'id_discount', 'id_currency', 'id_object', 'status', 'type', 'item_price', 'count', 'money', 'money_currency', 'rate', 'id_user'], 'integer'], - [['comment', 'created_at', 'updated_at'], 'safe'], +// [[ 'start', ], 'date' , 'timestampAttribute' => 'timestampStart' ,'timestampAttributeFormat' => 'yyyy-MM-dd' ], +// [[ 'end' , ], 'date' , 'timestampAttribute' => 'timestampEnd' ,'timestampAttributeFormat' => 'yyyy-MM-dd' ], + + [[ 'start', ], 'date', 'format' =>Yii::$app->formatter->datetimeFormat , 'timestampAttribute' => 'timestampStart' ,'timestampAttributeFormat' => 'yyyy-MM-dd HH:mm' ,'timeZone' => 'UTC' ], + [[ 'end' , ], 'date' ,'format' =>Yii::$app->formatter->datetimeFormat , 'timestampAttribute' => 'timestampEnd' ,'timestampAttributeFormat' => 'yyyy-MM-dd HH:mm' ,'timeZone' => 'UTC' ], + + [ [ 'id_account' ] , 'integer'], + ['types', 'each', 'rule' => ['integer']], +// [ [ 'types' ], function ($attribute, $params) { +// if (!is_array($this->$attribute)) { +// $this->addError($attribute, 'Invalid array'); +// } +// }], ]; } - /** - * @inheritdoc - */ - public function scenarios() - { - // bypass scenarios() implementation in the parent class - return Model::scenarios(); - } /** * Creates data provider instance with search query applied @@ -56,24 +81,208 @@ class TransferSearch extends Transfer } $query->andFilterWhere([ - 'id_transfer' => $this->id_transfer, - 'id_discount' => $this->id_discount, - 'id_currency' => $this->id_currency, - 'id_object' => $this->id_object, - 'status' => $this->status, + 'id_account' => $this->id_account, 'type' => $this->type, - 'item_price' => $this->item_price, - 'count' => $this->count, - 'money' => $this->money, - 'money_currency' => $this->money_currency, - 'rate' => $this->rate, - 'id_user' => $this->id_user, - 'created_at' => $this->created_at, - 'updated_at' => $this->updated_at, ]); + + $query->andFilterWhere(['in' ,'type', $this->types]); - $query->andFilterWhere(['like', 'comment', $this->comment]); - + $created_condition = ['and',[ '>=', 'transfer.created_at', $this->timestampStart ] ,[ '<', 'transfer.created_at', $this->timestampEnd ] ]; + $paid_condition = ['and',[ '>=', 'transfer.paid_at', $this->timestampStart ] ,[ '<', 'transfer.paid_at', $this->timestampEnd ] ]; + + $query->andFilterWhere(['or' , $created_condition , $paid_condition]); + return $dataProvider; } + + + protected function mkTotalQuery($mode){ + + $query = new Query(); + + $query->addSelect( [ + new Expression( 'transfer.id_account as account'), + new Expression( ' COALESCE(sum( ( case when direction = '.Transfer::DIRECTION_OUT.' then -1 else 1 end )* transfer.money ),0) as money' ) + + ]); + $query->from('transfer'); + + $query->andFilterWhere([ + 'id_account' => $this->id_account, + 'type' => $this->type, + ]); + + $query->andWhere(['id_user' => Yii::$app->user->id]); + + $query->andFilterWhere(['in' ,'type', $this->types]); + + + if ( $mode == 'created_at'){ + $query->andFilterWhere([ '>=', 'transfer.created_at' , $this->timestampStart ] ); + $query->andFilterWhere([ '<' , 'transfer.created_at' , $this->timestampEnd ] ); + }else if ( $mode == 'paid_at'){ + $query->andFilterWhere([ '>=', 'transfer.paid_at' , $this->timestampStart ] ); + $query->andFilterWhere([ '<' , 'transfer.paid_at' , $this->timestampEnd ] ); + }else if ( $mode == 'created_at_not_paid'){ + $query->andFilterWhere([ "transfer.status" => Transfer::STATUS_NOT_PAID ] ); + $query->andFilterWhere([ '>=', 'transfer.created_at' , $this->timestampStart ] ); + $query->andFilterWhere([ '<' , 'transfer.created_at' , $this->timestampEnd ] ); + }else if ( $mode == 'created_at_paid'){ + $query->andFilterWhere([ "transfer.status" => Transfer::STATUS_PAID ] ); + $query->andFilterWhere([ '>=', 'transfer.created_at' , $this->timestampStart ] ); + $query->andFilterWhere([ '<' , 'transfer.created_at' , $this->timestampEnd ] ); + } + + $query->groupBy('transfer.id_account'); + + return $query; + + + } + + protected function mkTransferTotalsWithZeroValue( ){ + $result = []; + + foreach ( $this->accounts as $a ){ + $accountTotal = [ + 'id_account' => $a->id_account, + 'label' => $a->name, + 'money' => 0 + ]; + + $result[] = $accountTotal; + } + return $result; + } + + + + protected function mkTotalsResult($queryResult,$accountMap){ + + $totals = []; + $totals['total'] = 0; + + $totals['accounts'] = []; + + foreach ($queryResult as $item){ + $account = ""; + if ( array_key_exists($item['account'], $accountMap)){ + $account = $accountMap[$item['account']]; + } + + $accountTotal = [ + 'id_account' => $item['account'], + 'label' => $account, + 'money' => $item['money'] + ]; + $totals['accounts'][] = $accountTotal; + $totals['total'] += $item['money']; + } + return $totals; + } + + protected function findByAccountInQueryResult($queryResult, $account){ + $result = null; + foreach ($queryResult as $item){ + if( $item['account'] == $account->id_account ){ + $result = $item; + } + } + return $result; + } + + protected function mkTotalsResultWithAllAvailableAccount($queryResult,$accountMap){ + + $totals = []; + $totals['total'] = 0; + + $totals['accounts'] = []; + + foreach ($this->accounts as $account){ +// echo 'account="'. $this->id_account .'"
'; + if ( isset($this->id_account) && is_numeric($this->id_account) && $this->id_account != $account->id_account ){ + continue ; + } + $accountTotal = [ + 'id_account' => $account->id_account, + 'label' => $account->name, + 'money' => 0, + ]; + + $item = $this->findByAccountInQueryResult($queryResult, $account); + + if ( isset($item)){ + $accountTotal['money'] = $item['money']; + } + + $totals['accounts'][] = $accountTotal; + $totals['total'] += $accountTotal['money']; + } + return $totals; + } + + + public function mkPaidAtTotals($accountMap){ + $query = $this->mkTotalQuery('paid_at'); + $command = $query->createCommand(); + $result = $command->queryAll(); + +// $paidAtTotals = $this->mkTotalsResult($result, $accountMap); + $paidAtTotals = $this->mkTotalsResultWithAllAvailableAccount($result, $accountMap); + + return $paidAtTotals; + } + + public function mkCreatedAtTotals($accountMap){ + $query = $this->mkTotalQuery('created_at'); + $command = $query->createCommand(); + $result = $command->queryAll(); + + $createdAtTotals = $this->mkTotalsResultWithAllAvailableAccount($result, $accountMap); + + return $createdAtTotals; + } + + public function mkCreatedAtNotPaidTotals($accountMap){ + $query = $this->mkTotalQuery('created_at_not_paid'); + $command = $query->createCommand(); + $result = $command->queryAll(); + + $createdAtTotals = $this->mkTotalsResultWithAllAvailableAccount($result, $accountMap); + + return $createdAtTotals; + } + + public function mkCreatedAtPaidTotals($accountMap){ + $query = $this->mkTotalQuery('created_at_paid'); + $command = $query->createCommand(); + $result = $command->queryAll(); + + $createdAtTotals = $this->mkTotalsResultWithAllAvailableAccount($result, $accountMap); + + return $createdAtTotals; + } + + + public function totalsTransfers($params){ + $accountTotals = []; + $fullTotal = [ + 'label' => Yii::t('common/transfer', 'Total'), + 'money' => 0 + ]; + + if ( $this->hasErrors() ){ + return; + } + + $accounts = Account::find()->orderBy("name asc")->all(); + $accountMap = ArrayHelper::map( $accounts ,'id_account','name' ); + + $this->totalsCreatedAt = $this->mkCreatedAtTotals($accountMap); + $this->totalsPaidAt = $this->mkPaidAtTotals($accountMap); + $this->totalsCreatedAtPaid = $this->mkCreatedAtPaidTotals($accountMap); + $this->totalsCreatedAtNotPaid = $this->mkCreatedAtNotPaidTotals($accountMap); + + } + } diff --git a/frontend/views/account/select.php b/frontend/views/account/select.php index 33ac305..0bf61f4 100644 --- a/frontend/views/account/select.php +++ b/frontend/views/account/select.php @@ -9,8 +9,9 @@ use frontend\components\HtmlHelper; /* @var $form yii\widgets\ActiveForm */ ?> +

- + field($model, 'id_account')->dropDownList(HtmlHelper::mkAccountOptions($accounts)) ?> diff --git a/frontend/views/money-movement/index.php b/frontend/views/money-movement/index.php index 3063fe2..ef198b8 100644 --- a/frontend/views/money-movement/index.php +++ b/frontend/views/money-movement/index.php @@ -26,7 +26,6 @@ $this->params['breadcrumbs'][] = $this->title; 'accountName', 'userName', 'name', - 'type', 'money', 'created_at:datetime', diff --git a/frontend/views/product/_customer_cart.php b/frontend/views/product/_customer_cart.php index 3ccf07d..551d3d0 100644 --- a/frontend/views/product/_customer_cart.php +++ b/frontend/views/product/_customer_cart.php @@ -33,4 +33,8 @@ use yii\bootstrap\Html;
- 'btn_pay_customer_cart', 'class' => 'btn btn-primary' ]) ?> \ No newline at end of file +
+
+ 'btn_pay_customer_cart', 'class' => 'btn btn-primary btn-block' , 'name' => 'payout_customer_cart']) ?> +
+
\ No newline at end of file diff --git a/frontend/views/product/_sale_form.php b/frontend/views/product/_sale_form.php index 2e3069d..ad3bcf5 100644 --- a/frontend/views/product/_sale_form.php +++ b/frontend/views/product/_sale_form.php @@ -98,13 +98,10 @@ $discountOptions = mkOptions( ArrayHelper::map($discounts, 'id_discount', 'name'
-
- 'btn btn-success btn-block', 'id' => 'btn_sell'] );?> -
-
+
'btn btn-success btn-block', 'id' => 'btn_sell_append'] );?>
-
+
isCardWithCustomer() ){ echo Html::a(Yii::t("frontend/product","Write up"),null,['class' => 'btn btn-success btn-block', 'id' => 'btn_add_to_customer_cart'] ); diff --git a/frontend/views/product/_user_cart.php b/frontend/views/product/_user_cart.php index 1f4a1be..62416d5 100644 --- a/frontend/views/product/_user_cart.php +++ b/frontend/views/product/_user_cart.php @@ -1,5 +1,6 @@ @@ -33,8 +34,10 @@ use yii\bootstrap\Html;
-
-
- 'btn_pay_user_cart', 'class' => 'btn btn-primary btn-block' ]) ?> +
+
+ + 'btn_pay_user_cart', 'class' => 'btn btn-primary btn-block' , 'name' => 'payout_user_cart']) ?> +
\ No newline at end of file diff --git a/frontend/views/product/create.php b/frontend/views/product/create.php index d24804f..114670f 100644 --- a/frontend/views/product/create.php +++ b/frontend/views/product/create.php @@ -16,6 +16,7 @@ $this->params['breadcrumbs'][] = $this->title; render('_form', [ 'model' => $model, + 'receptionForm' => $receptionForm, ]) ?>
diff --git a/frontend/views/product/sale.php b/frontend/views/product/sale.php index d4347a4..67ebf81 100644 --- a/frontend/views/product/sale.php +++ b/frontend/views/product/sale.php @@ -33,6 +33,9 @@ $options['id_account'] = Account::readDefault(); $this->registerJs ( 'new ProductSell( '. json_encode($options).');' ); +$this->params['breadcrumbs'][] = Yii::t('frontend/product', 'Products') ; +$this->params['breadcrumbs'][] = Yii::t('frontend/product', 'Sale'); + ?> +

title) ?>

- render('_search', ['model' => $searchModel]); ?> + render('_search', ['model' => $searchModel]); ?> + render('_index_stat', ['searchModel' => $searchModel]); ?> -

- 'btn btn-success']) ?> -

- - $dataProvider, - 'filterModel' => $searchModel, - 'columns' => [ - ['class' => 'yii\grid\SerialColumn'], - - 'id_transfer', - 'id_discount', - 'id_currency', - 'id_object', - 'status', - // 'type', - // 'item_price', - // 'count', - // 'money', - // 'money_currency', - // 'rate', - // 'id_user', - // 'comment', - // 'created_at', - // 'updated_at', - - ['class' => 'yii\grid\ActionColumn'], - ], - ]); ?> + + + + + $dataProvider, + 'itemView' => '_view' , + 'itemOptions' => ['class' => 'item-transfer'] + ] ) + ?>
diff --git a/frontend/views/transfer/view.php b/frontend/views/transfer/view.php index 9fff603..bb2225b 100644 --- a/frontend/views/transfer/view.php +++ b/frontend/views/transfer/view.php @@ -14,35 +14,43 @@ $this->params['breadcrumbs'][] = $this->title;

title) ?>

-

- $model->id_transfer], ['class' => 'btn btn-primary']) ?> - $model->id_transfer], [ - 'class' => 'btn btn-danger', - 'data' => [ - 'confirm' => Yii::t('frontend/transfer', 'Are you sure you want to delete this item?'), - 'method' => 'post', - ], - ]) ?> -

- $model, 'attributes' => [ 'id_transfer', - 'id_discount', - 'id_currency', - 'id_object', + [ + 'attribute' => 'id_discount', + 'value' => Html::getAttributeValue($model, 'discountName') + + ], + [ + 'attribute' => 'type', + 'value' => $model->getTransferTypeName(), + 'label' => 'Típus' + + ], + [ + 'attribute' => 'id_object', + 'value' => $model->getObjectName(), + 'label' => 'Megnevezés' + + ], 'status', 'type', 'item_price', 'count', 'money', - 'money_currency', - 'rate', - 'id_user', +// 'money_currency', +// 'rate', + [ + 'attribute' => 'id_user', + 'value' => $model->getUserName(), +// 'label' => 'Megnevezés' + + ], + 'created_at:datetime', + 'paid_at:datetime', 'comment', - 'created_at', - 'updated_at', ], ]) ?> diff --git a/frontend/web/js/product.sell.js b/frontend/web/js/product.sell.js index 157ea1d..0fb5a37 100644 --- a/frontend/web/js/product.sell.js +++ b/frontend/web/js/product.sell.js @@ -13,11 +13,11 @@ function ProductSell(o){ selector_user_cart: '.user-cart', selector_btn_pay_customer_cart: '#btn_pay_customer_cart', selector_btn_pay_user_cart: '#btn_pay_user_cart', + /**mark list paid url*/ url_pay_customer_card: '-', + url_pay_user_cart: '', /** ajax url for lookup service*/ lookup_product_url: '', - /**mark list paid url*/ - url_pay_user_cart: '', /**the id of form*/ selector_form: '#product_form', /**form contains error text*/ @@ -289,7 +289,8 @@ function ProductSell(o){ table.find('.product-barcode').html(product.barcode); table.find('.product-stock').html(product.stock); $('#productsaleform-id_product').val(product.id_product); - $('#productsaleform-id_account').val(product.id_account); + if ( app.defaults.id_account == null) + $('#productsaleform-id_account').val(product.id_account); } diff --git a/frontend/web/js/ticket.sell.js b/frontend/web/js/ticket.sell.js index 0790e6b..456ea04 100644 --- a/frontend/web/js/ticket.sell.js +++ b/frontend/web/js/ticket.sell.js @@ -35,7 +35,16 @@ function TicketSell(o){ price: null, clear_cart_url: '', cart_paid_message: 'Tételek fizetve', - transfer_list: [], + user_cart: [], + customer_cart: [], + /**selector for customer cart container*/ + selector_customer_cart: '.customer-cart', + selector_user_cart: '.user-cart', + selector_btn_pay_customer_cart: '#btn_pay_customer_cart', + selector_btn_pay_user_cart: '#btn_pay_user_cart', + /**mark list paid url*/ + url_pay_customer_card: '-', + url_pay_user_cart: '', }; @@ -45,8 +54,10 @@ function TicketSell(o){ $.extend(app.defaults, o ); addBehaviourTypeChangedListener(); useDefaults(); - createUserSoldItemsTable(); - addBehaviourBtnCartPaid(); + createCarts(); + addPayoutButtons(); + addSellButtons(); +// addBehaviourBtnCartPaid(); } function useDefaults(){ @@ -56,33 +67,100 @@ function TicketSell(o){ } } - function createUserSoldItemsTable(){ - $('.transfer-list-container').transferList({ - 'transfers' : app.defaults.transfer_list + + + //////////////////////////////////////// + // carts + //////////////////////////////////////// + + /** + * payout out user or customer cart + * */ + function addPayoutButtons(){ + addBehaviourPayoutUserCart(); + addBehaviourPayoutCustomerCart(); + } + + /** + * display user and customer cart on page load + * */ + function createCarts(){ + createUserCartTable(); + createCustomerCartTable(); + } + + function createUserCartTable(){ + $(app.defaults.selector_user_cart).transferList({ + 'transfers' : app.defaults.user_cart + }); + } + function createCustomerCartTable(){ + $(app.defaults.selector_customer_cart).transferList({ + 'transfers' : app.defaults.customer_cart }); } - function refreshCart(){ - $('.transfer-list-container').transferList('option','transfers' , app.defaults.sold_items ); + function addSellButtons(){ + addBehaviourBtnSellAndAppendToUserCart(); + addBehaviourBtnAddToCustomerCart(); } - function addBehaviourBtnCartPaid( ){ - $('#btn_paid').on('click',function(){ - - $.ajax({ - url: app.defaults.clear_cart_url, - type: 'post', - data: {}, - success: function (response) { - if ( response.code == 'success'){ - app.defaults.sold_items= response.transfers; - refreshCart(); - $.notify(app.defaults.cart_paid_message, { 'type' : 'success' }); - } - } - } - ); - }); + function addBehaviourBtnSellAndAppendToUserCart(){ + $('#btn_add_to_user_cart').on('click',submitAddTicketToUserCart); + } + + function addBehaviourBtnAddToCustomerCart(){ + $('#btn_add_to_customer_cart').on('click',submitAddTicketToCustomerCart); + } + + function submitAddTicketToUserCart(){ + $('#ticketcreate-cart').val('user'); + $('#ticket_form').submit(); + } + + function submitAddTicketToCustomerCart(){ + $('#ticketcreate-cart').val('customer'); + $('#ticket_form').submit(); + } + + + function addBehaviourPayoutUserCart( ){ +// $( app.defaults.selector_btn_pay_user_cart ).on('click',function(){ +// +// $.ajax({ +// url: app.defaults.url_pay_user_cart, +// type: 'post', +// data: {}, +// success: function (response) { +// if ( response.code == 'success'){ +// app.defaults.user_cart = response.transfers; +// refreshUserCart(); +// $.notify(app.defaults.message_paid, { 'type' : 'success' }); +// } +// } +// } +// ); +// }); + } + function addBehaviourPayoutCustomerCart( ){ +// $( app.defaults.selector_btn_pay_customer_cart ).on('click',function(){ +// $.ajax({ +// url: app.defaults.url_pay_customer_card, +// type: 'post', +// data: {}, +// success: function (response) { +// if ( response.code == 'success'){ +// app.defaults.customer_cart = response.customer_cart; +// refreshCustomerCart(); +// } +// $.notify(response.message, { 'type' : response.code }); +// }, +// error: function(){ +// alert('Hiba történt'); +// } +// } +// ); +// }); }