Bläddra i källkod

Refactoring services #885

refactoring
Guillaume 1 år sedan
förälder
incheckning
1a70bb505f
100 ändrade filer med 1233 tillägg och 653 borttagningar
  1. +1
    -1
      backend/controllers/AccessController.php
  2. +1
    -3
      backend/controllers/BackendController.php
  3. +1
    -1
      backend/controllers/CommunicateAdminController.php
  4. +3
    -6
      backend/controllers/CommunicateController.php
  5. +11
    -21
      backend/controllers/CronController.php
  6. +1
    -1
      backend/controllers/DeliveryNoteController.php
  7. +7
    -10
      backend/controllers/DevelopmentController.php
  8. +77
    -77
      backend/controllers/DistributionController.php
  9. +27
    -27
      backend/controllers/DocumentController.php
  10. +5
    -7
      backend/controllers/InvoiceController.php
  11. +60
    -60
      backend/controllers/OrderController.php
  12. +9
    -17
      backend/controllers/PointSaleController.php
  13. +9
    -9
      backend/controllers/ProducerAdminController.php
  14. +4
    -10
      backend/controllers/ProducerController.php
  15. +3
    -5
      backend/controllers/ProducerPriceRangeAdminController.php
  16. +2
    -14
      backend/controllers/ProductCategoryController.php
  17. +11
    -11
      backend/controllers/ProductController.php
  18. +2
    -2
      backend/controllers/QuotationController.php
  19. +4
    -6
      backend/controllers/ReportController.php
  20. +8
    -14
      backend/controllers/SiteController.php
  21. +1
    -4
      backend/controllers/StatsController.php
  22. +16
    -20
      backend/controllers/SubscriptionController.php
  23. +3
    -8
      backend/controllers/TaxRateAdminController.php
  24. +15
    -15
      backend/controllers/UserController.php
  25. +2
    -12
      backend/controllers/UserGroupController.php
  26. +3
    -3
      backend/models/MailForm.php
  27. +1
    -1
      backend/views/access/index.php
  28. +3
    -3
      backend/views/delivery-note/index.php
  29. +4
    -4
      backend/views/development/_form.php
  30. +8
    -8
      backend/views/development/development.php
  31. +11
    -11
      backend/views/distribution/report-bourlingue.php
  32. +2
    -2
      backend/views/distribution/report-grid.php
  33. +17
    -17
      backend/views/distribution/report.php
  34. +2
    -2
      backend/views/document/_download_product_line.php
  35. +2
    -2
      backend/views/document/_form.php
  36. +5
    -5
      backend/views/document/download.php
  37. +3
    -3
      backend/views/invoice/index.php
  38. +3
    -3
      backend/views/layouts/header.php
  39. +29
    -29
      backend/views/layouts/left.php
  40. +3
    -3
      backend/views/layouts/main-old.php
  41. +8
    -8
      backend/views/order/report.php
  42. +9
    -9
      backend/views/point-sale/_form.php
  43. +3
    -3
      backend/views/point-sale/index.php
  44. +2
    -2
      backend/views/producer-admin/_form.php
  45. +1
    -1
      backend/views/producer-admin/index.php
  46. +17
    -17
      backend/views/producer/update.php
  47. +5
    -5
      backend/views/product/_form.php
  48. +1
    -1
      backend/views/product/index.php
  49. +5
    -5
      backend/views/product/update/prices/_form.php
  50. +1
    -1
      backend/views/product/update/prices/list.php
  51. +2
    -2
      backend/views/quotation/index.php
  52. +1
    -1
      backend/views/site/index.php
  53. +4
    -4
      backend/views/subscription/_form.php
  54. +3
    -3
      backend/views/subscription/index.php
  55. +3
    -3
      backend/views/user/_form.php
  56. +3
    -3
      backend/views/user/credit.php
  57. +2
    -2
      backend/views/user/index.php
  58. +104
    -0
      common/components/BusinessLogic.php
  59. +6
    -6
      common/forms/SubscriptionForm.php
  60. +3
    -3
      common/helpers/Price.php
  61. +2
    -2
      common/helpers/Tiller.php
  62. +31
    -0
      common/logic/Config/TaxRate/TaxRateContainer.php
  63. +17
    -0
      common/logic/Config/TaxRate/TaxRateFactory.php
  64. +43
    -0
      common/logic/Config/TaxRate/TaxRateModel.php
  65. +37
    -0
      common/logic/Config/TaxRate/TaxRateRepository.php
  66. +4
    -5
      common/logic/Development/Development/DevelopmentModel.php
  67. +5
    -9
      common/logic/Development/DevelopmentPriority/DevelopmentPriorityModel.php
  68. +11
    -0
      common/logic/Distribution/Distribution/DistributionBuilder.php
  69. +43
    -0
      common/logic/Distribution/Distribution/DistributionContainer.php
  70. +16
    -0
      common/logic/Distribution/Distribution/DistributionFactory.php
  71. +18
    -20
      common/logic/Distribution/Distribution/DistributionModel.php
  72. +11
    -0
      common/logic/Distribution/Distribution/DistributionRepository.php
  73. +11
    -0
      common/logic/Distribution/Distribution/DistributionSolver.php
  74. +16
    -0
      common/logic/Distribution/PointSaleDistribution/PointSaleDistributionFactory.php
  75. +5
    -7
      common/logic/Distribution/PointSaleDistribution/PointSaleDistributionModel.php
  76. +16
    -0
      common/logic/Distribution/ProductDistribution/ProductDistributionFactory.php
  77. +7
    -7
      common/logic/Distribution/ProductDistribution/ProductDistributionModel.php
  78. +31
    -0
      common/logic/Document/DeliveryNote/DeliveryNoteContainer.php
  79. +16
    -0
      common/logic/Document/DeliveryNote/DeliveryNoteFactory.php
  80. +3
    -3
      common/logic/Document/DeliveryNote/DeliveryNoteModel.php
  81. +4
    -4
      common/logic/Document/DeliveryNote/DeliveryNoteSearch.php
  82. +11
    -0
      common/logic/Document/DeliveryNote/DeliveryNoteSolver.php
  83. +11
    -0
      common/logic/Document/Document/DocumentBuilder.php
  84. +37
    -0
      common/logic/Document/Document/DocumentContainer.php
  85. +10
    -10
      common/logic/Document/Document/DocumentModel.php
  86. +11
    -0
      common/logic/Document/Document/DocumentSolver.php
  87. +11
    -0
      common/logic/Document/Document/DocumentUtils.php
  88. +37
    -0
      common/logic/Document/Invoice/InvoiceContainer.php
  89. +16
    -0
      common/logic/Document/Invoice/InvoiceFactory.php
  90. +3
    -4
      common/logic/Document/Invoice/InvoiceModel.php
  91. +3
    -5
      common/logic/Document/Invoice/InvoiceSearch.php
  92. +39
    -0
      common/logic/Document/Quotation/QuotationContainer.php
  93. +16
    -0
      common/logic/Document/Quotation/QuotationFactory.php
  94. +3
    -3
      common/logic/Document/Quotation/QuotationModel.php
  95. +4
    -4
      common/logic/Document/Quotation/QuotationSearch.php
  96. +12
    -0
      common/logic/Order/Order/OrderBuilder.php
  97. +49
    -0
      common/logic/Order/Order/OrderContainer.php
  98. +16
    -0
      common/logic/Order/Order/OrderFactory.php
  99. +24
    -34
      common/logic/Order/Order/OrderModel.php
  100. +11
    -0
      common/logic/Order/Order/OrderRepository.php

+ 1
- 1
backend/controllers/AccessController.php Visa fil

@@ -95,7 +95,7 @@ class AccessController extends BackendController
])
->all() ;
$producer = Producer::searchOne() ;
$producer = ProducerModel::searchOne() ;

