add hidden account support add delete/payout buttons to carts add backend product sales with pdf export add frontend product sales with pdf export add frontend ticket sales with pdf export
114 lines
4.1 KiB
PHP
114 lines
4.1 KiB
PHP
<?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 backend\models\AccountSearch;
|
|
|
|
class FrontendMenuStructure{
|
|
|
|
public $menuItems;
|
|
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 = [];
|
|
|
|
$this->start = \Yii::$app->formatter->asDatetime( strtotime('today') );
|
|
$this->tomorrow = Yii::$app->formatter->asDatetime( strtotime('tomorrow') );
|
|
$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);
|
|
|
|
|
|
|
|
if ( $this->isLogged() ){
|
|
$lastAccountState = AccountState::find()->andWhere(['id_user' => Yii::$app->user->id])->andWhere(['type' => AccountState::TYPE_OPEN ])->orderBy(['account_state.created_at' => SORT_DESC])->limit(1)->one();
|
|
if ( isset($lastAccountState) ){
|
|
$this->start = Yii::$app->formatter->asDatetime(strtotime( $lastAccountState->created_at . ' UTC' ));
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function can($authItem){
|
|
$result = false;
|
|
if (\Yii::$app->user->can($authItem)) {
|
|
$result = true;
|
|
}
|
|
return $result;
|
|
}
|
|
|
|
|
|
protected function isLogged(){
|
|
return !Yii::$app->user->isGuest;
|
|
}
|
|
|
|
|
|
protected function addRecepcio(){
|
|
if ( $this->isLogged() ){
|
|
|
|
$isadmin =Yii::$app->user->can('admin') ||Yii::$app->user->can('employee');
|
|
|
|
$this->menuItems[] = ['label' => Yii::t('frontend/customer','Reception'), 'url' => ['/customer/reception'] ];
|
|
|
|
$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' => 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','Sales detailed'), 'url' => [ '/transfer/sale', '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 ] ],
|
|
];
|
|
|
|
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/collection','Collections'), 'url' => ['/collection/index' , 'CollectionSearch[start]' =>$this->start,'CollectionSearch[end]' => $this->tomorrow ] ];
|
|
|
|
$this->menuItems[] = ['label' => Yii::t('frontend/account', 'Account'),
|
|
'items' => $items
|
|
|
|
|
|
|
|
|
|
];
|
|
}
|
|
}
|
|
|
|
|
|
protected function addLoginMainMenu(){
|
|
if (Yii::$app->user->isGuest) {
|
|
$mainMenuItem= ['label' => Yii::t('frontend/site','Login'), 'url' => ['/site/login']];
|
|
} else {
|
|
$mainMenuItem= [
|
|
'label' => Yii::t('frontend/transfer','Logout'). '(' . Yii::$app->user->identity->username . ')',
|
|
'url' => ['/site/logout'],
|
|
'linkOptions' => ['data-method' => 'post']
|
|
];
|
|
}
|
|
$this->menuItems[] = $mainMenuItem;
|
|
}
|
|
|
|
|
|
public function run(){
|
|
$this->addRecepcio();
|
|
$this->addLoginMainMenu();
|
|
return $this->menuItems;
|
|
}
|
|
|
|
|
|
} |