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