return $this->render('index', [
'usersArray' => $usersArray,

+ 1
- 3
backend/controllers/BackendController.php Visa fil

@@ -38,8 +38,6 @@ termes.

namespace backend\controllers;

use common\models\Producer ;

class BackendController extends \common\controllers\CommonController
{
/**
@@ -48,7 +46,7 @@ class BackendController extends \common\controllers\CommonController
*/
public function checkProductsPointsSale()
{
if (!Product::searchCount() || !PointSale::searchCount()) {
if (!ProductModel::searchCount() || !PointSaleModel::searchCount()) {
$this->redirect(['site/index', 'error_products_points_sale' => 1]);
}
}

+ 1
- 1
backend/controllers/CommunicateAdminController.php Visa fil

@@ -80,7 +80,7 @@ class CommunicateAdminController extends BackendController
public function actionIndex($section = 'producers')
{
if($section == 'producers') {
$producers = Producer::find()->where(['producer.active' => 1])->with(['contact'])->all() ;
$producers = ProducerModel::find()->where(['producer.active' => 1])->with(['contact'])->all() ;
$usersArray = [];
$users = [] ;
foreach ($producers as $producer) {

+ 3
- 6
backend/controllers/CommunicateController.php Visa fil

@@ -38,9 +38,6 @@ termes.

namespace backend\controllers;

use common\models\Producer ;
use common\models\UserModel ;

/**
* UserController implements the CRUD actions for User model.
*/
@@ -78,8 +75,8 @@ class CommunicateController extends BackendController
*/
public function actionIndex()
{
$producer = Producer::searchOne() ;
$pointsSaleArray = PointSale::searchAll() ;
$producer = ProducerModel::searchOne() ;
$pointsSaleArray = PointSaleModel::searchAll() ;
return $this->render('index', [
'producer' => $producer,
@@ -95,7 +92,7 @@ class CommunicateController extends BackendController
*/
public function actionInstructions()
{
$producer = Producer::searchOne() ;
$producer = ProducerModel::searchOne() ;

// get your HTML raw content without any layouts or scripts
$content = $this->renderPartial('instructions_multi', [

+ 11
- 21
backend/controllers/CronController.php Visa fil

@@ -39,18 +39,8 @@
namespace backend\controllers;

use Yii;
use common\models\UserModel;
use yii\data\ActiveDataProvider;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
use yii\filters\AccessControl;
use kartik\mpdf\Pdf;
use common\models\Producer;
use common\models\Order;
use common\models\Subscription;
use common\models\Distribution;
use common\models\CreditHistory;

/**
* UserController implements the CRUD actions for User model.
@@ -99,7 +89,7 @@ class CronController extends BackendController
$dateTime = strtotime("+7 day");
$dayStr = strtolower(date('l', $dateTime));
$fieldDeliveryDay = 'delivery_' . $dayStr;
$pointsSaleArray = PointSale::searchAll(['point_sale.id_producer' => $producer->id]);
$pointsSaleArray = PointSaleModel::searchAll(['point_sale.id_producer' => $producer->id]);
$activeDistribution = false;
foreach ($pointsSaleArray as $pointSale) {
if ($pointSale->$fieldDeliveryDay) {
@@ -108,7 +98,7 @@ class CronController extends BackendController
}

if ($activeDistribution) {
$distribution = Distribution::initDistribution(date('Y-m-d', $dateTime), $producer->id);
$distribution = DistributionModel::initDistribution(date('Y-m-d', $dateTime), $producer->id);
$distribution->active(true);
}
}
@@ -168,13 +158,13 @@ class CronController extends BackendController
}
}

$arrayProducers = Producer::searchAll();
$arrayProducers = ProducerModel::searchAll();

foreach ($arrayProducers as $producer) {
$countOrders = 0;
$mailOrdersSend = false;

$distribution = Distribution::findOne([
$distribution = DistributionModel::findOne([
'date' => $date,
'active' => 1,
'id_producer' => $producer->id,
@@ -186,22 +176,22 @@ class CronController extends BackendController
* Paiement des commandes (paiement automatique)
*/

$arrayOrders = Order::searchAll([
$arrayOrders = OrderModel::searchAll([
'distribution.date' => $date,
'distribution.id_producer' => $producer->id
], [
'conditions' => 'date_delete IS NULL'
]);

$configCredit = Producer::getConfig('credit', $producer->id);
$configCredit = ProducerModel::getConfig('credit', $producer->id);

if ($arrayOrders && is_array($arrayOrders)) {
foreach ($arrayOrders as $order) {
if ($order->auto_payment && $configCredit) {
if ($order->getAmount(Order::AMOUNT_REMAINING) > 0) {
if ($order->getAmount(OrderModel::AMOUNT_REMAINING) > 0) {
$order->saveCreditHistory(
CreditHistory::TYPE_PAYMENT,
$order->getAmount(Order::AMOUNT_REMAINING),
CreditHistoryModel::TYPE_PAYMENT,
$order->getAmount(OrderModel::AMOUNT_REMAINING),
$order->distribution->id_producer,
$order->id_user,
UserModel::ID_USER_SYSTEM
@@ -216,8 +206,8 @@ class CronController extends BackendController
* Envoi des commandes par email au producteur
*/

if (!strlen($forceDate) && Producer::getConfig('option_notify_producer_order_summary', $producer->id)) {
$arrayOrders = Order::searchAll([
if (!strlen($forceDate) && ProducerModel::getConfig('option_notify_producer_order_summary', $producer->id)) {
$arrayOrders = OrderModel::searchAll([
'distribution.date' => $date,
'distribution.id_producer' => $producer->id
], [

+ 1
- 1
backend/controllers/DeliveryNoteController.php Visa fil

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

+ 7
- 10
backend/controllers/DevelopmentController.php Visa fil

@@ -40,9 +40,6 @@ namespace backend\controllers;

use common\helpers\GlobalParam;
use Yii;
use common\models\UserModel;
use common\models\Development;
use common\models\DevelopmentPriority;
use yii\data\ActiveDataProvider;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
@@ -100,10 +97,10 @@ class DevelopmentController extends Controller
}


public function actionDevelopment($status = Development::STATUS_OPEN)
public function actionDevelopment($status = DevelopmentModel::STATUS_OPEN)
{
$dataProvider = new ActiveDataProvider([
'query' => Development::find()
'query' => DevelopmentModel::find()
->with(['developmentPriority', 'developmentPriorityCurrentProducer'])
->where(['status' => $status])
->orderBy('date DESC'),
@@ -184,13 +181,13 @@ class DevelopmentController extends Controller
*/
public function actionPriority($idDevelopment, $priority = null)
{
$develpmentPriority = DevelopmentPriority::searchOne([
$develpmentPriority = DevelopmentPriorityModel::searchOne([
'id_development' => $idDevelopment,
]) ;

if (in_array($priority, [DevelopmentPriority::PRIORITY_HIGH,
DevelopmentPriority::PRIORITY_NORMAL,
DevelopmentPriority::PRIORITY_LOW])) {
if (in_array($priority, [DevelopmentPriorityModel::PRIORITY_HIGH,
DevelopmentPriorityModel::PRIORITY_NORMAL,
DevelopmentPriorityModel::PRIORITY_LOW])) {

if ($develpmentPriority) {
$develpmentPriority->priority = $priority;
@@ -221,7 +218,7 @@ class DevelopmentController extends Controller
*/
protected function findModel($id)
{
if (($model = Development::findOne($id)) !== null) {
if (($model = DevelopmentModel::findOne($id)) !== null) {
return $model;
} else {
throw new NotFoundHttpException('The requested page does not exist.');

+ 77
- 77
backend/controllers/DistributionController.php Visa fil

@@ -96,7 +96,7 @@ class DistributionController extends BackendController

$orderUpdate = null;
if ($idOrderUpdate) {
$orderUpdate = Order::searchOne(['id' => $idOrderUpdate]);
$orderUpdate = OrderModel::searchOne(['id' => $idOrderUpdate]);
}

return $this->render('index', [
@@ -137,7 +137,7 @@ class DistributionController extends BackendController

$json['means_payment'] = MeanPayment::getAll();

$distributionsArray = Distribution::searchAll([
$distributionsArray = DistributionModel::searchAll([
'active' => 1
], [
'conditions' => [
@@ -159,7 +159,7 @@ class DistributionController extends BackendController

if ($dateObject && $dateObject->format($format) === $date) {
// distribution
$distribution = Distribution::initDistribution($date);
$distribution = DistributionModel::initDistribution($date);
$json['distribution'] = [
'id' => $distribution->id,
'active' => $distribution->active,
@@ -172,7 +172,7 @@ class DistributionController extends BackendController
];

// commandes
$ordersArray = Order::searchAll([
$ordersArray = OrderModel::searchAll([
'distribution.id' => $distribution->id,
], [
'orderby' => 'user.lastname ASC, user.name ASC'
@@ -193,7 +193,7 @@ class DistributionController extends BackendController
$json['distribution']['weight'] = number_format($weight, 2);

// products
$productsQuery = Product::find()
$productsQuery = ProductModel::find()
->orWhere(['id_producer' => GlobalParam::getCurrentProducerId(),])
->joinWith([
'taxRate',
@@ -210,7 +210,7 @@ class DistributionController extends BackendController
$potentialWeight = 0;

foreach ($productsArray as &$theProduct) {
$quantityOrder = Order::getProductQuantity($theProduct['id'], $ordersArray);
$quantityOrder = OrderModel::getProductQuantity($theProduct['id'], $ordersArray);
$theProduct['quantity_ordered'] = $quantityOrder;

if (!isset($theProduct['productDistribution'][0])) {
@@ -249,7 +249,7 @@ class DistributionController extends BackendController
$productOrderArray = [];
foreach ($order->productOrder as $productOrder) {
$productOrderArray[$productOrder->id_product] = [
'quantity' => $productOrder->quantity * Product::$unitsArray[$productOrder->unit]['coefficient'],
'quantity' => $productOrder->quantity * ProductModel::$unitsArray[$productOrder->unit]['coefficient'],
'unit' => $productOrder->unit,
'price' => number_format($productOrder->price, 3),
'invoice_price' => number_format($productOrder->invoice_price, 2),
@@ -278,12 +278,12 @@ class DistributionController extends BackendController
'wording' => $creditHistoryService->getStrWording($creditHistory),
'debit' => ($creditHistoryService->isTypeDebit($creditHistory) ? '- ' . $creditHistoryService->getAmount(
$creditHistory,
Order::AMOUNT_TOTAL,
OrderModel::AMOUNT_TOTAL,
true
) : ''),
'credit' => ($creditHistoryService->isTypeCredit($creditHistory) ? '+ ' . $creditHistoryService->getAmount(
$creditHistory,
Order::AMOUNT_TOTAL,
OrderModel::AMOUNT_TOTAL,
true
) : '')
];
@@ -306,10 +306,10 @@ class DistributionController extends BackendController
$order = array_merge($order->getAttributes(), [
'selected' => false,
'weight' => $order->weight,
'amount' => Price::numberTwoDecimals($order->getAmountWithTax(Order::AMOUNT_TOTAL)),
'amount_paid' => Price::numberTwoDecimals($order->getAmount(Order::AMOUNT_PAID)),
'amount_remaining' => Price::numberTwoDecimals($order->getAmount(Order::AMOUNT_REMAINING)),
'amount_surplus' => Price::numberTwoDecimals($order->getAmount(Order::AMOUNT_SURPLUS)),
'amount' => Price::numberTwoDecimals($order->getAmountWithTax(OrderModel::AMOUNT_TOTAL)),
'amount_paid' => Price::numberTwoDecimals($order->getAmount(OrderModel::AMOUNT_PAID)),
'amount_remaining' => Price::numberTwoDecimals($order->getAmount(OrderModel::AMOUNT_REMAINING)),
'amount_surplus' => Price::numberTwoDecimals($order->getAmount(OrderModel::AMOUNT_SURPLUS)),
'user' => (isset($order->user)) ? array_merge(
$order->user->getAttributes(),
$arrayCreditUser
@@ -326,7 +326,7 @@ class DistributionController extends BackendController
$json['orders'] = $ordersArray;

// points de vente
$pointsSaleArray = PointSale::find()
$pointsSaleArray = PointSaleModel::find()
->joinWith([
'pointSaleDistribution' => function ($q) use ($distribution) {
$q->where(['id_distribution' => $distribution->id]);
@@ -347,7 +347,7 @@ class DistributionController extends BackendController
$json['points_sale'] = $pointsSaleArray;

// bons de livraison
$deliveryNotesArray = DeliveryNote::searchAll([
$deliveryNotesArray = DeliveryNoteModel::searchAll([
'distribution.date' => $date,
], [
'join_with' => ['user AS user_delivery_note', 'orders', 'producer']
@@ -395,7 +395,7 @@ class DistributionController extends BackendController
$dateSaturday = date('Y-m-d', strtotime('Saturday', $start));
$dateSunday = date('Y-m-d', strtotime('Sunday', $start));

$weekDistribution = Distribution::find()
$weekDistribution = DistributionModel::find()
->andWhere([
'id_producer' => GlobalParam::getCurrentProducerId(),
'active' => 1,
@@ -424,7 +424,7 @@ class DistributionController extends BackendController
}

// abonnements manquants
$arraySubscriptions = Subscription::searchByDate($date);
$arraySubscriptions = SubscriptionModel::searchByDate($date);
$json['missing_subscriptions'] = [];
if ($distribution->active) {
foreach ($arraySubscriptions as $subscription) {
@@ -467,12 +467,12 @@ class DistributionController extends BackendController
{
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;

$order = Order::searchOne(['id' => $idOrder]);
$distribution = Distribution::findOne($idDistribution);
$order = OrderModel::searchOne(['id' => $idOrder]);
$distribution = DistributionModel::findOne($idDistribution);
$user = UserModel::findOne($idUser);
$pointSale = PointSale::findOne($idPointSale);
$pointSale = PointSaleModel::findOne($idPointSale);

$productsArray = Product::find()
$productsArray = ProductModel::find()
->where([
'id_producer' => GlobalParam::getCurrentProducerId(),
])->joinWith([
@@ -505,7 +505,7 @@ class DistributionController extends BackendController
$productOrderArray[$product['id']] = [
'quantity' => $quantity,
'unit' => $product->unit,
'unit_coefficient' => Product::$unitsArray[$product->unit]['coefficient'],
'unit_coefficient' => ProductModel::$unitsArray[$product->unit]['coefficient'],
'prices' => $priceArray,
'active' => $product->productDistribution[0]->active
&& (!$pointSale || $product->isAvailableOnPointSale($pointSale)),
@@ -518,7 +518,7 @@ class DistributionController extends BackendController

public function actionAjaxUpdateInvoicePrices($idOrder)
{
$order = Order::searchOne([
$order = OrderModel::searchOne([
'id' => (int)$idOrder
]);

@@ -581,7 +581,7 @@ class DistributionController extends BackendController
$idProducer = GlobalParam::getCurrentProducerId();
}

$ordersArray = Order::searchAll(
$ordersArray = OrderModel::searchAll(
[
'distribution.date' => $date,
'distribution.id_producer' => $idProducer
@@ -592,7 +592,7 @@ class DistributionController extends BackendController
]
);

$distribution = Distribution::searchOne([
$distribution = DistributionModel::searchOne([
'id_producer' => $idProducer
], [
'conditions' => 'date LIKE :date',
@@ -600,8 +600,8 @@ class DistributionController extends BackendController
]);

if ($distribution) {
$selectedProductsArray = ProductDistribution::searchByDistribution($distribution->id);
$pointsSaleArray = PointSale::searchAll([
$selectedProductsArray = ProductDistributionModel::searchByDistribution($distribution->id);
$pointsSaleArray = PointSaleModel::searchAll([
'point_sale.id_producer' => $idProducer
]);

@@ -610,7 +610,7 @@ class DistributionController extends BackendController
}

// produits
$productsArray = Product::find()
$productsArray = ProductModel::find()
->joinWith([
'productDistribution' => function ($q) use ($distribution) {
$q->where(['id_distribution' => $distribution->id]);
@@ -639,7 +639,7 @@ class DistributionController extends BackendController
'pointsSaleArray' => $pointsSaleArray,
'productsArray' => $productsArray,
'ordersArray' => $ordersArray,
'producer' => Producer::searchOne(['id' => $idProducer])
'producer' => ProducerModel::searchOne(['id' => $idProducer])
]);

$dateStr = date('d/m/Y', strtotime($date));
@@ -708,8 +708,8 @@ class DistributionController extends BackendController
} elseif ($type == 'csv') {
$datas = [];

$optionCsvExportAllProducts = Producer::getConfig('option_csv_export_all_products');
$optionCsvExportByPiece = Producer::getConfig('option_csv_export_by_piece');
$optionCsvExportAllProducts = ProducerModel::getConfig('option_csv_export_all_products');
$optionCsvExportByPiece = ProducerModel::getConfig('option_csv_export_by_piece');

// produits en colonne
$productsNameArray = ['', 'Commentaire'];
@@ -718,8 +718,8 @@ class DistributionController extends BackendController
$cpt = 2;
foreach ($productsArray as $product) {
$productsHasQuantity[$product->id] = 0;
foreach (Product::$unitsArray as $unit => $dataUnit) {
$quantity = Order::getProductQuantity($product->id, $ordersArray, true, $unit);
foreach (ProductModel::$unitsArray as $unit => $dataUnit) {
$quantity = OrderModel::getProductQuantity($product->id, $ordersArray, true, $unit);
if ($quantity) {
$productsHasQuantity[$product->id] += $quantity;
}
@@ -733,7 +733,7 @@ class DistributionController extends BackendController
$productUnit = $product->unit;
}

$productName .= ' (' . Product::strUnit($productUnit, 'wording_short', true) . ')';
$productName .= ' (' . ProductModel::strUnit($productUnit, 'wording_short', true) . ')';

$productsNameArray[] = $productName;
$productsIndexArray[$product->id] = $cpt++;
@@ -751,7 +751,7 @@ class DistributionController extends BackendController

if ($optionCsvExportByPiece) {
foreach ($order->productOrder as $productOrder) {
$orderLine[$productsIndexArray[$productOrder->id_product]] = Order::getProductQuantityPieces(
$orderLine[$productsIndexArray[$productOrder->id_product]] = OrderModel::getProductQuantityPieces(
$productOrder->id_product,
[$order]
);
@@ -767,7 +767,7 @@ class DistributionController extends BackendController
}
$orderLine[$productsIndexArray[$productOrder->id_product]] .= $productOrder->quantity;
if ($productOrder->product->unit != $productOrder->unit) {
$orderLine[$productsIndexArray[$productOrder->id_product]] .= Product::strUnit(
$orderLine[$productsIndexArray[$productOrder->id_product]] .= ProductModel::strUnit(
$productOrder->unit,
'wording_short',
true
@@ -836,7 +836,7 @@ class DistributionController extends BackendController
$idProducer = GlobalParam::getCurrentProducerId();
}

$distribution = Distribution::searchOne([
$distribution = DistributionModel::searchOne([
'id_producer' => $idProducer
], [
'conditions' => 'date LIKE :date',
@@ -844,7 +844,7 @@ class DistributionController extends BackendController
]);

if ($distribution) {
$ordersArray = Order::searchAll(
$ordersArray = OrderModel::searchAll(
[
'distribution.date' => $date,
'distribution.id_producer' => $idProducer
@@ -855,8 +855,8 @@ class DistributionController extends BackendController
]
);

$selectedProductsArray = ProductDistribution::searchByDistribution($distribution->id);
$pointsSaleArray = PointSale::searchAll([
$selectedProductsArray = ProductDistributionModel::searchByDistribution($distribution->id);
$pointsSaleArray = PointSaleModel::searchAll([
'point_sale.id_producer' => $idProducer
]);

@@ -891,14 +891,14 @@ class DistributionController extends BackendController
}

// catégories
$categoriesArray = ProductCategory::searchAll(
$categoriesArray = ProductCategoryModel::searchAll(
['id_producer' => $idProducer],
['orderby' => 'product_category.position ASC']
);
array_unshift($categoriesArray, null);

// produits
$productsArray = Product::find()
$productsArray = ProductModel::find()
->joinWith([
'productDistribution' => function ($q) use ($distribution) {
$q->where(['id_distribution' => $distribution->id]);
@@ -928,7 +928,7 @@ class DistributionController extends BackendController
'categoriesArray' => $categoriesArray,
'productsArray' => $productsArray,
'ordersArray' => $ordersArrayPaged,
'producer' => Producer::searchOne(['id' => $idProducer])
'producer' => ProducerModel::searchOne(['id' => $idProducer])
]);

$dateStr = date('d/m/Y', strtotime($date));
@@ -1027,13 +1027,13 @@ class DistributionController extends BackendController
public function actionReportTerredepains($date, $key)
{
if ($key == 'ef572cc148c001f0180c4a624189ed30') {
$producer = Producer::searchOne([
$producer = ProducerModel::searchOne([
'producer.slug' => 'terredepains'
]);

$idProducer = $producer->id;

$ordersArray = Order::searchAll(
$ordersArray = OrderModel::searchAll(
[
'distribution.date' => $date,
'distribution.id_producer' => $idProducer
@@ -1044,7 +1044,7 @@ class DistributionController extends BackendController
]
);

$distribution = Distribution::searchOne([
$distribution = DistributionModel::searchOne([
'distribution.id_producer' => $idProducer
], [
'conditions' => 'date LIKE :date',
@@ -1054,8 +1054,8 @@ class DistributionController extends BackendController
]);

if ($distribution) {
$selectedProductsArray = ProductDistribution::searchByDistribution($distribution->id);
$pointsSaleArray = PointSale::searchAll([
$selectedProductsArray = ProductDistributionModel::searchByDistribution($distribution->id);
$pointsSaleArray = PointSaleModel::searchAll([
'point_sale.id_producer' => $idProducer
]);

@@ -1064,7 +1064,7 @@ class DistributionController extends BackendController
}

// produits
$productsArray = Product::find()
$productsArray = ProductModel::find()
->joinWith([
'productDistribution' => function ($q) use ($distribution) {
$q->where(['id_distribution' => $distribution->id]);
@@ -1084,7 +1084,7 @@ class DistributionController extends BackendController
$productsHasQuantity = [];
$cpt = 1;
foreach ($productsArray as $product) {
$theUnit = Product::strUnit($product->unit, 'wording_short', true);
$theUnit = ProductModel::strUnit($product->unit, 'wording_short', true);
$theUnit = ($theUnit == 'p.') ? '' : ' (' . $theUnit . ')';
$productsNameArray[] = $product->name . $theUnit;
$productsIndexArray[$product->id] = $cpt++;
@@ -1121,7 +1121,7 @@ class DistributionController extends BackendController
}
$orderLine[$productsIndexArray[$productOrder->id_product]] .= $productOrder->quantity;
if ($productOrder->product->unit != $productOrder->unit) {
$orderLine[$productsIndexArray[$productOrder->id_product]] .= Product::strUnit($productOrder->unit, 'wording_short', true);
$orderLine[$productsIndexArray[$productOrder->id_product]] .= ProductModel::strUnit($productOrder->unit, 'wording_short', true);
}
}
$datas[] = $this->_lineOrderReportCSV($orderLine, $cpt - 1, true);
@@ -1151,8 +1151,8 @@ class DistributionController extends BackendController
{
$totalsPointSaleArray = [$label];
foreach ($productsArray as $product) {
foreach (Product::$unitsArray as $unit => $dataUnit) {
$quantity = Order::getProductQuantity($product->id, $ordersArray, false, $unit);
foreach (ProductModel::$unitsArray as $unit => $dataUnit) {
$quantity = OrderModel::getProductQuantity($product->id, $ordersArray, false, $unit);
if ($quantity) {
$index = $productsIndexArray[$product->id];
if (!isset($totalsPointSaleArray[$index])) {
@@ -1166,7 +1166,7 @@ class DistributionController extends BackendController
$totalsPointSaleArray[$index] .= $quantity;

if ($product->unit != $unit) {
$totalsPointSaleArray[$index] .= '' . Product::strUnit($unit, 'wording_short', true);
$totalsPointSaleArray[$index] .= '' . ProductModel::strUnit($unit, 'wording_short', true);
}
}
}
@@ -1180,8 +1180,8 @@ class DistributionController extends BackendController

foreach ($productsArray as $product) {
$quantity = 0;
foreach (Product::$unitsArray as $unit => $dataUnit) {
$quantityProduct = Order::getProductQuantity($product->id, $ordersArray, false, $unit);
foreach (ProductModel::$unitsArray as $unit => $dataUnit) {
$quantityProduct = OrderModel::getProductQuantity($product->id, $ordersArray, false, $unit);

if ($unit == 'piece') {
$quantity += $quantityProduct;
@@ -1228,7 +1228,7 @@ class DistributionController extends BackendController
{
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;

$productDistribution = ProductDistribution::searchOne([
$productDistribution = ProductDistributionModel::searchOne([
'id_distribution' => $idDistribution,
'id_product' => $idProduct,
]);
@@ -1244,7 +1244,7 @@ class DistributionController extends BackendController
{
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;

$productDistribution = ProductDistribution::searchOne([
$productDistribution = ProductDistributionModel::searchOne([
'id_distribution' => $idDistribution,
'id_product' => $idProduct,
]);
@@ -1258,7 +1258,7 @@ class DistributionController extends BackendController
{
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;

$pointSaleDistribution = PointSaleDistribution::searchOne([
$pointSaleDistribution = PointSaleDistributionModel::searchOne([
'id_distribution' => $idDistribution,
'id_point_sale' => $idPointSale,
]);
@@ -1281,7 +1281,7 @@ class DistributionController extends BackendController
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;

if ($idDistribution) {
$distribution = Distribution::searchOne([
$distribution = DistributionModel::searchOne([
'id' => $idDistribution
]);
}
@@ -1289,7 +1289,7 @@ class DistributionController extends BackendController
$format = 'Y-m-d';
$dateObject = DateTime::createFromFormat($format, $date);
if ($dateObject && $dateObject->format($format) === $date) {
$distribution = Distribution::initDistribution($date);
$distribution = DistributionModel::initDistribution($date);
}

if ($distribution) {
@@ -1320,7 +1320,7 @@ class DistributionController extends BackendController
$dateSaturday = date('Y-m-d', strtotime('Saturday', $start));
$dateSunday = date('Y-m-d', strtotime('Sunday', $start));

$pointsSaleArray = PointSale::searchAll();
$pointsSaleArray = PointSaleModel::searchAll();

$activeMonday = false;
$activeTuesday = false;
@@ -1387,7 +1387,7 @@ class DistributionController extends BackendController
public function actionAjaxProcessAddSubscriptions($date)
{
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
Subscription::addAll($date, true);
SubscriptionModel::addAll($date, true);
return ['success'];
}

@@ -1400,14 +1400,14 @@ class DistributionController extends BackendController
{
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
$return = [];
$producerTiller = Producer::getConfig('tiller');
$producerTiller = ProducerModel::getConfig('tiller');

if ($producerTiller) {
$tiller = new Tiller();
$isSynchro = $tiller->isSynchro($date);

if (!$isSynchro) {
$orders = Order::searchAll([
$orders = OrderModel::searchAll([
'distribution.date' => $date,
'order.tiller_synchronization' => 1
], [
@@ -1457,7 +1457,7 @@ class DistributionController extends BackendController
[
'type' => $typePaymentTiller,
'amount' => $order->getAmountWithTax(
Order::AMOUNT_TOTAL
OrderModel::AMOUNT_TOTAL
) * 100,
'status' => 'ACCEPTED',
'date' => $strDate
@@ -1487,12 +1487,12 @@ class DistributionController extends BackendController

if (is_array($idOrders) && count($idOrders) > 0) {
foreach ($idOrders as $idOrder) {
$order = Order::searchOne([
$order = OrderModel::searchOne([
'id' => (int)$idOrder
]);

if ($order && $order->distribution->id_producer == GlobalParam::getCurrentProducerId()) {
$deliveryNote = DeliveryNote::searchOne([
$deliveryNote = DeliveryNoteModel::searchOne([
'id' => (int)$order->id_delivery_note
]);

@@ -1531,7 +1531,7 @@ class DistributionController extends BackendController

if (is_array($idOrders) && count($idOrders) > 0) {
foreach ($idOrders as $idOrder) {
$order = Order::searchOne([
$order = OrderModel::searchOne([
'id' => (int)$idOrder
]);

@@ -1540,7 +1540,7 @@ class DistributionController extends BackendController
$deliveryNote = null;
$idDeliveryNote = $order->id_delivery_note;
if ($idDeliveryNote) {
$deliveryNote = DeliveryNote::searchOne([
$deliveryNote = DeliveryNoteModel::searchOne([
'id' => (int)$idDeliveryNote
]);
}
@@ -1616,7 +1616,7 @@ class DistributionController extends BackendController
if (is_array($idOrders) && count($idOrders) > 0) {
// récupération première commande pour obtenir des infos
reset($idOrders);
$firstOrder = Order::searchOne([
$firstOrder = OrderModel::searchOne([
'id' => (int)$idOrders[key($idOrders)]
]);

@@ -1624,13 +1624,13 @@ class DistributionController extends BackendController
$deliveryNote = null;
$isUpdate = false;
$i = 0;
$ordersArray = Order::searchAll([
$ordersArray = OrderModel::searchAll([
'id' => $idOrders,
]);
do {
$order = $ordersArray[$i];
if ($order->distribution->id_producer == GlobalParam::getCurrentProducerId() && $order->id_delivery_note > 0) {
$deliveryNote = DeliveryNote::searchOne([
$deliveryNote = DeliveryNoteModel::searchOne([
'id' => $order->id_delivery_note
]);
$isUpdate = true;
@@ -1638,7 +1638,7 @@ class DistributionController extends BackendController
$i++;
} while ($deliveryNote == null && isset($ordersArray[$i]));

if ($deliveryNote && $deliveryNote->status == Document::STATUS_VALID) {
if ($deliveryNote && $deliveryNote->status == DocumentModel::STATUS_VALID) {
return [
'return' => 'error',
'alert' => [
@@ -1701,7 +1701,7 @@ class DistributionController extends BackendController
$deliveryNote->save();
} else {
// réinitialisation des order.id_delivery_note
Order::updateAll([
OrderModel::updateAll([
'id_delivery_note' => null
], [
'id_delivery_note' => $deliveryNote->id
@@ -1720,7 +1720,7 @@ class DistributionController extends BackendController

// affectation du BL aux commandes
foreach ($idOrders as $idOrder) {
$order = Order::searchOne([
$order = OrderModel::searchOne([
'id' => (int)$idOrder
]);
if ($order && $order->distribution->id_producer == GlobalParam::getCurrentProducerId()) {
@@ -1729,7 +1729,7 @@ class DistributionController extends BackendController
}

// init invoice price
$order = Order::searchOne(['id' => $idOrder]);
$order = OrderModel::searchOne(['id' => $idOrder]);
if ($order) {
$order->initInvoicePrices([
'user' => $user,

+ 27
- 27
backend/controllers/DocumentController.php Visa fil

@@ -82,9 +82,9 @@ class DocumentController extends BackendController
set_time_limit(0);

$validatedDocumentsArray = array_merge(
Quotation::find()->where(['status' => Document::STATUS_VALID])->all(),
DeliveryNote::find()->where(['status' => Document::STATUS_VALID])->all(),
Invoice::find()->where(['status' => Document::STATUS_VALID])->all()
QuotationModel::find()->where(['status' => DocumentModel::STATUS_VALID])->all(),
DeliveryNoteModel::find()->where(['status' => DocumentModel::STATUS_VALID])->all(),
InvoiceModel::find()->where(['status' => DocumentModel::STATUS_VALID])->all()
);

foreach($validatedDocumentsArray as $document) {
@@ -125,7 +125,7 @@ class DocumentController extends BackendController
if ($model->getClass() == 'Invoice') {
if ($model->deliveryNotes && is_array($model->deliveryNotes) && count($model->deliveryNotes)) {
foreach ($model->deliveryNotes as $key => $idDeliveryNote) {
Order::updateAll([
OrderModel::updateAll([
'id_invoice' => $model->id
], [
'id_delivery_note' => $idDeliveryNote
@@ -172,7 +172,7 @@ class DocumentController extends BackendController
$model->delete();

if ($this->getClass() == 'DeliveryNote') {
Order::updateAll([
OrderModel::updateAll([
'order.id_delivery_note' => null
], [
'order.id_delivery_note' => $id
@@ -180,7 +180,7 @@ class DocumentController extends BackendController
}

if ($this->getClass() == 'Quotation') {
Order::updateAll([
OrderModel::updateAll([
'order.id_quotation' => null
], [
'order.id_quotation' => $id
@@ -188,7 +188,7 @@ class DocumentController extends BackendController
}

if ($this->getClass() == 'Invoice') {
Order::updateAll([
OrderModel::updateAll([
'order.id_invoice' => null
], [
'order.id_invoice' => $id
@@ -282,7 +282,7 @@ class DocumentController extends BackendController
'', // Réf.
$productOrder->product->name, // Désignation *
$productOrder->quantity, // Qté *
'', // Product::strUnit($productOrder->unit, 'wording'), // Unité
'', // ProductModel::strUnit($productOrder->unit, 'wording'), // Unité
$price, // PU HT *
'', // Remise
$productOrder->taxRate->value * 100, // TVA
@@ -378,13 +378,13 @@ class DocumentController extends BackendController
'orderby' => 'distribution.date ASC',
'join_with' => ['user AS user_delivery_note', 'orders', 'producer']
];
$deliveryNotesCreateArray = DeliveryNote::searchAll([
$deliveryNotesCreateArray = DeliveryNoteModel::searchAll([
'id_user' => $user->id,
'status' => Document::STATUS_VALID
'status' => DocumentModel::STATUS_VALID
], $options);
$deliveryNotesUpdateArray = DeliveryNote::searchAll([
$deliveryNotesUpdateArray = DeliveryNoteModel::searchAll([
'id_user' => $user->id,
'status' => Document::STATUS_VALID,
'status' => DocumentModel::STATUS_VALID,
'order.id_invoice' => $idDocument
], $options);
$json['delivery_note_create_array'] = $this->initDeliveryNoteArray('create', $deliveryNotesCreateArray);
@@ -424,7 +424,7 @@ class DocumentController extends BackendController
$deliveryNote->getAttributes(),
[
'url' => Yii::$app->urlManager->createUrl(['delivery-note/update', 'id' => $deliveryNote->id]),
'total' => $deliveryNote->getAmountWithTax(Order::INVOICE_AMOUNT_TOTAL)
'total' => $deliveryNote->getAmountWithTax(OrderModel::INVOICE_AMOUNT_TOTAL)
]
);

@@ -439,7 +439,7 @@ class DocumentController extends BackendController
{
$classDocument = $this->getClass();

if ($id > 0 && Document::isValidClass($classDocument)) {
if ($id > 0 && DocumentModel::isValidClass($classDocument)) {
$document = $classDocument::searchOne([
'id' => $id
]);
@@ -470,7 +470,7 @@ class DocumentController extends BackendController
{
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;

if ($idDocument > 0 && Document::isValidClass($classDocument)) {
if ($idDocument > 0 && DocumentModel::isValidClass($classDocument)) {
$document = $classDocument::searchOne([
'id' => $idDocument
]);
@@ -501,13 +501,13 @@ class DocumentController extends BackendController
{
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;

if ($idDocument > 0 && Document::isValidClass($classDocument)) {
if ($idDocument > 0 && DocumentModel::isValidClass($classDocument)) {
$document = $classDocument::searchOne([
'id' => $idDocument
]);

if ($document) {
$productsArray = Product::searchAll([], [
$productsArray = ProductModel::searchAll([], [
'orderby' => 'product.order ASC'
]);

@@ -540,7 +540,7 @@ class DocumentController extends BackendController
'id_user' => $document->user->id,
'id_producer' => GlobalParam::getCurrentProducerId()
]);
$pointSale = PointSale::searchOne([
$pointSale = PointSaleModel::searchOne([
'id_user' => $document->user->id
]);

@@ -549,7 +549,7 @@ class DocumentController extends BackendController
'order',
function ($product) use ($document, $userProducer, $pointSale) {
return array_merge($product->getAttributes(), [
'unit_coefficient' => Product::$unitsArray[$product->unit]['coefficient'],
'unit_coefficient' => ProductModel::$unitsArray[$product->unit]['coefficient'],
'prices' => $product->getPriceArray($userProducer->user, $pointSale),
'wording_unit' => $product->wording_unit,
'tax_rate' => $product->taxRate->value
@@ -569,12 +569,12 @@ class DocumentController extends BackendController
'orders' => $ordersArray,
'total' => ($document->getClass() == 'Invoice' || $document->getClass(
) == 'DeliveryNote') ? $document->getAmount(
Order::INVOICE_AMOUNT_TOTAL
) : $document->getAmount(Order::AMOUNT_TOTAL),
OrderModel::INVOICE_AMOUNT_TOTAL
) : $document->getAmount(OrderModel::AMOUNT_TOTAL),
'total_with_tax' => ($document->getClass() == 'Invoice' || $document->getClass(
) == 'DeliveryNote') ? $document->getAmountWithTax(
Order::INVOICE_AMOUNT_TOTAL
) : $document->getAmountWithTax(Order::AMOUNT_TOTAL),
OrderModel::INVOICE_AMOUNT_TOTAL
) : $document->getAmountWithTax(OrderModel::AMOUNT_TOTAL),
'invoice_url' => ($document->getClass() == 'DeliveryNote' && $document->getInvoice()) ? Yii::$app->urlManager->createUrl(['invoice/update', 'id' => $document->getInvoice()->id]) : null
];
}
@@ -591,7 +591,7 @@ class DocumentController extends BackendController
$document = $classDocument::searchOne([
'id' => $idDocument
]);
$product = Product::searchOne([
$product = ProductModel::searchOne([
'id' => $idProduct
]);

@@ -602,7 +602,7 @@ class DocumentController extends BackendController
$order->id_point_sale = null;
$order->id_distribution = null;
$order->status = 'tmp-order';
$order->origin = Order::ORIGIN_ADMIN;
$order->origin = OrderModel::ORIGIN_ADMIN;
$order->date = date('Y-m-d H:i:s');
$fieldIdDocument = 'id_' . $classDocument::tableName();
$order->$fieldIdDocument = $document->id;
@@ -615,7 +615,7 @@ class DocumentController extends BackendController
$productOrder = new ProductOrder;
$productOrder->id_order = $order->id;
$productOrder->id_product = $idProduct;
$quantity = $quantity / Product::$unitsArray[$product->unit]['coefficient'];
$quantity = $quantity / ProductModel::$unitsArray[$product->unit]['coefficient'];
$productOrder->quantity = $quantity;
$productOrder->price = (float)$price;
$productOrder->unit = $product->unit;
@@ -647,7 +647,7 @@ class DocumentController extends BackendController
{
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;

$productOrder = ProductOrder::searchOne([
$productOrder = ProductOrderModel::searchOne([
'id' => $idProductOrder
]);


+ 5
- 7
backend/controllers/InvoiceController.php Visa fil

@@ -38,10 +38,8 @@ termes.

namespace backend\controllers;

use common\models\Order;
use Yii;


class InvoiceController extends DocumentController
{
/**
@@ -64,10 +62,10 @@ class InvoiceController extends DocumentController
{
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;

$invoice = Invoice::searchOne(['id' => $idInvoice]);
$invoice = InvoiceModel::searchOne(['id' => $idInvoice]);

if($invoice && $invoice->isStatusDraft()) {
Order::updateAll([
OrderModel::updateAll([
'id_invoice' => null
], [
'id_delivery_note' => $idDeliveryNote
@@ -94,11 +92,11 @@ class InvoiceController extends DocumentController
{
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;

$invoice = Invoice::searchOne(['id' => $idInvoice]);
$deliveryNote = DeliveryNote::searchOne(['id' => $idDeliveryNote]);
$invoice = InvoiceModel::searchOne(['id' => $idInvoice]);
$deliveryNote = DeliveryNoteModel::searchOne(['id' => $idDeliveryNote]);

if($invoice && $invoice->isStatusDraft() && $deliveryNote) {
Order::updateAll([
OrderModel::updateAll([
'id_invoice' => $idInvoice
], [
'id_delivery_note' => $idDeliveryNote

+ 60
- 60
backend/controllers/OrderController.php Visa fil

@@ -86,7 +86,7 @@ class OrderController extends BackendController
{
if ($date != '') {
// commandes
$orders = Order::searchAll([
$orders = OrderModel::searchAll([
'distribution.date' => $date
]);

@@ -98,7 +98,7 @@ class OrderController extends BackendController
foreach ($point->orders as $order) {

// suppression des product_order
ProductOrder::deleteAll(['id_order' => $order->id]);
ProductOrderModel::deleteAll(['id_order' => $order->id]);

// création des commande_produit modifiés
foreach ($products as $product) {
@@ -168,7 +168,7 @@ class OrderController extends BackendController
*/
public function actionIndex($date = '', $returnData = false)
{
if (!Product::searchCount() || !PointSale::searchCount()) {
if (!ProductModel::searchCount() || !PointSaleModel::searchCount()) {
$this->redirect(['site/index', 'error_products_points_sale' => 1]);
}

@@ -183,11 +183,11 @@ class OrderController extends BackendController
}

// création du jour de distribution
$distribution = Distribution::initDistribution($date);
$distribution = DistributionModel::initDistribution($date);

// points de vente
if ($distribution) {
$arrayPointsSale = PointSale::find()
$arrayPointsSale = PointSaleModel::find()
->joinWith(['pointSaleDistribution' => function ($q) use ($distribution) {
$q->where(['id_distribution' => $distribution->id]);
}])
@@ -196,17 +196,17 @@ class OrderController extends BackendController
])
->all();
} else {
$arrayPointsSale = PointSale::searchAll();
$arrayPointsSale = PointSaleModel::searchAll();
}

// produits
$arrayProducts = Product::searchAll();
$arrayProducts = ProductModel::searchAll();

// gestion des commandes
$this->processOrderForm($distribution, $date, $arrayPointsSale, $arrayProducts, $users);

// commandes
$arrayOrders = Order::searchAll([
$arrayOrders = OrderModel::searchAll([
'distribution.date' => $date,
]);

@@ -265,7 +265,7 @@ class OrderController extends BackendController
if (isset($_POST['Product'])) {

foreach ($arrayProducts as $product) {
$productDistribution = ProductDistribution::searchOne([
$productDistribution = ProductDistributionModel::searchOne([
'id_distribution' => $distribution->id,
'id_product' => $product->id
]);
@@ -306,12 +306,12 @@ class OrderController extends BackendController
$arrayProductsSelected = [];
if ($distribution) {
// produits selec pour production
$arrayProductsSelected = ProductDistribution::searchByDistribution($distribution->id);
$arrayProductsSelected = ProductDistributionModel::searchByDistribution($distribution->id);
}

// produits
if ($distribution) {
$arrayProducts = Product::searchByDistribution($distribution->id);
$arrayProducts = ProductModel::searchByDistribution($distribution->id);
}

// poids total de la production et CA potentiel
@@ -329,7 +329,7 @@ class OrderController extends BackendController
}

// jours de distribution
$arrayDistributionDays = Distribution::searchAll([
$arrayDistributionDays = DistributionModel::searchAll([
'active' => 1
]);

@@ -342,7 +342,7 @@ class OrderController extends BackendController
$oointsSaleDistribution = [];

if ($distribution) {
$pointsSaleDistribution = PointSaleDistribution::searchAll([
$pointsSaleDistribution = PointSaleDistributionModel::searchAll([
'id_distribution' => $distribution->id
]);
}
@@ -373,7 +373,7 @@ class OrderController extends BackendController
$dateSaturday = date('Y-m-d', strtotime('Saturday', $start));
$dateSunday = date('Y-m-d', strtotime('Sunday', $start));

$weekDistribution = Distribution::find()
$weekDistribution = DistributionModel::find()
->andWhere([
'id_producer' => GlobalParam::getCurrentProducerId(),
'active' => 1,
@@ -429,25 +429,25 @@ class OrderController extends BackendController
public function actionDownload($date = '', $idPointSale = 0, $global = 0)
{
// commandes
$ordersArray = Order::searchAll([
$ordersArray = OrderModel::searchAll([
'distribution.date' => $date
]);

// points de vente
$pointsSaleArray = PointSale::searchAll();
$pointsSaleArray = PointSaleModel::searchAll();
foreach ($pointsSaleArray as $pointSale) {
$pv->initOrders($ordersArray);
}

// produits
$productsArray = Product::find()->orderBy('order ASC')->all();
$productsArray = ProductModel::find()->orderBy('order ASC')->all();

$distribution = Distribution::find()
$distribution = DistributionModel::find()
->where('date LIKE \':date\'')
->params([':date' => $date])
->one();

$selectedProductsArray = ProductDistribution::searchByDistribution($distribution->id);
$selectedProductsArray = ProductDistributionModel::searchByDistribution($distribution->id);

/*
* export global
@@ -481,7 +481,7 @@ class OrderController extends BackendController
$strProducts = '';
foreach ($productsArray as $product) {
if (isset($selectedProductsArray[$product->id]['active']) && $selectedProductsArray[$product->id]['active']) {
$quantity = Order::getProductQuantity($product->id, $pointSale->orders);
$quantity = OrderModel::getProductQuantity($product->id, $pointSale->orders);
$strQuantity = '';
if ($quantity) {
$strQuantity = $quantity;
@@ -501,7 +501,7 @@ class OrderController extends BackendController
$strProducts = '';
foreach ($productsArray as $product) {
if (isset($selectedProductsArray[$product->id]['active']) && $selectedProductsArray[$product->id]['active']) {
$quantity = Order::getProductQuantity($product->id, $ordersArray);
$quantity = OrderModel::getProductQuantity($product->id, $ordersArray);
$strQuantity = '';
if ($quantity) {
$strQuantity = $quantity;
@@ -561,12 +561,12 @@ class OrderController extends BackendController
$data = [];
$filename = 'summary_' . $date;

$distribution = Distribution::find()
$distribution = DistributionModel::find()
->where('date LIKE \':date\'')
->params([':date' => $date])
->one();

$selectedProductsArray = ProductDistribution::searchByDistribution($distribution->id);
$selectedProductsArray = ProductDistributionModel::searchByDistribution($distribution->id);

// head
$data[0] = ['Lieu'];
@@ -587,7 +587,7 @@ class OrderController extends BackendController
$dataAdd = [$pointSale->name];
foreach ($products as $product) {
if (isset($selectedProductsArray[$product->id]['active']) && $selectedProductsArray[$product->id]['active']) {
$dataAdd[] = Order::getProductQuantity($product->id, $pointSale->orders);
$dataAdd[] = OrderModel::getProductQuantity($product->id, $pointSale->orders);
}
}
$data[] = $dataAdd;
@@ -597,7 +597,7 @@ class OrderController extends BackendController
$dataAdd = ['Total'];
foreach ($products as $product) {
if (isset($selectedProductsArray[$product->id]['active']) && $selectedProductsArray[$product->id]['active']) {
$dataAdd[] = Order::getProductQuantity($product->id, $orders);
$dataAdd[] = OrderModel::getProductQuantity($product->id, $orders);
}
}
$data[] = $dataAdd;
@@ -622,8 +622,8 @@ class OrderController extends BackendController
{
$data = [];

$distribution = Distribution::find()->where('date LIKE \':date\'')->params([':date' => $date])->one();
$selectedProductsArray = ProductDistribution::searchByDistribution($distribution->id);
$distribution = DistributionModel::find()->where('date LIKE \':date\'')->params([':date' => $date])->one();
$selectedProductsArray = ProductDistributionModel::searchByDistribution($distribution->id);

// datas
foreach ($pointsSale as $pointSale) {
@@ -686,13 +686,13 @@ class OrderController extends BackendController
public function actionChangeState($date, $active, $redirect = true)
{
// changement état
$distribution = Distribution::initDistribution($date);
$distribution = DistributionModel::initDistribution($date);
$distribution->active = $active;
$distribution->save();

if ($active) {
// add commandes automatiques
Subscription::addAll($date);
SubscriptionModel::addAll($date);
}

if ($redirect) {
@@ -718,7 +718,7 @@ class OrderController extends BackendController
$dateSaturday = date('Y-m-d', strtotime('Saturday', $start));
$dateSunday = date('Y-m-d', strtotime('Sunday', $start));

$pointsSaleArray = PointSale::searchAll();
$pointsSaleArray = PointSaleModel::searchAll();

$activeMonday = false;
$activeTuesday = false;
@@ -759,7 +759,7 @@ class OrderController extends BackendController
{
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;

$order = Order::searchOne([
$order = OrderModel::searchOne([
'id' => $idOrder
]);

@@ -780,15 +780,15 @@ class OrderController extends BackendController
*/
public function actionDelete($date, $idOrder)
{
$order = Order::searchOne(['id' => $idOrder]);
$order = OrderModel::searchOne(['id' => $idOrder]);

if ($order) {

// remboursement de la commande
if ($order->id_user && $order->getAmount(Order::AMOUNT_PAID) && Producer::getConfig('credit')) {
if ($order->id_user && $order->getAmount(OrderModel::AMOUNT_PAID) && ProducerModel::getConfig('credit')) {
$order->saveCreditHistory(
CreditHistory::TYPE_REFUND,
$order->getAmount(Order::AMOUNT_PAID),
CreditHistoryModel::TYPE_REFUND,
$order->getAmount(OrderModel::AMOUNT_PAID),
$order->distribution->id_producer,
$order->id_user,
UserModel::getCurrentId()
@@ -796,7 +796,7 @@ class OrderController extends BackendController
}

$order->delete();
ProductOrder::deleteAll(['id_order' => $idOrder]);
ProductOrderModel::deleteAll(['id_order' => $idOrder]);
}

$this->redirect(['index', 'date' => $date]);
@@ -819,8 +819,8 @@ class OrderController extends BackendController
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;

$products = json_decode($products);
$pointSale = PointSale::findOne($idPointSale);
$distribution = Distribution::searchOne([
$pointSale = PointSaleModel::findOne($idPointSale);
$distribution = DistributionModel::searchOne([
'date' => $date
]);

@@ -835,7 +835,7 @@ class OrderController extends BackendController
$order->id_point_sale = $idPointSale;
$order->mean_payment = $meanPayment;
$order->id_distribution = $distribution->id;
$order->origin = Order::ORIGIN_ADMIN;
$order->origin = OrderModel::ORIGIN_ADMIN;
$order->comment = $comment;
$order->status = 'tmp-order';

@@ -843,7 +843,7 @@ class OrderController extends BackendController
$order->id_user = $idUser;

// commentaire du point de vente
$userPointSale = UserPointSale::searchOne([
$userPointSale = UserPointSaleModel::searchOne([
'id_point_sale' => $idPointSale,
'id_user' => $idUser
]);
@@ -869,8 +869,8 @@ class OrderController extends BackendController
}

foreach ($products as $key => $dataProductOrder) {
$product = Product::findOne($key);
$quantity = $dataProductOrder->quantity / Product::$unitsArray[$dataProductOrder->unit]['coefficient'];
$product = ProductModel::findOne($key);
$quantity = $dataProductOrder->quantity / ProductModel::$unitsArray[$dataProductOrder->unit]['coefficient'];
if ($product && $quantity) {
$productOrder = new ProductOrder;
$productOrder->id_order = $order->id;
@@ -893,7 +893,7 @@ class OrderController extends BackendController
}
}

$order = Order::searchOne(['id' => $order->id]);
$order = OrderModel::searchOne(['id' => $order->id]);
if ($order && $processCredit) {
$order->processCredit();
}
@@ -936,7 +936,7 @@ class OrderController extends BackendController

\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;

$order = Order::searchOne(['id' => $idOrder]);
$order = OrderModel::searchOne(['id' => $idOrder]);

if ($order &&
$order->distribution->id_producer == GlobalParam::getCurrentProducerId()) {
@@ -947,7 +947,7 @@ class OrderController extends BackendController
$order->id_user = $idUser;

// commentaire du point de vente
$userPointSale = UserPointSale::searchOne([
$userPointSale = UserPointSaleModel::searchOne([
'id_point_sale' => $order->id_point_sale,
'id_user' => $idUser
]);
@@ -971,20 +971,20 @@ class OrderController extends BackendController

$products = json_decode($products);
foreach ($products as $key => $dataProductOrder) {
$productOrder = ProductOrder::findOne([
$productOrder = ProductOrderModel::findOne([
'id_order' => $idOrder,
'id_product' => $key
]);

$quantity = $dataProductOrder->quantity
/ Product::$unitsArray[$dataProductOrder->unit]['coefficient'];
/ ProductModel::$unitsArray[$dataProductOrder->unit]['coefficient'];

if ($quantity) {
if ($productOrder) {
$productOrder->quantity = $quantity;
$productOrder->price = $dataProductOrder->price;
} else {
$product = Product::findOne($key);
$product = ProductModel::findOne($key);

if ($product) {
$productOrder = new ProductOrder;
@@ -1023,19 +1023,19 @@ class OrderController extends BackendController

$order->save();

$order = Order::searchOne(['id' => $order->id]);
$order = OrderModel::searchOne(['id' => $order->id]);
if ($order && $processCredit) {
// Si changement d'user : on rembourse l'ancien user
$amountPaid = $order->getAmount(Order::AMOUNT_PAID);
$amountPaid = $order->getAmount(OrderModel::AMOUNT_PAID);
if($oldIdUser != $idUser && $amountPaid > 0) {
$order->saveCreditHistory(
CreditHistory::TYPE_REFUND,
CreditHistoryModel::TYPE_REFUND,
$amountPaid,
GlobalParam::getCurrentProducerId(),
$oldIdUser,
UserModel::getCurrentId()
);
$order = Order::searchOne(['id' => $order->id]);
$order = OrderModel::searchOne(['id' => $order->id]);
}

$order->processCredit();
@@ -1052,7 +1052,7 @@ class OrderController extends BackendController
public function actionPaymentStatus($idOrder)
{
$creditHistoryService = \Yii::$app->logic->getCreditHistoryContainer()->getService();
$order = Order::searchOne(['id' => $idOrder]);
$order = OrderModel::searchOne(['id' => $idOrder]);

if ($order) {
$html = '';
@@ -1065,11 +1065,11 @@ class OrderController extends BackendController
])
->one();

$amountPaid = $order->getAmount(Order::AMOUNT_PAID);
$amountPaid = $order->getAmount(OrderModel::AMOUNT_PAID);

if (abs($order->amount - $amountPaid) < 0.0001) {
$html .= '<span class="label label-success">Payé</span>';
$buttonsCredit = Html::a('Rembourser ' . $order->getAmountWithTax(Order::AMOUNT_TOTAL, true), 'javascript:void(0);', ['class' => 'btn btn-default btn-xs rembourser', 'data-montant' => $order->amount, 'data-type' => 'refund']);
$buttonsCredit = Html::a('Rembourser ' . $order->getAmountWithTax(OrderModel::AMOUNT_TOTAL, true), 'javascript:void(0);', ['class' => 'btn btn-default btn-xs rembourser', 'data-montant' => $order->amount, 'data-type' => 'refund']);
} elseif ($order->amount > $amountPaid) {
$amountToPay = $order->amount - $amountPaid;
$html .= '<span class="label label-danger">Non payé</span> reste <strong>' . number_format($amountToPay, 2) . ' €</strong> à payer';
@@ -1086,7 +1086,7 @@ class OrderController extends BackendController
. '</span>';

// historique
$history = CreditHistory::find()
$history = CreditHistoryModel::find()
->with('userAction')
->where(['id_order' => $idOrder])
->all();
@@ -1101,8 +1101,8 @@ class OrderController extends BackendController
. '<td>' . date('d/m/Y H:i:s', strtotime($creditHistoryService->getDate($creditHistory))) . '</td>'
. '<td>' . Html::encode($creditHistoryService->getStrUserAction($creditHistory)) . '</td>'
. '<td>' . $creditHistoryService->getStrWording($creditHistory) . '</td>'
. '<td>' . ($creditHistoryService->isTypeDebit($creditHistory) ? '- ' . $creditHistoryService->getAmountWithTax($creditHistory, Order::AMOUNT_TOTAL, true) : '') . '</td>'
. '<td>' . ($creditHistoryService->isTypeCredit($creditHistory) ? '+ ' . $creditHistoryService->getAmountWithTax($creditHistory, Order::AMOUNT_TOTAL, true) : '') . '</td>'
. '<td>' . ($creditHistoryService->isTypeDebit($creditHistory) ? '- ' . $creditHistoryService->getAmountWithTax($creditHistory, OrderModel::AMOUNT_TOTAL, true) : '') . '</td>'
. '<td>' . ($creditHistoryService->isTypeCredit($creditHistory) ? '+ ' . $creditHistoryService->getAmountWithTax($creditHistory, OrderModel::AMOUNT_TOTAL, true) : '') . '</td>'
. '</tr>';
}
} else {
@@ -1135,7 +1135,7 @@ class OrderController extends BackendController
{
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;

$order = Order::searchOne([
$order = OrderModel::searchOne([
'id' => $idOrder
]);

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

$order = Order::searchOne([
$order = OrderModel::searchOne([
'id' => (int)$idOrder
]);


+ 9
- 17
backend/controllers/PointSaleController.php Visa fil

@@ -40,16 +40,8 @@ namespace backend\controllers;

use Yii;
use yii\filters\AccessControl;
use common\models\PointSale;
use yii\data\ActiveDataProvider;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
use common\models\UserModel;
use common\models\UserPointSale;
use common\models\Order ;
use common\models\Producer ;
use common\models\Distribution ;
use yii\helpers\Html;

/**
@@ -109,7 +101,7 @@ class PointSaleController extends BackendController
if ($model->load(Yii::$app->request->post()) && $model->save()) {
$model->processPointProduction();
$model->processRestrictedAccess();
Distribution::linkPointSaleIncomingDistributions($model) ;
DistributionModel::linkPointSaleIncomingDistributions($model) ;
return $this->redirect(['index']);
} else {
return $this->render('create', array_merge($this->initForm(), [
@@ -126,7 +118,7 @@ class PointSaleController extends BackendController
*/
public function actionUpdate($id)
{
$model = PointSale::find()
$model = PointSaleModel::find()
->with('userPointSale')
->where(['id' => $id])
->one();
@@ -139,7 +131,7 @@ class PointSaleController extends BackendController
if ($model->load(Yii::$app->request->post()) && $model->save()) {
$model->processPointProduction();
$model->processRestrictedAccess();
Distribution::linkPointSaleIncomingDistributions($model) ;
DistributionModel::linkPointSaleIncomingDistributions($model) ;
Yii::$app->getSession()->setFlash('success', 'Point de vente modifié.');
return $this->redirect(['index']);
} else {
@@ -182,16 +174,16 @@ class PointSaleController extends BackendController
$pointSale->save();

// Suppression du lien entre les utilisateurs et le point de vente
UserPointSale::deleteAll(['id_point_sale' => $id]);
UserPointSaleModel::deleteAll(['id_point_sale' => $id]);

// Suppression du lien PointSaleDistribution pour toutes les distributions à venir
$incomingDistributions = Distribution::getIncomingDistributions();
$incomingDistributions = DistributionModel::getIncomingDistributions();
foreach ($incomingDistributions as $distribution) {
PointSaleDistribution::deleteAll(['id_point_sale' => $id, 'id_distribution' => $distribution->id]);
PointSaleDistributionModel::deleteAll(['id_point_sale' => $id, 'id_distribution' => $distribution->id]);
}

// Suppression de toutes les commandes à venir de ce point de vente
$ordersArray = Order::searchAll(
$ordersArray = OrderModel::searchAll(
[
'id_point_sale' => $id,
],
@@ -226,7 +218,7 @@ class PointSaleController extends BackendController
{
$pointSale = $this->findModel($id) ;
if($pointSale) {
PointSale::updateAll(['default' => 0], 'id_producer = :id_producer', [':id_producer' => GlobalParam::getCurrentProducerId()]) ;
PointSaleModel::updateAll(['default' => 0], 'id_producer = :id_producer', [':id_producer' => GlobalParam::getCurrentProducerId()]) ;
if(!$pointSale->default) {
$pointSale->default = 1 ;
$pointSale->save() ;
@@ -249,7 +241,7 @@ class PointSaleController extends BackendController
*/
protected function findModel($id)
{
if (($model = PointSale::findOne($id)) !== null) {
if (($model = PointSaleModel::findOne($id)) !== null) {
return $model;
}
else {

+ 9
- 9
backend/controllers/ProducerAdminController.php Visa fil

@@ -90,7 +90,7 @@ class ProducerAdminController extends BackendController
public function actionIndex()
{
$dataProviderProducer = new ActiveDataProvider([
'query' => Producer::find()
'query' => ProducerModel::find()
->with('userProducer', 'user')
->orderBy('active DESC, free_price DESC'),
'pagination' => [
@@ -98,7 +98,7 @@ class ProducerAdminController extends BackendController
],
]);

$producersArray = Producer::find()->where('active = 1')->all();
$producersArray = ProducerModel::find()->where('active = 1')->all();

$sumPrices = 0;
foreach($producersArray as $producer) {
@@ -161,14 +161,14 @@ class ProducerAdminController extends BackendController

$countOrders = 0;
if($withOrders) {
$countOrders = Order::searchCount([
$countOrders = OrderModel::searchCount([
'id_user' => $idUser,
'distribution.id_producer' => $fromProducerId
], ['conditions' => 'date_delete IS NULL']);
}

if(($withOrders && $countOrders) || !$withOrders) {
Producer::addUser($idUser, $toProducerId);
ProducerModel::addUser($idUser, $toProducerId);
$count ++;
}
}
@@ -190,12 +190,12 @@ class ProducerAdminController extends BackendController
*/
public function actionBill($idProducer)
{
$producer = Producer::findOne($idProducer);
$producer = ProducerModel::findOne($idProducer);

if ($producer) {
$period = date('Y-m', strtotime('-1 month'));

$last_invoice = Invoice::getLastInvoice() ;
$last_invoice = InvoiceModel::getLastInvoice() ;
if (!$last_invoice) {
$reference = 'BAP000001';
} else {
@@ -229,7 +229,7 @@ class ProducerAdminController extends BackendController
public function actionBilling()
{
$dataProviderInvoice = new ActiveDataProvider([
'query' => Invoice::find()
'query' => InvoiceModel::find()
->with('producer')
->orderBy('reference DESC'),
'pagination' => [
@@ -245,7 +245,7 @@ class ProducerAdminController extends BackendController
public function actionProducerInstallTaxUpdatePrices($idProducer)
{
// product
$productsArray = Product::searchAll([
$productsArray = ProductModel::searchAll([
'id_producer' => $idProducer
]) ;

@@ -280,7 +280,7 @@ class ProducerAdminController extends BackendController
* @throws NotFoundHttpException
*/
protected function findModel($id) {
if (($model = Producer::findOne($id)) !== null) {
if (($model = ProducerModel::findOne($id)) !== null) {
return $model;
} else {
throw new NotFoundHttpException('The requested page does not exist.');

+ 4
- 10
backend/controllers/ProducerController.php Visa fil

@@ -39,18 +39,12 @@
namespace backend\controllers;

use common\helpers\GlobalParam;
use common\models\ProducerPriceRange;
use Yii;
use common\models\UserModel;
use backend\models\MailForm;
use yii\data\ActiveDataProvider;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
use yii\filters\AccessControl;
use common\helpers\Upload;
use common\models\Producer;
use common\models\Invoice;

/**
* UserController implements the CRUD actions for User model.
@@ -163,7 +157,7 @@ class ProducerController extends BackendController
public function actionBilling()
{
$datasInvoices = new ActiveDataProvider([
'query' => Invoice::find()
'query' => InvoiceModel::find()
->where(['id_producer' => GlobalParam::getCurrentProducerId()])
->orderBy('reference DESC'),
'pagination' => [
@@ -171,7 +165,7 @@ class ProducerController extends BackendController
],
]);

$producer = Producer::findOne(GlobalParam::getCurrentProducerId());
$producer = ProducerModel::findOne(GlobalParam::getCurrentProducerId());

if ($producer->load(Yii::$app->request->post())) {
$producer->save();
@@ -182,7 +176,7 @@ class ProducerController extends BackendController
}

$dataProviderPrices = new ActiveDataProvider([
'query' => ProducerPriceRange::find()
'query' => ProducerPriceRangeModel::find()
->orderBy('id ASC'),
'pagination' => [
'pageSize' => 100,
@@ -206,7 +200,7 @@ class ProducerController extends BackendController
*/
protected function findModel($id)
{
if (($model = Producer::findOne($id)) !== null) {
if (($model = ProducerModel::findOne($id)) !== null) {
return $model;
} else {
throw new NotFoundHttpException('The requested page does not exist.');

+ 3
- 5
backend/controllers/ProducerPriceRangeAdminController.php Visa fil

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

namespace backend\controllers;

use common\models\ProducerPriceRange;
use Yii;
use common\models\UserModel;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
use yii\filters\AccessControl;
@@ -83,7 +81,7 @@ class ProducerPriceRangeAdminController extends BackendController
public function actionIndex()
{
$dataProvider = new ActiveDataProvider([
'query' => ProducerPriceRange::find()->orderBy('range_begin ASC')
'query' => ProducerPriceRangeModel::find()->orderBy('range_begin ASC')
]);

return $this->render('index', [
@@ -136,7 +134,7 @@ class ProducerPriceRangeAdminController extends BackendController
*/
public function actionDelete($id)
{
$producerPriceRange = ProducerPriceRange::searchOne([
$producerPriceRange = ProducerPriceRangeModel::searchOne([
'id' => $id
]) ;
$producerPriceRange->delete();
@@ -154,7 +152,7 @@ class ProducerPriceRangeAdminController extends BackendController
*/
protected function findModel($id)
{
if (($model = ProducerPriceRange::findOne($id)) !== null) {
if (($model = ProducerPriceRangeModel::findOne($id)) !== null) {
return $model;
} else {
throw new NotFoundHttpException('The requested page does not exist.');

+ 2
- 14
backend/controllers/ProductCategoryController.php Visa fil

@@ -39,22 +39,10 @@
namespace backend\controllers;

use common\helpers\GlobalParam;
use common\models\Product;
use common\models\ProductCategory;
use common\models\UserGroup;
use common\models\UserUserGroup;
use Yii;
use yii\filters\AccessControl;
use common\models\PointSale;
use yii\data\ActiveDataProvider;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
use common\models\UserModel;
use common\models\UserPointSale;
use common\models\Order;
use common\models\Producer;
use common\models\Distribution;
use yii\helpers\Html;

/**
@@ -155,7 +143,7 @@ class ProductCategoryController extends BackendController
$productCategory = $this->findModel($id);

$productCategory->delete();
Product::updateAll(['id_product_category' => null], ['id_product_category' => $id]);
ProductModel::updateAll(['id_product_category' => null], ['id_product_category' => $id]);
Yii::$app->getSession()->setFlash('success', 'Catégorie <strong>' . Html::encode($productCategory->name) . '</strong> supprimée.');

return $this->redirect(['index']);
@@ -187,7 +175,7 @@ class ProductCategoryController extends BackendController
*/
protected function findModel($id)
{
if (($model = ProductCategory::findOne($id)) !== null) {
if (($model = ProductCategoryModel::findOne($id)) !== null) {
return $model;
} else {
throw new NotFoundHttpException('The requested page does not exist.');

+ 11
- 11
backend/controllers/ProductController.php Visa fil

@@ -126,7 +126,7 @@ class ProductController extends BackendController

if ($model->load(Yii::$app->request->post()) && $model->save()) {

$lastProductOrder = Product::find()->where('id_producer = :id_producer')->params([':id_producer' => GlobalParam::getCurrentProducerId()])->orderBy('order DESC')->one();
$lastProductOrder = ProductModel::find()->where('id_producer = :id_producer')->params([':id_producer' => GlobalParam::getCurrentProducerId()])->orderBy('order DESC')->one();
if ($lastProductOrder) {
$model->order = ++$lastProductOrder->order;
}
@@ -138,7 +138,7 @@ class ProductController extends BackendController
$this->processAvailabilityPointsSale($model);

// link product / distribution
Distribution::linkProductIncomingDistributions($model);
DistributionModel::linkProductIncomingDistributions($model);

Yii::$app->getSession()->setFlash('success', 'Produit <strong>' . Html::encode($model->name) . '</strong> ajouté');

@@ -184,7 +184,7 @@ class ProductController extends BackendController

if ($model->apply_distributions) {
// link product / distribution
Distribution::linkProductIncomingDistributions($model);
DistributionModel::linkProductIncomingDistributions($model);
}

Yii::$app->getSession()->setFlash('success', 'Produit <strong>' . Html::encode($model->name) . '</strong> modifié');
@@ -202,11 +202,11 @@ class ProductController extends BackendController
*/
public function processAvailabilityPointsSale($model)
{
ProductPointSale::deleteAll(['id_product' => $model->id]);
ProductPointSaleModel::deleteAll(['id_product' => $model->id]);

if (is_array($model->pointsSale) && count($model->pointsSale)) {
foreach ($model->pointsSale as $key => $val) {
$pointSale = PointSale::findOne($val);
$pointSale = PointSaleModel::findOne($val);
if ($pointSale) {
$productPointSale = new ProductPointSale;
$productPointSale->id_product = $model->id;
@@ -235,7 +235,7 @@ class ProductController extends BackendController
'conditions' => 'user_producer.product_price_percent != 0',
]);

$pointSaleWithProductPercent = PointSale::searchAll([], [
$pointSaleWithProductPercent = PointSaleModel::searchAll([], [
'conditions' => 'point_sale.product_price_percent != 0'
]);

@@ -265,7 +265,7 @@ class ProductController extends BackendController
'from_quantity' => $model->from_quantity ? $model->from_quantity : null,
];

$productPriceExist = ProductPrice::findOne($conditionsProductPriceExist);
$productPriceExist = ProductPriceModel::findOne($conditionsProductPriceExist);

if ($productPriceExist) {
$productPriceExist->delete();
@@ -325,7 +325,7 @@ class ProductController extends BackendController

if ($confirm) {
$product->delete();
ProductDistribution::deleteAll(['id_product' => $id]);
ProductDistributionModel::deleteAll(['id_product' => $id]);
Yii::$app->getSession()->setFlash('success', 'Produit <strong>' . Html::encode($product->name) . '</strong> supprimé');
} else {
Yii::$app->getSession()->setFlash('info', 'Souhaitez-vous vraiment supprimer le produit <strong>' . Html::encode($product->name) . '</strong> ? '
@@ -359,7 +359,7 @@ class ProductController extends BackendController
$product->active = (int) $active;
$product->save();

Distribution::linkProductIncomingDistributions($product);
DistributionModel::linkProductIncomingDistributions($product);

return ['success', 'id' => $id, 'active' => $active];
}
@@ -373,7 +373,7 @@ class ProductController extends BackendController
*/
protected function findModel($id)
{
if (($model = Product::findOne($id)) !== null) {
if (($model = ProductModel::findOne($id)) !== null) {
return $model;
} else {
throw new NotFoundHttpException('The requested page does not exist.');
@@ -382,7 +382,7 @@ class ProductController extends BackendController

protected function findModelProductPrice($id)
{
if (($model = ProductPrice::findOne($id)) !== null) {
if (($model = ProductPriceModel::findOne($id)) !== null) {
return $model;
} else {
throw new NotFoundHttpException('The requested page does not exist.');

+ 2
- 2
backend/controllers/QuotationController.php Visa fil

@@ -60,7 +60,7 @@ class QuotationController extends DocumentController
'allow' => true,
'roles' => ['@'],
'matchCallback' => function ($rule, $action) {
return User::hasAccessBackend();
return UserModel::hasAccessBackend();
}
]
],
@@ -98,7 +98,7 @@ class QuotationController extends DocumentController
$invoice->name = str_replace(['Devis', 'devis'], 'Facture', $quotation->name);
$invoice->save() ;

Order::updateAll([
OrderModel::updateAll([
'order.id_invoice' => $invoice->id
], [
'order.id_quotation' => $id

+ 4
- 6
backend/controllers/ReportController.php Visa fil

@@ -41,8 +41,6 @@ namespace backend\controllers;
use common\helpers\GlobalParam;
use Yii;
use yii\filters\AccessControl;
use common\models\UserModel;
use common\models\Distribution ;

class ReportController extends BackendController
{
@@ -77,13 +75,13 @@ class ReportController extends BackendController
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
$usersArray = UserModel::findBy()->all() ;
$pointsSaleArray = PointSale::searchAll() ;
$pointsSaleArray = PointSaleModel::searchAll() ;
// distributions
$firstDistribution = Distribution::searchOne([], [
$firstDistribution = DistributionModel::searchOne([], [
'orderby' => 'date ASC'
]) ;
$lastDistribution = Distribution::searchOne([], [
$lastDistribution = DistributionModel::searchOne([], [
'orderby' => 'date DESC'
]) ;
@@ -94,7 +92,7 @@ class ReportController extends BackendController
$distributionYearsArray[] = $year ;
}
$distributionsArray = Distribution::searchAll([
$distributionsArray = DistributionModel::searchAll([
'distribution.active' => 1
], [
'orderby' => 'date ASC',

+ 8
- 14
backend/controllers/SiteController.php Visa fil

@@ -42,13 +42,7 @@ use common\helpers\GlobalParam;
use Yii;
use yii\filters\AccessControl;
use common\forms\LoginForm;
use common\models\UserModel;
use yii\filters\VerbFilter;
use common\models\Product;
use common\models\PointSale;
use common\models\Producer;
use common\models\Distribution;
use common\models\Order;

/**
* Site controller
@@ -118,13 +112,13 @@ class SiteController extends BackendController
{

// commandes
$optionDashboardNumberDistributions = Producer::getConfig('option_dashboard_number_distributions') ;
$optionDashboardNumberDistributions = ProducerModel::getConfig('option_dashboard_number_distributions') ;
$dashboardNumberDistributions = $optionDashboardNumberDistributions ? $optionDashboardNumberDistributions : 3 ;

$optionDashboardDateStart = Producer::getConfig('option_dashboard_date_start') ;
$optionDashboardDateEnd = Producer::getConfig('option_dashboard_date_end') ;
$optionDashboardDateStart = ProducerModel::getConfig('option_dashboard_date_start') ;
$optionDashboardDateEnd = ProducerModel::getConfig('option_dashboard_date_end') ;

$queryDistributions = Distribution::find()->with('order') ;
$queryDistributions = DistributionModel::find()->with('order') ;

if($optionDashboardDateStart || $optionDashboardDateEnd) {
if($optionDashboardDateStart) {
@@ -168,9 +162,9 @@ class SiteController extends BackendController
$paramsOrders[':date_start'] = date('Y-m-d 00:00:00') ;
}

$ordersArray = Order::searchAll([],[
$ordersArray = OrderModel::searchAll([],[
'orderby' => 'date DESC',
'conditions' => $conditionsOrders.' AND (origin = \'' . Order::ORIGIN_USER . '\' OR origin = \'' . Order::ORIGIN_ADMIN . '\' OR (origin = \'' . Order::ORIGIN_AUTO . '\' AND (date_update IS NOT NULL OR date_delete IS NOT NULL)))',
'conditions' => $conditionsOrders.' AND (origin = \'' . OrderModel::ORIGIN_USER . '\' OR origin = \'' . OrderModel::ORIGIN_ADMIN . '\' OR (origin = \'' . OrderModel::ORIGIN_AUTO . '\' AND (date_update IS NOT NULL OR date_delete IS NOT NULL)))',
'params' => $paramsOrders,
]);

@@ -187,8 +181,8 @@ class SiteController extends BackendController
// paramètres
$producer = GlobalParam::getCurrentProducer();

$productsCount = Product::searchCount() ;
$pointsSaleCount = PointSale::searchCount() ;
$productsCount = ProductModel::searchCount() ;
$pointsSaleCount = PointSaleModel::searchCount() ;

return $this->render('index', [
'distributionsArray' => $distributionsArray,

+ 1
- 4
backend/controllers/StatsController.php Visa fil

@@ -39,11 +39,8 @@ termes.
namespace backend\controllers;

use common\helpers\GlobalParam;
use yii\web\Controller;
use yii\filters\AccessControl;
use Yii;
use common\models\UserModel;
use common\models\Order;
use DateTime;
use DateInterval;
use DatePeriod;
@@ -145,7 +142,7 @@ class StatsController extends BackendController
{
if(!$year) $year = date('Y') ;
$productsArray = Product::searchAll() ;
$productsArray = ProductModel::searchAll() ;
$dataProducts = [] ;

+ 16
- 20
backend/controllers/SubscriptionController.php Visa fil

@@ -37,11 +37,7 @@ termes.

namespace backend\controllers;

use common\helpers\Debug;
use common\helpers\GlobalParam;
use common\models\Order ;
use common\models\Product ;
use common\models\SubscriptionSearch ;

class SubscriptionController extends BackendController
{
@@ -57,7 +53,7 @@ class SubscriptionController extends BackendController
'allow' => true,
'roles' => ['@'],
'matchCallback' => function ($rule, $action) {
return User::hasAccessBackend() ;
return UserModel::hasAccessBackend() ;
}
]
],
@@ -96,7 +92,7 @@ class SubscriptionController extends BackendController
$model->id_producer = GlobalParam::getCurrentProducerId();

if($idOrder) {
$order = Order::searchOne(['id' => $idOrder]);
$order = OrderModel::searchOne(['id' => $idOrder]);
if ($order) {
$model->id_user = $order->id_user;
$model->username = $order->username;
@@ -105,7 +101,7 @@ class SubscriptionController extends BackendController
$dateDay = strtolower(date('l',strtotime($order->distribution->date))) ;
$model->$dateDay = 1 ;
$model->week_frequency = 1 ;
if($model->id_user && Producer::getConfig('credit')) {
if($model->id_user && ProducerModel::getConfig('credit')) {
$model->auto_payment = 1 ;
}
@@ -119,7 +115,7 @@ class SubscriptionController extends BackendController
}
// produits
$productsArray = Product::searchAll([], [
$productsArray = ProductModel::searchAll([], [
'orderby' => 'product.order ASC'
]) ;
@@ -128,7 +124,7 @@ class SubscriptionController extends BackendController
{
Yii::$app->getSession()->setFlash('success', 'Abonnement ajouté');
$subscription = Subscription::findOne($model->id) ;
$subscription = SubscriptionModel::findOne($model->id) ;
$matchedDistributionsArray = $subscription->searchMatchedIncomingDistributions() ;
if(count($matchedDistributionsArray)) {
return $this->redirect(['subscription/update-distributions', 'idSubscription' => $subscription->id]);
@@ -156,7 +152,7 @@ class SubscriptionController extends BackendController
// form
$model = new SubscriptionForm;
$model->isAdmin = true ;
$subscription = Subscription::findOne($id);
$subscription = SubscriptionModel::findOne($id);
if ($subscription) {
$model->id = $id;
@@ -184,7 +180,7 @@ class SubscriptionController extends BackendController
}

// produits
$arrayProductsSubscription = ProductSubscription::searchAll([
$arrayProductsSubscription = ProductSubscriptionModel::searchAll([
'id_subscription' => $model->id
]) ;
@@ -196,7 +192,7 @@ class SubscriptionController extends BackendController
}

// produits
$productsArray = Product::searchAll([], [
$productsArray = ProductModel::searchAll([], [
'orderby' => 'product.order ASC'
]) ;

@@ -208,7 +204,7 @@ class SubscriptionController extends BackendController

if ($model->save()) {

$subscription = Subscription::findOne($model->id) ;
$subscription = SubscriptionModel::findOne($model->id) ;

$messageOrdersDeleted = '';
if($model->date_end) {
@@ -244,19 +240,19 @@ class SubscriptionController extends BackendController
*/
public function actionDelete($id)
{
$subscription = Subscription::searchOne([
$subscription = SubscriptionModel::searchOne([
'subscription.id' => $id
]) ;
$subscription->deleteOrdersIncomingDistributions() ;
$subscription->delete();
ProductSubscription::deleteAll(['id_subscription' => $id]);
ProductSubscriptionModel::deleteAll(['id_subscription' => $id]);
Yii::$app->getSession()->setFlash('success', 'Abonnement supprimé');
return $this->redirect(['subscription/index']);
}

public function actionUpdateDistributions($idSubscription, $generate = false, $update = false)
{
$subscription = Subscription::findOne($idSubscription) ;
$subscription = SubscriptionModel::findOne($idSubscription) ;
$matchedDistributionsArray = $subscription->searchMatchedIncomingDistributions() ;
if($generate) {
@@ -281,7 +277,7 @@ class SubscriptionController extends BackendController
{
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
$productsQuery = Product::find()
$productsQuery = ProductModel::find()
->where(['id_producer' => GlobalParam::getCurrentProducerId(),]) ;
if($idSubscription) {
@@ -302,13 +298,13 @@ class SubscriptionController extends BackendController
'price' => $theProduct['price']
] ;*/

$theProduct['wording_unit'] = Product::strUnit($theProduct['unit'], 'wording_short');
$theProduct['wording_unit'] = ProductModel::strUnit($theProduct['unit'], 'wording_short');

if(isset($theProduct['productSubscription'][0])) {
/*if($theProduct['productSubscription'][0]['unit'] != $theProduct['unit']) {
$theProduct['units'][] = [
'unit' => $theProduct['productSubscription'][0]['unit'],
'wording_unit' => Product::strUnit($theProduct['productSubscription'][0]['unit'], 'wording_short'),
'wording_unit' => ProductModel::strUnit($theProduct['productSubscription'][0]['unit'], 'wording_short'),
'step' => $theProduct['productSubscription'][0]['step'],
'price' => $theProduct['productSubscription'][0]['price'],
] ;
@@ -316,7 +312,7 @@ class SubscriptionController extends BackendController
$theProduct['step'] = $theProduct['productSubscription'][0]['step'] ;
$theProduct['price'] = $theProduct['productSubscription'][0]['price'] ;
}*/
$theProduct['quantity'] = $theProduct['productSubscription'][0]['quantity'] * Product::$unitsArray[$theProduct['unit']]['coefficient'] ;
$theProduct['quantity'] = $theProduct['productSubscription'][0]['quantity'] * ProductModel::$unitsArray[$theProduct['unit']]['coefficient'] ;
}
else {
$theProduct['quantity'] = '' ;

+ 3
- 8
backend/controllers/TaxRateAdminController.php Visa fil

@@ -38,16 +38,11 @@

namespace backend\controllers;

use common\models\TaxRate;
use Yii;
use common\models\UserModel;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
use yii\filters\AccessControl;
use common\helpers\Upload;
use common\models\Producer;
use yii\data\ActiveDataProvider;
use common\models\Invoice;

/**
* TaxRateAdminController implements the CRUD actions for TaxRate model.
@@ -87,7 +82,7 @@ class TaxRateAdminController extends BackendController
public function actionIndex()
{
$dataProviderTaxRate = new ActiveDataProvider([
'query' => TaxRate::find()
'query' => TaxRateModel::find()
]);

return $this->render('index', [
@@ -142,7 +137,7 @@ class TaxRateAdminController extends BackendController
*/
public function actionDelete($id)
{
$taxeRate = TaxRate::searchOne([
$taxeRate = TaxRateModel::searchOne([
'id' => $id
]) ;
$taxeRate->delete();
@@ -161,7 +156,7 @@ class TaxRateAdminController extends BackendController
*/
protected function findModel($id)
{
if (($model = TaxRate::findOne($id)) !== null) {
if (($model = TaxRateModel::findOne($id)) !== null) {
return $model;
} else {
throw new NotFoundHttpException('The requested page does not exist.');

+ 15
- 15
backend/controllers/UserController.php Visa fil

@@ -102,11 +102,11 @@ class UserController extends BackendController
)
]);

$producer = Producer::searchOne([
$producer = ProducerModel::searchOne([
'id' => GlobalParam::getCurrentProducerId()
]);

$pointsSaleArray = PointSale::searchAll();
$pointsSaleArray = PointSaleModel::searchAll();

return $this->render('index', [
'searchModel' => $searchModel,
@@ -124,7 +124,7 @@ class UserController extends BackendController

if ($model->id) {
// init points de vente sélectionnés
$userPointSaleArray = UserPointSale::searchAll([
$userPointSaleArray = UserPointSaleModel::searchAll([
'id_user' => $model->id
]);
if ($userPointSaleArray && count($userPointSaleArray) > 0) {
@@ -134,7 +134,7 @@ class UserController extends BackendController
}

// init groupes d'utilisateurs sélectionnés
$userUserGroupsArray = UserUserGroup::searchAll([
$userUserGroupsArray = UserUserGroupModel::searchAll([
'id_user' => $model->id
]);
if ($userUserGroupsArray && count($userUserGroupsArray) > 0) {
@@ -152,7 +152,7 @@ class UserController extends BackendController
}

// points de vente
$pointsSaleArray = PointSale::find()
$pointsSaleArray = PointSaleModel::find()
->where([
'id_producer' => GlobalParam::getCurrentProducerId(),
'status' => 1
@@ -165,7 +165,7 @@ class UserController extends BackendController
->all();

// groupes d'utilisateurs
$userGroupsArray = UserGroup::find()
$userGroupsArray = UserGroupModel::find()
->where([
'id_producer' => GlobalParam::getCurrentProducerId(),
])
@@ -196,7 +196,7 @@ class UserController extends BackendController
}

if ($userExist) {
Producer::addUser($userExist->id, GlobalParam::getCurrentProducerId());
ProducerModel::addUser($userExist->id, GlobalParam::getCurrentProducerId());
$this->processLinkPointSale($userExist);
$this->processLinkUserGroup($userExist);
Yii::$app->getSession()->setFlash('success', "L'utilisateur que vous souhaitez créer possède déjà un compte sur la plateforme. Il vient d'être lié à votre établissement.");
@@ -311,12 +311,12 @@ class UserController extends BackendController
public function processLinkPointSale($modelUser)
{
$posts = Yii::$app->request->post();
UserPointSale::deleteAll([
UserPointSaleModel::deleteAll([
'id_user' => $modelUser->id
]);
if (is_array($modelUser->points_sale) && count($modelUser->points_sale) > 0) {
foreach ($modelUser->points_sale as $pointSaleId) {
$userPointSale = UserPointSale::searchOne([
$userPointSale = UserPointSaleModel::searchOne([
'id_user' => $modelUser->id,
'id_point_sale' => $pointSaleId
]);
@@ -339,14 +339,14 @@ class UserController extends BackendController
public function processLinkUserGroup($modelUser)
{
$posts = Yii::$app->request->post();
UserUserGroup::deleteAll([
UserUserGroupModel::deleteAll([
'id_user' => $modelUser->id
]);

if (is_array($modelUser->user_groups) && count($modelUser->user_groups) > 0) {
foreach ($modelUser->user_groups as $userGroupId) {

$userUserGroup = UserUserGroup::searchOne([
$userUserGroup = UserUserGroupModel::searchOne([
'id_user' => $modelUser->id,
'id_user_group' => $userGroupId
]);
@@ -431,11 +431,11 @@ class UserController extends BackendController
$usersArray[] = $user['email'];
}

$pointsSaleArray = PointSale::find()->where(['id_producer' => GlobalParam::getCurrentProducerId()])->all();
$pointsSaleArray = PointSaleModel::find()->where(['id_producer' => GlobalParam::getCurrentProducerId()])->all();

$pointSale = null;
if ($idPointSale) {
$pointSale = PointSale::findOne(['id' => $idPointSale]);
$pointSale = PointSaleModel::findOne(['id' => $idPointSale]);
}

$mailForm = new MailForm();
@@ -465,7 +465,7 @@ class UserController extends BackendController
return $this->redirect(['mail', 'idPointSale' => $idPointSale]);
}

$incomingDistributions = Distribution::getIncomingDistributions();
$incomingDistributions = DistributionModel::getIncomingDistributions();
$incomingDistributionsArray = ['0' => '--'];
foreach ($incomingDistributions as $distribution) {
$incomingDistributionsArray[$distribution->id] = strftime('%A %d %B %Y', strtotime($distribution->date));
@@ -508,7 +508,7 @@ class UserController extends BackendController
$creditForm = new CreditForm;
}

$history = CreditHistory::find()
$history = CreditHistoryModel::find()
->with(['order', 'userAction'])
->where([
'id_user' => $user->id,

+ 2
- 12
backend/controllers/UserGroupController.php Visa fil

@@ -39,20 +39,10 @@
namespace backend\controllers;

use common\helpers\GlobalParam;
use common\models\UserGroup;
use common\models\UserUserGroup;
use Yii;
use yii\filters\AccessControl;
use common\models\PointSale;
use yii\data\ActiveDataProvider;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
use common\models\UserModel;
use common\models\UserPointSale;
use common\models\Order;
use common\models\Producer;
use common\models\Distribution;
use yii\helpers\Html;

/**
@@ -154,7 +144,7 @@ class UserGroupController extends BackendController
$userGroup = $this->findModel($id);

$userGroup->delete();
UserUserGroup::deleteAll(['id_user_group' => $id]);
UserUserGroupModel::deleteAll(['id_user_group' => $id]);
Yii::$app->getSession()->setFlash('success', 'Groupe d\'utilisateur <strong>' . Html::encode($userGroup->name) . '</strong> supprimé.');

return $this->redirect(['index']);
@@ -169,7 +159,7 @@ class UserGroupController extends BackendController
*/
protected function findModel($id)
{
if (($model = UserGroup::findOne($id)) !== null) {
if (($model = UserGroupModel::findOne($id)) !== null) {
return $model;
} else {
throw new NotFoundHttpException('The requested page does not exist.');

+ 3
- 3
backend/models/MailForm.php Visa fil

@@ -105,7 +105,7 @@ class MailForm extends Model
' ;
$messageAutoHtml = '<br /><br />' ;
$distribution = Distribution::searchOne(['id' => $this->id_distribution]) ;
$distribution = DistributionModel::searchOne(['id' => $this->id_distribution]) ;
if($distribution) {
@@ -116,7 +116,7 @@ class MailForm extends Model
'.$linkOrder ;

if($this->integrate_product_list) {
$productsArray = Product::find()
$productsArray = ProductModel::find()
->where([
'id_producer' => GlobalParam::getCurrentProducerId(),
])
@@ -143,7 +143,7 @@ Produits disponibles :
}
if($product->price) {
$productDescription .= ' / '.Price::format($product->getPriceWithTax()) ;
$productDescription .= ' ('.Product::strUnit($product->unit, 'wording_unit').')' ;
$productDescription .= ' ('.ProductModel::strUnit($product->unit, 'wording_unit').')' ;
}

$messageAutoText .= '- '.$productDescription.'

+ 1
- 1
backend/views/access/index.php Visa fil

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

+ 3
- 3
backend/views/delivery-note/index.php Visa fil

@@ -43,7 +43,7 @@ $this->addButton(['label' => 'Nouveau bon de livraison <span class="glyphicon gl
?>

<div class="delivery-note-index">
<?php if(DeliveryNote::searchCount()): ?>
<?php if(DeliveryNoteModel::searchCount()): ?>
<?= GridView::widget([
'filterModel' => $searchModel,
'dataProvider' => $dataProvider,
@@ -91,7 +91,7 @@ $this->addButton(['label' => 'Nouveau bon de livraison <span class="glyphicon gl
[
'attribute' => 'id_point_sale',
'header' => 'Point de vente',
'filter' => ArrayHelper::map(PointSale::searchAll([], ['as_array'=>true]), 'id', 'name'),
'filter' => ArrayHelper::map(PointSaleModel::searchAll([], ['as_array'=>true]), 'id', 'name'),
'format' => 'html',
'value' => function($model) {
$pointSale = $model->getPointSale() ;
@@ -105,7 +105,7 @@ $this->addButton(['label' => 'Nouveau bon de livraison <span class="glyphicon gl
'attribute' => 'amount',
'header' => 'Montant',
'value' => function($deliveryNote) {
return $deliveryNote->getAmountWithTax(Order::INVOICE_AMOUNT_TOTAL, true) ;
return $deliveryNote->getAmountWithTax(OrderModel::INVOICE_AMOUNT_TOTAL, true) ;
}
],
[

+ 4
- 4
backend/views/development/_form.php Visa fil

@@ -50,13 +50,13 @@ use common\models\Developpement ;
<?php $form = ActiveForm::begin(); ?>
<?= $form->field($model, 'type')->dropDownList([
Development::TYPE_EVOLUTION => 'Évolution',
Development::TYPE_BUG => 'Anomalie',
DevelopmentModel::TYPE_EVOLUTION => 'Évolution',
DevelopmentModel::TYPE_BUG => 'Anomalie',
]) ?>
<?= $form->field($model, 'status')->dropDownList([
Development::STATUS_OPEN => 'Ouvert',
Development::STATUS_CLOSED => 'Fermé',
DevelopmentModel::STATUS_OPEN => 'Ouvert',
DevelopmentModel::STATUS_CLOSED => 'Fermé',
]) ?>
<?= $form->field($model, 'subject')->textInput(['maxlength' => true]) ?>

+ 8
- 8
backend/views/development/development.php Visa fil

@@ -60,11 +60,11 @@ $this->addBreadcrumb($this->getTitle());
</div>

<ul id="tab-status-developments" class="nav nav-tabs" role="tablist">
<li role="presentation" class="<?php if ($status == Development::STATUS_OPEN): ?>active<?php endif; ?>"><a
href="<?= Yii::$app->urlManager->createUrl(['development/index', 'status' => Development::STATUS_OPEN]); ?>"
<li role="presentation" class="<?php if ($status == DevelopmentModel::STATUS_OPEN): ?>active<?php endif; ?>"><a
href="<?= Yii::$app->urlManager->createUrl(['development/index', 'status' => DevelopmentModel::STATUS_OPEN]); ?>"
id="" aria-controls="" role="tab">Ouvert</a></li>
<li role="presentation" class="<?php if ($status == Development::STATUS_CLOSED): ?>active<?php endif; ?>"><a
href="<?= Yii::$app->urlManager->createUrl(['development/index', 'status' => Development::STATUS_CLOSED]); ?>"
<li role="presentation" class="<?php if ($status == DevelopmentModel::STATUS_CLOSED): ?>active<?php endif; ?>"><a
href="<?= Yii::$app->urlManager->createUrl(['development/index', 'status' => DevelopmentModel::STATUS_CLOSED]); ?>"
id="" aria-controls="" role="tab">Fermé</a></li>
</ul>

@@ -82,7 +82,7 @@ $this->addBreadcrumb($this->getTitle());
'header' => 'Type',
'format' => 'raw',
'value' => function ($model) {
if ($model->type == Development::TYPE_EVOLUTION) {
if ($model->type == DevelopmentModel::TYPE_EVOLUTION) {
return '<span class="label label-success">Évolution</span>';
} else {
return '<span class="label label-danger">Anomalie</span>';
@@ -142,9 +142,9 @@ $this->addBreadcrumb($this->getTitle());
</button>
<ul class="dropdown-menu">
<li><a href="' . Yii::$app->urlManager->createUrl(['development/priority', 'idDevelopment' => $model->id]) . '">Non</a></li>
<li><a href="' . Yii::$app->urlManager->createUrl(['development/priority', 'idDevelopment' => $model->id, 'priority' => DevelopmentPriority::PRIORITY_LOW]) . '">Basse</a></li>
<li><a href="' . Yii::$app->urlManager->createUrl(['development/priority', 'idDevelopment' => $model->id, 'priority' => DevelopmentPriority::PRIORITY_NORMAL]) . '">Normale</a></li>
<li><a href="' . Yii::$app->urlManager->createUrl(['development/priority', 'idDevelopment' => $model->id, 'priority' => DevelopmentPriority::PRIORITY_HIGH]) . '">Haute</a></li>
<li><a href="' . Yii::$app->urlManager->createUrl(['development/priority', 'idDevelopment' => $model->id, 'priority' => DevelopmentPriorityModel::PRIORITY_LOW]) . '">Basse</a></li>
<li><a href="' . Yii::$app->urlManager->createUrl(['development/priority', 'idDevelopment' => $model->id, 'priority' => DevelopmentPriorityModel::PRIORITY_NORMAL]) . '">Normale</a></li>
<li><a href="' . Yii::$app->urlManager->createUrl(['development/priority', 'idDevelopment' => $model->id, 'priority' => DevelopmentPriorityModel::PRIORITY_HIGH]) . '">Haute</a></li>
</ul>
</div><br />';


+ 11
- 11
backend/views/distribution/report-bourlingue.php Visa fil

@@ -104,7 +104,7 @@ foreach ($pointsSaleArray as $pointSale) {
$add = false;
foreach ($order->productOrder as $productOrder) {
if($product->id == $productOrder->id_product) {
$unit = (Product::strUnit($productOrder->unit, 'wording_short', true) == 'p.') ? '' : '&nbsp;'.Product::strUnit($productOrder->unit, 'wording_short', true) ;
$unit = (ProductModel::strUnit($productOrder->unit, 'wording_short', true) == 'p.') ? '' : '&nbsp;'.ProductModel::strUnit($productOrder->unit, 'wording_short', true) ;
$strProducts .= $product->name . ' (' .$productOrder->quantity .$unit.')<br />';
$add = true;
}
@@ -156,7 +156,7 @@ foreach ($pointsSaleArray as $pointSale) {
$credit = '' ;

if(isset($order->user) && $order->user->id) {
$userProducer = UserProducer::searchOne([
$userProducer = UserProducerModel::searchOne([
'id_user' => $order->user->id
]);

@@ -181,10 +181,10 @@ foreach ($pointsSaleArray as $pointSale) {
$strProducts = '';
$cpt = 0 ;
foreach ($productsArray as $product) {
foreach(Product::$unitsArray as $unit => $dataUnit) {
$quantity = Order::getProductQuantity($product->id, $pointSale->orders, false, $unit);
foreach(ProductModel::$unitsArray as $unit => $dataUnit) {
$quantity = OrderModel::getProductQuantity($product->id, $pointSale->orders, false, $unit);
if ($quantity) {
$theUnit = (Product::strUnit($unit, 'wording_short', true) == 'p.') ? '' : '&nbsp;'.Product::strUnit($unit, 'wording_short', true) ;
$theUnit = (ProductModel::strUnit($unit, 'wording_short', true) == 'p.') ? '' : '&nbsp;'.ProductModel::strUnit($unit, 'wording_short', true) ;
$strProducts .= $product->name . ' (' .$quantity .$theUnit.')<br />';
}
}
@@ -230,10 +230,10 @@ foreach ($pointsSaleArray as $pointSale)

$cpt = 0 ;
foreach ($productsArray as $product) {
foreach(Product::$unitsArray as $unit => $dataUnit) {
$quantity = Order::getProductQuantity($product->id, $pointSale->orders, false, $unit);
foreach(ProductModel::$unitsArray as $unit => $dataUnit) {
$quantity = OrderModel::getProductQuantity($product->id, $pointSale->orders, false, $unit);
if ($quantity) {
$theUnit = (Product::strUnit($unit, 'wording_short', true) == 'p.') ? '' : '&nbsp;'.Product::strUnit($unit, 'wording_short', true) ;
$theUnit = (ProductModel::strUnit($unit, 'wording_short', true) == 'p.') ? '' : '&nbsp;'.ProductModel::strUnit($unit, 'wording_short', true) ;
$html .= $product->name . ' (' .$quantity .$theUnit.')<br />';
}
}
@@ -257,10 +257,10 @@ $html .= '<tr><td><strong>Total</strong></td><td>' ;

$cpt = 0 ;
foreach ($productsArray as $product) {
foreach(Product::$unitsArray as $unit => $dataUnit) {
$quantity = Order::getProductQuantity($product->id, $ordersArray, false, $unit);
foreach(ProductModel::$unitsArray as $unit => $dataUnit) {
$quantity = OrderModel::getProductQuantity($product->id, $ordersArray, false, $unit);
if ($quantity) {
$theUnit = (Product::strUnit($unit, 'wording_short', true) == 'p.') ? '' : '&nbsp;'.Product::strUnit($unit, 'wording_short', true) ;
$theUnit = (ProductModel::strUnit($unit, 'wording_short', true) == 'p.') ? '' : '&nbsp;'.ProductModel::strUnit($unit, 'wording_short', true) ;
$html .= $product->name . ' (' .$quantity .$theUnit.')<br />';
}
}

+ 2
- 2
backend/views/distribution/report-grid.php Visa fil

@@ -56,7 +56,7 @@ foreach($pointsSaleArray as $keyPointSale => $pointSale) {
foreach ($orders as $order) {
$html .= '<tr>';
$strUser = $order->getStrUser();
if ($producer->option_order_reference_type == Producer::ORDER_REFERENCE_TYPE_YEARLY && $order->reference && strlen($order->reference) > 0) {
if ($producer->option_order_reference_type == ProducerModel::ORDER_REFERENCE_TYPE_YEARLY && $order->reference && strlen($order->reference) > 0) {
$strUser .= '<br />' . $order->reference;
}

@@ -93,7 +93,7 @@ function line_product($product, $orders) {
$quantity = '' ;
foreach($order->productOrder as $productOrder) {
if($product->id == $productOrder->id_product) {
$unit = (Product::strUnit($productOrder->unit, 'wording_short', true) == 'p.') ? '' : '&nbsp;'.Product::strUnit($productOrder->unit, 'wording_short', true) ;
$unit = (ProductModel::strUnit($productOrder->unit, 'wording_short', true) == 'p.') ? '' : '&nbsp;'.ProductModel::strUnit($productOrder->unit, 'wording_short', true) ;

$quantity .= $productOrder->quantity .$unit ;
if($productOrder->quantity > 1) {

+ 17
- 17
backend/views/distribution/report.php Visa fil

@@ -86,7 +86,7 @@ foreach ($pointsSaleArray as $pointSale) {
}

// référence
if($producer->option_order_reference_type == Producer::ORDER_REFERENCE_TYPE_YEARLY && $order->reference && strlen($order->reference) > 0) {
if($producer->option_order_reference_type == ProducerModel::ORDER_REFERENCE_TYPE_YEARLY && $order->reference && strlen($order->reference) > 0) {
$strUser .= '<br />'.$order->reference ;
}

@@ -98,7 +98,7 @@ foreach ($pointsSaleArray as $pointSale) {
$add = false;
foreach ($order->productOrder as $productOrder) {
if($product->id == $productOrder->id_product) {
$unit = (Product::strUnit($productOrder->unit, 'wording_short', true) == 'p.') ? '' : '&nbsp;'.Product::strUnit($productOrder->unit, 'wording_short', true) ;
$unit = (ProductModel::strUnit($productOrder->unit, 'wording_short', true) == 'p.') ? '' : '&nbsp;'.ProductModel::strUnit($productOrder->unit, 'wording_short', true) ;
$strProducts .= '('.$productOrder->quantity .$unit.') '.$product->getNameExport() . '<br />';
$add = true;
}
@@ -115,7 +115,7 @@ foreach ($pointsSaleArray as $pointSale) {
$credit = '' ;

if(isset($order->user) && $order->user->id) {
$userProducer = UserProducer::searchOne([
$userProducer = UserProducerModel::searchOne([
'id_user' => $order->user->id
]);

@@ -129,17 +129,17 @@ foreach ($pointsSaleArray as $pointSale) {
$html .= '<td><strong>'.number_format($order->amount_with_tax, 2) . ' € ';

if($order->getPaymentStatus() == Order::PAYMENT_PAID)
if($order->getPaymentStatus() == OrderModel::PAYMENT_PAID)
{
$html .= '(payé)' ;
}
elseif($order->getPaymentStatus() == Order::PAYMENT_UNPAID && $order->getAmount(Order::AMOUNT_PAID))
elseif($order->getPaymentStatus() == OrderModel::PAYMENT_UNPAID && $order->getAmount(OrderModel::AMOUNT_PAID))
{
$html .= '(reste '.$order->getAmount(Order::AMOUNT_REMAINING, true).' à payer)' ;
$html .= '(reste '.$order->getAmount(OrderModel::AMOUNT_REMAINING, true).' à payer)' ;
}
elseif($order->getPaymentStatus() == Order::PAYMENT_SURPLUS)
elseif($order->getPaymentStatus() == OrderModel::PAYMENT_SURPLUS)
{
$html .= '(surplus : '.$order->getAmount(Order::PAYMENT_SURPLUS, true).' à rembourser)' ;
$html .= '(surplus : '.$order->getAmount(OrderModel::PAYMENT_SURPLUS, true).' à rembourser)' ;
}
$html .= '</strong></td>' ;
@@ -153,10 +153,10 @@ foreach ($pointsSaleArray as $pointSale) {
$strProducts = '';
$cpt = 0 ;
foreach ($productsArray as $product) {
foreach(Product::$unitsArray as $unit => $dataUnit) {
$quantity = Order::getProductQuantity($product->id, $pointSale->orders, false, $unit);
foreach(ProductModel::$unitsArray as $unit => $dataUnit) {
$quantity = OrderModel::getProductQuantity($product->id, $pointSale->orders, false, $unit);
if ($quantity) {
$theUnit = (Product::strUnit($unit, 'wording_short', true) == 'p.') ? '' : '&nbsp;'.Product::strUnit($unit, 'wording_short', true) ;
$theUnit = (ProductModel::strUnit($unit, 'wording_short', true) == 'p.') ? '' : '&nbsp;'.ProductModel::strUnit($unit, 'wording_short', true) ;
$strProducts .= '(' .$quantity .$theUnit.') '.$product->getNameExport() . '<br />';
}
}
@@ -202,10 +202,10 @@ foreach ($pointsSaleArray as $pointSale)

$cpt = 0 ;
foreach ($productsArray as $product) {
foreach(Product::$unitsArray as $unit => $dataUnit) {
$quantity = Order::getProductQuantity($product->id, $pointSale->orders, false, $unit);
foreach(ProductModel::$unitsArray as $unit => $dataUnit) {
$quantity = OrderModel::getProductQuantity($product->id, $pointSale->orders, false, $unit);
if ($quantity) {
$theUnit = (Product::strUnit($unit, 'wording_short', true) == 'p.') ? '' : '&nbsp;'.Product::strUnit($unit, 'wording_short', true) ;
$theUnit = (ProductModel::strUnit($unit, 'wording_short', true) == 'p.') ? '' : '&nbsp;'.ProductModel::strUnit($unit, 'wording_short', true) ;
$html .= '(' .$quantity .$theUnit.') '.$product->getNameExport() . '<br />';
}
}
@@ -229,10 +229,10 @@ $html .= '<tr><td><strong>Total</strong></td><td>' ;

$cpt = 0 ;
foreach ($productsArray as $product) {
foreach(Product::$unitsArray as $unit => $dataUnit) {
$quantity = Order::getProductQuantity($product->id, $ordersArray, false, $unit);
foreach(ProductModel::$unitsArray as $unit => $dataUnit) {
$quantity = OrderModel::getProductQuantity($product->id, $ordersArray, false, $unit);
if ($quantity) {
$theUnit = (Product::strUnit($unit, 'wording_short', true) == 'p.') ? '' : '&nbsp;'.Product::strUnit($unit, 'wording_short', true) ;
$theUnit = (ProductModel::strUnit($unit, 'wording_short', true) == 'p.') ? '' : '&nbsp;'.ProductModel::strUnit($unit, 'wording_short', true) ;
$html .= '(' .$quantity .$theUnit.') '.$product->name . '<br />';
}
}

+ 2
- 2
backend/views/document/_download_product_line.php Visa fil

@@ -24,9 +24,9 @@
</td>
<?php endif; ?>
<td class="align-center">
<?= $productOrder->quantity * Product::$unitsArray[$productOrder->unit]['coefficient'] ?>
<?= $productOrder->quantity * ProductModel::$unitsArray[$productOrder->unit]['coefficient'] ?>
</td>
<td class="align-center"><?= Product::strUnit($productOrder->unit, 'wording') ?></td>
<td class="align-center"><?= ProductModel::strUnit($productOrder->unit, 'wording') ?></td>
<?php if($displayPrices): ?>
<?php if($producer->taxRate->value != 0): ?>
<td class="align-center"><?= $productOrder->taxRate->value * 100 ?> %</td>

+ 2
- 2
backend/views/document/_form.php Visa fil

@@ -73,7 +73,7 @@ use common\models\Producer;
'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(
User::populateDropdownList(),
UserModel::populateDropdownList(),
[
'@change' => 'changeUser',
'v-model' => 'idUser',
@@ -215,7 +215,7 @@ use common\models\Producer;
class="btn btn-sm btn-default"><span class="glyphicon glyphicon-repeat"></span> Regénérer (PDF)</a>
<?php endif; ?>

<?php if ($model->getClass() == 'Invoice' && Producer::getConfig('option_export_evoliz')): ?>
<?php if ($model->getClass() == 'Invoice' && ProducerModel::getConfig('option_export_evoliz')): ?>
<a href="<?= Yii::$app->urlManager->createUrl([Yii::$app->controller->getControllerUrl() . '/export-csv-evoliz', 'id' => $model->id]) ?>"
class="btn btn-sm btn-default"><span class="glyphicon glyphicon-save-file"></span> Export Evoliz
(CSV)</a>

+ 5
- 5
backend/views/document/download.php Visa fil

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

$displayPrices = Yii::$app->controller->getClass() != 'DeliveryNote' || (Yii::$app->controller->getClass() == 'DeliveryNote' && Producer::getConfig('document_display_prices_delivery_note'));
$displayProductDescription = Producer::getConfig('document_display_product_description');
$documentPriceDecimals = (int) Producer::getConfig('option_document_price_decimals');
$displayPrices = Yii::$app->controller->getClass() != 'DeliveryNote' || (Yii::$app->controller->getClass() == 'DeliveryNote' && ProducerModel::getConfig('document_display_prices_delivery_note'));
$displayProductDescription = ProducerModel::getConfig('document_display_product_description');
$documentPriceDecimals = (int) ProducerModel::getConfig('option_document_price_decimals');

?>

@@ -126,7 +126,7 @@ $documentPriceDecimals = (int) Producer::getConfig('option_document_price_decima
<?php endforeach; ?>
<?php endif; ?>
<?php if ($displayPrices): ?>
<?php $typeAmount = $document->isInvoicePrice() ? Order::INVOICE_AMOUNT_TOTAL : Order::AMOUNT_TOTAL; ?>
<?php $typeAmount = $document->isInvoicePrice() ? OrderModel::INVOICE_AMOUNT_TOTAL : OrderModel::AMOUNT_TOTAL; ?>

<?php if ($producer->taxRate->value != 0): ?>

@@ -138,7 +138,7 @@ $documentPriceDecimals = (int) Producer::getConfig('option_document_price_decima
</tr>

<?php
$taxRateArray = TaxRate::getTaxRateArray();
$taxRateArray = $this->getLogic()->getTaxRateContainer()->getRepository()->getAsArray();
foreach ($document->getTotalVatArray($typeAmount) as $idTaxRate => $totalVat): ?>
<tr>
<td class="align-right" colspan="5">

+ 3
- 3
backend/views/invoice/index.php Visa fil

@@ -51,7 +51,7 @@ $this->addButton(['label' => 'Nouvelle facture <span class="glyphicon glyphicon-

<div class="invoice-index">

<?php if(Invoice::searchCount()): ?>
<?php if(InvoiceModel::searchCount()): ?>
<?= GridView::widget([
'filterModel' => $searchModel,
'dataProvider' => $dataProvider,
@@ -96,7 +96,7 @@ $this->addButton(['label' => 'Nouvelle facture <span class="glyphicon glyphicon-
'attribute' => 'amount',
'header' => 'Montant',
'value' => function($invoice) {
return $invoice->getAmountWithTax(Order::INVOICE_AMOUNT_TOTAL, true) ;
return $invoice->getAmountWithTax(OrderModel::INVOICE_AMOUNT_TOTAL, true) ;
}
],
[
@@ -134,7 +134,7 @@ $this->addButton(['label' => 'Nouvelle facture <span class="glyphicon glyphicon-
]);
},
'export-csv-evoliz' => function($url, $model) {
if(Producer::getConfig('option_export_evoliz')) {
if(ProducerModel::getConfig('option_export_evoliz')) {
return Html::a('<span class="glyphicon glyphicon-save-file"></span> Evoliz', $url, [
'title' => 'Export CSV Evoliz', 'class' => 'btn btn-default'
]);

+ 3
- 3
backend/views/layouts/header.php Visa fil

@@ -74,7 +74,7 @@ $producer = GlobalParam::getCurrentProducer();

<?php

$pastDistributionsArray = Distribution::find()
$pastDistributionsArray = DistributionModel::find()
->where(['<', 'distribution.date', date('Y-m-d')])
->andWhere([
'distribution.id_producer' => GlobalParam::getCurrentProducerId(),
@@ -86,7 +86,7 @@ $producer = GlobalParam::getCurrentProducer();

$pastDistributionsArray = array_reverse($pastDistributionsArray);

$incomingDistributionsArray = Distribution::find()
$incomingDistributionsArray = DistributionModel::find()
->where(['>=', 'distribution.date', date('Y-m-d')])
->andWhere([
'distribution.id_producer' => GlobalParam::getCurrentProducerId(),
@@ -237,7 +237,7 @@ $producer = GlobalParam::getCurrentProducer();
</a>
</li>
<li class="header">&nbsp;<strong>Autres producteurs</strong></li>
<?php $producersArray = Producer::find()->orderBy('name ASC')->all(); ?>
<?php $producersArray = ProducerModel::find()->orderBy('name ASC')->all(); ?>
<?php foreach ($producersArray as $producer): ?>
<li>
<a href="<?= Yii::$app->urlManagerBackend->createUrl(['site/change-producer', 'id' => $producer->id]); ?>"><?= Html::encode($producer->name) ?></a>

+ 29
- 29
backend/views/layouts/left.php Visa fil

@@ -54,39 +54,39 @@
[
'options' => ['class' => 'sidebar-menu tree', 'data-widget' => 'tree'],
'items' => [
['label' => 'Tableau de bord', 'icon' => 'dashboard', 'url' => ['/site/index'], 'visible' => User::isCurrentProducer()],
['label' => 'Distributions', 'icon' => 'calendar', 'url' => ['/distribution/index'], 'visible' => User::isCurrentProducer()],
['label' => 'Tableau de bord', 'icon' => 'dashboard', 'url' => ['/site/index'], 'visible' => UserModel::isCurrentProducer()],
['label' => 'Distributions', 'icon' => 'calendar', 'url' => ['/distribution/index'], 'visible' => UserModel::isCurrentProducer()],
[
'label' => 'Produits',
'icon' => 'clone',
'url' => ['/product/index'],
'visible' => User::isCurrentProducer(),
'visible' => UserModel::isCurrentProducer(),
'active' => Yii::$app->controller->id == 'product',
'items' => [
['label' => 'Liste', 'icon' => 'th-list', 'url' => ['/product/index'], 'visible' => User::isCurrentProducer()],
['label' => 'Catégories', 'icon' => 'book', 'url' => ['/product-category/index'], 'visible' => User::isCurrentProducer()],
['label' => 'Liste', 'icon' => 'th-list', 'url' => ['/product/index'], 'visible' => UserModel::isCurrentProducer()],
['label' => 'Catégories', 'icon' => 'book', 'url' => ['/product-category/index'], 'visible' => UserModel::isCurrentProducer()],
]
],
['label' => 'Points de vente', 'icon' => 'map-marker', 'url' => ['/point-sale/index'], 'visible' => User::isCurrentProducer(), 'active' => Yii::$app->controller->id == 'point-sale'],
['label' => 'Points de vente', 'icon' => 'map-marker', 'url' => ['/point-sale/index'], 'visible' => UserModel::isCurrentProducer(), 'active' => Yii::$app->controller->id == 'point-sale'],
[
'label' => 'Utilisateurs',
'icon' => 'users',
'url' => ['/user/index'],
'items' => [
['label' => 'Liste', 'icon' => 'th-list', 'url' => ['/user/index'], 'visible' => User::isCurrentProducer()],
['label' => 'Groupes', 'icon' => 'users', 'url' => ['/user-group/index'], 'visible' => User::isCurrentProducer()],
['label' => 'Liste', 'icon' => 'th-list', 'url' => ['/user/index'], 'visible' => UserModel::isCurrentProducer()],
['label' => 'Groupes', 'icon' => 'users', 'url' => ['/user-group/index'], 'visible' => UserModel::isCurrentProducer()],
],
],
['label' => 'Abonnements', 'icon' => 'repeat', 'url' => ['/subscription/index'], 'visible' => User::isCurrentProducer(), 'active' => Yii::$app->controller->id == 'subscription'],
['label' => 'Communiquer', 'icon' => 'bullhorn', 'url' => ['/communicate/index'], 'visible' => User::isCurrentProducer()],
['label' => 'Abonnements', 'icon' => 'repeat', 'url' => ['/subscription/index'], 'visible' => UserModel::isCurrentProducer(), 'active' => Yii::$app->controller->id == 'subscription'],
['label' => 'Communiquer', 'icon' => 'bullhorn', 'url' => ['/communicate/index'], 'visible' => UserModel::isCurrentProducer()],
[
'label' => 'Documents',
'icon' => 'clone',
'url' => ['/delivery-note/index'],
'items' => [
['label' => 'Bons de livraison', 'icon' => 'sticky-note-o', 'url' => ['/delivery-note/index'], 'visible' => User::isCurrentProducer()],
['label' => 'Factures', 'icon' => 'sticky-note-o', 'url' => ['/invoice/index'], 'visible' => User::isCurrentProducer()],
['label' => 'Devis', 'icon' => 'sticky-note-o', 'url' => ['/quotation/index'], 'visible' => User::isCurrentProducer()],
['label' => 'Bons de livraison', 'icon' => 'sticky-note-o', 'url' => ['/delivery-note/index'], 'visible' => UserModel::isCurrentProducer()],
['label' => 'Factures', 'icon' => 'sticky-note-o', 'url' => ['/invoice/index'], 'visible' => UserModel::isCurrentProducer()],
['label' => 'Devis', 'icon' => 'sticky-note-o', 'url' => ['/quotation/index'], 'visible' => UserModel::isCurrentProducer()],
],
],
[
@@ -94,33 +94,33 @@
'icon' => 'line-chart',
'url' => ['/stats/index'],
'items' => [
['label' => 'Chiffre d\'affaire', 'icon' => 'line-chart', 'url' => ['/stats/index'], 'visible' => User::isCurrentProducer()],
['label' => 'Rapports', 'icon' => 'pencil-square-o', 'url' => ['/report/index'], 'visible' => User::isCurrentProducer()],
['label' => 'Produits', 'icon' => 'table', 'url' => ['/stats/products'], 'visible' => User::isCurrentProducer()],
['label' => 'Chiffre d\'affaire', 'icon' => 'line-chart', 'url' => ['/stats/index'], 'visible' => UserModel::isCurrentProducer()],
['label' => 'Rapports', 'icon' => 'pencil-square-o', 'url' => ['/report/index'], 'visible' => UserModel::isCurrentProducer()],
['label' => 'Produits', 'icon' => 'table', 'url' => ['/stats/products'], 'visible' => UserModel::isCurrentProducer()],
],
],
['label' => 'Paramètres', 'icon' => 'cog', 'url' => ['/producer/update'], 'visible' => User::isCurrentProducer()],
['label' => 'Accès', 'icon' => 'lock', 'url' => ['/access/index'], 'visible' => User::isCurrentProducer()],
['label' => 'Paramètres', 'icon' => 'cog', 'url' => ['/producer/update'], 'visible' => UserModel::isCurrentProducer()],
['label' => 'Accès', 'icon' => 'lock', 'url' => ['/access/index'], 'visible' => UserModel::isCurrentProducer()],
[
'label' => 'Développement',
'icon' => 'code',
'url' => ['/development/index'],
'visible' => User::isCurrentProducer(),
'visible' => UserModel::isCurrentProducer(),
'active' => Yii::$app->controller->id == 'development',
'template'=>'<a href="{url}">{icon} {label}'.$newVersionOpendistribTemplate.'</a>'
],
['label' => 'Tarifs', 'icon' => 'euro', 'url' => ['/producer/billing'], 'visible' => User::isCurrentProducer()],
['label' => 'Tarifs', 'icon' => 'euro', 'url' => ['/producer/billing'], 'visible' => UserModel::isCurrentProducer()],

['label' => 'Administration', 'options' => ['class' => 'header'], 'visible' => User::isCurrentAdmin()],
['label' => 'Producteurs', 'icon' => 'th-list', 'url' => ['/producer-admin/index'], 'visible' => User::isCurrentAdmin()],
['label' => 'Tranches de prix', 'icon' => 'eur', 'url' => ['/producer-price-range-admin/index'], 'visible' => User::isCurrentAdmin()],
['label' => 'Taxes', 'icon' => 'eur', 'url' => ['/tax-rate-admin/index'], 'visible' => User::isCurrentAdmin()],
['label' => 'Communiquer', 'icon' => 'bullhorn', 'url' => ['/communicate-admin/index'], 'visible' => User::isCurrentAdmin()],
['label' => 'Administration', 'options' => ['class' => 'header'], 'visible' => UserModel::isCurrentAdmin()],
['label' => 'Producteurs', 'icon' => 'th-list', 'url' => ['/producer-admin/index'], 'visible' => UserModel::isCurrentAdmin()],
['label' => 'Tranches de prix', 'icon' => 'eur', 'url' => ['/producer-price-range-admin/index'], 'visible' => UserModel::isCurrentAdmin()],
['label' => 'Taxes', 'icon' => 'eur', 'url' => ['/tax-rate-admin/index'], 'visible' => UserModel::isCurrentAdmin()],
['label' => 'Communiquer', 'icon' => 'bullhorn', 'url' => ['/communicate-admin/index'], 'visible' => UserModel::isCurrentAdmin()],

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

+ 3
- 3
backend/views/layouts/main-old.php Visa fil

@@ -55,7 +55,7 @@ use common\helpers\GlobalParam;

$producer = null;
if (!Yii::$app->user->isGuest) {
$producer = Producer::findOne(GlobalParam::getCurrentProducerId());
$producer = ProducerModel::findOne(GlobalParam::getCurrentProducerId());
}

?>
@@ -216,7 +216,7 @@ if (!Yii::$app->user->isGuest) {
<?php elseif (UserModel::getCurrentStatus() == UserModel::STATUS_ADMIN): ?>
<?php $form = ActiveForm::begin(['id' => 'select-producer']); ?>
<?=
Html::dropDownList('select_producer', GlobalParam::getCurrentProducerId(), ArrayHelper::map(Producer::find()->orderBy('name ASC')->all(), 'id', function ($model, $defaultValue) {
Html::dropDownList('select_producer', GlobalParam::getCurrentProducerId(), ArrayHelper::map(ProducerModel::find()->orderBy('name ASC')->all(), 'id', function ($model, $defaultValue) {
return $model->name;
}));
?>
@@ -224,7 +224,7 @@ if (!Yii::$app->user->isGuest) {
<?php endif; ?>

<?php
$producer = Producer::findOne(GlobalParam::getCurrentProducerId());
$producer = ProducerModel::findOne(GlobalParam::getCurrentProducerId());
if (!$producer->active):
?>
<span class="label label-danger" data-toggle="tooltip" data-placement="bottom"

+ 8
- 8
backend/views/order/report.php Visa fil

@@ -110,17 +110,17 @@ foreach ($pointsSaleArray as $pointSale) {
$html .= '<td><strong>'.number_format($order->amount, 2) . ' € ';

if($order->getPaymentStatus() == Order::PAYMENT_PAID)
if($order->getPaymentStatus() == OrderModel::PAYMENT_PAID)
{
$html .= '(payé)' ;
}
elseif($order->getPaymentStatus() == Order::PAYMENT_UNPAID && $order->getAmount(Order::AMOUNT_PAID))
elseif($order->getPaymentStatus() == OrderModel::PAYMENT_UNPAID && $order->getAmount(OrderModel::AMOUNT_PAID))
{
$html .= '(reste '.$order->getAmount(Order::AMOUNT_REMAINING, true).' à payer)' ;
$html .= '(reste '.$order->getAmount(OrderModel::AMOUNT_REMAINING, true).' à payer)' ;
}
elseif($order->getPaymentStatus() == Order::PAYMENT_SURPLUS)
elseif($order->getPaymentStatus() == OrderModel::PAYMENT_SURPLUS)
{
$html .= '(surplus : '.$order->getAmount(Order::PAYMENT_SURPLUS, true).' à rembourser)' ;
$html .= '(surplus : '.$order->getAmount(OrderModel::PAYMENT_SURPLUS, true).' à rembourser)' ;
}
$html .= '</strong></td>' ;
@@ -133,7 +133,7 @@ foreach ($pointsSaleArray as $pointSale) {
$strProducts = '';
foreach ($productsArray as $product) {
$quantity = Order::getProductQuantity($product->id, $pointSale->orders);
$quantity = OrderModel::getProductQuantity($product->id, $pointSale->orders);
$strQuantity = '';
if ($quantity) {
$strQuantity = $quantity;
@@ -171,7 +171,7 @@ foreach ($pointsSaleArray as $pointSale)
{
$html .= '<tr><td>'.$pointSale->name.'</td><td>' ;
foreach ($productsArray as $product) {
$quantity = Order::getProductQuantity($product->id, $pointSale->orders);
$quantity = OrderModel::getProductQuantity($product->id, $pointSale->orders);
$strQuantity = ($quantity) ? $quantity : '' ;
if(strlen($strQuantity)) {
@@ -190,7 +190,7 @@ foreach ($pointsSaleArray as $pointSale)
// total
$html .= '<tr><td><strong>Total</strong></td><td>' ;
foreach ($productsArray as $product) {
$quantity = Order::getProductQuantity($product->id, $ordersArray);
$quantity = OrderModel::getProductQuantity($product->id, $ordersArray);
if($quantity) {
$html .= $quantity . '&nbsp;'.$product->name.', ' ;
}

+ 9
- 9
backend/views/point-sale/_form.php Visa fil

@@ -59,12 +59,12 @@ use common\models\ProductPrice ;
<?= $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(User::populateDropdownList(), ['class' => 'select2'])
->dropDownList(UserModel::populateDropdownList(), ['class' => 'select2'])
->hint('Utilisé lors de la facturation'); ?>

<?php
$addHintCredit = '';
if (!Producer::getConfig('credit')):
if (!ProducerModel::getConfig('credit')):
$addHintCredit = '<br /><strong>Attention, le système de Crédit est désactivé au niveau des ' . Html::a('paramètres globaux', ['producer/update']) . '.</strong>';
endif;

@@ -76,14 +76,14 @@ use common\models\ProductPrice ;

<?= $form->field($model, 'credit_functioning')
->dropDownList([
'' => 'Paramètres globaux (' . Producer::$creditFunctioningArray[Producer::getConfig('credit_functioning')] . ')',
Producer::CREDIT_FUNCTIONING_OPTIONAL => Producer::$creditFunctioningArray[Producer::CREDIT_FUNCTIONING_OPTIONAL],
Producer::CREDIT_FUNCTIONING_MANDATORY => Producer::$creditFunctioningArray[Producer::CREDIT_FUNCTIONING_MANDATORY],
Producer::CREDIT_FUNCTIONING_USER => Producer::$creditFunctioningArray[Producer::CREDIT_FUNCTIONING_USER],
], [])->hint(Producer::HINT_CREDIT_FUNCTIONING); ?>
'' => 'Paramètres globaux (' . ProducerModel::$creditFunctioningArray[ProducerModel::getConfig('credit_functioning')] . ')',
ProducerModel::CREDIT_FUNCTIONING_OPTIONAL => ProducerModel::$creditFunctioningArray[ProducerModel::CREDIT_FUNCTIONING_OPTIONAL],
ProducerModel::CREDIT_FUNCTIONING_MANDATORY => ProducerModel::$creditFunctioningArray[ProducerModel::CREDIT_FUNCTIONING_MANDATORY],
ProducerModel::CREDIT_FUNCTIONING_USER => ProducerModel::$creditFunctioningArray[ProducerModel::CREDIT_FUNCTIONING_USER],
], [])->hint(ProducerModel::HINT_CREDIT_FUNCTIONING); ?>

<?php /*$form->field($model, 'product_price_percent')
->dropDownList(ProductPrice::percentValues(), [])->hint('Pourcentage appliqué aux prix de chaque produit dans ce point de vente.');*/ ?>
->dropDownList(ProductPriceModel::percentValues(), [])->hint('Pourcentage appliqué aux prix de chaque produit dans ce point de vente.');*/ ?>

<?= $form->field($model, 'maximum_number_orders')->textInput() ?>

@@ -128,7 +128,7 @@ use common\models\ProductPrice ;

<?= Html::activeCheckboxList($model, 'users', ArrayHelper::map($users, 'user_id', function ($model_user, $defaultValue) use ($model) {

return Html::encode(User::getUsernameFromArray($model_user)) . '<br />'
return Html::encode(UserModel::getUsernameFromArray($model_user)) . '<br />'
. Html::activeTextInput(
$model,
'users_comment[' . $model_user['user_id'] . ']',

+ 3
- 3
backend/views/point-sale/index.php Visa fil

@@ -98,7 +98,7 @@ $this->addButton(
],
'format' => 'raw',
'value' => function ($model) {
$count = UserPointSale::find()->where(
$count = UserPointSaleModel::find()->where(
['id_point_sale' => $model->id]
)->count();
$html = '';
@@ -128,8 +128,8 @@ $this->addButton(
'label' => 'Crédit',
'format' => 'raw',
'value' => function ($model) {
if ($model->credit && isset(Producer::$creditFunctioningArray[$model->credit_functioning])) {
return '<span class="glyphicon glyphicon-euro"></span> ' . Producer::$creditFunctioningArray[$model->credit_functioning];
if ($model->credit && isset(ProducerModel::$creditFunctioningArray[$model->credit_functioning])) {
return '<span class="glyphicon glyphicon-euro"></span> ' . ProducerModel::$creditFunctioningArray[$model->credit_functioning];
}

return '';

+ 2
- 2
backend/views/producer-admin/_form.php Visa fil

@@ -52,9 +52,9 @@ use yii\widgets\ActiveForm;

<h3>Facturation</h3>
<?= $form->field($model, 'option_billing_type')
->dropDownList(Producer::getBillingTypePopulateDropdown()); ?>
->dropDownList(ProducerModel::getBillingTypePopulateDropdown()); ?>
<?= $form->field($model, 'option_billing_frequency')
->dropDownList(Producer::getBillingFrequencyPopulateDropdown()); ?>
->dropDownList(ProducerModel::getBillingFrequencyPopulateDropdown()); ?>
<?= $form->field($model, 'option_billing_reduction')
->dropDownList([
0 => 'Non',

+ 1
- 1
backend/views/producer-admin/index.php Visa fil

@@ -188,7 +188,7 @@ $this->addButton(['label' => 'Nouveau producteur <span class="glyphicon glyphico
'format' => 'raw',
'value' => function($model) {
$str = '<ul style="margin: 0px;padding-left: 15px;">';
$str .= '<li>'.Producer::$billingFrequencyArray[$model->option_billing_frequency].'</li>';
$str .= '<li>'.ProducerModel::$billingFrequencyArray[$model->option_billing_frequency].'</li>';

if($model->option_billing_permanent_transfer) {
$str .= '<li>Virement permanent : <strong>'.Price::format($model->option_billing_permanent_transfer_amount, 0).'</strong></li>';

+ 17
- 17
backend/views/producer/update.php Visa fil

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

<script>
var appInitValues = {
isAdmin: <?= (int)User::isCurrentAdmin() ?>
isAdmin: <?= (int)UserModel::isCurrentAdmin() ?>
};
</script>

@@ -120,8 +120,8 @@ $this->addBreadcrumb($this->getTitle());
?>
<?= $form->field($model, 'behavior_home_point_sale_day_list')
->dropDownList([
Producer::BEHAVIOR_HOME_POINT_SALE_DAY_LIST_WEEK => 'Jours de la semaine',
Producer::BEHAVIOR_HOME_POINT_SALE_DAY_LIST_INCOMING_DISTRIBUTIONS => 'Distributions à venir',
ProducerModel::BEHAVIOR_HOME_POINT_SALE_DAY_LIST_WEEK => 'Jours de la semaine',
ProducerModel::BEHAVIOR_HOME_POINT_SALE_DAY_LIST_INCOMING_DISTRIBUTIONS => 'Distributions à venir',
]); ?>
</div>
</div>
@@ -245,13 +245,13 @@ $this->addBreadcrumb($this->getTitle());
<h4>Tunnel de commande</h4>
<?= $form->field($model, 'option_order_entry_point')
->dropDownList([
Producer::ORDER_ENTRY_POINT_DATE => 'Date',
Producer::ORDER_ENTRY_POINT_POINT_SALE => 'Point de vente',
ProducerModel::ORDER_ENTRY_POINT_DATE => 'Date',
ProducerModel::ORDER_ENTRY_POINT_POINT_SALE => 'Point de vente',
], []); ?>
<?= $form->field($model, 'behavior_order_select_distribution')
->dropDownList([
Producer::BEHAVIOR_ORDER_SELECT_DISTRIBUTION_CALENDAR => 'Calendrier',
Producer::BEHAVIOR_ORDER_SELECT_DISTRIBUTION_LIST => 'Liste',
ProducerModel::BEHAVIOR_ORDER_SELECT_DISTRIBUTION_CALENDAR => 'Calendrier',
ProducerModel::BEHAVIOR_ORDER_SELECT_DISTRIBUTION_LIST => 'Liste',
]); ?>
<?= $form->field($model, 'option_delivery')
->dropDownList([
@@ -313,13 +313,13 @@ $this->addBreadcrumb($this->getTitle());
<h4>Divers</h4>
<?= $form->field($model, 'option_order_reference_type')
->dropDownList([
Producer::ORDER_REFERENCE_TYPE_NONE => '--',
Producer::ORDER_REFERENCE_TYPE_YEARLY => 'Annuelle',
ProducerModel::ORDER_REFERENCE_TYPE_NONE => '--',
ProducerModel::ORDER_REFERENCE_TYPE_YEARLY => 'Annuelle',
], []); ?>
<?= $form->field($model, 'option_behavior_cancel_order')
->dropDownList([
Producer::BEHAVIOR_DELETE_ORDER_DELETE => 'Suppression de la commande',
Producer::BEHAVIOR_DELETE_ORDER_STATUS => 'Passage de la commande en statut "supprimé"',
ProducerModel::BEHAVIOR_DELETE_ORDER_DELETE => 'Suppression de la commande',
ProducerModel::BEHAVIOR_DELETE_ORDER_STATUS => 'Passage de la commande en statut "supprimé"',
], []); ?>
</div>
</div>
@@ -351,10 +351,10 @@ $this->addBreadcrumb($this->getTitle());

<?= $form->field($model, 'credit_functioning')
->dropDownList([
Producer::CREDIT_FUNCTIONING_OPTIONAL => Producer::$creditFunctioningArray[Producer::CREDIT_FUNCTIONING_OPTIONAL],
Producer::CREDIT_FUNCTIONING_MANDATORY => Producer::$creditFunctioningArray[Producer::CREDIT_FUNCTIONING_MANDATORY],
Producer::CREDIT_FUNCTIONING_USER => Producer::$creditFunctioningArray[Producer::CREDIT_FUNCTIONING_USER],
], [])->hint(Producer::HINT_CREDIT_FUNCTIONING); ?>
ProducerModel::CREDIT_FUNCTIONING_OPTIONAL => ProducerModel::$creditFunctioningArray[ProducerModel::CREDIT_FUNCTIONING_OPTIONAL],
ProducerModel::CREDIT_FUNCTIONING_MANDATORY => ProducerModel::$creditFunctioningArray[ProducerModel::CREDIT_FUNCTIONING_MANDATORY],
ProducerModel::CREDIT_FUNCTIONING_USER => ProducerModel::$creditFunctioningArray[ProducerModel::CREDIT_FUNCTIONING_USER],
], [])->hint(ProducerModel::HINT_CREDIT_FUNCTIONING); ?>

<?= $form->field($model, 'use_credit_checked_default')
->dropDownList([
@@ -381,7 +381,7 @@ $this->addBreadcrumb($this->getTitle());
1 => 'Oui',
], []); ?>
<?= $form->field($model, 'option_online_payment_minimum_amount')
->hint('Valeur par défaut si non défini : '.Producer::ONLINE_PAYMENT_MINIMUM_AMOUNT_DEFAULT.' €')
->hint('Valeur par défaut si non défini : '.ProducerModel::ONLINE_PAYMENT_MINIMUM_AMOUNT_DEFAULT.' €')
->textInput(); ?>
<?= $form->field($model, 'option_stripe_mode_test')->dropDownList([
0 => 'Non',
@@ -430,7 +430,7 @@ $this->addBreadcrumb($this->getTitle());
<div class="panel-body">
<h4>Facturation</h4>
<?= $form->field($model, 'id_tax_rate_default')
->dropDownList(ArrayHelper::map(TaxRate::find()->all(), 'id', function ($model) {
->dropDownList(ArrayHelper::map(TaxRateModel::find()->all(), 'id', function ($model) {
return $model->name;
}))
->label('TVA à appliquer par défaut'); ?>

+ 5
- 5
backend/views/product/_form.php Visa fil

@@ -22,12 +22,12 @@ use common\helpers\GlobalParam;
<?= $form->field($model, 'active')->radioList([1 => 'Oui', 0 => 'Non']) ?>
<?= $form->field($model, 'name')->textInput(['maxlength' => 255]) ?>
<?= $form->field($model, 'reference')->textInput(['maxlength' => 255]) ?>
<?= $form->field($model, 'id_product_category')->dropDownList(ProductCategory::populateDropdownList()); ?>
<?= $form->field($model, 'id_product_category')->dropDownList(ProductCategoryModel::populateDropdownList()); ?>
<?= $form->field($model, 'description')->textInput(['maxlength' => 255]) ?>
<?= $form->field($model, 'recipe')->textarea()->label('Description longue') ?>

<?= $form->field($model, 'unit')
->dropDownList(ArrayHelper::map(Product::$unitsArray, 'unit', 'wording'))
->dropDownList(ArrayHelper::map(ProductModel::$unitsArray, 'unit', 'wording'))
->label('Unité (pièce, poids ou volume)'); ?>


@@ -37,10 +37,10 @@ use common\helpers\GlobalParam;
$producer = \common\helpers\GlobalParam::getCurrentProducer();
$taxRateDefault = $producer->taxRate;

$taxRateNamesArray = array_merge(array(0 => 'Tva par défaut'), ArrayHelper::map(TaxRate::find()->all(), 'id', function ($model) {
$taxRateNamesArray = array_merge(array(0 => 'Tva par défaut'), ArrayHelper::map(TaxRateModel::find()->all(), 'id', function ($model) {
return $model->name;
}));
$taxRateValuesArray = array_merge(array(0 => $taxRateDefault->value), ArrayHelper::map(TaxRate::find()->all(), 'id', function ($model) {
$taxRateValuesArray = array_merge(array(0 => $taxRateDefault->value), ArrayHelper::map(TaxRateModel::find()->all(), 'id', function ($model) {
return $model->value;
}));
foreach ($taxRateValuesArray as $key => $taxRateValue) {
@@ -139,7 +139,7 @@ use common\helpers\GlobalParam;
<?= $form->field($model, 'available_on_points_sale')->radioList([1 => 'Disponible', 0 => 'Indisponible']) ?>

<strong id="label-availability-points-sale">Et <span><?php if($model->available_on_points_sale): ?>indisponible<?php else: ?>disponible<?php endif; ?></span> sur les points de vente</strong>
<?php $pointSaleArray = PointSale::find()
<?php $pointSaleArray = PointSaleModel::find()
->where(['id_producer' => GlobalParam::getCurrentProducerId()])
->orderBy('is_bread_box ASC, name ASC')
->all(); ?>

+ 1
- 1
backend/views/product/index.php Visa fil

@@ -116,7 +116,7 @@ $this->addButton(['label' => 'Nouveau produit <span class="glyphicon glyphicon-p
'value' => function ($model) {
$return = '';
if ($model->price) {
$return = Price::format($model->getPriceWithTax()) . ' (' . Product::strUnit($model->unit, 'wording_unit', true) . ')';
$return = Price::format($model->getPriceWithTax()) . ' (' . ProductModel::strUnit($model->unit, 'wording_unit', true) . ')';
}

return $return;

+ 5
- 5
backend/views/product/update/prices/_form.php Visa fil

@@ -28,9 +28,9 @@ use common\models\UserModel ;
]); ?>

<?= $form->field($model, 'id_user')->dropDownList(UserModel::populateDropdownList()); ?>
<?= $form->field($model, 'id_user_group')->dropDownList(UserGroup::populateDropdownList()); ?>
<?= $form->field($model, 'id_point_sale')->dropDownList(PointSale::populateDropdownList()); ?>
<?= $form->field($model, 'from_quantity')->label('À partir de la quantité ('.Product::strUnit(Product::getRefUnit($modelProduct->unit), 'wording').')'); ?>
<?= $form->field($model, 'id_user_group')->dropDownList(UserGroupModel::populateDropdownList()); ?>
<?= $form->field($model, 'id_point_sale')->dropDownList(PointSaleModel::populateDropdownList()); ?>
<?= $form->field($model, 'from_quantity')->label('À partir de la quantité ('.ProductModel::strUnit(ProductModel::getRefUnit($modelProduct->unit), 'wording').')'); ?>

<?php
$producer = GlobalParam::getCurrentProducer();
@@ -44,13 +44,13 @@ use common\models\UserModel ;
'template' => '
<div class="row">
<div class="col-xs-6">
<label for="product-price" class="control-label without-tax">Prix ('.Product::strUnit(Product::getRefUnit($modelProduct->unit), 'wording_unit').') HT</label>
<label for="product-price" class="control-label without-tax">Prix ('.ProductModel::strUnit(ProductModel::getRefUnit($modelProduct->unit), 'wording_unit').') HT</label>
<div class="input-group">
{input} <span class="input-group-addon"><span class="glyphicon glyphicon-euro"></span></span>
</div>
</div>
<div class="col-xs-6">
<label for="productprice-price-with-tax" class="control-label with-tax">Prix ('.Product::strUnit(Product::getRefUnit($modelProduct->unit), 'wording_unit').') TTC</label>
<label for="productprice-price-with-tax" class="control-label with-tax">Prix ('.ProductModel::strUnit(ProductModel::getRefUnit($modelProduct->unit), 'wording_unit').') TTC</label>
<div class="input-group">
<input type="text" id="productprice-price-with-tax" class="form-control" name="" value="" data-tax-rate-value="'.$taxRateValue.'">
<span class="input-group-addon"><span class="glyphicon glyphicon-euro"></span></span>

+ 1
- 1
backend/views/product/update/prices/list.php Visa fil

@@ -106,7 +106,7 @@ $this->addBreadcrumb('Modifier');
'attribute' => 'from_quantity',
'value' => function ($productPrice) {
if($productPrice->from_quantity) {
return $productPrice->from_quantity.' '.Product::strUnit(Product::getRefUnit($productPrice->product->unit), 'wording');
return $productPrice->from_quantity.' '.ProductModel::strUnit(ProductModel::getRefUnit($productPrice->product->unit), 'wording');
}

return '' ;

+ 2
- 2
backend/views/quotation/index.php Visa fil

@@ -43,7 +43,7 @@ $this->addButton(['label' => 'Nouveau devis <span class="glyphicon glyphicon-plu
?>

<div class="quotation-index">
<?php if(Quotation::searchCount()): ?>
<?php if(QuotationModel::searchCount()): ?>
<?= GridView::widget([
'filterModel' => $searchModel,
'dataProvider' => $dataProvider,
@@ -88,7 +88,7 @@ $this->addButton(['label' => 'Nouveau devis <span class="glyphicon glyphicon-plu
'attribute' => 'amount',
'header' => 'Montant',
'value' => function($invoice) {
return $invoice->getAmountWithTax(Order::AMOUNT_TOTAL, true) ;
return $invoice->getAmountWithTax(OrderModel::AMOUNT_TOTAL, true) ;
}
],
[

+ 1
- 1
backend/views/site/index.php Visa fil

@@ -162,7 +162,7 @@ $this->setTitle('Tableau de bord');
</td>
<td><?= $order->getCartSummary() ; ?></td>
<td><?= $order->getPointSaleSummary() ; ?></td>
<td><?= $order->getAmountWithTax(Order::AMOUNT_TOTAL, true) ; ?></td>
<td><?= $order->getAmountWithTax(OrderModel::AMOUNT_TOTAL, true) ; ?></td>
<td class="history"><?= $order->getStrHistory() ; ?></td>
</tr>
<?php endforeach; ?>

+ 4
- 4
backend/views/subscription/_form.php Visa fil

@@ -64,7 +64,7 @@ use common\helpers\GlobalParam ;
<div class="clr"></div>
<?= $form->field($model, 'id_producer')->hiddenInput() ?>
<?= $form->field($model, 'id_point_sale')->dropDownList(ArrayHelper::map(PointSale::searchAll(), 'id', function($model, $defaultValue) {
<?= $form->field($model, 'id_point_sale')->dropDownList(ArrayHelper::map(PointSaleModel::searchAll(), 'id', function($model, $defaultValue) {
return $model['name'];
}), ['prompt' => '--','class' => 'form-control user-id']) ?>
<?= $form->field($model, 'date_begin') ?>
@@ -84,9 +84,9 @@ use common\helpers\GlobalParam ;

<?= $form->field($model, 'auto_payment')
->dropDownList([
Subscription::AUTO_PAYMENT_DEDUCTED => 'Déduit',
Subscription::AUTO_PAYMENT_YES => 'Oui',
Subscription::AUTO_PAYMENT_NO => 'Non'
SubscriptionModel::AUTO_PAYMENT_DEDUCTED => 'Déduit',
SubscriptionModel::AUTO_PAYMENT_YES => 'Oui',
SubscriptionModel::AUTO_PAYMENT_NO => 'Non'
])
->hint('Attention, un compte client existant doit être spécifié en haut de ce formulaire.') ?>

+ 3
- 3
backend/views/subscription/index.php Visa fil

@@ -46,7 +46,7 @@ $this->setTitle('Abonnements') ;
$this->addBreadcrumb($this->getTitle()) ;
$this->addButton(['label' => 'Nouvel abonnement <span class="glyphicon glyphicon-plus"></span>', 'url' => 'subscription/create', 'class' => 'btn btn-primary']) ;

$subscriptionsArray = Subscription::searchAll() ;
$subscriptionsArray = SubscriptionModel::searchAll() ;



@@ -82,7 +82,7 @@ $subscriptionsArray = Subscription::searchAll() ;
foreach($model->productSubscription as $productSubscription)
{
if(isset($productSubscription->product)) {
$html .= Html::encode($productSubscription->product->name).' ('.($productSubscription->quantity * Product::$unitsArray[$productSubscription->product->unit]['coefficient']).'&nbsp;'.Product::strUnit($productSubscription->product->unit, 'wording_short').')<br />' ;
$html .= Html::encode($productSubscription->product->name).' ('.($productSubscription->quantity * ProductModel::$unitsArray[$productSubscription->product->unit]['coefficient']).'&nbsp;'.ProductModel::strUnit($productSubscription->product->unit, 'wording_short').')<br />' ;
}
else {
$html .= 'Produit non défini<br />' ;
@@ -102,7 +102,7 @@ $subscriptionsArray = Subscription::searchAll() ;
'attribute' => 'id_point_sale',
'label' => 'Point de vente',
'format' => 'raw',
'filter' => ArrayHelper::map(PointSale::find()->where(['id_producer' => GlobalParam::getCurrentProducerId()])->asArray()->all(), 'id', 'name'),
'filter' => ArrayHelper::map(PointSaleModel::find()->where(['id_producer' => GlobalParam::getCurrentProducerId()])->asArray()->all(), 'id', 'name'),
'value' => function($model) {
return Html::encode($model->pointSale->name) ;
}

+ 3
- 3
backend/views/user/_form.php Visa fil

@@ -52,7 +52,7 @@ use common\models\ProductPrice ;
]); ?>

<?= $form->field($model, 'type')
->dropDownList(User::getTypeChoicesArray(), [
->dropDownList(UserModel::getTypeChoicesArray(), [
'v-model' => 'type'
]) ; ?>
<?= $form->field($model, 'name_legal_person', ['options' => ['v-show' => "type == 'legal-person'"]])->textInput() ?>
@@ -62,7 +62,7 @@ use common\models\ProductPrice ;
<?= $form->field($model, 'email')->textInput() ?>
<?= $form->field($model, 'address')->textarea() ?>

<?php if(Producer::getConfig('option_export_evoliz')): ?>
<?php if(ProducerModel::getConfig('option_export_evoliz')): ?>
<?= $form->field($model, 'evoliz_code')->textInput() ?>
<?php endif; ?>

@@ -88,7 +88,7 @@ use common\models\ProductPrice ;
?>

<?php /* $form->field($model, 'product_price_percent')
->dropDownList(ProductPrice::percentValues(), [])->hint('Pourcentage appliqué aux prix de chaque produit pour cet utilisateur.');*/ ?>
->dropDownList(ProductPriceModel::percentValues(), [])->hint('Pourcentage appliqué aux prix de chaque produit pour cet utilisateur.');*/ ?>

<div class="form-group">
<?= Html::submitButton($model->isNewRecord ? 'Ajouter' : 'Modifier', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>

+ 3
- 3
backend/views/user/credit.php Visa fil

@@ -54,7 +54,7 @@ $this->addBreadcrumb('Créditer') ;
<div class="user-credit">
<?php
$producer = Producer::searchOne([
$producer = ProducerModel::searchOne([
'id' => GlobalParam::getCurrentProducerId()
]);
@@ -89,8 +89,8 @@ $this->addBreadcrumb('Créditer') ;
<div class="panel-body">
<?php $form = ActiveForm::begin(); ?>
<?= $form->field($creditForm, 'type')->dropDownList([
CreditHistory::TYPE_CREDIT => 'Crédit',
CreditHistory::TYPE_DEBIT => 'Débit',
CreditHistoryModel::TYPE_CREDIT => 'Crédit',
CreditHistoryModel::TYPE_DEBIT => 'Débit',
]) ?>
<?= $form->field($creditForm, 'amount')->textInput() ?>
<?= $form->field($creditForm, 'mean_payment')->dropDownList([

+ 2
- 2
backend/views/user/index.php Visa fil

@@ -107,7 +107,7 @@ $this->render('_menu', [
'buttons' => [
'orders' => function ($url, $model) {
$url = Yii::$app->urlManager->createUrl(['user/orders', 'id' => $model['id']]);
$countOrders = Order::searchCount([
$countOrders = OrderModel::searchCount([
'id_user' => $model['id'],
], ['conditions' => 'date_delete IS NULL']);

@@ -129,7 +129,7 @@ $this->render('_menu', [
'format' => 'raw',
'value' => function ($model) use ($producer) {

$userProducer = UserProducer::searchOne([
$userProducer = UserProducerModel::searchOne([
'id_user' => $model->id
]);
$credit = $userProducer ? $userProducer->credit : 0;

+ 104
- 0
common/components/BusinessLogic.php Visa fil

@@ -2,10 +2,25 @@

namespace common\components;

use common\logic\Config\TaxRate\TaxRateContainer;
use common\logic\Distribution\Distribution\DistributionContainer;
use common\logic\Document\Document\DocumentContainer;
use common\logic\Order\Order\OrderContainer;
use common\logic\Order\OrderStatusHistory\OrderStatusHistoryContainer;
use common\logic\Order\ProductOrder\ProductOrderContainer;
use common\logic\PointSale\PointSale\PointSaleContainer;
use common\logic\Producer\Producer\ProducerContainer;
use common\logic\Producer\ProducerPriceRange\ProducerPriceRangeContainer;
use common\logic\Product\Product\ProductContainer;
use common\logic\Product\ProductCategory\ProductCategoryContainer;
use common\logic\Product\ProductPointSale\ProductPointSaleContainer;
use common\logic\Product\ProductPrice\ProductPriceContainer;
use common\logic\Subscription\ProductSubscription\ProductSubscriptionContainer;
use common\logic\Subscription\Subscription\SubscriptionContainer;
use common\logic\User\CreditHistory\CreditHistoryContainer;
use common\logic\User\User\UserContainer;
use common\logic\User\UserGroup\UserGroupContainer;
use common\logic\User\UserGroup\UserUserGroupContainer;
use common\logic\User\UserProducer\UserProducerContainer;
use yii\base\ErrorException;

@@ -14,11 +29,25 @@ class BusinessLogic
public function getContainers()
{
return [
$this->getTaxRateContainer(),
$this->getUserUserGroupContainer(),
$this->getUserGroupContainer(),
$this->getDocumentContainer(),
$this->getCreditHistoryContainer(),
$this->getProducerPriceRangeContainer(),
$this->getUserProducerContainer(),
$this->getOrderSatusHistoryContainer(),
$this->getProductCategoryContainer(),
$this->getProductPointSaleContainer(),
$this->getProductOrderContainer(),
$this->getProductPriceContainer(),
$this->getProductSubscriptionContainer(),
$this->getSubscriptionContainer(),
$this->getProductContainer(),
$this->getDistributionContainer(),
$this->getUserContainer(),
$this->getProducerContainer(),
$this->getOrderContainer(),
];
}

@@ -47,6 +76,81 @@ class BusinessLogic
return new CreditHistoryContainer();
}

public function getDocumentContainer(): DocumentContainer
{
return new DocumentContainer();
}

public function getUserGroupContainer(): UserGroupContainer
{
return new UserGroupContainer();
}

public function getUserUserGroupContainer(): UserUserGroupContainer
{
return new UserUserGroupContainer();
}

public function getDistributionContainer(): DistributionContainer
{
return new DistributionContainer();
}

public function getTaxRateContainer(): TaxRateContainer
{
return new TaxRateContainer();
}

public function getOrderContainer(): OrderContainer
{
return new OrderContainer();
}

public function getOrderSatusHistoryContainer(): OrderStatusHistoryContainer
{
return new OrderStatusHistoryContainer();
}

public function getPointSaleContainer(): PointSaleContainer
{
return new PointSaleContainer();
}

public function getProductOrderContainer(): ProductOrderContainer
{
return new ProductOrderContainer();
}

public function getProductContainer(): ProductContainer
{
return new ProductContainer();
}

public function getProductCategoryContainer(): ProductCategoryContainer
{
return new ProductCategoryContainer();
}

public function getProductPointSaleContainer(): ProductPointSaleContainer
{
return new ProductPointSaleContainer();
}

public function getProductPriceContainer(): ProductPriceContainer
{
return new ProductPriceContainer();
}

public function getSubscriptionContainer(): SubscriptionContainer
{
return new SubscriptionContainer();
}

public function getProductSubscriptionContainer(): ProductSubscriptionContainer
{
return new ProductSubscriptionContainer();
}

/*
* Hiérarchie des apps
*/

common/models/SubscriptionForm.php → common/forms/SubscriptionForm.php Visa fil

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

namespace common\models;
namespace common\forms;

use Yii;
use yii\base\Model;
@@ -118,7 +118,7 @@ class SubscriptionForm extends Model
public function save()
{
if ($this->id) {
$subscription = Subscription::searchOne(['id' => $this->id]) ;
$subscription = SubscriptionModel::searchOne(['id' => $this->id]) ;
}
else {
$subscription = new Subscription ;
@@ -156,19 +156,19 @@ class SubscriptionForm extends Model

// produits
if ($this->id) {
$productsSubscriptionsArray = ProductSubscription::findAll(['id_subscription' => $this->id]) ;
ProductSubscription::deleteAll(['id_subscription' => $this->id]);
$productsSubscriptionsArray = ProductSubscriptionModel::findAll(['id_subscription' => $this->id]) ;
ProductSubscriptionModel::deleteAll(['id_subscription' => $this->id]);
}

foreach ($this->products as $nameInput => $quantity) {
if ($quantity) {
$idProduct = (int) str_replace('product_', '', $nameInput);
$product = Product::findOne($idProduct) ;
$product = ProductModel::findOne($idProduct) ;

$newProductSubscription = new ProductSubscription;
$newProductSubscription->id_subscription = $subscription->id;
$newProductSubscription->id_product = $idProduct;
$newProductSubscription->quantity = $quantity / Product::$unitsArray[$product->unit]['coefficient'];
$newProductSubscription->quantity = $quantity / ProductModel::$unitsArray[$product->unit]['coefficient'];

$newProductSubscription->save();
}

+ 3
- 3
common/helpers/Price.php Visa fil

@@ -56,18 +56,18 @@ class Price
return floatval($priceWithTax) / ($taxRate + 1);
}

public static function getPriceWithTax($priceWithoutTax, $taxRate, $taxCalculationMethod = Document::TAX_CALCULATION_METHOD_DEFAULT)
public static function getPriceWithTax($priceWithoutTax, $taxRate, $taxCalculationMethod = DocumentModel::TAX_CALCULATION_METHOD_DEFAULT)
{
$vat = self::getVat($priceWithoutTax, $taxRate, $taxCalculationMethod);

return self::numberTwoDecimals(self::round($priceWithoutTax + $vat));
}

public static function getVat($priceTotalWithoutTax, $taxRate, $taxCalculationMethod = Document::TAX_CALCULATION_METHOD_DEFAULT)
public static function getVat($priceTotalWithoutTax, $taxRate, $taxCalculationMethod = DocumentModel::TAX_CALCULATION_METHOD_DEFAULT)
{
$vat = $priceTotalWithoutTax * $taxRate;

if($taxCalculationMethod == Document::TAX_CALCULATION_METHOD_SUM_OF_ROUNDINGS) {
if($taxCalculationMethod == DocumentModel::TAX_CALCULATION_METHOD_SUM_OF_ROUNDINGS) {
$vat = self::round($vat);
}


+ 2
- 2
common/helpers/Tiller.php Visa fil

@@ -80,7 +80,7 @@ class Tiller
{
if ($this->producer_tiller) {
$ordersTiller = $this->getOrders($date);
$ordersOpendistrib = Order::searchAll([
$ordersOpendistrib = OrderModel::searchAll([
'distribution.date' => $date,
'order.tiller_synchronization' => 1
], [
@@ -96,7 +96,7 @@ class Tiller
foreach ($ordersTiller->orders as $orderTiller) {
if ($orderOpendistrib->tiller_external_id == $orderTiller->id) {
$amountTotalOrderOpendistrib = (int)round(
$orderOpendistrib->getAmountWithTax(Order::AMOUNT_TOTAL) * 100
$orderOpendistrib->getAmountWithTax(OrderModel::AMOUNT_TOTAL) * 100
);
if ($amountTotalOrderOpendistrib == (int)$orderTiller->currentPayedAmount
|| $amountTotalOrderOpendistrib == (int)$orderTiller->currentBill) {

+ 31
- 0
common/logic/Config/TaxRate/TaxRateContainer.php Visa fil

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

namespace common\logic\Config\TaxRate;

use common\logic\ContainerInterface;

class TaxRateContainer implements ContainerInterface
{
public function getEntityFqcn(): string
{
return TaxRateModel::class;
}

public function getServices(): array
{
return [
TaxRateFactory::class,
TaxRateRepository::class,
];
}

public function getFactory(): TaxRateFactory
{
return new TaxRateFactory();
}

public function getRepository(): TaxRateRepository
{
return new TaxRateRepository();
}
}

+ 17
- 0
common/logic/Config/TaxRate/TaxRateFactory.php Visa fil

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

namespace common\logic\Config\TaxRate;

use common\logic\BaseService;
use common\logic\FactoryInterface;
use Stripe\TaxRate;

class TaxRateFactory extends BaseService implements FactoryInterface
{
public function create(): TaxRate
{
$taxRate = new TaxRate();

return $taxRate;
}
}

+ 43
- 0
common/logic/Config/TaxRate/TaxRateModel.php Visa fil

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

namespace common\logic\Config\TaxRate;

use common\components\ActiveRecordCommon;

/**
* This is the model class for table "tax_rate".
*
*/
class TaxRateModel extends ActiveRecordCommon
{
/**
* @inheritdoc
*/
public static function tableName()
{
return 'tax_rate';
}

/**
* @inheritdoc
*/
public function rules()
{
return [
[['value'], 'number'],
[['name'], 'string', 'max' => 255],
];
}

/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'name' => 'Nom',
'value' => 'Valeur (0.2 pour 20%)',
];
}
}

+ 37
- 0
common/logic/Config/TaxRate/TaxRateRepository.php Visa fil

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

namespace common\logic\Config\TaxRate;

use common\logic\BaseService;
use common\logic\RepositoryInterface;

class TaxRateRepository extends BaseService implements RepositoryInterface
{

/**
* Retourne les options de base nécessaires à la fonction de recherche.
*
*/
public function defaultOptionsSearch(): array
{
return [
'with' => [],
'join_with' => [],
'orderby' => 'pourcent ASC',
'attribute_id_producer' => ''
] ;
}

// getTaxRateArray
public function getAsArray(): array
{
$taxRateArrayReturn = [];
$taxRateArray = TaxRateModel::find()->all();

foreach($taxRateArray as $taxRate) {
$taxRateArrayReturn[$taxRate->id] = $taxRate;
}

return $taxRateArrayReturn;
}
}

common/models/Development.php → common/logic/Development/Development/DevelopmentModel.php Visa fil

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

namespace common\models;
namespace common\logic\Development\Development;

use common\helpers\GlobalParam;
use Yii;
use common\components\ActiveRecordCommon ;
use common\models\DeveloppementPriorite;

/**
* This is the model class for table "development".
@@ -54,7 +53,7 @@ use common\models\DeveloppementPriorite;
* @property string $status
* @property double $time_estimate
*/
class Development extends ActiveRecordCommon
class DevelopmentModel extends ActiveRecordCommon
{
const STATUS_OPEN = 'open';
const STATUS_CLOSED = 'closed';
@@ -92,7 +91,7 @@ class Development extends ActiveRecordCommon
public function getDevelopmentPriority()
{
return $this->hasMany(
DevelopmentPriority::className(),
DevelopmentPriorityModel::className(),
['id_development' => 'id'])
->with('producer');
}
@@ -100,7 +99,7 @@ class Development extends ActiveRecordCommon
public function getDevelopmentPriorityCurrentProducer()
{
return $this->hasOne(
DevelopmentPriority::className(),
DevelopmentPriorityModel::className(),
['id_development' => 'id'])
->where(['id_producer' => GlobalParam::getCurrentProducerId()])
->with('producer');

common/models/DevelopmentPriority.php → common/logic/Development/DevelopmentPriority/DevelopmentPriorityModel.php Visa fil

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

namespace common\models;
namespace common\logic\Development\DevelopmentPriority;

use common\logic\Producer\Producer\ProducerModel;
use Yii;
use common\components\ActiveRecordCommon ;
use common\models\Producer;

/**
* This is the model class for table "development_priority".
*
* @property integer $id_user
* @property integer $id_development
*/
class DevelopmentPriority extends ActiveRecordCommon
class DevelopmentPriorityModel extends ActiveRecordCommon
{

const PRIORITY_HIGH = 'high';
@@ -138,13 +134,13 @@ class DevelopmentPriority extends ActiveRecordCommon
public function getClassCssStyleButton()
{
$styleButton = 'default';
if ($this->priority == DevelopmentPriority::PRIORITY_LOW) {
if ($this->priority == DevelopmentPriorityModel::PRIORITY_LOW) {
$styleButton = 'info';
}
elseif ($this->priority == DevelopmentPriority::PRIORITY_NORMAL) {
elseif ($this->priority == DevelopmentPriorityModel::PRIORITY_NORMAL) {
$styleButton = 'warning';
}
elseif ($this->priority == DevelopmentPriority::PRIORITY_HIGH) {
elseif ($this->priority == DevelopmentPriorityModel::PRIORITY_HIGH) {
$styleButton = 'danger';
}

+ 11
- 0
common/logic/Distribution/Distribution/DistributionBuilder.php Visa fil

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

namespace common\logic\Distribution\Distribution;

use common\logic\BaseService;
use common\logic\BuilderInterface;

class DistributionBuilder extends BaseService implements BuilderInterface
{

}

+ 43
- 0
common/logic/Distribution/Distribution/DistributionContainer.php Visa fil

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

namespace common\logic\Distribution\Distribution;

use common\logic\ContainerInterface;

class DistributionContainer implements ContainerInterface
{
public function getEntityFqcn(): string
{
return DistributionModel::class;
}

public function getServices(): array
{
return [
DistributionFactory::class,
DistributionSolver::class,
DistributionRepository::class,
DistributionBuilder::class
];
}

public function getFactory(): DistributionFactory
{
return new DistributionFactory();
}

public function getSolver(): DistributionSolver
{
return new DistributionSolver();
}

public function getRepository(): DistributionRepository
{
return new DistributionRepository();
}

public function getBuilder(): DistributionBuilder
{
return new DistributionBuilder();
}
}

+ 16
- 0
common/logic/Distribution/Distribution/DistributionFactory.php Visa fil

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

namespace common\logic\Distribution\Distribution;

use common\logic\BaseService;
use common\logic\FactoryInterface;

class DistributionFactory extends BaseService implements FactoryInterface
{
public function create(): DistributionModel
{
$distribution = new DistributionModel();

return $distribution;
}
}

common/models/Distribution.php → common/logic/Distribution/Distribution/DistributionModel.php Visa fil

@@ -36,12 +36,10 @@
* termes.
*/

namespace common\models;
namespace common\logic\Distribution\Distribution;

use common\logic\Producer\Producer\ProducerModel;
use Yii;
use common\helpers\GlobalParam;
use common\models\Order;
use common\components\ActiveRecordCommon;

/**
@@ -51,7 +49,7 @@ use common\components\ActiveRecordCommon;
* @property string $date
* @property integer $active
*/
class Distribution extends ActiveRecordCommon
class DistributionModel extends ActiveRecordCommon
{
/**
* @inheritdoc
@@ -96,17 +94,17 @@ class Distribution extends ActiveRecordCommon

public function getOrder()
{
return $this->hasMany(Order::className(), ['id_distribution' => 'id']);
return $this->hasMany(OrderModel::className(), ['id_distribution' => 'id']);
}

public function getProductDistribution()
{
return $this->hasMany(ProductDistribution::className(), ['id_distribution' => 'id']);
return $this->hasMany(ProductDistributionModel::className(), ['id_distribution' => 'id']);
}

public function getPointSaleDistribution()
{
return $this->hasMany(PointSaleDistribution::className(), ['id_distribution' => 'id']) ;
return $this->hasMany(PointSaleDistributionModel::className(), ['id_distribution' => 'id']) ;
}

/**
@@ -174,7 +172,7 @@ class Distribution extends ActiveRecordCommon
$idProducer = GlobalParam::getCurrentProducerId();
}

$distribution = Distribution::searchOne($paramsDistribution);
$distribution = DistributionModel::searchOne($paramsDistribution);

if (!$distribution) {
$distribution = new Distribution;
@@ -188,20 +186,20 @@ class Distribution extends ActiveRecordCommon
// point_sale_distribution à définir s'ils ne sont pas initialisés
if ($distribution) {

$countPointSaleDistribution = PointSaleDistribution::searchCount([
$countPointSaleDistribution = PointSaleDistributionModel::searchCount([
'id_distribution' => $distribution->id
]);

if (!$countPointSaleDistribution) {
PointSaleDistribution::setAll($distribution->id, true);
PointSaleDistributionModel::setAll($distribution->id, true);
}
}

// init produits sélectionnés pour cette production
$products = Product::searchAll();
$products = ProductModel::searchAll();

if ($distribution) {
$productsDistribution = ProductDistribution::searchAll([
$productsDistribution = ProductDistributionModel::searchAll([
'id_distribution' => $distribution->id
]);
if (!count($productsDistribution)) {
@@ -222,7 +220,7 @@ class Distribution extends ActiveRecordCommon
*/
public static function getIncomingDistributions()
{
$distributionsArray = Distribution::find()
$distributionsArray = DistributionModel::find()
->where('date > \'' . date('Y-m-d') . '\'')
->andWhere([
'id_producer' => GlobalParam::getCurrentProducerId(),
@@ -296,7 +294,7 @@ class Distribution extends ActiveRecordCommon
*/
public function linkProduct($product)
{
$productDistribution = ProductDistribution::searchOne([
$productDistribution = ProductDistributionModel::searchOne([
'id_distribution' => $this->id,
'id_product' => $product->id
]);
@@ -332,7 +330,7 @@ class Distribution extends ActiveRecordCommon
$productDistribution->save();

// update prices product order
$ordersArray = Order::searchAll([
$ordersArray = OrderModel::searchAll([
'distribution.date' => $this->date,
'distribution.id_producer' => $this->id_producer
],
@@ -376,10 +374,10 @@ class Distribution extends ActiveRecordCommon
*/
public function linkProductGift()
{
$productGift = Product::getProductGift();
$productGift = ProductModel::getProductGift();

if ($productGift) {
$productDistribution = ProductDistribution::searchOne([
$productDistribution = ProductDistributionModel::searchOne([
'id_distribution' => $this->id,
'id_product' => $productGift->id
]);
@@ -413,7 +411,7 @@ class Distribution extends ActiveRecordCommon
*/
public function linkPointSale($pointSale)
{
$pointSaleDistribution = PointSaleDistribution::searchOne([
$pointSaleDistribution = PointSaleDistributionModel::searchOne([
'id_distribution' => $this->id,
'id_point_sale' => $pointSale->id
]);
@@ -464,13 +462,13 @@ class Distribution extends ActiveRecordCommon
*/
public function active($active = true)
{
PointSaleDistribution::setAll($this->id, true);
PointSaleDistributionModel::setAll($this->id, true);
$this->active = (int)$active;
$this->save();

if ($active) {
// ajout des abonnements
Subscription::addAll($this->date);
SubscriptionModel::addAll($this->date);
}
}


+ 11
- 0
common/logic/Distribution/Distribution/DistributionRepository.php Visa fil

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

namespace common\logic\Distribution\Distribution;

use common\logic\BaseService;
use common\logic\RepositoryInterface;

class DistributionRepository extends BaseService implements RepositoryInterface
{

}

+ 11
- 0
common/logic/Distribution/Distribution/DistributionSolver.php Visa fil

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

namespace common\logic\Distribution\Distribution;

use common\logic\BaseService;
use common\logic\SolverInterface;

class DistributionSolver extends BaseService implements SolverInterface
{

}

+ 16
- 0
common/logic/Distribution/PointSaleDistribution/PointSaleDistributionFactory.php Visa fil

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

namespace common\logic\Distribution\PointSaleDistribution;

use common\logic\BaseService;
use common\logic\FactoryInterface;

class PointSaleDistributionFactory extends BaseService implements FactoryInterface
{
public function create(): PointSaleDistributionModel
{
$pointSaleDistribution = new PointSaleDistributionModel();

return $pointSaleDistribution;
}
}

common/models/PointSaleDistribution.php → common/logic/Distribution/PointSaleDistribution/PointSaleDistributionModel.php Visa fil

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

namespace common\models;
namespace common\logic\Distribution\PointSaleDistribution;

use common\helpers\GlobalParam;
use Yii;
use common\components\ActiveRecordCommon ;
use common\models\PointVente;
use common\models\Production;

/**
* This is the model class for table "production_point_vente".
@@ -51,7 +49,7 @@ use common\models\Production;
* @property integer $id_point_sale
* @property integer $delivery
*/
class PointSaleDistribution extends ActiveRecordCommon
class PointSaleDistributionModel extends ActiveRecordCommon
{

var $points_sale_distribution;
@@ -98,7 +96,7 @@ class PointSaleDistribution extends ActiveRecordCommon

public function getPointSale()
{
return $this->hasOne(PointSale::className(), ['id' => 'id_point_sale']);
return $this->hasOne(PointSaleModel::className(), ['id' => 'id_point_sale']);
}
/**
@@ -125,7 +123,7 @@ class PointSaleDistribution extends ActiveRecordCommon
public static function setAll($idDistribution, $boolDelivery)
{
// liaison PointSale / Distribution
$arrPointsSale = PointSale::find()
$arrPointsSale = PointSaleModel::find()
->with(['pointSaleDistribution' => function($q) use ($idDistribution) {
$q->where(['id_distribution' => $idDistribution]);
}])
@@ -143,7 +141,7 @@ class PointSaleDistribution extends ActiveRecordCommon
}
}

$distribution = Distribution::findOne($idDistribution);
$distribution = DistributionModel::findOne($idDistribution);

if ($distribution) {
$day = date('N', strtotime($distribution->date));

+ 16
- 0
common/logic/Distribution/ProductDistribution/ProductDistributionFactory.php Visa fil

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

namespace common\logic\Distribution\ProductDistribution;

use common\logic\BaseService;
use common\logic\FactoryInterface;

class ProductDistributionFactory extends BaseService implements FactoryInterface
{
public function create(): ProductDistributionModel
{
$productDistribution = new ProductDistributionModel();

return $productDistribution;
}
}

common/models/ProductDistribution.php → common/logic/Distribution/ProductDistribution/ProductDistributionModel.php Visa fil

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

namespace common\models;
namespace common\logic\Distribution\ProductDistribution;

use common\components\ActiveRecordCommon ;

@@ -48,7 +48,7 @@ use common\components\ActiveRecordCommon ;
* @property integer $id_product
* @property integer $active
*/
class ProductDistribution extends ActiveRecordCommon
class ProductDistributionModel extends ActiveRecordCommon
{

/**
@@ -76,7 +76,7 @@ class ProductDistribution extends ActiveRecordCommon
public function getProduct()
{
return $this->hasOne(Product::className(), ['id' => 'id_product']);
return $this->hasOne(ProductModel::className(), ['id' => 'id_product']);
}
public function getDistribution()
@@ -120,11 +120,11 @@ class ProductDistribution extends ActiveRecordCommon
*/
public static function searchByDistribution($idDistribution)
{
$arrayProductsDistribution = ProductDistribution::searchAll([
$arrayProductsDistribution = ProductDistributionModel::searchAll([
'id_distribution' => $idDistribution
]) ;
$orders = Order::searchAll([
$orders = OrderModel::searchAll([
'distribution.id' => $idDistribution
]) ;

@@ -134,8 +134,8 @@ class ProductDistribution extends ActiveRecordCommon
'active' => (int) $productDistribution->active,
'unavailable' => (int) $productDistribution->product->unavailable,
'quantity_max' => $productDistribution->quantity_max,
'quantity_order' => Order::getProductQuantity($productDistribution->id_product, $orders),
'quantity_remaining' => $productDistribution->quantity_max - Order::getProductQuantity($productDistribution->id_product, $orders)
'quantity_order' => OrderModel::getProductQuantity($productDistribution->id_product, $orders),
'quantity_remaining' => $productDistribution->quantity_max - OrderModel::getProductQuantity($productDistribution->id_product, $orders)
];
}
}

+ 31
- 0
common/logic/Document/DeliveryNote/DeliveryNoteContainer.php Visa fil

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

namespace common\logic\Document\DeliveryNote;

use common\logic\ContainerInterface;

class DeliveryNoteContainer implements ContainerInterface
{
public function getEntityFqcn(): string
{
return DeliveryNoteModel::class;
}

public function getServices(): array
{
return [
DeliveryNoteFactory::class,
DeliveryNoteSolver::class,
];
}

public function getFactory(): DeliveryNoteFactory
{
return new DeliveryNoteFactory();
}

public function getSolver(): DeliveryNoteSolver
{
return new DeliveryNoteSolver();
}
}

+ 16
- 0
common/logic/Document/DeliveryNote/DeliveryNoteFactory.php Visa fil

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

namespace common\logic\Document\DeliveryNote;

use common\logic\BaseService;
use common\logic\FactoryInterface;

class DeliveryNoteFactory extends BaseService implements FactoryInterface
{
public function create(): DeliveryNoteModel
{
$deliveryNote = new DeliveryNoteModel();

return $deliveryNote;
}
}

common/models/DeliveryNote.php → common/logic/Document/DeliveryNote/DeliveryNoteModel.php Visa fil

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

namespace common\models;
namespace common\logic\Document\DeliveryNote;

use common\components\ActiveRecordCommon;
use Yii;
@@ -55,7 +55,7 @@ use Yii;
* @property string $city
* @property string $postcode
*/
class DeliveryNote extends Document
class DeliveryNoteModel extends Document
{

/**
@@ -114,7 +114,7 @@ class DeliveryNote extends Document
$idInvoice = $this->getInvoiceId();

if($idInvoice) {
$invoice = Invoice::searchOne([
$invoice = InvoiceModel::searchOne([
'id' => $idInvoice
]);
}

common/models/DeliveryNoteSearch.php → common/logic/Document/DeliveryNote/DeliveryNoteSearch.php Visa fil

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

namespace common\models;

namespace common\logic\Document\DeliveryNote;

use common\helpers\GlobalParam;
use yii\data\ActiveDataProvider;

class DeliveryNoteSearch extends DeliveryNote
class DeliveryNoteSearch extends DeliveryNoteModel
{
public $id_point_sale ;
public $date_distribution ;
@@ -60,7 +60,7 @@ class DeliveryNoteSearch extends DeliveryNote
{
$optionsSearch = self::defaultOptionsSearch();

$query = DeliveryNote::find()
$query = DeliveryNoteModel::find()
->with($optionsSearch['with'])
->joinWith($optionsSearch['join_with'])
->where(['delivery_note.id_producer' => GlobalParam::getCurrentProducerId()])

+ 11
- 0
common/logic/Document/DeliveryNote/DeliveryNoteSolver.php Visa fil

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

namespace common\logic\Document\DeliveryNote;

use common\logic\BaseService;
use common\logic\SolverInterface;

class DeliveryNoteSolver extends BaseService implements SolverInterface
{

}

+ 11
- 0
common/logic/Document/Document/DocumentBuilder.php Visa fil

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

namespace common\logic\Document\Document;

use common\logic\BaseService;
use common\logic\BuilderInterface;

class DocumentBuilder extends BaseService implements BuilderInterface
{

}

+ 37
- 0
common/logic/Document/Document/DocumentContainer.php Visa fil

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

namespace common\logic\Document\Document;

use common\logic\ContainerInterface;

class DocumentContainer implements ContainerInterface
{
public function getEntityFqcn(): string
{
return DocumentModel::class;
}

public function getServices(): array
{
return [
DocumentSolver::class,
DocumentBuilder::class,
DocumentUtils::class,
];
}

public function getSolver(): DocumentSolver
{
return new DocumentSolver();
}

public function getBuilder(): DocumentBuilder
{
return new DocumentBuilder();
}

public function getUtils(): DocumentUtils
{
return new DocumentUtils();
}
}

common/models/Document.php → common/logic/Document/Document/DocumentModel.php Visa fil

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

namespace common\models;
namespace common\logic\Document\Document;

use common\components\ActiveRecordCommon;
use common\helpers\GlobalParam;
use common\logic\Producer\Producer\ProducerModel;
use kartik\mpdf\Pdf;
use Symfony\Component\Finder\Exception\DirectoryNotFoundException;
use yii\base\ErrorException;

class Document extends ActiveRecordCommon
class DocumentModel extends ActiveRecordCommon
{
const STATUS_DRAFT = 'draft';
const STATUS_VALID = 'valid';
@@ -110,9 +110,9 @@ class Document extends ActiveRecordCommon

public function relationOrders($fieldIdDocument)
{
$defaultOptionsSearch = Order::defaultOptionsSearch();
$defaultOptionsSearch = OrderModel::defaultOptionsSearch();

return $this->hasMany(Order::className(), [$fieldIdDocument => 'id'])
return $this->hasMany(OrderModel::className(), [$fieldIdDocument => 'id'])
->with($defaultOptionsSearch['with'])
->joinWith($defaultOptionsSearch['join_with'])
->orderBy('distribution.date ASC');
@@ -122,17 +122,17 @@ class Document extends ActiveRecordCommon
* Méthodes
*/

public function getAmount($type = Order::AMOUNT_TOTAL, $format = false)
public function getAmount($type = OrderModel::AMOUNT_TOTAL, $format = false)
{
return $this->_getAmountGeneric($type, false, $format);
}

public function getAmountWithTax($type = Order::AMOUNT_TOTAL, $format = false)
public function getAmountWithTax($type = OrderModel::AMOUNT_TOTAL, $format = false)
{
return $this->_getAmountGeneric($type, true, $format);
}

protected function _getAmountGeneric($type = Order::AMOUNT_TOTAL, $withTax = true, $format = false)
protected function _getAmountGeneric($type = OrderModel::AMOUNT_TOTAL, $withTax = true, $format = false)
{
$amount = 0;
$totalVat = 0;
@@ -262,7 +262,7 @@ class Document extends ActiveRecordCommon
}

$prefix = ProducerModel::getConfig('document_' . $classLower . '_prefix');
$oneDocumentExist = $class::searchOne(['status' => Document::STATUS_VALID], ['orderby' => 'reference DESC']);
$oneDocumentExist = $class::searchOne(['status' => DocumentModel::STATUS_VALID], ['orderby' => 'reference DESC']);

if ($oneDocumentExist) {
$reference = $oneDocumentExist->reference;
@@ -380,7 +380,7 @@ class Document extends ActiveRecordCommon

public function changeStatus($status)
{
if ($status == Document::STATUS_VALID) {
if ($status == DocumentModel::STATUS_VALID) {
$this->status = $status;
$this->reference = $this->generateReference();
}

+ 11
- 0
common/logic/Document/Document/DocumentSolver.php Visa fil

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

namespace common\logic\Document\Document;

use common\logic\BaseService;
use common\logic\SolverInterface;

class DocumentSolver extends BaseService implements SolverInterface
{

}

+ 11
- 0
common/logic/Document/Document/DocumentUtils.php Visa fil

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

namespace common\logic\Document\Document;

use common\logic\BaseService;
use common\logic\UtilsInterface;

class DocumentUtils extends BaseService implements UtilsInterface
{

}

+ 37
- 0
common/logic/Document/Invoice/InvoiceContainer.php Visa fil

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

namespace common\logic\Document\Invoice;

use common\logic\ContainerInterface;
use common\logic\Document\Document\DocumentBuilder;
use common\logic\Document\Document\DocumentSolver;

class InvoiceContainer implements ContainerInterface
{
public function getEntityFqcn(): string
{
return InvoiceModel::class;
}

public function getServices(): array
{
return [
InvoiceFactory::class,
];
}

public function getFactory(): InvoiceFactory
{
return new InvoiceFactory();
}

public function getSolver(): DocumentSolver
{
return new DocumentSolver();
}

public function getBuilder(): DocumentBuilder
{
return new DocumentBuilder();
}
}

+ 16
- 0
common/logic/Document/Invoice/InvoiceFactory.php Visa fil

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

namespace common\logic\Document\Invoice;

use common\logic\BaseService;
use common\logic\FactoryInterface;

class InvoiceFactory extends BaseService implements FactoryInterface
{
public function create(): InvoiceModel
{
$invoice = new InvoiceModel();

return $invoice;
}
}

common/models/Invoice.php → common/logic/Document/Invoice/InvoiceModel.php Visa fil

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

namespace common\models;
namespace common\logic\Document\Invoice;

use common\components\ActiveRecordCommon;
use Yii;
use common\logic\Document\Document\DocumentModel;

/**
* This is the model class for table "invoice".
@@ -54,7 +53,7 @@ use Yii;
* @property string $city
* @property string $postcode
*/
class Invoice extends Document
class InvoiceModel extends DocumentModel
{

public $deliveryNotes ;

common/models/InvoiceSearch.php → common/logic/Document/Invoice/InvoiceSearch.php Visa fil

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

namespace common\models;
namespace common\logic\Document\Invoice;

use common\helpers\GlobalParam;
use common\models\Invoice;

class InvoiceSearch extends Invoice
class InvoiceSearch extends InvoiceModel
{

var $username;

public function rules()
@@ -59,7 +57,7 @@ class InvoiceSearch extends Invoice
{
$optionsSearch = self::defaultOptionsSearch();

$query = Invoice::find()
$query = InvoiceModel::find()
->with($optionsSearch['with'])
->joinWith($optionsSearch['join_with'])
->where(['invoice.id_producer' => GlobalParam::getCurrentProducerId()])

+ 39
- 0
common/logic/Document/Quotation/QuotationContainer.php Visa fil

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

namespace common\logic\Document\Invoice;

use common\logic\ContainerInterface;
use common\logic\Document\Document\DocumentBuilder;
use common\logic\Document\Document\DocumentSolver;
use common\logic\Document\Quotation\QuotationFactory;
use common\logic\Document\Quotation\QuotationModel;

class QuotationContainer implements ContainerInterface
{
public function getEntityFqcn(): string
{
return QuotationModel::class;
}

public function getServices(): array
{
return [
QuotationFactory::class,
];
}

public function getFactory(): QuotationFactory
{
return new QuotationFactory();
}

public function getSolver(): DocumentSolver
{
return new DocumentSolver();
}

public function getBuilder(): DocumentBuilder
{
return new DocumentBuilder();
}
}

+ 16
- 0
common/logic/Document/Quotation/QuotationFactory.php Visa fil

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

namespace common\logic\Document\Quotation;

use common\logic\BaseService;
use common\logic\FactoryInterface;

class QuotationFactory extends BaseService implements FactoryInterface
{
public function create(): QuotationModel
{
$quotation = new QuotationModel();

return $quotation;
}
}

common/models/Quotation.php → common/logic/Document/Quotation/QuotationModel.php Visa fil

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

namespace common\models;
namespace common\logic\Document\Quotation;

use Yii;
use common\logic\Document\Document\DocumentModel;

/**
* This is the model class for table "quotation".
@@ -53,7 +53,7 @@ use Yii;
* @property string $city
* @property string $postcode
*/
class Quotation extends Document
class QuotationModel extends DocumentModel
{

/**

common/models/QuotationSearch.php → common/logic/Document/Quotation/QuotationSearch.php Visa fil

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

namespace common\models;
namespace common\logic\Document\Quotation;

use common\models\Quotation;
use common\helpers\GlobalParam;
use yii\data\ActiveDataProvider;

class QuotationSearch extends Quotation
class QuotationSearch extends QuotationModel
{

public function rules()
@@ -58,7 +58,7 @@ class QuotationSearch extends Quotation
{
$optionsSearch = self::defaultOptionsSearch();

$query = Quotation::find()
$query = QuotationModel::find()
->with($optionsSearch['with'])
->joinWith($optionsSearch['join_with'])
->where(['quotation.id_producer' => GlobalParam::getCurrentProducerId()])

+ 12
- 0
common/logic/Order/Order/OrderBuilder.php Visa fil

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

namespace common\logic\Order\Order;

use common\logic\BaseService;
use common\logic\BuilderInterface;
use common\logic\SolverInterface;

class OrderBuilder extends BaseService implements BuilderInterface
{
}

+ 49
- 0
common/logic/Order/Order/OrderContainer.php Visa fil

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

namespace common\logic\Order\Order;

use common\logic\ContainerInterface;

class OrderContainer implements ContainerInterface
{
public function getEntityFqcn(): string
{
return OrderModel::class;
}

public function getServices(): array
{
return [
OrderFactory::class,
OrderSolver::class,
OrderRepository::class,
OrderBuilder::class,
OrderUtils::class
];
}

public function getFactory(): OrderFactory
{
return new OrderFactory();
}

public function getSolver(): OrderSolver
{
return new OrderSolver();
}

public function getRepository(): OrderRepository
{
return new OrderRepository();
}

public function getBuilder(): OrderBuilder
{
return new OrderBuilder();
}

public function getUtils(): OrderUtils
{
return new OrderUtils();
}
}

+ 16
- 0
common/logic/Order/Order/OrderFactory.php Visa fil

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

namespace common\logic\Order\Order;

use common\logic\BaseService;
use common\logic\FactoryInterface;

class OrderFactory extends BaseService implements FactoryInterface
{
public function create(): OrderModel
{
$order = new OrderModel();

return $order;
}
}

common/models/Order.php → common/logic/Order/Order/OrderModel.php Visa fil

@@ -36,15 +36,13 @@
* termes.
*/

namespace common\models;
namespace common\logic\Order\Order;

use common\helpers\Debug;
use common\helpers\GlobalParam;
use common\helpers\Price;
use common\logic\Producer\Producer\ProducerModel;
use common\logic\User\CreditHistory\CreditHistoryModel;
use common\logic\User\User\UserModel;
use common\models\Producer;
use Yii;
use yii\helpers\Html;
use common\components\ActiveRecordCommon;
@@ -53,16 +51,8 @@ use yii\web\NotFoundHttpException;
/**
* This is the model class for table "order".
*
* @property integer $id
* @property integer $id_user
* @property string $date
* @property string $date_update
* @property integer $id_point_sale
* @property integer $id_distribution
* @property boolean $auto_payment
* @property integer $id_subscription
*/
class Order extends ActiveRecordCommon
class OrderModel extends ActiveRecordCommon
{
var $amount = 0;
var $amount_with_tax = 0;
@@ -160,7 +150,7 @@ class Order extends ActiveRecordCommon

public function getProductOrder()
{
return $this->hasMany(ProductOrder::className(), ['id_order' => 'id'])
return $this->hasMany(ProductOrderModel::className(), ['id_order' => 'id'])
->orderBy(['product.order' => SORT_ASC])
->joinWith('product');
}
@@ -178,7 +168,7 @@ class Order extends ActiveRecordCommon

public function getPointSale()
{
return $this->hasOne(PointSale::className(), ['id' => 'id_point_sale'])
return $this->hasOne(PointSaleModel::className(), ['id' => 'id_point_sale'])
->with('userPointSale');
}

@@ -189,23 +179,23 @@ class Order extends ActiveRecordCommon

public function getSubscription()
{
return $this->hasOne(Subscription::className(), ['id' => 'id_subscription'])
return $this->hasOne(SubscriptionModel::className(), ['id' => 'id_subscription'])
->with('productSubscription');
}

public function getInvoice()
{
return $this->hasOne(Invoice::className(), ['id' => 'id_invoice']);
return $this->hasOne(InvoiceModel::className(), ['id' => 'id_invoice']);
}

public function getQuotation()
{
return $this->hasOne(Quotation::className(), ['id' => 'id_quotation']);
return $this->hasOne(QuotationModel::className(), ['id' => 'id_quotation']);
}

public function getDeliveryNote()
{
return $this->hasOne(DeliveryNote::className(), ['id' => 'id_delivery_note']);
return $this->hasOne(DeliveryNoteModel::className(), ['id' => 'id_delivery_note']);
}

/**
@@ -233,7 +223,7 @@ class Order extends ActiveRecordCommon
* Initialise le montant total, le montant déjà payé et le poids de la
* commande.
*/
public function init($taxCalculationMethod = Document::TAX_CALCULATION_METHOD_DEFAULT)
public function init($taxCalculationMethod = DocumentModel::TAX_CALCULATION_METHOD_DEFAULT)
{
$this->initAmount($taxCalculationMethod);
$this->initPaidAmount();
@@ -245,7 +235,7 @@ class Order extends ActiveRecordCommon
* Initialise le montant de la commande.
*
*/
public function initAmount($taxCalculationMethod = Document::TAX_CALCULATION_METHOD_DEFAULT)
public function initAmount($taxCalculationMethod = DocumentModel::TAX_CALCULATION_METHOD_DEFAULT)
{
$this->amount = 0;
$this->amount_with_tax = 0;
@@ -360,7 +350,7 @@ class Order extends ActiveRecordCommon
public function delete($force = false)
{
// remboursement si l'utilisateur a payé pour cette commande
$amountPaid = $this->getAmount(Order::AMOUNT_PAID);
$amountPaid = $this->getAmount(OrderModel::AMOUNT_PAID);
if ($amountPaid > 0.01) {
$this->saveCreditHistory(
CreditHistoryModel::TYPE_REFUND,
@@ -377,7 +367,7 @@ class Order extends ActiveRecordCommon
'option_behavior_cancel_order'
) == ProducerModel::BEHAVIOR_DELETE_ORDER_STATUS && strlen($this->date_delete)) ||
$force) {
ProductOrder::deleteAll(['id_order' => $this->id]);
ProductOrderModel::deleteAll(['id_order' => $this->id]);
return parent::delete();
} // status 'delete'
elseif (ProducerModel::getConfig('option_behavior_cancel_order') == ProducerModel::BEHAVIOR_DELETE_ORDER_STATUS) {
@@ -529,7 +519,7 @@ class Order extends ActiveRecordCommon
*/
public function getDataJson()
{
$order = Order::searchOne(['order.id' => $this->id]);
$order = OrderModel::searchOne(['order.id' => $this->id]);

$jsonOrder = [];
if ($order) {
@@ -609,7 +599,7 @@ class Order extends ActiveRecordCommon

public function setTillerSynchronization()
{
$order = Order::searchOne(['id' => $this->id]);
$order = OrderModel::searchOne(['id' => $this->id]);

$paymentStatus = $order->getPaymentStatus();

@@ -652,7 +642,7 @@ class Order extends ActiveRecordCommon
public function getCartSummary($htmlFormat = true)
{
if (!isset($this->productOrder)) {
$this->productOrder = productOrder::find()->where(['id_order' => $this->id])->all();
$this->productOrder = ProductOrderModel::find()->where(['id_order' => $this->id])->all();
}

$html = '';
@@ -660,7 +650,7 @@ class Order extends ActiveRecordCommon
$i = 0;
foreach ($this->productOrder as $p) {
if (isset($p->product)) {
$html .= Html::encode($p->product->name) . ' (' . $p->quantity . '&nbsp;' . Product::strUnit(
$html .= Html::encode($p->product->name) . ' (' . $p->quantity . '&nbsp;' . ProductModel::strUnit(
$p->unit,
'wording_short',
true
@@ -722,15 +712,15 @@ class Order extends ActiveRecordCommon
if ($creditActive) {
$html .= '<br />';
if ($this->paid_amount) {
if ($this->getPaymentStatus() == Order::PAYMENT_PAID) {
if ($this->getPaymentStatus() == OrderModel::PAYMENT_PAID) {
$html .= '<span class="label label-success">Payée</span>';
} elseif ($this->getPaymentStatus() == Order::PAYMENT_UNPAID) {
} elseif ($this->getPaymentStatus() == OrderModel::PAYMENT_UNPAID) {
$html .= '<span class="label label-danger">Non payée</span><br />
Reste <strong>' . $this->getAmount(
Order::AMOUNT_REMAINING,
OrderModel::AMOUNT_REMAINING,
true
) . '</strong> à payer';
} elseif ($this->getPaymentStatus() == Order::PAYMENT_SURPLUS) {
} elseif ($this->getPaymentStatus() == OrderModel::PAYMENT_SURPLUS) {
$html .= '<span class="label label-success">Payée</span>';
}
} else {
@@ -947,7 +937,7 @@ class Order extends ActiveRecordCommon
$quantity += $po->quantity;
} else {
if (isset($po->product) && $po->product->weight > 0) {
$quantity += ($po->quantity * Product::$unitsArray[$po->unit]['coefficient']) / $po->product->weight;
$quantity += ($po->quantity * ProductModel::$unitsArray[$po->unit]['coefficient']) / $po->product->weight;
}
}
}
@@ -979,7 +969,7 @@ class Order extends ActiveRecordCommon
if (is_array($orders)) {
if (count($orders)) {
foreach ($orders as $order) {
if (is_a($order, 'common\models\Order')) {
if (is_a($order, 'common\logic\Order\Order\OrderModel')) {
$order->init();
}
}
@@ -987,7 +977,7 @@ class Order extends ActiveRecordCommon
}
} else {
$order = $orders;
if (is_a($order, 'common\models\Order')) {
if (is_a($order, 'common\logic\Order\Order\OrderModel')) {
return $order->init();
} // count
else {
@@ -1059,7 +1049,7 @@ class Order extends ActiveRecordCommon
$producer = ProducerModel::findOne($idProducer);

if (!$this->reference && $producer->option_order_reference_type == ProducerModel::ORDER_REFERENCE_TYPE_YEARLY) {
$lastOrder = Order::find()->innerJoinWith('distribution', true)
$lastOrder = OrderModel::find()->innerJoinWith('distribution', true)
->where(['>=', 'distribution.date', date('Y') . '-01-01'])
->andWhere([
'distribution.id_producer' => $producer->id

+ 11
- 0
common/logic/Order/Order/OrderRepository.php Visa fil

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

namespace common\logic\Order\Order;

use common\logic\BaseService;
use common\logic\RepositoryInterface;

class OrderRepository extends BaseService implements RepositoryInterface
{

}

Vissa filer visades inte eftersom för många filer har ändrats

Laddar…
Avbryt
Spara