Browse Source

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

refactoring
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



class BackendController extends \common\controllers\CommonController 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

public function actionIndex($date = '') public function actionIndex($date = '')
{ {
$this->checkProductsPointsSale() ;
$format = 'Y-m-d' ; $format = 'Y-m-d' ;
$theDate = '' ; $theDate = '' ;
$dateObject = DateTime::createFromFormat($format, $date); $dateObject = DateTime::createFromFormat($format, $date);

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

*/ */
public function actionIndex() public function actionIndex()
{ {
if (!Product::searchCount() || !PointSale::searchCount()) {
$this->redirect(['site/index', 'error_products_points_sale' => 1]);
}

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

Loading…
Cancel
Save