Add transfer and account_state today view to reception

This commit is contained in:
2016-10-01 18:41:21 +02:00
parent d46e717b53
commit 8b6b506d17
13 changed files with 632 additions and 127 deletions

View File

@@ -2,12 +2,13 @@
namespace frontend\controllers;
use common\components\DateUtil;
use frontend\models\AccountstateSearchToday;
use Yii;
use common\models\AccountState;
use frontend\models\AccountstateSearch;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
use common\models\Account;
use common\components\DailyListing;
use common\models\User;
@@ -45,13 +46,18 @@ class AccountStateController extends Controller {
];
}
/**
* Lists all AccountState models.
*
* @return mixed
*/
/**
* Lists all AccountState models.
* @return mixed
* @throws NotFoundHttpException
*/
public function actionIndex() {
if ( Helper::isReceptionAccountStateIndexToday()){
throw new NotFoundHttpException();
}
$searchModel = new AccountstateSearch ();
$searchModel->accounts = Account::read ();
@@ -64,7 +70,24 @@ class AccountStateController extends Controller {
'dataProvider' => $dataProvider
] );
}
/**
* 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.
* If creation is successful, the browser will be redirected to the 'view' page.
@@ -92,9 +115,14 @@ class AccountStateController extends Controller {
$mail->sednMail();
}
$redirectTo = 'index';
if ( Helper::isReceptionAccountStateIndexToday() ){
$redirectTo = 'today';
}
return $this->redirect ( [
'index'
$redirectTo
] );
} else {
@@ -139,9 +167,16 @@ class AccountStateController extends Controller {
$mail = new AccountStateMail(['model' => $model,'controller' => $this]);
$mail->sednMail();
}
return $this->redirect ( [
'index'
$redirectTo = 'index';
if ( Helper::isReceptionAccountStateIndexToday() ){
$redirectTo = 'today';
}
return $this->redirect ( [
$redirectTo
] );
// return $this->redirect(['view', 'id' => $model->id_account_state]);
} else {
@@ -179,7 +214,14 @@ class AccountStateController extends Controller {
* @throws NotFoundHttpException if the model cannot be found
*/
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;
} else {
throw new NotFoundHttpException ( 'The requested page does not exist.' );
@@ -256,7 +298,7 @@ class AccountStateController extends Controller {
$details = null;
if ($accountState->isTypeClose ()) {
$prev;
$prev = null;
if ($accountState->type == AccountState::TYPE_CLOSE) {
if (isset ( $accountState->prev_state )) {
$prev = AccountState::findOne ( $accountState->prev_state );
@@ -311,7 +353,7 @@ class AccountStateController extends Controller {
if ($accountState->isTypeClose ()) {
$prev;
$prev = null;
if ($accountState->type == AccountState::TYPE_CLOSE) {
if (isset ( $accountState->prev_state )) {
$prev = AccountState::findOne ( $accountState->prev_state );