Kaynağa Gözat

Merge branch 'develop'

master
Guillaume Bourgeois 1 yıl önce
ebeveyn
işleme
858b476b67
100 değiştirilmiş dosya ile 1015 ekleme ve 628 silme
  1. +10
    -13
      backend/controllers/AccessController.php
  2. +0
    -2
      backend/controllers/BackendController.php
  3. +5
    -3
      backend/controllers/CommunicateAdminController.php
  4. +3
    -1
      backend/controllers/CommunicateController.php
  5. +6
    -4
      backend/controllers/CreditController.php
  6. +2
    -2
      backend/controllers/CronController.php
  7. +3
    -6
      backend/controllers/DashboardController.php
  8. +3
    -6
      backend/controllers/DeliveryNoteController.php
  9. +6
    -2
      backend/controllers/DevelopmentController.php
  10. +54
    -37
      backend/controllers/DistributionController.php
  11. +7
    -10
      backend/controllers/DocumentController.php
  12. +12
    -13
      backend/controllers/OrderController.php
  13. +5
    -8
      backend/controllers/PointSaleController.php
  14. +6
    -4
      backend/controllers/ProducerAdminController.php
  15. +3
    -1
      backend/controllers/ProducerController.php
  16. +3
    -6
      backend/controllers/ProducerPriceRangeAdminController.php
  17. +3
    -6
      backend/controllers/ProductCategoryController.php
  18. +7
    -10
      backend/controllers/ProductController.php
  19. +3
    -8
      backend/controllers/QuotationController.php
  20. +5
    -3
      backend/controllers/ReportController.php
  21. +8
    -4
      backend/controllers/SiteController.php
  22. +3
    -1
      backend/controllers/StatsAdminController.php
  23. +3
    -4
      backend/controllers/StatsController.php
  24. +3
    -1
      backend/controllers/SubscriptionController.php
  25. +3
    -5
      backend/controllers/SupportAdminController.php
  26. +3
    -7
      backend/controllers/SupportController.php
  27. +3
    -2
      backend/controllers/TaxRateAdminController.php
  28. +32
    -32
      backend/controllers/UserController.php
  29. +3
    -8
      backend/controllers/UserGroupController.php
  30. +5
    -5
      backend/models/CreditForm.php
  31. +2
    -2
      backend/views/access/index.php
  32. +3
    -3
      backend/views/credit/index.php
  33. +4
    -4
      backend/views/dashboard/index.php
  34. +1
    -1
      backend/views/development/development.php
  35. +19
    -66
      backend/views/distribution/index.php
  36. +25
    -0
      backend/views/distribution/shopping-cart-labels.php
  37. +4
    -4
      backend/views/document/_form.php
  38. +2
    -2
      backend/views/document/download.php
  39. +3
    -3
      backend/views/invoice/index.php
  40. +8
    -9
      backend/views/layouts/header.php
  41. +49
    -46
      backend/views/layouts/left.php
  42. +5
    -5
      backend/views/point-sale/_form.php
  43. +16
    -3
      backend/views/producer-admin/index.php
  44. +2
    -2
      backend/views/producer/update.php
  45. +2
    -2
      backend/views/product/update/prices/_form.php
  46. +4
    -4
      backend/views/product/update/prices/list.php
  47. +3
    -3
      backend/views/quotation/index.php
  48. +48
    -64
      backend/views/site/error.php
  49. +2
    -2
      backend/views/subscription/_form.php
  50. +5
    -5
      backend/views/support/view.php
  51. +2
    -2
      backend/views/user/_form.php
  52. +2
    -2
      backend/views/user/credit.php
  53. +42
    -38
      backend/views/user/index.php
  54. +2
    -2
      backend/views/user/orders.php
  55. +7
    -0
      backend/web/css/screen.css
  56. +20
    -8
      backend/web/js/vuejs/distribution-index.js
  57. +8
    -0
      backend/web/sass/producer-admin/_index.scss
  58. +1
    -0
      backend/web/sass/screen.scss
  59. +8
    -7
      common/components/BusinessLogicTrait.php
  60. +10
    -0
      common/config/main.php
  61. +2
    -1
      common/config/params.php
  62. +8
    -3
      common/controllers/CommonController.php
  63. +4
    -4
      common/forms/SubscriptionForm.php
  64. +10
    -4
      common/helpers/Tiller.php
  65. +27
    -0
      common/logic/AbstractModule.php
  66. +3
    -0
      common/logic/AbstractSingleton.php
  67. +1
    -1
      common/logic/Distribution/Distribution/Service/DistributionBuilder.php
  68. +0
    -1
      common/logic/Distribution/Distribution/Service/DistributionReportPdfGenerator.php
  69. +108
    -0
      common/logic/Distribution/Distribution/Service/DistributionShoppingCartLabelsPdfGenerator.php
  70. +2
    -0
      common/logic/Distribution/Distribution/Wrapper/DistributionContainer.php
  71. +2
    -0
      common/logic/Distribution/Distribution/Wrapper/DistributionManager.php
  72. +8
    -0
      common/logic/ModuleInterface.php
  73. +15
    -12
      common/logic/Order/Order/Repository/OrderRepository.php
  74. +3
    -3
      common/logic/Payment/Event/OrderObserver.php
  75. +7
    -1
      common/logic/Payment/Service/PaymentUtils.php
  76. +2
    -0
      common/logic/PointSale/PointSale/Service/PointSaleSolver.php
  77. +3
    -3
      common/logic/User/User/Event/TicketObserver.php
  78. +11
    -1
      common/logic/User/User/Model/User.php
  79. +30
    -8
      common/logic/User/User/Model/UserSearch.php
  80. +45
    -0
      common/logic/User/User/Service/AuthorizationChecker.php
  81. +1
    -1
      common/logic/User/User/Service/NewsletterManager.php
  82. +6
    -6
      common/logic/User/User/Service/UserNotifier.php
  83. +30
    -26
      common/logic/User/User/Service/UserSolver.php
  84. +13
    -6
      common/logic/User/User/Wrapper/UserContainer.php
  85. +0
    -29
      common/logic/User/User/Wrapper/UserManager.php
  86. +83
    -0
      common/logic/User/User/Wrapper/UserModule.php
  87. +3
    -3
      common/mail/paymentErrorProducer-html.php
  88. +3
    -3
      common/mail/paymentErrorProducer-text.php
  89. +3
    -1
      common/versions/22.10.A.php
  90. +3
    -1
      common/versions/22.11.A.php
  91. +3
    -1
      common/versions/22.11.B.php
  92. +3
    -1
      common/versions/22.12.A.php
  93. +3
    -1
      common/versions/23.1.A.php
  94. +1
    -0
      common/versions/23.10.A.php
  95. +1
    -0
      common/versions/23.10.B.php
  96. +35
    -0
      common/versions/23.10.C.php
  97. +3
    -1
      common/versions/23.3.A.php
  98. +3
    -1
      common/versions/23.4.A.php
  99. +3
    -1
      common/versions/23.6.A.php
  100. +3
    -1
      common/versions/23.6.B.php

+ 10
- 13
backend/controllers/AccessController.php Dosyayı Görüntüle

