Browse Source

Refactoring services #885

refactoring
Guillaume 1 year ago
parent
commit
8bbbf12b71
64 changed files with 203 additions and 317 deletions
  1. +1
    -4
      backend/controllers/AccessController.php
  2. +1
    -1
      backend/controllers/CommunicateController.php
  3. +1
    -1
      backend/controllers/DeliveryNoteController.php
  4. +1
    -1
      backend/controllers/DevelopmentController.php
  5. +0
    -13
      backend/controllers/DistributionController.php
  6. +1
    -1
      backend/controllers/DocumentController.php
  7. +3
    -12
      backend/controllers/OrderController.php
  8. +1
    -1
      backend/controllers/PointSaleController.php
  9. +0
    -6
      backend/controllers/ProducerAdminController.php
  10. +1
    -1
      backend/controllers/ProducerController.php
  11. +125
    -127
      backend/controllers/ProductCategoryController.php
  12. +1
    -1
      backend/controllers/ProductController.php
  13. +1
    -1
      backend/controllers/QuotationController.php
  14. +1
    -1
      backend/controllers/ReportController.php
  15. +1
    -1
      backend/controllers/SiteController.php
  16. +1
    -1
      backend/controllers/StatsController.php
  17. +1
    -1
      backend/controllers/SubscriptionController.php
  18. +2
    -2
      backend/controllers/UserGroupController.php
  19. +0
    -4
      backend/models/AccessUserProducerForm.php
  20. +0
    -5
      backend/models/CreditForm.php
  21. +1
    -1
      backend/views/development/development.php
  22. +0
    -4
      backend/views/document/_form.php
  23. +0
    -3
      backend/views/invoice/index.php
  24. +0
    -4
      backend/views/layouts/header.php
  25. +0
    -2
      backend/views/layouts/main-old.php
  26. +0
    -5
      backend/views/point-sale/_form.php
  27. +0
    -5
      backend/views/producer-admin/create.php
  28. +0
    -3
      backend/views/producer-admin/index.php
  29. +0
    -5
      backend/views/producer-admin/update.php
  30. +0
    -2
      backend/views/producer-price-range-admin/create.php
  31. +0
    -3
      backend/views/producer-price-range-admin/index.php
  32. +0
    -2
      backend/views/producer-price-range-admin/update.php
  33. +0
    -6
      backend/views/producer/billing.php
  34. +0
    -2
      backend/views/producer/update.php
  35. +0
    -7
      backend/views/product-category/_form.php
  36. +0
    -3
      backend/views/product/_form.php
  37. +0
    -3
      backend/views/product/index.php
  38. +0
    -6
      backend/views/product/update/prices/_form.php
  39. +0
    -2
      backend/views/tax-rate-admin/create.php
  40. +0
    -3
      backend/views/tax-rate-admin/index.php
  41. +0
    -2
      backend/views/tax-rate-admin/update.php
  42. +0
    -5
      backend/views/user-group/_form.php
  43. +0
    -2
      backend/views/user/credit.php
  44. +4
    -2
      common/components/ActiveRecordCommon.php
  45. +1
    -1
      common/components/BusinessLogic.php
  46. +0
    -1
      common/helpers/GlobalParam.php
  47. +4
    -4
      common/logic/Producer/Producer/ProducerBuilder.php
  48. +1
    -1
      common/logic/Producer/Producer/ProducerRepository.php
  49. +1
    -1
      common/logic/Producer/ProducerPriceRange/ProducerPriceRangeRepository.php
  50. +1
    -1
      common/logic/User/User/User.php
  51. +1
    -1
      common/logic/User/User/UserRepository.php
  52. +1
    -1
      common/logic/User/UserUserGroup/UserUserGroupContainer.php
  53. +0
    -1
      common/mail/orderConfirmProducer-html.php
  54. +0
    -1
      common/mail/orderConfirmProducer-text.php
  55. +4
    -3
      frontend/controllers/SiteController.php
  56. +2
    -1
      frontend/controllers/UserController.php
  57. +2
    -1
      frontend/views/layouts/main.php
  58. +4
    -2
      producer/controllers/CreditController.php
  59. +19
    -18
      producer/controllers/OrderController.php
  60. +2
    -1
      producer/controllers/ProducerBaseController.php
  61. +2
    -2
      producer/controllers/SiteController.php
  62. +5
    -5
      producer/controllers/SubscriptionController.php
  63. +3
    -3
      producer/views/layouts/main.php
  64. +2
    -1
      producer/views/order/_form.php

+ 1
- 4
backend/controllers/AccessController.php View File

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();
} }
] ]
], ],

+ 1
- 1
backend/controllers/CommunicateController.php View File

