namespace backend\controllers; | namespace backend\controllers; | ||||
use common\helpers\GlobalParam; | use common\helpers\GlobalParam; | ||||
use common\models\Producer ; | |||||
use common\models\ User ; | |||||
use common\models\ UserSearch ; | |||||
use backend\models\AccessUserProducerForm ; | use backend\models\AccessUserProducerForm ; | ||||
/** | /** | ||||
'allow' => true, | 'allow' => true, | ||||
'roles' => ['@'], | 'roles' => ['@'], | ||||
'matchCallback' => function ($rule, $action) { | 'matchCallback' => function ($rule, $action) { | ||||
return User::hasAccessBackend(); | |||||
return $this->getLogic()->getUserContainer()->getSolver()->hasAccessBackend(); | |||||
} | } | ||||
] | ] | ||||
], | ], |
'allow' => true, | 'allow' => true, | ||||
'roles' => ['@'], | 'roles' => ['@'], | ||||
'matchCallback' => function ($rule, $action) { | 'matchCallback' => function ($rule, $action) { | ||||
return User::hasAccessBackend(); | |||||
return $this->getLogic()->getUserContainer()->getSolver()->hasAccessBackend(); | |||||
} | } | ||||
] | ] | ||||
], | ], |
'allow' => true, | 'allow' => true, | ||||
'roles' => ['@'], | 'roles' => ['@'], | ||||
'matchCallback' => function ($rule, $action) { | 'matchCallback' => function ($rule, $action) { | ||||
return User::hasAccessBackend(); | |||||
return $this->getLogic()->getUserContainer()->getSolver()->hasAccessBackend(); | |||||
} | } | ||||
] | ] | ||||
], | ], |
'allow' => true, | 'allow' => true, | ||||
'roles' => ['@'], | 'roles' => ['@'], | ||||
'matchCallback' => function ($rule, $action) { | 'matchCallback' => function ($rule, $action) { | ||||
return User::hasAccessBackend() ; | |||||
return $this->getLogic()->getUserContainer()->getSolver()->hasAccessBackend(); | |||||
} | } | ||||
] | ] | ||||
], | ], |
namespace backend\controllers; | namespace backend\controllers; | ||||
use backend\controllers\BackendController; | |||||
use common\helpers\GlobalParam; | use common\helpers\GlobalParam; | ||||
use common\models\DeliveryNote; | |||||
use common\models\Distribution; | |||||
use common\models\Document; | |||||
use common\models\PointSale; | |||||
use common\models\Product; | |||||
use common\models\Producer; | |||||
use common\models\Order; | |||||
use common\models\ProductCategory; | |||||
use common\models\ User; | |||||
use common\models\Subscription; | |||||
use common\helpers\Price; | use common\helpers\Price; | ||||
use common\models\PointSaleDistribution; | |||||
use common\logic\UserProducer\ UserProducer; | |||||
use DateTime; | use DateTime; | ||||
class DistributionController extends BackendController | class DistributionController extends BackendController |
'allow' => true, | 'allow' => true, | ||||
'roles' => ['@'], | 'roles' => ['@'], | ||||
'matchCallback' => function ($rule, $action) { | 'matchCallback' => function ($rule, $action) { | ||||
return User::hasAccessBackend(); | |||||
return $this->getLogic()->getUserContainer()->getSolver()->hasAccessBackend(); | |||||
} | } | ||||
] | ] | ||||
], | ], |
namespace backend\controllers; | namespace backend\controllers; | ||||
use common\helpers\GlobalParam; | use common\helpers\GlobalParam; | ||||
use common\models\CreditHistory; | |||||
use common\models\Order; | |||||
use common\models\ProductOrder; | |||||
use common\models\Product; | |||||
use common\models\ User; | |||||
use common\models\ProductDistribution; | |||||
use common\models\Distribution; | |||||
use common\models\Producer; | |||||
use common\logic\UserProducer\ UserProducer; | |||||
class OrderController extends BackendController | class OrderController extends BackendController | ||||
{ | { | ||||
$order->getAmount(Order::AMOUNT_PAID), | $order->getAmount(Order::AMOUNT_PAID), | ||||
$order->distribution->id_producer, | $order->distribution->id_producer, | ||||
$order->id_user, | $order->id_user, | ||||
User::getCurrentId() | |||||
GlobalParam::getCurrentUserId() | |||||
); | ); | ||||
} | } | ||||
$amountPaid, | $amountPaid, | ||||
GlobalParam::getCurrentProducerId(), | GlobalParam::getCurrentProducerId(), | ||||
$oldIdUser, | $oldIdUser, | ||||
User::getCurrentId() | |||||
GlobalParam::getCurrentUserId() | |||||
); | ); | ||||
$order = Order::searchOne(['id' => $order->id]); | $order = Order::searchOne(['id' => $order->id]); | ||||
} | } | ||||
$amount, | $amount, | ||||
GlobalParam::getCurrentProducerId(), | GlobalParam::getCurrentProducerId(), | ||||
$order->id_user, | $order->id_user, | ||||
User::getCurrentId() | |||||
GlobalParam::getCurrentUserId() | |||||
); | ); | ||||
} | } | ||||
'allow' => true, | 'allow' => true, | ||||
'roles' => ['@'], | 'roles' => ['@'], | ||||
'matchCallback' => function ($rule, $action) { | 'matchCallback' => function ($rule, $action) { | ||||
return User::hasAccessBackend(); | |||||
return $this->getLogic()->getUserContainer()->getSolver()->hasAccessBackend(); | |||||
} | } | ||||
], | ], | ||||
], | ], |
use yii\web\NotFoundHttpException; | use yii\web\NotFoundHttpException; | ||||
use yii\filters\VerbFilter; | use yii\filters\VerbFilter; | ||||
use yii\filters\AccessControl; | use yii\filters\AccessControl; | ||||
use common\helpers\Upload; | |||||
use common\models\Producer; | |||||
use yii\data\ActiveDataProvider; | use yii\data\ActiveDataProvider; | ||||
use common\models\Invoice; | |||||
use common\models\Product; | |||||
use common\models\Order; | |||||
use common\models\Subscription; | |||||
/** | /** | ||||
* UserController implements the CRUD actions for User model. | * UserController implements the CRUD actions for User model. |
'allow' => true, | 'allow' => true, | ||||
'roles' => ['@'], | 'roles' => ['@'], | ||||
'matchCallback' => function ($rule, $action) { | 'matchCallback' => function ($rule, $action) { | ||||
return User::hasAccessBackend(); | |||||
return $this->getLogic()->getUserContainer()->getSolver()->hasAccessBackend(); | |||||
} | } | ||||
] | ] | ||||
], | ], |
*/ | */ | ||||
class ProductCategoryController extends BackendController | class ProductCategoryController extends BackendController | ||||
{ | { | ||||
public function behaviors() | |||||
{ | |||||
return [ | |||||
'verbs' => [ | |||||
'class' => VerbFilter::className(), | |||||
'actions' => [ | |||||
], | |||||
], | |||||
'access' => [ | |||||
'class' => AccessControl::className(), | |||||
'rules' => [ | |||||
[ | |||||
'allow' => true, | |||||
'roles' => ['@'], | |||||
'matchCallback' => function ($rule, $action) { | |||||
return User::hasAccessBackend(); | |||||
} | |||||
], | |||||
], | |||||
], | |||||
]; | |||||
public function behaviors() | |||||
{ | |||||
return [ | |||||
'verbs' => [ | |||||
'class' => VerbFilter::className(), | |||||
'actions' => [ | |||||
], | |||||
], | |||||
'access' => [ | |||||
'class' => AccessControl::className(), | |||||
'rules' => [ | |||||
[ | |||||
'allow' => true, | |||||
'roles' => ['@'], | |||||
'matchCallback' => function ($rule, $action) { | |||||
return $this->getLogic()->getUserContainer()->getSolver()->hasAccessBackend(); | |||||
} | |||||
], | |||||
], | |||||
], | |||||
]; | |||||
} | |||||
/** | |||||
* Liste les points de vente. | |||||
* | |||||
* @return mixed | |||||
*/ | |||||
public function actionIndex() | |||||
{ | |||||
$searchModel = new ProductCategorySearch(); | |||||
$dataProvider = $searchModel->search(Yii::$app->request->queryParams); | |||||
return $this->render('index', [ | |||||
'searchModel' => $searchModel, | |||||
'dataProvider' => $dataProvider, | |||||
]); | |||||
} | |||||
/** | |||||
* Crée une catégorie. | |||||
* | |||||
* @return mixed | |||||
*/ | |||||
public function actionCreate() | |||||
{ | |||||
$model = new ProductCategory(); | |||||
$model->id_producer = GlobalParam::getCurrentProducerId(); | |||||
if ($model->load(Yii::$app->request->post()) && $model->save()) { | |||||
Yii::$app->getSession()->setFlash('success', "Catégorie ajoutée."); | |||||
return $this->redirect(['index']); | |||||
} else { | |||||
return $this->render('create', [ | |||||
'model' => $model, | |||||
]); | |||||
} | } | ||||
/** | |||||
* Liste les points de vente. | |||||
* | |||||
* @return mixed | |||||
*/ | |||||
public function actionIndex() | |||||
{ | |||||
$searchModel = new ProductCategorySearch(); | |||||
$dataProvider = $searchModel->search(Yii::$app->request->queryParams); | |||||
return $this->render('index', [ | |||||
'searchModel' => $searchModel, | |||||
'dataProvider' => $dataProvider, | |||||
]); | |||||
} | |||||
/** | |||||
* Modifie une catégorie. | |||||
* | |||||
* @param integer $id | |||||
* @return mixed | |||||
*/ | |||||
public function actionUpdate($id) | |||||
{ | |||||
$model = $this->findModel($id); | |||||
if ($model->load(Yii::$app->request->post()) && $model->save()) { | |||||
Yii::$app->getSession()->setFlash('success', "Catégorie modifiée."); | |||||
return $this->redirect(['index']); | |||||
} else { | |||||
return $this->render('update', [ | |||||
'model' => $model, | |||||
]); | |||||
} | } | ||||
/** | |||||
* Crée une catégorie. | |||||
* | |||||
* @return mixed | |||||
*/ | |||||
public function actionCreate() | |||||
{ | |||||
$model = new ProductCategory(); | |||||
$model->id_producer = GlobalParam::getCurrentProducerId() ; | |||||
if ($model->load(Yii::$app->request->post()) && $model->save()) { | |||||
Yii::$app->getSession()->setFlash('success', "Catégorie ajoutée."); | |||||
return $this->redirect(['index']); | |||||
} | |||||
else { | |||||
return $this->render('create', [ | |||||
'model' => $model, | |||||
]); | |||||
} | |||||
} | |||||
/** | |||||
* Supprime une catégorie | |||||
* | |||||
* @param integer $id | |||||
* @return mixed | |||||
*/ | |||||
public function actionDelete($id) | |||||
{ | |||||
$productCategory = $this->findModel($id); | |||||
$productCategory->delete(); | |||||
Product::updateAll(['id_product_category' => null], ['id_product_category' => $id]); | |||||
Yii::$app->getSession()->setFlash('success', 'Catégorie <strong>' . Html::encode($productCategory->name) . '</strong> supprimée.'); | |||||
return $this->redirect(['index']); | |||||
} | |||||
/** | |||||
* Modifie l'ordre des catégories. | |||||
* | |||||
* @param array $array | |||||
*/ | |||||
public function actionPosition() | |||||
{ | |||||
$array = Yii::$app->request->post('array'); | |||||
$positionArray = json_decode(stripslashes($array)); | |||||
foreach ($positionArray as $id => $position) { | |||||
$category = $this->findModel($id); | |||||
$category->position = $position; | |||||
$category->save(); | |||||
} | } | ||||
/** | |||||
* Modifie une catégorie. | |||||
* | |||||
* @param integer $id | |||||
* @return mixed | |||||
*/ | |||||
public function actionUpdate($id) | |||||
{ | |||||
$model = $this->findModel($id); | |||||
if ($model->load(Yii::$app->request->post()) && $model->save()) { | |||||
Yii::$app->getSession()->setFlash('success', "Catégorie modifiée."); | |||||
return $this->redirect(['index']); | |||||
} | |||||
else { | |||||
return $this->render('update', [ | |||||
'model' => $model, | |||||
]); | |||||
} | |||||
} | |||||
/** | |||||
* Supprime une catégorie | |||||
* | |||||
* @param integer $id | |||||
* @return mixed | |||||
*/ | |||||
public function actionDelete($id) | |||||
{ | |||||
$productCategory = $this->findModel($id); | |||||
$productCategory->delete(); | |||||
Product::updateAll(['id_product_category' => null], ['id_product_category' => $id]); | |||||
Yii::$app->getSession()->setFlash('success', 'Catégorie <strong>' . Html::encode($productCategory->name) . '</strong> supprimée.'); | |||||
return $this->redirect(['index']); | |||||
} | |||||
/** | |||||
* Modifie l'ordre des catégories. | |||||
* | |||||
* @param array $array | |||||
*/ | |||||
public function actionPosition() | |||||
{ | |||||
$array = Yii::$app->request->post('array'); | |||||
$positionArray = json_decode(stripslashes($array)); | |||||
foreach ($positionArray as $id => $position) { | |||||
$category = $this->findModel($id); | |||||
$category->position = $position; | |||||
$category->save(); | |||||
} | |||||
} | |||||
/** | |||||
* Recherche une catégorie en fonction de son ID. | |||||
* | |||||
* @param integer $id | |||||
* @return ProductCategory | |||||
* @throws NotFoundHttpException si le modèle n'est pas trouvé | |||||
*/ | |||||
protected function findModel($id) | |||||
{ | |||||
if (($model = ProductCategory::findOne($id)) !== null) { | |||||
return $model; | |||||
} else { | |||||
throw new NotFoundHttpException('The requested page does not exist.'); | |||||
} | |||||
} | |||||
/** | |||||
* Recherche une catégorie en fonction de son ID. | |||||
* | |||||
* @param integer $id | |||||
* @return ProductCategory | |||||
* @throws NotFoundHttpException si le modèle n'est pas trouvé | |||||
*/ | |||||
protected function findModel($id) | |||||
{ | |||||
if (($model = ProductCategory::findOne($id)) !== null) { | |||||
return $model; | |||||
} else { | |||||
throw new NotFoundHttpException('The requested page does not exist.'); | |||||
} | } | ||||
} | |||||
} | } |
'allow' => true, | 'allow' => true, | ||||
'roles' => ['@'], | 'roles' => ['@'], | ||||
'matchCallback' => function ($rule, $action) { | 'matchCallback' => function ($rule, $action) { | ||||
return User::hasAccessBackend(); | |||||
return $this->getLogic()->getUserContainer()->getSolver()->hasAccessBackend(); | |||||
} | } | ||||
] | ] | ||||
], | ], |
'allow' => true, | 'allow' => true, | ||||
'roles' => ['@'], | 'roles' => ['@'], | ||||
'matchCallback' => function ($rule, $action) { | 'matchCallback' => function ($rule, $action) { | ||||
return User::hasAccessBackend(); | |||||
return $this->getLogic()->getUserContainer()->getSolver()->hasAccessBackend(); | |||||
} | } | ||||
] | ] | ||||
], | ], |
'allow' => true, | 'allow' => true, | ||||
'roles' => ['@'], | 'roles' => ['@'], | ||||
'matchCallback' => function ($rule, $action) { | 'matchCallback' => function ($rule, $action) { | ||||
return User::hasAccessBackend() ; | |||||
return $this->getLogic()->getUserContainer()->getSolver()->hasAccessBackend(); | |||||
} | } | ||||
] | ] | ||||
], | ], |
'allow' => true, | 'allow' => true, | ||||
'roles' => ['@'], | 'roles' => ['@'], | ||||
'matchCallback' => function ($rule, $action) { | 'matchCallback' => function ($rule, $action) { | ||||
return User::hasAccessBackend() ; | |||||
return $this->getLogic()->getUserContainer()->getSolver()->hasAccessBackend(); | |||||
} | } | ||||
], | ], | ||||
[ | [ |
'allow' => true, | 'allow' => true, | ||||
'roles' => ['@'], | 'roles' => ['@'], | ||||
'matchCallback' => function ($rule, $action) { | 'matchCallback' => function ($rule, $action) { | ||||
return User::hasAccessBackend() ; | |||||
return $this->getLogic()->getUserContainer()->getSolver()->hasAccessBackend(); | |||||
} | } | ||||
] | ] | ||||
], | ], |
'allow' => true, | 'allow' => true, | ||||
'roles' => ['@'], | 'roles' => ['@'], | ||||
'matchCallback' => function ($rule, $action) { | 'matchCallback' => function ($rule, $action) { | ||||
return User::hasAccessBackend() ; | |||||
return $this->getLogic()->getUserContainer()->getSolver()->hasAccessBackend(); | |||||
} | } | ||||
] | ] | ||||
], | ], |
'allow' => true, | 'allow' => true, | ||||
'roles' => ['@'], | 'roles' => ['@'], | ||||
'matchCallback' => function ($rule, $action) { | 'matchCallback' => function ($rule, $action) { | ||||
return User::hasAccessBackend(); | |||||
return $this->getLogic()->getUserContainer()->getSolver()->hasAccessBackend(); | |||||
} | } | ||||
], | ], | ||||
], | ], | ||||
$userGroup = $this->findModel($id); | $userGroup = $this->findModel($id); | ||||
$userGroup->delete(); | $userGroup->delete(); | ||||
User UserGroup::deleteAll(['id_user_group' => $id]); | |||||
UserUserGroup::deleteAll(['id_user_group' => $id]); | |||||
Yii::$app->getSession()->setFlash('success', 'Groupe d\'utilisateur <strong>' . Html::encode($userGroup->name) . '</strong> supprimé.'); | Yii::$app->getSession()->setFlash('success', 'Groupe d\'utilisateur <strong>' . Html::encode($userGroup->name) . '</strong> supprimé.'); | ||||
return $this->redirect(['index']); | return $this->redirect(['index']); |
namespace backend\models; | namespace backend\models; | ||||
use common\helpers\GlobalParam; | use common\helpers\GlobalParam; | ||||
use Yii; | |||||
use yii\base\Model; | use yii\base\Model; | ||||
use common\models\ User ; | |||||
use common\models\Producer ; | |||||
use common\logic\UserProducer\ UserProducer ; | |||||
/** | /** | ||||
* ContactForm is the model behind the contact form. | * ContactForm is the model behind the contact form. |
use common\helpers\Mailjet; | use common\helpers\Mailjet; | ||||
use Yii; | use Yii; | ||||
use yii\base\Model; | use yii\base\Model; | ||||
use common\models\CreditHistory ; | |||||
use common\models\ User ; | |||||
use common\models\Producer ; | |||||
use common\logic\UserProducer\ UserProducer ; | |||||
use common\helpers\Mail ; | |||||
/** | /** | ||||
* ContactForm is the model behind the contact form. | * ContactForm is the model behind the contact form. |
]; | ]; | ||||
if ( User::hasAccessBackend()) { | |||||
if ($this->getLogic()->getUserContainer()->getSolver()->hasAccessBackend()) { | |||||
$columns[] = [ | $columns[] = [ | ||||
'header' => 'Priorité', | 'header' => 'Priorité', |
use yii\helpers\Html; | use yii\helpers\Html; | ||||
use yii\widgets\ActiveForm; | use yii\widgets\ActiveForm; | ||||
use common\models\Product; | |||||
use yii\helpers\ArrayHelper; | |||||
use common\models\TaxRate; | |||||
use common\models\Producer; | |||||
\backend\assets\VuejsDocumentFormAsset::register($this); | \backend\assets\VuejsDocumentFormAsset::register($this); | ||||
use yii\helpers\Html; | use yii\helpers\Html; | ||||
use yii\grid\GridView; | use yii\grid\GridView; | ||||
use common\helpers\Url; | use common\helpers\Url; | ||||
use common\models\Product; | |||||
use common\models\TaxRate; | |||||
use common\models\Producer; | |||||
$this->setTitle('Factures'); | $this->setTitle('Factures'); | ||||
$this->addBreadcrumb($this->getTitle()); | $this->addBreadcrumb($this->getTitle()); |
*/ | */ | ||||
use yii\helpers\Html; | use yii\helpers\Html; | ||||
use common\models\Producer; | |||||
use common\models\ User; | |||||
use yii\widgets\ActiveForm; | |||||
use yii\helpers\ArrayHelper; | |||||
use common\helpers\GlobalParam; | use common\helpers\GlobalParam; | ||||
/* @var $this \yii\web\View */ | /* @var $this \yii\web\View */ |
use yii\bootstrap\Nav; | use yii\bootstrap\Nav; | ||||
use yii\bootstrap\NavBar; | use yii\bootstrap\NavBar; | ||||
use yii\widgets\Breadcrumbs; | use yii\widgets\Breadcrumbs; | ||||
use common\models\Producer; | |||||
use common\models\ User; | |||||
use yii\widgets\ActiveForm; | use yii\widgets\ActiveForm; | ||||
use yii\helpers\ArrayHelper; | use yii\helpers\ArrayHelper; | ||||
use common\helpers\Url; | use common\helpers\Url; |
use yii\helpers\Html; | use yii\helpers\Html; | ||||
use yii\widgets\ActiveForm; | use yii\widgets\ActiveForm; | ||||
use yii\helpers\ArrayHelper; | use yii\helpers\ArrayHelper; | ||||
use common\models\Producer; | |||||
use common\models\ProductPrice ; | |||||
/* @var $this yii\web\View */ | |||||
/* @var $model backend\models\PointVente */ | |||||
/* @var $form yii\widgets\ActiveForm */ | |||||
?> | ?> | ||||
<div class="point-sale-form"> | <div class="point-sale-form"> |
termes. | termes. | ||||
*/ | */ | ||||
use yii\helpers\Html; | |||||
use yii\widgets\ActiveForm; | |||||
use yii\helpers\ArrayHelper ; | |||||
use common\models\Producer ; | |||||
$this->setTitle('Ajouter producteur') ; | $this->setTitle('Ajouter producteur') ; | ||||
$this->addBreadcrumb(['label' => 'Producteurs', 'url' => ['index']]) ; | $this->addBreadcrumb(['label' => 'Producteurs', 'url' => ['index']]) ; | ||||
$this->addBreadcrumb('Ajouter') ; | $this->addBreadcrumb('Ajouter') ; |
use yii\helpers\Html; | use yii\helpers\Html; | ||||
use yii\grid\GridView; | use yii\grid\GridView; | ||||
use common\models\ User ; | |||||
use common\models\Producer ; | |||||
use common\models\Distribution ; | |||||
$this->setTitle('Producteurs') ; | $this->setTitle('Producteurs') ; | ||||
$this->addBreadcrumb($this->getTitle()) ; | $this->addBreadcrumb($this->getTitle()) ; |
termes. | termes. | ||||
*/ | */ | ||||
use yii\helpers\Html; | |||||
use yii\widgets\ActiveForm; | |||||
use yii\helpers\ArrayHelper ; | |||||
use common\models\Producer ; | |||||
$this->setTitle('Modifier producteur') ; | $this->setTitle('Modifier producteur') ; | ||||
$this->addBreadcrumb(['label' => 'Producteurs', 'url' => ['index']]) ; | $this->addBreadcrumb(['label' => 'Producteurs', 'url' => ['index']]) ; | ||||
$this->addBreadcrumb('Modifier') ; | $this->addBreadcrumb('Modifier') ; |
use yii\helpers\Html; | use yii\helpers\Html; | ||||
use yii\widgets\ActiveForm; | use yii\widgets\ActiveForm; | ||||
use yii\helpers\ArrayHelper ; | |||||
use common\models\Producer ; | |||||
$this->setTitle('Ajouter une tranche de prix') ; | $this->setTitle('Ajouter une tranche de prix') ; | ||||
$this->addBreadcrumb(['label' => 'tranche de prix', 'url' => ['index']]) ; | $this->addBreadcrumb(['label' => 'tranche de prix', 'url' => ['index']]) ; |
use yii\helpers\Html; | use yii\helpers\Html; | ||||
use yii\grid\GridView; | use yii\grid\GridView; | ||||
use common\models\ User; | |||||
use common\models\Producer; | |||||
use common\models\Distribution; | |||||
$this->setTitle('Tranches de prix'); | $this->setTitle('Tranches de prix'); | ||||
$this->addBreadcrumb($this->getTitle()); | $this->addBreadcrumb($this->getTitle()); |
use yii\helpers\Html; | use yii\helpers\Html; | ||||
use yii\widgets\ActiveForm; | use yii\widgets\ActiveForm; | ||||
use yii\helpers\ArrayHelper ; | |||||
use common\models\Producer ; | |||||
$this->setTitle('Éditer une taxe') ; | $this->setTitle('Éditer une taxe') ; | ||||
$this->addBreadcrumb(['label' => 'taxe', 'url' => ['index']]) ; | $this->addBreadcrumb(['label' => 'taxe', 'url' => ['index']]) ; |
termes. | termes. | ||||
*/ | */ | ||||
use yii\helpers\Html; | |||||
use yii\grid\GridView; | |||||
use common\models\ User ; | |||||
use common\models\Producer ; | |||||
use yii\bootstrap\ActiveForm; | |||||
$this->setTitle('Tarifs') ; | $this->setTitle('Tarifs') ; | ||||
$this->addBreadcrumb($this->getTitle()) ; | $this->addBreadcrumb($this->getTitle()) ; | ||||
use yii\helpers\Html; | use yii\helpers\Html; | ||||
use yii\widgets\ActiveForm; | use yii\widgets\ActiveForm; | ||||
use common\helpers\Url; | |||||
use common\models\Producer; | |||||
\backend\assets\VuejsProducerUpdateAsset::register($this); | \backend\assets\VuejsProducerUpdateAsset::register($this); | ||||
use yii\helpers\Html; | use yii\helpers\Html; | ||||
use yii\widgets\ActiveForm; | use yii\widgets\ActiveForm; | ||||
use yii\helpers\ArrayHelper; | |||||
use common\models\Producer; | |||||
use common\models\ProductPrice ; | |||||
/* @var $this yii\web\View */ | |||||
/* @var $model backend\models\PointVente */ | |||||
/* @var $form yii\widgets\ActiveForm */ | |||||
?> | ?> | ||||
use yii\helpers\Html; | use yii\helpers\Html; | ||||
use yii\bootstrap\ActiveForm; | use yii\bootstrap\ActiveForm; | ||||
use common\models\Product; | |||||
use yii\helpers\ArrayHelper; | use yii\helpers\ArrayHelper; | ||||
use common\models\TaxRate; | |||||
use common\models\Producer; | |||||
use common\helpers\GlobalParam; | use common\helpers\GlobalParam; | ||||
?> | ?> |
use yii\helpers\Html; | use yii\helpers\Html; | ||||
use yii\grid\GridView; | use yii\grid\GridView; | ||||
use common\helpers\Url; | use common\helpers\Url; | ||||
use common\models\Product; | |||||
use common\models\TaxRate; | |||||
use common\models\Producer; | |||||
use common\helpers\GlobalParam; | use common\helpers\GlobalParam; | ||||
use \lo\widgets\Toggle; | use \lo\widgets\Toggle; | ||||
use yii\helpers\Html; | use yii\helpers\Html; | ||||
use yii\bootstrap\ActiveForm; | use yii\bootstrap\ActiveForm; | ||||
use common\models\Product; | |||||
use yii\helpers\ArrayHelper; | |||||
use common\models\TaxRate; | |||||
use common\models\Producer; | |||||
use common\helpers\GlobalParam; | use common\helpers\GlobalParam; | ||||
use common\models\ User ; | |||||
?> | ?> | ||||
use yii\helpers\Html; | use yii\helpers\Html; | ||||
use yii\widgets\ActiveForm; | use yii\widgets\ActiveForm; | ||||
use yii\helpers\ArrayHelper ; | |||||
use common\models\Producer ; | |||||
$this->setTitle('Ajouter une taxe') ; | $this->setTitle('Ajouter une taxe') ; | ||||
$this->addBreadcrumb(['label' => 'taxe', 'url' => ['index']]) ; | $this->addBreadcrumb(['label' => 'taxe', 'url' => ['index']]) ; |
use yii\helpers\Html; | use yii\helpers\Html; | ||||
use yii\grid\GridView; | use yii\grid\GridView; | ||||
use common\models\ User; | |||||
use common\models\Producer; | |||||
use common\models\Distribution; | |||||
$this->setTitle('Taxes'); | $this->setTitle('Taxes'); | ||||
$this->addBreadcrumb($this->getTitle()); | $this->addBreadcrumb($this->getTitle()); |
use yii\helpers\Html; | use yii\helpers\Html; | ||||
use yii\widgets\ActiveForm; | use yii\widgets\ActiveForm; | ||||
use yii\helpers\ArrayHelper ; | |||||
use common\models\Producer ; | |||||
$this->setTitle('Éditer une taxe') ; | $this->setTitle('Éditer une taxe') ; | ||||
$this->addBreadcrumb(['label' => 'taxe', 'url' => ['index']]) ; | $this->addBreadcrumb(['label' => 'taxe', 'url' => ['index']]) ; |
use yii\helpers\Html; | use yii\helpers\Html; | ||||
use yii\widgets\ActiveForm; | use yii\widgets\ActiveForm; | ||||
use yii\helpers\ArrayHelper; | use yii\helpers\ArrayHelper; | ||||
use common\models\Producer; | |||||
use common\models\ProductPrice ; | |||||
/* @var $this yii\web\View */ | |||||
/* @var $model backend\models\PointVente */ | |||||
/* @var $form yii\widgets\ActiveForm */ | |||||
?> | ?> | ||||
<div class="user-group-form"> | <div class="user-group-form"> |
use yii\helpers\Html; | use yii\helpers\Html; | ||||
use yii\widgets\ActiveForm; | use yii\widgets\ActiveForm; | ||||
use common\models\CreditHistory; | |||||
use common\models\Producer; | |||||
use common\helpers\GlobalParam; | use common\helpers\GlobalParam; | ||||
$creditHistoryService = $this->getLogic()->getCreditHistoryContainer()->getService(); | $creditHistoryService = $this->getLogic()->getCreditHistoryContainer()->getService(); |
public static function searchBy($params = [], $options = []) | public static function searchBy($params = [], $options = []) | ||||
{ | { | ||||
$class = get_called_class(); | $class = get_called_class(); | ||||
$repositoryClass = $class.'Repository'; | |||||
if (is_callable([$class, 'defaultOptionsSearch'])) { | |||||
$default_options = $class::defaultOptionsSearch(); | |||||
if (is_callable([$repositoryClass, 'defaultOptionsSearch'])) { | |||||
$repository = new $repositoryClass; | |||||
$default_options = $repository->defaultOptionsSearch(); | |||||
} else { | } else { | ||||
throw new \ErrorException('La méthode "defaultOptionsSearch" n\'est ' | throw new \ErrorException('La méthode "defaultOptionsSearch" n\'est ' | ||||
. 'pas définie dans la classe "' . $class . '"'); | . 'pas définie dans la classe "' . $class . '"'); |
use common\logic\User\CreditHistory\CreditHistoryContainer; | use common\logic\User\CreditHistory\CreditHistoryContainer; | ||||
use common\logic\User\User\UserContainer; | use common\logic\User\User\UserContainer; | ||||
use common\logic\User\UserGroup\UserGroupContainer; | use common\logic\User\UserGroup\UserGroupContainer; | ||||
use common\logic\User\UserGroup\UserUserGroupContainer; | |||||
use common\logic\User\UserProducer\UserProducerContainer; | use common\logic\User\UserProducer\UserProducerContainer; | ||||
use common\logic\User\UserUserGroup\UserUserGroupContainer; | |||||
use yii\base\ErrorException; | use yii\base\ErrorException; | ||||
class BusinessLogic | class BusinessLogic |
use common\logic\Producer\Producer\Producer; | use common\logic\Producer\Producer\Producer; | ||||
use common\logic\User\User\UserSolver; | use common\logic\User\User\UserSolver; | ||||
use common\models\Producer; | |||||
class GlobalParam | class GlobalParam | ||||
{ | { |
namespace common\logic\Producer\Producer; | namespace common\logic\Producer\Producer; | ||||
use common\helpers\Opendistrib; | use common\helpers\Opendistrib; | ||||
use common\logic\User\UserProducer\UserProducerFactory; | |||||
use common\helpers\Password; | use common\helpers\Password; | ||||
use common\logic\BaseService; | use common\logic\BaseService; | ||||
use common\logic\BuilderInterface; | use common\logic\BuilderInterface; | ||||
use common\logic\User\UserProducer\UserProducer; | use common\logic\User\UserProducer\UserProducer; | ||||
use common\logic\User\UserProducer\UserProducerBuilder; | |||||
use common\logic\User\UserProducer\UserProducerRepository; | use common\logic\User\UserProducer\UserProducerRepository; | ||||
use common\helpers\Url; | use common\helpers\Url; | ||||
{ | { | ||||
protected ProducerRepository $producerRepository; | protected ProducerRepository $producerRepository; | ||||
protected UserProducerRepository $userProducerRepository; | protected UserProducerRepository $userProducerRepository; | ||||
protected UserProducerFactory $userProducerFactory; | |||||
protected UserProducerBuilder $userProducerBuilder; | |||||
protected ProducerSolver $producerSolver; | protected ProducerSolver $producerSolver; | ||||
public function __construct() | public function __construct() | ||||
{ | { | ||||
$this->producerRepository = $this->loadService(ProducerRepository::class); | $this->producerRepository = $this->loadService(ProducerRepository::class); | ||||
$this->userProducerRepository = $this->loadService(UserProducerRepository::class); | $this->userProducerRepository = $this->loadService(UserProducerRepository::class); | ||||
$this->userProducerFactory = $this->loadService(UserProducerFactory::class); | |||||
$this->userProducerBuilder = $this->loadService(UserProducerBuilder::class); | |||||
$this->producerSolver = $this->loadService(ProducerSolver::class); | $this->producerSolver = $this->loadService(ProducerSolver::class); | ||||
} | } | ||||
{ | { | ||||
$userProducer = $this->userProducerRepository->getOne($idUser, $idProducer); | $userProducer = $this->userProducerRepository->getOne($idUser, $idProducer); | ||||
if (!$userProducer) { | if (!$userProducer) { | ||||
$userProducer = $this->userProducerFactory->create($idUser, $idProducer, $bookmark); | |||||
$userProducer = $this->userProducerBuilder->create($idUser, $idProducer, $bookmark); | |||||
} | } | ||||
if (!$userProducer->getActive()) { | if (!$userProducer->getActive()) { |
class ProducerRepository extends BaseService implements RepositoryInterface | class ProducerRepository extends BaseService implements RepositoryInterface | ||||
{ | { | ||||
protected ProducerPriceRangeRepository $ ProducerPriceRange; | |||||
protected ProducerPriceRangeRepository $producerPriceRangeRepository; | |||||
protected ProducerSolver $producerSolver; | protected ProducerSolver $producerSolver; | ||||
public function __construct() | public function __construct() |
* Retourne les options de base nécessaires à la fonction de recherche. | * Retourne les options de base nécessaires à la fonction de recherche. | ||||
* | * | ||||
*/ | */ | ||||
public static function defaultOptionsSearch(): array | |||||
public function defaultOptionsSearch(): array | |||||
{ | { | ||||
return [ | return [ | ||||
'with' => [], | 'with' => [], |
public function getUserUserGroup() | public function getUserUserGroup() | ||||
{ | { | ||||
return $this->hasMany(User UserGroup::className(), ['id_user' => 'id']); | |||||
return $this->hasMany(UserUserGroup::className(), ['id_user' => 'id']); | |||||
} | } | ||||
public function getOrder() | public function getOrder() |
public function belongsToUserGroup(User $user, int $userGroupId): bool | public function belongsToUserGroup(User $user, int $userGroupId): bool | ||||
{ | { | ||||
if (!$user->userUserGroup) { | if (!$user->userUserGroup) { | ||||
$user->populateRelation('userUserGroup', User UserGroup::searchAll([ | |||||
$user->populateRelation('userUserGroup', UserUserGroup::searchAll([ | |||||
'id_user' => $user->id | 'id_user' => $user->id | ||||
])); | ])); | ||||
} | } |
<?php | <?php | ||||
namespace common\logic\User\UserGroup; | |||||
namespace common\logic\User\UserUserGroup; | |||||
use common\logic\ContainerInterface; | use common\logic\ContainerInterface; | ||||
use common\logic\User\UserProducer\UserUserGroupRepository; | use common\logic\User\UserProducer\UserUserGroupRepository; |
termes. | termes. | ||||
*/ | */ | ||||
use common\models\Producer ; | |||||
use common\helpers\GlobalParam ; | use common\helpers\GlobalParam ; | ||||
$producer = GlobalParam::getCurrentProducer() ; | $producer = GlobalParam::getCurrentProducer() ; | ||||
termes. | termes. | ||||
*/ | */ | ||||
use common\models\Producer ; | |||||
use common\helpers\GlobalParam ; | use common\helpers\GlobalParam ; | ||||
$producer = GlobalParam::getCurrentProducer() ; | $producer = GlobalParam::getCurrentProducer() ; | ||||
namespace frontend\controllers; | namespace frontend\controllers; | ||||
use common\helpers\GlobalParam; | |||||
use common\logic\User\User\User; | use common\logic\User\User\User; | ||||
use frontend\forms\ProducerCodeForm; | use frontend\forms\ProducerCodeForm; | ||||
use Yii; | use Yii; | ||||
$userProducerArray = $this->getLogic() | $userProducerArray = $this->getLogic() | ||||
->getUserProducerContainer() | ->getUserProducerContainer() | ||||
->getRepository() | ->getRepository() | ||||
->getBy(User::getCurrentId()); | |||||
->getBy(GlobalParam::getCurrentUserId()); | |||||
if ($userProducerArray | if ($userProducerArray | ||||
&& is_array($userProducerArray) | && is_array($userProducerArray) | ||||
if ($producerCodeForm->load($this->getRequest()->post()) | if ($producerCodeForm->load($this->getRequest()->post()) | ||||
&& $producerCodeForm->validate()) { | && $producerCodeForm->validate()) { | ||||
$producerContainer->getService()->addUser(User::getCurrentId(), $id); | |||||
$producerContainer->getBuilder()->addUser(GlobalParam::getCurrentUserId(), $id); | |||||
$this->redirect($this->getUrlManagerProducer()->createAbsoluteUrl(['site/index', 'slug_producer' => $producer->slug])); | $this->redirect($this->getUrlManagerProducer()->createAbsoluteUrl(['site/index', 'slug_producer' => $producer->slug])); | ||||
} | } | ||||
if ($this->getUser()->isGuest) { | if ($this->getUser()->isGuest) { | ||||
if ($loginForm->load($this->getRequest()->post()) && $loginForm->login()) { | if ($loginForm->load($this->getRequest()->post()) && $loginForm->login()) { | ||||
if (!strlen($producer->code)) { | if (!strlen($producer->code)) { | ||||
$producerContainer->getService()->addUser(User::getCurrentId(), $id); | |||||
$producerContainer->getBuilder()->addUser(GlobalParam::getCurrentUserId(), $id); | |||||
} | } | ||||
$this->redirect($returnUrl); | $this->redirect($returnUrl); |
namespace frontend\controllers; | namespace frontend\controllers; | ||||
use common\helpers\GlobalParam; | |||||
use Yii; | use Yii; | ||||
use common\models\ User; | use common\models\ User; | ||||
use yii\data\ActiveDataProvider; | use yii\data\ActiveDataProvider; | ||||
*/ | */ | ||||
public function actionUpdate() | public function actionUpdate() | ||||
{ | { | ||||
$idUser = User::getCurrentId(); | |||||
$idUser = GlobalParam::getCurrentUserId(); | |||||
$model = $this->findModel($idUser); | $model = $this->findModel($idUser); | ||||
if ($model->load($this->getRequest()->post()) | if ($model->load($this->getRequest()->post()) |
* termes. | * termes. | ||||
*/ | */ | ||||
use common\helpers\GlobalParam; | |||||
use yii\helpers\Html; | use yii\helpers\Html; | ||||
use yii\bootstrap\Nav; | use yii\bootstrap\Nav; | ||||
use yii\bootstrap\NavBar; | use yii\bootstrap\NavBar; | ||||
$producersArray = Producer::find() | $producersArray = Producer::find() | ||||
->joinWith(['userProducer user_producer']) | ->joinWith(['userProducer user_producer']) | ||||
->where([ | ->where([ | ||||
'user_producer.id_user' => User::getCurrentId(), | |||||
'user_producer.id_user' => GlobalParam::getCurrentUserId(), | |||||
'user_producer.bookmark' => 1, | 'user_producer.bookmark' => 1, | ||||
]) | ]) | ||||
->all(); | ->all(); |
namespace producer\controllers; | namespace producer\controllers; | ||||
use common\helpers\GlobalParam; | |||||
use common\helpers\Mailjet; | use common\helpers\Mailjet; | ||||
use common\helpers\MeanPayment; | use common\helpers\MeanPayment; | ||||
use common\logic\User\CreditHistory\CreditHistory; | use common\logic\User\CreditHistory\CreditHistory; | ||||
use common\logic\User\CreditHistory\CreditHistorySearch; | |||||
use common\logic\User\User\User; | use common\logic\User\User\User; | ||||
use common\logic\User\UserProducer\UserProducer; | use common\logic\User\UserProducer\UserProducer; | ||||
use producer\models\CreditForm; | use producer\models\CreditForm; | ||||
} | } | ||||
$searchModel = new CreditHistorySearch(); | $searchModel = new CreditHistorySearch(); | ||||
$searchModel->id_user = User::getCurrentId(); | |||||
$searchModel->id_user = GlobalParam::getCurrentUserId(); | |||||
$dataProvider = $searchModel->search(\Yii::$app->request->queryParams); | $dataProvider = $searchModel->search(\Yii::$app->request->queryParams); | ||||
$userProducer = UserProducer::searchOne([ | $userProducer = UserProducer::searchOne([ | ||||
'id_producer' => $producer->id, | 'id_producer' => $producer->id, | ||||
'id_user' => User::getCurrentId() | |||||
'id_user' => GlobalParam::getCurrentUserId() | |||||
]); | ]); | ||||
if (strlen($returnPayment)) { | if (strlen($returnPayment)) { |
namespace producer\controllers; | namespace producer\controllers; | ||||
use common\helpers\GlobalParam; | |||||
use common\helpers\Mailjet; | use common\helpers\Mailjet; | ||||
use common\logic\Producer\Producer\Producer; | use common\logic\Producer\Producer\Producer; | ||||
use common\logic\User\CreditHistory\CreditHistory; | use common\logic\User\CreditHistory\CreditHistory; | ||||
public function actionRemoveProducer($id = 0) | public function actionRemoveProducer($id = 0) | ||||
{ | { | ||||
$userProducer = UserProducer::find() | $userProducer = UserProducer::find() | ||||
->where(['id_producer' => $id, 'id_user' => User::getCurrentId()]) | |||||
->where(['id_producer' => $id, 'id_user' => GlobalParam::getCurrentUserId()]) | |||||
->one(); | ->one(); | ||||
$userProducer->active = 0; | $userProducer->active = 0; | ||||
} | } | ||||
$userPointSale = UserPointSale::searchOne([ | $userPointSale = UserPointSale::searchOne([ | ||||
'id_user' => User::getCurrentId(), | |||||
'id_user' => GlobalParam::getCurrentUserId(), | |||||
'id_point_sale' => $pointSale->id | 'id_point_sale' => $pointSale->id | ||||
]); | ]); | ||||
CreditHistory::TYPE_PAYMENT, | CreditHistory::TYPE_PAYMENT, | ||||
$amountRemaining, | $amountRemaining, | ||||
$distribution->id_producer, | $distribution->id_producer, | ||||
User::getCurrentId(), | |||||
User::getCurrentId() | |||||
GlobalParam::getCurrentUserId(), | |||||
GlobalParam::getCurrentUserId() | |||||
); | ); | ||||
$order->changeOrderStatus('paid-by-credit', 'user'); | $order->changeOrderStatus('paid-by-credit', 'user'); | ||||
} else { | } else { | ||||
CreditHistory::TYPE_REFUND, | CreditHistory::TYPE_REFUND, | ||||
$amountSurplus, | $amountSurplus, | ||||
$distribution->id_producer, | $distribution->id_producer, | ||||
User::getCurrentId(), | |||||
User::getCurrentId() | |||||
GlobalParam::getCurrentUserId(), | |||||
GlobalParam::getCurrentUserId() | |||||
); | ); | ||||
} | } | ||||
} else { | } else { | ||||
throw new UserException('Vous ne pouvez plus annuler cette commande.'); | throw new UserException('Vous ne pouvez plus annuler cette commande.'); | ||||
} | } | ||||
if ($order && User::getCurrentId() == $order->id_user) { | |||||
if ($order && GlobalParam::getCurrentUserId() == $order->id_user) { | |||||
$order->delete(); | $order->delete(); | ||||
Yii::$app->session->setFlash('success', 'Votre commande a bien été annulée.'); | |||||
\Yii::$app->session->setFlash('success', 'Votre commande a bien été annulée.'); | |||||
} | } | ||||
$this->redirect(Yii::$app->urlManager->createUrl(['order/history'])); | |||||
$this->redirect(\Yii::$app->urlManager->createUrl(['order/history'])); | |||||
} | } | ||||
/** | /** | ||||
// Commandes de l'utilisateur | // Commandes de l'utilisateur | ||||
$ordersUserArray = []; | $ordersUserArray = []; | ||||
if (User::getCurrentId() && !$producer->isOnlinePaymentActiveAndTypeOrder()) { | |||||
if (GlobalParam::getCurrentUserId() && !$producer->isOnlinePaymentActiveAndTypeOrder()) { | |||||
$conditionsOrdersUser = [ | $conditionsOrdersUser = [ | ||||
'distribution.date > :date' | 'distribution.date > :date' | ||||
]; | ]; | ||||
} | } | ||||
$ordersUserArray = Order::searchAll([ | $ordersUserArray = Order::searchAll([ | ||||
'id_user' => User::getCurrentId() | |||||
'id_user' => GlobalParam::getCurrentUserId() | |||||
], [ | ], [ | ||||
'conditions' => $conditionsOrdersUser, | 'conditions' => $conditionsOrdersUser, | ||||
'params' => $paramsOrdersUser | 'params' => $paramsOrdersUser | ||||
// User | // User | ||||
$userProducer = UserProducer::searchOne([ | $userProducer = UserProducer::searchOne([ | ||||
'id_producer' => $producer->id, | 'id_producer' => $producer->id, | ||||
'id_user' => User::getCurrentId() | |||||
'id_user' => GlobalParam::getCurrentUserId() | |||||
]); | ]); | ||||
if($user && !$userProducer) { | if($user && !$userProducer) { | ||||
private function _getOrderUser($date, $pointSaleId = false) | private function _getOrderUser($date, $pointSaleId = false) | ||||
{ | { | ||||
$orderUser = false; | $orderUser = false; | ||||
if (User::getCurrentId()) { | |||||
if (GlobalParam::getCurrentUserId()) { | |||||
$conditionOrderUser = [ | $conditionOrderUser = [ | ||||
'distribution.date' => $date, | 'distribution.date' => $date, | ||||
'id_user' => User::getCurrentId(), | |||||
'id_user' => GlobalParam::getCurrentUserId(), | |||||
]; | ]; | ||||
if ($pointSaleId) { | if ($pointSaleId) { | ||||
]); | ]); | ||||
} | } | ||||
if (User::getCurrentId()) { | |||||
if (GlobalParam::getCurrentUserId()) { | |||||
$pointsSaleArray = $pointsSaleArray->with([ | $pointsSaleArray = $pointsSaleArray->with([ | ||||
'userPointSale' => function ($query) { | 'userPointSale' => function ($query) { | ||||
$query->onCondition( | $query->onCondition( | ||||
['id_user' => User::getCurrentId()] | |||||
['id_user' => GlobalParam::getCurrentUserId()] | |||||
); | ); | ||||
} | } | ||||
]); | ]); | ||||
->andWhere( | ->andWhere( | ||||
'status = 1 AND (restricted_access = 0 OR (restricted_access = 1 AND (SELECT COUNT(*) FROM user_point_sale WHERE point_sale.id = user_point_sale.id_point_sale AND user_point_sale.id_user = :id_user) > 0))' | 'status = 1 AND (restricted_access = 0 OR (restricted_access = 1 AND (SELECT COUNT(*) FROM user_point_sale WHERE point_sale.id = user_point_sale.id_point_sale AND user_point_sale.id_user = :id_user) > 0))' | ||||
) | ) | ||||
->params([':id_user' => User::getCurrentId()]) | |||||
->params([':id_user' => GlobalParam::getCurrentUserId()]) | |||||
->orderBy('code ASC, restricted_access ASC, is_bread_box ASC, `default` DESC, name ASC') | ->orderBy('code ASC, restricted_access ASC, is_bread_box ASC, `default` DESC, name ASC') | ||||
->all(); | ->all(); | ||||
$order = Order::searchOne(['id' => $idOrder]); | $order = Order::searchOne(['id' => $idOrder]); | ||||
$producer = $this->getProducer(); | $producer = $this->getProducer(); | ||||
if (!$order || ($order->id_user != User::getCurrentId() && !$producer->option_allow_order_guest)) { | |||||
if (!$order || ($order->id_user != GlobalParam::getCurrentUserId() && !$producer->option_allow_order_guest)) { | |||||
throw new \yii\base\UserException('Commande introuvable.'); | throw new \yii\base\UserException('Commande introuvable.'); | ||||
} | } | ||||
namespace producer\controllers; | namespace producer\controllers; | ||||
use common\controllers\CommonController; | use common\controllers\CommonController; | ||||
use common\helpers\GlobalParam; | |||||
use common\logic\Producer\Producer\Producer; | use common\logic\Producer\Producer\Producer; | ||||
use common\logic\User\User\User; | use common\logic\User\User\User; | ||||
use common\logic\User\UserProducer\UserProducer; | use common\logic\User\UserProducer\UserProducer; | ||||
$userProducer = UserProducer::find() | $userProducer = UserProducer::find() | ||||
->where([ | ->where([ | ||||
'id_user' => User::getCurrentId(), | |||||
'id_user' => GlobalParam::getCurrentUserId(), | |||||
'id_producer' => $producer->id | 'id_producer' => $producer->id | ||||
]) | ]) | ||||
->one() ; | ->one() ; |
$producer = $this->getProducer(); | $producer = $this->getProducer(); | ||||
$userProducer = UserProducer::find() | $userProducer = UserProducer::find() | ||||
->where([ | ->where([ | ||||
'id_user' => User::getCurrentId(), | |||||
'id_user' => GlobalParam::getCurrentUserId(), | |||||
'id_producer' => $producer->id | 'id_producer' => $producer->id | ||||
]) | ]) | ||||
->one(); | ->one(); | ||||
if (!$userProducer) { | if (!$userProducer) { | ||||
$userProducer = $this->getLogic()->getProducerContainer()->getBuilder()->addUser(User::getCurrentId(), $producer->id); | |||||
$userProducer = $this->getLogic()->getProducerContainer()->getBuilder()->addUser(GlobalParam::getCurrentUserId(), $producer->id); | |||||
} | } | ||||
if ($userProducer) { | if ($userProducer) { |
} | } | ||||
$searchModel = new SubscriptionSearch; | $searchModel = new SubscriptionSearch; | ||||
$searchModel->id_user = User::getCurrentId(); | |||||
$searchModel->id_user = GlobalParam::getCurrentUserId(); | |||||
$dataProvider = $searchModel->search(Yii::$app->request->queryParams); | $dataProvider = $searchModel->search(Yii::$app->request->queryParams); | ||||
return $this->render('index', [ | return $this->render('index', [ | ||||
// form | // form | ||||
$model = new SubscriptionForm; | $model = new SubscriptionForm; | ||||
$model->id_producer = GlobalParam::getCurrentProducerId(); | $model->id_producer = GlobalParam::getCurrentProducerId(); | ||||
$model->id_user = User::getCurrentId(); | |||||
$model->id_user = GlobalParam::getCurrentUserId(); | |||||
$posts = Yii::$app->request->post(); | $posts = Yii::$app->request->post(); | ||||
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; | \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; | ||||
$params = []; | $params = []; | ||||
$user = User::getCurrent(); | |||||
$user = GlobalParam::getCurrentUser(); | |||||
$userProducer = UserProducer::searchOne([ | $userProducer = UserProducer::searchOne([ | ||||
'id_user' => User::getCurrentId() | |||||
'id_user' => GlobalParam::getCurrentUserId() | |||||
]); | ]); | ||||
$pointSale = false; | $pointSale = false; | ||||
'id' => $idSubscription | 'id' => $idSubscription | ||||
]); | ]); | ||||
if (!$subscription || $subscription->id_user != User::getCurrentId()) { | |||||
if (!$subscription || $subscription->id_user != GlobalParam::getCurrentUserId()) { | |||||
throw new UserException('Abonnement introuvable'); | throw new UserException('Abonnement introuvable'); | ||||
} else { | } else { | ||||
$params = array_merge($params, $subscription->getAttributes()); | $params = array_merge($params, $subscription->getAttributes()); |
$producer = $this->context->getProducer(); | $producer = $this->context->getProducer(); | ||||
if (!Yii::$app->user->isGuest) { | if (!Yii::$app->user->isGuest) { | ||||
$userProducer = UserProducer::findOne(['id_user' => User::getCurrentId(), 'id_producer' => $producer->id]); | |||||
$userProducer = UserProducer::findOne(['id_user' => GlobalParam::getCurrentUserId(), 'id_producer' => $producer->id]); | |||||
} | } | ||||
?> | ?> | ||||
$countSubcriptions = Subscription::find() | $countSubcriptions = Subscription::find() | ||||
->where([ | ->where([ | ||||
'subscription.id_user' => User::getCurrentId(), | |||||
'subscription.id_user' => GlobalParam::getCurrentUserId(), | |||||
'subscription.id_producer' => GlobalParam::getCurrentProducerId(), | 'subscription.id_producer' => GlobalParam::getCurrentProducerId(), | ||||
])->count(); | ])->count(); | ||||
$labelSubscription = $countSubcriptions > 0 ? 'success' : 'default'; | $labelSubscription = $countSubcriptions > 0 ? 'success' : 'default'; | ||||
$countOrders = Order::find() | $countOrders = Order::find() | ||||
->joinWith(['distribution']) | ->joinWith(['distribution']) | ||||
->where([ | ->where([ | ||||
'id_user' => User::getCurrentId(), | |||||
'id_user' => GlobalParam::getCurrentUserId(), | |||||
'distribution.id_producer' => GlobalParam::getCurrentProducerId() | 'distribution.id_producer' => GlobalParam::getCurrentProducerId() | ||||
]) | ]) | ||||
->params([':date_today' => date('Y-m-d')]) | ->params([':date_today' => date('Y-m-d')]) |
termes. | termes. | ||||
*/ | */ | ||||
use common\helpers\GlobalParam; | |||||
use yii\widgets\ActiveForm; | use yii\widgets\ActiveForm; | ||||
use common\logic\Producer\Producer\Producer; | use common\logic\Producer\Producer\Producer; | ||||
{ | { | ||||
foreach($pointSale->userPointSale as $userPointSale) | foreach($pointSale->userPointSale as $userPointSale) | ||||
{ | { | ||||
if($userPointSale->id_user == User::getCurrentId() && strlen($userPointSale->comment)) | |||||
if($userPointSale->id_user == GlobalParam::getCurrentUserId() && strlen($userPointSale->comment)) | |||||
{ | { | ||||
$comment = '<div class="comment"><span>'.Html::encode($userPointSale->comment).'</span></div>' ; | $comment = '<div class="comment"><span>'.Html::encode($userPointSale->comment).'</span></div>' ; | ||||
} | } |