@@ -52,11 +52,6 @@ class AccessController extends BackendController
public function behaviors()
{
return [
'verbs' => [
'class' => VerbFilter::class,
'actions' => [
],
],
'access' => [
'class' => AccessControl::class,
'rules' => [
@@ -64,7 +59,9 @@ class AccessController extends BackendController
'allow' => true,
'roles' => ['@'],
'matchCallback' => function ($rule, $action) {
return $this->getUserManager()->hasAccessBackend();
return $this->getUserModule()
->getAuthorizationChecker()
->isGrantedAsProducer($this->getUserCurrent());
}
]
],
@@ -78,15 +75,15 @@ class AccessController extends BackendController
*/
public function actionIndex()
{
$userManager = $this->getUserManager();
$userModule = $this->getUserModule();
$producer = $this->getProducerCurrent();
$userSearch = new UserSearch();
$usersArray = $userSearch->search()->query->all();

$modelAccessUserProducerForm = new AccessUserProducerForm;
if ($modelAccessUserProducerForm->load(\Yii::$app->request->post()) && $modelAccessUserProducerForm->validate()) {
$user = $userManager->findOneUserById($modelAccessUserProducerForm->id_user);
if($user && $userManager->grantAccess($user)) {
$user = $userModule->findOneUserById($modelAccessUserProducerForm->id_user);
if($user && $userModule->grantAccess($user)) {
$this->setFlash('success', 'Droits ajoutés à l\'utilisateur');
}
else {
@@ -96,7 +93,7 @@ class AccessController extends BackendController

return $this->render('index', [
'usersArray' => $usersArray,
'usersAccessArray' => $userManager->findUsersByProducer($producer),
'usersAccessArray' => $userModule->findUsersByProducer($producer),
'producer' => $producer,
'modelAccessUserProducerForm' => $modelAccessUserProducerForm,
]);
@@ -104,10 +101,10 @@ class AccessController extends BackendController

public function actionDelete($idUser)
{
$userManager = $this->getUserManager();
$user = $userManager->findOneUserById($idUser);
$userModule = $this->getUserModule();
$user = $userModule->findOneUserById($idUser);

if ($user && $userManager->deleteAccess($user)) {
if ($user && $userModule->deleteAccess($user)) {
$this->addFlash('success', 'Droits de l\'utilisateur supprimé.');
}
else {

+ 0
- 2
backend/controllers/BackendController.php Dosyayı Görüntüle

@@ -49,12 +49,10 @@ class BackendController extends CommonController
{
$producerCurrent = $this->getProducerCurrent();

// Contexte producteur
if($producerCurrent) {
$this->getLogic()->setProducerContext($producerCurrent);
}

// Pas de producteur défini
if(!$producerCurrent) {
$this->redirect(\Yii::$app->urlManagerFrontend->createAbsoluteUrl(['dashboard/index']));
return false;

+ 5
- 3
backend/controllers/CommunicateAdminController.php Dosyayı Görüntüle

@@ -66,7 +66,9 @@ class CommunicateAdminController extends BackendController
'allow' => true,
'roles' => ['@'],
'matchCallback' => function ($rule, $action) {
return $this->getUserManager()->isCurrentAdmin();
return $this->getUserModule()
->getAuthorizationChecker()
->isGrantedAsAdministrator($this->getUserCurrent());
}
]
],
@@ -77,7 +79,7 @@ class CommunicateAdminController extends BackendController
public function actionIndex($section = 'producers')
{
$producerManager = $this->getProducerManager();
$userManager = $this->getUserManager();
$userModule = $this->getUserModule();

if ($section == 'producers') {
$producers = $producerManager->findProducersActive();
@@ -96,7 +98,7 @@ class CommunicateAdminController extends BackendController
}
}
} elseif ($section == 'users') {
$users = $userManager->findUsersByStatus(User::STATUS_ACTIVE);
$users = $userModule->findUsersByStatus(User::STATUS_ACTIVE);
$usersArray = [];
foreach ($users as $user) {
if (isset($user['email']) && strlen($user['email'])) {

+ 3
- 1
backend/controllers/CommunicateController.php Dosyayı Görüntüle

@@ -64,7 +64,9 @@ class CommunicateController extends BackendController
'allow' => true,
'roles' => ['@'],
'matchCallback' => function ($rule, $action) {
return $this->getUserManager()->hasAccessBackend();
return $this->getUserModule()
->getAuthorizationChecker()
->isGrantedAsProducer($this->getUserCurrent());
}
]
],

+ 6
- 4
backend/controllers/CreditController.php Dosyayı Görüntüle

@@ -56,7 +56,9 @@ class CreditController extends BackendController
'allow' => true,
'roles' => ['@'],
'matchCallback' => function ($rule, $action) {
return $this->getUserManager()->hasAccessBackend();
return $this->getUserModule()
->getAuthorizationChecker()
->isGrantedAsProducer($this->getUserCurrent());
}
]
],
@@ -66,11 +68,11 @@ class CreditController extends BackendController

public function actionIndex()
{
$userManager = $this->getUserManager();
$userModule = $this->getUserModule();
$userProducerManager = $this->getUserProducerManager();

$dataProviderUsersWithNegativeCredit = new ActiveDataProvider([
'query' => $userManager->queryUsersWithNegativeCredit(),
'query' => $userModule->queryUsersWithNegativeCredit(),
'sort' => false,
'pagination' => [
'pageSize' => 30,
@@ -85,6 +87,6 @@ class CreditController extends BackendController

public function actionExportUsers(string $type)
{
$this->getUserManager()->exportUsersCreditAsCsv($type);
$this->getUserModule()->exportUsersCreditAsCsv($type);
}
}

+ 2
- 2
backend/controllers/CronController.php Dosyayı Görüntüle

@@ -112,7 +112,7 @@ class CronController extends BackendController
$distributionManager = $this->getDistributionManager();
$orderManager = $this->getOrderManager();
$paymentManager = $this->getPaymentManager();
$userManager = $this->getUserManager();
$userModule = $this->getUserModule();

if ($key == '64ac0bdab7e9f5e48c4d991ec5201d57') {
ini_set('memory_limit', '-1');
@@ -164,7 +164,7 @@ class CronController extends BackendController
$orderManager->initOrder($order);
if ($order->auto_payment && $configCredit) {
if ($orderManager->isCreditAutoPayment($order) && $orderManager->getOrderAmount($order, Order::AMOUNT_REMAINING) > 0) {
$paymentManager->payOrder($order, MeanPayment::CREDIT, $userManager->findOneUserById(User::ID_USER_SYSTEM), false);
$paymentManager->payOrder($order, MeanPayment::CREDIT, $userModule->findOneUserById(User::ID_USER_SYSTEM), false);
$countOrders++;
}
}

+ 3
- 6
backend/controllers/DashboardController.php Dosyayı Görüntüle

@@ -59,16 +59,13 @@ class DashboardController extends BackendController
'allow' => true,
'roles' => ['@'],
'matchCallback' => function ($rule, $action) {
return $this->getUserManager()->hasAccessBackend();
return $this->getUserModule()
->getAuthorizationChecker()
->isGrantedAsProducer($this->getUserCurrent());
}
],
],
],
'verbs' => [
'class' => VerbFilter::class,
'actions' => [
],
],
];
}


+ 3
- 6
backend/controllers/DeliveryNoteController.php Dosyayı Görüntüle

@@ -48,11 +48,6 @@ class DeliveryNoteController extends DocumentController
public function behaviors()
{
return [
'verbs' => [
'class' => VerbFilter::class,
'actions' => [
],
],
'access' => [
'class' => AccessControl::class,
'rules' => [
@@ -60,7 +55,9 @@ class DeliveryNoteController extends DocumentController
'allow' => true,
'roles' => ['@'],
'matchCallback' => function ($rule, $action) {
return $this->getUserManager()->hasAccessBackend();
return $this->getUserModule()
->getAuthorizationChecker()
->isGrantedAsProducer($this->getUserCurrent());
}
]
],

+ 6
- 2
backend/controllers/DevelopmentController.php Dosyayı Görüntüle

@@ -59,7 +59,9 @@ class DevelopmentController extends BackendController
'allow' => true,
'roles' => ['@'],
'matchCallback' => function ($rule, $action) {
return $this->getUserManager()->hasAccessBackend();
return $this->getUserModule()
->getAuthorizationChecker()
->isGrantedAsProducer($this->getUserCurrent());
}
]
],
@@ -78,7 +80,9 @@ class DevelopmentController extends BackendController
foreach ($versionsArray as $version) {
$versionsRenderArray[$version] = [
'version' => $version,
'content' => $this->renderFile('@common/versions/' . $version . '.php')
'content' => $this->renderFile('@common/versions/' . $version . '.php', [
'userCurrent' => $this->getUserCurrent()
])
];
}


+ 54
- 37
backend/controllers/DistributionController.php Dosyayı Görüntüle

@@ -75,8 +75,9 @@ class DistributionController extends BackendController
'allow' => true,
'roles' => ['@'],
'matchCallback' => function ($rule, $action) {
$userManager = $this->getUserManager();
return $userManager->isCurrentAdmin() || $userManager->isCurrentProducer();
return $this->getUserModule()
->getAuthorizationChecker()
->isGrantedAsProducer($this->getUserCurrent());
}
]
],
@@ -116,7 +117,7 @@ class DistributionController extends BackendController
$distributionManager = $this->getDistributionManager();
$orderManager = $this->getOrderManager();
$productManager = $this->getProductManager();
$userManager = $this->getUserManager();
$userModule = $this->getUserModule();

$producer = $this->getProducerCurrent();
$format = 'Y-m-d';
@@ -130,7 +131,7 @@ class DistributionController extends BackendController

if ($dateObject && $dateObject->format($format) === $date) {
$distribution = $distributionManager->createDistributionIfNotExist($date);
$ordersArray = $orderManager->findOrdersByDistribution($distribution);
$ordersArray = $orderManager->findOrdersByDistribution($distribution, false);
$ordersArrayObject = $ordersArray;
$productsArray = $productManager->findProductsByDistribution($distribution, false);

@@ -140,7 +141,7 @@ class DistributionController extends BackendController
$json['points_sale'] = $this->buildAjaxInfosResponsePointsSale($distribution);
$json['delivery_notes'] = $this->buildAjaxInfosResponseDeliveryNotes($date);
$json['order_create'] = $this->buildAjaxInfosResponseOrderCreate($distribution, $productsArray);
$json['users'] = $userManager->findUsers();
$json['users'] = $userModule->findUsers();
$json['one_distribution_week_active'] = $distributionManager->isOneDistributionWeekActive($date);
$json['tiller_is_synchro'] = $this->buildAjaxInfosResponseTiller($producer, $date);
$json['missing_subscriptions'] = $this->buildAjaxInfosResponseMissingSubscriptions($date, $distribution, $ordersArrayObject);
@@ -277,6 +278,9 @@ class DistributionController extends BackendController
'url_report_grid' => $this->getUrlManagerBackend()->createUrl(
['distribution/report-grid', 'date' => $distribution->date]
),
'url_export_shopping_cart_labels' => $this->getUrlManagerBackend()->createUrl(
['distribution/export-shopping-cart-labels', 'date' => $distribution->date]
),
];

// montant et poids des commandes
@@ -301,7 +305,7 @@ class DistributionController extends BackendController

public function buildAjaxInfosResponseOrders(array $ordersArray, array $productsArray)
{
$userManager = $this->getUserManager();
$userModule = $this->getUserModule();
$orderManager = $this->getOrderManager();
$paymentManager = $this->getPaymentManager();

@@ -341,7 +345,7 @@ class DistributionController extends BackendController
'mean_payment' => $payment->mean_payment,
'wording_mean_payment' => $paymentManager->getStrMeanPayment($payment),
'date' => date('d/m/Y H:i:s', strtotime($payment->date)),
'user' => $payment->getUserObject() ? $userManager->getUsername($payment->getUserObject()) : '',
'user' => $payment->getUserObject() ? $userModule->getUsername($payment->getUserObject()) : '',
'user_action' => $paymentManager->getStrUserAction($payment),
'wording' => $paymentManager->getStrWording($payment, $order),
'amount' => $paymentManager->getAmount($payment, Order::AMOUNT_TOTAL, true),
@@ -350,8 +354,8 @@ class DistributionController extends BackendController

$arrayCreditUser = [];
if(isset($order->user)) {
$arrayCreditUser['credit'] = $userManager->getCredit($order->user);
$arrayCreditUser['credit_active'] = $userManager->getCreditActive($order->user);
$arrayCreditUser['credit'] = $userModule->getCredit($order->user);
$arrayCreditUser['credit_active'] = $userModule->getCreditActive($order->user);
}

$oneProductUnactivated = false;
@@ -366,8 +370,8 @@ class DistributionController extends BackendController
$order = array_merge($order->getAttributes(), [
'selected' => false,
'weight' => $order->weight,
'amount' => Price::numberTwoDecimals($orderManager->getOrderAmountWithTax($order, Order::AMOUNT_TOTAL)),
'amount_paid' => Price::numberTwoDecimals($orderManager->getOrderAmount($order, Order::AMOUNT_PAID)),
'amount' => (float) Price::numberTwoDecimals($orderManager->getOrderAmountWithTax($order, Order::AMOUNT_TOTAL)),
'amount_paid' => (float) Price::numberTwoDecimals($orderManager->getOrderAmount($order, Order::AMOUNT_PAID)),
'amount_remaining' => Price::numberTwoDecimals($orderManager->getOrderAmount($order, Order::AMOUNT_REMAINING)),
'amount_surplus' => Price::numberTwoDecimals($orderManager->getOrderAmount($order, Order::AMOUNT_SURPLUS)),
'user' => (isset($order->user)) ? array_merge(
@@ -379,6 +383,7 @@ class DistributionController extends BackendController
'paymentsArray' => $paymentArray,
'oneProductUnactivated' => $oneProductUnactivated,
'isLinkedToValidDocument' => $orderManager->isLinkedToValidDocument($order),
'isLinkedToValidInvoice' => $orderManager->isLinkedToValidInvoice($order),
'isCreditAutoPayment' => $orderManager->isCreditAutoPayment($order),
'isCreditContext' => $orderManager->isCreditContext($order),
'isPaid' => $orderManager->isOrderPaid($order),
@@ -386,6 +391,7 @@ class DistributionController extends BackendController
'paymentLabelShort' => $orderManager->getPaymentLabelShort($order),
'isCreditFunctioningMandatory' => $orderManager->isOrderCreditFunctioningMandatory($order),
'isCreditFunctioningUser' => $orderManager->isOrderCreditFunctioningUser($order),
'debitCredit' => false,
]);
}
}
@@ -467,10 +473,10 @@ class DistributionController extends BackendController
public function actionAjaxPointSaleFavorite($idUser)
{
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
$userManager = $this->getUserManager();
$userModule = $this->getUserModule();
$orderManager = $this->getOrderManager();

$user = $userManager->findOneUserById($idUser);
$user = $userModule->findOneUserById($idUser);
$idFavoritePointSale = 0;

if($user) {
@@ -496,13 +502,13 @@ class DistributionController extends BackendController

$distributionManager = $this->getDistributionManager();
$orderManager = $this->getOrderManager();
$userManager = $this->getUserManager();
$userModule = $this->getUserModule();
$pointSaleManager = $this->getPointSaleManager();
$productManager = $this->getProductManager();

$order = $orderManager->findOneOrderById($idOrder);
$distribution = $distributionManager->findOneDistributionById($idDistribution);
$user = $userManager->findOneUserById($idUser);
$user = $userModule->findOneUserById($idUser);
$pointSale = $pointSaleManager->findOnePointSaleById($idPointSale);

$productsArray = Product::find()
@@ -639,6 +645,15 @@ class DistributionController extends BackendController
}
}

public function actionExportShoppingCartLabels(string $date)
{
$distributionManager = $this->getDistributionManager();
$distribution = $distributionManager->findOneDistribution($date);
if($distribution) {
return $distributionManager->generateDistributionShoppingCartLabelsPdf($distribution);
}
}

public function actionAjaxProcessProductQuantityMax($idDistribution, $idProduct, $quantityMax)
{
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
@@ -874,31 +889,33 @@ class DistributionController extends BackendController
$typePaymentTiller = 'CASH';
}

$returnTiller = $tiller->postOrder([
'externalId' => $order->id,
'type' => 1,
'status' => 'IN_PROGRESS',
'openDate' => $strDate,
'closeDate' => $strDate,
'lines' => $lines,
'payments' => [
[
'type' => $typePaymentTiller,
'amount' => $orderManager->getOrderAmountWithTax(
$order,
Order::AMOUNT_PAID
) * 100,
'status' => 'ACCEPTED',
'date' => $strDate
if(!$tiller->isSynchro($date, $order->id)) {
$returnTiller = $tiller->postOrder([
'externalId' => $order->id,
'type' => 1,
'status' => 'IN_PROGRESS',
'openDate' => $strDate,
'closeDate' => $strDate,
'lines' => $lines,
'payments' => [
[
'type' => $typePaymentTiller,
'amount' => $orderManager->getOrderAmountWithTax(
$order,
Order::AMOUNT_PAID
) * 100,
'status' => 'ACCEPTED',
'date' => $strDate
]
]
]
]);
]);

$returnTillerObject = json_decode($returnTiller);
$order->tiller_external_id = '' . $returnTillerObject->id;
$order->save();
$returnTillerObject = json_decode($returnTiller);
$order->tiller_external_id = '' . $returnTillerObject->id;
$order->save();

$return[] = $returnTiller;
$return[] = $returnTiller;
}
}
}
}

+ 7
- 10
backend/controllers/DocumentController.php Dosyayı Görüntüle

@@ -64,11 +64,6 @@ class DocumentController extends BackendController
public function behaviors()
{
return [
'verbs' => [
'class' => VerbFilter::class,
'actions' => [
],
],
'access' => [
'class' => AccessControl::class,
'rules' => [
@@ -76,7 +71,9 @@ class DocumentController extends BackendController
'allow' => true,
'roles' => ['@'],
'matchCallback' => function ($rule, $action) {
return $this->getUserManager()->hasAccessBackend();
return $this->getUserModule()
->getAuthorizationChecker()
->isGrantedAsProducer($this->getUserCurrent());
}
]
],
@@ -409,13 +406,13 @@ class DocumentController extends BackendController
if ($backUpdateForm) {
return $this->redirect([$this->getControllerUrl() . '/update', 'id' => $id]);
} else {
return $this->redirect([$this->getControllerUrl() . '/index']);
return $this->redirectReferer();
}
}

public function actionAjaxUserInfos($typeAction, $idUser, $classDocument, $idDocument = false)
{
$userManager = $this->getUserManager();
$userModule = $this->getUserModule();
$documentManager = $this->getDocumentManager();
$orderManager = $this->getOrderManager();
$producerManager = $this->getProducerManager();
@@ -424,7 +421,7 @@ class DocumentController extends BackendController
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;

if ($idUser > 0) {
$user = $userManager->findOneUserById($idUser);
$user = $userModule->findOneUserById($idUser);

if ($user) {
$document = null;
@@ -435,7 +432,7 @@ class DocumentController extends BackendController
if ($document && $document->id_user == $user->id) {
$address = $document->address;
} else {
$address = $userManager->getFullAddress($user);
$address = $userModule->getFullAddress($user);
}

$json = [

+ 12
- 13
backend/controllers/OrderController.php Dosyayı Görüntüle

@@ -69,8 +69,9 @@ class OrderController extends BackendController
'allow' => true,
'roles' => ['@'],
'matchCallback' => function ($rule, $action) {
return $this->getUserManager()->isCurrentProducer()
|| $this->getUserManager()->isCurrentAdmin();
return $this->getUserModule()
->getAuthorizationChecker()
->isGrantedAsProducer($this->getUserCurrent());
}
]
],
@@ -766,14 +767,14 @@ class OrderController extends BackendController
* @param string $commentaire
*/
public function actionAjaxCreate(
$date, $idPointSale, $idUser, $username, $meanPayment = '', $products, $comment)
$date, $idPointSale, $idUser, $username, $meanPayment = '', $products, $comment, $debitCredit = false)
{
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;

$distributionManager = $this->getDistributionManager();
$pointSaleManager = $this->getPointSaleManager();
$userPointSaleManager = $this->getUserPointSaleManager();
$userManager = $this->getUserManager();
$userModule = $this->getUserModule();
$userProducerManager = $this->getUserProducerManager();
$producerManager = $this->getProducerManager();
$productManager = $this->getProductManager();
@@ -803,7 +804,7 @@ class OrderController extends BackendController
$order->id_user = $idUser;

// commentaire du point de vente
$userPointSale = $userPointSaleManager->findOneUserPointSale($userManager->findOneUserById($idUser), $pointSale);
$userPointSale = $userPointSaleManager->findOneUserPointSale($userModule->findOneUserById($idUser), $pointSale);

if ($userPointSale && strlen($userPointSale->comment)) {
$order->comment_point_sale = $userPointSale->comment;
@@ -852,7 +853,7 @@ class OrderController extends BackendController

$order = $orderManager->findOneOrderById($order->id);
$orderManager->initOrder($order);
if ($order && $orderManager->isCreditAutoPayment($order)) {
if ($order && $orderManager->isCreditAutoPayment($order, $debitCredit)) {
$orderManager->processCredit($order);
}

@@ -885,7 +886,7 @@ class OrderController extends BackendController
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;

$orderManager = $this->getOrderManager();
$userManager = $this->getUserManager();
$userModule = $this->getUserModule();
$pointSaleManager = $this->getPointSaleManager();
$userPointSaleManager = $this->getUserPointSaleManager();
$paymentManager = $this->getPaymentManager();
@@ -900,11 +901,12 @@ class OrderController extends BackendController
$meanPayment = $request->post('meanPayment');
$products = $request->post('products');
$comment = $request->post('comment');
$debitCredit = $request->post('debitCredit');

$order = $orderManager->findOneOrderById($idOrder);
$orderManager->initOrder($order);

$user = $userManager->findOneUserById($idUser);
$user = $userModule->findOneUserById($idUser);
$pointSale = $pointSaleManager->findOnePointSaleById($idPointSale);

if ($order
@@ -957,10 +959,7 @@ class OrderController extends BackendController
$productOrder->quantity = $quantity;
$productOrder->price = $dataProductOrder->price;

if(isset($dataProductOrder->invoice_price)
&& $dataProductOrder->invoice_price
&& $dataProductOrder->invoice_price != $dataProductOrder->price) {

if(isset($dataProductOrder->invoice_price) && $dataProductOrder->invoice_price) {
$productOrder->invoice_price = $dataProductOrder->invoice_price;
}
} else {
@@ -1005,7 +1004,7 @@ class OrderController extends BackendController

$order = Order::searchOne(['id' => $order->id]);
$orderManager->initOrder($order);
if ($order && $orderManager->isCreditAutoPayment($order)) {
if ($order && $orderManager->isCreditAutoPayment($order, $debitCredit)) {
$orderManager->processCredit($order);
}
}

+ 5
- 8
backend/controllers/PointSaleController.php Dosyayı Görüntüle

@@ -55,11 +55,6 @@ class PointSaleController extends BackendController
public function behaviors()
{
return [
'verbs' => [
'class' => VerbFilter::class,
'actions' => [
],
],
'access' => [
'class' => AccessControl::class,
'rules' => [
@@ -67,7 +62,9 @@ class PointSaleController extends BackendController
'allow' => true,
'roles' => ['@'],
'matchCallback' => function ($rule, $action) {
return $this->getUserManager()->hasAccessBackend();
return $this->getUserModule()
->getAuthorizationChecker()
->isGrantedAsProducer($this->getUserCurrent());
}
],
],
@@ -153,9 +150,9 @@ class PointSaleController extends BackendController
*/
public function initForm(int $id = 0)
{
$userManager = $this->getUserManager();
$userModule = $this->getUserModule();

$users = $userManager->queryUsersBy()
$users = $userModule->queryUsersBy()
->leftJoin('user_point_sale', 'user_point_sale.id_user = user.id AND user_point_sale.id_point_sale = :id_point_sale', [':id_point_sale' => $id])
->orderBy('user_point_sale.id_point_sale DESC, lastname ASC, name ASC')
->all();

+ 6
- 4
backend/controllers/ProducerAdminController.php Dosyayı Görüntüle

@@ -68,7 +68,9 @@ class ProducerAdminController extends BackendController
'allow' => true,
'roles' => ['@'],
'matchCallback' => function ($rule, $action) {
return $this->getUserManager()->isCurrentAdmin();
return $this->getUserModule()
->getAuthorizationChecker()
->isGrantedAsAdministrator($this->getUserCurrent());
}
]
],
@@ -183,12 +185,12 @@ class ProducerAdminController extends BackendController
public function actionUserTransfer($fromProducerId, $toProducerId, $withOrders = 1)
{
$producerManager = $this->getProducerManager();
$userManager = $this->getUserManager();
$userModule = $this->getUserModule();

$fromProducerId = (int)$fromProducerId;
$toProducerId = (int)$toProducerId;
$count = 0;
$usersArray = $userManager->queryUsersBy(['id_producer' => $fromProducerId])->all();
$usersArray = $userModule->queryUsersBy(['id_producer' => $fromProducerId])->all();

foreach ($usersArray as $user) {
$idUser = $user['user_id'];
@@ -203,7 +205,7 @@ class ProducerAdminController extends BackendController

if (($withOrders && $countOrders) || !$withOrders) {
$producerManager->addUser(
$userManager->findOneUserById($idUser),
$userModule->findOneUserById($idUser),
$producerManager->findOneProducerById($toProducerId)
);
$count++;

+ 3
- 1
backend/controllers/ProducerController.php Dosyayı Görüntüle

@@ -72,7 +72,9 @@ class ProducerController extends BackendController
'allow' => true,
'roles' => ['@'],
'matchCallback' => function ($rule, $action) {
return $this->getUserManager()->hasAccessBackend();
return $this->getUserModule()
->getAuthorizationChecker()
->isGrantedAsProducer($this->getUserCurrent());
}
]
],

+ 3
- 6
backend/controllers/ProducerPriceRangeAdminController.php Dosyayı Görüntüle

@@ -53,11 +53,6 @@ class ProducerPriceRangeAdminController extends BackendController
public function behaviors()
{
return [
'verbs' => [
'class' => VerbFilter::class,
'actions' => [
],
],
'access' => [
'class' => AccessControl::class,
'rules' => [
@@ -65,7 +60,9 @@ class ProducerPriceRangeAdminController extends BackendController
'allow' => true,
'roles' => ['@'],
'matchCallback' => function ($rule, $action) {
return $this->getUserManager()->isCurrentAdmin();
return $this->getUserModule()
->getAuthorizationChecker()
->isGrantedAsAdministrator($this->getUserCurrent());
}
]
],

+ 3
- 6
backend/controllers/ProductCategoryController.php Dosyayı Görüntüle

@@ -55,11 +55,6 @@ class ProductCategoryController extends BackendController
public function behaviors()
{
return [
'verbs' => [
'class' => VerbFilter::class,
'actions' => [
],
],
'access' => [
'class' => AccessControl::class,
'rules' => [
@@ -67,7 +62,9 @@ class ProductCategoryController extends BackendController
'allow' => true,
'roles' => ['@'],
'matchCallback' => function ($rule, $action) {
return $this->getUserManager()->hasAccessBackend();
return $this->getUserModule()
->getAuthorizationChecker()
->isGrantedAsProducer($this->getUserCurrent());
}
],
],

+ 7
- 10
backend/controllers/ProductController.php Dosyayı Görüntüle

@@ -68,11 +68,6 @@ class ProductController extends BackendController
public function behaviors()
{
return [
'verbs' => [
'class' => VerbFilter::class,
'actions' => [
],
],
'access' => [
'class' => AccessControl::class,
'rules' => [
@@ -80,7 +75,9 @@ class ProductController extends BackendController
'allow' => true,
'roles' => ['@'],
'matchCallback' => function ($rule, $action) {
return $this->getUserManager()->hasAccessBackend();
return $this->getUserModule()
->getAuthorizationChecker()
->isGrantedAsProducer($this->getUserCurrent());
}
]
],
@@ -380,7 +377,7 @@ class ProductController extends BackendController
$productPriceManager = $this->getProductPriceManager();
$userGroupManager = $this->getUserGroupManager();
$pointSaleManager = $this->getPointSaleManager();
$userManager = $this->getUserManager();
$userModule = $this->getUserModule();

$model = new ProductPriceUploadForm();

@@ -416,7 +413,7 @@ class ProductController extends BackendController
$price = (float) str_replace(',', '.', $productPriceCsv[5]);

$product = $productName ? $productManager->findOneProductByName($productName) : null;
$user = (count($userArray) > 1) ? $userManager->findOneUserById((int)$userArray[1]) : null;
$user = (count($userArray) > 1) ? $userModule->findOneUserById((int)$userArray[1]) : null;
$userGroup = $userGroupName ? $userGroupManager->findOneUserGroupByName($userGroupName) : null;
$pointSale = $pointSaleName ? $pointSaleManager->findOnePointSaleByName($pointSaleName) : null;

@@ -484,7 +481,7 @@ class ProductController extends BackendController
{
$productManager = $this->getProductManager();
$productPriceManager = $this->getProductPriceManager();
$userManager = $this->getUserManager();
$userModule = $this->getUserModule();

$data = [];

@@ -517,7 +514,7 @@ class ProductController extends BackendController
if($productPrice->user || $productPrice->userGroup || $productPrice->pointSale || $productPrice->from_quantity) {
$data[] = [
$product->name,
$productPrice->user ? str_replace('#', '', $userManager->getUsername($productPrice->user)).' #'.$productPrice->user->id : '',
$productPrice->user ? str_replace('#', '', $userModule->getUsername($productPrice->user)).' #'.$productPrice->user->id : '',
$productPrice->userGroup ? $productPrice->userGroup->name : '',
$productPrice->pointSale ? $productPrice->pointSale->name : '',
$productPrice->from_quantity ?? '',

+ 3
- 8
backend/controllers/QuotationController.php Dosyayı Görüntüle

@@ -41,10 +41,8 @@ namespace backend\controllers;
use common\helpers\GlobalParam;
use common\logic\Document\Quotation\Model\QuotationSearch;
use common\logic\Order\Order\Model\Order;
use Yii;
use yii\base\UserException;
use yii\filters\AccessControl;
use yii\filters\VerbFilter;
use yii\helpers\Html;

class QuotationController extends DocumentController
@@ -52,11 +50,6 @@ class QuotationController extends DocumentController
public function behaviors()
{
return [
'verbs' => [
'class' => VerbFilter::class,
'actions' => [
],
],
'access' => [
'class' => AccessControl::class,
'rules' => [
@@ -64,7 +57,9 @@ class QuotationController extends DocumentController
'allow' => true,
'roles' => ['@'],
'matchCallback' => function ($rule, $action) {
return $this->getUserManager()->hasAccessBackend();
return $this->getUserModule()
->getAuthorizationChecker()
->isGrantedAsProducer($this->getUserCurrent());
}
]
],

+ 5
- 3
backend/controllers/ReportController.php Dosyayı Görüntüle

@@ -57,7 +57,9 @@ class ReportController extends BackendController
'allow' => true,
'roles' => ['@'],
'matchCallback' => function ($rule, $action) {
return $this->getUserManager()->hasAccessBackend();
return $this->getUserModule()
->getAuthorizationChecker()
->isGrantedAsProducer($this->getUserCurrent());
}
]
],
@@ -75,11 +77,11 @@ class ReportController extends BackendController
{
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;

$userManager = $this->getUserManager();
$userModule = $this->getUserModule();
$pointSaleManager = $this->getPointSaleManager();
$distributionManager = $this->getDistributionManager();

$usersArray = $userManager->findUsers();
$usersArray = $userModule->findUsers();
$pointsSaleArray = $pointSaleManager->findPointSales();
$firstDistribution = $distributionManager->findOneFirstDistribution();
$lastDistribution = $distributionManager->findOneLastDistribution();

+ 8
- 4
backend/controllers/SiteController.php Dosyayı Görüntüle

@@ -59,7 +59,7 @@ class SiteController extends BackendController
'class' => AccessControl::class,
'rules' => [
[
'actions' => ['login', 'error'],
'actions' => ['login', 'error', 'maintenance'],
'allow' => true,
],
[
@@ -67,7 +67,9 @@ class SiteController extends BackendController
'allow' => true,
'roles' => ['@'],
'matchCallback' => function ($rule, $action) {
return $this->getUserManager()->hasAccessBackend();
return $this->getUserModule()
->getAuthorizationChecker()
->isGrantedAsProducer($this->getUserCurrent());
}
],
[
@@ -75,7 +77,9 @@ class SiteController extends BackendController
'allow' => true,
'roles' => ['@'],
'matchCallback' => function ($rule, $action) {
return $this->getUserManager()->getCurrentStatus() == User::STATUS_ADMIN;
return $this->getUserModule()
->getAuthorizationChecker()
->isGrantedAsAdministrator($this->getUserCurrent());
}
],
],
@@ -139,7 +143,7 @@ class SiteController extends BackendController
$producer = $this->getProducerContainer()->getRepository()->findOneProducerById($id);

if($producer) {
$this->getUserContainer()->getBuilder()->switchProducer($user, $producer);
$this->getUserModule()->getServices()->getBuilder()->switchProducer($user, $producer);
}
else {
$this->addFlash('error', 'Producteur introuvable.');

+ 3
- 1
backend/controllers/StatsAdminController.php Dosyayı Görüntüle

@@ -56,7 +56,9 @@ class StatsAdminController extends BackendController
'allow' => true,
'roles' => ['@'],
'matchCallback' => function ($rule, $action) {
return $this->isUserCurrentAdmin();
return $this->getUserModule()
->getAuthorizationChecker()
->isGrantedAsAdministrator($this->getUserCurrent());
}
]
],

+ 3
- 4
backend/controllers/StatsController.php Dosyayı Görüntüle

@@ -41,9 +41,6 @@ namespace backend\controllers;
use common\helpers\GlobalParam;
use yii\filters\AccessControl;
use Yii;
use DateTime;
use DateInterval;
use DatePeriod;

class StatsController extends BackendController
{
@@ -57,7 +54,9 @@ class StatsController extends BackendController
'allow' => true,
'roles' => ['@'],
'matchCallback' => function ($rule, $action) {
return $this->getUserManager()->hasAccessBackend();
return $this->getUserModule()
->getAuthorizationChecker()
->isGrantedAsProducer($this->getUserCurrent());
}
]
],

+ 3
- 1
backend/controllers/SubscriptionController.php Dosyayı Görüntüle

@@ -58,7 +58,9 @@ class SubscriptionController extends BackendController
'allow' => true,
'roles' => ['@'],
'matchCallback' => function ($rule, $action) {
return $this->getUserManager()->hasAccessBackend();
return $this->getUserModule()
->getAuthorizationChecker()
->isGrantedAsProducer($this->getUserCurrent());
}
]
],

+ 3
- 5
backend/controllers/SupportAdminController.php Dosyayı Görüntüle

@@ -51,10 +51,6 @@ class SupportAdminController extends SupportController
public function behaviors()
{
return [
'verbs' => [
'class' => VerbFilter::class,
'actions' => [],
],
'access' => [
'class' => AccessControl::class,
'rules' => [
@@ -62,7 +58,9 @@ class SupportAdminController extends SupportController
'allow' => true,
'roles' => ['@'],
'matchCallback' => function ($rule, $action) {
return $this->getUserManager()->isCurrentAdmin();
return $this->getUserModule()
->getAuthorizationChecker()
->isGrantedAsProducer($this->getUserCurrent());
}
]
],

+ 3
- 7
backend/controllers/SupportController.php Dosyayı Görüntüle

@@ -41,7 +41,6 @@ namespace backend\controllers;
use common\logic\Ticket\Ticket\Model\Ticket;
use common\logic\Ticket\Ticket\Model\TicketSearch;
use yii\filters\AccessControl;
use yii\filters\VerbFilter;
use yii\helpers\Html;
use yii\web\NotFoundHttpException;

@@ -50,11 +49,6 @@ class SupportController extends BackendController
public function behaviors()
{
return [
'verbs' => [
'class' => VerbFilter::class,
'actions' => [
],
],
'access' => [
'class' => AccessControl::class,
'rules' => [
@@ -62,7 +56,9 @@ class SupportController extends BackendController
'allow' => true,
'roles' => ['@'],
'matchCallback' => function ($rule, $action) {
return $this->getUserManager()->hasAccessBackend();
return $this->getUserModule()
->getAuthorizationChecker()
->isGrantedAsProducer($this->getUserCurrent());
}
]
],

+ 3
- 2
backend/controllers/TaxRateAdminController.php Dosyayı Görüntüle

@@ -39,7 +39,6 @@
namespace backend\controllers;

use common\logic\Config\TaxRate\Model\TaxRate;
use Yii;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
use yii\filters\AccessControl;
@@ -66,7 +65,9 @@ class TaxRateAdminController extends BackendController
'allow' => true,
'roles' => ['@'],
'matchCallback' => function ($rule, $action) {
return $this->isUserCurrentAdmin();
return $this->getUserModule()
->getAuthorizationChecker()
->isGrantedAsAdministrator($this->getUserCurrent());
}
]
],

+ 32
- 32
backend/controllers/UserController.php Dosyayı Görüntüle

@@ -41,12 +41,10 @@ namespace backend\controllers;
use backend\models\CreditForm;
use common\helpers\GlobalParam;
use backend\models\MailForm;
use common\helpers\MeanPayment;
use common\helpers\Password;
use common\logic\Order\Order\Model\OrderSearch;
use common\logic\PointSale\PointSale\Model\PointSale;
use common\logic\PointSale\UserPointSale\Model\UserPointSale;
use common\logic\Payment\Model\Payment;
use common\logic\User\User\Model\User;
use common\logic\User\User\Model\UserSearch;
use common\logic\User\UserProducer\Model\UserProducer;
@@ -72,7 +70,9 @@ class UserController extends BackendController
'allow' => true,
'roles' => ['@'],
'matchCallback' => function ($rule, $action) {
return $this->getUserManager()->hasAccessBackend();
return $this->getUserModule()
->getAuthorizationChecker()
->isGrantedAsProducer($this->getUserCurrent());
}
]
],
@@ -120,15 +120,15 @@ class UserController extends BackendController

public function actionCreate()
{
$userManager = $this->getUserManager();
$userModule = $this->getUserModule();
$producerManager = $this->getProducerManager();
$producerCurrent = $this->getProducerCurrent();
$model = $userManager->instanciateUser();
$model = $userModule->instanciateUser();
$posts = Yii::$app->request->post();
$userExist = false;

if ($posts && isset($posts['User']['email']) && strlen($posts['User']['email']) > 0) {
$userExist = $userManager->findOneUserByEmail($posts['User']['email']);
$userExist = $userModule->findOneUserByEmail($posts['User']['email']);
}

if ($userExist) {
@@ -140,8 +140,8 @@ class UserController extends BackendController
if ($model->load(\Yii::$app->request->post()) && $model->validate() && YII_ENV != 'demo') {
$model->id_producer = 0;
$password = Password::generate();
$userManager->setPassword($model, $password);
$userManager->generateAuthKey($model);
$userModule->setPassword($model, $password);
$userModule->generateAuthKey($model);
$model->username = $model->email;
if (!strlen($model->email)) {
$model->username = 'inconnu@opendistrib.net';
@@ -158,13 +158,13 @@ class UserController extends BackendController
$useProducer->newsletter = $model->newsletter;
$useProducer->save();

$userManager->sendMailWelcome($model, $password);
$userModule->sendMailWelcome($model, $password);
$this->processLinkPointSale($model);
$this->processLinkUserGroup($model);
$this->processProductPricePercent($model);

$this->setFlash('success', 'Utilisateur créé.');
$model = $userManager->instanciateUser();
$model = $userModule->instanciateUser();
}
}

@@ -176,7 +176,7 @@ class UserController extends BackendController

public function actionUpdate($id)
{
$userManager = $this->getUserManager();
$userModule = $this->getUserModule();
$pointSaleManager = $this->getPointSaleManager();

$model = $this->findModel($id);
@@ -190,22 +190,22 @@ class UserController extends BackendController
// on envoie le mail de bienvenue si le mail vient d'être défini
if (!strlen($previousMail) && strlen($model->email)) {
$password = Password::generate();
$userManager->setPassword($model, $password);
$userModule->setPassword($model, $password);
$model->username = $model->email;
$userManager->sendMailWelcome($model, $password);
$userModule->sendMailWelcome($model, $password);
}
$this->processLinkPointSale($model);
$this->processLinkUserGroup($model);
$this->processProductPricePercent($model);

if($model->newsletter) {
$userManager->subscribeUserNewsletter($model);
$userModule->subscribeUserNewsletter($model);
}
else {
$userManager->unsubscribeUserNewsletter($model);
$userModule->unsubscribeUserNewsletter($model);
}

$this->setFlash('success', 'Utilisateur <strong>'.Html::encode($userManager->getUsername($model)).'</strong> modifié.');
$this->setFlash('success', 'Utilisateur <strong>'.Html::encode($userModule->getUsername($model)).'</strong> modifié.');

return $this->redirect(['index']);
}
@@ -217,7 +217,7 @@ class UserController extends BackendController
$newPassword = Yii::$app->request->post('submit_new_password');
if ($newPassword) {
$password = Password::generate();
$userManager->setPassword($model, $password);
$userModule->setPassword($model, $password);
$model->save();

$producer = $this->getProducerCurrent();
@@ -234,7 +234,7 @@ class UserController extends BackendController
$producer
);

$this->setFlash('success', 'Nouveau mot de passe envoyé à <strong>'.Html::encode($userManager->getUsername($model)).'</strong>.');
$this->setFlash('success', 'Nouveau mot de passe envoyé à <strong>'.Html::encode($userModule->getUsername($model)).'</strong>.');

return $this->redirect(['index']);
}
@@ -361,10 +361,10 @@ class UserController extends BackendController
*/
public function actionDelete(int $id)
{
$userManager = $this->getUserManager();
$userModule = $this->getUserModule();
$userProducerManager = $this->getUserProducerManager();

$user = $userManager->findOneUserById($id);
$user = $userModule->findOneUserById($id);
$userProducer = $userProducerManager->findOneUserProducer($user);

if ($userProducer) {
@@ -390,11 +390,11 @@ class UserController extends BackendController
*/
public function actionCredit(int $id)
{
$userManager = $this->getUserManager();
$userModule = $this->getUserModule();
$paymentContainer = $this->getPaymentContainer();
$userProducerContainer = $this->getUserProducerContainer();

$user = $userManager->findOneUserById($id);
$user = $userModule->findOneUserById($id);
$userProducer = $userProducerContainer->getRepository()->findOneUserProducer($user);

if ($userProducer) {
@@ -435,10 +435,10 @@ class UserController extends BackendController
*/
public function actionStateCredit($idUser, $state)
{
$userManager = $this->getUserManager();
$userModule = $this->getUserModule();
$userProducerManager = $this->getUserProducerManager();

$user = $userManager->findOneUserById($idUser);
$user = $userModule->findOneUserById($idUser);
$userProducer = $userProducerManager->findOneUserProducer($user);

if ($userProducer) {
@@ -457,9 +457,9 @@ class UserController extends BackendController
*/
public function actionOrders($id)
{
$userManager = $this->getUserManager();
$userModule = $this->getUserModule();

$user = $userManager->findOneUserById($id);
$user = $userModule->findOneUserById($id);
$searchModel = new OrderSearch();
$dataProvider = $searchModel->search(array_merge(\Yii::$app->request->queryParams, ['id_user' => $id]));

@@ -476,9 +476,9 @@ class UserController extends BackendController
*/
protected function findModel($id)
{
$userManager = $this->getUserManager();
$userModule = $this->getUserModule();

if (($user = $userManager->findOneUserById($id)) !== null) {
if (($user = $userModule->findOneUserById($id)) !== null) {
return $user;
} else {
throw new NotFoundHttpException("Utilisateur introuvable");
@@ -495,14 +495,14 @@ class UserController extends BackendController
$usersPointSaleLink = 0,
$usersPointSaleHasOrder = 0)
{
$userManager = $this->getUserManager();
$userModule = $this->getUserModule();
$distributionManager = $this->getDistributionManager();

if ($idPointSale && !$usersPointSaleLink && !$usersPointSaleHasOrder) {
$usersPointSaleLink = 1;
}

$users = $userManager->queryUsersBy([
$users = $userModule->queryUsersBy([
'id_producer' => GlobalParam::getCurrentProducerId(),
'id_point_sale' => $idPointSale,
'users_point_sale_link' => $usersPointSaleLink,
@@ -578,11 +578,11 @@ class UserController extends BackendController

public function actionSwitchIdentity(int $id)
{
$userManager = $this->getUserManager();
$userModule = $this->getUserModule();
if($this->isUserCurrentAdmin()) {
$initialId = Yii::$app->user->getId();
if($initialId != $id) {
$user = $userManager->findOneUserById($id);
$user = $userModule->findOneUserById($id);
$duration = 0;
Yii::$app->user->switchIdentity($user, $duration);
Yii::$app->session->set('user.idbeforeswitch',$initialId);

+ 3
- 8
backend/controllers/UserGroupController.php Dosyayı Görüntüle

@@ -41,10 +41,8 @@ namespace backend\controllers;
use common\helpers\GlobalParam;
use common\logic\User\UserGroup\Model\UserGroupSearch;
use common\logic\User\UserUserGroup\Model\UserUserGroup;
use Yii;
use yii\filters\AccessControl;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
use yii\helpers\Html;

/**
@@ -56,11 +54,6 @@ class UserGroupController extends BackendController
public function behaviors()
{
return [
'verbs' => [
'class' => VerbFilter::class,
'actions' => [
],
],
'access' => [
'class' => AccessControl::class,
'rules' => [
@@ -68,7 +61,9 @@ class UserGroupController extends BackendController
'allow' => true,
'roles' => ['@'],
'matchCallback' => function ($rule, $action) {
return $this->getUserManager()->hasAccessBackend();
return $this->getUserModule()
->getAuthorizationChecker()
->isGrantedAsProducer($this->getUserCurrent());
}
],
],

+ 5
- 5
backend/models/CreditForm.php Dosyayı Görüntüle

@@ -40,7 +40,7 @@ namespace backend\models;

use common\helpers\GlobalParam;
use common\logic\Payment\Wrapper\PaymentManager;
use common\logic\User\User\Wrapper\UserManager;
use common\logic\User\User\Wrapper\UserModule;
use common\logic\User\UserProducer\Wrapper\UserProducerManager;
use yii\base\Model;

@@ -57,7 +57,7 @@ class CreditForm extends Model
public $amount ;
public $mean_payment ;
public $comment ;
public $send_mail ;
public $send_mail = 1;

/**
* @inheritdoc
@@ -97,13 +97,13 @@ class CreditForm extends Model
*/
public function save()
{
$userManager = UserManager::getInstance();
$userModule = UserModule::getInstance();
$userProducerManager = UserProducerManager::getInstance();
$paymentManager = PaymentManager::getInstance();

if ($this->validate()) {
$user = $userManager->findOneUserById($this->id_user);
$paymentManager->creditOrDebitUser($this->type, $user, $this->amount, $this->mean_payment, $userManager->getCurrent(), $this->comment);
$user = $userModule->findOneUserById($this->id_user);
$paymentManager->creditOrDebitUser($this->type, $user, $this->amount, $this->mean_payment, $userModule->getCurrent(), $this->comment);
// on prévient l'utilisateur que son compte vient d'être crédité
if($this->send_mail) {

+ 2
- 2
backend/views/access/index.php Dosyayı Görüntüle

@@ -40,7 +40,7 @@ use yii\helpers\Html ;
use yii\widgets\ActiveForm;
use yii\helpers\ArrayHelper ;

$userManager = $this->getUserManager();
$userModule = $this->getUserModule();

$this->setTitle('Accès') ;

@@ -55,7 +55,7 @@ $this->setTitle('Accès') ;
</div>
<div class="panel-body">
<?php $form = ActiveForm::begin(); ?>
<?= $form->field($modelAccessUserProducerForm, 'id_user')->dropDownList( $userManager->populateUserDropdownList(), ['class' => 'select2'])->label(''); ?>
<?= $form->field($modelAccessUserProducerForm, 'id_user')->dropDownList( $userModule->populateUserDropdownList(), ['class' => 'select2'])->label(''); ?>
<?= Html::submitButton('Ajouter', ['class' => 'btn btn-success']) ?>
<?php ActiveForm::end(); ?>
</div>

+ 3
- 3
backend/views/credit/index.php Dosyayı Görüntüle

@@ -3,7 +3,7 @@
use common\helpers\Price;
use yii\grid\GridView;

$userManager = $this->getUserManager();
$userModule = $this->getUserModule();

$this->setTitle('Crédit');

@@ -43,8 +43,8 @@ GridView::widget([
'columns' => [
[
'label' => 'Client',
'value' => function ($user) use ($userManager) {
return $userManager->getUsernameFromArray($user, true);
'value' => function ($user) use ($userModule) {
return $userModule->getUsernameFromArray($user, true);
}
],
[

+ 4
- 4
backend/views/dashboard/index.php Dosyayı Görüntüle

@@ -41,10 +41,10 @@ use common\logic\Order\Order\Model\Order;
use common\logic\Order\Order\Wrapper\OrderManager;
use common\logic\Producer\Producer\Wrapper\ProducerManager;
use common\logic\Subscription\Subscription\Wrapper\SubscriptionManager;
use common\logic\User\User\Wrapper\UserManager;
use common\logic\User\User\Wrapper\UserModule;
use yii\helpers\Html ;

$userManager = UserManager::getInstance();
$userModule = UserModule::getInstance();
$orderManager = OrderManager::getInstance();
$subscriptionManager = SubscriptionManager::getInstance();
$producerManager = ProducerManager::getInstance();
@@ -158,7 +158,7 @@ $this->setTitle('Tableau de bord');
<?php foreach($subscriptionsLatestAddedArray as $subscription): ?>
<tr>
<td><?= date('d/m/Y à H:i', strtotime($subscription->created_at)); ?></td>
<td><?= $userManager->getUsername($subscription->user); ?></td>
<td><?= $userModule->getUsername($subscription->user); ?></td>
<td><?= Html::encode($subscription->pointSale->name); ?></td>
<td><?= $subscriptionManager->getProductsListAsHtml($subscription); ?></td>
<td><?= $subscriptionManager->getDaysAsHtml($subscription); ?></td>
@@ -219,7 +219,7 @@ $this->setTitle('Tableau de bord');
<div class="comment"><span class="glyphicon glyphicon-comment"></span> <?= nl2br(Html::encode($order->comment)) ; ?></div>
<?php endif; ?>
</td>
<td><?= $orderManager->getCartSummary($order) ; ?></td>
<td><?= $orderManager->getCartSummary($order); ?></td>
<td><?= $orderManager->getPointSaleSummary($order) ; ?></td>
<td><?= $orderManager->getOrderAmountWithTax($order, Order::AMOUNT_TOTAL, true) ; ?></td>
<td class="history"><?= $orderManager->getHistorySummary($order) ; ?></td>

+ 1
- 1
backend/views/development/development.php Dosyayı Görüntüle

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


if ($this->getUserManager()->hasAccessBackend()) {
if ($this->getUserModule()->hasAccessBackend()) {

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

+ 19
- 66
backend/views/distribution/index.php Dosyayı Görüntüle

@@ -210,12 +210,11 @@ $this->setPageTitle('Distributions') ;
<div class="info-box-content">
<span class="info-box-text">
{{ countOrders }} Commande<span v-if="countOrders > 1">s</span><br />
<a :href="distribution.url_report" class="btn btn-xs btn-default" v-if="countOrders > 0">Liste (PDF)</a>
<a :href="distribution.url_report+'&type=csv'" class="btn btn-xs btn-default" v-if="countOrders > 0">Tableau (CSV)</a>

<br v-if="producer && producer.option_display_export_grid && countOrders > 0" />
<br />
<a :href="distribution.url_report_grid" class="btn btn-xs btn-default" v-if="producer && producer.option_display_export_grid && countOrders > 0">Grille (PDF)</a>
<a :href="distribution.url_export_shopping_cart_labels" class="btn btn-xs btn-default" v-if="countOrders > 0">Étiquettes (PDF)</a>
</span>
</div>
</div>
@@ -383,7 +382,7 @@ $this->setPageTitle('Distributions') ;
</template>
</td>
<td class="column-amount">
{{ order.amount.replace(/(\d)(?=(\d{3})+(?:\.\d+)?$)/g, "$1,")+'&nbsp;€' }}
{{ order.amount.toFixed(2)+'&nbsp;€' }}
<div class="state-payment-mobile">
<order-state-payment :order="order" :producer="producer"></order-state-payment>
</div>
@@ -393,6 +392,15 @@ $this->setPageTitle('Distributions') ;
<order-state-payment :order="order" :producer="producer"></order-state-payment>
</a>
<span class="glyphicon glyphicon-time" title="Débit automatique du crédit la veille de la distribution" v-if="order.amount != 0 && order.auto_payment && (order.amount_paid == 0 || order.amount_paid < order.amount)"></span>

<div v-if="order.amount_paid > 0 && order.amount_paid < order.amount">
<span class="glyphicon glyphicon-alert"></span> Reste à payer
</div>
<div v-if="order.amount_paid > order.amount">
<span class="glyphicon glyphicon-alert"></span> Surplus à rembourser
{{ order.amount_paid }} /
{{ order.amount }}
</div>
</td>
<td class="column-credit" v-if="!idActivePointSale || (pointSaleActive && pointSaleActive.credit == 1)">
<template v-if="order.isCreditContext">
@@ -401,31 +409,6 @@ $this->setPageTitle('Distributions') ;
</a>
</template>
</td>
<td class="column-payment" v-if="false && producer && producer.credit">
<!--<div class="btn-group" v-if="order.user && !order.date_delete">
<button class="btn btn-xs btn-default" v-if="order.amount_paid == order.amount" @click="orderPaymentClick" :data-id-order="order.id" data-type="refund" :data-amount="order.amount">
<span class="glyphicon glyphicon-euro"></span> Recréditer
</button>
<button class="btn btn-xs btn-default" v-else-if="order.amount_paid == 0" @click="orderPaymentClick" :data-id-order="order.id" data-type="payment" :data-amount="order.amount">
<span class="glyphicon glyphicon-euro"></span> Débiter
</button>
<button class="btn btn-xs btn-default" v-else-if="order.amount_paid < order.amount" @click="orderPaymentClick" :data-id-order="order.id" data-type="payment" :data-amount="order.amount_remaining">
<span class="glyphicon glyphicon-euro"></span> Débiter
</button>
<button class="btn btn-xs btn-default" v-else-if="order.amount_paid > order.amount" @click="orderPaymentClick" :data-id-order="order.id" data-type="refund" :data-amount="order.amount_surplus">
<span class="glyphicon glyphicon-euro"></span> Recréditer
</button>

<button type="button" class="btn btn-xs btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="caret"></span>
<span class="sr-only">Toggle Dropdown</span>
</button>
<ul class="dropdown-menu">
<li><a href="javascript:void(0);" @click="orderPaymentModalClick" :data-id-order="order.id">Historique</a></li>
</ul>
</div>-->
</td>

<td class="column-actions">
<span v-if="false && order.oneProductUnactivated" class="glyphicon glyphicon-warning-sign" title="Contient un produit non activé"></span>

@@ -461,11 +444,6 @@ $this->setPageTitle('Distributions') ;
</li>
</template>
</template>
<!--<li>
<a href="javascript:void(0);" @click="orderPaymentClick" :data-id-order="order.id" :data-type="getTypePayment(order)" data-mean-payment="credit-card">
{{ getLabelPaymentRefund(order, 'Payer', 'Rembourser', 'par carte bancaire') }}
</a>
</li>-->
<li>
<a href="javascript:void(0);" @click="orderPaymentModalClick" :data-id-order="order.id">
<span class="glyphicon glyphicon-th-list"></span> Historique
@@ -507,8 +485,6 @@ $this->setPageTitle('Distributions') ;
<span class="caret"></span>
</button>
<ul class="dropdown-menu">
<!--<li><a href="javascript:void(0);" class="" :data-id-order="order.id" @click="orderViewClick"><span :class="'glyphicon ' + ((showViewProduct && idOrderView == order.id) ? 'glyphicon-eye-close' : 'glyphicon-eye-open')"></span> Voir</a></li>
<li><a href="javascript:void(0);" class="" :data-id-order="order.id" @click="updateOrderClick"><span class="glyphicon glyphicon-pencil"></span> Modifier</a></li>-->
<li><a href="javascript:void(0);" class="" :data-id-order="order.id" @click="deleteOrderClick"><span class="glyphicon glyphicon-trash"></span> Supprimer</a></li>
<li v-if="order.id_subscription > 0"><a class="" :href="baseUrl+'/subscription/update?id='+order.id_subscription"><span class="glyphicon glyphicon-repeat"></span> Modifier l'abonnement lié</a></li>
<li v-else><a class="add-subscription" :href="baseUrl+'/subscription/create?idOrder='+order.id"><span class="glyphicon glyphicon-plus"></span><span class="glyphicon glyphicon-repeat"></span>Créer un abonnement</a></li>
@@ -550,7 +526,7 @@ $this->setPageTitle('Distributions') ;
<div class="info-box-content">
<span class="info-box-text">Montant</span>
<span class="info-box-number">
{{ order.amount.replace(/(\d)(?=(\d{3})+(?:\.\d+)?$)/g, "$1,")+' €' }}
{{ order.amount.toFixed(2)+' €' }}
</span>
</div>
</div>
@@ -640,19 +616,7 @@ $this->setPageTitle('Distributions') ;
</div>

<script type="text/x-template" id="order-state-payment">


<span v-html="order.paymentLabelShort"></span>

<!--<span class="glyphicon glyphicon-signal" title="Paiement partiel ou surplus" v-if="order.amount_paid > order.amount || order.amount_paid < order.amount"></span>-->

<!--<span class="label label-success" v-if="order.amount_paid == order.amount">&nbsp;</span>
<span class="label label-default" v-else-if="order.amount_paid == 0">&nbsp;</span>-->

<!--<span class="label label-success input-group-addon" v-if="order.amount_paid == order.amount">débité</span>
<span class="label label-default input-group-addon" v-else-if="order.amount_paid == 0">non débité</span>
<span class="label label-default input-group-addon" v-else-if="order.amount_paid > order.amount">surplus</span>
<span class="label label-warning input-group-addon" v-else-if="order.amount_paid < order.amount">reste à débiter</span>-->
</script>

<!-- template for the order-form component -->
@@ -695,17 +659,14 @@ $this->setPageTitle('Distributions') ;
<option v-for="pointSale in pointsSale" v-if="pointSale.pointSaleDistribution[0].delivery == 1" :value="pointSale.id"">{{ pointSale.name }}</option>
</select>
</div>
<div class="form-group">
<!--<label class="control-label" for="select-mean-payment">Moyen de paiement</label>
<select class="form-control" id="select-mean-payment" v-model="order.mean_payment">
<option value="0">--</option>
<option v-for="(wordingMeanPayment, keyMeanPayment) in meansPayment" :value="keyMeanPayment">{{ wordingMeanPayment }}</option>
</select>-->
</div>
<div class="form-group">
<label class="control-label" for="textarea-comment">Commentaire</label>
<textarea class="form-control" id="textarea-comment" v-model="order.comment"></textarea>
</div>
<div class="form-group" v-if="isPointSaleCreditFunctioningOptional(order.id_point_sale)">
<input type="checkbox" id="debit-credit" v-model="order.debitCredit" />
<label class="control-label" for="debit-credit">Débiter le crédit</label>
</div>
</div>
<div class="col-md-8">
<label class="control-label">Produits</label>
@@ -738,7 +699,8 @@ $this->setPageTitle('Distributions') ;
<div class="invoice-price" v-show="vatMode == 'all'" v-if="(order.id_invoice || order.id_delivery_note || order.id_quotation) && order.productOrder[product.id].quantity > 0">
<span class="label-invoice-price">Prix facturé</span><br />
<div class="input-group">
<input type="text" v-model="order.productOrder[product.id].invoice_price" class="form-control input-sm" :data-id-product="product.id" />
<input v-if="order.isLinkedToValidInvoice" type="text" v-model="order.productOrder[product.id].invoice_price" class="form-control input-sm" :data-id-product="product.id" disabled="disabled" title="La commande est liée à une facture validée, le prix facturé n'est donc plus modifiable" />
<input v-else type="text" v-model="order.productOrder[product.id].invoice_price" class="form-control input-sm" :data-id-product="product.id" />
<span class="input-group-addon" id="basic-addon2">€ HT</span>
</div>
</div>
@@ -789,15 +751,6 @@ $this->setPageTitle('Distributions') ;
</modal>
</script>

<script type="text/x-template" id="order-state-payment">
<div class="input-group">
<span class="label label-success input-group-addon" v-if="order.amount_paid == order.amount">payé</span>
<span class="label label-default input-group-addon" v-else-if="order.amount_paid == 0">non réglé</span>
<span class="label label-default input-group-addon" v-else-if="order.amount_paid > order.amount">surplus</span>
<span class="label label-warning input-group-addon" v-else-if="order.amount_paid < order.amount">reste à débiter</span>
</div>
</script>

<!-- template for the modal component -->
<script type="text/x-template" id="modal-template">
<transition name="modal">

+ 25
- 0
backend/views/distribution/shopping-cart-labels.php Dosyayı Görüntüle

@@ -0,0 +1,25 @@
<?php

use common\logic\Order\Order\Wrapper\OrderManager;
use yii\helpers\Html;

$orderManager = OrderManager::getInstance();
$index = 0

?>
<?php foreach($ordersArray as $order): ?>
<div class="shopping-cart-label shopping-cart-label-<?= $index ?>">
<div class="inner">
<div class="username">
<?= $orderManager->getOrderUsername($order); ?>
</div>
<div class="point-sale">
<?= Html::encode($order->pointSale->name); ?> &bull; <?= date('d/m', strtotime($distribution->date)); ?>
</div>
<div class="products">
<?= $orderManager->getCartSummary($order); ?>
</div>
</div>
</div>
<?php $index = ($index == 5) ? 0 : $index + 1; ?>
<?php endforeach; ?>

+ 4
- 4
backend/views/document/_form.php Dosyayı Görüntüle

@@ -38,7 +38,7 @@

use common\helpers\MeanPayment;use common\helpers\Price;use common\logic\Document\Document\Wrapper\DocumentManager;
use common\logic\Document\Invoice\Wrapper\InvoiceManager;use common\logic\Payment\Wrapper\PaymentManager;use common\logic\Producer\Producer\Wrapper\ProducerManager;
use common\logic\User\User\Wrapper\UserManager;
use common\logic\User\User\Wrapper\UserModule;
use yii\helpers\Html;
use yii\widgets\ActiveForm;

@@ -47,7 +47,7 @@ use yii\widgets\ActiveForm;
$producerManager = ProducerManager::getInstance();
$documentManager = DocumentManager::getInstance();
$invoiceManager = InvoiceManager::getInstance();
$userManager = UserManager::getInstance();
$userModule = UserModule::getInstance();
$paymentManager = PaymentManager::getInstance();

$documentClass = $documentManager->getClass($model);
@@ -73,14 +73,14 @@ $documentClass = $documentManager->getClass($model);

<?php if ($action == 'update'): ?>
<?= $form->field($model, 'id_user', [
'template' => '{label} <div>{input}</div>' . $userManager->getUsername($model->user),
'template' => '{label} <div>{input}</div>' . $userModule->getUsername($model->user),
])->hiddenInput(); ?>
<?php else: ?>
<?= $form->field($model, 'id_user', [
'template' => '{label} <a href="' . Yii::$app->urlManager->createUrl(['user/create']) . '" class="btn btn-xs btn-default">Nouvel utilisateur <span class="glyphicon glyphicon-plus"></span></a><div>{input}</div>{hint}',
])
->dropDownList(
$userManager->populateUserDropdownList(),
$userModule->populateUserDropdownList(),
[
'@change' => 'changeUser',
'v-model' => 'idUser',

+ 2
- 2
backend/views/document/download.php Dosyayı Görüntüle

@@ -5,7 +5,7 @@ use common\logic\Order\Order\Model\Order;
use common\helpers\Price;

$producerManager = $this->getProducerManager();
$userManager = $this->getUserManager();
$userModule = $this->getUserModule();
$documentManager = $this->getDocumentManager();
$orderManager = $this->getOrderManager();

@@ -37,7 +37,7 @@ $documentPriceDecimals = (int) $producerManager->getConfig('option_document_pric
<?php if ($document->address && strlen($document->address) > 0): ?>
<?= nl2br($document->address) ?>
<?php else: ?>
<?= $userManager->getFullAddress($document->user, true); ?>
<?= $userModule->getFullAddress($document->user, true); ?>
<?php endif; ?>
</div>
</div>

+ 3
- 3
backend/views/invoice/index.php Dosyayı Görüntüle

@@ -44,7 +44,7 @@ use common\logic\Order\Order\Model\Order;

$producerManager = $this->getProducerManager();
$invoiceManager = $this->getInvoiceManager();
$userManager = $this->getUserManager();
$userModule = $this->getUserModule();

$this->setTitle('Factures');
$this->addBreadcrumb($this->getTitle());
@@ -87,8 +87,8 @@ $this->addButton(['label' => 'Nouvelle facture <span class="glyphicon glyphicon-
'headerOptions' => ['class' => 'column-hide-on-mobile'],
'filterOptions' => ['class' => 'column-hide-on-mobile'],
'contentOptions' => ['class' => 'column-hide-on-mobile'],
'value' => function ($invoice) use ($userManager) {
return $userManager->getUsername($invoice->user);
'value' => function ($invoice) use ($userModule) {
return $userModule->getUsername($invoice->user);
}
],
[

+ 8
- 9
backend/views/layouts/header.php Dosyayı Görüntüle

@@ -38,23 +38,22 @@

use common\helpers\Price;
use common\logic\Producer\Producer\Wrapper\ProducerManager;
use common\logic\User\User\Wrapper\UserManager;
use common\logic\User\User\Wrapper\UserModule;
use yii\helpers\Html;
use common\helpers\GlobalParam;

use common\logic\Distribution\Distribution\Model\Distribution;
use common\logic\Producer\Producer\Model\Producer;

$userManager = UserManager::getInstance();
$userModule = UserModule::getInstance();
$producerManager = ProducerManager::getInstance();
$producer = GlobalParam::getCurrentProducer();
$userCurrent = GlobalParam::getCurrentUser();

?>

<header class="main-header">

<!-- <?= Html::a('<span class="logo-mini"><img src="' . Yii::$app->urlManagerBackend->getBaseUrl() . '/img/logo-distrib.png" /></span><span class="logo-lg"><img src="' . Yii::$app->urlManagerBackend->getBaseUrl() . '/img/logo-distrib.png" /></span>', Yii::$app->homeUrl, ['class' => 'logo']) ?>-->

<?= Html::a('Opendistrib', Yii::$app->homeUrl, ['class' => 'logo']); ?>

<nav class="navbar navbar-static-top" role="navigation">
@@ -82,7 +81,7 @@ $producer = GlobalParam::getCurrentProducer();
<div class="navbar-custom-menu">
<?php

$usersArray = $userManager->queryUsersBy(['id_producer' => GlobalParam::getCurrentProducerId()])
$usersArray = $userModule->queryUsersBy(['id_producer' => GlobalParam::getCurrentProducerId()])
->andWhere('CAST(FROM_UNIXTIME(user.created_at) AS date) > \'' . date("Y-m-d", strtotime("-7 days")) . '\'')
->orderBy('created_at DESC')
->all();
@@ -91,7 +90,7 @@ $producer = GlobalParam::getCurrentProducer();

<ul class="nav navbar-nav">

<?php if ($userManager->isCurrentAdmin()): ?>
<?php if ($userModule->getAuthorizationChecker()->isGrantedAsAdministrator($userCurrent)): ?>
<li class="dropdown producer-menu">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
<span class="glyphicon glyphicon-grain"></span>
@@ -232,7 +231,7 @@ $producer = GlobalParam::getCurrentProducer();

<?php

$usersNegativeCreditArray = $userManager->findUsersWithNegativeCredit();
$usersNegativeCreditArray = $userModule->findUsersWithNegativeCredit();

?>

@@ -252,7 +251,7 @@ $producer = GlobalParam::getCurrentProducer();
<?php foreach ($usersNegativeCreditArray as $user): ?>
<li>
<a href="<?= Yii::$app->urlManagerBackend->createUrl(['user/credit', 'id' => $user['user_id']]); ?>">
<h5><?= $userManager->getUsernameFromArray($user); ?>
<h5><?= $userModule->getUsernameFromArray($user); ?>
<small>
<i class="fa fa-euro"></i> <?= Price::format($user['credit']); ?>
</small>
@@ -268,7 +267,7 @@ $producer = GlobalParam::getCurrentProducer();
</ul>

</li>
<?php if ($userManager->isCurrentProducer() || $userManager->isCurrentAdmin()): ?>
<?php if ($userModule->getAuthorizationChecker()->isGrantedAsProducer($userCurrent)): ?>
<li>
<a href="<?= Yii::$app->urlManagerProducer->createAbsoluteUrl(['site/index', 'slug_producer' => GlobalParam::getCurrentProducer()->slug]); ?>">
<span class="glyphicon glyphicon-eye-open"></span>

+ 49
- 46
backend/views/layouts/left.php Dosyayı Görüntüle

@@ -37,15 +37,18 @@
*/

use common\helpers\GlobalParam;
use common\helpers\Opendistrib;
use yii\helpers\Html;
use common\logic\Ticket\Ticket\Wrapper\TicketManager;
use common\logic\User\User\Wrapper\UserModule;

$producerManager = $this->getProducerManager();
$userManager = $this->getUserManager();
$userModule = UserModule::getInstance();
$userProducerManager = $this->getUserProducerManager();
$ticketManager = $this->getTicketManager();

$producer = GlobalParam::getCurrentProducer();
$userCurrent = GlobalParam::getCurrentUser();
$isUserCurrentGrantedAsAdministrator = $userModule->getAuthorizationChecker()->isGrantedAsAdministrator($userCurrent);
$isUserCurrentGrantedAsProducer = $userModule->getAuthorizationChecker()->isGrantedAsProducer($userCurrent);


?>

@@ -61,13 +64,13 @@ $producer = GlobalParam::getCurrentProducer();

$countTicketsProducerUnreadLabel = '';
$countTicketsProducerUnread = $ticketManager->countTicketsUnreadByUser($this->getUserCurrent());
if($countTicketsProducerUnread && !$userManager->isCurrentAdmin()) {
if($countTicketsProducerUnread && !$isUserCurrentGrantedAsAdministrator) {
$countTicketsProducerUnreadLabel = '<span class="pull-right-container"><small class="label pull-right bg-green">'.$countTicketsProducerUnread.'</small></span>';
}

$countTicketsAdminUnreadLabel = '';
$countTicketsAdminUnread = $ticketManager->countTicketsAdminUnreadByUser($this->getUserCurrent());
if($countTicketsAdminUnread && $userManager->isCurrentAdmin()) {
if($countTicketsAdminUnread && $isUserCurrentGrantedAsAdministrator) {
$countTicketsAdminUnreadLabel = '<span class="pull-right-container"><small class="label pull-right bg-green">'.$countTicketsAdminUnread.'</small></span>';
}

@@ -81,56 +84,56 @@ $producer = GlobalParam::getCurrentProducer();
[
'options' => ['class' => 'sidebar-menu tree', 'data-widget' => 'tree'],
'items' => [
['label' => "Besoin d'aide ?", 'options' => ['class' => 'header'], 'visible' => $userManager->isCurrentProducer()],
['label' => "Besoin d'aide ?", 'options' => ['class' => 'header'], 'visible' => $isUserCurrentGrantedAsProducer],
[
'label' => 'Support',
'icon' => 'comments',
'url' => ['support/index'],
'visible' => $userManager->isCurrentProducer(),
'visible' => $isUserCurrentGrantedAsProducer,
'template' => '<a href="{url}">{icon} {label}' . $countTicketsProducerUnreadLabel . '</a>'
],
['label' => $producer->name, 'options' => ['class' => 'header'], 'visible' => $userManager->isCurrentProducer()],
['label' => 'Tableau de bord', 'icon' => 'dashboard', 'url' => ['/dashboard/index'], 'visible' => $userManager->isCurrentProducer()],
['label' => 'Distributions', 'icon' => 'calendar', 'url' => ['/distribution/index'], 'visible' => $userManager->isCurrentProducer()],
['label' => $producer->name, 'options' => ['class' => 'header'], 'visible' => $isUserCurrentGrantedAsProducer],
['label' => 'Tableau de bord', 'icon' => 'dashboard', 'url' => ['/dashboard/index'], 'visible' => $isUserCurrentGrantedAsProducer],
['label' => 'Distributions', 'icon' => 'calendar', 'url' => ['/distribution/index'], 'visible' => $isUserCurrentGrantedAsProducer],
[
'label' => 'Produits',
'icon' => 'clone',
'url' => ['/product/index'],
'visible' => $userManager->isCurrentProducer(),
'visible' => $isUserCurrentGrantedAsProducer,
'active' => Yii::$app->controller->id == 'product',
'items' => [
['label' => 'Liste', 'icon' => 'th-list', 'url' => ['/product/index'], 'visible' => $userManager->isCurrentProducer()],
['label' => 'Catégories', 'icon' => 'book', 'url' => ['/product-category/index'], 'visible' => $userManager->isCurrentProducer()],
['label' => 'Import prix', 'icon' => 'upload', 'url' => ['/product/price-import'], 'visible' => $userManager->isCurrentProducer()],
['label' => 'Liste', 'icon' => 'th-list', 'url' => ['/product/index'], 'visible' => $isUserCurrentGrantedAsProducer],
['label' => 'Catégories', 'icon' => 'book', 'url' => ['/product-category/index'], 'visible' => $isUserCurrentGrantedAsProducer],
['label' => 'Import prix', 'icon' => 'upload', 'url' => ['/product/price-import'], 'visible' => $isUserCurrentGrantedAsProducer],
]
],
['label' => 'Points de vente', 'icon' => 'map-marker', 'url' => ['/point-sale/index'], 'visible' => $userManager->isCurrentProducer(), 'active' => Yii::$app->controller->id == 'point-sale'],
['label' => 'Points de vente', 'icon' => 'map-marker', 'url' => ['/point-sale/index'], 'visible' => $isUserCurrentGrantedAsProducer, 'active' => Yii::$app->controller->id == 'point-sale'],
[
'label' => 'Utilisateurs',
'icon' => 'users',
'url' => ['/user/index'],
'items' => [
['label' => 'Liste', 'icon' => 'th-list', 'url' => ['/user/index'], 'visible' => $userManager->isCurrentProducer()],
['label' => 'Liste', 'icon' => 'th-list', 'url' => ['/user/index'], 'visible' => $isUserCurrentGrantedAsProducer],
[
'label' => 'Crédit',
'icon' => 'euro',
'url' => ['/credit/index'],
'template' => '<a href="{url}">{icon} {label}' . $sumUserProducerCreditsLabel . '</a>',
'visible' => $userManager->isCurrentProducer() && $producerManager->getConfig('credit')
'visible' => $isUserCurrentGrantedAsProducer && $producerManager->getConfig('credit')
],
['label' => 'Groupes', 'icon' => 'users', 'url' => ['/user-group/index'], 'visible' => $userManager->isCurrentProducer()],
['label' => 'Groupes', 'icon' => 'users', 'url' => ['/user-group/index'], 'visible' => $isUserCurrentGrantedAsProducer],
],
],
['label' => 'Abonnements', 'icon' => 'repeat', 'url' => ['/subscription/index'], 'visible' => $userManager->isCurrentProducer(), 'active' => Yii::$app->controller->id == 'subscription'],
['label' => 'Communiquer', 'icon' => 'bullhorn', 'url' => ['/communicate/index'], 'visible' => $userManager->isCurrentProducer()],
['label' => 'Abonnements', 'icon' => 'repeat', 'url' => ['/subscription/index'], 'visible' => $isUserCurrentGrantedAsProducer, 'active' => Yii::$app->controller->id == 'subscription'],
['label' => 'Communiquer', 'icon' => 'bullhorn', 'url' => ['/communicate/index'], 'visible' => $isUserCurrentGrantedAsProducer],
[
'label' => 'Documents',
'icon' => 'clone',
'url' => ['/delivery-note/index'],
'items' => [
['label' => 'Bons de livraison', 'icon' => 'sticky-note-o', 'url' => ['/delivery-note/index'], 'visible' => $userManager->isCurrentProducer()],
['label' => 'Factures', 'icon' => 'sticky-note-o', 'url' => ['/invoice/index'], 'visible' => $userManager->isCurrentProducer()],
['label' => 'Devis', 'icon' => 'sticky-note-o', 'url' => ['/quotation/index'], 'visible' => $userManager->isCurrentProducer()],
['label' => 'Bons de livraison', 'icon' => 'sticky-note-o', 'url' => ['/delivery-note/index'], 'visible' => $isUserCurrentGrantedAsProducer],
['label' => 'Factures', 'icon' => 'sticky-note-o', 'url' => ['/invoice/index'], 'visible' => $isUserCurrentGrantedAsProducer],
['label' => 'Devis', 'icon' => 'sticky-note-o', 'url' => ['/quotation/index'], 'visible' => $isUserCurrentGrantedAsProducer],
],
],
[
@@ -138,53 +141,53 @@ $producer = GlobalParam::getCurrentProducer();
'icon' => 'line-chart',
'url' => ['/stats/index'],
'items' => [
['label' => 'Chiffre d\'affaire', 'icon' => 'line-chart', 'url' => ['/stats/index'], 'visible' => $userManager->isCurrentProducer()],
['label' => 'Rapports', 'icon' => 'pencil-square-o', 'url' => ['/report/index'], 'visible' => $userManager->isCurrentProducer()],
['label' => 'Produits', 'icon' => 'table', 'url' => ['/stats/products'], 'visible' => $userManager->isCurrentProducer()],
['label' => 'Chiffre d\'affaire', 'icon' => 'line-chart', 'url' => ['/stats/index'], 'visible' => $isUserCurrentGrantedAsProducer],
['label' => 'Rapports', 'icon' => 'pencil-square-o', 'url' => ['/report/index'], 'visible' => $isUserCurrentGrantedAsProducer],
['label' => 'Produits', 'icon' => 'table', 'url' => ['/stats/products'], 'visible' => $isUserCurrentGrantedAsProducer],
],
],
['label' => 'Paramètres', 'icon' => 'cog', 'url' => ['/producer/update'], 'visible' => $userManager->isCurrentProducer()],
['label' => 'Accès', 'icon' => 'lock', 'url' => ['/access/index'], 'visible' => $userManager->isCurrentProducer()],
['label' => "Opendistrib", 'options' => ['class' => 'header'], 'visible' => $userManager->isCurrentProducer()],
['label' => 'Paramètres', 'icon' => 'cog', 'url' => ['/producer/update'], 'visible' => $isUserCurrentGrantedAsProducer],
['label' => 'Accès', 'icon' => 'lock', 'url' => ['/access/index'], 'visible' => $isUserCurrentGrantedAsProducer],
['label' => "Opendistrib", 'options' => ['class' => 'header'], 'visible' => $isUserCurrentGrantedAsProducer],
[
'label' => 'Développement',
'icon' => 'code',
'url' => ['/development/index'],
'visible' => $userManager->isCurrentProducer(),
'visible' => $isUserCurrentGrantedAsProducer,
'active' => Yii::$app->controller->id == 'development',
'template' => '<a href="{url}">{icon} {label}' . $newVersionOpendistribLabel . '</a>'
],
['label' => 'Tarifs', 'icon' => 'euro', 'url' => ['/producer/billing'], 'visible' => $userManager->isCurrentProducer()],
['label' => 'Tarifs', 'icon' => 'euro', 'url' => ['/producer/billing'], 'visible' => $isUserCurrentGrantedAsProducer],

['label' => 'Administration', 'options' => ['class' => 'header'], 'visible' => $userManager->isCurrentAdmin()],
['label' => 'Administration', 'options' => ['class' => 'header'], 'visible' => $isUserCurrentGrantedAsAdministrator],
[
'label' => 'Tickets',
'icon' => 'comments',
'url' => ['support-admin/index'],
'visible' => $userManager->isCurrentAdmin(),
'visible' => $isUserCurrentGrantedAsAdministrator,
'template' => '<a href="{url}">{icon} {label}' . $countTicketsAdminUnreadLabel . '</a>'
],
['label' => 'Producteurs', 'icon' => 'th-list', 'url' => ['/producer-admin/index'], 'visible' => $userManager->isCurrentAdmin()],
['label' => 'Producteurs', 'icon' => 'th-list', 'url' => ['/producer-admin/index'], 'visible' => $isUserCurrentGrantedAsAdministrator],
[
'label' => 'Statistiques',
'icon' => 'line-chart',
'url' => ['/stats-admin/matomo'],
'visible' => $userManager->isCurrentAdmin(),
'visible' => $isUserCurrentGrantedAsAdministrator,
'items' => [
['label' => 'Matomo', 'icon' => 'line-chart', 'url' => ['/stats-admin/matomo'], 'visible' => $userManager->isCurrentAdmin()],
['label' => 'Chiffre d\'affaire', 'icon' => 'line-chart', 'url' => ['/stats-admin/turnover'], 'visible' => $userManager->isCurrentAdmin()],
['label' => 'Commandes clients', 'icon' => 'calendar', 'url' => ['/stats-admin/customer-orders'], 'visible' => $userManager->isCurrentAdmin()],
['label' => 'Matomo', 'icon' => 'line-chart', 'url' => ['/stats-admin/matomo'], 'visible' => $isUserCurrentGrantedAsAdministrator],
['label' => 'Chiffre d\'affaire', 'icon' => 'line-chart', 'url' => ['/stats-admin/turnover'], 'visible' => $isUserCurrentGrantedAsAdministrator],
['label' => 'Commandes clients', 'icon' => 'calendar', 'url' => ['/stats-admin/customer-orders'], 'visible' => $isUserCurrentGrantedAsAdministrator],
],
],

['label' => 'Tranches de prix', 'icon' => 'eur', 'url' => ['/producer-price-range-admin/index'], 'visible' => $userManager->isCurrentAdmin()],
['label' => 'Taxes', 'icon' => 'eur', 'url' => ['/tax-rate-admin/index'], 'visible' => $userManager->isCurrentAdmin()],
['label' => 'Communiquer', 'icon' => 'bullhorn', 'url' => ['/communicate-admin/index'], 'visible' => $userManager->isCurrentAdmin()],
['label' => 'Tranches de prix', 'icon' => 'eur', 'url' => ['/producer-price-range-admin/index'], 'visible' => $isUserCurrentGrantedAsAdministrator],
['label' => 'Taxes', 'icon' => 'eur', 'url' => ['/tax-rate-admin/index'], 'visible' => $isUserCurrentGrantedAsAdministrator],
['label' => 'Communiquer', 'icon' => 'bullhorn', 'url' => ['/communicate-admin/index'], 'visible' => $isUserCurrentGrantedAsAdministrator],

//['label' => 'Outils', 'options' => ['class' => 'header'], 'visible' => $userManager->isCurrentAdmin()],
//['label' => 'Gii', 'icon' => 'file-code-o', 'url' => ['/gii'], 'visible' => $userManager->isCurrentAdmin()],
//['label' => 'Debug', 'icon' => 'dashboard', 'url' => ['/debug'], 'visible' => $userManager->isCurrentAdmin()],
['label' => 'Login', 'url' => ['site/login'], 'visible' => !$userManager->isCurrentConnected()],
//['label' => 'Outils', 'options' => ['class' => 'header'], 'visible' => $isUserCurrentGrantedAsAdministrator],
//['label' => 'Gii', 'icon' => 'file-code-o', 'url' => ['/gii'], 'visible' => $isUserCurrentGrantedAsAdministrator],
//['label' => 'Debug', 'icon' => 'dashboard', 'url' => ['/debug'], 'visible' => $isUserCurrentGrantedAsAdministrator],
['label' => 'Login', 'url' => ['site/login'], 'visible' => !$userModule->isCurrentConnected()],
],
]
) ?>

+ 5
- 5
backend/views/point-sale/_form.php Dosyayı Görüntüle

@@ -40,10 +40,10 @@ use yii\helpers\Html;
use yii\widgets\ActiveForm;
use yii\helpers\ArrayHelper;
use common\logic\Producer\Producer\Model\Producer;
use common\logic\User\User\Wrapper\UserManager;
use common\logic\User\User\Wrapper\UserModule;

$producerManager = $this->getProducerManager();
$userManager = $this->getUserManager();
$userModule = $this->getUserModule();

?>

@@ -58,7 +58,7 @@ $userManager = $this->getUserManager();
<?= $form->field($model, 'id_user', [
'template' => '{label} <a href="' . Yii::$app->urlManager->createUrl(['user/create']) . '" class="btn btn-xs btn-default">Nouvel utilisateur <span class="glyphicon glyphicon-plus"></span></a><div>{input}</div>{hint}',
])
->dropDownList($userManager->populateUserDropdownList(), ['class' => 'select2'])
->dropDownList($userModule->populateUserDropdownList(), ['class' => 'select2'])
->hint('Utilisé lors de la facturation'); ?>
<?php
$addHintCredit = '';
@@ -126,8 +126,8 @@ $userManager = $this->getUserManager();
. 'Dans le cas des boîtes à pain, il vous est possible de spécifier un commentaire pour chaque utilisateur sélectionné afin de lui renseigner son numéro de boîte ou son code.') ?>
<div id="users">
<?= Html::activeCheckboxList($model, 'users', ArrayHelper::map($users, 'user_id', function ($model_user, $defaultValue) use ($model) {
$userManager = UserManager::getInstance();
return Html::encode($userManager->getUsernameFromArray($model_user)) . '<br />'
$userModule = UserModule::getInstance();
return Html::encode($userModule->getUsernameFromArray($model_user)) . '<br />'
. Html::activeTextInput(
$model,
'users_comment[' . $model_user['user_id'] . ']',

+ 16
- 3
backend/views/producer-admin/index.php Dosyayı Görüntüle

@@ -78,7 +78,14 @@ $this->addButton(['label' => 'Nouveau producteur <span class="glyphicon glyphico
return $html ;
}
],
'name',
[
'attribute' => 'name',
'format' => 'raw',
'value' => function($model) {
$html = Html::encode($model->name);
return $html;
}
],
[
'attribute' => 'Contact',
'format' => 'raw',
@@ -154,11 +161,17 @@ $this->addButton(['label' => 'Nouveau producteur <span class="glyphicon glyphico
'label' => 'Commentaire',
'format' => 'raw',
'value' => function($producer) {
$html = '';

if($producer->admin_comment) {
return $producer->admin_comment;
$html .= $producer->admin_comment;
}

if($producer->active && (!$producer->latitude || !$producer->longitude)) {
$html .= '<div class="alert-latitude-longitude"><span class="glyphicon glyphicon-map-marker"></span> Latitude/longitude à saisir</div>';
}

return '';
return $html;
}
],
[

+ 2
- 2
backend/views/producer/update.php Dosyayı Görüntüle

@@ -43,7 +43,7 @@ use common\logic\Config\TaxRate\Model\TaxRate;
use common\logic\Document\Document\Model\Document;
use yii\helpers\ArrayHelper;

$userManager = $this->getUserManager();
$userModule = $this->getUserModule();

\backend\assets\VuejsProducerUpdateAsset::register($this);
$this->setTitle('Paramètres');
@@ -53,7 +53,7 @@ $this->addBreadcrumb($this->getTitle());

<script>
var appInitValues = {
isAdmin: <?= (int) $userManager->isCurrentAdmin() ?>
isAdmin: <?= (int) $userModule->isCurrentAdmin() ?>
};
</script>


+ 2
- 2
backend/views/product/update/prices/_form.php Dosyayı Görüntüle

@@ -4,7 +4,7 @@ use yii\helpers\Html;
use yii\bootstrap\ActiveForm;
use common\helpers\GlobalParam;

$userManager = $this->getUserManager();
$userModule = $this->getUserModule();
$userGroupManager = $this->getUserGroupManager();
$pointSaleManager = $this->getPointSaleManager();
$productManager = $this->getProductManager();
@@ -24,7 +24,7 @@ $productManager = $this->getProductManager();
'options' => ['enctype' => 'multipart/form-data']
]); ?>

<?= $form->field($model, 'id_user')->dropDownList($userManager->populateUserDropdownList()); ?>
<?= $form->field($model, 'id_user')->dropDownList($userModule->populateUserDropdownList()); ?>
<?= $form->field($model, 'id_user_group')->dropDownList($userGroupManager->populateUserGroupDropdownList()); ?>
<?= $form->field($model, 'id_point_sale')->dropDownList($pointSaleManager->populatePointSaleDropdownList()); ?>
<?= $form->field($model, 'from_quantity')->label('À partir de la quantité ('. $productManager->strUnit($productManager->getRefUnit($modelProduct->unit), 'wording').')'); ?>

+ 4
- 4
backend/views/product/update/prices/list.php Dosyayı Görüntüle

@@ -36,14 +36,14 @@
* termes.
*/

use common\logic\User\User\Wrapper\UserManager;
use common\logic\User\User\Wrapper\UserModule;
use yii\helpers\Html;
use common\helpers\Price;
use yii\grid\GridView;
use common\logic\Product\Product\Wrapper\ProductManager;

$productManager = ProductManager::getInstance();
$userManager = UserManager::getInstance();
$userModule = UserModule::getInstance();

$this->setTitle('Liste des prix (' . Html::encode($model->name) . ')');
$this->addBreadcrumb(['label' => 'Produits', 'url' => ['index']]);
@@ -81,9 +81,9 @@ $this->render('../_nav', [
[
'attribute' => 'id_user',
'format' => 'raw',
'value' => function ($model) use ($userManager) {
'value' => function ($model) use ($userModule) {
if ($model->user) {
return $userManager->getUsername($model->user);
return $userModule->getUsername($model->user);
}
return '<span class="label label-success">Tous</span>';
}

+ 3
- 3
backend/views/quotation/index.php Dosyayı Görüntüle

@@ -42,7 +42,7 @@ use common\logic\Order\Order\Model\Order;
use yii\helpers\Html;

$quotationManager = $this->getQuotationManager();
$userManager = $this->getUserManager();
$userModule = $this->getUserModule();

$this->setTitle('Devis');
$this->addBreadcrumb($this->getTitle());
@@ -84,8 +84,8 @@ $this->addButton(['label' => 'Nouveau devis <span class="glyphicon glyphicon-plu
'headerOptions' => ['class' => 'column-hide-on-mobile'],
'filterOptions' => ['class' => 'column-hide-on-mobile'],
'contentOptions' => ['class' => 'column-hide-on-mobile'],
'value' => function ($quotation) use ($userManager) {
return $userManager->getUsername($quotation->user);
'value' => function ($quotation) use ($userModule) {
return $userModule->getUsername($quotation->user);
}
],
[

+ 48
- 64
backend/views/site/error.php Dosyayı Görüntüle

@@ -1,80 +1,64 @@
<?php

/**
Copyright distrib (2018)
contact@opendistrib.net
Ce logiciel est un programme informatique servant à aider les producteurs
à distribuer leur production en circuits courts.
Ce logiciel est régi par la licence CeCILL soumise au droit français et
respectant les principes de diffusion des logiciels libres. Vous pouvez
utiliser, modifier et/ou redistribuer ce programme sous les conditions
de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA
sur le site "http://www.cecill.info".
En contrepartie de l'accessibilité au code source et des droits de copie,
de modification et de redistribution accordés par cette licence, il n'est
offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons,
seule une responsabilité restreinte pèse sur l'auteur du programme, le
titulaire des droits patrimoniaux et les concédants successifs.
A cet égard l'attention de l'utilisateur est attirée sur les risques
associés au chargement, à l'utilisation, à la modification et/ou au
développement et à la reproduction du logiciel par l'utilisateur étant
donné sa spécificité de logiciel libre, qui peut le rendre complexe à
manipuler et qui le réserve donc à des développeurs et des professionnels
avertis possédant des connaissances informatiques approfondies. Les
utilisateurs sont donc invités à charger et tester l'adéquation du
logiciel à leurs besoins dans des conditions permettant d'assurer la
sécurité de leurs systèmes et ou de leurs données et, plus généralement,
à l'utiliser et l'exploiter dans les mêmes conditions de sécurité.
Le fait que vous puissiez accéder à cet en-tête signifie que vous avez
pris connaissance de la licence CeCILL, et que vous en avez accepté les
termes.
*/
/**
* Copyright distrib (2018)
*
* contact@opendistrib.net
*
* Ce logiciel est un programme informatique servant à aider les producteurs
* à distribuer leur production en circuits courts.
*
* Ce logiciel est régi par la licence CeCILL soumise au droit français et
* respectant les principes de diffusion des logiciels libres. Vous pouvez
* utiliser, modifier et/ou redistribuer ce programme sous les conditions
* de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA
* sur le site "http://www.cecill.info".
*
* En contrepartie de l'accessibilité au code source et des droits de copie,
* de modification et de redistribution accordés par cette licence, il n'est
* offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons,
* seule une responsabilité restreinte pèse sur l'auteur du programme, le
* titulaire des droits patrimoniaux et les concédants successifs.
*
* A cet égard l'attention de l'utilisateur est attirée sur les risques
* associés au chargement, à l'utilisation, à la modification et/ou au
* développement et à la reproduction du logiciel par l'utilisateur étant
* donné sa spécificité de logiciel libre, qui peut le rendre complexe à
* manipuler et qui le réserve donc à des développeurs et des professionnels
* avertis possédant des connaissances informatiques approfondies. Les
* utilisateurs sont donc invités à charger et tester l'adéquation du
* logiciel à leurs besoins dans des conditions permettant d'assurer la
* sécurité de leurs systèmes et ou de leurs données et, plus généralement,
* à l'utiliser et l'exploiter dans les mêmes conditions de sécurité.
*
* Le fait que vous puissiez accéder à cet en-tête signifie que vous avez
* pris connaissance de la licence CeCILL, et que vous en avez accepté les
* termes.
*/

use yii\helpers\Html;

/* @var $this yii\web\View */
/* @var $name string */
/* @var $message string */
/* @var $exception Exception */
$this->setTitle('Le serveur a renvoyé une erreur', 'Erreur');

$this->title = $name;
?>
<section class="content">

<div class="error-page">
<h2 class="headline text-info"><i class="fa fa-warning text-yellow"></i></h2>

<div class="error-content">
<h3><?= $name ?></h3>

<p>
<?= nl2br(Html::encode($message)) ?>
</p>

<h2>Erreur <?php if ($exception->statusCode): ?><?= $exception->statusCode; ?><?php endif; ?></h2>
<p><?= nl2br(Html::encode($exception->getMessage())); ?></p>
<div class="box box-warning">
<div class="box-body">
<?= $this->renderFile('@common/views/error_info.php', [
'urlContact' => Yii::$app->urlManager->createUrl('support/index'),
]) ?>
</div>
</div>
<p>
The above error occurred while the Web server was processing your request.
Please contact us if you think this is a server error. Thank you.
Meanwhile, you may <a href='<?= Yii::$app->homeUrl ?>'>return to dashboard</a> or try using the search
form.
<a class="btn btn-default" href="<?= Yii::$app->urlManager->createUrl('dashboard/index') ?>">
Retour à l'accueil
</a>
</p>

<form class='search-form'>
<div class='input-group'>
<input type="text" name="search" class='form-control' placeholder="Search"/>

<div class="input-group-btn">
<button type="submit" name="submit" class="btn btn-primary"><i class="fa fa-search"></i>
</button>
</div>
</div>
</form>
</div>
</div>

</section>

+ 2
- 2
backend/views/subscription/_form.php Dosyayı Görüntüle

@@ -43,7 +43,7 @@ use common\logic\Subscription\Subscription\Model\Subscription;

\backend\assets\VuejsSubscriptionFormAsset::register($this);

$userManager = $this->getUserManager();
$userModule = $this->getUserModule();
$pointSaleManager = $this->getPointSaleManager();

?>
@@ -54,7 +54,7 @@ $pointSaleManager = $this->getPointSaleManager();
<?= $form->field($model, 'id')->hiddenInput() ?>
<?php endif; ?>
<div class="col-md-5" id="bloc-select-user">
<?= $form->field($model, 'id_user')->dropDownList($userManager->populateUserDropdownList(), ['class' => 'select2']); ?>
<?= $form->field($model, 'id_user')->dropDownList($userModule->populateUserDropdownList(), ['class' => 'select2']); ?>
</div>
<div class="col-md-1" id="or-user">
<span>OU</span>

+ 5
- 5
backend/views/support/view.php Dosyayı Görüntüle

@@ -1,12 +1,12 @@
<?php

use common\logic\Ticket\Ticket\Wrapper\TicketManager;
use common\logic\User\User\Wrapper\UserManager;
use common\logic\User\User\Wrapper\UserModule;
use yii\helpers\Html;
use yii\widgets\ActiveForm;

$ticketManager = TicketManager::getInstance();
$userManager = UserManager::getInstance();
$userModule = UserModule::getInstance();
$this->setTitle('Voir un ticket');
$this->addBreadcrumb(['label' => 'Support', 'url' => ['index']]);
$this->addBreadcrumb('Voir un ticket');
@@ -29,7 +29,7 @@ $this->addBreadcrumb('Voir un ticket');
<td><strong>Statut</strong></td>
<td><?= $ticketManager->getTicketStatusLabelAsHtml($ticket); ?></td>
</tr>
<?php if($userManager->isCurrentAdmin()): ?>
<?php if($userModule->isCurrentAdmin()): ?>
<tr>
<td><strong>Producteur</strong></td>
<td><?= $ticketManager->isTicketUnread($ticket, $ticket->user) ?
@@ -50,10 +50,10 @@ $this->addBreadcrumb('Voir un ticket');
<a name="bottom"></a>
<?php endif; ?>
<a name="<?= $ticketMessage->id ?>"></a>
<i class="fa fa-user <?= $userManager->isAdmin($ticketMessage->user) ? 'bg-orange' : 'bg-aqua'; ?>"></i>
<i class="fa fa-user <?= $userModule->isAdmin($ticketMessage->user) ? 'bg-orange' : 'bg-aqua'; ?>"></i>
<div class="timeline-item">
<span class="time"><i class="fa fa-clock-o"></i> <?= date('d/m/Y à H:i', strtotime($ticketMessage->created_at)) ?></span>
<h3 class="timeline-header"><?= Html::encode($userManager->getUsername($ticketMessage->user)); ?></h3>
<h3 class="timeline-header"><?= Html::encode($userModule->getUsername($ticketMessage->user)); ?></h3>
<div class="timeline-body">
<?= nl2br($ticketMessage->message); ?>
</div>

+ 2
- 2
backend/views/user/_form.php Dosyayı Görüntüle

@@ -42,7 +42,7 @@ use yii\helpers\ArrayHelper;

\backend\assets\VuejsUserFormAsset::register($this);

$userManager = $this->getUserManager();
$userModule = $this->getUserModule();
$producerManager = $this->getProducerManager();

?>
@@ -55,7 +55,7 @@ $producerManager = $this->getProducerManager();
]); ?>

<?= $form->field($model, 'type')
->dropDownList($userManager->getTypeChoicesArray(), [
->dropDownList($userModule->getTypeChoicesArray(), [
'v-model' => 'type'
]); ?>
<?= $form->field($model, 'name_legal_person', ['options' => ['v-show' => "type == 'legal-person'"]])->textInput() ?>

+ 2
- 2
backend/views/user/credit.php Dosyayı Görüntüle

@@ -45,7 +45,7 @@ use common\helpers\MeanPayment;

$paymentManager = $this->getPaymentManager();
$producerManager = $this->getProducerManager();
$userManager = $this->getUserManager();
$userModule = $this->getUserModule();

$this->setTitle('Créditer <small>'.Html::encode($user->lastname.' '.$user->name).'</small>', 'Créditer '.Html::encode($user->lastname.' '.$user->name)) ;
$this->addBreadcrumb(['label' => 'Utilisateurs', 'url' => ['index']]) ;
@@ -113,7 +113,7 @@ $this->addBreadcrumb('Créditer') ;
</div>
<div class="col-md-8">
<h2>Historique <span class="the-credit"><?= number_format($userManager->getCredit($user), 2); ?> €</span></h2>
<h2>Historique <span class="the-credit"><?= number_format($userModule->getCredit($user), 2); ?> €</span></h2>

<?= GridView::widget([
'dataProvider' => $dataProvider,

+ 42
- 38
backend/views/user/index.php Dosyayı Görüntüle

@@ -36,16 +36,17 @@
* termes.
*/

use common\components\PageSizer;
use common\helpers\GlobalParam;
use common\logic\Producer\Producer\Wrapper\ProducerManager;
use yii\helpers\Html;
use yii\grid\GridView;
use common\logic\User\User\Wrapper\UserManager;
use common\logic\User\User\Wrapper\UserModule;
use common\logic\Order\Order\Model\Order;
use common\logic\User\UserProducer\Model\UserProducer;
use common\logic\User\User\Model\User;

$userModule = UserModule::getInstance();
$producerManager = ProducerManager::getInstance();
$userCurrent = GlobalParam::getCurrentUser();

$this->setTitle('Utilisateurs');
$this->addBreadcrumb($this->getTitle());
@@ -74,9 +75,8 @@ $this->render('_menu', [
[
'attribute' => 'username',
'label' => 'Nom',
'value' => function ($model) {
$userManager = UserManager::getInstance();
return $userManager->getUsername($model);
'value' => function ($user) use ($userModule) {
return $userModule->getUsername($user);
}
],
[
@@ -85,13 +85,9 @@ $this->render('_menu', [
'headerOptions' => ['class' => 'column-hide-on-mobile'],
'filterOptions' => ['class' => 'column-hide-on-mobile'],
'contentOptions' => ['class' => 'column-hide-on-mobile'],
'value' => function ($model) {
$userManager = UserManager::getInstance();
$typeArray = $userManager->getTypeChoicesArray();
if(isset($typeArray[$model['type']])) {
return $typeArray[$model['type']];
}
return '';
'filter' => $userModule->getTypeChoicesArray(),
'value' => function ($user) use ($userModule) {
return $userModule->getTypeLabel($user['type']);
}
],
[
@@ -101,16 +97,16 @@ $this->render('_menu', [
'headerOptions' => ['class' => 'column-hide-on-mobile'],
'filterOptions' => ['class' => 'column-hide-on-mobile'],
'contentOptions' => ['class' => 'column-hide-on-mobile'],
'value' => function ($model) {
'value' => function ($user) {
$html = '';
if (strlen($model['phone'])) {
$html .= $model['phone'];
if (strlen($user['phone'])) {
$html .= $user['phone'];
}
if (strlen($model['phone']) && strlen($model['email'])) {
if (strlen($user['phone']) && strlen($user['email'])) {
$html .= '<br />';
}
if (strlen($model['email'])) {
$html .= $model['email'];
if (strlen($user['email'])) {
$html .= $user['email'];
}
return $html;
}
@@ -122,12 +118,14 @@ $this->render('_menu', [
'headerOptions' => ['class' => 'column-hide-on-mobile'],
'filterOptions' => ['class' => 'column-hide-on-mobile'],
'contentOptions' => ['class' => 'column-hide-on-mobile'],
'value' => function ($model) {
$userManager = UserManager::getInstance();
if($userManager->isUserSubscribedNewsletter($model)) {
'filter' => [
0 => 'Non',
1 => 'Oui'
],
'value' => function ($user) use ($userModule) {
if($userModule->isUserSubscribedNewsletter($user)) {
return '<span class="label label-success">Oui</span>';
}

return '<span class="label label-danger">Non</span>';
}
],
@@ -191,24 +189,30 @@ $this->render('_menu', [
'headerOptions' => ['class' => 'column-actions'],
'contentOptions' => ['class' => 'column-actions'],
'buttons' => [
'update' => function ($url, $model) {
$url = Yii::$app->urlManager->createUrl(['user/update', 'id' => $model->id]);
$user = User::find()->with('userProducer')->where(['id' => $model->id])->one();
return Html::a('<span class="glyphicon glyphicon-pencil"></span>', $url, [
'title' => 'Modifier', 'class' => 'btn btn-default'
]);
'update' => function ($url, $user) {
return Html::a('<span class="glyphicon glyphicon-pencil"></span>',
Yii::$app->urlManager->createUrl(['user/update', 'id' => $user->id]),
[
'title' => 'Modifier',
'class' => 'btn btn-default'
]);
},
'delete' => function ($url, $model) {
return Html::a('<span class="glyphicon glyphicon-trash"></span>', Yii::$app->urlManager->createUrl(array_merge(['user/delete', 'id' => $model->id], Yii::$app->getRequest()->getQueryParams())), [
'title' => 'Supprimer', 'class' => 'btn btn-default btn-confirm-delete'
]);
},
'switch' => function($url, $model) {
$userManager = UserManager::getInstance();
if($userManager->isCurrentAdmin()) {
return Html::a('<span class="glyphicon glyphicon-user"></span>', Yii::$app->urlManager->createUrl(['user/switch-identity', 'id' => $model->id]), [
'title' => 'Prendre la main', 'class' => 'btn btn-default'
return Html::a('<span class="glyphicon glyphicon-trash"></span>',
Yii::$app->urlManager->createUrl(array_merge(['user/delete', 'id' => $model->id], Yii::$app->getRequest()->getQueryParams())),
[
'title' => 'Supprimer',
'class' => 'btn btn-default btn-confirm-delete'
]);
},
'switch' => function($url, $model) use ($userModule, $userCurrent) {
if($userModule->getAuthorizationChecker()->isGrantedAsAdministrator($userCurrent)) {
return Html::a('<span class="glyphicon glyphicon-user"></span>',
Yii::$app->urlManager->createUrl(['user/switch-identity', 'id' => $model->id]),
[
'title' => 'Prendre la main',
'class' => 'btn btn-default'
]);
}
}
],

+ 2
- 2
backend/views/user/orders.php Dosyayı Görüntüle

@@ -39,10 +39,10 @@
use yii\grid\GridView;
use yii\helpers\Html;

$userManager = $this->getUserManager();
$userModule = $this->getUserModule();
$orderManager = $this->getOrderManager();

$this->setTitle('Commandes <small>' . Html::encode($userManager->getUsername($user)) . '</small>', 'Commandes de ' . Html::encode($userManager->getUsername($user)));
$this->setTitle('Commandes <small>' . Html::encode($userModule->getUsername($user)) . '</small>', 'Commandes de ' . Html::encode($userModule->getUsername($user)));
$this->addBreadcrumb(['label' => 'Utilisateurs', 'url' => ['index']]);
$this->addBreadcrumb(['label' => Html::encode($user->lastname . ' ' . $user->name)]);
$this->addBreadcrumb('Commandes');

+ 7
- 0
backend/web/css/screen.css Dosyayı Görüntüle

@@ -2788,6 +2788,13 @@ termes.
margin-right: 0px;
}

/* line 2, ../sass/producer-admin/_index.scss */
.producer-admin-index .alert-latitude-longitude {
font-size: 13px;
color: gray;
margin-top: 5px;
}

/**
Copyright distrib (2018)


+ 20
- 8
backend/web/js/vuejs/distribution-index.js Dosyayı Görüntüle

@@ -1018,10 +1018,26 @@ Vue.component('order-form', {
}
return JSON.stringify(productOrderArrayRequest);
},
getPointSale: function(idPointSale) {
for(key in this.pointsSale) {
if (this.pointsSale[key].id == idPointSale) {
return this.pointsSale[key];
}
}

return false;
},
isPointSaleCreditFunctioningOptional: function(idPointSale) {
var pointSale = this.getPointSale(idPointSale);
if(pointSale && pointSale.credit_functioning == 'optional') {
return true;
}

return false;
},
submitFormCreate: function (event) {
var app = this;
if (this.checkForm()) {
var processCredit = event.currentTarget.getAttribute('data-process-credit');
axios.get(UrlManager.getBaseUrlAbsolute() + "order/ajax-create", {
params: {
date: this.date.getFullYear() + '-'
@@ -1032,7 +1048,8 @@ Vue.component('order-form', {
username: this.order.username,
meanPayment: this.order.mean_payment,
products: app.getProductOrderArrayRequest(),
comment: this.order.comment
comment: this.order.comment,
debitCredit: this.order.debitCredit
}
})
.then(function (response) {
@@ -1051,11 +1068,6 @@ Vue.component('order-form', {
submitFormUpdate: function (event) {
var app = this;
if (this.checkForm()) {
var processCredit = event.currentTarget.getAttribute('data-process-credit');
if (processCredit == null) {
processCredit = 0;
}

var data = new FormData();
data.append('date', this.date.getFullYear() + '-'
+ ('0' + (this.date.getMonth() + 1)).slice(-2) + '-'
@@ -1067,7 +1079,7 @@ Vue.component('order-form', {
data.append('username', '' + this.order.username);
data.append('products', app.getProductOrderArrayRequest());
data.append('comment', this.order.comment && this.order.comment.length ? this.order.comment : '');
data.append('processCredit', processCredit);
data.append('debitCredit', this.order.debitCredit ? this.order.debitCredit : 0);

axios.post(UrlManager.getBaseUrlAbsolute() + "order/ajax-update", data)
.then(function (response) {

+ 8
- 0
backend/web/sass/producer-admin/_index.scss Dosyayı Görüntüle

@@ -0,0 +1,8 @@
.producer-admin-index {
.alert-latitude-longitude {
font-size: 13px;
color: gray;
margin-top: 5px;
}
}


+ 1
- 0
backend/web/sass/screen.scss Dosyayı Görüntüle

@@ -1532,4 +1532,5 @@ a.btn, button.btn {
@import "development/_index.scss" ;
@import "support/_index.scss";
@import "support/_view.scss";
@import "producer-admin/_index.scss";
@import "_responsive.scss" ;

+ 8
- 7
common/components/BusinessLogicTrait.php Dosyayı Görüntüle

@@ -53,6 +53,7 @@ use common\logic\Ticket\TicketUser\Wrapper\TicketUserContainer;
use common\logic\Ticket\TicketUser\Wrapper\TicketUserManager;
use common\logic\User\User\Wrapper\UserContainer;
use common\logic\User\User\Wrapper\UserManager;
use common\logic\User\User\Wrapper\UserModule;
use common\logic\User\UserGroup\Wrapper\UserGroupContainer;
use common\logic\User\UserGroup\Wrapper\UserGroupManager;
use common\logic\User\UserProducer\Wrapper\UserProducerContainer;
@@ -177,9 +178,14 @@ trait BusinessLogicTrait
return PaymentManager::getInstance();
}

public function getUserManager(): UserManager
public function getUserModule(): UserModule
{
return UserManager::getInstance();
return UserModule::getInstance();
}

public function getUserContainer(): UserContainer
{
return UserContainer::getInstance();
}

public function getUserGroupManager(): UserGroupManager
@@ -207,11 +213,6 @@ trait BusinessLogicTrait
return TicketUserManager::getInstance();
}

public function getUserContainer(): UserContainer
{
return UserContainer::getInstance();
}

public function getProducerContainer(): ProducerContainer
{
return ProducerContainer::getInstance();

+ 10
- 0
common/config/main.php Dosyayı Görüntüle

@@ -61,6 +61,16 @@ return [
Yii::$app->end();
}
}

if (Yii::$app->params['maintenanceMode']) {
if(isset($_GET['letMeIn'])) {
Yii::$app->session->set('letMeIn', (int) $_GET['letMeIn']);
}
$letMeIn = Yii::$app->session['letMeIn'];
if (!$letMeIn) {
Yii::$app->catchAll = ['site/maintenance'];
}
}
},
'components' => [
'parameterBag' => [

+ 2
- 1
common/config/params.php Dosyayı Görüntüle

@@ -37,7 +37,8 @@
*/

return [
'version' => '23.10.B',
'version' => '23.10.C',
'maintenanceMode' => false,
'siteName' => 'Opendistrib',
'adminEmail' => 'contact@opendistrib.net',
'supportEmail' => 'contact@opendistrib.net',

+ 8
- 3
common/controllers/CommonController.php Dosyayı Görüntüle

@@ -51,11 +51,16 @@ class CommonController extends \yii\web\Controller
public function beforeAction($event)
{
if (!Yii::$app->user->isGuest) {
$this->getUserManager()->updateUserLastConnection(Yii::$app->user->identity);
$this->getUserModule()->updateUserLastConnection(Yii::$app->user->identity);
}

return parent::beforeAction($event);
}
}

public function actionMaintenance()
{
return $this->renderFile('@common/views/maintenance.php');
}

public function getLogic(): BusinessLogic
{
@@ -84,7 +89,7 @@ class CommonController extends \yii\web\Controller

public function isUserCurrentAdmin()
{
return $this->getUserManager()->isAdmin($this->getUserCurrent());
return $this->getUserModule()->isAdmin($this->getUserCurrent());
}

public function getRequest()

+ 4
- 4
common/forms/SubscriptionForm.php Dosyayı Görüntüle

@@ -42,7 +42,7 @@ use common\logic\Product\Product\Model\Product;
use common\logic\Subscription\ProductSubscription\Model\ProductSubscription;
use common\logic\Subscription\Subscription\Model\Subscription;
use common\logic\Subscription\Subscription\Wrapper\SubscriptionManager;
use common\logic\User\User\Wrapper\UserManager;
use common\logic\User\User\Wrapper\UserModule;
use Yii;
use yii\base\Model;

@@ -117,15 +117,15 @@ class SubscriptionForm extends Model
*/
public function save()
{
$userManager = UserManager::getInstance();
$userModule = UserModule::getInstance();
$subscriptionManager = SubscriptionManager::getInstance();

if ($this->id) {
$subscription = Subscription::searchOne(['id' => $this->id]) ;
$subscription->populateUpdatedBy($userManager->getCurrent());
$subscription->populateUpdatedBy($userModule->getCurrent());
}
else {
$subscription = $subscriptionManager->instanciateSubscription($userManager->getCurrent()) ;
$subscription = $subscriptionManager->instanciateSubscription($userModule->getCurrent()) ;
}

if ($subscription) {

+ 10
- 4
common/helpers/Tiller.php Dosyayı Görüntüle

@@ -80,12 +80,13 @@ class Tiller
}
}

public function isSynchro($date)
public function isSynchro($date, $idOrder = null)
{
$orderManager = OrderManager::getInstance();

if ($this->producer_tiller) {
$ordersTiller = $this->getOrders($date);

$ordersOpendistrib = Order::searchAll([
'distribution.date' => $date,
'order.tiller_synchronization' => 1
@@ -115,9 +116,14 @@ class Tiller
}
}

foreach ($ordersOpendistribSynchro as $idOrder => $isSynchro) {
if (!$isSynchro) {
return false;
if($idOrder && isset($ordersOpendistribSynchro[$idOrder])) {
return $ordersOpendistribSynchro[$idOrder];
}
else {
foreach ($ordersOpendistribSynchro as $idOrder => $isSynchro) {
if (!$isSynchro) {
return false;
}
}
}


+ 27
- 0
common/logic/AbstractModule.php Dosyayı Görüntüle

@@ -0,0 +1,27 @@
<?php

namespace common\logic;

use yii\base\ErrorException;

abstract class AbstractModule extends AbstractSingleton implements ModuleInterface
{
public function getEntityFqcn(): string
{
return $this->getDefinition()->getEntityFqcn();
}

public function __call($method, $args)
{
foreach($this->getServices() as $serviceClass) {
if(method_exists($serviceClass, $method)) {
return call_user_func_array(
[$serviceClass::getInstance(), $method],
$args
);
}
}

throw new ErrorException('La méthode '.$method.' est introuvable dans les services du module '.get_class($this));
}
}

+ 3
- 0
common/logic/AbstractSingleton.php Dosyayı Görüntüle

@@ -15,6 +15,9 @@ abstract class AbstractSingleton
trigger_error("Le clonage n'est pas autorisé.", E_USER_ERROR);
}*/

/**
* @return $this
*/
final public static function getInstance(): self
{
$c = get_called_class();

+ 1
- 1
common/logic/Distribution/Distribution/Service/DistributionBuilder.php Dosyayı Görüntüle

@@ -155,7 +155,7 @@ class DistributionBuilder extends AbstractBuilder

public function updateOrderProductPrices(Distribution $distribution, Product $product): void
{
$ordersArray = $this->orderRepository->findOrdersByDistribution($distribution, 'origin != "user"');
$ordersArray = $this->orderRepository->findOrdersByDistribution($distribution, false, 'origin != "user"');

if ($ordersArray) {
foreach ($ordersArray as $order) {

+ 0
- 1
common/logic/Distribution/Distribution/Service/DistributionReportPdfGenerator.php Dosyayı Görüntüle

@@ -18,7 +18,6 @@ use common\logic\Product\Product\Model\Product;
use common\logic\Product\Product\Repository\ProductRepository;
use common\logic\Product\Product\Service\ProductSolver;
use common\logic\User\User\Repository\UserRepository;
use common\logic\User\UserProducer\Model\UserProducer;
use kartik\mpdf\Pdf;

class DistributionReportPdfGenerator extends AbstractGenerator

+ 108
- 0
common/logic/Distribution/Distribution/Service/DistributionShoppingCartLabelsPdfGenerator.php Dosyayı Görüntüle

@@ -0,0 +1,108 @@
<?php

namespace common\logic\Distribution\Distribution\Service;

use common\logic\AbstractGenerator;
use common\logic\Distribution\Distribution\Model\Distribution;
use common\logic\Order\Order\Repository\OrderRepository;
use kartik\mpdf\Pdf;

class DistributionShoppingCartLabelsPdfGenerator extends AbstractGenerator
{
protected OrderRepository $orderRepository;

public function loadDependencies(): void
{
$this->orderRepository = $this->loadService(OrderRepository::class);
}

public function generateDistributionShoppingCartLabelsPdf(Distribution $distribution)
{
$ordersArray = $this->orderRepository->findOrdersByDistribution($distribution);

$content = \Yii::$app->getView()->render('@backend/views/distribution/shopping-cart-labels.php', [
'distribution' => $distribution,
'ordersArray' => $ordersArray,
]);

$pdf = new Pdf([
'mode' => Pdf::MODE_UTF8,
'format' => Pdf::FORMAT_A4,
'orientation' => Pdf::ORIENT_PORTRAIT,
'destination' => Pdf::DEST_BROWSER,
'filename' => \Yii::getAlias(
'@app/web/pdf/Etiquettes-' . $distribution->date . '-' . $this->getProducerContextId() . '.pdf'
),
'content' => $content,
'cssInline' => $this->getCss(),
'methods' => [
'SetHeader' => ['Étiquettes du ' . date('d/m/Y', strtotime($distribution->date))],
'SetFooter' => ['{PAGENO}'],
]
]);

return $pdf->render();
}

public function getCss(): string
{
return '
@page {
margin: 0px 0px 0px 0px !important;
padding: 0px 0px 0px 0px !important;
}
body {
font-family: Arial, Helvetica, sans-serif;
font-size: 13px;
}
.clr {
clear: both;
}
.shopping-cart-label {
box-sizing: border-box;
width: 49.9%;
height: 368px;
float: left;
text-align: center;
}
.shopping-cart-label.shopping-cart-label-0,
.shopping-cart-label.shopping-cart-label-2 {
border-bottom: solid 1px #e0e0e0;
border-right: solid 1px #e0e0e0;
}
.shopping-cart-label.shopping-cart-label-1,
.shopping-cart-label.shopping-cart-label-3 {
border-bottom: solid 1px #e0e0e0;
}
.shopping-cart-label.shopping-cart-label-4 {
border-right: solid 1px #e0e0e0;
}
.shopping-cart-label .inner {
padding: 20px;
}
.shopping-cart-label .username {
margin-bottom: 3px;
font-weight: bold;
font-size: 18px;
}
.shopping-cart-label .point-sale {
margin-bottom: 10px;
font-size: 15px;
text-transform: uppercase;
}
.shopping-cart-label .products {
}
';
}
}

+ 2
- 0
common/logic/Distribution/Distribution/Wrapper/DistributionContainer.php Dosyayı Görüntüle

@@ -9,6 +9,7 @@ use common\logic\Distribution\Distribution\Service\DistributionDefinition;
use common\logic\Distribution\Distribution\Service\DistributionReportCsvGenerator;
use common\logic\Distribution\Distribution\Service\DistributionReportGridPdfGenerator;
use common\logic\Distribution\Distribution\Service\DistributionReportPdfGenerator;
use common\logic\Distribution\Distribution\Service\DistributionShoppingCartLabelsPdfGenerator;
use common\logic\Distribution\Distribution\Service\DistributionSolver;

class DistributionContainer extends AbstractContainer
@@ -23,6 +24,7 @@ class DistributionContainer extends AbstractContainer
DistributionReportCsvGenerator::class,
DistributionReportGridPdfGenerator::class,
DistributionReportPdfGenerator::class,
DistributionShoppingCartLabelsPdfGenerator::class
];
}


+ 2
- 0
common/logic/Distribution/Distribution/Wrapper/DistributionManager.php Dosyayı Görüntüle

@@ -9,6 +9,7 @@ use common\logic\Distribution\Distribution\Service\DistributionDefinition;
use common\logic\Distribution\Distribution\Service\DistributionReportCsvGenerator;
use common\logic\Distribution\Distribution\Service\DistributionReportGridPdfGenerator;
use common\logic\Distribution\Distribution\Service\DistributionReportPdfGenerator;
use common\logic\Distribution\Distribution\Service\DistributionShoppingCartLabelsPdfGenerator;
use common\logic\Distribution\Distribution\Service\DistributionSolver;

/**
@@ -19,6 +20,7 @@ use common\logic\Distribution\Distribution\Service\DistributionSolver;
* @mixin DistributionReportCsvGenerator
* @mixin DistributionReportGridPdfGenerator
* @mixin DistributionReportPdfGenerator
* @mixin DistributionShoppingCartLabelsPdfGenerator
*/
class DistributionManager extends AbstractManager
{

+ 8
- 0
common/logic/ModuleInterface.php Dosyayı Görüntüle

@@ -0,0 +1,8 @@
<?php

namespace common\logic;

interface ModuleInterface
{
public function getServices(): array;
}

+ 15
- 12
common/logic/Order/Order/Repository/OrderRepository.php Dosyayı Görüntüle

@@ -71,7 +71,6 @@ class OrderRepository extends AbstractRepository
'productOrder',
'productOrder.product',
'productOrder.taxRate',
'pointSale',
'payment',
'payment.user',
'payment.userAction',
@@ -83,6 +82,7 @@ class OrderRepository extends AbstractRepository
'distribution',
'user',
'user.userProducer',
'pointSale',
],
self::ORDER_BY => 'order.date ASC',
self::ATTRIBUTE_ID_PRODUCER => 'distribution.id_producer'
@@ -124,14 +124,18 @@ class OrderRepository extends AbstractRepository
->find();
}

public function findOrdersByDistribution(Distribution $distribution, string $conditionAppend = '')
public function findOrdersByDistribution(Distribution $distribution, bool $filterIsValid = true, string $conditionAppend = '')
{
return $this->createDefaultQuery()
$query = $this->createDefaultQuery()
->filterByDistributionDate($distribution->date)
->filterIsValid()
->filterByCondition($conditionAppend)
->orderBy('user.lastname ASC, user.name ASC, comment_point_sale ASC')
->find();
->orderBy('point_sale.name ASC, user.lastname ASC, user.name ASC, comment_point_sale ASC');

if($filterIsValid) {
$query->filterIsValid();
}

return $query->find();
}

public function findOrdersByUserAndInvoice(User $user, Invoice $invoice)
@@ -326,9 +330,8 @@ class OrderRepository extends AbstractRepository
return $productDistributionArray;
}

public function isCreditAutoPayment(Order $order)
public function isCreditAutoPayment(Order $order, bool $debitCreditOnFunctioningOptional = false)
{
//$pointSale = $this->pointSaleRepository->findOnePointSaleById($order->id_point_sale);
$pointSale = $order->pointSale;

if($pointSale) {
@@ -339,7 +342,7 @@ class OrderRepository extends AbstractRepository
return true;
}
elseif ($creditFunctioning == Producer::CREDIT_FUNCTIONING_OPTIONAL) {
return false;
return $debitCreditOnFunctioningOptional;
}
elseif ($creditFunctioning == Producer::CREDIT_FUNCTIONING_USER) {
$userProducer = $this->userProducerRepository->findOneUserProducer($order->user);
@@ -521,7 +524,7 @@ class OrderRepository extends AbstractRepository
$classLabel = 'default';
$titleLabel = '';

if(!$amountPaid) {
if($amountPaid > -0.01 && $amountPaid < 0.01) {
if($isOrderPaid && $amountTotal != 0) {
$label = 'Facture payée';
}
@@ -553,7 +556,7 @@ class OrderRepository extends AbstractRepository
}

$orderPaymentStatus = $this->orderSolver->getPaymentStatus($order);
if($amountPaid == 0 && !$isOrderPaid) {
if($amountPaid > -0.01 && $amountPaid < 0.01 && !$isOrderPaid) {
$classLabel = 'default';
}
elseif($orderPaymentStatus == Order::PAYMENT_SURPLUS) {
@@ -565,7 +568,7 @@ class OrderRepository extends AbstractRepository
}
elseif($orderPaymentStatus == Order::PAYMENT_UNPAID) {
$classLabel = 'warning';
$titleLabel = 'Paiement partiel';
$titleLabel = 'Paiement partiel '.$amountPaid;
}

return '<span class="label label-'.$classLabel.'" title="'.$titleLabel.'">'.$label.'</span>';

+ 3
- 3
common/logic/Payment/Event/OrderObserver.php Dosyayı Görüntüle

@@ -5,7 +5,7 @@ namespace common\logic\Payment\Event;
use common\logic\Order\Order\Event\OrderDeleteEvent;
use common\logic\Order\Order\Model\Order;
use common\logic\Payment\Wrapper\PaymentManager;
use common\logic\User\User\Wrapper\UserManager;
use common\logic\User\User\Wrapper\UserModule;
use justcoded\yii2\eventlistener\observers\Observer;

class OrderObserver extends Observer
@@ -21,8 +21,8 @@ class OrderObserver extends Observer
{
$order = $event->order;
$paymentManager = PaymentManager::getInstance();
$userManager = UserManager::getInstance();
$userModule = UserModule::getInstance();

$paymentManager->refundOrderCredit($order, $userManager->getCurrent());
$paymentManager->refundOrderCredit($order, $userModule->getCurrent());
}
}

+ 7
- 1
common/logic/Payment/Service/PaymentUtils.php Dosyayı Görüntüle

@@ -121,9 +121,15 @@ class PaymentUtils extends AbstractService implements UtilsInterface
$amountPaid = round($this->orderSolver->getOrderAmount($order, Order::AMOUNT_PAID), 2);

if ($amountPaid >= 0.01 && $order->id_user) {

$amount = $this->orderSolver->getOrderAmount($order, Order::AMOUNT_PAID);
if($meanPayment == MeanPayment::CREDIT) {
$amount = $this->orderSolver->getOrderAmountPaidByCredit($order);
}

$this->paymentBuilder->createPayment(
Payment::TYPE_REFUND,
$this->orderSolver->getOrderAmount($order, Order::AMOUNT_PAID),
$amount,
$this->getProducerContext(),
$order->user,
$userAction,

+ 2
- 0
common/logic/PointSale/PointSale/Service/PointSaleSolver.php Dosyayı Görüntüle

@@ -4,7 +4,9 @@ namespace common\logic\PointSale\PointSale\Service;

use common\helpers\GlobalParam;
use common\logic\AbstractService;
use common\logic\Order\Order\Model\Order;
use common\logic\PointSale\PointSale\Model\PointSale;
use common\logic\Producer\Producer\Model\Producer;
use common\logic\SolverInterface;
use yii\helpers\Html;


+ 3
- 3
common/logic/User/User/Event/TicketObserver.php Dosyayı Görüntüle

@@ -1,7 +1,7 @@
<?php
namespace common\logic\User\User\Event;

use common\logic\User\User\Wrapper\UserManager;
use common\logic\User\User\Wrapper\UserModule;
use justcoded\yii2\eventlistener\observers\ActiveRecordObserver;
use yii\db\AfterSaveEvent;

@@ -10,8 +10,8 @@ class TicketObserver extends ActiveRecordObserver
public function inserted(AfterSaveEvent $event)
{
$ticket = $event->sender;
$userManager = UserManager::getInstance();
$userModule = UserModule::getInstance();

$userManager->sendMailNewTicketAdmin($ticket);
$userModule->sendMailNewTicketAdmin($ticket);
}
}

+ 11
- 1
common/logic/User/User/Model/User.php Dosyayı Görüntüle

@@ -51,11 +51,16 @@ use common\components\ActiveRecordCommon;
*/
class User extends ActiveRecordCommon implements IdentityInterface
{

const TYPE_INDIVIDUAL = 'individual';
const TYPE_LEGAL_PERSON = 'legal-person';
const TYPE_GUEST = 'guest';

public static array $types = [
self::TYPE_GUEST,
self::TYPE_INDIVIDUAL,
self::TYPE_LEGAL_PERSON
];

const STATUS_DELETED = 0;
const STATUS_ACTIVE = 10;
const STATUS_PRODUCER = 11;
@@ -258,6 +263,11 @@ class User extends ActiveRecordCommon implements IdentityInterface
return $this->lastname;
}

public function getStatus(): string
{
return $this->status;
}

/**
* @inheritdoc
*/

+ 30
- 8
common/logic/User/User/Model/UserSearch.php Dosyayı Görüntüle

@@ -42,6 +42,7 @@ use common\helpers\GlobalParam;
use common\logic\PointSale\PointSale\Model\PointSale;
use common\logic\Producer\Producer\Wrapper\ProducerManager;
use common\logic\User\User\Repository\UserRepository;
use common\logic\User\User\Wrapper\UserModule;
use yii\data\ActiveDataProvider;

class UserSearch extends User
@@ -50,12 +51,13 @@ class UserSearch extends User
var $subscribers;
var $inactive;
var $username;
var $contacts;

public function rules()
{
return [
[['no_mail', 'mail_distribution_monday', 'mail_distribution_tuesday', 'mail_distribution_wednesday', 'mail_distribution_thursday', 'mail_distribution_friday', 'mail_distribution_saturday', 'mail_distribution_sunday'], 'boolean'],
[['lastname', 'name', 'phone', 'address'], 'string'],
[['lastname', 'name', 'phone', 'address', 'type', 'newsletter', 'contacts'], 'string'],
[['id_point_sale', 'inactive', 'subscribers'], 'integer'],
[['date_last_connection', 'id_point_sale', 'username'], 'safe'],
];
@@ -63,6 +65,7 @@ class UserSearch extends User

public function search($params = [])
{
$userModule = UserModule::getInstance();
$producerManager = ProducerManager::getInstance();
$producer = GlobalParam::getCurrentProducer();

@@ -143,14 +146,33 @@ class UserSearch extends User
]);
}

$query->andFilterWhere([
'or',
['like', 'user.lastname', $this->username],
['like', 'user.name', $this->username],
['like', 'user.name_legal_person', $this->username],
]);
if (isset($this->newsletter) && is_numeric($this->newsletter)) {
$query->andWhere([
'user_producer.newsletter' => $this->newsletter
]);
}

if ($userModule->isTypeValid($this->type)) {
$query->andWhere(['user.type' => $this->type]);
}

if(strlen($this->username)) {
$query->andFilterWhere([
'or',
['like', 'user.lastname', $this->username],
['like', 'user.name', $this->username],
['like', 'user.name_legal_person', $this->username],
]);
}

if(strlen($this->contacts)) {
$query->andFilterWhere([
'or',
['like', 'user.email', $this->contacts],
['like', 'user.phone', $this->contacts],
]);
}

return $dataProvider;
}

}

+ 45
- 0
common/logic/User/User/Service/AuthorizationChecker.php Dosyayı Görüntüle

@@ -0,0 +1,45 @@
<?php

namespace common\logic\User\User\Service;

use common\logic\AbstractUtils;
use common\logic\User\User\Model\User;

class AuthorizationChecker extends AbstractUtils
{
protected UserSolver $userSolver;

public function loadDependencies(): void
{
$this->userSolver = $this->loadService(UserSolver::class);
}

public function isGrantedAsAdministrator(User $user = null): bool
{
if(!$user) {
return false;
}

return $this->userSolver->isStatusAdministrator($user);
}

public function isGrantedAsProducer(User $user = null): bool
{
if(!$user) {
return false;
}

return $this->isGrantedAsAdministrator($user)
|| $this->userSolver->isStatusProducer($user);
}

public function isGrantedAsUser(User $user = null): bool
{
if(!$user) {
return false;
}

return $this->isGrantedAsProducer($user)
|| $this->userSolver->isStatusUser($user);
}
}

common/logic/User/User/Service/NewsletterUtils.php → common/logic/User/User/Service/NewsletterManager.php Dosyayı Görüntüle

@@ -8,7 +8,7 @@ use common\logic\User\UserProducer\Repository\UserProducerRepository;
use common\logic\User\UserProducer\Service\UserProducerBuilder;
use common\logic\UtilsInterface;

class NewsletterUtils extends AbstractService implements UtilsInterface
class NewsletterManager extends AbstractService implements UtilsInterface
{
protected UserProducerRepository $userProducerRepository;
protected UserProducerBuilder $userProducerBuilder;

common/logic/User/User/Service/UserUtils.php → common/logic/User/User/Service/UserNotifier.php Dosyayı Görüntüle

@@ -3,25 +3,25 @@
namespace common\logic\User\User\Service;

use common\helpers\GlobalParam;
use common\helpers\Mailjet;
use common\logic\AbstractService;
use common\logic\AbstractNotifier;
use common\logic\Producer\Producer\Model\Producer;
use common\logic\Ticket\Ticket\Model\Ticket;
use common\logic\User\User\Model\User;
use common\logic\UtilsInterface;

class UserUtils extends AbstractService implements UtilsInterface
class UserNotifier extends AbstractNotifier implements UtilsInterface
{
protected UserSolver $userSolver;

public function loadDependencies(): void
{
parent::loadDependencies();
$this->userSolver = $this->loadService(UserSolver::class);
}

public function sendEmailSignup(User $user, Producer $producer)
{
\Yii::$app->mailerService->sendFromSite(
$this->mailer->sendFromSite(
'Inscription',
'signup',
[
@@ -40,7 +40,7 @@ class UserUtils extends AbstractService implements UtilsInterface
{
if (strlen($user->email)) {
$producer = Producer::findOne(GlobalParam::getCurrentProducerId());
\Yii::$app->mailerService->sendFromProducer(
$this->mailer->sendFromProducer(
'Inscription',
'createUserAdmin',
[
@@ -56,7 +56,7 @@ class UserUtils extends AbstractService implements UtilsInterface

public function sendMailNewTicketAdmin(Ticket $ticket)
{
\Yii::$app->mailerService->sendAdmin(
$this->mailer->sendAdmin(
'Nouveau ticket',
'newTicketAdmin',
[

+ 30
- 26
common/logic/User/User/Service/UserSolver.php Dosyayı Görüntüle

@@ -20,6 +20,21 @@ class UserSolver extends AbstractService implements SolverInterface
];
}

public function getTypeLabel(string $type): string
{
$typesArray = $this->getTypeChoicesArray();
if(key_exists($type, $typesArray)) {
return $typesArray[$type];
}

return '';
}

public function isTypeValid(string $type = null): bool
{
return in_array($type, User::$types);
}

public function getUsernameFromArray(array $modelArray, $withType = false): string
{
$username = '';
@@ -115,6 +130,11 @@ class UserSolver extends AbstractService implements SolverInterface
return $user->status == User::STATUS_ADMIN;
}

public function isStatusAdministrator(User $user): bool
{
return $user->getStatus() == User::STATUS_ADMIN;
}

/**
* Retourne si l'utilisateur est un producteur ou non.
*
@@ -125,6 +145,16 @@ class UserSolver extends AbstractService implements SolverInterface
|| $user->status == User::STATUS_PRODUCER) && $user->id_producer;
}

public function isStatusProducer(User $user): bool
{
return $user->getStatus() == User::STATUS_PRODUCER;
}

public function isStatusUser(User $user): bool
{
return $user->getStatus() == User::STATUS_ACTIVE;
}

/**
* Retourne l'utilisateur courant.
*
@@ -152,32 +182,6 @@ class UserSolver extends AbstractService implements SolverInterface
return !\Yii::$app->user->isGuest;
}

/**
* Retourne si l'utilisateur courant est un producteur ou non.
*
*/
public function isCurrentProducer(): bool
{
$user = $this->getCurrent();
if ($user) {
return $this->isProducer($user);
}
return false;
}

/**
* Retourne si l'utilisateur courant est un admin ou non.
*
*/
public function isCurrentAdmin(): bool
{
$user = $this->getCurrent();
if ($user) {
return $this->isAdmin($user);
}
return false;
}

/**
* Retourne l'ID de l'utilisateur courant connecté.
*

+ 13
- 6
common/logic/User/User/Wrapper/UserContainer.php Dosyayı Görüntüle

@@ -5,12 +5,13 @@ namespace common\logic\User\User\Wrapper;
use common\logic\AbstractContainer;
use common\logic\User\User\Repository\UserRepository;
use common\logic\User\User\Repository\UserRepositoryQuery;
use common\logic\User\User\Service\NewsletterUtils;
use common\logic\User\User\Service\AuthorizationChecker;
use common\logic\User\User\Service\NewsletterManager;
use common\logic\User\User\Service\UserBuilder;
use common\logic\User\User\Service\UserDefinition;
use common\logic\User\User\Service\UserNotifier;
use common\logic\User\User\Service\UsersCreditCsvGenerator;
use common\logic\User\User\Service\UserSolver;
use common\logic\User\User\Service\UserUtils;

class UserContainer extends AbstractContainer
{
@@ -22,9 +23,10 @@ class UserContainer extends AbstractContainer
UserRepositoryQuery::class,
UserRepository::class,
UserBuilder::class,
UserNotifier::class,
UsersCreditCsvGenerator::class,
UserUtils::class,
NewsletterUtils::class,
NewsletterManager::class,
AuthorizationChecker::class,
];
}

@@ -48,8 +50,13 @@ class UserContainer extends AbstractContainer
return UserBuilder::getInstance();
}

public function getUtils(): UserUtils
public function getNotifier(): UserNotifier
{
return UserUtils::getInstance();
return UserNotifier::getInstance();
}

public function getNewsletterManager(): NewsletterManager
{
return NewsletterManager::getInstance();
}
}

+ 0
- 29
common/logic/User/User/Wrapper/UserManager.php Dosyayı Görüntüle

@@ -1,29 +0,0 @@
<?php

namespace common\logic\User\User\Wrapper;

use common\logic\AbstractManager;
use common\logic\User\User\Repository\UserRepository;
use common\logic\User\User\Service\NewsletterUtils;
use common\logic\User\User\Service\UserBuilder;
use common\logic\User\User\Service\UserDefinition;
use common\logic\User\User\Service\UsersCreditCsvGenerator;
use common\logic\User\User\Service\UserSolver;
use common\logic\User\User\Service\UserUtils;

/**
* @mixin UserDefinition
* @mixin UserSolver
* @mixin UserRepository
* @mixin UserBuilder
* @mixin UserUtils
* @mixin UsersCreditCsvGenerator
* @mixin NewsletterUtils
*/
class UserManager extends AbstractManager
{
public function getContainerFqcn(): string
{
return UserContainer::class;
}
}

+ 83
- 0
common/logic/User/User/Wrapper/UserModule.php Dosyayı Görüntüle

@@ -0,0 +1,83 @@
<?php

namespace common\logic\User\User\Wrapper;

use common\logic\AbstractModule;
use common\logic\User\User\Model\User;
use common\logic\User\User\Repository\UserRepository;
use common\logic\User\User\Repository\UserRepositoryQuery;
use common\logic\User\User\Service\AuthorizationChecker;
use common\logic\User\User\Service\NewsletterManager;
use common\logic\User\User\Service\UserBuilder;
use common\logic\User\User\Service\UserDefinition;
use common\logic\User\User\Service\UserNotifier;
use common\logic\User\User\Service\UsersCreditCsvGenerator;
use common\logic\User\User\Service\UserSolver;

/**
* @mixin UserDefinition
* @mixin UserSolver
* @mixin UserRepository
* @mixin UserBuilder
* @mixin UserNotifier
* @mixin UsersCreditCsvGenerator
* @mixin NewsletterManager
* @mixin AuthorizationChecker
*/
class UserModule extends AbstractModule
{
public function getServices(): array
{
return [
UserDefinition::class,
UserSolver::class,
UserRepositoryQuery::class,
UserRepository::class,
UserBuilder::class,
UserNotifier::class,
UsersCreditCsvGenerator::class,
NewsletterManager::class,
AuthorizationChecker::class,
];
}

public function getDefinition(): UserDefinition
{
return UserDefinition::getInstance();
}

public function getSolver(): UserSolver
{
return UserSolver::getInstance();
}

public function getRepository(): UserRepository
{
return UserRepository::getInstance();
}

public function getBuilder(): UserBuilder
{
return UserBuilder::getInstance();
}

public function getNotifier(): UserNotifier
{
return UserNotifier::getInstance();
}

public function getUsersCreditCsvGenerator(): UsersCreditCsvGenerator
{
return UsersCreditCsvGenerator::getInstance();
}

public function getNewsletterManager(): NewsletterManager
{
return NewsletterManager::getInstance();
}

public function getAuthorizationChecker(): AuthorizationChecker
{
return AuthorizationChecker::getInstance();
}
}

+ 3
- 3
common/mail/paymentErrorProducer-html.php Dosyayı Görüntüle

@@ -36,15 +36,15 @@ pris connaissance de la licence CeCILL, et que vous en avez accepté les
termes.
*/

use common\logic\User\User\Wrapper\UserManager;
use common\logic\User\User\Wrapper\UserModule;
use yii\helpers\Html;

$userManager = UserManager::getInstance();
$userModule = UserModule::getInstance();

?>
<p>Bonjour,</p>

<p>Le client <strong><?= $userManager->getUsername($user) ?></strong> vient de passer une commande pour le <strong><?= date('d/m/Y',strtotime($distribution->date)) ?></strong> mais le paiement par carte bancaire n'a pas abouti.<br />
<p>Le client <strong><?= $userModule->getUsername($user) ?></strong> vient de passer une commande pour le <strong><?= date('d/m/Y',strtotime($distribution->date)) ?></strong> mais le paiement par carte bancaire n'a pas abouti.<br />
Il vient de recevoir un message pour régulariser le paiement par virement bancaire.</p>

<p>Sa commande a été enregistrée avec l'état "non payé".</p>

+ 3
- 3
common/mail/paymentErrorProducer-text.php Dosyayı Görüntüle

@@ -36,16 +36,16 @@ pris connaissance de la licence CeCILL, et que vous en avez accepté les
termes.
*/

use common\logic\User\User\Wrapper\UserManager;
use common\logic\User\User\Wrapper\UserModule;
use yii\helpers\Html;

$userManager = UserManager::getInstance();
$userModule = UserModule::getInstance();

?>

Bonjour,

Le client <?= $userManager->getUsername() ?> vient de passer une commande pour le <?= date('d/m/Y',strtotime($distribution->date)) ?> mais le paiement par carte bancaire n'a pas abouti.
Le client <?= $userModule->getUsername() ?> vient de passer une commande pour le <?= date('d/m/Y',strtotime($distribution->date)) ?> mais le paiement par carte bancaire n'a pas abouti.
Il vient de recevoir un message pour régulariser le paiement par virement bancaire.

Sa commande a été enregistrée avec l'état "non payé".

+ 3
- 1
common/versions/22.10.A.php Dosyayı Görüntüle

@@ -30,7 +30,9 @@ version(
"[Backend] Facture > créer : tri des utilisateurs par ordre alphabétique",
"Correctif connexion personnes morales"
]
]
],
[],
$userCurrent
);

?>

+ 3
- 1
common/versions/22.11.A.php Dosyayı Görüntüle

@@ -13,7 +13,9 @@ version(
"[Administration] Abonnements : suppression des commandes après la date de fin lors de l'arrêt d'un abonnement",
"[Administration] Distributions > calendrier : amélioration chargement automatique des distributions (affichage pastilles vertes)"
]
]
],
[],
$userCurrent
);

?>

+ 3
- 1
common/versions/22.11.B.php Dosyayı Görüntüle

@@ -13,7 +13,9 @@ version(
"[Administration] Développement : mise en avant des nouvelles versions et des informations de contact"
],
[]
]
],
[],
$userCurrent
);

?>

+ 3
- 1
common/versions/22.12.A.php Dosyayı Görüntüle

@@ -10,7 +10,9 @@ version(
"[Administration] Abonnements : comportement paiement automatique (déduit, oui, non)"
],
[]
]
],
[],
$userCurrent
);

?>

+ 3
- 1
common/versions/23.1.A.php Dosyayı Görüntüle

@@ -12,7 +12,9 @@ version(
"[Administration] Documents > listes : optimisation chargement",
"[Espace producteur] Commander : ajustement ordre des points de vente"
]
]
],
[],
$userCurrent
);

?>

+ 1
- 0
common/versions/23.10.A.php Dosyayı Görüntüle

@@ -22,6 +22,7 @@ version(
"[Administration] Correctif problème upload images webp"
]
],
$userCurrent
);

?>

+ 1
- 0
common/versions/23.10.B.php Dosyayı Görüntüle

@@ -26,6 +26,7 @@ version(
],
[]
],
$userCurrent
);

?>

+ 35
- 0
common/versions/23.10.C.php Dosyayı Görüntüle

@@ -0,0 +1,35 @@
<?php

require_once dirname(__FILE__).'/_macros.php';

version(
'16/10/2023',
[
[
"[Administration] Distributions : génération d'étiquettes",
"[Administration] Utilisateurs > liste : ajout filtres de recherche",
"[Administration] Utilisateurs > formulaire crédit : 'Prévenir l'utilisateur' coché par défaut",
"[Administration] Distributions > formulaire commande : possibilité de débiter la commande dans un contexte de crédit optionnel",
],
[
"[Espace producteur] Inscription / connexion : lien vers pages de connexion/inscription du producteur",
"[Espace producteur] Accueil : correctif colonnes tableau produits en version mobile",
"[Administration] Documents : filtres de recherches conservés lors d'un envoi d'email",
"[Administration] Distributions > Synchronisation Tiller : correctif synchronisation en double des commandes",
]
],
[
[
"[Administration] Producteurs : alerte au niveau des producteurs qui n'ont pas de coordonnées GPS",
"[Global] Page d'erreur personnalisée",
"[Global] Possibilité de mettre tout le site en maintenance"
],
[
"[Technique] Mise en place AuthorizationChecker",
"[Technique] Refactoring UserManager en UserModule"
]
],
$userCurrent
);

?>

+ 3
- 1
common/versions/23.3.A.php Dosyayı Görüntüle

@@ -13,7 +13,9 @@ version(
"[Administration] Export vers le logiciel Evoliz : ajout de la TVA + code classification vente"
],
[]
]
],
[],
$userCurrent
);

?>

+ 3
- 1
common/versions/23.4.A.php Dosyayı Görüntüle

@@ -12,7 +12,9 @@ version(
[
"Logiciel de caisse Tiller : synchronisation des commandes partiellement payées"
]
]
],
[],
$userCurrent
);

?>

+ 3
- 1
common/versions/23.6.A.php Dosyayı Görüntüle

@@ -14,7 +14,9 @@ version(
"[Espace producteur] Produits : mise en évidence des noms de produit",
"[Site] Profil utilisateur : permettre édition adresse email"
],
]
],
[],
$userCurrent
);

?>

+ 3
- 1
common/versions/23.6.B.php Dosyayı Görüntüle

@@ -21,7 +21,9 @@ version(
"[Espace producteur] Abonnements : correctif disponibilité produits par point de vente",
"Abonnements > ajout/modification : prise en compte des contraintes de délai et d'heure limite de commande dans la génération des commandes des distributions à venir"
]
]
],
[],
$userCurrent
);

?>

Bu fark içinde çok fazla dosya değişikliği olduğu için bazı dosyalar gösterilmiyor

Yükleniyor…
İptal
Kaydet