@@ -39,9 +39,6 @@ termes. | |||
namespace backend\controllers; | |||
use common\helpers\GlobalParam; | |||
use common\models\Producer ; | |||
use common\models\ User ; | |||
use common\models\ UserSearch ; | |||
use backend\models\AccessUserProducerForm ; | |||
/** | |||
@@ -64,7 +61,7 @@ class AccessController extends BackendController | |||
'allow' => true, | |||
'roles' => ['@'], | |||
'matchCallback' => function ($rule, $action) { | |||
return User::hasAccessBackend(); | |||
return $this->getLogic()->getUserContainer()->getSolver()->hasAccessBackend(); | |||
} | |||
] | |||
], |
@@ -59,7 +59,7 @@ class CommunicateController extends BackendController | |||
'allow' => true, | |||
'roles' => ['@'], | |||
'matchCallback' => function ($rule, $action) { | |||
return User::hasAccessBackend(); | |||
return $this->getLogic()->getUserContainer()->getSolver()->hasAccessBackend(); | |||
} | |||
] | |||
], |
@@ -58,7 +58,7 @@ class DeliveryNoteController extends DocumentController | |||
'allow' => true, | |||
'roles' => ['@'], | |||
'matchCallback' => function ($rule, $action) { | |||
return User::hasAccessBackend(); | |||
return $this->getLogic()->getUserContainer()->getSolver()->hasAccessBackend(); | |||
} | |||
] | |||
], |
@@ -63,7 +63,7 @@ class DevelopmentController extends Controller | |||
'allow' => true, | |||
'roles' => ['@'], | |||
'matchCallback' => function ($rule, $action) { | |||
return User::hasAccessBackend() ; | |||
return $this->getLogic()->getUserContainer()->getSolver()->hasAccessBackend(); | |||
} | |||
] | |||
], |
@@ -38,21 +38,8 @@ | |||
namespace backend\controllers; | |||
use backend\controllers\BackendController; | |||
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\models\PointSaleDistribution; | |||
use common\logic\UserProducer\ UserProducer; | |||
use DateTime; | |||
class DistributionController extends BackendController |
@@ -69,7 +69,7 @@ class DocumentController extends BackendController | |||
'allow' => true, | |||
'roles' => ['@'], | |||
'matchCallback' => function ($rule, $action) { | |||
return User::hasAccessBackend(); | |||
return $this->getLogic()->getUserContainer()->getSolver()->hasAccessBackend(); | |||
} | |||
] | |||
], |
@@ -39,15 +39,6 @@ | |||
namespace backend\controllers; | |||
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 | |||
{ | |||
@@ -791,7 +782,7 @@ class OrderController extends BackendController | |||
$order->getAmount(Order::AMOUNT_PAID), | |||
$order->distribution->id_producer, | |||
$order->id_user, | |||
User::getCurrentId() | |||
GlobalParam::getCurrentUserId() | |||
); | |||
} | |||
@@ -1033,7 +1024,7 @@ class OrderController extends BackendController | |||
$amountPaid, | |||
GlobalParam::getCurrentProducerId(), | |||
$oldIdUser, | |||
User::getCurrentId() | |||
GlobalParam::getCurrentUserId() | |||
); | |||
$order = Order::searchOne(['id' => $order->id]); | |||
} | |||
@@ -1145,7 +1136,7 @@ class OrderController extends BackendController | |||
$amount, | |||
GlobalParam::getCurrentProducerId(), | |||
$order->id_user, | |||
User::getCurrentId() | |||
GlobalParam::getCurrentUserId() | |||
); | |||
} | |||
@@ -65,7 +65,7 @@ class PointSaleController extends BackendController | |||
'allow' => true, | |||
'roles' => ['@'], | |||
'matchCallback' => function ($rule, $action) { | |||
return User::hasAccessBackend(); | |||
return $this->getLogic()->getUserContainer()->getSolver()->hasAccessBackend(); | |||
} | |||
], | |||
], |
@@ -44,13 +44,7 @@ use common\models\ User; | |||
use yii\web\NotFoundHttpException; | |||
use yii\filters\VerbFilter; | |||
use yii\filters\AccessControl; | |||
use common\helpers\Upload; | |||
use common\models\Producer; | |||
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. |
@@ -70,7 +70,7 @@ class ProducerController extends BackendController | |||
'allow' => true, | |||
'roles' => ['@'], | |||
'matchCallback' => function ($rule, $action) { | |||
return User::hasAccessBackend(); | |||
return $this->getLogic()->getUserContainer()->getSolver()->hasAccessBackend(); | |||
} | |||
] | |||
], |
@@ -50,136 +50,134 @@ use yii\helpers\Html; | |||
*/ | |||
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.'); | |||
} | |||
} | |||
} |
@@ -79,7 +79,7 @@ class ProductController extends BackendController | |||
'allow' => true, | |||
'roles' => ['@'], | |||
'matchCallback' => function ($rule, $action) { | |||
return User::hasAccessBackend(); | |||
return $this->getLogic()->getUserContainer()->getSolver()->hasAccessBackend(); | |||
} | |||
] | |||
], |
@@ -60,7 +60,7 @@ class QuotationController extends DocumentController | |||
'allow' => true, | |||
'roles' => ['@'], | |||
'matchCallback' => function ($rule, $action) { | |||
return User::hasAccessBackend(); | |||
return $this->getLogic()->getUserContainer()->getSolver()->hasAccessBackend(); | |||
} | |||
] | |||
], |
@@ -56,7 +56,7 @@ class ReportController extends BackendController | |||
'allow' => true, | |||
'roles' => ['@'], | |||
'matchCallback' => function ($rule, $action) { | |||
return User::hasAccessBackend() ; | |||
return $this->getLogic()->getUserContainer()->getSolver()->hasAccessBackend(); | |||
} | |||
] | |||
], |
@@ -68,7 +68,7 @@ class SiteController extends BackendController | |||
'allow' => true, | |||
'roles' => ['@'], | |||
'matchCallback' => function ($rule, $action) { | |||
return User::hasAccessBackend() ; | |||
return $this->getLogic()->getUserContainer()->getSolver()->hasAccessBackend(); | |||
} | |||
], | |||
[ |
@@ -58,7 +58,7 @@ class StatsController extends BackendController | |||
'allow' => true, | |||
'roles' => ['@'], | |||
'matchCallback' => function ($rule, $action) { | |||
return User::hasAccessBackend() ; | |||
return $this->getLogic()->getUserContainer()->getSolver()->hasAccessBackend(); | |||
} | |||
] | |||
], |
@@ -53,7 +53,7 @@ class SubscriptionController extends BackendController | |||
'allow' => true, | |||
'roles' => ['@'], | |||
'matchCallback' => function ($rule, $action) { | |||
return User::hasAccessBackend() ; | |||
return $this->getLogic()->getUserContainer()->getSolver()->hasAccessBackend(); | |||
} | |||
] | |||
], |
@@ -66,7 +66,7 @@ class UserGroupController extends BackendController | |||
'allow' => true, | |||
'roles' => ['@'], | |||
'matchCallback' => function ($rule, $action) { | |||
return User::hasAccessBackend(); | |||
return $this->getLogic()->getUserContainer()->getSolver()->hasAccessBackend(); | |||
} | |||
], | |||
], | |||
@@ -144,7 +144,7 @@ class UserGroupController extends BackendController | |||
$userGroup = $this->findModel($id); | |||
$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é.'); | |||
return $this->redirect(['index']); |
@@ -39,11 +39,7 @@ termes. | |||
namespace backend\models; | |||
use common\helpers\GlobalParam; | |||
use Yii; | |||
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. |
@@ -42,11 +42,6 @@ use common\helpers\GlobalParam; | |||
use common\helpers\Mailjet; | |||
use Yii; | |||
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. |
@@ -126,7 +126,7 @@ $this->addBreadcrumb($this->getTitle()); | |||
]; | |||
if ( User::hasAccessBackend()) { | |||
if ($this->getLogic()->getUserContainer()->getSolver()->hasAccessBackend()) { | |||
$columns[] = [ | |||
'header' => 'Priorité', |
@@ -38,10 +38,6 @@ | |||
use yii\helpers\Html; | |||
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); | |||
@@ -39,9 +39,6 @@ | |||
use yii\helpers\Html; | |||
use yii\grid\GridView; | |||
use common\helpers\Url; | |||
use common\models\Product; | |||
use common\models\TaxRate; | |||
use common\models\Producer; | |||
$this->setTitle('Factures'); | |||
$this->addBreadcrumb($this->getTitle()); |
@@ -37,10 +37,6 @@ | |||
*/ | |||
use yii\helpers\Html; | |||
use common\models\Producer; | |||
use common\models\ User; | |||
use yii\widgets\ActiveForm; | |||
use yii\helpers\ArrayHelper; | |||
use common\helpers\GlobalParam; | |||
/* @var $this \yii\web\View */ |
@@ -40,8 +40,6 @@ use yii\helpers\Html; | |||
use yii\bootstrap\Nav; | |||
use yii\bootstrap\NavBar; | |||
use yii\widgets\Breadcrumbs; | |||
use common\models\Producer; | |||
use common\models\ User; | |||
use yii\widgets\ActiveForm; | |||
use yii\helpers\ArrayHelper; | |||
use common\helpers\Url; |
@@ -39,12 +39,7 @@ | |||
use yii\helpers\Html; | |||
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 */ | |||
?> | |||
<div class="point-sale-form"> |
@@ -36,11 +36,6 @@ pris connaissance de la licence CeCILL, et que vous en avez accepté les | |||
termes. | |||
*/ | |||
use yii\helpers\Html; | |||
use yii\widgets\ActiveForm; | |||
use yii\helpers\ArrayHelper ; | |||
use common\models\Producer ; | |||
$this->setTitle('Ajouter producteur') ; | |||
$this->addBreadcrumb(['label' => 'Producteurs', 'url' => ['index']]) ; | |||
$this->addBreadcrumb('Ajouter') ; |
@@ -38,9 +38,6 @@ termes. | |||
use yii\helpers\Html; | |||
use yii\grid\GridView; | |||
use common\models\ User ; | |||
use common\models\Producer ; | |||
use common\models\Distribution ; | |||
$this->setTitle('Producteurs') ; | |||
$this->addBreadcrumb($this->getTitle()) ; |
@@ -36,11 +36,6 @@ pris connaissance de la licence CeCILL, et que vous en avez accepté les | |||
termes. | |||
*/ | |||
use yii\helpers\Html; | |||
use yii\widgets\ActiveForm; | |||
use yii\helpers\ArrayHelper ; | |||
use common\models\Producer ; | |||
$this->setTitle('Modifier producteur') ; | |||
$this->addBreadcrumb(['label' => 'Producteurs', 'url' => ['index']]) ; | |||
$this->addBreadcrumb('Modifier') ; |
@@ -38,8 +38,6 @@ termes. | |||
use yii\helpers\Html; | |||
use yii\widgets\ActiveForm; | |||
use yii\helpers\ArrayHelper ; | |||
use common\models\Producer ; | |||
$this->setTitle('Ajouter une tranche de prix') ; | |||
$this->addBreadcrumb(['label' => 'tranche de prix', 'url' => ['index']]) ; |
@@ -38,9 +38,6 @@ | |||
use yii\helpers\Html; | |||
use yii\grid\GridView; | |||
use common\models\ User; | |||
use common\models\Producer; | |||
use common\models\Distribution; | |||
$this->setTitle('Tranches de prix'); | |||
$this->addBreadcrumb($this->getTitle()); |
@@ -38,8 +38,6 @@ termes. | |||
use yii\helpers\Html; | |||
use yii\widgets\ActiveForm; | |||
use yii\helpers\ArrayHelper ; | |||
use common\models\Producer ; | |||
$this->setTitle('Éditer une taxe') ; | |||
$this->addBreadcrumb(['label' => 'taxe', 'url' => ['index']]) ; |
@@ -36,12 +36,6 @@ pris connaissance de la licence CeCILL, et que vous en avez accepté les | |||
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->addBreadcrumb($this->getTitle()) ; | |||
@@ -38,8 +38,6 @@ | |||
use yii\helpers\Html; | |||
use yii\widgets\ActiveForm; | |||
use common\helpers\Url; | |||
use common\models\Producer; | |||
\backend\assets\VuejsProducerUpdateAsset::register($this); | |||
@@ -38,13 +38,6 @@ | |||
use yii\helpers\Html; | |||
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 */ | |||
?> | |||
@@ -2,10 +2,7 @@ | |||
use yii\helpers\Html; | |||
use yii\bootstrap\ActiveForm; | |||
use common\models\Product; | |||
use yii\helpers\ArrayHelper; | |||
use common\models\TaxRate; | |||
use common\models\Producer; | |||
use common\helpers\GlobalParam; | |||
?> |
@@ -39,9 +39,6 @@ | |||
use yii\helpers\Html; | |||
use yii\grid\GridView; | |||
use common\helpers\Url; | |||
use common\models\Product; | |||
use common\models\TaxRate; | |||
use common\models\Producer; | |||
use common\helpers\GlobalParam; | |||
use \lo\widgets\Toggle; | |||
@@ -2,13 +2,7 @@ | |||
use yii\helpers\Html; | |||
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\models\ User ; | |||
?> | |||
@@ -38,8 +38,6 @@ termes. | |||
use yii\helpers\Html; | |||
use yii\widgets\ActiveForm; | |||
use yii\helpers\ArrayHelper ; | |||
use common\models\Producer ; | |||
$this->setTitle('Ajouter une taxe') ; | |||
$this->addBreadcrumb(['label' => 'taxe', 'url' => ['index']]) ; |
@@ -38,9 +38,6 @@ | |||
use yii\helpers\Html; | |||
use yii\grid\GridView; | |||
use common\models\ User; | |||
use common\models\Producer; | |||
use common\models\Distribution; | |||
$this->setTitle('Taxes'); | |||
$this->addBreadcrumb($this->getTitle()); |
@@ -38,8 +38,6 @@ termes. | |||
use yii\helpers\Html; | |||
use yii\widgets\ActiveForm; | |||
use yii\helpers\ArrayHelper ; | |||
use common\models\Producer ; | |||
$this->setTitle('Éditer une taxe') ; | |||
$this->addBreadcrumb(['label' => 'taxe', 'url' => ['index']]) ; |
@@ -39,12 +39,7 @@ | |||
use yii\helpers\Html; | |||
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 */ | |||
?> | |||
<div class="user-group-form"> |
@@ -38,8 +38,6 @@ termes. | |||
use yii\helpers\Html; | |||
use yii\widgets\ActiveForm; | |||
use common\models\CreditHistory; | |||
use common\models\Producer; | |||
use common\helpers\GlobalParam; | |||
$creditHistoryService = $this->getLogic()->getCreditHistoryContainer()->getService(); |
@@ -65,9 +65,11 @@ class ActiveRecordCommon extends \yii\db\ActiveRecord | |||
public static function searchBy($params = [], $options = []) | |||
{ | |||
$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 { | |||
throw new \ErrorException('La méthode "defaultOptionsSearch" n\'est ' | |||
. 'pas définie dans la classe "' . $class . '"'); |
@@ -22,8 +22,8 @@ use common\logic\Subscription\Subscription\SubscriptionContainer; | |||
use common\logic\User\CreditHistory\CreditHistoryContainer; | |||
use common\logic\User\User\UserContainer; | |||
use common\logic\User\UserGroup\UserGroupContainer; | |||
use common\logic\User\UserGroup\UserUserGroupContainer; | |||
use common\logic\User\UserProducer\UserProducerContainer; | |||
use common\logic\User\UserUserGroup\UserUserGroupContainer; | |||
use yii\base\ErrorException; | |||
class BusinessLogic |
@@ -40,7 +40,6 @@ namespace common\helpers; | |||
use common\logic\Producer\Producer\Producer; | |||
use common\logic\User\User\UserSolver; | |||
use common\models\Producer; | |||
class GlobalParam | |||
{ |
@@ -3,11 +3,11 @@ | |||
namespace common\logic\Producer\Producer; | |||
use common\helpers\Opendistrib; | |||
use common\logic\User\UserProducer\UserProducerFactory; | |||
use common\helpers\Password; | |||
use common\logic\BaseService; | |||
use common\logic\BuilderInterface; | |||
use common\logic\User\UserProducer\UserProducer; | |||
use common\logic\User\UserProducer\UserProducerBuilder; | |||
use common\logic\User\UserProducer\UserProducerRepository; | |||
use common\helpers\Url; | |||
@@ -15,14 +15,14 @@ class ProducerBuilder extends BaseService implements BuilderInterface | |||
{ | |||
protected ProducerRepository $producerRepository; | |||
protected UserProducerRepository $userProducerRepository; | |||
protected UserProducerFactory $userProducerFactory; | |||
protected UserProducerBuilder $userProducerBuilder; | |||
protected ProducerSolver $producerSolver; | |||
public function __construct() | |||
{ | |||
$this->producerRepository = $this->loadService(ProducerRepository::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); | |||
} | |||
@@ -67,7 +67,7 @@ class ProducerBuilder extends BaseService implements BuilderInterface | |||
{ | |||
$userProducer = $this->userProducerRepository->getOne($idUser, $idProducer); | |||
if (!$userProducer) { | |||
$userProducer = $this->userProducerFactory->create($idUser, $idProducer, $bookmark); | |||
$userProducer = $this->userProducerBuilder->create($idUser, $idProducer, $bookmark); | |||
} | |||
if (!$userProducer->getActive()) { |
@@ -16,7 +16,7 @@ use yii\helpers\Html; | |||
class ProducerRepository extends BaseService implements RepositoryInterface | |||
{ | |||
protected ProducerPriceRangeRepository $ ProducerPriceRange; | |||
protected ProducerPriceRangeRepository $producerPriceRangeRepository; | |||
protected ProducerSolver $producerSolver; | |||
public function __construct() |
@@ -12,7 +12,7 @@ class ProducerPriceRangeRepository extends BaseService implements RepositoryInte | |||
* Retourne les options de base nécessaires à la fonction de recherche. | |||
* | |||
*/ | |||
public static function defaultOptionsSearch(): array | |||
public function defaultOptionsSearch(): array | |||
{ | |||
return [ | |||
'with' => [], |
@@ -236,7 +236,7 @@ class User extends ActiveRecordCommon implements IdentityInterface | |||
public function getUserUserGroup() | |||
{ | |||
return $this->hasMany(User UserGroup::className(), ['id_user' => 'id']); | |||
return $this->hasMany(UserUserGroup::className(), ['id_user' => 'id']); | |||
} | |||
public function getOrder() |
@@ -43,7 +43,7 @@ class UserRepository extends BaseService implements RepositoryInterface | |||
public function belongsToUserGroup(User $user, int $userGroupId): bool | |||
{ | |||
if (!$user->userUserGroup) { | |||
$user->populateRelation('userUserGroup', User UserGroup::searchAll([ | |||
$user->populateRelation('userUserGroup', UserUserGroup::searchAll([ | |||
'id_user' => $user->id | |||
])); | |||
} |
@@ -1,6 +1,6 @@ | |||
<?php | |||
namespace common\logic\User\UserGroup; | |||
namespace common\logic\User\UserUserGroup; | |||
use common\logic\ContainerInterface; | |||
use common\logic\User\UserProducer\UserUserGroupRepository; |
@@ -36,7 +36,6 @@ pris connaissance de la licence CeCILL, et que vous en avez accepté les | |||
termes. | |||
*/ | |||
use common\models\Producer ; | |||
use common\helpers\GlobalParam ; | |||
$producer = GlobalParam::getCurrentProducer() ; | |||
@@ -36,7 +36,6 @@ pris connaissance de la licence CeCILL, et que vous en avez accepté les | |||
termes. | |||
*/ | |||
use common\models\Producer ; | |||
use common\helpers\GlobalParam ; | |||
$producer = GlobalParam::getCurrentProducer() ; | |||
@@ -38,6 +38,7 @@ | |||
namespace frontend\controllers; | |||
use common\helpers\GlobalParam; | |||
use common\logic\User\User\User; | |||
use frontend\forms\ProducerCodeForm; | |||
use Yii; | |||
@@ -204,7 +205,7 @@ class SiteController extends FrontendController | |||
$userProducerArray = $this->getLogic() | |||
->getUserProducerContainer() | |||
->getRepository() | |||
->getBy(User::getCurrentId()); | |||
->getBy(GlobalParam::getCurrentUserId()); | |||
if ($userProducerArray | |||
&& is_array($userProducerArray) | |||
@@ -383,7 +384,7 @@ class SiteController extends FrontendController | |||
if ($producerCodeForm->load($this->getRequest()->post()) | |||
&& $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])); | |||
} | |||
@@ -416,7 +417,7 @@ class SiteController extends FrontendController | |||
if ($this->getUser()->isGuest) { | |||
if ($loginForm->load($this->getRequest()->post()) && $loginForm->login()) { | |||
if (!strlen($producer->code)) { | |||
$producerContainer->getService()->addUser(User::getCurrentId(), $id); | |||
$producerContainer->getBuilder()->addUser(GlobalParam::getCurrentUserId(), $id); | |||
} | |||
$this->redirect($returnUrl); |
@@ -38,6 +38,7 @@ termes. | |||
namespace frontend\controllers; | |||
use common\helpers\GlobalParam; | |||
use Yii; | |||
use common\models\ User; | |||
use yii\data\ActiveDataProvider; | |||
@@ -81,7 +82,7 @@ class UserController extends FrontendController | |||
*/ | |||
public function actionUpdate() | |||
{ | |||
$idUser = User::getCurrentId(); | |||
$idUser = GlobalParam::getCurrentUserId(); | |||
$model = $this->findModel($idUser); | |||
if ($model->load($this->getRequest()->post()) |
@@ -36,6 +36,7 @@ | |||
* termes. | |||
*/ | |||
use common\helpers\GlobalParam; | |||
use yii\helpers\Html; | |||
use yii\bootstrap\Nav; | |||
use yii\bootstrap\NavBar; | |||
@@ -192,7 +193,7 @@ if (!Yii::$app->user->isGuest && \Yii::$app->user->identity->id_producer > 0) { | |||
$producersArray = Producer::find() | |||
->joinWith(['userProducer user_producer']) | |||
->where([ | |||
'user_producer.id_user' => User::getCurrentId(), | |||
'user_producer.id_user' => GlobalParam::getCurrentUserId(), | |||
'user_producer.bookmark' => 1, | |||
]) | |||
->all(); |
@@ -38,9 +38,11 @@ | |||
namespace producer\controllers; | |||
use common\helpers\GlobalParam; | |||
use common\helpers\Mailjet; | |||
use common\helpers\MeanPayment; | |||
use common\logic\User\CreditHistory\CreditHistory; | |||
use common\logic\User\CreditHistory\CreditHistorySearch; | |||
use common\logic\User\User\User; | |||
use common\logic\User\UserProducer\UserProducer; | |||
use producer\models\CreditForm; | |||
@@ -93,12 +95,12 @@ class CreditController extends ProducerBaseController | |||
} | |||
$searchModel = new CreditHistorySearch(); | |||
$searchModel->id_user = User::getCurrentId(); | |||
$searchModel->id_user = GlobalParam::getCurrentUserId(); | |||
$dataProvider = $searchModel->search(\Yii::$app->request->queryParams); | |||
$userProducer = UserProducer::searchOne([ | |||
'id_producer' => $producer->id, | |||
'id_user' => User::getCurrentId() | |||
'id_user' => GlobalParam::getCurrentUserId() | |||
]); | |||
if (strlen($returnPayment)) { |
@@ -38,6 +38,7 @@ | |||
namespace producer\controllers; | |||
use common\helpers\GlobalParam; | |||
use common\helpers\Mailjet; | |||
use common\logic\Producer\Producer\Producer; | |||
use common\logic\User\CreditHistory\CreditHistory; | |||
@@ -154,7 +155,7 @@ class OrderController extends ProducerBaseController | |||
public function actionRemoveProducer($id = 0) | |||
{ | |||
$userProducer = UserProducer::find() | |||
->where(['id_producer' => $id, 'id_user' => User::getCurrentId()]) | |||
->where(['id_producer' => $id, 'id_user' => GlobalParam::getCurrentUserId()]) | |||
->one(); | |||
$userProducer->active = 0; | |||
@@ -394,7 +395,7 @@ class OrderController extends ProducerBaseController | |||
} | |||
$userPointSale = UserPointSale::searchOne([ | |||
'id_user' => User::getCurrentId(), | |||
'id_user' => GlobalParam::getCurrentUserId(), | |||
'id_point_sale' => $pointSale->id | |||
]); | |||
@@ -515,8 +516,8 @@ class OrderController extends ProducerBaseController | |||
CreditHistory::TYPE_PAYMENT, | |||
$amountRemaining, | |||
$distribution->id_producer, | |||
User::getCurrentId(), | |||
User::getCurrentId() | |||
GlobalParam::getCurrentUserId(), | |||
GlobalParam::getCurrentUserId() | |||
); | |||
$order->changeOrderStatus('paid-by-credit', 'user'); | |||
} else { | |||
@@ -529,8 +530,8 @@ class OrderController extends ProducerBaseController | |||
CreditHistory::TYPE_REFUND, | |||
$amountSurplus, | |||
$distribution->id_producer, | |||
User::getCurrentId(), | |||
User::getCurrentId() | |||
GlobalParam::getCurrentUserId(), | |||
GlobalParam::getCurrentUserId() | |||
); | |||
} | |||
} else { | |||
@@ -614,12 +615,12 @@ class OrderController extends ProducerBaseController | |||
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(); | |||
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'])); | |||
} | |||
/** | |||
@@ -717,7 +718,7 @@ class OrderController extends ProducerBaseController | |||
// Commandes de l'utilisateur | |||
$ordersUserArray = []; | |||
if (User::getCurrentId() && !$producer->isOnlinePaymentActiveAndTypeOrder()) { | |||
if (GlobalParam::getCurrentUserId() && !$producer->isOnlinePaymentActiveAndTypeOrder()) { | |||
$conditionsOrdersUser = [ | |||
'distribution.date > :date' | |||
]; | |||
@@ -731,7 +732,7 @@ class OrderController extends ProducerBaseController | |||
} | |||
$ordersUserArray = Order::searchAll([ | |||
'id_user' => User::getCurrentId() | |||
'id_user' => GlobalParam::getCurrentUserId() | |||
], [ | |||
'conditions' => $conditionsOrdersUser, | |||
'params' => $paramsOrdersUser | |||
@@ -752,7 +753,7 @@ class OrderController extends ProducerBaseController | |||
// User | |||
$userProducer = UserProducer::searchOne([ | |||
'id_producer' => $producer->id, | |||
'id_user' => User::getCurrentId() | |||
'id_user' => GlobalParam::getCurrentUserId() | |||
]); | |||
if($user && !$userProducer) { | |||
@@ -892,10 +893,10 @@ class OrderController extends ProducerBaseController | |||
private function _getOrderUser($date, $pointSaleId = false) | |||
{ | |||
$orderUser = false; | |||
if (User::getCurrentId()) { | |||
if (GlobalParam::getCurrentUserId()) { | |||
$conditionOrderUser = [ | |||
'distribution.date' => $date, | |||
'id_user' => User::getCurrentId(), | |||
'id_user' => GlobalParam::getCurrentUserId(), | |||
]; | |||
if ($pointSaleId) { | |||
@@ -938,11 +939,11 @@ class OrderController extends ProducerBaseController | |||
]); | |||
} | |||
if (User::getCurrentId()) { | |||
if (GlobalParam::getCurrentUserId()) { | |||
$pointsSaleArray = $pointsSaleArray->with([ | |||
'userPointSale' => function ($query) { | |||
$query->onCondition( | |||
['id_user' => User::getCurrentId()] | |||
['id_user' => GlobalParam::getCurrentUserId()] | |||
); | |||
} | |||
]); | |||
@@ -952,7 +953,7 @@ class OrderController extends ProducerBaseController | |||
->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))' | |||
) | |||
->params([':id_user' => User::getCurrentId()]) | |||
->params([':id_user' => GlobalParam::getCurrentUserId()]) | |||
->orderBy('code ASC, restricted_access ASC, is_bread_box ASC, `default` DESC, name ASC') | |||
->all(); | |||
@@ -1014,7 +1015,7 @@ class OrderController extends ProducerBaseController | |||
$order = Order::searchOne(['id' => $idOrder]); | |||
$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.'); | |||
} | |||
@@ -39,6 +39,7 @@ termes. | |||
namespace producer\controllers; | |||
use common\controllers\CommonController; | |||
use common\helpers\GlobalParam; | |||
use common\logic\Producer\Producer\Producer; | |||
use common\logic\User\User\User; | |||
use common\logic\User\UserProducer\UserProducer; | |||
@@ -67,7 +68,7 @@ class ProducerBaseController extends CommonController | |||
$userProducer = UserProducer::find() | |||
->where([ | |||
'id_user' => User::getCurrentId(), | |||
'id_user' => GlobalParam::getCurrentUserId(), | |||
'id_producer' => $producer->id | |||
]) | |||
->one() ; |
@@ -234,13 +234,13 @@ class SiteController extends ProducerBaseController | |||
$producer = $this->getProducer(); | |||
$userProducer = UserProducer::find() | |||
->where([ | |||
'id_user' => User::getCurrentId(), | |||
'id_user' => GlobalParam::getCurrentUserId(), | |||
'id_producer' => $producer->id | |||
]) | |||
->one(); | |||
if (!$userProducer) { | |||
$userProducer = $this->getLogic()->getProducerContainer()->getBuilder()->addUser(User::getCurrentId(), $producer->id); | |||
$userProducer = $this->getLogic()->getProducerContainer()->getBuilder()->addUser(GlobalParam::getCurrentUserId(), $producer->id); | |||
} | |||
if ($userProducer) { |
@@ -76,7 +76,7 @@ class SubscriptionController extends ProducerBaseController | |||
} | |||
$searchModel = new SubscriptionSearch; | |||
$searchModel->id_user = User::getCurrentId(); | |||
$searchModel->id_user = GlobalParam::getCurrentUserId(); | |||
$dataProvider = $searchModel->search(Yii::$app->request->queryParams); | |||
return $this->render('index', [ | |||
@@ -90,7 +90,7 @@ class SubscriptionController extends ProducerBaseController | |||
// form | |||
$model = new SubscriptionForm; | |||
$model->id_producer = GlobalParam::getCurrentProducerId(); | |||
$model->id_user = User::getCurrentId(); | |||
$model->id_user = GlobalParam::getCurrentUserId(); | |||
$posts = Yii::$app->request->post(); | |||
@@ -245,9 +245,9 @@ class SubscriptionController extends ProducerBaseController | |||
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; | |||
$params = []; | |||
$user = User::getCurrent(); | |||
$user = GlobalParam::getCurrentUser(); | |||
$userProducer = UserProducer::searchOne([ | |||
'id_user' => User::getCurrentId() | |||
'id_user' => GlobalParam::getCurrentUserId() | |||
]); | |||
$pointSale = false; | |||
@@ -316,7 +316,7 @@ class SubscriptionController extends ProducerBaseController | |||
'id' => $idSubscription | |||
]); | |||
if (!$subscription || $subscription->id_user != User::getCurrentId()) { | |||
if (!$subscription || $subscription->id_user != GlobalParam::getCurrentUserId()) { | |||
throw new UserException('Abonnement introuvable'); | |||
} else { | |||
$params = array_merge($params, $subscription->getAttributes()); |
@@ -50,7 +50,7 @@ use common\logic\User\User\User; | |||
$producer = $this->context->getProducer(); | |||
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]); | |||
} | |||
?> | |||
@@ -153,7 +153,7 @@ if (!Yii::$app->user->isGuest) { | |||
$countSubcriptions = Subscription::find() | |||
->where([ | |||
'subscription.id_user' => User::getCurrentId(), | |||
'subscription.id_user' => GlobalParam::getCurrentUserId(), | |||
'subscription.id_producer' => GlobalParam::getCurrentProducerId(), | |||
])->count(); | |||
$labelSubscription = $countSubcriptions > 0 ? 'success' : 'default'; | |||
@@ -161,7 +161,7 @@ if (!Yii::$app->user->isGuest) { | |||
$countOrders = Order::find() | |||
->joinWith(['distribution']) | |||
->where([ | |||
'id_user' => User::getCurrentId(), | |||
'id_user' => GlobalParam::getCurrentUserId(), | |||
'distribution.id_producer' => GlobalParam::getCurrentProducerId() | |||
]) | |||
->params([':date_today' => date('Y-m-d')]) |
@@ -36,6 +36,7 @@ pris connaissance de la licence CeCILL, et que vous en avez accepté les | |||
termes. | |||
*/ | |||
use common\helpers\GlobalParam; | |||
use yii\widgets\ActiveForm; | |||
use common\logic\Producer\Producer\Producer; | |||
@@ -123,7 +124,7 @@ use common\logic\Producer\Producer\Producer; | |||
{ | |||
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>' ; | |||
} |