'allow' => true, 'allow' => true,
'roles' => ['@'], 'roles' => ['@'],
'matchCallback' => function ($rule, $action) { 'matchCallback' => function ($rule, $action) {
return User::hasAccessBackend();
return $this->getLogic()->getUserContainer()->getSolver()->hasAccessBackend();
} }
] ]
], ],

+ 1
- 1
backend/controllers/DeliveryNoteController.php View File

'allow' => true, 'allow' => true,
'roles' => ['@'], 'roles' => ['@'],
'matchCallback' => function ($rule, $action) { 'matchCallback' => function ($rule, $action) {
return User::hasAccessBackend();
return $this->getLogic()->getUserContainer()->getSolver()->hasAccessBackend();
} }
] ]
], ],

+ 1
- 1
backend/controllers/DevelopmentController.php View File

'allow' => true, 'allow' => true,
'roles' => ['@'], 'roles' => ['@'],
'matchCallback' => function ($rule, $action) { 'matchCallback' => function ($rule, $action) {
return User::hasAccessBackend() ;
return $this->getLogic()->getUserContainer()->getSolver()->hasAccessBackend();
} }
] ]
], ],

+ 0
- 13
backend/controllers/DistributionController.php View File



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

+ 1
- 1
backend/controllers/DocumentController.php View File

'allow' => true, 'allow' => true,
'roles' => ['@'], 'roles' => ['@'],
'matchCallback' => function ($rule, $action) { 'matchCallback' => function ($rule, $action) {
return User::hasAccessBackend();
return $this->getLogic()->getUserContainer()->getSolver()->hasAccessBackend();
} }
] ]
], ],

+ 3
- 12
backend/controllers/OrderController.php View File

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()
); );
} }



+ 1
- 1
backend/controllers/PointSaleController.php View File

'allow' => true, 'allow' => true,
'roles' => ['@'], 'roles' => ['@'],
'matchCallback' => function ($rule, $action) { 'matchCallback' => function ($rule, $action) {
return User::hasAccessBackend();
return $this->getLogic()->getUserContainer()->getSolver()->hasAccessBackend();
} }
], ],
], ],

+ 0
- 6
backend/controllers/ProducerAdminController.php View File

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.

+ 1
- 1
backend/controllers/ProducerController.php View File

'allow' => true, 'allow' => true,
'roles' => ['@'], 'roles' => ['@'],
'matchCallback' => function ($rule, $action) { 'matchCallback' => function ($rule, $action) {
return User::hasAccessBackend();
return $this->getLogic()->getUserContainer()->getSolver()->hasAccessBackend();
} }
] ]
], ],

+ 125
- 127
backend/controllers/ProductCategoryController.php View File

*/ */
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.');
} }
}


} }

+ 1
- 1
backend/controllers/ProductController.php View File

'allow' => true, 'allow' => true,
'roles' => ['@'], 'roles' => ['@'],
'matchCallback' => function ($rule, $action) { 'matchCallback' => function ($rule, $action) {
return User::hasAccessBackend();
return $this->getLogic()->getUserContainer()->getSolver()->hasAccessBackend();
} }
] ]
], ],

+ 1
- 1
backend/controllers/QuotationController.php View File

'allow' => true, 'allow' => true,
'roles' => ['@'], 'roles' => ['@'],
'matchCallback' => function ($rule, $action) { 'matchCallback' => function ($rule, $action) {
return User::hasAccessBackend();
return $this->getLogic()->getUserContainer()->getSolver()->hasAccessBackend();
} }
] ]
], ],

+ 1
- 1
backend/controllers/ReportController.php View File

'allow' => true, 'allow' => true,
'roles' => ['@'], 'roles' => ['@'],
'matchCallback' => function ($rule, $action) { 'matchCallback' => function ($rule, $action) {
return User::hasAccessBackend() ;
return $this->getLogic()->getUserContainer()->getSolver()->hasAccessBackend();
} }
] ]
], ],

+ 1
- 1
backend/controllers/SiteController.php View File

'allow' => true, 'allow' => true,
'roles' => ['@'], 'roles' => ['@'],
'matchCallback' => function ($rule, $action) { 'matchCallback' => function ($rule, $action) {
return User::hasAccessBackend() ;
return $this->getLogic()->getUserContainer()->getSolver()->hasAccessBackend();
} }
], ],
[ [

+ 1
- 1
backend/controllers/StatsController.php View File

'allow' => true, 'allow' => true,
'roles' => ['@'], 'roles' => ['@'],
'matchCallback' => function ($rule, $action) { 'matchCallback' => function ($rule, $action) {
return User::hasAccessBackend() ;
return $this->getLogic()->getUserContainer()->getSolver()->hasAccessBackend();
} }
] ]
], ],

+ 1
- 1
backend/controllers/SubscriptionController.php View File

