Add transfer and account_state today view to reception
This commit is contained in:
parent
d46e717b53
commit
8b6b506d17
@ -12,6 +12,34 @@ use yii\i18n\Formatter;
|
|||||||
|
|
||||||
class DateUtil
|
class DateUtil
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Get UTC today @00:00:00 .
|
||||||
|
* Helper method to generate date for mysql
|
||||||
|
*
|
||||||
|
* @return \DateTime
|
||||||
|
*/
|
||||||
|
public static function todayStart( ){
|
||||||
|
$d2 = new \DateTime();
|
||||||
|
$d2->setTimezone( new \DateTimeZone( "UTC" ) );
|
||||||
|
$d2->setTime(0, 0, 0);
|
||||||
|
return $d2;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get UTC t @00:00:00 .
|
||||||
|
* Helper method to generate date for mysql
|
||||||
|
*
|
||||||
|
* @return \DateTime
|
||||||
|
*/
|
||||||
|
public static function tomorrowStart( ){
|
||||||
|
$d2 = new \DateTime();
|
||||||
|
$d2->add(new \DateInterval('P1D'));
|
||||||
|
$d2->setTimezone( new \DateTimeZone( "UTC" ) );
|
||||||
|
$d2->setTime(0, 0, 0);
|
||||||
|
return $d2;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static function addMonth($timestamp, $monthCount = 1)
|
public static function addMonth($timestamp, $monthCount = 1)
|
||||||
{
|
{
|
||||||
@ -65,4 +93,12 @@ class DateUtil
|
|||||||
return $formatter->asDatetime($dateTimeObject);
|
return $formatter->asDatetime($dateTimeObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function formatDateUtc($dateTimeObject)
|
||||||
|
{
|
||||||
|
$formatter = new Formatter;
|
||||||
|
$formatter->datetimeFormat = 'php:Y-m-d';
|
||||||
|
$formatter->timeZone = 'UTC';
|
||||||
|
return $formatter->asDatetime($dateTimeObject);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -321,6 +321,17 @@ class Helper {
|
|||||||
return \Yii::$app->params ['ticket_create_price_editable'] == true ;
|
return \Yii::$app->params ['ticket_create_price_editable'] == true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function isReceptionTransferListToday(){
|
||||||
|
return \Yii::$app->params['reception_transfer_list_only_today'];
|
||||||
|
}
|
||||||
|
public static function isReceptionAccountStateIndexToday(){
|
||||||
|
return \Yii::$app->params['reception_account_state_index_only_today'];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function isReceptionTransferIndexEnabled(){
|
||||||
|
return !Helper::isReceptionTransferListToday();
|
||||||
|
}
|
||||||
|
|
||||||
public static function getRealUserIp() {
|
public static function getRealUserIp() {
|
||||||
$client = @$_SERVER ['HTTP_CLIENT_IP'];
|
$client = @$_SERVER ['HTTP_CLIENT_IP'];
|
||||||
$forward = @$_SERVER ['HTTP_X_FORWARDED_FOR'];
|
$forward = @$_SERVER ['HTTP_X_FORWARDED_FOR'];
|
||||||
|
|||||||
@ -30,6 +30,9 @@ return [
|
|||||||
* Hány napig láthatják visszamenőleg a recepciósok az adatokat
|
* Hány napig láthatják visszamenőleg a recepciósok az adatokat
|
||||||
* */
|
* */
|
||||||
'reception_visibility_days' => 3,
|
'reception_visibility_days' => 3,
|
||||||
|
'reception_account_state_index_only_today' => false,
|
||||||
|
'reception_transfer_list_only_today' => false,
|
||||||
|
|
||||||
'backend_skin' => 'skin-red', //skin-green
|
'backend_skin' => 'skin-red', //skin-green
|
||||||
/**User cart module on/off*/
|
/**User cart module on/off*/
|
||||||
'user_cart_on' => true,
|
'user_cart_on' => true,
|
||||||
|
|||||||
@ -11,7 +11,8 @@ use backend\models\AccountSearch;
|
|||||||
use common\models\Account;
|
use common\models\Account;
|
||||||
use common\components\Helper;
|
use common\components\Helper;
|
||||||
|
|
||||||
class FrontendMenuStructure{
|
class FrontendMenuStructure
|
||||||
|
{
|
||||||
|
|
||||||
public $menuItems;
|
public $menuItems;
|
||||||
public $start;//start date and time
|
public $start;//start date and time
|
||||||
@ -21,31 +22,31 @@ class FrontendMenuStructure{
|
|||||||
public $tomorrowDate;//tomorrow date
|
public $tomorrowDate;//tomorrow date
|
||||||
public $yesterDay;//yesterday date
|
public $yesterDay;//yesterday date
|
||||||
|
|
||||||
public function __construct(){
|
public function __construct()
|
||||||
|
{
|
||||||
$this->menuItems = [];
|
$this->menuItems = [];
|
||||||
|
|
||||||
$this->yesterDay = \Yii::$app->formatter->asDatetime( strtotime('yesterday UTC') );
|
$this->yesterDay = \Yii::$app->formatter->asDatetime(strtotime('yesterday UTC'));
|
||||||
$this->start = \Yii::$app->formatter->asDatetime( strtotime('today UTC') );
|
$this->start = \Yii::$app->formatter->asDatetime(strtotime('today UTC'));
|
||||||
$this->tomorrow = Yii::$app->formatter->asDatetime( strtotime('tomorrow UTC') );
|
$this->tomorrow = Yii::$app->formatter->asDatetime(strtotime('tomorrow UTC'));
|
||||||
$this->startDate = Yii::$app->formatter->asDate( strtotime('today UTC') );
|
$this->startDate = Yii::$app->formatter->asDate(strtotime('today UTC'));
|
||||||
$this->tomorrowDate = Yii::$app->formatter->asDate( strtotime('tomorrow UTC') );
|
$this->tomorrowDate = Yii::$app->formatter->asDate(strtotime('tomorrow UTC'));
|
||||||
|
|
||||||
Yii::info("Start date is : ". $this->start);
|
Yii::info("Start date is : " . $this->start);
|
||||||
|
|
||||||
|
|
||||||
|
if ($this->isLogged()) {
|
||||||
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();
|
||||||
$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)) {
|
||||||
if ( isset($lastAccountState) ){
|
$this->start = Yii::$app->formatter->asDatetime(strtotime($lastAccountState->created_at . ' UTC'));
|
||||||
$this->start = Yii::$app->formatter->asDatetime(strtotime( $lastAccountState->created_at . ' UTC' ));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected function can($authItem)
|
||||||
protected function can($authItem){
|
{
|
||||||
$result = false;
|
$result = false;
|
||||||
if (\Yii::$app->user->can($authItem)) {
|
if (\Yii::$app->user->can($authItem)) {
|
||||||
$result = true;
|
$result = true;
|
||||||
@ -54,40 +55,49 @@ class FrontendMenuStructure{
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected function isLogged(){
|
protected function isLogged()
|
||||||
|
{
|
||||||
return !Yii::$app->user->isGuest;
|
return !Yii::$app->user->isGuest;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected function addRecepcio(){
|
protected function addRecepcio()
|
||||||
if ( $this->isLogged() ){
|
{
|
||||||
|
if ($this->isLogged()) {
|
||||||
|
|
||||||
$isadmin =Yii::$app->user->can('admin') ||Yii::$app->user->can('employee');
|
$isadmin = Yii::$app->user->can('admin') || Yii::$app->user->can('employee');
|
||||||
|
|
||||||
$this->menuItems[] = ['label' => Yii::t('frontend/customer','Reception'), 'url' => ['/customer/reception'] ];
|
$this->menuItems[] = ['label' => Yii::t('frontend/customer', 'Reception'), 'url' => ['/customer/reception']];
|
||||||
|
|
||||||
$items = [
|
$items = [];
|
||||||
['label' => Yii::t('frontend/account-state','Default account'), 'url' => ['/account/select'] ],
|
|
||||||
['label' => Yii::t('frontend/account-state', 'Account states'), 'url' => ['/account-state/index' ,'AccountstateSearch[id_account]' => Account::readDefault(), 'AccountstateSearch[start]' => $this->yesterDay] ],
|
|
||||||
['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 ] ],
|
$items[] = ['label' => Yii::t('frontend/account-state', 'Default account'), 'url' => ['/account/select']];
|
||||||
|
|
||||||
];
|
|
||||||
|
|
||||||
if ( Helper::isCompanyMovar() ){
|
if ( Helper::isReceptionAccountStateIndexToday() ){
|
||||||
$items[] = ['label' => Yii::t('frontend/transfer','Daily transfers'), 'url' => [ '/transfer/list', 'TransferListSearch[id_account]' => Account::readDefault(), 'TransferListSearch[start]' => $this->start, 'TransferListSearch[end]' => $this->tomorrow ] ];
|
$items[] = ['label' => Yii::t('frontend/account-state', 'Account states'), 'url' => ['/account-state/today' ]];
|
||||||
$items[] = ['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 ] ];
|
}else{
|
||||||
$items[] = ['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 ] ];
|
$items[] = ['label' => Yii::t('frontend/account-state', 'Account states'), 'url' => ['/account-state/index', 'AccountstateSearch[id_account]' => Account::readDefault(), 'AccountstateSearch[start]' => $this->yesterDay]];
|
||||||
}
|
}
|
||||||
|
|
||||||
// if ( $isadmin || Yii::$app->user->can('reception.transfers') ){
|
$items[] = ['label' => Yii::t('frontend/account-state', 'Open account state'), 'url' => ['/account-state/open']];
|
||||||
$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/account-state', 'Close account state'), 'url' => ['/account-state/close']];
|
||||||
//$items[] = ['label' => Yii::t('frontend/collection','Collections'), 'url' => ['/collection/index' , 'CollectionSearch[start]' =>$this->start,'CollectionSearch[end]' => $this->tomorrow ] ];
|
$items[] = ['label' => Yii::t('frontend/money-movement', 'Money movements'), 'url' => ['/money-movement/index', 'MoneyMovementSearch[start]' => $this->start, 'MoneyMovementSearch[end]' => $this->tomorrow]];
|
||||||
// }
|
|
||||||
|
|
||||||
$items[] = ['label' => Yii::t('frontend/card','Vendégek'), 'url' => [ '/card/index' ] ];
|
|
||||||
|
if (Helper::isCompanyMovar()) {
|
||||||
|
$items[] = ['label' => Yii::t('frontend/transfer', 'Daily transfers'), 'url' => ['/transfer/list', 'TransferListSearch[id_account]' => Account::readDefault(), 'TransferListSearch[start]' => $this->start, 'TransferListSearch[end]' => $this->tomorrow]];
|
||||||
|
$items[] = ['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]];
|
||||||
|
$items[] = ['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 ( Helper::isReceptionTransferListToday()){
|
||||||
|
$items[] = ['label' => Yii::t('frontend/transfer', 'Transfers'), 'url' => ['/transfer/today', ]];
|
||||||
|
}else{
|
||||||
|
$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/card', 'Vendégek'), 'url' => ['/card/index']];
|
||||||
// $items[] = ['label' => Yii::t('frontend/card','Leltár'), 'url' => [ '/product/inventory' ] ];
|
// $items[] = ['label' => Yii::t('frontend/card','Leltár'), 'url' => [ '/product/inventory' ] ];
|
||||||
// $items[] = ['label' => Yii::t('frontend/card','Leltár'), 'url' => [ '/inventory/index' ] ];
|
// $items[] = ['label' => Yii::t('frontend/card','Leltár'), 'url' => [ '/inventory/index' ] ];
|
||||||
|
|
||||||
@ -96,19 +106,18 @@ class FrontendMenuStructure{
|
|||||||
'items' => $items
|
'items' => $items
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected function addLoginMainMenu(){
|
protected function addLoginMainMenu()
|
||||||
|
{
|
||||||
if (Yii::$app->user->isGuest) {
|
if (Yii::$app->user->isGuest) {
|
||||||
$mainMenuItem= ['label' => Yii::t('frontend/site','Login'), 'url' => ['/site/login']];
|
$mainMenuItem = ['label' => Yii::t('frontend/site', 'Login'), 'url' => ['/site/login']];
|
||||||
} else {
|
} else {
|
||||||
$mainMenuItem= [
|
$mainMenuItem = [
|
||||||
'label' => Yii::t('frontend/transfer','Logout'). '(' . Yii::$app->user->identity->username . ')',
|
'label' => Yii::t('frontend/transfer', 'Logout') . '(' . Yii::$app->user->identity->username . ')',
|
||||||
'url' => ['/site/logout'],
|
'url' => ['/site/logout'],
|
||||||
'linkOptions' => ['data-method' => 'post']
|
'linkOptions' => ['data-method' => 'post']
|
||||||
];
|
];
|
||||||
@ -117,7 +126,8 @@ class FrontendMenuStructure{
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function run(){
|
public function run()
|
||||||
|
{
|
||||||
$this->addRecepcio();
|
$this->addRecepcio();
|
||||||
$this->addLoginMainMenu();
|
$this->addLoginMainMenu();
|
||||||
return $this->menuItems;
|
return $this->menuItems;
|
||||||
|
|||||||
@ -2,12 +2,13 @@
|
|||||||
|
|
||||||
namespace frontend\controllers;
|
namespace frontend\controllers;
|
||||||
|
|
||||||
|
use common\components\DateUtil;
|
||||||
|
use frontend\models\AccountstateSearchToday;
|
||||||
use Yii;
|
use Yii;
|
||||||
use common\models\AccountState;
|
use common\models\AccountState;
|
||||||
use frontend\models\AccountstateSearch;
|
use frontend\models\AccountstateSearch;
|
||||||
use yii\web\Controller;
|
use yii\web\Controller;
|
||||||
use yii\web\NotFoundHttpException;
|
use yii\web\NotFoundHttpException;
|
||||||
use yii\filters\VerbFilter;
|
|
||||||
use common\models\Account;
|
use common\models\Account;
|
||||||
use common\components\DailyListing;
|
use common\components\DailyListing;
|
||||||
use common\models\User;
|
use common\models\User;
|
||||||
@ -48,10 +49,15 @@ class AccountStateController extends Controller {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Lists all AccountState models.
|
* Lists all AccountState models.
|
||||||
*
|
|
||||||
* @return mixed
|
* @return mixed
|
||||||
|
* @throws NotFoundHttpException
|
||||||
*/
|
*/
|
||||||
public function actionIndex() {
|
public function actionIndex() {
|
||||||
|
|
||||||
|
if ( Helper::isReceptionAccountStateIndexToday()){
|
||||||
|
throw new NotFoundHttpException();
|
||||||
|
}
|
||||||
|
|
||||||
$searchModel = new AccountstateSearch ();
|
$searchModel = new AccountstateSearch ();
|
||||||
|
|
||||||
$searchModel->accounts = Account::read ();
|
$searchModel->accounts = Account::read ();
|
||||||
@ -65,6 +71,23 @@ class AccountStateController extends Controller {
|
|||||||
] );
|
] );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Lists all AccountState models.
|
||||||
|
* @return mixed
|
||||||
|
* @throws NotFoundHttpException
|
||||||
|
*/
|
||||||
|
public function actionToday() {
|
||||||
|
|
||||||
|
$searchModel = new AccountstateSearchToday();
|
||||||
|
|
||||||
|
$dataProvider = $searchModel->search ( Yii::$app->request->queryParams );
|
||||||
|
|
||||||
|
return $this->render ( 'today', [
|
||||||
|
'searchModel' => $searchModel,
|
||||||
|
'dataProvider' => $dataProvider
|
||||||
|
] );
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new AccountState model.
|
* Creates a new AccountState 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.
|
||||||
@ -92,9 +115,14 @@ class AccountStateController extends Controller {
|
|||||||
$mail->sednMail();
|
$mail->sednMail();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$redirectTo = 'index';
|
||||||
|
|
||||||
|
if ( Helper::isReceptionAccountStateIndexToday() ){
|
||||||
|
$redirectTo = 'today';
|
||||||
|
}
|
||||||
|
|
||||||
return $this->redirect ( [
|
return $this->redirect ( [
|
||||||
'index'
|
$redirectTo
|
||||||
] );
|
] );
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
@ -140,8 +168,15 @@ class AccountStateController extends Controller {
|
|||||||
$mail->sednMail();
|
$mail->sednMail();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$redirectTo = 'index';
|
||||||
|
|
||||||
|
if ( Helper::isReceptionAccountStateIndexToday() ){
|
||||||
|
$redirectTo = 'today';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return $this->redirect ( [
|
return $this->redirect ( [
|
||||||
'index'
|
$redirectTo
|
||||||
] );
|
] );
|
||||||
// return $this->redirect(['view', 'id' => $model->id_account_state]);
|
// return $this->redirect(['view', 'id' => $model->id_account_state]);
|
||||||
} else {
|
} else {
|
||||||
@ -179,7 +214,14 @@ class AccountStateController extends Controller {
|
|||||||
* @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 = AccountState::findOne ( $id )) !== null) {
|
$query = AccountState::find();
|
||||||
|
$query->andWhere(['id_account_state'=> $id]);
|
||||||
|
if ( Helper::isReceptionAccountStateIndexToday()){
|
||||||
|
$query->andWhere(['id_user'=>\Yii::$app->user->id]);
|
||||||
|
$query->andWhere(['>=','account_state.created_at', DateUtil::formatDateUtc(DateUtil::todayStart()) ]);
|
||||||
|
}
|
||||||
|
$model = $query->one();
|
||||||
|
if ( $model !== 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.' );
|
||||||
@ -256,7 +298,7 @@ class AccountStateController extends Controller {
|
|||||||
$details = null;
|
$details = null;
|
||||||
if ($accountState->isTypeClose ()) {
|
if ($accountState->isTypeClose ()) {
|
||||||
|
|
||||||
$prev;
|
$prev = null;
|
||||||
if ($accountState->type == AccountState::TYPE_CLOSE) {
|
if ($accountState->type == AccountState::TYPE_CLOSE) {
|
||||||
if (isset ( $accountState->prev_state )) {
|
if (isset ( $accountState->prev_state )) {
|
||||||
$prev = AccountState::findOne ( $accountState->prev_state );
|
$prev = AccountState::findOne ( $accountState->prev_state );
|
||||||
@ -311,7 +353,7 @@ class AccountStateController extends Controller {
|
|||||||
|
|
||||||
if ($accountState->isTypeClose ()) {
|
if ($accountState->isTypeClose ()) {
|
||||||
|
|
||||||
$prev;
|
$prev = null;
|
||||||
if ($accountState->type == AccountState::TYPE_CLOSE) {
|
if ($accountState->type == AccountState::TYPE_CLOSE) {
|
||||||
if (isset ( $accountState->prev_state )) {
|
if (isset ( $accountState->prev_state )) {
|
||||||
$prev = AccountState::findOne ( $accountState->prev_state );
|
$prev = AccountState::findOne ( $accountState->prev_state );
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace frontend\controllers;
|
namespace frontend\controllers;
|
||||||
|
|
||||||
|
use frontend\models\TransferSearchToday;
|
||||||
use Yii;
|
use Yii;
|
||||||
use common\models\Transfer;
|
use common\models\Transfer;
|
||||||
use frontend\models\TransferSearch;
|
use frontend\models\TransferSearch;
|
||||||
@ -71,12 +72,18 @@ class TransferController extends Controller
|
|||||||
'dataProvider' => $dataProvider,
|
'dataProvider' => $dataProvider,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Lists all Transfer models.
|
* Lists all Transfer models.
|
||||||
* @return mixed
|
* @return mixed
|
||||||
|
* @throws NotFoundHttpException
|
||||||
*/
|
*/
|
||||||
public function actionIndex()
|
public function actionIndex()
|
||||||
{
|
{
|
||||||
|
if ( !Helper::isReceptionTransferIndexEnabled()){
|
||||||
|
throw new NotFoundHttpException();
|
||||||
|
}
|
||||||
|
|
||||||
$searchModel = new TransferSearch();
|
$searchModel = new TransferSearch();
|
||||||
$searchModel->accounts = Account::read();
|
$searchModel->accounts = Account::read();
|
||||||
$searchModel->load(Yii::$app->request->queryParams);
|
$searchModel->load(Yii::$app->request->queryParams);
|
||||||
@ -90,6 +97,27 @@ class TransferController extends Controller
|
|||||||
'dataProvider' => $dataProvider,
|
'dataProvider' => $dataProvider,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Lists all Transfer models.
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function actionToday()
|
||||||
|
{
|
||||||
|
$searchModel = new TransferSearchToday();
|
||||||
|
$searchModel->id_account = Account::readDefault();
|
||||||
|
$searchModel->load(Yii::$app->request->queryParams);
|
||||||
|
|
||||||
|
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
|
||||||
|
|
||||||
|
//$searchModel->totalsTransfers(Yii::$app->request->queryParams);
|
||||||
|
|
||||||
|
return $this->render('today', [
|
||||||
|
'searchModel' => $searchModel,
|
||||||
|
'dataProvider' => $dataProvider,
|
||||||
|
]);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
85
frontend/models/AccountstateSearchToday.php
Normal file
85
frontend/models/AccountstateSearchToday.php
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace frontend\models;
|
||||||
|
|
||||||
|
use common\components\DateUtil;
|
||||||
|
use common\models\Account;
|
||||||
|
use Yii;
|
||||||
|
use yii\base\Model;
|
||||||
|
use yii\data\ActiveDataProvider;
|
||||||
|
use common\models\AccountState;
|
||||||
|
use common\components\Helper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* AccountstateSearch represents the model behind the search form about `common\models\AccountState`.
|
||||||
|
*/
|
||||||
|
class AccountstateSearchToday extends AccountState
|
||||||
|
{
|
||||||
|
|
||||||
|
public $start;
|
||||||
|
public $end;
|
||||||
|
|
||||||
|
public $timestampStart;
|
||||||
|
public $timestampEnd;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritdoc
|
||||||
|
*/
|
||||||
|
public function rules()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritdoc
|
||||||
|
*/
|
||||||
|
public function scenarios()
|
||||||
|
{
|
||||||
|
// bypass scenarios() implementation in the parent class
|
||||||
|
return Model::scenarios();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates data provider instance with search query applied
|
||||||
|
*
|
||||||
|
* @param array $params
|
||||||
|
*
|
||||||
|
* @return ActiveDataProvider
|
||||||
|
*/
|
||||||
|
public function search($params)
|
||||||
|
{
|
||||||
|
$query = AccountState::find();
|
||||||
|
|
||||||
|
$dataProvider = new ActiveDataProvider([
|
||||||
|
'query' => $query,
|
||||||
|
'sort' => false
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->load($params);
|
||||||
|
|
||||||
|
if (!$this->validate()) {
|
||||||
|
// uncomment the following line if you do not want to return any records when validation fails
|
||||||
|
$query->where('0=1');
|
||||||
|
return $dataProvider;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$query->innerJoinWith('account');
|
||||||
|
$query->innerJoinWith('account.userAccountAssignments');
|
||||||
|
$query->andWhere(['user_account_assignment.id_user' => Yii::$app->user->id]);
|
||||||
|
$query->andWhere([
|
||||||
|
'account_state.id_user' => \Yii::$app->user->id,
|
||||||
|
'account_state.id_account' => Account::readDefault()
|
||||||
|
]);
|
||||||
|
|
||||||
|
$query->andWhere( [ '>=','account_state.created_at', DateUtil::formatDateUtc( DateUtil::todayStart() ) ] );
|
||||||
|
|
||||||
|
$query->orderBy( 'account_state.created_at desc' );
|
||||||
|
|
||||||
|
$query->limit = 20;
|
||||||
|
|
||||||
|
return $dataProvider;
|
||||||
|
}
|
||||||
|
}
|
||||||
117
frontend/models/TransferSearchToday.php
Normal file
117
frontend/models/TransferSearchToday.php
Normal file
@ -0,0 +1,117 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace frontend\models;
|
||||||
|
|
||||||
|
use common\components\DateUtil;
|
||||||
|
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;
|
||||||
|
use common\components\Helper;
|
||||||
|
use yii\web\NotFoundHttpException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TransferSearch represents the model behind the search form about `common\models\Transfer`.
|
||||||
|
*/
|
||||||
|
class TransferSearchToday extends Transfer
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public $totals;
|
||||||
|
|
||||||
|
public $accounts;
|
||||||
|
|
||||||
|
public $types;
|
||||||
|
|
||||||
|
public $timestampStart;
|
||||||
|
|
||||||
|
public $timestampEnd;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritdoc
|
||||||
|
*/
|
||||||
|
public function rules()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
['types', 'each', 'rule' => ['integer']],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates data provider instance with search query applied
|
||||||
|
*
|
||||||
|
* @param array $params
|
||||||
|
* @return ActiveDataProvider
|
||||||
|
* @throws NotFoundHttpException
|
||||||
|
*/
|
||||||
|
public function search($params)
|
||||||
|
{
|
||||||
|
|
||||||
|
if ( !isset( $this->id_account ) ){
|
||||||
|
throw new NotFoundHttpException("Kassza nem található");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$this->timestampStart = DateUtil::formatDateUtc( DateUtil::todayStart() ) ;
|
||||||
|
$this->timestampEnd = DateUtil::formatDateUtc( DateUtil::tomorrowStart() );
|
||||||
|
$query = Transfer::find();
|
||||||
|
|
||||||
|
$dataProvider = new ActiveDataProvider([
|
||||||
|
'query' => $query,
|
||||||
|
]);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$this->load($params);
|
||||||
|
|
||||||
|
|
||||||
|
if (!$this->validate()) {
|
||||||
|
// uncomment the following line if you do not want to return any records when validation fails
|
||||||
|
$query->where('0=1');
|
||||||
|
}
|
||||||
|
$query->andWhere( ['or',['id_user' => Yii::$app->user->id ] , ['paid_by' => Yii::$app->user->id],] );
|
||||||
|
$query->andWhere(['transfer.id_account' => $this->id_account]);
|
||||||
|
|
||||||
|
$query->andFilterWhere([
|
||||||
|
'type' => $this->type,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$query->andFilterWhere(['in' ,'type', $this->types]);
|
||||||
|
|
||||||
|
$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;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function totalsTransfers($params){
|
||||||
|
$accountTotals = [];
|
||||||
|
$fullTotal = [
|
||||||
|
'label' => Yii::t('common/transfer', 'Total'),
|
||||||
|
'money' => 0
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
$accounts = Account::find()->orderBy("name asc")->all();
|
||||||
|
$accountMap = ArrayHelper::map( $accounts ,'id_account','name' );
|
||||||
|
$idUser = Yii::$app->user->id;
|
||||||
|
|
||||||
|
|
||||||
|
$this->totals = Transfer::mkTotals($this->timestampStart, $this->timestampEnd, $idUser, $this->types, $this->id_account, $accounts, $accountMap);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
64
frontend/views/account-state/_search_today.php
Normal file
64
frontend/views/account-state/_search_today.php
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use yii\helpers\Html;
|
||||||
|
use yii\widgets\ActiveForm;
|
||||||
|
use kartik\widgets\DateTimePicker;
|
||||||
|
use frontend\components\HtmlHelper;
|
||||||
|
use common\models\AccountState;
|
||||||
|
|
||||||
|
/* @var $this yii\web\View */
|
||||||
|
/* @var $model frontend\models\AccountstateSearch */
|
||||||
|
/* @var $form yii\widgets\ActiveForm */
|
||||||
|
?>
|
||||||
|
<?php
|
||||||
|
$accountOptions = ['' =>'Mind']+ HtmlHelper::mkAccountOptions( $model->accounts );
|
||||||
|
$userOptions = ['' => 'Mind'] + HtmlHelper::mkOptions($model->users,'id','username');
|
||||||
|
$typeOptions = ['' => 'Mind'] + AccountState::types();
|
||||||
|
?>
|
||||||
|
<div class="account-state-search">
|
||||||
|
|
||||||
|
<?php $form = ActiveForm::begin([
|
||||||
|
'action' => ['today'],
|
||||||
|
'method' => 'get',
|
||||||
|
]); ?>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-4">
|
||||||
|
<?= $form->field($model, 'id_account')->dropDownList($accountOptions) ?>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-4">
|
||||||
|
<?= $form->field($model, 'id_user')->dropDownList($userOptions) ?>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-4">
|
||||||
|
<?= $form->field($model, 'type')->dropDownList($typeOptions) ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-4">
|
||||||
|
<?= $form->field($model, 'start')->widget(DateTimePicker::classname(), [
|
||||||
|
'pluginOptions' => [
|
||||||
|
'autoclose'=>true,
|
||||||
|
'format' => 'yyyy.mm.dd hh:ii'
|
||||||
|
]
|
||||||
|
])->label('Időszak kezdete') ?>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-4">
|
||||||
|
<?= $form->field($model, 'end') ->widget(DateTimePicker::classname(), [
|
||||||
|
'pluginOptions' => [
|
||||||
|
'autoclose'=>true,
|
||||||
|
'format' => 'yyyy.mm.dd hh:ii'
|
||||||
|
]
|
||||||
|
])->label("Időszak vége") ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<?= Html::submitButton(Yii::t('frontend/account-state', 'Search'), ['class' => 'btn btn-primary']) ?>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php ActiveForm::end(); ?>
|
||||||
|
|
||||||
|
</div>
|
||||||
37
frontend/views/account-state/today.php
Normal file
37
frontend/views/account-state/today.php
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use yii\helpers\Html;
|
||||||
|
use yii\grid\GridView;
|
||||||
|
use yii\widgets\ListView;
|
||||||
|
use yii\base\Widget;
|
||||||
|
|
||||||
|
/* @var $this yii\web\View */
|
||||||
|
/* @var $searchModel frontend\models\AccountstateSearch */
|
||||||
|
/* @var $dataProvider yii\data\ActiveDataProvider */
|
||||||
|
|
||||||
|
$this->title = Yii::t('frontend/account-state', 'Account States');
|
||||||
|
$this->params['breadcrumbs'][] = $this->title;
|
||||||
|
?>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.notes-view table thead th,
|
||||||
|
.notes-view table td{
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<div class="account-state-index">
|
||||||
|
|
||||||
|
<h1><?= Html::encode($this->title) ?></h1>
|
||||||
|
<?php // echo $this->render('_search_today', ['model' => $searchModel]); ?>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<?= Html::a(Yii::t('frontend/account-state', 'Open Account State'), ['open'], ['class' => 'btn btn-success']) ?>
|
||||||
|
<?= Html::a(Yii::t('frontend/account-state', 'Close Account State'), ['close'], ['class' => 'btn btn-success']) ?>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<?php echo ListView::widget([
|
||||||
|
'dataProvider' => $dataProvider,
|
||||||
|
'itemView' => '_item_view'
|
||||||
|
])?>
|
||||||
|
|
||||||
|
</div>
|
||||||
@ -24,7 +24,11 @@ if ( $model ->type == AccountState::TYPE_OPEN ){
|
|||||||
}else{
|
}else{
|
||||||
$this->title = "Kassza zárás";
|
$this->title = "Kassza zárás";
|
||||||
}
|
}
|
||||||
$this->params['breadcrumbs'][] = ['label' => Yii::t('frontend/account-state', 'Account States'), 'url' => ['index']];
|
if ( \common\components\Helper::isReceptionAccountStateIndexToday()){
|
||||||
|
$this->params['breadcrumbs'][] = ['label' => Yii::t('frontend/account-state', 'Account States'), 'url' => ['today']];
|
||||||
|
}else{
|
||||||
|
$this->params['breadcrumbs'][] = ['label' => Yii::t('frontend/account-state', 'Account States'), 'url' => ['index']];
|
||||||
|
}
|
||||||
$this->params['breadcrumbs'][] = $this->title;
|
$this->params['breadcrumbs'][] = $this->title;
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
|||||||
36
frontend/views/transfer/_search_today.php
Normal file
36
frontend/views/transfer/_search_today.php
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use yii\helpers\Html;
|
||||||
|
use yii\widgets\ActiveForm;
|
||||||
|
use kartik\widgets\DatePicker;
|
||||||
|
use frontend\components\HtmlHelper;
|
||||||
|
use common\models\Transfer;
|
||||||
|
use kartik\widgets\DateTimePicker;
|
||||||
|
|
||||||
|
/* @var $this yii\web\View */
|
||||||
|
/* @var $model common\models\TransferSearch */
|
||||||
|
/* @var $form yii\widgets\ActiveForm */
|
||||||
|
?>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="transfer-search">
|
||||||
|
|
||||||
|
<?php $form = ActiveForm::begin([
|
||||||
|
'action' => ['today'],
|
||||||
|
'method' => 'get',
|
||||||
|
]); ?>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-4">
|
||||||
|
<?php echo $form->field($model, 'types')->checkboxList( Transfer::types()) ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<?= Html::submitButton(Yii::t('frontend/transfer', 'Search'), ['class' => 'btn btn-primary']) ?>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<?php ActiveForm::end(); ?>
|
||||||
|
|
||||||
|
</div>
|
||||||
32
frontend/views/transfer/today.php
Normal file
32
frontend/views/transfer/today.php
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
use yii\helpers\Html;
|
||||||
|
use yii\grid\GridView;
|
||||||
|
use yii\widgets\ListView;
|
||||||
|
use yii\base\Widget;
|
||||||
|
/* @var $this yii\web\View */
|
||||||
|
/* @var $searchModel common\models\TransferSearch */
|
||||||
|
/* @var $dataProvider yii\data\ActiveDataProvider */
|
||||||
|
$this->title = Yii::t('frontend/transfer', 'Transfers');
|
||||||
|
$this->params['breadcrumbs'][] = $this->title;
|
||||||
|
?>
|
||||||
|
<style>
|
||||||
|
.dl-transfer{
|
||||||
|
margin-bottom: 0px;
|
||||||
|
}
|
||||||
|
.item-transfer{
|
||||||
|
border: 1px solid #b4b4b4;
|
||||||
|
margin-top: 12px;
|
||||||
|
padding-top: 6px;
|
||||||
|
padding-bottom: 6px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<div class="transfer-index">
|
||||||
|
<h1><?= Html::encode($this->title) ?></h1>
|
||||||
|
<?php echo $this->render('_search_today', ['model' => $searchModel]); ?>
|
||||||
|
<?php echo ListView::widget([
|
||||||
|
'dataProvider' => $dataProvider,
|
||||||
|
'itemView' => '_view' ,
|
||||||
|
'itemOptions' => ['class' => 'item-transfer']
|
||||||
|
] )
|
||||||
|
?>
|
||||||
|
</div>
|
||||||
Loading…
Reference in New Issue
Block a user