|
|
@@ -38,9 +38,11 @@ termes. |
|
|
|
|
|
|
|
namespace producer\controllers; |
|
|
|
|
|
|
|
class CommandeController extends ProducerBaseController { |
|
|
|
class CommandeController extends ProducerBaseController |
|
|
|
{ |
|
|
|
|
|
|
|
public function behaviors() { |
|
|
|
public function behaviors() |
|
|
|
{ |
|
|
|
return [ |
|
|
|
'access' => [ |
|
|
|
'class' => AccessControl::className(), |
|
|
@@ -54,8 +56,15 @@ class CommandeController extends ProducerBaseController { |
|
|
|
]; |
|
|
|
} |
|
|
|
|
|
|
|
public function actionInfosProduction($id_production) { |
|
|
|
|
|
|
|
/** |
|
|
|
* Retourne au format JSON toutes les informations relatives à une |
|
|
|
* production donnée. |
|
|
|
* |
|
|
|
* @param integer $id_production |
|
|
|
* @return mixed |
|
|
|
*/ |
|
|
|
public function actionInfosProduction($id_production) |
|
|
|
{ |
|
|
|
$production = Production::findOne($id_production); |
|
|
|
|
|
|
|
if ($production) { |
|
|
@@ -90,6 +99,12 @@ class CommandeController extends ProducerBaseController { |
|
|
|
return json_encode([]); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Initialise le formulaire de création/modification de commande. |
|
|
|
* |
|
|
|
* @param Commande $commande |
|
|
|
* @return array |
|
|
|
*/ |
|
|
|
public function initForm($commande = null) { |
|
|
|
|
|
|
|
// etablissements |
|
|
@@ -207,8 +222,8 @@ class CommandeController extends ProducerBaseController { |
|
|
|
* |
|
|
|
* @return ProducerView |
|
|
|
*/ |
|
|
|
|
|
|
|
public function actionHistorique() { |
|
|
|
public function actionHistorique() |
|
|
|
{ |
|
|
|
|
|
|
|
$data_provider_commandes = new ActiveDataProvider([ |
|
|
|
'query' => Commande::find() |
|
|
@@ -232,7 +247,13 @@ class CommandeController extends ProducerBaseController { |
|
|
|
]); |
|
|
|
} |
|
|
|
|
|
|
|
public function actionRemoveEtablissement($id = 0) { |
|
|
|
/** |
|
|
|
* Supprime un producteur. |
|
|
|
* |
|
|
|
* @param integer $id |
|
|
|
*/ |
|
|
|
public function actionRemoveEtablissement($id = 0) |
|
|
|
{ |
|
|
|
$user_etablissement = UserEtablissement::find() |
|
|
|
->where(['id_etablissement' => $id, 'id_user' => Yii::$app->user->identity->id]) |
|
|
|
->one(); |
|
|
@@ -243,7 +264,13 @@ class CommandeController extends ProducerBaseController { |
|
|
|
$this->redirect(['commande/index']); |
|
|
|
} |
|
|
|
|
|
|
|
public function actionCreate() { |
|
|
|
/** |
|
|
|
* Crée une commande. |
|
|
|
* |
|
|
|
* @return mixed |
|
|
|
*/ |
|
|
|
public function actionCreate() |
|
|
|
{ |
|
|
|
|
|
|
|
$id_etablissement = $this->getProducer()->id ; |
|
|
|
$commande = new Commande; |
|
|
@@ -272,7 +299,15 @@ class CommandeController extends ProducerBaseController { |
|
|
|
])); |
|
|
|
} |
|
|
|
|
|
|
|
public function actionUpdate($id) { |
|
|
|
/** |
|
|
|
* Modifie une commande. |
|
|
|
* |
|
|
|
* @param integer $id |
|
|
|
* @return mixed |
|
|
|
* @throws UserException |
|
|
|
*/ |
|
|
|
public function actionUpdate($id) |
|
|
|
{ |
|
|
|
|
|
|
|
$commande = Commande::find() |
|
|
|
->with('production') |
|
|
@@ -292,19 +327,32 @@ class CommandeController extends ProducerBaseController { |
|
|
|
|
|
|
|
|
|
|
|
return $this->render('update', array_merge($this->initForm($commande), [ |
|
|
|
'model' => $commande, |
|
|
|
'commande_introuvable' => !$commande, |
|
|
|
'model' => $commande, |
|
|
|
'commande_introuvable' => !$commande, |
|
|
|
])); |
|
|
|
} |
|
|
|
|
|
|
|
public function _verifEtablissementActif($id_etablissement) { |
|
|
|
/** |
|
|
|
* Vérifie si un producteur est actif. |
|
|
|
* |
|
|
|
* @param integer $id_etablissement |
|
|
|
* @throws NotFoundHttpException |
|
|
|
*/ |
|
|
|
public function _verifEtablissementActif($id_etablissement) |
|
|
|
{ |
|
|
|
$etablissement = Etablissement::findOne($id_etablissement); |
|
|
|
if ($etablissement && !$etablissement->actif) { |
|
|
|
throw new NotFoundHttpException('Cet établissement est actuellement hors ligne.'); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public function gestionForm($commande) { |
|
|
|
/** |
|
|
|
* Traite le formulaire de création/modification de commande. |
|
|
|
* |
|
|
|
* @param Commande $commande |
|
|
|
*/ |
|
|
|
public function gestionForm($commande) |
|
|
|
{ |
|
|
|
$posts = Yii::$app->request->post(); |
|
|
|
$produits = array(); |
|
|
|
|
|
|
@@ -469,8 +517,15 @@ class CommandeController extends ProducerBaseController { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public function actionAnnuler($id) { |
|
|
|
|
|
|
|
/** |
|
|
|
* Annule une commande. |
|
|
|
* |
|
|
|
* @param integer $id |
|
|
|
* @throws \yii\web\NotFoundHttpException |
|
|
|
* @throws UserException |
|
|
|
*/ |
|
|
|
public function actionAnnuler($id) |
|
|
|
{ |
|
|
|
$commande = Commande::find() |
|
|
|
->with('production', 'creditHistorique', 'commandeProduits') |
|
|
|
->where(['id' => $id]) |
|
|
@@ -505,7 +560,15 @@ class CommandeController extends ProducerBaseController { |
|
|
|
$this->redirect(Yii::$app->urlManager->createUrl(['commande/historique'])); |
|
|
|
} |
|
|
|
|
|
|
|
public function actionVerifCodePointVente($id_point_vente, $code) { |
|
|
|
/** |
|
|
|
* Vérifie le code saisi pour un point de vente. |
|
|
|
* |
|
|
|
* @param integer $id_point_vente |
|
|
|
* @param string $code |
|
|
|
* @return boolean |
|
|
|
*/ |
|
|
|
public function actionVerifCodePointVente($id_point_vente, $code) |
|
|
|
{ |
|
|
|
$point_vente = PointVente::findOne($id_point_vente); |
|
|
|
if ($point_vente) { |
|
|
|
if ($point_vente->verifCode($code)) { |