'allow' => true, 'allow' => true,
'roles' => ['@'], 'roles' => ['@'],
'matchCallback' => function ($rule, $action) { 'matchCallback' => function ($rule, $action) {
return User::hasAccessBackend() ;
return $this->getLogic()->getUserContainer()->getSolver()->hasAccessBackend();
} }
] ]
], ],

+ 2
- 2
backend/controllers/UserGroupController.php View File

'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']);

+ 0
- 4
backend/models/AccessUserProducerForm.php View File

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.

+ 0
- 5
backend/models/CreditForm.php View File

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.

+ 1
- 1
backend/views/development/development.php View File

]; ];




if ( User::hasAccessBackend()) {
if ($this->getLogic()->getUserContainer()->getSolver()->hasAccessBackend()) {


$columns[] = [ $columns[] = [
'header' => 'Priorité', 'header' => 'Priorité',

+ 0
- 4
backend/views/document/_form.php View File



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);



+ 0
- 3
backend/views/invoice/index.php View File

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());

+ 0
- 4
backend/views/layouts/header.php View File

*/ */


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 */

+ 0
- 2
backend/views/layouts/main-old.php View File

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;

+ 0
- 5
backend/views/point-sale/_form.php View File

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">

+ 0
- 5
backend/views/producer-admin/create.php View File

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') ;

+ 0
- 3
backend/views/producer-admin/index.php View File



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()) ;

+ 0
- 5
backend/views/producer-admin/update.php View File

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') ;

+ 0
- 2
backend/views/producer-price-range-admin/create.php View File



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']]) ;

+ 0
- 3
backend/views/producer-price-range-admin/index.php View File



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());

+ 0
- 2
backend/views/producer-price-range-admin/update.php View File



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']]) ;

+ 0
- 6
backend/views/producer/billing.php View File

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()) ;



+ 0
- 2
backend/views/producer/update.php View File



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);



+ 0
- 7
backend/views/product-category/_form.php View File



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 */


?> ?>



+ 0
- 3
backend/views/product/_form.php View File



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;


?> ?>

+ 0
- 3
backend/views/product/index.php View File

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;



+ 0
- 6
backend/views/product/update/prices/_form.php View File



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 ;



?> ?>



+ 0
- 2
backend/views/tax-rate-admin/create.php View File



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']]) ;

+ 0
- 3
backend/views/tax-rate-admin/index.php View File



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());

+ 0
- 2
backend/views/tax-rate-admin/update.php View File



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']]) ;

+ 0
- 5
backend/views/user-group/_form.php View File

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">

+ 0
- 2
backend/views/user/credit.php View File



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();

+ 4
- 2
common/components/ActiveRecordCommon.php View File

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 . '"');

+ 1
- 1
common/components/BusinessLogic.php View File

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

+ 0
- 1
common/helpers/GlobalParam.php View File



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
{ {

+ 4
- 4
common/logic/Producer/Producer/ProducerBuilder.php View File

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()) {

+ 1
- 1
common/logic/Producer/Producer/ProducerRepository.php View File



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()

+ 1
- 1
common/logic/Producer/ProducerPriceRange/ProducerPriceRangeRepository.php View File

* 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' => [],

+ 1
- 1
common/logic/User/User/User.php View File



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()

+ 1
- 1
common/logic/User/User/UserRepository.php View File

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
])); ]));
} }

+ 1
- 1
common/logic/User/UserUserGroup/UserUserGroupContainer.php View File

<?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;

+ 0
- 1
common/mail/orderConfirmProducer-html.php View File

termes. termes.
*/ */


use common\models\Producer ;
use common\helpers\GlobalParam ; use common\helpers\GlobalParam ;
$producer = GlobalParam::getCurrentProducer() ; $producer = GlobalParam::getCurrentProducer() ;



+ 0
- 1
common/mail/orderConfirmProducer-text.php View File

termes. termes.
*/ */


use common\models\Producer ;
use common\helpers\GlobalParam ; use common\helpers\GlobalParam ;
$producer = GlobalParam::getCurrentProducer() ; $producer = GlobalParam::getCurrentProducer() ;



+ 4
- 3
frontend/controllers/SiteController.php View File



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);

+ 2
- 1
frontend/controllers/UserController.php View File



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())

+ 2
- 1
frontend/views/layouts/main.php View File

* 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();

+ 4
- 2
producer/controllers/CreditController.php View File



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)) {

+ 19
- 18
producer/controllers/OrderController.php View File



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.');
} }



+ 2
- 1
producer/controllers/ProducerBaseController.php View File

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() ;

+ 2
- 2
producer/controllers/SiteController.php View File

$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) {

+ 5
- 5
producer/controllers/SubscriptionController.php View File

} }


$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());

+ 3
- 3
producer/views/layouts/main.php View File



$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')])

+ 2
- 1
producer/views/order/_form.php View File

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>' ;
} }

Loading…
Cancel
Save