Browse Source

[backend] distribution/index : redirection vers le tableau de bord si aucun produit ou point de vente de saisi

dev
Guillaume Bourgeois 5 years ago
parent
commit
7c53298478
3 changed files with 15 additions and 5 deletions
  1. +10
    -0
      backend/controllers/BackendController.php
  2. +2
    -0
      backend/controllers/DistributionController.php
  3. +3
    -5
      backend/controllers/SubscriptionController.php

+ 10
- 0
backend/controllers/BackendController.php View File

@@ -42,6 +42,16 @@ use common\models\Producer ;

class BackendController extends \common\controllers\CommonController
{
/**
* Vérifie si l'utilisateur a au moins saisi un produit et un point de vente.
* Si ce n'est pas le cas : redirection vers le tableau de bord.
*/
public function checkProductsPointsSale()
{
if (!Product::searchCount() || !PointSale::searchCount()) {
$this->redirect(['site/index', 'error_products_points_sale' => 1]);
}
}

}


+ 2
- 0
backend/controllers/DistributionController.php View File

@@ -77,6 +77,8 @@ class DistributionController extends BackendController
public function actionIndex($date = '')
{
$this->checkProductsPointsSale() ;
$format = 'Y-m-d' ;
$theDate = '' ;
$dateObject = DateTime::createFromFormat($format, $date);

+ 3
- 5
backend/controllers/SubscriptionController.php View File

@@ -68,10 +68,8 @@ class SubscriptionController extends BackendController
*/
public function actionIndex()
{
if (!Product::searchCount() || !PointSale::searchCount()) {
$this->redirect(['site/index', 'error_products_points_sale' => 1]);
}

$this->checkProductsPointsSale() ;
$searchModel = new SubscriptionSearch ;
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
@@ -87,7 +85,7 @@ class SubscriptionController extends BackendController
* @return string
*/
public function actionCreate($idOrder = 0)
{
{
// form
$model = new SubscriptionForm;
$model->id_producer = Producer::getId();

Loading…
Cancel
Save