Переглянути джерело

Refactoring services #885

refactoring
Guillaume 1 рік тому
джерело
коміт
8bbbf12b71
64 змінених файлів з 203 додано та 317 видалено
  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 Переглянути файл

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

+ 1
- 1
backend/controllers/CommunicateController.php Переглянути файл

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

+ 1
- 1
backend/controllers/DeliveryNoteController.php Переглянути файл

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

+ 1
- 1
backend/controllers/DevelopmentController.php Переглянути файл

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

+ 0
- 13
backend/controllers/DistributionController.php Переглянути файл

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

+ 1
- 1
backend/controllers/DocumentController.php Переглянути файл

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

+ 3
- 12
backend/controllers/OrderController.php Переглянути файл

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


+ 1
- 1
backend/controllers/PointSaleController.php Переглянути файл

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

+ 0
- 6
backend/controllers/ProducerAdminController.php Переглянути файл

@@ -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.

+ 1
- 1
backend/controllers/ProducerController.php Переглянути файл

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

+ 125
- 127
backend/controllers/ProductCategoryController.php Переглянути файл

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

}

+ 1
- 1
backend/controllers/ProductController.php Переглянути файл

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

+ 1
- 1
backend/controllers/QuotationController.php Переглянути файл

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

+ 1
- 1
backend/controllers/ReportController.php Переглянути файл

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

+ 1
- 1
backend/controllers/SiteController.php Переглянути файл

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

+ 1
- 1
backend/controllers/StatsController.php Переглянути файл

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

+ 1
- 1
backend/controllers/SubscriptionController.php Переглянути файл

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

+ 2
- 2
backend/controllers/UserGroupController.php Переглянути файл

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

+ 0
- 4
backend/models/AccessUserProducerForm.php Переглянути файл

@@ -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.

+ 0
- 5
backend/models/CreditForm.php Переглянути файл

@@ -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.

+ 1
- 1
backend/views/development/development.php Переглянути файл

@@ -126,7 +126,7 @@ $this->addBreadcrumb($this->getTitle());
];


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

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

+ 0
- 4
backend/views/document/_form.php Переглянути файл

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


+ 0
- 3
backend/views/invoice/index.php Переглянути файл

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

+ 0
- 4
backend/views/layouts/header.php Переглянути файл

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

+ 0
- 2
backend/views/layouts/main-old.php Переглянути файл

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

+ 0
- 5
backend/views/point-sale/_form.php Переглянути файл

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

+ 0
- 5
backend/views/producer-admin/create.php Переглянути файл

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

+ 0
- 3
backend/views/producer-admin/index.php Переглянути файл

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

+ 0
- 5
backend/views/producer-admin/update.php Переглянути файл

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

+ 0
- 2
backend/views/producer-price-range-admin/create.php Переглянути файл

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

+ 0
- 3
backend/views/producer-price-range-admin/index.php Переглянути файл

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

+ 0
- 2
backend/views/producer-price-range-admin/update.php Переглянути файл

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

+ 0
- 6
backend/views/producer/billing.php Переглянути файл

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


+ 0
- 2
backend/views/producer/update.php Переглянути файл

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


+ 0
- 7
backend/views/product-category/_form.php Переглянути файл

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

?>


+ 0
- 3
backend/views/product/_form.php Переглянути файл

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

?>

+ 0
- 3
backend/views/product/index.php Переглянути файл

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


+ 0
- 6
backend/views/product/update/prices/_form.php Переглянути файл

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


?>


+ 0
- 2
backend/views/tax-rate-admin/create.php Переглянути файл

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

+ 0
- 3
backend/views/tax-rate-admin/index.php Переглянути файл

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

+ 0
- 2
backend/views/tax-rate-admin/update.php Переглянути файл

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

+ 0
- 5
backend/views/user-group/_form.php Переглянути файл

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

+ 0
- 2
backend/views/user/credit.php Переглянути файл

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

+ 4
- 2
common/components/ActiveRecordCommon.php Переглянути файл

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

+ 1
- 1
common/components/BusinessLogic.php Переглянути файл

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

+ 0
- 1
common/helpers/GlobalParam.php Переглянути файл

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

+ 4
- 4
common/logic/Producer/Producer/ProducerBuilder.php Переглянути файл

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

+ 1
- 1
common/logic/Producer/Producer/ProducerRepository.php Переглянути файл

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

+ 1
- 1
common/logic/Producer/ProducerPriceRange/ProducerPriceRangeRepository.php Переглянути файл

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

+ 1
- 1
common/logic/User/User/User.php Переглянути файл

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

+ 1
- 1
common/logic/User/User/UserRepository.php Переглянути файл

@@ -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
- 1
common/logic/User/UserUserGroup/UserUserGroupContainer.php Переглянути файл

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

+ 0
- 1
common/mail/orderConfirmProducer-html.php Переглянути файл

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


+ 0
- 1
common/mail/orderConfirmProducer-text.php Переглянути файл

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


+ 4
- 3
frontend/controllers/SiteController.php Переглянути файл

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

+ 2
- 1
frontend/controllers/UserController.php Переглянути файл

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

+ 2
- 1
frontend/views/layouts/main.php Переглянути файл

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

+ 4
- 2
producer/controllers/CreditController.php Переглянути файл

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

+ 19
- 18
producer/controllers/OrderController.php Переглянути файл

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


+ 2
- 1
producer/controllers/ProducerBaseController.php Переглянути файл

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

+ 2
- 2
producer/controllers/SiteController.php Переглянути файл

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

+ 5
- 5
producer/controllers/SubscriptionController.php Переглянути файл

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

+ 3
- 3
producer/views/layouts/main.php Переглянути файл

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

+ 2
- 1
producer/views/order/_form.php Переглянути файл

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

Завантаження…
Відмінити
Зберегти