add frontend changes
This commit is contained in:
62
frontend/components/FrontendController.php
Normal file
62
frontend/components/FrontendController.php
Normal file
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
namespace frontend\components;
|
||||
|
||||
use Yii;
|
||||
use common\models\Order;
|
||||
use yii\helpers\Html;
|
||||
use common\models\MoneyMovement;
|
||||
use yii\db\Query;
|
||||
use common\models\AccountState;
|
||||
use yii\web\Controller;
|
||||
use yii\base\Object;
|
||||
use frontend\models\ReceptionForm;
|
||||
use common\models\UserSoldItem;
|
||||
use common\models\ShoppingCart;
|
||||
use common\models\Transfer;
|
||||
use common\models\User;
|
||||
|
||||
class FrontendController extends Controller{
|
||||
|
||||
|
||||
|
||||
protected function mkReceptionForm($number){
|
||||
$receptionForm = new ReceptionForm();
|
||||
$receptionForm->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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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<br>abcd<br>abcd<br>abcd<br>abcd<br>abcd<br>abcd<br>abcd<br>abcd<br>abcd<br>abcd<br>abcd<br>abcd<br>');
|
||||
|
||||
$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 ] ],
|
||||
]
|
||||
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user