@@ -78,11 +78,11 @@ class CommunicateAdminController extends BackendController | |||
public function actionIndex($section = 'producers') | |||
{ | |||
$producerManager = $this->getProducerManager(); | |||
$producerModule = $this->getProducerModule(); | |||
$userModule = $this->getUserModule(); | |||
if ($section == 'producers') { | |||
$producers = $producerManager->findProducersActive(); | |||
$producers = $producerModule->findProducersActive(); | |||
$usersArray = []; | |||
$users = []; | |||
foreach ($producers as $producer) { |
@@ -80,7 +80,7 @@ class CommunicateController extends BackendController | |||
public function actionIndex() | |||
{ | |||
$producer = $this->getProducerCurrent(); | |||
$pointsSaleArray = $this->getPointSaleManager()->findPointSales(); | |||
$pointsSaleArray = $this->getPointSaleModule()->findPointSales(); | |||
return $this->render('index', [ | |||
'producer' => $producer, |
@@ -69,7 +69,7 @@ class CreditController extends BackendController | |||
public function actionIndex() | |||
{ | |||
$userModule = $this->getUserModule(); | |||
$userProducerManager = $this->getUserProducerManager(); | |||
$userProducerModule = $this->getUserProducerModule(); | |||
$dataProviderUsersWithNegativeCredit = new ActiveDataProvider([ | |||
'query' => $userModule->queryUsersWithNegativeCredit(), | |||
@@ -80,7 +80,7 @@ class CreditController extends BackendController | |||
]); | |||
return $this->render('index', [ | |||
'sumUserProducerCredits' => $userProducerManager->sumUserProducerCredits(), | |||
'sumUserProducerCredits' => $userProducerModule->sumUserProducerCredits(), | |||
'dataProviderUsersWithNegativeCredit' => $dataProviderUsersWithNegativeCredit | |||
]); | |||
} |
@@ -108,10 +108,10 @@ class CronController extends BackendController | |||
*/ | |||
public function actionProcessOrders($key = '', $forceDate = '') | |||
{ | |||
$producerManager = $this->getProducerManager(); | |||
$distributionManager = $this->getDistributionManager(); | |||
$orderManager = $this->getOrderManager(); | |||
$paymentManager = $this->getPaymentManager(); | |||
$producerModule = $this->getProducerModule(); | |||
$distributionModule = $this-> getDistributionModule(); | |||
$orderModule = $this->getOrderModule(); | |||
$paymentManager = $this->getPaymentModule(); | |||
$userModule = $this->getUserModule(); | |||
if ($key == '64ac0bdab7e9f5e48c4d991ec5201d57') { | |||
@@ -134,7 +134,7 @@ class CronController extends BackendController | |||
$date = date('Y-m-d', time() + 24 * 60 * 60); | |||
} | |||
} | |||
$arrayProducers = $producerManager->findProducers(); | |||
$arrayProducers = $producerModule->findProducers(); | |||
foreach ($arrayProducers as $producer) { | |||
@@ -142,7 +142,7 @@ class CronController extends BackendController | |||
$countOrders = 0; | |||
$mailOrdersSend = false; | |||
$distribution = $distributionManager | |||
$distribution = $distributionModule | |||
->findOneDistribution($date, true); | |||
if ($distribution) { | |||
@@ -157,13 +157,13 @@ class CronController extends BackendController | |||
'conditions' => 'date_delete IS NULL' | |||
]); | |||
$configCredit = $producerManager->getConfig('credit'); | |||
$configCredit = $producerModule->getConfig('credit'); | |||
if ($arrayOrders && is_array($arrayOrders)) { | |||
foreach ($arrayOrders as $order) { | |||
$orderManager->initOrder($order); | |||
$orderModule->initOrder($order); | |||
if ($order->auto_payment && $configCredit) { | |||
if ($orderManager->isCreditAutoPayment($order) && $orderManager->getOrderAmount($order, Order::AMOUNT_REMAINING) > 0) { | |||
if ($orderModule->isCreditAutoPayment($order) && $orderModule->getOrderAmount($order, Order::AMOUNT_REMAINING) > 0) { | |||
$paymentManager->payOrder($order, MeanPayment::CREDIT, $userModule->findOneUserById(User::ID_USER_SYSTEM), false); | |||
$countOrders++; | |||
} | |||
@@ -175,7 +175,7 @@ class CronController extends BackendController | |||
* Envoi des commandes par email au producteur | |||
*/ | |||
if (!strlen($forceDate) && $producerManager->getConfig('option_notify_producer_order_summary')) { | |||
if (!strlen($forceDate) && $producerModule->getConfig('option_notify_producer_order_summary')) { | |||
$arrayOrders = Order::searchAll([ | |||
'distribution.date' => $date, | |||
'distribution.id_producer' => $producer->id |
@@ -76,11 +76,11 @@ class DashboardController extends BackendController | |||
{ | |||
return $this->render('index', [ | |||
'producer' => $this->getProducerCurrent(), | |||
'productsCount' => $this->getProductContainer()->getRepository()->countProducts(), | |||
'pointsSaleCount' => $this->getPointSaleContainer()->getRepository()->countPointSales(), | |||
'distributionsArray' => $this->getDistributionContainer()->getRepository()->findDistributionsDashboard(), | |||
'ordersArray' => $this->getOrderContainer()->getRepository()->findOrdersDashboard(), | |||
'subscriptionsLatestAddedArray' => $this->getSubscriptionContainer()->getRepository()->findSubscriptionsLatestAdded() | |||
'productsCount' => $this->getProductModule()->getRepository()->countProducts(), | |||
'pointsSaleCount' => $this->getPointSaleModule()->getRepository()->countPointSales(), | |||
'distributionsArray' => $this->getDistributionModule()->getRepository()->findDistributionsDashboard(), | |||
'ordersArray' => $this->getOrderModule()->getRepository()->findOrdersDashboard(), | |||
'subscriptionsLatestAddedArray' => $this->getSubscriptionModule()->getRepository()->findSubscriptionsLatestAdded() | |||
]); | |||
} | |||
} |
@@ -74,7 +74,7 @@ class DevelopmentController extends BackendController | |||
*/ | |||
public function actionIndex() | |||
{ | |||
$producerManager = $this->getProducerManager(); | |||
$producerModule = $this->getProducerModule(); | |||
$versionsArray = Opendistrib::getVersions(); | |||
$versionsRenderArray = []; | |||
foreach ($versionsArray as $version) { | |||
@@ -86,7 +86,7 @@ class DevelopmentController extends BackendController | |||
]; | |||
} | |||
$producerManager->updateOpendistribVersion($this->getProducerCurrent()); | |||
$producerModule->updateOpendistribVersion($this->getProducerCurrent()); | |||
return $this->render('index', [ | |||
'versionsArray' => $versionsRenderArray |
@@ -89,7 +89,7 @@ class DistributionController extends BackendController | |||
{ | |||
$this->checkProductsPointsSale(); | |||
$orderManager = $this->getOrderManager(); | |||
$orderModule = $this->getOrderModule(); | |||
$format = 'Y-m-d'; | |||
$theDate = ''; | |||
@@ -101,7 +101,7 @@ class DistributionController extends BackendController | |||
$orderUpdate = null; | |||
if ($idOrderUpdate) { | |||
$orderUpdate = $orderManager->findOneOrderById($idOrderUpdate); | |||
$orderUpdate = $orderModule->findOneOrderById($idOrderUpdate); | |||
} | |||
return $this->render('index', [ | |||
@@ -114,9 +114,9 @@ class DistributionController extends BackendController | |||
{ | |||
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; | |||
$distributionManager = $this->getDistributionManager(); | |||
$orderManager = $this->getOrderManager(); | |||
$productManager = $this->getProductManager(); | |||
$distributionModule = $this-> getDistributionModule(); | |||
$orderModule = $this->getOrderModule(); | |||
$productModule = $this->getProductModule(); | |||
$userModule = $this->getUserModule(); | |||
$producer = $this->getProducerCurrent(); | |||
@@ -130,10 +130,10 @@ class DistributionController extends BackendController | |||
$json['units'] = Product::$unitsArray; | |||
if ($dateObject && $dateObject->format($format) === $date) { | |||
$distribution = $distributionManager->createDistributionIfNotExist($date); | |||
$ordersArray = $orderManager->findOrdersByDistribution($distribution, false); | |||
$distribution = $distributionModule->createDistributionIfNotExist($date); | |||
$ordersArray = $orderModule->findOrdersByDistribution($distribution, false); | |||
$ordersArrayObject = $ordersArray; | |||
$productsArray = $productManager->findProductsByDistribution($distribution, false); | |||
$productsArray = $productModule->findProductsByDistribution($distribution, false); | |||
$json['products'] = $this->buildAjaxInfosResponseProducts($distribution, $productsArray, $ordersArray); | |||
$json['distribution'] = $this->buildAjaxInfosResponseDistribution($distribution, $ordersArrayObject, $productsArray); | |||
@@ -142,7 +142,7 @@ class DistributionController extends BackendController | |||
$json['delivery_notes'] = $this->buildAjaxInfosResponseDeliveryNotes($date); | |||
$json['order_create'] = $this->buildAjaxInfosResponseOrderCreate($distribution, $productsArray); | |||
$json['users'] = $userModule->findUsers(); | |||
$json['one_distribution_week_active'] = $distributionManager->isOneDistributionWeekActive($date); | |||
$json['one_distribution_week_active'] = $distributionModule->isOneDistributionWeekActive($date); | |||
$json['tiller_is_synchro'] = $this->buildAjaxInfosResponseTiller($producer, $date); | |||
$json['missing_subscriptions'] = $this->buildAjaxInfosResponseMissingSubscriptions($date, $distribution, $ordersArrayObject); | |||
} | |||
@@ -152,18 +152,18 @@ class DistributionController extends BackendController | |||
public function buildAjaxInfosResponsePointsSale(Distribution $distribution) | |||
{ | |||
$producerManager = $this->getProducerManager(); | |||
$pointSaleManager = $this->getPointSaleManager(); | |||
$pointSaleDistributionManager = $this->getPointSaleDistributionManager(); | |||
$producerModule = $this->getProducerModule(); | |||
$pointSaleModule = $this->getPointSaleModule(); | |||
$pointSaleDistributionModule = $this->getPointSaleDistributionModule(); | |||
$pointsSaleArray = $pointSaleManager->findPointSalesByDistributionAsArray($distribution); | |||
$pointsSaleArray = $pointSaleModule->findPointSalesByDistributionAsArray($distribution); | |||
// @TODO : à gérer autrement | |||
foreach($pointsSaleArray as &$pointSaleArray) { | |||
$idPointSale = $pointSaleArray['id']; | |||
$pointSale = $pointSaleManager->findOnePointSaleById($idPointSale); | |||
$pointSale = $pointSaleModule->findOnePointSaleById($idPointSale); | |||
if(!isset($pointSaleArray['pointSaleDistribution']) || !$pointSaleArray['pointSaleDistribution'] || !count($pointSaleArray['pointSaleDistribution'])) { | |||
$pointSaleDistribution = $pointSaleDistributionManager->createPointSaleDistributionIfNotExist($distribution, $pointSale); | |||
$pointSaleDistribution = $pointSaleDistributionModule->createPointSaleDistributionIfNotExist($distribution, $pointSale); | |||
$pointSaleArray['pointSaleDistribution'] = [ | |||
[ | |||
'id_distribution' => $pointSaleDistribution->id_distribution, | |||
@@ -173,7 +173,7 @@ class DistributionController extends BackendController | |||
]; | |||
} | |||
$pointSaleArray['credit_functioning'] = $producerManager->getPointSaleCreditFunctioning($pointSale); | |||
$pointSaleArray['credit_functioning'] = $producerModule->getPointSaleCreditFunctioning($pointSale); | |||
} | |||
return $pointsSaleArray; | |||
@@ -181,17 +181,17 @@ class DistributionController extends BackendController | |||
public function buildAjaxInfosResponseProducts(Distribution $distribution, array $productsArray, array $ordersArray) | |||
{ | |||
$distributionManager = $this->getDistributionManager(); | |||
$orderManager = $this->getOrderManager(); | |||
$distributionModule = $this-> getDistributionModule(); | |||
$orderModule = $this->getOrderModule(); | |||
$jsonProductsArray = []; | |||
foreach ($productsArray as $product) { | |||
$jsonProduct = $product->getAttributes(); | |||
$quantityOrder = $orderManager->getProductQuantity($product, $ordersArray); | |||
$quantityOrder = $orderModule->getProductQuantity($product, $ordersArray); | |||
$jsonProduct['quantity_ordered'] = $quantityOrder; | |||
if (!isset($product->productDistribution[0])) { | |||
$productDistributionAdd = $distributionManager->addProduct($distribution, $product); | |||
$productDistributionAdd = $distributionModule->addProduct($distribution, $product); | |||
if($productDistributionAdd) { | |||
$jsonProduct['productDistribution'][0] = $productDistributionAdd->getAttributes(); | |||
$product->populateRelation('productDistribution', [$productDistributionAdd]); | |||
@@ -267,9 +267,9 @@ class DistributionController extends BackendController | |||
public function buildAjaxInfosResponseDistribution(Distribution $distribution, array $ordersArray, array $productsArray) | |||
{ | |||
$productManager = $this->getProductManager(); | |||
$orderManager = $this->getOrderManager(); | |||
$distributionManager = $this->getDistributionManager(); | |||
$productModule = $this->getProductModule(); | |||
$orderModule = $this->getOrderModule(); | |||
$distributionModule = $this-> getDistributionModule(); | |||
$distributionJsonData = [ | |||
'id' => $distribution->id, | |||
@@ -283,7 +283,7 @@ class DistributionController extends BackendController | |||
'url_export_shopping_cart_labels' => $this->getUrlManagerBackend()->createUrl( | |||
['distribution/export-shopping-cart-labels', 'date' => $distribution->date] | |||
), | |||
'url_order' => $distributionManager->getLinkOrder($distribution), | |||
'url_order' => $distributionModule->getLinkOrder($distribution), | |||
]; | |||
// montant et poids des commandes | |||
@@ -291,17 +291,17 @@ class DistributionController extends BackendController | |||
$weight = 0; | |||
if ($ordersArray) { | |||
foreach ($ordersArray as $order) { | |||
$orderManager->initOrder($order); | |||
$orderModule->initOrder($order); | |||
if (is_null($order->date_delete)) { | |||
$revenues += $orderManager->getOrderAmountWithTax($order); | |||
$revenues += $orderModule->getOrderAmountWithTax($order); | |||
$weight += $order->weight; | |||
} | |||
} | |||
} | |||
$distributionJsonData['revenues'] = Price::format($revenues); | |||
$distributionJsonData['weight'] = number_format($weight, 2); | |||
$distributionJsonData['potential_revenues'] = Price::format($productManager->getProductDistributionPotentialRevenues($productsArray)); | |||
$distributionJsonData['potential_weight'] = number_format($productManager->getProductDistributionPotentialWeight($productsArray), 2); | |||
$distributionJsonData['potential_revenues'] = Price::format($productModule->getProductDistributionPotentialRevenues($productsArray)); | |||
$distributionJsonData['potential_weight'] = number_format($productModule->getProductDistributionPotentialWeight($productsArray), 2); | |||
return $distributionJsonData; | |||
} | |||
@@ -309,13 +309,13 @@ class DistributionController extends BackendController | |||
public function buildAjaxInfosResponseOrders(array $ordersArray, array $productsArray) | |||
{ | |||
$userModule = $this->getUserModule(); | |||
$orderManager = $this->getOrderManager(); | |||
$paymentManager = $this->getPaymentManager(); | |||
$orderModule = $this->getOrderModule(); | |||
$paymentManager = $this->getPaymentModule(); | |||
if ($ordersArray) { | |||
foreach ($ordersArray as &$order) { | |||
$orderManager->initOrder($order); | |||
$orderModule->initOrder($order); | |||
$productOrderArray = []; | |||
foreach ($order->productOrder as $productOrder) { | |||
@@ -373,10 +373,10 @@ class DistributionController extends BackendController | |||
$order = array_merge($order->getAttributes(), [ | |||
'selected' => false, | |||
'weight' => $order->weight, | |||
'amount' => (float) Price::numberTwoDecimals($orderManager->getOrderAmountWithTax($order, Order::AMOUNT_TOTAL)), | |||
'amount_paid' => (float) Price::numberTwoDecimals($orderManager->getOrderAmount($order, Order::AMOUNT_PAID)), | |||
'amount_remaining' => Price::numberTwoDecimals($orderManager->getOrderAmount($order, Order::AMOUNT_REMAINING)), | |||
'amount_surplus' => Price::numberTwoDecimals($orderManager->getOrderAmount($order, Order::AMOUNT_SURPLUS)), | |||
'amount' => (float) Price::numberTwoDecimals($orderModule->getOrderAmountWithTax($order, Order::AMOUNT_TOTAL)), | |||
'amount_paid' => (float) Price::numberTwoDecimals($orderModule->getOrderAmount($order, Order::AMOUNT_PAID)), | |||
'amount_remaining' => Price::numberTwoDecimals($orderModule->getOrderAmount($order, Order::AMOUNT_REMAINING)), | |||
'amount_surplus' => Price::numberTwoDecimals($orderModule->getOrderAmount($order, Order::AMOUNT_SURPLUS)), | |||
'user' => (isset($order->user)) ? array_merge( | |||
$order->user->getAttributes(), | |||
$arrayCreditUser | |||
@@ -385,15 +385,15 @@ class DistributionController extends BackendController | |||
'productOrder' => $productOrderArray, | |||
'paymentsArray' => $paymentArray, | |||
'oneProductUnactivated' => $oneProductUnactivated, | |||
'isLinkedToValidDocument' => $orderManager->isLinkedToValidDocument($order), | |||
'isLinkedToValidInvoice' => $orderManager->isLinkedToValidInvoice($order), | |||
'isCreditAutoPayment' => $orderManager->isCreditAutoPayment($order), | |||
'isCreditContext' => $orderManager->isCreditContext($order), | |||
'isPaid' => $orderManager->isOrderPaid($order), | |||
'isPaidViaInvoice' => $orderManager->isOrderPaidViaInvoice($order), | |||
'paymentLabelShort' => $orderManager->getPaymentLabelShort($order), | |||
'isCreditFunctioningMandatory' => $orderManager->isOrderCreditFunctioningMandatory($order), | |||
'isCreditFunctioningUser' => $orderManager->isOrderCreditFunctioningUser($order), | |||
'isLinkedToValidDocument' => $orderModule->isLinkedToValidDocument($order), | |||
'isLinkedToValidInvoice' => $orderModule->isLinkedToValidInvoice($order), | |||
'isCreditAutoPayment' => $orderModule->isCreditAutoPayment($order), | |||
'isCreditContext' => $orderModule->isCreditContext($order), | |||
'isPaid' => $orderModule->isOrderPaid($order), | |||
'isPaidViaInvoice' => $orderModule->isOrderPaidViaInvoice($order), | |||
'paymentLabelShort' => $orderModule->getPaymentLabelShort($order), | |||
'isCreditFunctioningMandatory' => $orderModule->isOrderCreditFunctioningMandatory($order), | |||
'isCreditFunctioningUser' => $orderModule->isOrderCreditFunctioningUser($order), | |||
'debitCredit' => false, | |||
]); | |||
} | |||
@@ -421,8 +421,8 @@ class DistributionController extends BackendController | |||
public function buildAjaxInfosResponseOrderCreate(Distribution $distribution, array $productsArray) | |||
{ | |||
$pointSaleManager = $this->getPointSaleManager(); | |||
$pointSaleDefault = $pointSaleManager->findOnePointSaleDefaultByDistribution($distribution); | |||
$pointSaleModule = $this->getPointSaleModule(); | |||
$pointSaleDefault = $pointSaleModule->findOnePointSaleDefaultByDistribution($distribution); | |||
$productOrderArray = []; | |||
foreach ($productsArray as $product) { | |||
@@ -454,17 +454,17 @@ class DistributionController extends BackendController | |||
public function buildAjaxInfosResponseMissingSubscriptions(string $date, Distribution $distribution, array $ordersArray) | |||
{ | |||
$subscriptionManager = $this->getSubscriptionManager(); | |||
$subscriptionModule = $this->getSubscriptionModule(); | |||
$missingSubscriptionsArray = []; | |||
$arraySubscriptions = $subscriptionManager->findSubscriptionsByDate($date); | |||
$arraySubscriptions = $subscriptionModule->findSubscriptionsByDate($date); | |||
if ($distribution->active) { | |||
foreach ($arraySubscriptions as $subscription) { | |||
if (!$subscriptionManager->hasOrderAlreadyExist($subscription, $ordersArray) | |||
if (!$subscriptionModule->hasOrderAlreadyExist($subscription, $ordersArray) | |||
&& $subscription->productSubscription && count($subscription->productSubscription) | |||
&& $subscription->id_point_sale && $subscription->id_point_sale > 0) { | |||
$missingSubscriptionsArray[] = [ | |||
'username' => $subscriptionManager->getUsername($subscription) | |||
'username' => $subscriptionModule->getUsername($subscription) | |||
]; | |||
} | |||
} | |||
@@ -477,13 +477,13 @@ class DistributionController extends BackendController | |||
{ | |||
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; | |||
$userModule = $this->getUserModule(); | |||
$orderManager = $this->getOrderManager(); | |||
$orderModule = $this->getOrderModule(); | |||
$user = $userModule->findOneUserById($idUser); | |||
$idFavoritePointSale = 0; | |||
if($user) { | |||
$favoritePointSale = $orderManager->getUserFavoritePointSale($user); | |||
$favoritePointSale = $orderModule->getUserFavoritePointSale($user); | |||
if ($favoritePointSale) { | |||
$idFavoritePointSale = $favoritePointSale->id; | |||
} | |||
@@ -503,16 +503,16 @@ class DistributionController extends BackendController | |||
{ | |||
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; | |||
$distributionManager = $this->getDistributionManager(); | |||
$orderManager = $this->getOrderManager(); | |||
$distributionModule = $this-> getDistributionModule(); | |||
$orderModule = $this->getOrderModule(); | |||
$userModule = $this->getUserModule(); | |||
$pointSaleManager = $this->getPointSaleManager(); | |||
$productManager = $this->getProductManager(); | |||
$pointSaleModule = $this->getPointSaleModule(); | |||
$productModule = $this->getProductModule(); | |||
$order = $orderManager->findOneOrderById($idOrder); | |||
$distribution = $distributionManager->findOneDistributionById($idDistribution); | |||
$order = $orderModule->findOneOrderById($idOrder); | |||
$distribution = $distributionModule->findOneDistributionById($idDistribution); | |||
$user = $userModule->findOneUserById($idUser); | |||
$pointSale = $pointSaleManager->findOnePointSaleById($idPointSale); | |||
$pointSale = $pointSaleModule->findOnePointSaleById($idPointSale); | |||
$productsArray = Product::find() | |||
->where([ | |||
@@ -526,7 +526,7 @@ class DistributionController extends BackendController | |||
$productOrderArray = []; | |||
foreach ($productsArray as $product) { | |||
$priceArray = $productManager->getPriceArray($product, $user, $pointSale); | |||
$priceArray = $productModule->getPriceArray($product, $user, $pointSale); | |||
$quantity = 0; | |||
$invoicePrice = null; | |||
@@ -549,7 +549,7 @@ class DistributionController extends BackendController | |||
'unit' => $product->unit, | |||
'prices' => $priceArray, | |||
'active' => $product->productDistribution[0]->active | |||
&& (!$pointSale || $productManager->isAvailableOnPointSale($product, $pointSale)), | |||
&& (!$pointSale || $productModule->isAvailableOnPointSale($product, $pointSale)), | |||
'invoice_price' => $invoicePrice | |||
]; | |||
} | |||
@@ -559,20 +559,20 @@ class DistributionController extends BackendController | |||
public function actionAjaxUpdateInvoicePrices($idOrder) | |||
{ | |||
$orderManager = $this->getOrderManager(); | |||
$userProducerManager = $this->getUserProducerManager(); | |||
$productManager = $this->getProductManager(); | |||
$orderModule = $this->getOrderModule(); | |||
$userProducerModule = $this->getUserProducerModule(); | |||
$productModule = $this->getProductModule(); | |||
$order = $orderManager->findOneOrderById($idOrder); | |||
$order = $orderModule->findOneOrderById($idOrder); | |||
if ($order && $order->distribution->id_producer == GlobalParam::getCurrentProducerId()) { | |||
$userProducer = null; | |||
if ($order->id_user) { | |||
$userProducer = $userProducerManager->findOneUserProducer($order->user); | |||
$userProducer = $userProducerModule->findOneUserProducer($order->user); | |||
} | |||
foreach ($order->productOrder as $productOrder) { | |||
$invoicePrice = $productManager->getPrice($productOrder->product, [ | |||
'user' => $orderManager->getUserForInvoicing($order), | |||
$invoicePrice = $productModule->getPrice($productOrder->product, [ | |||
'user' => $orderModule->getUserForInvoicing($order), | |||
'point_sale' => $order->pointSale, | |||
'user_producer' => $userProducer, | |||
'quantity' => $productOrder->quantity | |||
@@ -615,18 +615,18 @@ class DistributionController extends BackendController | |||
$idProducer = $this->getProducerCurrent()->id; | |||
} | |||
$distributionManager = $this->getDistributionManager(); | |||
$producerManager = $this->getProducerManager(); | |||
$producerCurrent = $producerManager->findOneProducerById($idProducer); | |||
$distributionModule = $this-> getDistributionModule(); | |||
$producerModule = $this->getProducerModule(); | |||
$producerCurrent = $producerModule->findOneProducerById($idProducer); | |||
$this->getLogic()->setProducerContext($producerCurrent); | |||
$distribution = $distributionManager->findOneDistribution($date); | |||
$distribution = $distributionModule->findOneDistribution($date); | |||
if ($distribution) { | |||
if ($type == 'pdf') { | |||
return $distributionManager->generateDistributionReportPdf($distribution, $save); | |||
return $distributionModule->generateDistributionReportPdf($distribution, $save); | |||
} | |||
elseif ($type == 'csv') { | |||
$distributionManager->generateDistributionReportCsv($distribution); | |||
$distributionModule->generateDistributionReportCsv($distribution); | |||
} | |||
} | |||
} | |||
@@ -637,41 +637,41 @@ class DistributionController extends BackendController | |||
$idProducer = $this->getProducerCurrent()->id; | |||
} | |||
$distributionManager = $this->getDistributionManager(); | |||
$producerManager = $this->getProducerManager(); | |||
$producerCurrent = $producerManager->findOneProducerById($idProducer); | |||
$distributionModule = $this-> getDistributionModule(); | |||
$producerModule = $this->getProducerModule(); | |||
$producerCurrent = $producerModule->findOneProducerById($idProducer); | |||
$this->getLogic()->setProducerContext($producerCurrent); | |||
$distribution = $distributionManager->findOneDistribution($date); | |||
$distribution = $distributionModule->findOneDistribution($date); | |||
if ($distribution) { | |||
return $distributionManager->generateDistributionReportGridPdf($distribution, $save); | |||
return $distributionModule->generateDistributionReportGridPdf($distribution, $save); | |||
} | |||
} | |||
public function actionExportShoppingCartLabels(string $date) | |||
{ | |||
$distributionManager = $this->getDistributionManager(); | |||
$distribution = $distributionManager->findOneDistribution($date); | |||
$distributionModule = $this-> getDistributionModule(); | |||
$distribution = $distributionModule->findOneDistribution($date); | |||
if($distribution) { | |||
return $distributionManager->generateDistributionShoppingCartLabelsPdf($distribution); | |||
return $distributionModule->generateDistributionShoppingCartLabelsPdf($distribution); | |||
} | |||
} | |||
public function actionAjaxProcessProductQuantityMax($idDistribution, $idProduct, $quantityMax) | |||
{ | |||
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; | |||
$productDistributionManager = $this->getProductDistributionManager(); | |||
$productDistributionModule = $this->getProductDistributionManager(); | |||
$productDistribution = $this->getProductDistribution($idProduct, $idDistribution); | |||
$productDistributionManager->updateProductDistributionQuantityMax($productDistribution, (float) $quantityMax); | |||
$productDistributionModule->updateProductDistributionQuantityMax($productDistribution, (float) $quantityMax); | |||
return ['success']; | |||
} | |||
public function actionAjaxProcessActiveProduct(int $idDistribution, int $idProduct, int $active) | |||
{ | |||
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; | |||
$productDistributionManager = $this->getProductDistributionManager(); | |||
$productDistributionModule = $this->getProductDistributionManager(); | |||
$productDistribution = $this->getProductDistribution($idProduct, $idDistribution); | |||
$productDistributionManager->updateProductDistributionActive($productDistribution, $active); | |||
$productDistributionModule->updateProductDistributionActive($productDistribution, $active); | |||
return ['success']; | |||
} | |||
@@ -679,29 +679,29 @@ class DistributionController extends BackendController | |||
{ | |||
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; | |||
$distributionManager = $this->getDistributionManager(); | |||
$pointSaleManager = $this->getPointSaleManager(); | |||
$pointSaleDistributionManager = $this->getPointSaleDistributionManager(); | |||
$distributionModule = $this-> getDistributionModule(); | |||
$pointSaleModule = $this->getPointSaleModule(); | |||
$pointSaleDistributionModule = $this->getPointSaleDistributionModule(); | |||
$pointSaleDistribution = $pointSaleDistributionManager->findOnePointSaleDistribution( | |||
$distributionManager->findOneDistributionById($idDistribution), | |||
$pointSaleManager->findOnePointSaleById($idPointSale) | |||
$pointSaleDistribution = $pointSaleDistributionModule->findOnePointSaleDistribution( | |||
$distributionModule->findOneDistributionById($idDistribution), | |||
$pointSaleModule->findOnePointSaleById($idPointSale) | |||
); | |||
$pointSaleDistribution->delivery = $delivery; | |||
$pointSaleDistributionManager->update($pointSaleDistribution); | |||
$pointSaleDistributionModule->update($pointSaleDistribution); | |||
return ['success']; | |||
} | |||
public function getProductDistribution(int $idProduct, int $idDistribution) | |||
{ | |||
$distributionManager = $this->getDistributionManager(); | |||
$productManager = $this->getProductManager(); | |||
$productDistributionManager = $this->getProductDistributionManager(); | |||
$distributionModule = $this-> getDistributionModule(); | |||
$productModule = $this->getProductModule(); | |||
$productDistributionModule = $this->getProductDistributionManager(); | |||
return $productDistributionManager->findOneProductDistribution( | |||
$distributionManager->findOneDistributionById($idDistribution), | |||
$productManager->findOneProductById($idProduct) | |||
return $productDistributionModule->findOneProductDistribution( | |||
$distributionModule->findOneDistributionById($idDistribution), | |||
$productModule->findOneProductById($idProduct) | |||
); | |||
} | |||
@@ -716,20 +716,20 @@ class DistributionController extends BackendController | |||
public function actionAjaxProcessActiveDistribution(int $idDistribution = 0, string $date = '', bool $active = false) | |||
{ | |||
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; | |||
$distributionManager = $this->getDistributionManager(); | |||
$distributionModule = $this-> getDistributionModule(); | |||
if ($idDistribution) { | |||
$distribution = $distributionManager->findOneDistributionById($idDistribution); | |||
$distribution = $distributionModule->findOneDistributionById($idDistribution); | |||
} | |||
$format = 'Y-m-d'; | |||
$dateObject = DateTime::createFromFormat($format, $date); | |||
if ($dateObject && $dateObject->format($format) === $date) { | |||
$distribution = $distributionManager->createDistributionIfNotExist($date); | |||
$distribution = $distributionModule->createDistributionIfNotExist($date); | |||
} | |||
if (isset($distribution) && $distribution) { | |||
$distributionManager->activeDistribution($distribution, $active); | |||
$distributionModule->activeDistribution($distribution, $active); | |||
return ['success']; | |||
} | |||
@@ -822,7 +822,7 @@ class DistributionController extends BackendController | |||
*/ | |||
public function actionAjaxProcessAddSubscriptions($date) | |||
{ | |||
$ordersArray = $this->getOrderManager()->createAllOrdersFromSubscriptions($date, true); | |||
$ordersArray = $this->getOrderModule()->createAllOrdersFromSubscriptions($date, true); | |||
if($ordersArray && count($ordersArray)) { | |||
return Ajax::responseSuccess('Les abonnements ont bien été importés.'); | |||
@@ -840,12 +840,12 @@ class DistributionController extends BackendController | |||
{ | |||
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; | |||
$producerManager = $this->getProducerManager(); | |||
$productOrderManager = $this->getProductOrderManager(); | |||
$orderManager = $this->getOrderManager(); | |||
$producerModule = $this->getProducerModule(); | |||
$productOrderModule = $this->getProductOrderModule(); | |||
$orderModule = $this->getOrderModule(); | |||
$return = []; | |||
$producerTiller = $producerManager->getConfig('tiller'); | |||
$producerTiller = $producerModule->getConfig('tiller'); | |||
if ($producerTiller) { | |||
$tiller = new Tiller(); | |||
@@ -863,12 +863,12 @@ class DistributionController extends BackendController | |||
if ($orders && count($orders)) { | |||
foreach ($orders as $order) { | |||
$orderManager->initOrder($order); | |||
$orderModule->initOrder($order); | |||
$lines = []; | |||
foreach ($order->productOrder as $productOrder) { | |||
$lines[] = [ | |||
'name' => $productOrder->product->name, | |||
'price' => $productOrderManager->getPriceWithTax($productOrder) * 100 * $productOrder->quantity, | |||
'price' => $productOrderModule->getPriceWithTax($productOrder) * 100 * $productOrder->quantity, | |||
'tax' => $productOrder->taxRate->value * 100, | |||
'date' => $strDate, | |||
'quantity' => $productOrder->quantity | |||
@@ -903,7 +903,7 @@ class DistributionController extends BackendController | |||
'payments' => [ | |||
[ | |||
'type' => $typePaymentTiller, | |||
'amount' => $orderManager->getOrderAmountWithTax( | |||
'amount' => $orderModule->getOrderAmountWithTax( | |||
$order, | |||
Order::AMOUNT_PAID | |||
) * 100, | |||
@@ -935,20 +935,20 @@ class DistributionController extends BackendController | |||
public function actionAjaxGenerateDeliveryNotePointSale($idOrders) | |||
{ | |||
$orderManager = $this->getOrderManager(); | |||
$deliveryNoteManager = $this->getDeliveryNoteManager(); | |||
$orderModule = $this->getOrderModule(); | |||
$deliveryNoteModule = $this->getDeliveryNoteModule(); | |||
if (strlen($idOrders)) { | |||
$idOrders = json_decode($idOrders, true); | |||
if (is_array($idOrders) && count($idOrders) > 0) { | |||
reset($idOrders); | |||
$firstOrder = $orderManager->findOneOrderById((int)$idOrders[key($idOrders)]); | |||
$firstOrder = $orderModule->findOneOrderById((int)$idOrders[key($idOrders)]); | |||
$ordersArray = Order::searchAll(['id' => $idOrders,]); | |||
$deliveryNote = $deliveryNoteManager->getOneDeliveryNoteExistingFromOrders($ordersArray); | |||
$deliveryNote = $deliveryNoteModule->getOneDeliveryNoteExistingFromOrders($ordersArray); | |||
$isUpdate = (bool) $deliveryNote; | |||
if ($deliveryNote && $deliveryNoteManager->isStatusValid($deliveryNote)) { | |||
if ($deliveryNote && $deliveryNoteModule->isStatusValid($deliveryNote)) { | |||
return Ajax::responseError('Vous ne pouvez pas modifier un bon de livraison déjà validé.'); | |||
} | |||
@@ -958,7 +958,7 @@ class DistributionController extends BackendController | |||
if ($firstOrder) { | |||
if (!$deliveryNote) { | |||
$deliveryNoteManager->createDeliveryNoteForPointSale( | |||
$deliveryNoteModule->createDeliveryNoteForPointSale( | |||
$firstOrder->pointSale, | |||
$firstOrder->distribution, | |||
$idOrders | |||
@@ -992,29 +992,29 @@ class DistributionController extends BackendController | |||
public function generateDeliveryNote(int $idOrder) | |||
{ | |||
$orderManager = $this->getOrderManager(); | |||
$deliveryNoteManager = $this->getDeliveryNoteManager(); | |||
$orderModule = $this->getOrderModule(); | |||
$deliveryNoteModule = $this->getDeliveryNoteModule(); | |||
$order = $orderManager->findOneOrderById($idOrder); | |||
if ($orderManager->isOrderFromProducer($order) && $order->id_user) { | |||
$deliveryNoteManager->createDeliveryNoteForOrder($order); | |||
$order = $orderModule->findOneOrderById($idOrder); | |||
if ($orderModule->isOrderFromProducer($order) && $order->id_user) { | |||
$deliveryNoteModule->createDeliveryNoteForOrder($order); | |||
} | |||
} | |||
public function actionAjaxValidateDeliveryNotes($idOrders) | |||
{ | |||
$orderManager = $this->getOrderManager(); | |||
$deliveryNoteManager = $this->getDeliveryNoteManager(); | |||
$orderModule = $this->getOrderModule(); | |||
$deliveryNoteModule = $this->getDeliveryNoteModule(); | |||
if (strlen($idOrders)) { | |||
$idOrders = json_decode($idOrders, true); | |||
if (is_array($idOrders) && count($idOrders) > 0) { | |||
foreach ($idOrders as $idOrder) { | |||
$order = $orderManager->findOneOrderById($idOrder); | |||
if ($orderManager->isOrderFromProducer($order)) { | |||
$deliveryNote = $deliveryNoteManager->findOneDeliveryNoteById((int) $order->id_delivery_note); | |||
$order = $orderModule->findOneOrderById($idOrder); | |||
if ($orderModule->isOrderFromProducer($order)) { | |||
$deliveryNote = $deliveryNoteModule->findOneDeliveryNoteById((int) $order->id_delivery_note); | |||
if($deliveryNote) { | |||
$deliveryNoteManager->validateDocument($deliveryNote); | |||
$deliveryNoteModule->validateDocument($deliveryNote); | |||
} | |||
} | |||
} |
@@ -100,13 +100,13 @@ class DocumentController extends BackendController | |||
public function actionCreate() | |||
{ | |||
$documentManager = $this->getDocumentManager(); | |||
$documentModule = $this->getDocumentModule(); | |||
$class = $this->getClass(); | |||
$class = 'common\\logic\\Document\\'.$class.'\\Model\\'.$class; | |||
$model = new $class(); | |||
$documentManager->initTaxCalculationMethod($model); | |||
$documentModule->initTaxCalculationMethod($model); | |||
if ($model->load(\Yii::$app->request->post())) { | |||
$model->id_producer = GlobalParam::getCurrentProducerId(); | |||
@@ -131,14 +131,14 @@ class DocumentController extends BackendController | |||
public function processInvoiceViaDeliveryNotes($model) | |||
{ | |||
$orderManager = $this->getOrderManager(); | |||
$documentManager = $this->getDocumentManager(); | |||
$deliveryNoteManager = $this->getDeliveryNoteManager(); | |||
if ($documentManager->getClass($model) == 'Invoice') { | |||
$orderModule = $this->getOrderModule(); | |||
$documentModule = $this->getDocumentModule(); | |||
$deliveryNoteModule = $this->getDeliveryNoteModule(); | |||
if ($documentModule->getClass($model) == 'Invoice') { | |||
if ($model->deliveryNotes && is_array($model->deliveryNotes) && count($model->deliveryNotes)) { | |||
foreach ($model->deliveryNotes as $key => $idDeliveryNote) { | |||
$deliveryNote = $deliveryNoteManager->findOneDeliveryNoteById($idDeliveryNote); | |||
$orderManager->assignAllOrdersInvoiceByDeliveryNote($model, $deliveryNote); | |||
$deliveryNote = $deliveryNoteModule->findOneDeliveryNoteById($idDeliveryNote); | |||
$orderModule->assignAllOrdersInvoiceByDeliveryNote($model, $deliveryNote); | |||
} | |||
} | |||
} | |||
@@ -146,13 +146,13 @@ class DocumentController extends BackendController | |||
public function processInvoiceViaOrders($model) | |||
{ | |||
$orderManager = $this->getOrderManager(); | |||
$documentManager = $this->getDocumentManager(); | |||
if ($documentManager->getClass($model) == 'Invoice') { | |||
$orderModule = $this->getOrderModule(); | |||
$documentModule = $this->getDocumentModule(); | |||
if ($documentModule->getClass($model) == 'Invoice') { | |||
if ($model->ordersOnCreate && is_array($model->ordersOnCreate) && count($model->ordersOnCreate)) { | |||
foreach ($model->ordersOnCreate as $key => $idOrder) { | |||
$order = $orderManager->findOneOrderById($idOrder); | |||
$orderManager->updateOrderInvoice($order, $model); | |||
$order = $orderModule->findOneOrderById($idOrder); | |||
$orderModule->updateOrderInvoice($order, $model); | |||
} | |||
} | |||
} | |||
@@ -160,8 +160,8 @@ class DocumentController extends BackendController | |||
public function actionUpdate($id) | |||
{ | |||
$documentManager = $this->getDocumentManager(); | |||
$paymentManager = $this->getPaymentManager(); | |||
$documentModule = $this->getDocumentModule(); | |||
$paymentManager = $this->getPaymentModule(); | |||
$document = $this->findModel($id); | |||
if (!$document) { | |||
@@ -173,10 +173,10 @@ class DocumentController extends BackendController | |||
} | |||
$payment = null; | |||
if($documentManager->isDocumentInvoice($document) && $documentManager->isStatusValid($document)) { | |||
if($documentModule->isDocumentInvoice($document) && $documentModule->isStatusValid($document)) { | |||
$payment = $paymentManager->instanciatePayment( | |||
Payment::TYPE_PAYMENT, | |||
number_format($documentManager->getAmountWithTax($document, Order::INVOICE_AMOUNT_TOTAL), 2), | |||
number_format($documentModule->getAmountWithTax($document, Order::INVOICE_AMOUNT_TOTAL), 2), | |||
$this->getProducerCurrent(), | |||
null, | |||
null, | |||
@@ -213,14 +213,14 @@ class DocumentController extends BackendController | |||
public function actionDelete($id) | |||
{ | |||
$documentManager = $this->getDocumentManager(); | |||
$documentModule = $this->getDocumentModule(); | |||
$model = $this->findModel($id); | |||
if ($documentManager->isStatusValid($model)) { | |||
if ($documentModule->isStatusValid($model)) { | |||
throw new UserException('Vous ne pouvez pas supprimer un document validé.'); | |||
} | |||
$documentManager->delete($model); | |||
$documentModule->delete($model); | |||
if ($this->getClass() == 'DeliveryNote') { | |||
Order::updateAll([ | |||
@@ -253,8 +253,8 @@ class DocumentController extends BackendController | |||
public function actionExportCsvEvoliz(int $id) | |||
{ | |||
$documentManager = $this->getDocumentManager(); | |||
$productOrderManager = $this->getProductOrderManager(); | |||
$documentModule = $this->getDocumentModule(); | |||
$productOrderModule = $this->getProductOrderModule(); | |||
$datas = []; | |||
$document = $this->findModel($id); | |||
@@ -300,16 +300,16 @@ class DocumentController extends BackendController | |||
'Code Classification vente', | |||
]; | |||
foreach ($documentManager->getProductsOrders($document) as $productOrderArray) { | |||
foreach ($documentModule->getProductsOrders($document) as $productOrderArray) { | |||
foreach ($productOrderArray as $productOrder) { | |||
$price = $productOrder->getPrice(); | |||
if ($documentManager->isInvoicePrice($document) && $productOrder->getInvoicePrice()) { | |||
if ($documentModule->isInvoicePrice($document) && $productOrder->getInvoicePrice()) { | |||
$price = $productOrder->getInvoicePrice(); | |||
} | |||
$typeTotal = $documentManager->isInvoicePrice($document) ? Order::INVOICE_AMOUNT_TOTAL : Order::AMOUNT_TOTAL; | |||
$priceTotal = $productOrderManager->getPriceByTypeTotal($productOrder, $typeTotal) * $productOrder->quantity; | |||
$typeTotal = $documentModule->isInvoicePrice($document) ? Order::INVOICE_AMOUNT_TOTAL : Order::AMOUNT_TOTAL; | |||
$priceTotal = $productOrderModule->getPriceByTypeTotal($productOrder, $typeTotal) * $productOrder->quantity; | |||
$tva = Price::getVat( | |||
$priceTotal, | |||
$productOrder->taxRate->value, | |||
@@ -366,7 +366,7 @@ class DocumentController extends BackendController | |||
// status | |||
$status = ''; | |||
if ($documentManager->isStatusDraft($document)) { | |||
if ($documentModule->isStatusDraft($document)) { | |||
$status = 'brouillon_'; | |||
} | |||
@@ -377,17 +377,17 @@ class DocumentController extends BackendController | |||
public function actionDownload($id) | |||
{ | |||
$documentManager = $this->getDocumentManager(); | |||
$documentModule = $this->getDocumentModule(); | |||
$document = $this->findModel($id); | |||
return $documentManager->downloadPdf($document); | |||
return $documentModule->downloadPdf($document); | |||
} | |||
public function actionRegenerate($id) | |||
{ | |||
$documentManager = $this->getDocumentManager(); | |||
$documentModule = $this->getDocumentModule(); | |||
$document = $this->findModel($id); | |||
$documentManager->downloadPdf($document, true); | |||
$documentModule->downloadPdf($document, true); | |||
$this->setFlash('success', 'Le document PDF a bien été regénéré.'); | |||
return $this->redirect([$this->getControllerUrl() . '/update', 'id' => $id]); | |||
@@ -395,9 +395,9 @@ class DocumentController extends BackendController | |||
public function actionSend(int $id, $backUpdateForm = false) | |||
{ | |||
$documentManager = $this->getDocumentManager(); | |||
$documentModule = $this->getDocumentModule(); | |||
$document = $this->findModel($id); | |||
if ($documentManager->sendDocument($document)) { | |||
if ($documentModule->sendDocument($document)) { | |||
$this->setFlash('success', $this->getFlashMessage('send', $document)); | |||
} else { | |||
$this->setFlash('danger', $this->getFlashMessage('send', $document)); | |||
@@ -413,9 +413,9 @@ class DocumentController extends BackendController | |||
public function actionAjaxUserInfos($typeAction, $idUser, $classDocument, $idDocument = false) | |||
{ | |||
$userModule = $this->getUserModule(); | |||
$documentManager = $this->getDocumentManager(); | |||
$orderManager = $this->getOrderManager(); | |||
$producerManager = $this->getProducerManager(); | |||
$documentModule = $this->getDocumentModule(); | |||
$orderModule = $this->getOrderModule(); | |||
$producerModule = $this->getProducerModule(); | |||
$producerCurrent = $this->getProducerCurrent(); | |||
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; | |||
@@ -425,7 +425,7 @@ class DocumentController extends BackendController | |||
if ($user) { | |||
$document = null; | |||
if ($documentManager->isValidClass($classDocument) && $idDocument) { | |||
if ($documentModule->isValidClass($classDocument) && $idDocument) { | |||
$document = $this->findModel($idDocument, $classDocument); | |||
} | |||
@@ -462,15 +462,15 @@ class DocumentController extends BackendController | |||
$json['orders_create_array'] = []; | |||
$json['orders_update_array'] = []; | |||
if(!$producerManager->getConfig('option_invoice_only_based_on_delivery_notes')) { | |||
$json['orders_create_array'] = $this->initOrdersArray($orderManager->findOrdersByUserNotInvoiced($user)); | |||
$json['orders_update_array'] = $document ? $this->initOrdersArray($orderManager->findOrdersByUserAndInvoice($user, $document)) : []; | |||
if(!$producerModule->getConfig('option_invoice_only_based_on_delivery_notes')) { | |||
$json['orders_create_array'] = $this->initOrdersArray($orderModule->findOrdersByUserNotInvoiced($user)); | |||
$json['orders_update_array'] = $document ? $this->initOrdersArray($orderModule->findOrdersByUserAndInvoice($user, $document)) : []; | |||
} | |||
} | |||
if ($classDocument == 'DeliveryNote') { | |||
$json['orders_create_array'] = $this->initOrdersArray($orderManager->findOrdersByUserNotLinkedDeliveryNote($user)); | |||
$json['orders_update_array'] = $document ? $this->initOrdersArray($orderManager->findOrdersByUserAndDeliveryNote($user, $document)) : []; | |||
$json['orders_create_array'] = $this->initOrdersArray($orderModule->findOrdersByUserNotLinkedDeliveryNote($user)); | |||
$json['orders_update_array'] = $document ? $this->initOrdersArray($orderModule->findOrdersByUserAndDeliveryNote($user, $document)) : []; | |||
} | |||
return $json; | |||
@@ -482,16 +482,16 @@ class DocumentController extends BackendController | |||
public function initOrdersArray(array $ordersArray) | |||
{ | |||
$orderManager = $this->getOrderManager(); | |||
$orderModule = $this->getOrderModule(); | |||
$ordersReturnArray = []; | |||
foreach($ordersArray as &$order) { | |||
$orderManager->initOrder($order); | |||
$orderModule->initOrder($order); | |||
$ordersReturnArray[] = [ | |||
'id' => $order->id, | |||
'date' => $order->distribution->date, | |||
'name' => date('d/m/Y', strtotime($order->distribution->date)), | |||
'amount_with_tax' => $orderManager->getOrderAmountWithTax($order, Order::INVOICE_AMOUNT_TOTAL) | |||
'amount_with_tax' => $orderModule->getOrderAmountWithTax($order, Order::INVOICE_AMOUNT_TOTAL) | |||
]; | |||
} | |||
@@ -520,17 +520,17 @@ class DocumentController extends BackendController | |||
public function addDeliveryNoteToArray($deliveryNote, $isCreate = true) | |||
{ | |||
$deliveryNoteManager = $this->getDeliveryNoteManager(); | |||
$deliveryNoteModule = $this->getDeliveryNoteModule(); | |||
$deliveryNoteData = array_merge( | |||
$deliveryNote->getAttributes(), | |||
[ | |||
'url' => $this->getUrlManagerBackend()->createUrl(['delivery-note/update', 'id' => $deliveryNote->id]), | |||
'total' => $deliveryNoteManager->getAmountWithTax($deliveryNote, Order::INVOICE_AMOUNT_TOTAL) | |||
'total' => $deliveryNoteModule->getAmountWithTax($deliveryNote, Order::INVOICE_AMOUNT_TOTAL) | |||
] | |||
); | |||
if (($isCreate && !$deliveryNoteManager->isInvoiced($deliveryNote)) || !$isCreate) { | |||
if (($isCreate && !$deliveryNoteModule->isInvoiced($deliveryNote)) || !$isCreate) { | |||
return $deliveryNoteData; | |||
} | |||
@@ -539,17 +539,17 @@ class DocumentController extends BackendController | |||
public function actionValidate($id, $backUpdateForm = false) | |||
{ | |||
$documentManager = $this->getDocumentManager(); | |||
$documentModule = $this->getDocumentModule(); | |||
$classDocument = $this->getClass(); | |||
if ($id > 0 && $documentManager->isValidClass($classDocument)) { | |||
if ($id > 0 && $documentModule->isValidClass($classDocument)) { | |||
$document = $this->findModel($id); | |||
if ($document) { | |||
$documentManager->validateDocument($document); | |||
$documentModule->validateDocument($document); | |||
// @TODO : gérer via un événement | |||
$documentManager->generatePdf($document, Pdf::DEST_FILE); | |||
$documentModule->generatePdf($document, Pdf::DEST_FILE); | |||
$this->setFlash('success', $this->getFlashMessage('validate', $document)); | |||
@@ -570,23 +570,23 @@ class DocumentController extends BackendController | |||
{ | |||
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; | |||
$orderManager = $this->getOrderManager(); | |||
$productManager = $this->getProductManager(); | |||
$documentManager = $this->getDocumentManager(); | |||
$deliveryNoteManager = $this->getDeliveryNoteManager(); | |||
$userProducerManager = $this->getUserProducerManager(); | |||
$pointSaleManager = $this->getPointSaleManager(); | |||
$orderModule = $this->getOrderModule(); | |||
$productModule = $this->getProductModule(); | |||
$documentModule = $this->getDocumentModule(); | |||
$deliveryNoteModule = $this->getDeliveryNoteModule(); | |||
$userProducerModule = $this->getUserProducerModule(); | |||
$pointSaleModule = $this->getPointSaleModule(); | |||
if ($idDocument > 0 && $documentManager->isValidClass($classDocument)) { | |||
if ($idDocument > 0 && $documentModule->isValidClass($classDocument)) { | |||
$document = $this->findModel($idDocument, $classDocument); | |||
if ($document) { | |||
$ordersArray = []; | |||
$productsArray = $productManager->findProducts(false); | |||
$productsArray = $productModule->findProducts(false); | |||
foreach ($document->orders as $order) { | |||
$orderManager->initOrder($order); | |||
$orderModule->initOrder($order); | |||
$productsOrderArray = []; | |||
foreach ($order->productOrder as $productOrder) { | |||
@@ -597,7 +597,7 @@ class DocumentController extends BackendController | |||
$ordersArray[$order->id] = array_merge( | |||
$order->getAttributes(), | |||
[ | |||
'username' => $orderManager->getOrderUsername($order), | |||
'username' => $orderModule->getOrderUsername($order), | |||
'distribution_date' => isset($order->distribution) ? date( | |||
'd/m/Y', | |||
strtotime( | |||
@@ -610,16 +610,16 @@ class DocumentController extends BackendController | |||
); | |||
} | |||
$userProducer = $userProducerManager->findOneUserProducer($document->user); | |||
$pointSale = $pointSaleManager->findOnePointSaleByIdUser($document->user->id); | |||
$userProducer = $userProducerModule->findOneUserProducer($document->user); | |||
$pointSale = $pointSaleModule->findOnePointSaleByIdUser($document->user->id); | |||
$productsArray = yii\helpers\ArrayHelper::map( | |||
$productsArray, | |||
'order', | |||
function ($product) use ($document, $userProducer, $pointSale, $productManager) { | |||
function ($product) use ($document, $userProducer, $pointSale, $productModule) { | |||
return array_merge($product->getAttributes(), [ | |||
'unit_coefficient' => Product::$unitsArray[$product->unit]['coefficient'], | |||
'prices' => $productManager->getPriceArray($product, $userProducer->user, $pointSale), | |||
'prices' => $productModule->getPriceArray($product, $userProducer->user, $pointSale), | |||
'wording_unit' => $product->wording_unit, | |||
'tax_rate' => $product->taxRate->value | |||
]); | |||
@@ -630,21 +630,21 @@ class DocumentController extends BackendController | |||
'return' => 'success', | |||
'tax_rate_producer' => GlobalParam::getCurrentProducer()->taxRate->value, | |||
'document' => array_merge($document->getAttributes(), [ | |||
'html_label' => $documentManager->getHtmlLabel($document), | |||
'class' => $documentManager->getClass($document) | |||
'html_label' => $documentModule->getHtmlLabel($document), | |||
'class' => $documentModule->getClass($document) | |||
]), | |||
'id_user' => $document->user->id, | |||
'products' => $productsArray, | |||
'orders' => $ordersArray, | |||
'total' => ($documentManager->getClass($document) == 'Invoice' || $documentManager->getClass($document) == 'DeliveryNote') ? $documentManager->getAmount( | |||
'total' => ($documentModule->getClass($document) == 'Invoice' || $documentModule->getClass($document) == 'DeliveryNote') ? $documentModule->getAmount( | |||
$document, | |||
Order::INVOICE_AMOUNT_TOTAL | |||
) : $documentManager->getAmount($document, Order::AMOUNT_TOTAL), | |||
'total_with_tax' => ($documentManager->getClass($document) == 'Invoice' || $documentManager->getClass($document) == 'DeliveryNote') ? $documentManager->getAmountWithTax( | |||
) : $documentModule->getAmount($document, Order::AMOUNT_TOTAL), | |||
'total_with_tax' => ($documentModule->getClass($document) == 'Invoice' || $documentModule->getClass($document) == 'DeliveryNote') ? $documentModule->getAmountWithTax( | |||
$document, | |||
Order::INVOICE_AMOUNT_TOTAL | |||
) : $documentManager->getAmountWithTax($document, Order::AMOUNT_TOTAL), | |||
'invoice_url' => ($documentManager->getClass($document) == 'DeliveryNote' && $deliveryNoteManager->getInvoice($document)) ? $this->getUrlManagerBackend()->createUrl(['invoice/update', 'id' => $deliveryNoteManager->getInvoice($document)->id]) : null | |||
) : $documentModule->getAmountWithTax($document, Order::AMOUNT_TOTAL), | |||
'invoice_url' => ($documentModule->getClass($document) == 'DeliveryNote' && $deliveryNoteModule->getInvoice($document)) ? $this->getUrlManagerBackend()->createUrl(['invoice/update', 'id' => $deliveryNoteModule->getInvoice($document)->id]) : null | |||
]; | |||
} | |||
} | |||
@@ -654,13 +654,13 @@ class DocumentController extends BackendController | |||
public function actionAjaxAddProduct($idDocument, $classDocument, $idProduct, $quantity, $price) | |||
{ | |||
$documentManager = $this->getDocumentManager(); | |||
$productManager = $this->getProductManager(); | |||
$documentModule = $this->getDocumentModule(); | |||
$productModule = $this->getProductModule(); | |||
if ($documentManager->isValidClass($classDocument)) { | |||
if ($documentModule->isValidClass($classDocument)) { | |||
$document = $this->findModel($idDocument, $classDocument); | |||
$classDocumentComplete = $documentManager->getClass($document, true); | |||
$product = $productManager->findOneProductById($idProduct); | |||
$classDocumentComplete = $documentModule->getClass($document, true); | |||
$product = $productModule->findOneProductById($idProduct); | |||
if ($document && $product) { | |||
if (count($document->orders) == 0) { | |||
@@ -700,12 +700,12 @@ class DocumentController extends BackendController | |||
public function actionAjaxDeleteProductOrder($idProductOrder) | |||
{ | |||
$productOrderManager = $this->getProductOrderManager(); | |||
$productOrderModule = $this->getProductOrderModule(); | |||
$productOrder = $productOrderManager->findOneProductOrderById($idProductOrder); | |||
$productOrder = $productOrderModule->findOneProductOrderById($idProductOrder); | |||
if ($productOrder) { | |||
$productOrderManager->delete($productOrder); | |||
$productOrderModule->delete($productOrder); | |||
return Ajax::responseSuccess('Produit supprimé'); | |||
} | |||
@@ -715,14 +715,14 @@ class DocumentController extends BackendController | |||
public function actionAjaxAddOrder($idDocument, $classDocument, $idOrder) | |||
{ | |||
$documentManager = $this->getDocumentManager(); | |||
$orderManager = $this->getOrderManager(); | |||
$documentModule = $this->getDocumentModule(); | |||
$orderModule = $this->getOrderModule(); | |||
$document = $documentManager->findOneDocumentByIdAndClass($idDocument, $classDocument); | |||
$order = $orderManager->findOneOrderById($idOrder); | |||
$document = $documentModule->findOneDocumentByIdAndClass($idDocument, $classDocument); | |||
$order = $orderModule->findOneOrderById($idOrder); | |||
if ($document && $documentManager->isStatusDraft($document) && $order) { | |||
$orderManager->updateOrderDocument($order, $document); | |||
if ($document && $documentModule->isStatusDraft($document) && $order) { | |||
$orderModule->updateOrderDocument($order, $document); | |||
return Ajax::responseSuccess("Commande ajoutée à la facture."); | |||
} | |||
@@ -733,18 +733,18 @@ class DocumentController extends BackendController | |||
public function actionAjaxDeleteOrder($idDocument, $classDocument, $idOrder) | |||
{ | |||
$documentManager = $this->getDocumentManager(); | |||
$orderManager = $this->getOrderManager(); | |||
$documentModule = $this->getDocumentModule(); | |||
$orderModule = $this->getOrderModule(); | |||
$document = $documentManager->findOneDocumentByIdAndClass($idDocument, $classDocument); | |||
$order = $orderManager->findOneOrderById($idOrder); | |||
$document = $documentModule->findOneDocumentByIdAndClass($idDocument, $classDocument); | |||
$order = $orderModule->findOneOrderById($idOrder); | |||
if ($document && $documentManager->isStatusDraft($document)) { | |||
if($documentManager->isDocumentDeliveryNote($document)) { | |||
$orderManager->updateOrderDeliveryNote($order, null); | |||
if ($document && $documentModule->isStatusDraft($document)) { | |||
if($documentModule->isDocumentDeliveryNote($document)) { | |||
$orderModule->updateOrderDeliveryNote($order, null); | |||
} | |||
elseif($documentManager->isDocumentInvoice($document)) { | |||
$orderManager->updateOrderInvoice($order, null); | |||
elseif($documentModule->isDocumentInvoice($document)) { | |||
$orderModule->updateOrderInvoice($order, null); | |||
} | |||
return Ajax::responseSuccess('Commande supprimée de la facture.'); | |||
@@ -756,14 +756,14 @@ class DocumentController extends BackendController | |||
public function actionAjaxIgnoreOrderWhenInvoicing($idDocument, $classDocument, $idOrder) | |||
{ | |||
$documentManager = $this->getDocumentManager(); | |||
$orderManager = $this->getOrderManager(); | |||
$documentModule = $this->getDocumentModule(); | |||
$orderModule = $this->getOrderModule(); | |||
$document = $documentManager->findOneDocumentByIdAndClass($idDocument, $classDocument); | |||
$order = $orderManager->findOneOrderById($idOrder); | |||
$document = $documentModule->findOneDocumentByIdAndClass($idDocument, $classDocument); | |||
$order = $orderModule->findOneOrderById($idOrder); | |||
if ($document && $documentManager->isStatusDraft($document) && $order) { | |||
$orderManager->updateOrderIgnoreWhenInvoicing($order, true); | |||
if ($document && $documentModule->isStatusDraft($document) && $order) { | |||
$orderModule->updateOrderIgnoreWhenInvoicing($order, true); | |||
return Ajax::responseSuccess("La commande sera maintenant ignorée au moment de la facturation."); | |||
} | |||
else { | |||
@@ -859,8 +859,8 @@ class DocumentController extends BackendController | |||
*/ | |||
protected function findModel($idDocument, $classDocument = null) | |||
{ | |||
$documentManager = $this->getDocumentManager(); | |||
$model = $documentManager->findOneDocumentByIdAndClass($idDocument, $classDocument ?? $this->getClass()); | |||
$documentModule = $this->getDocumentModule(); | |||
$model = $documentModule->findOneDocumentByIdAndClass($idDocument, $classDocument ?? $this->getClass()); | |||
if ($model) { | |||
return $model; |
@@ -60,14 +60,14 @@ class InvoiceController extends DocumentController | |||
public function actionAjaxDeleteDeliveryNote($idInvoice, $idDeliveryNote) | |||
{ | |||
$orderManager = $this->getOrderManager(); | |||
$invoiceManager = $this->getInvoiceManager(); | |||
$deliveryNoteManager = $this->getDeliveryNoteManager(); | |||
$invoice = $invoiceManager->findOneInvoiceById($idInvoice); | |||
$deliveryNote = $deliveryNoteManager->findOneDeliveryNoteById($idDeliveryNote); | |||
$orderModule = $this->getOrderModule(); | |||
$invoiceModule = $this-> getInvoiceModule(); | |||
$deliveryNoteModule = $this->getDeliveryNoteModule(); | |||
$invoice = $invoiceModule->findOneInvoiceById($idInvoice); | |||
$deliveryNote = $deliveryNoteModule->findOneDeliveryNoteById($idDeliveryNote); | |||
if ($invoice && $invoiceManager->isStatusDraft($invoice) && $deliveryNote) { | |||
$orderManager->unassignAllOrdersInvoiceByDeliveryNote($deliveryNote); | |||
if ($invoice && $invoiceModule->isStatusDraft($invoice) && $deliveryNote) { | |||
$orderModule->unassignAllOrdersInvoiceByDeliveryNote($deliveryNote); | |||
return Ajax::responseSuccess('Bon de livraison supprimé de la facture.'); | |||
} else { | |||
return Ajax::responseError('Une erreur est survenue lors de la suppression du bon de livraison.'); | |||
@@ -76,15 +76,15 @@ class InvoiceController extends DocumentController | |||
public function actionAjaxAddDeliveryNote($idInvoice, $idDeliveryNote) | |||
{ | |||
$orderManager = $this->getOrderManager(); | |||
$invoiceManager = $this->getInvoiceManager(); | |||
$deliveryNoteManager = $this->getDeliveryNoteManager(); | |||
$orderModule = $this->getOrderModule(); | |||
$invoiceModule = $this-> getInvoiceModule(); | |||
$deliveryNoteModule = $this->getDeliveryNoteModule(); | |||
$invoice = $invoiceManager->findOneInvoiceById($idInvoice); | |||
$deliveryNote = $deliveryNoteManager->findOneDeliveryNoteById($idDeliveryNote); | |||
$invoice = $invoiceModule->findOneInvoiceById($idInvoice); | |||
$deliveryNote = $deliveryNoteModule->findOneDeliveryNoteById($idDeliveryNote); | |||
if ($invoice && $invoiceManager->isStatusDraft($invoice) && $deliveryNote) { | |||
$orderManager->assignAllOrdersInvoiceByDeliveryNote($invoice, $deliveryNote); | |||
if ($invoice && $invoiceModule->isStatusDraft($invoice) && $deliveryNote) { | |||
$orderModule->assignAllOrdersInvoiceByDeliveryNote($invoice, $deliveryNote); | |||
return Ajax::responseSuccess("Bon de livraison ajouté à la facture."); | |||
} else { | |||
return Ajax::responseError("Une erreur est survenue lors de l'ajout du bon de livraison."); |
@@ -90,14 +90,14 @@ class OrderController extends BackendController | |||
array $users | |||
) | |||
{ | |||
$orderManager = $this->getOrderManager(); | |||
$pointSaleManager = $this->getPointSaleManager(); | |||
$orderModule = $this->getOrderModule(); | |||
$pointSaleModule = $this->getPointSaleModule(); | |||
if ($date != '') { | |||
$orders = $orderManager->findOrdersByDistribution($distribution); | |||
$orders = $orderModule->findOrdersByDistribution($distribution); | |||
foreach ($pointsSale as $point) { | |||
$orderManager->initPointSaleOrders($point, $orders); | |||
$orderModule->initPointSaleOrders($point, $orders); | |||
if (isset($_POST['submit_pv']) && $_POST['submit_pv']) { | |||
// modifs | |||
@@ -158,7 +158,7 @@ class OrderController extends BackendController | |||
} | |||
} | |||
$orderManager->generateOrderReference($order); | |||
$orderModule->generateOrderReference($order); | |||
} | |||
} | |||
} | |||
@@ -170,11 +170,11 @@ class OrderController extends BackendController | |||
*/ | |||
public function actionIndex($date = '', $returnData = false) | |||
{ | |||
$distributionManager = $this->getDistributionManager(); | |||
$productManager = $this->getProductManager(); | |||
$pointSaleManager = $this->getPointSaleManager(); | |||
$orderManager = $this->getOrderManager(); | |||
$productDistributionManager = $this->getProductDistributionManager(); | |||
$distributionModule = $this-> getDistributionModule(); | |||
$productModule = $this->getProductModule(); | |||
$pointSaleModule = $this->getPointSaleModule(); | |||
$orderModule = $this->getOrderModule(); | |||
$productDistributionModule = $this->getProductDistributionManager(); | |||
if (!Product::searchCount() || !PointSale::searchCount()) { | |||
$this->redirect(['dashboard/index', 'error_products_points_sale' => 1]); | |||
@@ -190,7 +190,7 @@ class OrderController extends BackendController | |||
$arrayUsers[$user->id] = $user->name . ' ' . $user->lastname; | |||
} | |||
$distribution = $distributionManager->createDistributionIfNotExist($date); | |||
$distribution = $distributionModule->createDistributionIfNotExist($date); | |||
if ($distribution) { | |||
$arrayPointsSale = PointSale::find() | |||
@@ -202,15 +202,15 @@ class OrderController extends BackendController | |||
]) | |||
->all(); | |||
} else { | |||
$arrayPointsSale = $pointSaleManager->findPointSales(); | |||
$arrayPointsSale = $pointSaleModule->findPointSales(); | |||
} | |||
$arrayProducts = $productManager->findProducts(); | |||
$arrayProducts = $productModule->findProducts(); | |||
$this->processOrderForm($distribution, $date, $arrayPointsSale, $arrayProducts, $users); | |||
// commandes | |||
$arrayOrders = $orderManager->findOrdersByDistribution($distribution); | |||
$arrayOrders = $orderModule->findOrdersByDistribution($distribution); | |||
$revenues = 0; | |||
$weight = 0; | |||
$revenuesDelivered = 0; | |||
@@ -231,7 +231,7 @@ class OrderController extends BackendController | |||
// init commandes point de vente | |||
foreach ($arrayPointsSale as $pointSale) { | |||
$orderManager->initPointSaleOrders($pointSale, $arrayOrders); | |||
$orderModule->initPointSaleOrders($pointSale, $arrayOrders); | |||
$dataSelectOrders = []; | |||
$dataOptionsOrders = []; | |||
@@ -267,7 +267,7 @@ class OrderController extends BackendController | |||
foreach ($arrayProducts as $product) { | |||
$productDistribution = $productDistributionManager->findOneProductDistribution($distribution, $product); | |||
$productDistribution = $productDistributionModule->findOneProductDistribution($distribution, $product); | |||
if (!$productDistribution) { | |||
$productDistribution = new ProductDistribution(); | |||
@@ -281,7 +281,7 @@ class OrderController extends BackendController | |||
$productDistribution->quantity_max = null; | |||
} | |||
$productDistributionManager->saveCreate($productDistribution); | |||
$productDistributionModule->saveCreate($productDistribution); | |||
} | |||
if (isset($_POST['Product'][$product->id]['active'])) { | |||
@@ -296,15 +296,15 @@ class OrderController extends BackendController | |||
$productDistribution->quantity_max = null; | |||
} | |||
$productDistributionManager->saveUpdate($productDistribution); | |||
$productDistributionModule->saveUpdate($productDistribution); | |||
} | |||
} | |||
} | |||
$arrayProductsSelected = []; | |||
if ($distribution) { | |||
$arrayProductsSelected = $productDistributionManager->findProductDistributionsByDistribution($distribution); | |||
$arrayProducts = $productManager->findProductsByDistribution($distribution); | |||
$arrayProductsSelected = $productDistributionModule->findProductDistributionsByDistribution($distribution); | |||
$arrayProducts = $productModule->findProductsByDistribution($distribution); | |||
} | |||
// poids total de la production et CA potentiel | |||
@@ -321,7 +321,7 @@ class OrderController extends BackendController | |||
} | |||
} | |||
$arrayDistributionDays = $distributionManager->findDistributionsActive(); | |||
$arrayDistributionDays = $distributionModule->findDistributionsActive(); | |||
// commandes auto | |||
$subscriptionForm = new SubscriptionForm(); | |||
@@ -417,20 +417,20 @@ class OrderController extends BackendController | |||
*/ | |||
public function actionDownload($date = '', $idPointSale = 0, $global = 0) | |||
{ | |||
$orderManager = $this->getOrderManager(); | |||
$distributionManager = $this->getDistributionManager(); | |||
$pointSaleManager = $this->getPointSaleManager(); | |||
$productManager = $this->getProductManager(); | |||
$productDistributionManager = $this->getProductDistributionManager(); | |||
$distribution = $distributionManager->findOneDistribution($date); | |||
$selectedProductsArray = $productDistributionManager->findProductDistributionsByDistribution($distribution); | |||
$productsArray = $productManager->findProducts(); | |||
$ordersArray = $orderManager->findOrdersByDistributionDate($date); | |||
$pointsSaleArray = $pointSaleManager->findPointSales(); | |||
$orderModule = $this->getOrderModule(); | |||
$distributionModule = $this-> getDistributionModule(); | |||
$pointSaleModule = $this->getPointSaleModule(); | |||
$productModule = $this->getProductModule(); | |||
$productDistributionModule = $this->getProductDistributionManager(); | |||
$distribution = $distributionModule->findOneDistribution($date); | |||
$selectedProductsArray = $productDistributionModule->findProductDistributionsByDistribution($distribution); | |||
$productsArray = $productModule->findProducts(); | |||
$ordersArray = $orderModule->findOrdersByDistributionDate($date); | |||
$pointsSaleArray = $pointSaleModule->findPointSales(); | |||
foreach ($pointsSaleArray as $pointSale) { | |||
$pointSaleManager->initOrders($pointSale, $ordersArray); | |||
$pointSaleModule->initOrders($pointSale, $ordersArray); | |||
} | |||
/* | |||
@@ -465,7 +465,7 @@ class OrderController extends BackendController | |||
$strProducts = ''; | |||
foreach ($productsArray as $product) { | |||
if (isset($selectedProductsArray[$product->id]['active']) && $selectedProductsArray[$product->id]['active']) { | |||
$quantity = $orderManager->getProductQuantity($product, $pointSale->orders); | |||
$quantity = $orderModule->getProductQuantity($product, $pointSale->orders); | |||
$strQuantity = ''; | |||
if ($quantity) { | |||
$strQuantity = $quantity; | |||
@@ -485,7 +485,7 @@ class OrderController extends BackendController | |||
$strProducts = ''; | |||
foreach ($productsArray as $product) { | |||
if (isset($selectedProductsArray[$product->id]['active']) && $selectedProductsArray[$product->id]['active']) { | |||
$quantity = $orderManager->getProductQuantity($product, $ordersArray); | |||
$quantity = $orderModule->getProductQuantity($product, $ordersArray); | |||
$strQuantity = ''; | |||
if ($quantity) { | |||
$strQuantity = $quantity; | |||
@@ -542,15 +542,15 @@ class OrderController extends BackendController | |||
*/ | |||
public function contentRecapCSV(string $date, array $products, array $pointsSale, array $orders) | |||
{ | |||
$orderManager = $this->getOrderManager(); | |||
$distributionManager = $this->getDistributionManager(); | |||
$productDistributionManager = $this->getProductDistributionManager(); | |||
$orderModule = $this->getOrderModule(); | |||
$distributionModule = $this-> getDistributionModule(); | |||
$productDistributionModule = $this->getProductDistributionManager(); | |||
$data = []; | |||
$filename = 'summary_' . $date; | |||
$distribution = $distributionManager->findOneDistribution($date); | |||
$selectedProductsArray = $productDistributionManager->findProductDistributionsByDistribution($distribution); | |||
$distribution = $distributionModule->findOneDistribution($date); | |||
$selectedProductsArray = $productDistributionModule->findProductDistributionsByDistribution($distribution); | |||
// head | |||
$data[0] = ['Lieu']; | |||
@@ -571,7 +571,7 @@ class OrderController extends BackendController | |||
$dataAdd = [$pointSale->name]; | |||
foreach ($products as $product) { | |||
if (isset($selectedProductsArray[$product->id]['active']) && $selectedProductsArray[$product->id]['active']) { | |||
$dataAdd[] = $orderManager->getProductQuantity($product, $pointSale->orders); | |||
$dataAdd[] = $orderModule->getProductQuantity($product, $pointSale->orders); | |||
} | |||
} | |||
$data[] = $dataAdd; | |||
@@ -581,7 +581,7 @@ class OrderController extends BackendController | |||
$dataAdd = ['Total']; | |||
foreach ($products as $product) { | |||
if (isset($selectedProductsArray[$product->id]['active']) && $selectedProductsArray[$product->id]['active']) { | |||
$dataAdd[] = $orderManager->getProductQuantity($product, $orders); | |||
$dataAdd[] = $orderModule->getProductQuantity($product, $orders); | |||
} | |||
} | |||
$data[] = $dataAdd; | |||
@@ -604,12 +604,12 @@ class OrderController extends BackendController | |||
*/ | |||
public function contentPointSaleCSV($date, $products, $pointsSale, $idPointSale) | |||
{ | |||
$distributionManager = $this->getDistributionManager(); | |||
$productDistributionManager = $this->getProductDistributionManager(); | |||
$distributionModule = $this-> getDistributionModule(); | |||
$productDistributionModule = $this->getProductDistributionManager(); | |||
$data = []; | |||
$distribution = $distributionManager->findOneDistribution($date); | |||
$selectedProductsArray = $productDistributionManager->findProductDistributionsByDistribution($distribution); | |||
$distribution = $distributionModule->findOneDistribution($date); | |||
$selectedProductsArray = $productDistributionModule->findProductDistributionsByDistribution($distribution); | |||
// datas | |||
foreach ($pointsSale as $pointSale) { | |||
@@ -667,9 +667,9 @@ class OrderController extends BackendController | |||
*/ | |||
public function actionChangeState(string $date, bool $active, bool $redirect = true) | |||
{ | |||
$distributionManager = $this->getDistributionManager(); | |||
$distribution = $distributionManager->createDistributionIfNotExist($date); | |||
$distributionManager->activeDistribution($distribution, $active); | |||
$distributionModule = $this-> getDistributionModule(); | |||
$distribution = $distributionModule->createDistributionIfNotExist($date); | |||
$distributionModule->activeDistribution($distribution, $active); | |||
if ($redirect) { | |||
$this->redirect(['index', 'date' => $date]); | |||
@@ -681,9 +681,9 @@ class OrderController extends BackendController | |||
*/ | |||
public function actionChangeStateWeek(string $date, bool $active) | |||
{ | |||
$pointSaleManager = $this->getPointSaleManager(); | |||
$pointSaleModule = $this->getPointSaleModule(); | |||
$pointsSaleArray = $pointSaleManager->findPointSales(); | |||
$pointsSaleArray = $pointSaleModule->findPointSales(); | |||
$week = sprintf('%02d', date('W', strtotime($date))); | |||
$start = strtotime(date('Y', strtotime($date)) . 'W' . $week); | |||
@@ -731,11 +731,11 @@ class OrderController extends BackendController | |||
{ | |||
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; | |||
$orderManager = $this->getOrderManager(); | |||
$orderModule = $this->getOrderModule(); | |||
$order = $orderManager->findOneOrderById($idOrder); | |||
$order = $orderModule->findOneOrderById($idOrder); | |||
if ($order) { | |||
$orderManager->deleteOrder($order); | |||
$orderModule->deleteOrder($order); | |||
} | |||
return ['success']; | |||
@@ -747,10 +747,10 @@ class OrderController extends BackendController | |||
*/ | |||
public function actionDelete(string $date, int $idOrder) | |||
{ | |||
$orderManager = $this->getOrderManager(); | |||
$order = $orderManager->findOneOrderById($idOrder); | |||
$orderModule = $this->getOrderModule(); | |||
$order = $orderModule->findOneOrderById($idOrder); | |||
if ($order) { | |||
$orderManager->deleteOrder($order); | |||
$orderModule->deleteOrder($order); | |||
} | |||
$this->redirect(['index', 'date' => $date]); | |||
@@ -771,18 +771,18 @@ class OrderController extends BackendController | |||
{ | |||
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; | |||
$distributionManager = $this->getDistributionManager(); | |||
$pointSaleManager = $this->getPointSaleManager(); | |||
$userPointSaleManager = $this->getUserPointSaleManager(); | |||
$distributionModule = $this-> getDistributionModule(); | |||
$pointSaleModule = $this->getPointSaleModule(); | |||
$userPointSaleModule = $this->getUserPointSaleModule(); | |||
$userModule = $this->getUserModule(); | |||
$userProducerManager = $this->getUserProducerManager(); | |||
$producerManager = $this->getProducerManager(); | |||
$productManager = $this->getProductManager(); | |||
$orderManager = $this->getOrderManager(); | |||
$userProducerModule = $this->getUserProducerModule(); | |||
$producerModule = $this->getProducerModule(); | |||
$productModule = $this->getProductModule(); | |||
$orderModule = $this->getOrderModule(); | |||
$products = json_decode($products); | |||
$pointSale = $pointSaleManager->findOnePointSaleById($idPointSale); | |||
$distribution = $distributionManager->findOneDistribution($date); | |||
$pointSale = $pointSaleModule->findOnePointSaleById($idPointSale); | |||
$distribution = $distributionModule->findOneDistribution($date); | |||
$producerCurrent = $this->getProducerCurrent(); | |||
if (preg_match("/^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$/", $date) | |||
@@ -804,7 +804,7 @@ class OrderController extends BackendController | |||
$order->id_user = $idUser; | |||
// commentaire du point de vente | |||
$userPointSale = $userPointSaleManager->findOneUserPointSale($userModule->findOneUserById($idUser), $pointSale); | |||
$userPointSale = $userPointSaleModule->findOneUserPointSale($userModule->findOneUserById($idUser), $pointSale); | |||
if ($userPointSale && strlen($userPointSale->comment)) { | |||
$order->comment_point_sale = $userPointSale->comment; | |||
@@ -821,11 +821,11 @@ class OrderController extends BackendController | |||
if (isset($order->user) && $order->user) { | |||
$user = $order->user; | |||
$userProducer = $userProducerManager->findOneUserProducer($user); | |||
$userProducer = $userProducerModule->findOneUserProducer($user); | |||
} | |||
foreach ($products as $key => $dataProductOrder) { | |||
$product = $productManager->findOneProductById($key); | |||
$product = $productModule->findOneProductById($key); | |||
if(isset(Product::$unitsArray[$dataProductOrder->unit]) && Product::$unitsArray[$dataProductOrder->unit]['coefficient']) { | |||
$quantity = $dataProductOrder->quantity / Product::$unitsArray[$dataProductOrder->unit]['coefficient']; | |||
if ($product && $quantity) { | |||
@@ -838,7 +838,7 @@ class OrderController extends BackendController | |||
if ($dataProductOrder->price) { | |||
$productOrder->price = $dataProductOrder->price; | |||
} else { | |||
$productOrder->price = $productManager->getPrice($product, [ | |||
$productOrder->price = $productModule->getPrice($product, [ | |||
'user' => $user, | |||
'user_producer' => $userProducer, | |||
'point_sale' => $order->pointSale, | |||
@@ -851,22 +851,22 @@ class OrderController extends BackendController | |||
} | |||
} | |||
$order = $orderManager->findOneOrderById($order->id); | |||
$orderManager->initOrder($order); | |||
if ($order && $orderManager->isCreditAutoPayment($order, $debitCredit)) { | |||
$orderManager->processCredit($order); | |||
$order = $orderModule->findOneOrderById($order->id); | |||
$orderModule->initOrder($order); | |||
if ($order && $orderModule->isCreditAutoPayment($order, $debitCredit)) { | |||
$orderModule->processCredit($order); | |||
} | |||
$order = $orderManager->findOneOrderById($order->id); | |||
$orderManager->initOrder($order); | |||
$order = $orderModule->findOneOrderById($order->id); | |||
$orderModule->initOrder($order); | |||
if ($order) { | |||
$orderManager->generateOrderReference($order); | |||
$orderManager->updateOrderTillerSynchronization($order); | |||
$orderModule->generateOrderReference($order); | |||
$orderModule->updateOrderTillerSynchronization($order); | |||
} | |||
// lien utilisateur / point de vente | |||
if ($idUser && $pointSale) { | |||
$pointSaleManager->addUser($user, $pointSale); | |||
$pointSaleModule->addUser($user, $pointSale); | |||
} | |||
} | |||
@@ -885,12 +885,12 @@ class OrderController extends BackendController | |||
{ | |||
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; | |||
$orderManager = $this->getOrderManager(); | |||
$orderModule = $this->getOrderModule(); | |||
$userModule = $this->getUserModule(); | |||
$pointSaleManager = $this->getPointSaleManager(); | |||
$userPointSaleManager = $this->getUserPointSaleManager(); | |||
$paymentManager = $this->getPaymentManager(); | |||
$productManager = $this->getProductManager(); | |||
$pointSaleModule = $this->getPointSaleModule(); | |||
$userPointSaleModule = $this->getUserPointSaleModule(); | |||
$paymentManager = $this->getPaymentModule(); | |||
$productModule = $this->getProductModule(); | |||
$request = \Yii::$app->request; | |||
$date = $request->post('date'); | |||
@@ -903,22 +903,22 @@ class OrderController extends BackendController | |||
$comment = $request->post('comment'); | |||
$debitCredit = $request->post('debitCredit'); | |||
$order = $orderManager->findOneOrderById($idOrder); | |||
$orderManager->initOrder($order); | |||
$order = $orderModule->findOneOrderById($idOrder); | |||
$orderModule->initOrder($order); | |||
$user = $userModule->findOneUserById($idUser); | |||
$pointSale = $pointSaleManager->findOnePointSaleById($idPointSale); | |||
$pointSale = $pointSaleModule->findOnePointSaleById($idPointSale); | |||
if ($order | |||
&& $order->distribution->id_producer == GlobalParam::getCurrentProducerId()) { | |||
// Si changement d'user : on rembourse l'ancien user | |||
$oldIdUser = $order->id_user; | |||
$amountPaid = $orderManager->getOrderAmountWithTax($order, Order::AMOUNT_PAID); | |||
$amountPaid = $orderModule->getOrderAmountWithTax($order, Order::AMOUNT_PAID); | |||
if ($oldIdUser != $idUser && $amountPaid > 0) { | |||
$paymentManager->refundOrderCredit($order, $this->getUserCurrent()); | |||
$order = $orderManager->findOneOrderById($idOrder); | |||
$orderManager->initOrder($order); | |||
$order = $orderModule->findOneOrderById($idOrder); | |||
$orderModule->initOrder($order); | |||
} | |||
if ($idUser) { | |||
@@ -926,7 +926,7 @@ class OrderController extends BackendController | |||
$order->id_user = $idUser; | |||
// commentaire du point de vente | |||
$userPointSale = $userPointSaleManager->findOneUserPointSale($user, $pointSale); | |||
$userPointSale = $userPointSaleModule->findOneUserPointSale($user, $pointSale); | |||
if ($userPointSale && strlen($userPointSale->comment)) { | |||
$order->comment_point_sale = $userPointSale->comment; | |||
} | |||
@@ -977,7 +977,7 @@ class OrderController extends BackendController | |||
if ($dataProductOrder->price) { | |||
$productOrder->price = $dataProductOrder->price; | |||
} else { | |||
$productOrder->price = $productManager->getPrice($product, [ | |||
$productOrder->price = $productModule->getPrice($product, [ | |||
'user' => $user, | |||
'user_producer' => $userProducer, | |||
'point_sale' => $order->pointSale, | |||
@@ -1003,9 +1003,9 @@ class OrderController extends BackendController | |||
$order->save(); | |||
$order = Order::searchOne(['id' => $order->id]); | |||
$orderManager->initOrder($order); | |||
if ($order && $orderManager->isCreditAutoPayment($order, $debitCredit)) { | |||
$orderManager->processCredit($order); | |||
$orderModule->initOrder($order); | |||
if ($order && $orderModule->isCreditAutoPayment($order, $debitCredit)) { | |||
$orderModule->processCredit($order); | |||
} | |||
} | |||
} | |||
@@ -1015,10 +1015,10 @@ class OrderController extends BackendController | |||
*/ | |||
public function actionPaymentStatus(int $idOrder) | |||
{ | |||
$orderManager = $this->getOrderManager(); | |||
$paymentManager = $this->getPaymentManager(); | |||
$orderModule = $this->getOrderModule(); | |||
$paymentManager = $this->getPaymentModule(); | |||
$order = $orderManager->findOneOrderById($idOrder); | |||
$order = $orderModule->findOneOrderById($idOrder); | |||
if ($order) { | |||
$html = ''; | |||
@@ -1031,11 +1031,11 @@ class OrderController extends BackendController | |||
]) | |||
->one(); | |||
$amountPaid = $orderManager->getOrderAmount($order, Order::AMOUNT_PAID); | |||
$amountPaid = $orderModule->getOrderAmount($order, Order::AMOUNT_PAID); | |||
if (abs($order->amount - $amountPaid) < 0.0001) { | |||
$html .= '<span class="label label-success">Payé</span>'; | |||
$buttonsCredit = Html::a('Recréditer ' . $orderManager->getOrderAmountWithTax($order, Order::AMOUNT_TOTAL, true), 'javascript:void(0);', ['class' => 'btn btn-default btn-xs rembourser', 'data-montant' => $order->amount, 'data-type' => 'refund']); | |||
$buttonsCredit = Html::a('Recréditer ' . $orderModule->getOrderAmountWithTax($order, Order::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> à débiter'; | |||
@@ -1096,10 +1096,10 @@ class OrderController extends BackendController | |||
{ | |||
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; | |||
$orderManager = $this->getOrderManager(); | |||
$paymentManager = $this->getPaymentManager(); | |||
$order = $orderManager->findOneOrderById($idOrder); | |||
$orderManager->initOrder($order); | |||
$orderModule = $this->getOrderModule(); | |||
$paymentManager = $this->getPaymentModule(); | |||
$order = $orderModule->findOneOrderById($idOrder); | |||
$orderModule->initOrder($order); | |||
if ($order) { | |||
$paymentManager->payOrRefundOrder($type, $order, $meanPayment, $this->getUserCurrent()); | |||
@@ -1115,11 +1115,11 @@ class OrderController extends BackendController | |||
{ | |||
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; | |||
$orderManager = $this->getOrderManager(); | |||
$orderModule = $this->getOrderModule(); | |||
$order = $orderManager->findOneOrderById($idOrder); | |||
$order = $orderModule->findOneOrderById($idOrder); | |||
if ($order) { | |||
$orderManager->updateOrderTillerSynchronization($order, (int) $boolSynchroTiller); | |||
$orderModule->updateOrderTillerSynchronization($order, (int) $boolSynchroTiller); | |||
return ['success']; | |||
} | |||
@@ -93,15 +93,15 @@ class PointSaleController extends BackendController | |||
*/ | |||
public function actionCreate() | |||
{ | |||
$pointSaleManager = $this->getPointSaleManager(); | |||
$distributionManager = $this->getDistributionManager(); | |||
$pointSaleModule = $this->getPointSaleModule(); | |||
$distributionModule = $this-> getDistributionModule(); | |||
$pointSale = $pointSaleManager->instanciatePointSale(); | |||
$pointSale = $pointSaleModule->instanciatePointSale(); | |||
if ($pointSale->load(\Yii::$app->request->post()) && $pointSale->save()) { | |||
$pointSaleManager->updatePointSalePointProduction($pointSale); | |||
$pointSaleManager->processRestrictedAccess($pointSale); | |||
$distributionManager->addPointSaleIncomingDistributions($pointSale); | |||
$pointSaleModule->updatePointSalePointProduction($pointSale); | |||
$pointSaleModule->processRestrictedAccess($pointSale); | |||
$distributionModule->addPointSaleIncomingDistributions($pointSale); | |||
return $this->redirect(['index']); | |||
} else { | |||
@@ -116,8 +116,8 @@ class PointSaleController extends BackendController | |||
*/ | |||
public function actionUpdate(int $id) | |||
{ | |||
$distributionManager = $this->getDistributionManager(); | |||
$pointSaleManager = $this->getPointSaleManager(); | |||
$distributionModule = $this-> getDistributionModule(); | |||
$pointSaleModule = $this->getPointSaleModule(); | |||
$model = PointSale::find() | |||
->with('userPointSale') | |||
@@ -131,9 +131,9 @@ class PointSaleController extends BackendController | |||
if ($model->load(\Yii::$app->request->post()) && $model->save()) { | |||
$pointSaleManager->updatePointSalePointProduction($model); | |||
$pointSaleManager->processRestrictedAccess($model); | |||
$distributionManager->addPointSaleIncomingDistributions($model); | |||
$pointSaleModule->updatePointSalePointProduction($model); | |||
$pointSaleModule->processRestrictedAccess($model); | |||
$distributionModule->addPointSaleIncomingDistributions($model); | |||
$this->setFlash('success', 'Point de vente modifié.'); | |||
@@ -167,8 +167,8 @@ class PointSaleController extends BackendController | |||
*/ | |||
public function actionDelete(int $id, $confirm = false) | |||
{ | |||
$orderManager = $this->getOrderManager(); | |||
$distributionManager = $this->getDistributionManager(); | |||
$orderModule = $this->getOrderModule(); | |||
$distributionModule = $this-> getDistributionModule(); | |||
$pointSale = $this->findModel($id); | |||
@@ -180,7 +180,7 @@ class PointSaleController extends BackendController | |||
UserPointSale::deleteAll(['id_point_sale' => $id]); | |||
// Suppression du lien PointSaleDistribution pour toutes les distributions à venir | |||
$incomingDistributions = $distributionManager->findDistributionsIncoming(true); | |||
$incomingDistributions = $distributionModule->findDistributionsIncoming(true); | |||
foreach ($incomingDistributions as $distribution) { | |||
PointSaleDistribution::deleteAll(['id_point_sale' => $id, 'id_distribution' => $distribution->id]); | |||
} | |||
@@ -198,7 +198,7 @@ class PointSaleController extends BackendController | |||
if ($ordersArray) { | |||
foreach ($ordersArray as $order) { | |||
$orderManager->deleteOrder($order, true); | |||
$orderModule->deleteOrder($order, true); | |||
} | |||
} | |||
@@ -216,7 +216,7 @@ class PointSaleController extends BackendController | |||
*/ | |||
public function actionDefault(int $id) | |||
{ | |||
$pointSaleManager = $this->getPointSaleManager(); | |||
$pointSaleModule = $this->getPointSaleModule(); | |||
$pointSale = $this->findModel($id); | |||
if ($pointSale) { | |||
@@ -224,7 +224,7 @@ class PointSaleController extends BackendController | |||
if (!$pointSale->default) { | |||
$pointSale->default = 1; | |||
$pointSaleManager->saveUpdate($pointSale); | |||
$pointSaleModule->saveUpdate($pointSale); | |||
$this->setFlash('success', 'Point de vente <strong>' . Html::encode($pointSale->name) . '</strong> défini par défaut.'); | |||
} else { |
@@ -85,7 +85,7 @@ class ProducerAdminController extends BackendController | |||
*/ | |||
public function actionIndex() | |||
{ | |||
$producerManager = $this->getProducerManager(); | |||
$producerModule = $this->getProducerModule(); | |||
$dataProviderProducer = new ActiveDataProvider([ | |||
'query' => Producer::find() | |||
@@ -96,10 +96,10 @@ class ProducerAdminController extends BackendController | |||
], | |||
]); | |||
$producersArray = $producerManager->findProducersActive(); | |||
$producersArray = $producerModule->findProducersActive(); | |||
$sumPrices = 0; | |||
foreach ($producersArray as $producer) { | |||
$sumPrices += $producerManager->getAmountBilledLastMonth($producer); | |||
$sumPrices += $producerModule->getAmountBilledLastMonth($producer); | |||
} | |||
return $this->render('index', [ | |||
@@ -113,10 +113,10 @@ class ProducerAdminController extends BackendController | |||
*/ | |||
public function actionCreate() | |||
{ | |||
$producerManager = $this->getProducerManager(); | |||
$producer = $producerManager->instanciateProducer(); | |||
$producerModule = $this->getProducerModule(); | |||
$producer = $producerModule->instanciateProducer(); | |||
if ($producer->load(\Yii::$app->request->post()) && $producerManager->saveCreate($producer)) { | |||
if ($producer->load(\Yii::$app->request->post()) && $producerModule->saveCreate($producer)) { | |||
$this->setFlash('success', 'Producteur créé.'); | |||
return $this->redirect(['index']); | |||
} else { | |||
@@ -131,10 +131,10 @@ class ProducerAdminController extends BackendController | |||
*/ | |||
public function actionUpdate(int $id) | |||
{ | |||
$producerManager = $this->getProducerManager(); | |||
$producerModule = $this->getProducerModule(); | |||
$producer = $this->findProducer($id); | |||
if ($producer->load(\Yii::$app->request->post()) && $producerManager->saveCreate($producer)) { | |||
if ($producer->load(\Yii::$app->request->post()) && $producerModule->saveCreate($producer)) { | |||
$this->setFlash('success', 'Producteur modifié.'); | |||
return $this->redirect(['index']); | |||
} else { | |||
@@ -171,10 +171,10 @@ class ProducerAdminController extends BackendController | |||
public function actionDolibarr(int $id) | |||
{ | |||
$producerManager = $this->getProducerManager(); | |||
$producerModule = $this->getProducerModule(); | |||
$producer = $this->findProducer($id); | |||
if($producer->dolibarr_socid) { | |||
$producerManager->generateDolibarrProducerInvoice($producer); | |||
$producerModule->generateDolibarrProducerInvoice($producer); | |||
return Ajax::responseSuccess("Facture générée sur Dolibarr pour le producteur \"".Html::encode($producer->name)."\""); | |||
} | |||
else { | |||
@@ -184,7 +184,7 @@ class ProducerAdminController extends BackendController | |||
public function actionUserTransfer($fromProducerId, $toProducerId, $withOrders = 1) | |||
{ | |||
$producerManager = $this->getProducerManager(); | |||
$producerModule = $this->getProducerModule(); | |||
$userModule = $this->getUserModule(); | |||
$fromProducerId = (int)$fromProducerId; | |||
@@ -204,9 +204,9 @@ class ProducerAdminController extends BackendController | |||
} | |||
if (($withOrders && $countOrders) || !$withOrders) { | |||
$producerManager->addUser( | |||
$producerModule->addUser( | |||
$userModule->findOneUserById($idUser), | |||
$producerManager->findOneProducerById($toProducerId) | |||
$producerModule->findOneProducerById($toProducerId) | |||
); | |||
$count++; | |||
} | |||
@@ -255,9 +255,9 @@ class ProducerAdminController extends BackendController | |||
*/ | |||
protected function findProducer(int $id) | |||
{ | |||
$producerManager = $this->getProducerManager(); | |||
$producerModule = $this->getProducerModule(); | |||
if (($model = $producerManager->findOneProducerById($id)) !== null) { | |||
if (($model = $producerModule->findOneProducerById($id)) !== null) { | |||
return $model; | |||
} else { | |||
throw new NotFoundHttpException('Producteur introuvable.'); |
@@ -87,8 +87,8 @@ class ProducerController extends BackendController | |||
*/ | |||
public function actionUpdate() | |||
{ | |||
$producerContainer = $this->getProducerContainer(); | |||
$producerBuilder = $producerContainer->getBuilder(); | |||
$producerModule = $this->getProducerModule(); | |||
$producerBuilder = $producerModule->getBuilder(); | |||
$request = Yii::$app->request; | |||
$model = $this->findModel(GlobalParam::getCurrentProducerId()); | |||
@@ -168,8 +168,8 @@ class ProducerController extends BackendController | |||
public function actionUpdateOpendistribVersion() | |||
{ | |||
$producerManager = $this->getProducerManager(); | |||
$producerManager->updateOpendistribVersion($this->getProducerCurrent()); | |||
$producerModule = $this->getProducerModule(); | |||
$producerModule->updateOpendistribVersion($this->getProducerCurrent()); | |||
return $this->redirect(\Yii::$app->request->referrer); | |||
} | |||
@@ -183,7 +183,7 @@ class ProducerController extends BackendController | |||
$entity = $request->post('entity'); | |||
$pageSize = $request->post('pagesize'); | |||
$this->getProducerContainer()->getProducerPageSizer() | |||
$this->getProducerModule()->getProducerPageSizer() | |||
->updatePagesize($producerCurrent, $entity, $pageSize); | |||
} | |||
@@ -89,11 +89,11 @@ class ProducerPriceRangeAdminController extends BackendController | |||
*/ | |||
public function actionCreate() | |||
{ | |||
$producerPriceRangeManager = $this->getProducerPriceRangeManager(); | |||
$producerPriceRange = $producerPriceRangeManager->instanciateProducerPriceRange(); | |||
$producerPriceRangeModule = $this->getProducerPriceRangeModule(); | |||
$producerPriceRange = $producerPriceRangeModule->instanciateProducerPriceRange(); | |||
if ($producerPriceRange->load(\Yii::$app->request->post()) | |||
&& $producerPriceRangeManager->saveCreate($producerPriceRange)) { | |||
&& $producerPriceRangeModule->saveCreate($producerPriceRange)) { | |||
$this->setFlash('success', 'Tranche de prix créée.'); | |||
@@ -110,10 +110,10 @@ class ProducerPriceRangeAdminController extends BackendController | |||
*/ | |||
public function actionUpdate(int $id) | |||
{ | |||
$producerPriceRangeManager = $this->getProducerPriceRangeManager(); | |||
$producerPriceRangeModule = $this->getProducerPriceRangeModule(); | |||
$producerPriceRange = $this->findModel($id); | |||
if ($producerPriceRange->load(\Yii::$app->request->post()) && $producerPriceRangeManager->saveUpdate($producerPriceRange)) { | |||
if ($producerPriceRange->load(\Yii::$app->request->post()) && $producerPriceRangeModule->saveUpdate($producerPriceRange)) { | |||
$this->setFlash('success', 'Tranche de prix éditée.'); | |||
return $this->redirect(['index']); | |||
} else { | |||
@@ -128,10 +128,10 @@ class ProducerPriceRangeAdminController extends BackendController | |||
*/ | |||
public function actionDelete(int $id) | |||
{ | |||
$producerPriceRangeManager = $this->getProducerPriceRangeManager(); | |||
$producerPriceRangeModule = $this->getProducerPriceRangeModule(); | |||
$producerPriceRange = $this->findModel($id); | |||
$producerPriceRangeManager->delete($producerPriceRange); | |||
$producerPriceRangeModule->delete($producerPriceRange); | |||
$this->setFlash('success', 'Tranche de prix supprimée.'); | |||
return $this->redirect(['producer-price-range-admin/index']); | |||
@@ -139,8 +139,8 @@ class ProducerPriceRangeAdminController extends BackendController | |||
protected function findModel($id) | |||
{ | |||
$producerPriceRangeManager = $this->getProducerPriceRangeManager(); | |||
if (($producerPriceRange = $producerPriceRangeManager->findOneProducerPriceRangeById($id)) !== null) { | |||
$producerPriceRangeModule = $this->getProducerPriceRangeModule(); | |||
if (($producerPriceRange = $producerPriceRangeModule->findOneProducerPriceRangeById($id)) !== null) { | |||
return $producerPriceRange; | |||
} else { | |||
throw new NotFoundHttpException('The requested page does not exist.'); |
@@ -91,12 +91,12 @@ class ProductCategoryController extends BackendController | |||
*/ | |||
public function actionCreate() | |||
{ | |||
$productCategoryManager = $this->getProductCategoryManager(); | |||
$productCategory = $productCategoryManager->instanciateProductCategory(); | |||
$productCategoryModule = $this->getProductCategoryModule(); | |||
$productCategory = $productCategoryModule->instanciateProductCategory(); | |||
$productCategory->id_producer = GlobalParam::getCurrentProducerId(); | |||
if ($productCategory->load(\Yii::$app->request->post()) && $productCategoryManager->saveCreate($productCategory)) { | |||
if ($productCategory->load(\Yii::$app->request->post()) && $productCategoryModule->saveCreate($productCategory)) { | |||
$this->setFlash('success', "Catégorie ajoutée."); | |||
return $this->redirect(['index']); | |||
} else { | |||
@@ -111,10 +111,10 @@ class ProductCategoryController extends BackendController | |||
*/ | |||
public function actionUpdate(int $id) | |||
{ | |||
$productCategoryManager = $this->getProductCategoryManager(); | |||
$productCategoryModule = $this->getProductCategoryModule(); | |||
$productCategory = $this->findModel($id); | |||
if ($productCategory->load(\Yii::$app->request->post()) && $productCategoryManager->saveUpdate($productCategory)) { | |||
if ($productCategory->load(\Yii::$app->request->post()) && $productCategoryModule->saveUpdate($productCategory)) { | |||
$this->setFlash('success', "Catégorie modifiée."); | |||
return $this->redirect(['index']); | |||
} else { | |||
@@ -129,10 +129,10 @@ class ProductCategoryController extends BackendController | |||
*/ | |||
public function actionDelete($id) | |||
{ | |||
$productCategoryManager = $this->getProductCategoryManager(); | |||
$productCategoryModule = $this->getProductCategoryModule(); | |||
$productCategory = $this->findModel($id); | |||
$productCategoryManager->delete($productCategory); | |||
$productCategoryModule->delete($productCategory); | |||
Product::updateAll(['id_product_category' => null], ['id_product_category' => $id]); | |||
$this->setFlash('success', 'Catégorie <strong>' . Html::encode($productCategory->name) . '</strong> supprimée.'); | |||
@@ -160,8 +160,8 @@ class ProductCategoryController extends BackendController | |||
*/ | |||
protected function findModel($id) | |||
{ | |||
$productCategoryManager = $this->getProductCategoryManager(); | |||
if (($productCategory = $productCategoryManager->findOneProductCategoryById($id)) !== null) { | |||
$productCategoryModule = $this->getProductCategoryModule(); | |||
if (($productCategory = $productCategoryModule->findOneProductCategoryById($id)) !== null) { | |||
return $productCategory; | |||
} else { | |||
throw new NotFoundHttpException('The requested page does not exist.'); |
@@ -106,10 +106,10 @@ class ProductController extends BackendController | |||
*/ | |||
public function actionCreate() | |||
{ | |||
$productManager = $this->getProductManager(); | |||
$distributionManager = $this->getDistributionManager(); | |||
$productModule = $this->getProductModule(); | |||
$distributionModule = $this-> getDistributionModule(); | |||
$model = $productManager->instanciateProduct(); | |||
$model = $productModule->instanciateProduct(); | |||
$model->status = Product::STATUS_ONLINE; | |||
$model->id_producer = GlobalParam::getCurrentProducerId(); | |||
@@ -131,14 +131,14 @@ class ProductController extends BackendController | |||
if ($lastProductOrder) { | |||
$model->order = ++$lastProductOrder->order; | |||
} | |||
$productManager->create($model); | |||
$productModule->create($model); | |||
if($model->photoFile) { | |||
Upload::uploadFile($model, 'photoFile', 'photo'); | |||
} | |||
$this->processAvailabilityPointsSale($model); | |||
$distributionManager->addProductIncomingDistributions($model); | |||
$distributionModule->addProductIncomingDistributions($model); | |||
$this->setFlash('success', 'Produit <strong>' . Html::encode($model->name) . '</strong> ajouté'); | |||
@@ -156,8 +156,8 @@ class ProductController extends BackendController | |||
*/ | |||
public function actionUpdate($id) | |||
{ | |||
$productManager = $this->getProductManager(); | |||
$distributionManager = $this->getDistributionManager(); | |||
$productModule = $this->getProductModule(); | |||
$distributionModule = $this-> getDistributionModule(); | |||
$request = Yii::$app->request; | |||
$model = $this->findModel($id); | |||
@@ -185,9 +185,9 @@ class ProductController extends BackendController | |||
$this->processAvailabilityPointsSale($model); | |||
if ($model->apply_distributions) { | |||
$distributionManager->addProductIncomingDistributions($model); | |||
$distributionModule->addProductIncomingDistributions($model); | |||
} | |||
$productManager->update($model); | |||
$productModule->update($model); | |||
$this->setFlash('success', 'Produit <strong>' . Html::encode($model->name) . '</strong> modifié'); | |||
return $this->redirect(['index']); | |||
@@ -205,16 +205,16 @@ class ProductController extends BackendController | |||
*/ | |||
public function processAvailabilityPointsSale($product) | |||
{ | |||
$pointSaleManager = $this->getPointSaleManager(); | |||
$productPointSaleManager = $this->getProductPointSaleManager(); | |||
$pointSaleModule = $this->getPointSaleModule(); | |||
$productPointSaleModule = $this->getProductPointSaleModule(); | |||
ProductPointSale::deleteAll(['id_product' => $product->id]); | |||
if (is_array($product->pointsSale) && count($product->pointsSale)) { | |||
foreach ($product->pointsSale as $key => $idPointSale) { | |||
$pointSale = $pointSaleManager->findOnePointSaleById($idPointSale); | |||
$pointSale = $pointSaleModule->findOnePointSaleById($idPointSale); | |||
if ($pointSale) { | |||
$productPointSaleManager->createProductPointSale( | |||
$productPointSaleModule->createProductPointSale( | |||
$product, | |||
$pointSale, | |||
($product->available_on_points_sale) ? false : true | |||
@@ -319,13 +319,13 @@ class ProductController extends BackendController | |||
*/ | |||
public function actionDelete(int $id, bool $confirm = false) | |||
{ | |||
$productContainer = $this->getProductContainer(); | |||
$productDistributionContainer = $this->getProductDistributionContainer(); | |||
$productModule = $this->getProductModule(); | |||
$productDistributionModule = $this->getProductDistributionModule(); | |||
$product = $this->findModel($id); | |||
if ($confirm) { | |||
$productContainer->getBuilder()->updateStatusDeleted($product); | |||
$productDistributionContainer->getBuilder()->disableProductDistributionsIncomingByProduct($product); | |||
$productModule->getBuilder()->updateStatusDeleted($product); | |||
$productDistributionModule->getBuilder()->disableProductDistributionsIncomingByProduct($product); | |||
$this->setFlash('success', 'Produit <strong>' . Html::encode($product->name) . '</strong> supprimé'); | |||
} else { | |||
@@ -355,13 +355,13 @@ class ProductController extends BackendController | |||
{ | |||
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; | |||
$distributionManager = $this->getDistributionManager(); | |||
$distributionModule = $this-> getDistributionModule(); | |||
$product = $this->findModel($id); | |||
$product->status = (int) $status; | |||
$product->save(); | |||
$distributionManager->addProductIncomingDistributions($product); | |||
$distributionModule->addProductIncomingDistributions($product); | |||
return ['success', 'id' => $id, 'status' => $status]; | |||
} | |||
@@ -373,10 +373,10 @@ class ProductController extends BackendController | |||
*/ | |||
public function actionPriceImport() | |||
{ | |||
$productManager = $this->getProductManager(); | |||
$productPriceManager = $this->getProductPriceManager(); | |||
$userGroupManager = $this->getUserGroupManager(); | |||
$pointSaleManager = $this->getPointSaleManager(); | |||
$productModule = $this->getProductModule(); | |||
$productPriceModule = $this->getProductPriceModule(); | |||
$userGroupModule = $this->getUserGroupModule(); | |||
$pointSaleModule = $this->getPointSaleModule(); | |||
$userModule = $this->getUserModule(); | |||
$model = new ProductPriceUploadForm(); | |||
@@ -412,10 +412,10 @@ class ProductController extends BackendController | |||
$quantityFrom = (float)$productPriceCsv[4]; | |||
$price = (float) str_replace(',', '.', $productPriceCsv[5]); | |||
$product = $productName ? $productManager->findOneProductByName($productName) : null; | |||
$product = $productName ? $productModule->findOneProductByName($productName) : null; | |||
$user = (count($userArray) > 1) ? $userModule->findOneUserById((int)$userArray[1]) : null; | |||
$userGroup = $userGroupName ? $userGroupManager->findOneUserGroupByName($userGroupName) : null; | |||
$pointSale = $pointSaleName ? $pointSaleManager->findOnePointSaleByName($pointSaleName) : null; | |||
$userGroup = $userGroupName ? $userGroupModule->findOneUserGroupByName($userGroupName) : null; | |||
$pointSale = $pointSaleName ? $pointSaleModule->findOnePointSaleByName($pointSaleName) : null; | |||
if (($productName && !$product) | |||
|| (count($userArray) > 1 && !$user) | |||
@@ -431,20 +431,20 @@ class ProductController extends BackendController | |||
// prix de base | |||
if (!$user && !$userGroup && !$pointSale && !$quantityFrom) { | |||
$product->price = $price; | |||
$productManager->saveUpdate($product); | |||
$productModule->saveUpdate($product); | |||
$countUpdate++; | |||
} // prix spécifique | |||
else { | |||
$productPrice = $productPriceManager->findOneProductPriceBy($product, $user, $userGroup, $pointSale, $quantityFrom); | |||
$productPrice = $productPriceModule->findOneProductPriceBy($product, $user, $userGroup, $pointSale, $quantityFrom); | |||
if ($productPrice) { | |||
$productPrice->price = $price; | |||
$productPriceManager->saveUpdate($productPrice); | |||
$productPriceModule->saveUpdate($productPrice); | |||
$countUpdate++; | |||
} | |||
// Création automatique du prix spécifique | |||
else { | |||
$productPrice = $productPriceManager->instanciateProductPrice($product, $price, $user, $userGroup, $pointSale, $quantityFrom); | |||
$productPriceManager->saveCreate($productPrice); | |||
$productPrice = $productPriceModule->instanciateProductPrice($product, $price, $user, $userGroup, $pointSale, $quantityFrom); | |||
$productPriceModule->saveCreate($productPrice); | |||
$countCreate ++; | |||
} | |||
} | |||
@@ -479,8 +479,8 @@ class ProductController extends BackendController | |||
*/ | |||
public function actionPriceExport() | |||
{ | |||
$productManager = $this->getProductManager(); | |||
$productPriceManager = $this->getProductPriceManager(); | |||
$productModule = $this->getProductModule(); | |||
$productPriceModule = $this->getProductPriceModule(); | |||
$userModule = $this->getUserModule(); | |||
$data = []; | |||
@@ -494,7 +494,7 @@ class ProductController extends BackendController | |||
"Prix HT" | |||
]; | |||
$productArray = $productManager->findProducts(); | |||
$productArray = $productModule->findProducts(); | |||
foreach($productArray as $product) { | |||
// prix produit | |||
@@ -509,7 +509,7 @@ class ProductController extends BackendController | |||
// prix spécifiques | |||
foreach($product->productPrice as $productPrice) { | |||
$productPrice = $productPriceManager->findOneProductPriceById($productPrice->id); | |||
$productPrice = $productPriceModule->findOneProductPriceById($productPrice->id); | |||
if($productPrice->user || $productPrice->userGroup || $productPrice->pointSale || $productPrice->from_quantity) { | |||
$data[] = [ | |||
@@ -534,9 +534,9 @@ class ProductController extends BackendController | |||
*/ | |||
protected function findModel(int $id) | |||
{ | |||
$productManager = $this->getProductManager(); | |||
$productModule = $this->getProductModule(); | |||
if (($product = $productManager->findOneProductById($id)) !== null) { | |||
if (($product = $productModule->findOneProductById($id)) !== null) { | |||
return $product; | |||
} else { | |||
throw new NotFoundHttpException('The requested page does not exist.'); | |||
@@ -545,8 +545,8 @@ class ProductController extends BackendController | |||
protected function findModelProductPrice($id) | |||
{ | |||
$productPriceManager = $this->getProductPriceManager(); | |||
if (($productPrice = $productPriceManager->findOneProductPriceById($id)) !== null) { | |||
$productPriceModule = $this->getProductPriceModule(); | |||
if (($productPrice = $productPriceModule->findOneProductPriceById($id)) !== null) { | |||
return $productPrice; | |||
} else { | |||
throw new NotFoundHttpException('The requested page does not exist.'); |
@@ -85,19 +85,19 @@ class QuotationController extends DocumentController | |||
public function actionTransform($id) | |||
{ | |||
$quotationManager = $this->getQuotationManager(); | |||
$invoiceManager = $this->getInvoiceManager(); | |||
$quotationModule = $this->getQuotationModule(); | |||
$invoiceModule = $this-> getInvoiceModule(); | |||
$quotation = $this->findModel($id); | |||
if ($quotationManager->isStatusValid($quotation)) { | |||
if ($quotationModule->isStatusValid($quotation)) { | |||
$invoice = $invoiceManager->instanciateInvoice(); | |||
$invoiceManager->initTaxCalculationMethod($invoice); | |||
$invoice = $invoiceModule->instanciateInvoice(); | |||
$invoiceModule->initTaxCalculationMethod($invoice); | |||
$invoice->id_producer = GlobalParam::getCurrentProducerId(); | |||
$invoice->id_user = $quotation->id_user; | |||
$invoice->address = $quotation->address; | |||
$invoice->comment = $quotation->comment; | |||
$invoice->name = str_replace(['Devis', 'devis'], 'Facture', $quotation->name); | |||
$invoiceManager->saveCreate($invoice); | |||
$invoiceModule->saveCreate($invoice); | |||
Order::updateAll([ | |||
'order.id_invoice' => $invoice->id |
@@ -78,13 +78,13 @@ class ReportController extends BackendController | |||
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; | |||
$userModule = $this->getUserModule(); | |||
$pointSaleManager = $this->getPointSaleManager(); | |||
$distributionManager = $this->getDistributionManager(); | |||
$pointSaleModule = $this->getPointSaleModule(); | |||
$distributionModule = $this-> getDistributionModule(); | |||
$usersArray = $userModule->findUsers(); | |||
$pointsSaleArray = $pointSaleManager->findPointSales(); | |||
$firstDistribution = $distributionManager->findOneFirstDistribution(); | |||
$lastDistribution = $distributionManager->findOneLastDistribution(); | |||
$pointsSaleArray = $pointSaleModule->findPointSales(); | |||
$firstDistribution = $distributionModule->findOneFirstDistribution(); | |||
$lastDistribution = $distributionModule->findOneLastDistribution(); | |||
$firstYear = date('Y', strtotime($firstDistribution->date)); | |||
$lastYear = date('Y', strtotime($lastDistribution->date)); | |||
@@ -94,7 +94,7 @@ class ReportController extends BackendController | |||
} | |||
$distributionsByMonthArray = []; | |||
$distributionsArray = $distributionManager->findDistributionsActive(); | |||
$distributionsArray = $distributionModule->findDistributionsActive(); | |||
foreach ($distributionsArray as $distribution) { | |||
$month = date('Y-m', strtotime($distribution->date)); | |||
if (!isset($distributionsByMonthArray[$month])) { |
@@ -140,7 +140,7 @@ class SiteController extends BackendController | |||
public function actionSwitchProducer(int $id) | |||
{ | |||
$user = $this->getUserCurrent(); | |||
$producer = $this->getProducerContainer()->getRepository()->findOneProducerById($id); | |||
$producer = $this->getProducerModule()->getRepository()->findOneProducerById($id); | |||
if($producer) { | |||
$this->getUserModule()->getBuilder()->switchProducer($user, $producer); |
@@ -113,7 +113,7 @@ class StatsAdminController extends BackendController | |||
public function actionCustomerOrders() | |||
{ | |||
$orderManager = $this->getOrderManager(); | |||
$orderModule = $this->getOrderModule(); | |||
$data = []; | |||
$dataLabels = []; | |||
$dateStart = date('Y-m-d', time() - 60 * 60 * 24 * 30); | |||
@@ -126,7 +126,7 @@ class StatsAdminController extends BackendController | |||
foreach ($period as $date) { | |||
$dateFormat = date('d/m/Y', $date->getTimestamp()); | |||
$dataLabels[] = $dateFormat; | |||
$data[] = $orderManager->countGlobalOrdersByDateAndOrigin($date); | |||
$data[] = $orderModule->countGlobalOrdersByDateAndOrigin($date); | |||
} | |||
return $this->render('customer_orders', [ |
@@ -69,15 +69,15 @@ class StatsController extends BackendController | |||
*/ | |||
public function actionIndex(int $year = null) | |||
{ | |||
$producerManager = $this->getProducerManager(); | |||
$producerModule = $this->getProducerModule(); | |||
$producerCurrent = $this->getProducerCurrent(); | |||
if(!$year) { | |||
$year = date('Y'); | |||
} | |||
$yearsWithTurnoverArray = $producerManager->getYearsWithTurnover($producerCurrent); | |||
$dataChartTurnover = $producerManager->getDatasChartTurnoverStatistics($producerCurrent, $year); | |||
$yearsWithTurnoverArray = $producerModule->getYearsWithTurnover($producerCurrent); | |||
$dataChartTurnover = $producerModule->getDatasChartTurnoverStatistics($producerCurrent, $year); | |||
return $this->render('index', [ | |||
'yearCurrent' => $year, | |||
@@ -95,13 +95,13 @@ class StatsController extends BackendController | |||
*/ | |||
public function actionProducts(int $year = 0, $section = 1) | |||
{ | |||
$productManager = $this->getProductManager(); | |||
$productModule = $this->getProductModule(); | |||
if (!$year) { | |||
$year = date('Y'); | |||
} | |||
$productsArray = $productManager->findProducts(); | |||
$productsArray = $productModule->findProducts(); | |||
$dataProducts = []; | |||
$dataProducts[self::TOTALS] = ['max' => [], 'orders' => []]; |
@@ -91,18 +91,18 @@ class SubscriptionController extends BackendController | |||
*/ | |||
public function actionCreate($idOrder = 0) | |||
{ | |||
$orderManager = $this->getOrderManager(); | |||
$producerManager = $this->getProducerManager(); | |||
$productManager = $this->getProductManager(); | |||
$subscriptionManger = $this->getSubscriptionManager(); | |||
$distributionManager = $this->getDistributionManager(); | |||
$orderModule = $this->getOrderModule(); | |||
$producerModule = $this->getProducerModule(); | |||
$productModule = $this->getProductModule(); | |||
$subscriptionManger = $this->getSubscriptionModule(); | |||
$distributionModule = $this-> getDistributionModule(); | |||
$model = new SubscriptionForm(); | |||
$model->isAdmin = true; | |||
$model->id_producer = GlobalParam::getCurrentProducerId(); | |||
if ($idOrder) { | |||
$order = $orderManager->findOneOrderById($idOrder); | |||
$order = $orderModule->findOneOrderById($idOrder); | |||
if ($order) { | |||
$model->id_user = $order->id_user; | |||
$model->username = $order->username; | |||
@@ -111,7 +111,7 @@ class SubscriptionController extends BackendController | |||
$dateDay = strtolower(date('l', strtotime($order->distribution->date))); | |||
$model->$dateDay = 1; | |||
$model->week_frequency = 1; | |||
if ($model->id_user && $producerManager->getConfig('credit')) { | |||
if ($model->id_user && $producerModule->getConfig('credit')) { | |||
$model->auto_payment = 1; | |||
} | |||
@@ -124,14 +124,14 @@ class SubscriptionController extends BackendController | |||
} | |||
// produits | |||
$productsArray = $productManager->findProducts(); | |||
$productsArray = $productModule->findProducts(); | |||
if ($model->load(\Yii::$app->request->post()) && $model->validate() && $model->save()) { | |||
$this->setFlash('success', 'Abonnement ajouté'); | |||
$subscription = $subscriptionManger->findOneSubscriptionById($model->id); | |||
$matchedDistributionsArray = $distributionManager->findDistributionsIncomingMatchWithSubscrtiption($subscription); | |||
$matchedDistributionsArray = $distributionModule->findDistributionsIncomingMatchWithSubscrtiption($subscription); | |||
if (count($matchedDistributionsArray)) { | |||
return $this->redirect(['subscription/update-distributions', 'idSubscription' => $subscription->id]); | |||
@@ -151,15 +151,15 @@ class SubscriptionController extends BackendController | |||
*/ | |||
public function actionUpdate($id) | |||
{ | |||
$subscriptionManager = $this->getSubscriptionManager(); | |||
$productSubscriptionManager = $this->getProductSubscriptionManager(); | |||
$productManager = $this->getProductManager(); | |||
$distributionManager = $this->getDistributionManager(); | |||
$orderManager = $this->getOrderManager(); | |||
$subscriptionModule = $this->getSubscriptionModule(); | |||
$productSubscriptionModule = $this->getProductSubscriptionModule(); | |||
$productModule = $this->getProductModule(); | |||
$distributionModule = $this-> getDistributionModule(); | |||
$orderModule = $this->getOrderModule(); | |||
$model = new SubscriptionForm; | |||
$model->isAdmin = true; | |||
$subscription = $subscriptionManager->findOneSubscriptionById($id); | |||
$subscription = $subscriptionModule->findOneSubscriptionById($id); | |||
if ($subscription) { | |||
$model->id = $id; | |||
@@ -186,7 +186,7 @@ class SubscriptionController extends BackendController | |||
$model->comment = $subscription->comment; | |||
} | |||
$arrayProductsSubscription = $productSubscriptionManager->findProductSubscriptionsBySubscription($subscription); | |||
$arrayProductsSubscription = $productSubscriptionModule->findProductSubscriptionsBySubscription($subscription); | |||
foreach ($arrayProductsSubscription as $productSubscription) { | |||
$model->products['product_' . $productSubscription->id_product] = $productSubscription->quantity; | |||
} | |||
@@ -195,7 +195,7 @@ class SubscriptionController extends BackendController | |||
} | |||
// produits | |||
$productsArray = $productManager->findProducts(); | |||
$productsArray = $productModule->findProducts(); | |||
if ($model->load(\Yii::$app->request->post()) && $model->validate()) { | |||
@@ -205,11 +205,11 @@ class SubscriptionController extends BackendController | |||
if ($model->save()) { | |||
$subscription = $subscriptionManager->findOneSubscriptionById($model->id); | |||
$subscription = $subscriptionModule->findOneSubscriptionById($model->id); | |||
$messageOrdersDeleted = ''; | |||
if ($model->date_end) { | |||
$countOrdersDeleted = $orderManager->deleteOrdersIncomingDistributionsFromSubscription($subscription, true); | |||
$countOrdersDeleted = $orderModule->deleteOrdersIncomingDistributionsFromSubscription($subscription, true); | |||
if ($countOrdersDeleted) { | |||
$messageOrdersDeleted = '<br />' . $countOrdersDeleted . ' commandes supprimées'; | |||
} | |||
@@ -217,7 +217,7 @@ class SubscriptionController extends BackendController | |||
$this->setFlash('success', 'Abonnement modifié' . $messageOrdersDeleted); | |||
$matchedDistributionsArray = $distributionManager->findDistributionsIncomingMatchWithSubscrtiption($subscription); | |||
$matchedDistributionsArray = $distributionModule->findDistributionsIncomingMatchWithSubscrtiption($subscription); | |||
if (count($matchedDistributionsArray)) { | |||
return $this->redirect(['subscription/update-distributions', 'idSubscription' => $subscription->id, 'update' => true]); | |||
} else { | |||
@@ -237,12 +237,12 @@ class SubscriptionController extends BackendController | |||
*/ | |||
public function actionDelete(int $id) | |||
{ | |||
$subscriptionManager = $this->getSubscriptionManager(); | |||
$orderManager = $this->getOrderManager(); | |||
$subscriptionModule = $this->getSubscriptionModule(); | |||
$orderModule = $this->getOrderModule(); | |||
$subscription = $subscriptionManager->findOneSubscriptionById($id); | |||
$orderManager->deleteOrdersIncomingDistributionsFromSubscription($subscription); | |||
$subscriptionManager->deleteSubscription($subscription); | |||
$subscription = $subscriptionModule->findOneSubscriptionById($id); | |||
$orderModule->deleteOrdersIncomingDistributionsFromSubscription($subscription); | |||
$subscriptionModule->deleteSubscription($subscription); | |||
$this->setFlash('success', 'Abonnement supprimé'); | |||
@@ -251,19 +251,19 @@ class SubscriptionController extends BackendController | |||
public function actionUpdateDistributions(int $idSubscription, bool $generate = false, bool $update = false) | |||
{ | |||
$subscriptionManager = $this->getSubscriptionManager(); | |||
$distributionManager = $this->getDistributionManager(); | |||
$orderManager = $this->getOrderManager(); | |||
$subscriptionModule = $this->getSubscriptionModule(); | |||
$distributionModule = $this-> getDistributionModule(); | |||
$orderModule = $this->getOrderModule(); | |||
$subscription = $subscriptionManager->findOneSubscriptionById($idSubscription); | |||
$matchedDistributionsArray = $distributionManager->findDistributionsIncomingMatchWithSubscrtiption($subscription); | |||
$subscription = $subscriptionModule->findOneSubscriptionById($idSubscription); | |||
$matchedDistributionsArray = $distributionModule->findDistributionsIncomingMatchWithSubscrtiption($subscription); | |||
if ($generate) { | |||
if ($update) { | |||
$orderManager->deleteOrdersIncomingDistributionsFromSubscription($subscription); | |||
$orderModule->deleteOrdersIncomingDistributionsFromSubscription($subscription); | |||
} | |||
foreach ($matchedDistributionsArray as $distribution) { | |||
$orderManager->createOrderFromSubscription($subscription, $distribution->date); | |||
$orderModule->createOrderFromSubscription($subscription, $distribution->date); | |||
} | |||
$this->setFlash('success', 'Commandes ' . ($update ? 're-' : '') . 'générées dans les distributions futures.'); | |||
return $this->redirect(['subscription/index']); | |||
@@ -280,7 +280,7 @@ class SubscriptionController extends BackendController | |||
{ | |||
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; | |||
$productManager = $this->getProductManager(); | |||
$productModule = $this->getProductModule(); | |||
$productsQuery = Product::find() | |||
->where(['id_producer' => GlobalParam::getCurrentProducerId()]) | |||
@@ -296,7 +296,7 @@ class SubscriptionController extends BackendController | |||
$productsArray = $productsQuery->asArray()->orderBy('order ASC')->all(); | |||
foreach ($productsArray as &$theProduct) { | |||
$theProduct['wording_unit'] = $productManager->strUnit($theProduct['unit'], 'wording_short'); | |||
$theProduct['wording_unit'] = $productModule->strUnit($theProduct['unit'], 'wording_short'); | |||
if (isset($theProduct['productSubscription'][0])) { | |||
$theProduct['quantity'] = $theProduct['productSubscription'][0]['quantity'] * Product::$unitsArray[$theProduct['unit']]['coefficient']; |
@@ -83,12 +83,12 @@ class SupportController extends BackendController | |||
public function actionCreate() | |||
{ | |||
$userCurrent = $this->getUserCurrent(); | |||
$ticketManager = $this->getTicketManager(); | |||
$ticketMessageManager = $this->getTicketMessageManager(); | |||
$ticket = $ticketManager->instanciateTicket($this->getProducerCurrent(), $userCurrent); | |||
$ticketModule = $this->getTicketModule(); | |||
$ticketMessageModule = $this->getTicketMessageModule(); | |||
$ticket = $ticketModule->instanciateTicket($this->getProducerCurrent(), $userCurrent); | |||
if ($ticket->load(\Yii::$app->request->post()) && $ticket->validate() && $ticketManager->create($ticket)) { | |||
$ticketMessageManager->createTicketMessage($ticket, $userCurrent, $ticket->message); | |||
if ($ticket->load(\Yii::$app->request->post()) && $ticket->validate() && $ticketModule->create($ticket)) { | |||
$ticketMessageModule->createTicketMessage($ticket, $userCurrent, $ticket->message); | |||
$this->setFlash('success', 'Le ticket a bien été créé.'); | |||
return $this->redirect(['view', 'id' => $ticket->id]); | |||
} else { | |||
@@ -100,12 +100,12 @@ class SupportController extends BackendController | |||
public function actionView(int $id) | |||
{ | |||
$ticketManager = $this->getTicketManager(); | |||
$ticketMessageManager = $this->getTicketMessageManager(); | |||
$ticketModule = $this->getTicketModule(); | |||
$ticketMessageModule = $this->getTicketMessageModule(); | |||
$ticket = $this->findTicket($id); | |||
$ticketManager->viewTicket($ticket, $this->getUserCurrent()); | |||
$ticketMessage = $ticketMessageManager->instanciateTicketMessage($ticket, $this->getUserCurrent()); | |||
if ($ticketMessage->load(\Yii::$app->request->post()) && $ticketManager->createTicketMessage($ticketMessage)) { | |||
$ticketModule->viewTicket($ticket, $this->getUserCurrent()); | |||
$ticketMessage = $ticketMessageModule->instanciateTicketMessage($ticket, $this->getUserCurrent()); | |||
if ($ticketMessage->load(\Yii::$app->request->post()) && $ticketModule->createTicketMessage($ticketMessage)) { | |||
return $this->redirect(['view', 'id' => $ticket->id, '#' => 'bottom']); | |||
} | |||
@@ -117,28 +117,28 @@ class SupportController extends BackendController | |||
public function actionClose(int $id) | |||
{ | |||
$ticketManager = $this->getTicketManager(); | |||
$ticketModule = $this->getTicketModule(); | |||
$ticket = $this->findTicket($id); | |||
$ticketManager->closeTicket($ticket); | |||
$ticketModule->closeTicket($ticket); | |||
$this->addFlash('success', "Le ticket <strong>".Html::encode($ticket->subject)."</strong> a bien été fermé."); | |||
return $this->redirect(['index']); | |||
} | |||
public function actionOpen(int $id) | |||
{ | |||
$ticketManager = $this->getTicketManager(); | |||
$ticketModule = $this->getTicketModule(); | |||
$ticket = $this->findTicket($id); | |||
$ticketManager->openTicket($ticket); | |||
$ticketModule->openTicket($ticket); | |||
$this->addFlash('success', "Le ticket a bien été ouvert."); | |||
return $this->redirect(['index']); | |||
} | |||
public function findTicket(int $id) | |||
{ | |||
$ticketManager = $this->getTicketManager(); | |||
$ticket = $ticketManager->findOneTicketById($id); | |||
$ticketModule = $this->getTicketModule(); | |||
$ticket = $ticketModule->findOneTicketById($id); | |||
if ($ticket && $ticketManager->hasTicketAccess($ticket, $this->getUserCurrent())) { | |||
if ($ticket && $ticketModule->hasTicketAccess($ticket, $this->getUserCurrent())) { | |||
return $ticket; | |||
} else { | |||
throw new NotFoundHttpException("Le ticket est introuvable."); |
@@ -88,7 +88,7 @@ class TaxRateAdminController extends BackendController | |||
public function actionCreate() | |||
{ | |||
$model = $this->getTaxRateManager()->instanciateTaxRate(); | |||
$model = $this-> getTaxRateModule()->instanciateTaxRate(); | |||
if ($model->load(\Yii::$app->request->post()) && $model->save()) { | |||
$this->setFlash('success', 'Taxe créée.'); | |||
@@ -116,9 +116,9 @@ class TaxRateAdminController extends BackendController | |||
public function actionDelete(int $id) | |||
{ | |||
$taxRateManager = $this->getTaxRateManager(); | |||
$taxRateModule = $this-> getTaxRateModule(); | |||
$taxRate = $this->findModel($id); | |||
$taxRateManager->delete($taxRate); | |||
$taxRateModule->delete($taxRate); | |||
$this->setFlash('success', 'Taxe supprimé'); | |||
@@ -127,8 +127,8 @@ class TaxRateAdminController extends BackendController | |||
protected function findModel($id) | |||
{ | |||
$taxRateManager = $this->getTaxRateManager(); | |||
if (($taxRate = $taxRateManager->findOneTaxRateById($id)) !== null) { | |||
$taxRateModule = $this-> getTaxRateModule(); | |||
if (($taxRate = $taxRateModule->findOneTaxRateById($id)) !== null) { | |||
return $taxRate; | |||
} else { | |||
throw new NotFoundHttpException('The requested page does not exist.'); |
@@ -88,7 +88,7 @@ class UserController extends BackendController | |||
bool $sectionSubscribers = false, | |||
bool $sectionInactiveUsers = false) | |||
{ | |||
$pointSaleManager = $this->getPointSaleManager(); | |||
$pointSaleModule = $this->getPointSaleModule(); | |||
$searchModel = new UserSearch(); | |||
$dataProvider = $searchModel->search([ | |||
@@ -105,7 +105,7 @@ class UserController extends BackendController | |||
]); | |||
$producer = $this->getProducerCurrent(); | |||
$pointsSaleArray = $pointSaleManager->findPointSales(); | |||
$pointsSaleArray = $pointSaleModule->findPointSales(); | |||
return $this->render('index', [ | |||
'searchModel' => $searchModel, | |||
@@ -121,7 +121,7 @@ class UserController extends BackendController | |||
public function actionCreate() | |||
{ | |||
$userModule = $this->getUserModule(); | |||
$producerManager = $this->getProducerManager(); | |||
$producerModule = $this->getProducerModule(); | |||
$producerCurrent = $this->getProducerCurrent(); | |||
$model = $userModule->instanciateUser(); | |||
$posts = Yii::$app->request->post(); | |||
@@ -132,7 +132,7 @@ class UserController extends BackendController | |||
} | |||
if ($userExist) { | |||
$producerManager->addUser($userExist, $producerCurrent); | |||
$producerModule->addUser($userExist, $producerCurrent); | |||
$this->processLinkPointSale($userExist); | |||
$this->processLinkUserGroup($userExist); | |||
$this->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."); | |||
@@ -177,7 +177,7 @@ class UserController extends BackendController | |||
public function actionUpdate($id) | |||
{ | |||
$userModule = $this->getUserModule(); | |||
$pointSaleManager = $this->getPointSaleManager(); | |||
$pointSaleModule = $this->getPointSaleModule(); | |||
$model = $this->findModel($id); | |||
$previousMail = $model->email; | |||
@@ -241,32 +241,32 @@ class UserController extends BackendController | |||
return $this->render('update', array_merge($this->initForm($model), [ | |||
'model' => $model, | |||
'pointSaleBillingArray' => $pointSaleManager->findByBillingUser($model) | |||
'pointSaleBillingArray' => $pointSaleModule->findByBillingUser($model) | |||
])); | |||
} | |||
public function initForm($model) | |||
{ | |||
$userPointSaleManager = $this->getUserPointSaleManager(); | |||
$userUserGroupManager = $this->getUserUserGroupManager(); | |||
$userProducerManager = $this->getUserProducerManager(); | |||
$userGroupManager = $this->getUserGroupManager(); | |||
$userPointSaleModule = $this->getUserPointSaleModule(); | |||
$userUserGroupModule = $this->getUserUserGroupModule(); | |||
$userProducerModule = $this->getUserProducerModule(); | |||
$userGroupModule = $this->getUserGroupModule(); | |||
if ($model->id) { | |||
$userPointSaleArray = $userPointSaleManager->findUserPointSalesByUser($model); | |||
$userPointSaleArray = $userPointSaleModule->findUserPointSalesByUser($model); | |||
if ($userPointSaleArray && count($userPointSaleArray) > 0) { | |||
foreach ($userPointSaleArray as $userPointSale) { | |||
$model->points_sale[] = $userPointSale->id_point_sale; | |||
} | |||
} | |||
$userUserGroupsArray = $userUserGroupManager->findUserUserGroupsByUser($model); | |||
$userUserGroupsArray = $userUserGroupModule->findUserUserGroupsByUser($model); | |||
if ($userUserGroupsArray && count($userUserGroupsArray) > 0) { | |||
foreach ($userUserGroupsArray as $userUserGroup) { | |||
$model->user_groups[] = $userUserGroup->id_user_group; | |||
} | |||
} | |||
$userProducer = $userProducerManager->findOneUserProducer($model); | |||
$userProducer = $userProducerModule->findOneUserProducer($model); | |||
$model->product_price_percent = $userProducer->product_price_percent; | |||
} | |||
@@ -282,7 +282,7 @@ class UserController extends BackendController | |||
}]) | |||
->all(); | |||
$userGroupsArray = $userGroupManager->findUserGroups(); | |||
$userGroupsArray = $userGroupModule->findUserGroups(); | |||
return [ | |||
'pointsSaleArray' => $pointsSaleArray, | |||
@@ -296,16 +296,16 @@ class UserController extends BackendController | |||
public function processLinkPointSale(User $modelUser) | |||
{ | |||
$posts = Yii::$app->request->post(); | |||
$userPointSaleManager = $this->getUserPointSaleManager(); | |||
$pointSaleManager = $this->getPointSaleManager(); | |||
$userPointSaleModule = $this->getUserPointSaleModule(); | |||
$pointSaleModule = $this->getPointSaleModule(); | |||
UserPointSale::deleteAll([ | |||
'id_user' => $modelUser->id | |||
]); | |||
if (is_array($modelUser->points_sale) && count($modelUser->points_sale) > 0) { | |||
foreach ($modelUser->points_sale as $pointSaleId) { | |||
$pointSale = $pointSaleManager->findOnePointSaleById($pointSaleId); | |||
$userPointSale = $userPointSaleManager->findOneUserPointSale($modelUser, $pointSale); | |||
$pointSale = $pointSaleModule->findOnePointSaleById($pointSaleId); | |||
$userPointSale = $userPointSaleModule->findOneUserPointSale($modelUser, $pointSale); | |||
if (!$userPointSale) { | |||
$userPointSale = new UserPointSale; | |||
@@ -362,17 +362,17 @@ class UserController extends BackendController | |||
public function actionDelete(int $id) | |||
{ | |||
$userModule = $this->getUserModule(); | |||
$userProducerManager = $this->getUserProducerManager(); | |||
$userProducerModule = $this->getUserProducerModule(); | |||
$user = $userModule->findOneUserById($id); | |||
$userProducer = $userProducerManager->findOneUserProducer($user); | |||
$userProducer = $userProducerModule->findOneUserProducer($user); | |||
if ($userProducer) { | |||
if($userProducerManager->hasOutstandingCredit($userProducer)) { | |||
if($userProducerModule->hasOutstandingCredit($userProducer)) { | |||
$this->setFlash('error', "Vous ne pouvez pas supprimer cet utilisateur car il a toujours du crédit en cours."); | |||
} | |||
else { | |||
$userProducerManager->unlinkUserProducer($userProducer); | |||
$userProducerModule->unlinkUserProducer($userProducer); | |||
$this->setFlash('success', 'L\'utilisateur a bien été supprimé de votre établissement.'); | |||
} | |||
} else { | |||
@@ -391,22 +391,33 @@ class UserController extends BackendController | |||
public function actionCredit(int $id) | |||
{ | |||
$userModule = $this->getUserModule(); | |||
$paymentContainer = $this->getPaymentContainer(); | |||
$userProducerContainer = $this->getUserProducerContainer(); | |||
$paymentModule = $this->getPaymentModule(); | |||
$userProducerModule = $this->getUserProducerModule(); | |||
$user = $userModule->findOneUserById($id); | |||
$userProducer = $userProducerContainer->getRepository()->findOneUserProducer($user); | |||
$userProducer = $userProducerModule->getRepository()->findOneUserProducer($user); | |||
if ($userProducer) { | |||
$creditForm = new CreditForm(); | |||
if ($creditForm->load(\Yii::$app->request->post()) && $creditForm->validate()) { | |||
$paymentContainer->getUtils() | |||
->creditOrDebitUser($creditForm->type, $user, $creditForm->amount, $creditForm->mean_payment, $this->getUserCurrent(), $creditForm->comment); | |||
$paymentModule->getUtils() | |||
->creditOrDebitUser( | |||
$creditForm->type, | |||
$user, | |||
$creditForm->amount, | |||
$creditForm->mean_payment, | |||
$this->getUserCurrent(), | |||
$creditForm->comment | |||
); | |||
if($creditForm->send_mail) { | |||
$paymentContainer->getNotifier() | |||
->notifyUserCreditMovement($user, $creditForm->type, $creditForm->amount); | |||
$paymentModule->getNotifier() | |||
->notifyUserCreditMovement( | |||
$user, | |||
$creditForm->type, | |||
$creditForm->amount | |||
); | |||
if(!$user->email) { | |||
$this->addFlash('error', "L'utilisateur n'a pas pu être prévenu car son adresse email n'est pas définie."); | |||
} | |||
@@ -421,7 +432,7 @@ class UserController extends BackendController | |||
'user' => $user, | |||
'userProducer' => $userProducer, | |||
'creditForm' => $creditForm, | |||
'dataProvider' => $paymentContainer->getRepository() | |||
'dataProvider' => $paymentModule->getRepository() | |||
->queryPaymentsCreditHistoryByUser($user)->getDataProvider(20), | |||
]); | |||
} else { | |||
@@ -436,10 +447,10 @@ class UserController extends BackendController | |||
public function actionStateCredit($idUser, $state) | |||
{ | |||
$userModule = $this->getUserModule(); | |||
$userProducerManager = $this->getUserProducerManager(); | |||
$userProducerModule = $this->getUserProducerModule(); | |||
$user = $userModule->findOneUserById($idUser); | |||
$userProducer = $userProducerManager->findOneUserProducer($user); | |||
$userProducer = $userProducerModule->findOneUserProducer($user); | |||
if ($userProducer) { | |||
$userProducer->credit_active = $state; | |||
@@ -496,7 +507,7 @@ class UserController extends BackendController | |||
$usersPointSaleHasOrder = 0) | |||
{ | |||
$userModule = $this->getUserModule(); | |||
$distributionManager = $this->getDistributionManager(); | |||
$distributionModule = $this-> getDistributionModule(); | |||
if ($idPointSale && !$usersPointSaleLink && !$usersPointSaleHasOrder) { | |||
$usersPointSaleLink = 1; | |||
@@ -556,7 +567,7 @@ class UserController extends BackendController | |||
return $this->redirect(['mail', 'idPointSale' => $idPointSale]); | |||
} | |||
$incomingDistributions = $distributionManager->findDistributionsIncoming(); | |||
$incomingDistributions = $distributionModule->findDistributionsIncoming(); | |||
$incomingDistributionsArray = ['0' => '--']; | |||
foreach ($incomingDistributions as $distribution) { | |||
$incomingDistributionsArray[$distribution->id] = strftime('%A %d %B %Y', strtotime($distribution->date)); |
@@ -92,9 +92,9 @@ class UserGroupController extends BackendController | |||
*/ | |||
public function actionCreate() | |||
{ | |||
$userGroupManager = $this->getUserGroupManager(); | |||
$userGroupModule = $this->getUserGroupModule(); | |||
$model = $userGroupManager->instanciateUserGroup(); | |||
$model = $userGroupModule->instanciateUserGroup(); | |||
$model->id_producer = GlobalParam::getCurrentProducerId(); | |||
if ($model->load(\Yii::$app->request->post()) && $model->save()) { | |||
@@ -142,8 +142,8 @@ class UserGroupController extends BackendController | |||
*/ | |||
protected function findModel(int $id) | |||
{ | |||
$userGroupManager = $this->getUserGroupManager(); | |||
if (($model = $userGroupManager->findOneUserGroupById($id)) !== null) { | |||
$userGroupModule = $this->getUserGroupModule(); | |||
if (($model = $userGroupModule->findOneUserGroupById($id)) !== null) { | |||
return $model; | |||
} else { | |||
throw new NotFoundHttpException('The requested page does not exist.'); |
@@ -39,9 +39,9 @@ termes. | |||
namespace backend\models; | |||
use common\helpers\GlobalParam; | |||
use common\logic\Payment\Wrapper\PaymentManager; | |||
use common\logic\User\User\Wrapper\UserModule; | |||
use common\logic\User\UserProducer\Wrapper\UserProducerManager; | |||
use common\logic\Payment\Module\PaymentModule; | |||
use common\logic\User\User\Module\UserModule; | |||
use common\logic\User\UserProducer\Module\UserProducerModule; | |||
use yii\base\Model; | |||
/** | |||
@@ -98,8 +98,8 @@ class CreditForm extends Model | |||
public function save() | |||
{ | |||
$userModule = UserModule::getInstance(); | |||
$userProducerManager = UserProducerManager::getInstance(); | |||
$paymentManager = PaymentManager::getInstance(); | |||
$userProducerModule = UserProducerModule::getInstance(); | |||
$paymentManager = PaymentModule::getInstance(); | |||
if ($this->validate()) { | |||
$user = $userModule->findOneUserById($this->id_user); | |||
@@ -108,7 +108,7 @@ class CreditForm extends Model | |||
// on prévient l'utilisateur que son compte vient d'être crédité | |||
if($this->send_mail) { | |||
$producer = GlobalParam::getCurrentProducer() ; | |||
$userProducer = $userProducerManager->findOneUserProducer($user); | |||
$userProducer = $userProducerModule->findOneUserProducer($user); | |||
\Yii::$app->mailerService->sendFromProducer( | |||
'Mouvement de crédit', |
@@ -41,10 +41,10 @@ namespace backend\models; | |||
use common\helpers\GlobalParam; | |||
use common\helpers\Mailjet; | |||
use common\logic\Distribution\Distribution\Model\Distribution; | |||
use common\logic\Distribution\Distribution\Wrapper\DistributionManager; | |||
use common\logic\Producer\Producer\Wrapper\ProducerManager; | |||
use common\logic\Distribution\Distribution\Module\DistributionModule; | |||
use common\logic\Producer\Producer\Module\ProducerModule; | |||
use common\logic\Product\Product\Model\Product; | |||
use common\logic\Product\Product\Wrapper\ProductManager; | |||
use common\logic\Product\Product\Module\ProductModule; | |||
use Yii; | |||
use yii\base\Model; | |||
use common\helpers\Price ; | |||
@@ -93,9 +93,9 @@ class MailForm extends Model | |||
*/ | |||
public function sendEmail($usersArray, $fromProducer = true) | |||
{ | |||
$productManager = ProductManager::getInstance(); | |||
$producerManager = ProducerManager::getInstance(); | |||
$distributionManager = DistributionManager::getInstance(); | |||
$productModule = ProductModule::getInstance(); | |||
$producerModule = ProducerModule::getInstance(); | |||
$distributionModule =DistributionModule::getInstance(); | |||
$mj = new \Mailjet\Client( | |||
Mailjet::getApiKey('public'), | |||
@@ -119,7 +119,7 @@ class MailForm extends Model | |||
if($distribution) { | |||
$linkOrder = $distributionManager->getLinkOrder($distribution); | |||
$linkOrder = $distributionModule->getLinkOrder($distribution); | |||
$dateOrder = strftime('%A %d %B %Y', strtotime($distribution->date)) ; | |||
$messageAutoHtml .= '<a href="'.$linkOrder.'">Passer ma commande du '.$dateOrder.'</a>' ; | |||
$messageAutoText .= 'Suivez ce lien pour passer votre commande du '.$dateOrder.' : | |||
@@ -154,8 +154,8 @@ Produits disponibles : | |||
$productDescription .= ' / '.$product->description ; | |||
} | |||
if($product->price) { | |||
$productDescription .= ' / '.Price::format($productManager->getPriceWithTax($product)) ; | |||
$productDescription .= ' ('. $productManager->strUnit($product->unit, 'wording_unit').')' ; | |||
$productDescription .= ' / '.Price::format($productModule->getPriceWithTax($product)) ; | |||
$productDescription .= ' ('. $productModule->strUnit($product->unit, 'wording_unit').')' ; | |||
} | |||
$messageAutoText .= '- '.$productDescription.' | |||
@@ -170,7 +170,7 @@ Produits disponibles : | |||
if($fromProducer) { | |||
$producer = GlobalParam::getCurrentProducer() ; | |||
$fromEmail = $producerManager->getEmailOpendistrib($producer) ; | |||
$fromEmail = $producerModule->getEmailOpendistrib($producer) ; | |||
$fromName = $producer->name ; | |||
// Message inscription newsletter |
@@ -38,16 +38,16 @@ termes. | |||
use common\helpers\GlobalParam; | |||
use common\logic\Order\Order\Model\Order; | |||
use common\logic\Order\Order\Wrapper\OrderManager; | |||
use common\logic\Producer\Producer\Wrapper\ProducerManager; | |||
use common\logic\Subscription\Subscription\Wrapper\SubscriptionManager; | |||
use common\logic\User\User\Wrapper\UserModule; | |||
use common\logic\Order\Order\Module\OrderModule; | |||
use common\logic\Producer\Producer\Module\ProducerModule; | |||
use common\logic\Subscription\Subscription\Module\SubscriptionModule; | |||
use common\logic\User\User\Module\UserModule; | |||
use yii\helpers\Html ; | |||
$userModule = UserModule::getInstance(); | |||
$orderManager = OrderManager::getInstance(); | |||
$subscriptionManager = SubscriptionManager::getInstance(); | |||
$producerManager = ProducerManager::getInstance(); | |||
$orderModule = OrderModule::getInstance(); | |||
$subscriptionModule = SubscriptionModule::getInstance(); | |||
$producerModule = ProducerModule::getInstance(); | |||
$this->setTitle('Tableau de bord'); | |||
@@ -160,9 +160,9 @@ $this->setTitle('Tableau de bord'); | |||
<td><?= date('d/m/Y à H:i', strtotime($subscription->created_at)); ?></td> | |||
<td><?= $userModule->getUsername($subscription->user); ?></td> | |||
<td><?= Html::encode($subscription->pointSale->name); ?></td> | |||
<td><?= $subscriptionManager->getProductsListAsHtml($subscription); ?></td> | |||
<td><?= $subscriptionManager->getDaysAsHtml($subscription); ?></td> | |||
<td><?= $subscriptionManager->getPeriodAsHtml($subscription); ?></td> | |||
<td><?= $subscriptionModule->getProductsListAsHtml($subscription); ?></td> | |||
<td><?= $subscriptionModule->getDaysAsHtml($subscription); ?></td> | |||
<td><?= $subscriptionModule->getPeriodAsHtml($subscription); ?></td> | |||
<td> | |||
<a href="<?= $this->getUrlManager()->createUrl(['subscription/update', 'id' => $subscription->id]) ?>" class="btn btn-default"> | |||
<span class="glyphicon glyphicon-pencil"></span> | |||
@@ -202,10 +202,10 @@ $this->setTitle('Tableau de bord'); | |||
</thead> | |||
<tbody> | |||
<?php foreach($ordersArray as $order): ?> | |||
<?php $orderManager->initOrder($order); ?> | |||
<?php $orderModule->initOrder($order); ?> | |||
<tr class="<?= $orderManager->getHistoryClass($order) ; ?>"> | |||
<td class="infos"><?= $orderManager->getLabelOrigin($order, true); ?></td> | |||
<tr class="<?= $orderModule->getHistoryClass($order) ; ?>"> | |||
<td class="infos"><?= $orderModule->getLabelOrigin($order, true); ?></td> | |||
<td class="date"> | |||
<div class="block-date"> | |||
<div class="day"><?= strftime('%A', strtotime($order->distribution->date)) ?></div> | |||
@@ -214,15 +214,15 @@ $this->setTitle('Tableau de bord'); | |||
</div> | |||
</td> | |||
<td> | |||
<?= $orderManager->getOrderUsername($order); ?><br /> | |||
<?= $orderModule->getOrderUsername($order); ?><br /> | |||
<?php if(strlen($order->comment)): ?> | |||
<div class="comment"><span class="glyphicon glyphicon-comment"></span> <?= nl2br(Html::encode($order->comment)) ; ?></div> | |||
<?php endif; ?> | |||
</td> | |||
<td><?= $orderManager->getCartSummary($order); ?></td> | |||
<td><?= $orderManager->getPointSaleSummary($order) ; ?></td> | |||
<td><?= $orderManager->getOrderAmountWithTax($order, Order::AMOUNT_TOTAL, true) ; ?></td> | |||
<td class="history"><?= $orderManager->getHistorySummary($order) ; ?></td> | |||
<td><?= $orderModule->getCartSummary($order); ?></td> | |||
<td><?= $orderModule->getPointSaleSummary($order) ; ?></td> | |||
<td><?= $orderModule->getOrderAmountWithTax($order, Order::AMOUNT_TOTAL, true) ; ?></td> | |||
<td class="history"><?= $orderModule->getHistorySummary($order) ; ?></td> | |||
</tr> | |||
<?php endforeach; ?> | |||
</tbody> |
@@ -42,9 +42,9 @@ use common\logic\PointSale\PointSale\Model\PointSale; | |||
use common\logic\Order\Order\Model\Order; | |||
use yii\helpers\Html; | |||
use yii\helpers\ArrayHelper; | |||
use common\logic\Document\DeliveryNote\Wrapper\DeliveryNoteManager; | |||
use common\logic\Document\DeliveryNote\Module\DeliveryNoteModule; | |||
$deliveryNoteManager = $this->getDeliveryNoteManager(); | |||
$deliveryNoteModule = $this->getDeliveryNoteModule(); | |||
$this->setTitle('Bons de livraison'); | |||
$this->addBreadcrumb($this->getTitle()); | |||
@@ -66,8 +66,8 @@ $this->addButton(['label' => 'Nouveau bon de livraison <span class="glyphicon gl | |||
'valid' => 'Valide', | |||
], | |||
'format' => 'raw', | |||
'value' => function ($model) use ($deliveryNoteManager) { | |||
return $deliveryNoteManager->getHtmlLabel($model); | |||
'value' => function ($model) use ($deliveryNoteModule) { | |||
return $deliveryNoteModule->getHtmlLabel($model); | |||
} | |||
], | |||
[ | |||
@@ -93,8 +93,8 @@ $this->addButton(['label' => 'Nouveau bon de livraison <span class="glyphicon gl | |||
'headerOptions' => ['class' => 'column-hide-on-mobile'], | |||
'filterOptions' => ['class' => 'column-hide-on-mobile'], | |||
'contentOptions' => ['class' => 'column-hide-on-mobile'], | |||
'value' => function ($model) use ($deliveryNoteManager) { | |||
$distribution = $deliveryNoteManager->getDistribution($model); | |||
'value' => function ($model) use ($deliveryNoteModule) { | |||
$distribution = $deliveryNoteModule->getDistribution($model); | |||
return $distribution ? date('d/m/Y', strtotime($distribution->date)) : ''; | |||
} | |||
], | |||
@@ -106,16 +106,16 @@ $this->addButton(['label' => 'Nouveau bon de livraison <span class="glyphicon gl | |||
'headerOptions' => ['class' => 'column-hide-on-mobile'], | |||
'filterOptions' => ['class' => 'column-hide-on-mobile'], | |||
'contentOptions' => ['class' => 'column-hide-on-mobile'], | |||
'value' => function ($model) use ($deliveryNoteManager) { | |||
$pointSale = $deliveryNoteManager->getPointSale($model); | |||
'value' => function ($model) use ($deliveryNoteModule) { | |||
$pointSale = $deliveryNoteModule->getPointSale($model); | |||
return $pointSale ? Html::encode($pointSale->name) : ''; | |||
} | |||
], | |||
[ | |||
'attribute' => 'amount', | |||
'header' => 'Montant', | |||
'value' => function ($deliveryNote) use ($deliveryNoteManager) { | |||
return $deliveryNoteManager->getAmountWithTax($deliveryNote, Order::INVOICE_AMOUNT_TOTAL, true); | |||
'value' => function ($deliveryNote) use ($deliveryNoteModule) { | |||
return $deliveryNoteModule->getAmountWithTax($deliveryNote, Order::INVOICE_AMOUNT_TOTAL, true); | |||
} | |||
], | |||
[ | |||
@@ -124,7 +124,7 @@ $this->addButton(['label' => 'Nouveau bon de livraison <span class="glyphicon gl | |||
'headerOptions' => ['class' => 'column-actions'], | |||
'contentOptions' => ['class' => 'column-actions'], | |||
'buttons' => [ | |||
'send' => function ($url, $deliveryNote) use ($deliveryNoteManager) { | |||
'send' => function ($url, $deliveryNote) use ($deliveryNoteModule) { | |||
return ((isset($deliveryNote->user) && strlen($deliveryNote->user->email) > 0) ? Html::a('<span class="glyphicon glyphicon-send"></span>', $url, [ | |||
'title' => 'Envoyer', 'class' => 'btn btn-default' | |||
]) : ''); | |||
@@ -134,8 +134,8 @@ $this->addButton(['label' => 'Nouveau bon de livraison <span class="glyphicon gl | |||
'title' => 'Télécharger', 'class' => 'btn btn-default' | |||
]); | |||
}, | |||
'validate' => function ($url, $deliveryNote) use ($deliveryNoteManager) { | |||
return ($deliveryNoteManager->isStatusDraft($deliveryNote) ? Html::a('<span class="glyphicon glyphicon-ok"></span>', $url, [ | |||
'validate' => function ($url, $deliveryNote) use ($deliveryNoteModule) { | |||
return ($deliveryNoteModule->isStatusDraft($deliveryNote) ? Html::a('<span class="glyphicon glyphicon-ok"></span>', $url, [ | |||
'title' => 'Valider', 'class' => 'btn btn-default' | |||
]) : ''); | |||
}, | |||
@@ -144,8 +144,8 @@ $this->addButton(['label' => 'Nouveau bon de livraison <span class="glyphicon gl | |||
'title' => 'Modifier', 'class' => 'btn btn-default' | |||
]); | |||
}, | |||
'delete' => function ($url, $deliveryNote) use ($deliveryNoteManager) { | |||
return ($deliveryNoteManager->isStatusDraft($deliveryNote) ? Html::a('<span class="glyphicon glyphicon-trash"></span>', $url, [ | |||
'delete' => function ($url, $deliveryNote) use ($deliveryNoteModule) { | |||
return ($deliveryNoteModule->isStatusDraft($deliveryNote) ? Html::a('<span class="glyphicon glyphicon-trash"></span>', $url, [ | |||
'title' => 'Supprimer', 'class' => 'btn btn-default' | |||
]) : ''); | |||
} |
@@ -37,13 +37,13 @@ termes. | |||
*/ | |||
use common\helpers\Price; | |||
use common\logic\Order\Order\Wrapper\OrderManager; | |||
use common\logic\Order\Order\Module\OrderModule; | |||
use common\logic\Product\Product\Model\Product; | |||
use common\logic\Product\Product\Wrapper\ProductManager; | |||
use common\logic\Product\Product\Module\ProductModule; | |||
use common\logic\User\UserProducer\Model\UserProducer; | |||
$productManager = ProductManager::getInstance(); | |||
$orderManager = OrderManager::getInstance(); | |||
$productModule = ProductModule::getInstance(); | |||
$orderModule = OrderModule::getInstance(); | |||
$dayWeek = date('w', strtotime($date)); | |||
$dayWeekArray = [0 => 'sunday', 1 => 'monday', 2 => 'tuesday', 3 => 'wednesday', 4 => 'thursday', 5 => 'friday', 6 => 'saturday']; | |||
@@ -79,7 +79,7 @@ foreach ($pointsSaleArray as $pointSale) { | |||
$strUser = ''; | |||
// username | |||
$strUser = $orderManager->getOrderUsername($order) ; | |||
$strUser = $orderModule->getOrderUsername($order) ; | |||
if(strlen($order->comment_point_sale)) | |||
{ | |||
@@ -108,7 +108,7 @@ foreach ($pointsSaleArray as $pointSale) { | |||
$add = false; | |||
foreach ($order->productOrder as $productOrder) { | |||
if($product->id == $productOrder->id_product) { | |||
$unit = ( $productManager->strUnit($productOrder->unit, 'wording_short', true) == 'p.') ? '' : ' '. $productManager->strUnit($productOrder->unit, 'wording_short', true) ; | |||
$unit = ( $productModule->strUnit($productOrder->unit, 'wording_short', true) == 'p.') ? '' : ' '. $productModule->strUnit($productOrder->unit, 'wording_short', true) ; | |||
$strProducts .= $product->name . ' (' .$productOrder->quantity .$unit.')<br />'; | |||
$add = true; | |||
} | |||
@@ -186,9 +186,9 @@ foreach ($pointsSaleArray as $pointSale) { | |||
$cpt = 0 ; | |||
foreach ($productsArray as $product) { | |||
foreach( Product::$unitsArray as $unit => $dataUnit) { | |||
$quantity = $orderManager->getProductQuantity($product, $pointSale->orders, false, $unit); | |||
$quantity = $orderModule->getProductQuantity($product, $pointSale->orders, false, $unit); | |||
if ($quantity) { | |||
$theUnit = ( $productManager->strUnit($unit, 'wording_short', true) == 'p.') ? '' : ' '. $productManager->strUnit($unit, 'wording_short', true) ; | |||
$theUnit = ( $productModule->strUnit($unit, 'wording_short', true) == 'p.') ? '' : ' '. $productModule->strUnit($unit, 'wording_short', true) ; | |||
$strProducts .= $product->name . ' (' .$quantity .$theUnit.')<br />'; | |||
} | |||
} | |||
@@ -235,9 +235,9 @@ foreach ($pointsSaleArray as $pointSale) | |||
$cpt = 0 ; | |||
foreach ($productsArray as $product) { | |||
foreach( Product::$unitsArray as $unit => $dataUnit) { | |||
$quantity = $orderManager->getProductQuantity($product, $pointSale->orders, false, $unit); | |||
$quantity = $orderModule->getProductQuantity($product, $pointSale->orders, false, $unit); | |||
if ($quantity) { | |||
$theUnit = ( $productManager->strUnit($unit, 'wording_short', true) == 'p.') ? '' : ' '. $productManager->strUnit($unit, 'wording_short', true) ; | |||
$theUnit = ( $productModule->strUnit($unit, 'wording_short', true) == 'p.') ? '' : ' '. $productModule->strUnit($unit, 'wording_short', true) ; | |||
$html .= $product->name . ' (' .$quantity .$theUnit.')<br />'; | |||
} | |||
} | |||
@@ -262,9 +262,9 @@ $html .= '<tr><td><strong>Total</strong></td><td>' ; | |||
$cpt = 0 ; | |||
foreach ($productsArray as $product) { | |||
foreach( Product::$unitsArray as $unit => $dataUnit) { | |||
$quantity = $orderManager->getProductQuantity($product, $ordersArray, false, $unit); | |||
$quantity = $orderModule->getProductQuantity($product, $ordersArray, false, $unit); | |||
if ($quantity) { | |||
$theUnit = ( $productManager->strUnit($unit, 'wording_short', true) == 'p.') ? '' : ' '. $productManager->strUnit($unit, 'wording_short', true) ; | |||
$theUnit = ( $productModule->strUnit($unit, 'wording_short', true) == 'p.') ? '' : ' '. $productModule->strUnit($unit, 'wording_short', true) ; | |||
$html .= $product->name . ' (' .$quantity .$theUnit.')<br />'; | |||
} | |||
} |
@@ -1,10 +1,10 @@ | |||
<?php | |||
use common\logic\Order\Order\Wrapper\OrderManager; | |||
use common\logic\Order\Order\Module\OrderModule; | |||
use common\logic\Producer\Producer\Model\Producer; | |||
use common\logic\Product\Product\Wrapper\ProductManager; | |||
use common\logic\Product\Product\Module\ProductModule; | |||
$orderManager = OrderManager::getInstance(); | |||
$orderModule = OrderModule::getInstance(); | |||
$html = ''; | |||
@@ -22,7 +22,7 @@ foreach ($pointsSaleArray as $keyPointSale => $pointSale) { | |||
foreach ($orders as $order) { | |||
$html .= '<th class="th-user" text-rotate="90">' | |||
. '<div class="user">' . $orderManager->getOrderUsername($order) . '</div>' | |||
. '<div class="user">' . $orderModule->getOrderUsername($order) . '</div>' | |||
//.'<div class="amount">'.number_format($order->amount_with_tax, 2) .' € </div>' | |||
. '</th>'; | |||
} | |||
@@ -61,7 +61,7 @@ foreach ($pointsSaleArray as $keyPointSale => $pointSale) { | |||
foreach ($orders as $order) { | |||
$html .= '<tr>'; | |||
$strUser = $orderManager->getOrderUsername($order); | |||
$strUser = $orderModule->getOrderUsername($order); | |||
if ($producer->option_order_reference_type == Producer::ORDER_REFERENCE_TYPE_YEARLY && $order->reference && strlen($order->reference) > 0) { | |||
$strUser .= '<br />' . $order->reference; | |||
} | |||
@@ -90,7 +90,7 @@ echo $html; | |||
function line_product($product, $orders) | |||
{ | |||
$productManager = ProductManager::getInstance(); | |||
$productModule = ProductModule::getInstance(); | |||
$html = ''; | |||
if (has_quantity($product, $orders)) { | |||
@@ -101,7 +101,7 @@ function line_product($product, $orders) | |||
$quantity = ''; | |||
foreach ($order->productOrder as $productOrder) { | |||
if ($product->id == $productOrder->id_product) { | |||
$unit = ($productManager->strUnit($productOrder->unit, 'wording_short', true) == 'p.') ? '' : ' ' . $productManager->strUnit($productOrder->unit, 'wording_short', true); | |||
$unit = ($productModule->strUnit($productOrder->unit, 'wording_short', true) == 'p.') ? '' : ' ' . $productModule->strUnit($productOrder->unit, 'wording_short', true); | |||
$quantity .= $productOrder->quantity . $unit; | |||
if ($productOrder->quantity > 1) { |
@@ -1,9 +1,9 @@ | |||
<?php | |||
use common\logic\Order\Order\Wrapper\OrderManager; | |||
use common\logic\Order\Order\Module\OrderModule; | |||
use yii\helpers\Html; | |||
$orderManager = OrderManager::getInstance(); | |||
$orderModule = OrderModule::getInstance(); | |||
$index = 0 | |||
?> | |||
@@ -11,13 +11,13 @@ $index = 0 | |||
<div class="shopping-cart-label shopping-cart-label-<?= $index ?>"> | |||
<div class="inner"> | |||
<div class="username"> | |||
<?= $orderManager->getOrderUsername($order); ?> | |||
<?= $orderModule->getOrderUsername($order); ?> | |||
</div> | |||
<div class="point-sale"> | |||
<?= Html::encode($order->pointSale->name); ?> • <?= date('d/m', strtotime($distribution->date)); ?> | |||
</div> | |||
<div class="products"> | |||
<?= $orderManager->getCartSummary($order); ?> | |||
<?= $orderModule->getCartSummary($order); ?> | |||
</div> | |||
</div> | |||
</div> |
@@ -4,8 +4,8 @@ use common\helpers\Price; | |||
use common\logic\Product\Product\Model\Product; | |||
use yii\helpers\Html; | |||
$documentManager = $this->getDocumentManager(); | |||
$productManager = $this->getProductManager(); | |||
$documentModule = $this->getDocumentModule(); | |||
$productModule = $this->getProductModule(); | |||
?> | |||
@@ -24,7 +24,7 @@ $productManager = $this->getProductManager(); | |||
<?php | |||
$price = $productOrder->getPrice() ; | |||
if($documentManager->isInvoicePrice($document) && $productOrder->getInvoicePrice()) { | |||
if($documentModule->isInvoicePrice($document) && $productOrder->getInvoicePrice()) { | |||
$price = $productOrder->getInvoicePrice() ; | |||
} | |||
?> | |||
@@ -37,13 +37,13 @@ $productManager = $this->getProductManager(); | |||
<td class="align-center"> | |||
<?= $productOrder->quantity * Product::$unitsArray[$productOrder->unit]['coefficient'] ?> | |||
</td> | |||
<td class="align-center"><?= $productManager->strUnit($productOrder->unit, 'wording') ?></td> | |||
<td class="align-center"><?= $productModule->strUnit($productOrder->unit, 'wording') ?></td> | |||
<?php if($displayPrices): ?> | |||
<?php if($producer->taxRate->value != 0): ?> | |||
<td class="align-center"><?= $productOrder->taxRate->value * 100 ?> %</td> | |||
<?php endif; ?> | |||
<td class="align-center"> | |||
<?php if($documentManager->getClass($document) == ''): ?> | |||
<?php if($documentModule->getClass($document) == ''): ?> | |||
<?= Price::format($price * $productOrder->quantity) ?> | |||
<?php else: ?> | |||
<?= Price::format($price * $productOrder->quantity) ?> |
@@ -36,21 +36,24 @@ | |||
* termes. | |||
*/ | |||
use common\helpers\MeanPayment;use common\helpers\Price;use common\logic\Document\Document\Wrapper\DocumentManager; | |||
use common\logic\Document\Invoice\Wrapper\InvoiceManager;use common\logic\Payment\Wrapper\PaymentManager;use common\logic\Producer\Producer\Wrapper\ProducerManager; | |||
use common\logic\User\User\Wrapper\UserModule; | |||
use common\helpers\MeanPayment;use common\helpers\Price; | |||
use common\logic\Document\Document\Module\DocumentModule; | |||
use common\logic\Document\Invoice\Module\InvoiceModule; | |||
use common\logic\Payment\Module\PaymentModule; | |||
use common\logic\Producer\Producer\Module\ProducerModule; | |||
use common\logic\User\User\Module\UserModule; | |||
use yii\helpers\Html; | |||
use yii\widgets\ActiveForm; | |||
\backend\assets\VuejsDocumentFormAsset::register($this); | |||
$producerManager = ProducerManager::getInstance(); | |||
$documentManager = DocumentManager::getInstance(); | |||
$invoiceManager = InvoiceManager::getInstance(); | |||
$producerModule = ProducerModule::getInstance(); | |||
$documentModule = DocumentModule::getInstance(); | |||
$invoiceModule = InvoiceModule::getInstance(); | |||
$userModule = UserModule::getInstance(); | |||
$paymentManager = PaymentManager::getInstance(); | |||
$paymentManager = PaymentModule::getInstance(); | |||
$documentClass = $documentManager->getClass($model); | |||
$documentClass = $documentModule->getClass($model); | |||
?> | |||
@@ -175,7 +178,7 @@ $documentClass = $documentManager->getClass($model); | |||
<div class="info-box-content"> | |||
<span class="info-box-text"> | |||
Total<span v-if="taxRateProducer != 0"> (TTC)</span> | |||
<?php if($invoiceManager->isDocumentInvoice($model) && $invoiceManager->isInvoicePaid($model)): ?> | |||
<?php if( $invoiceModule->isDocumentInvoice($model) && $invoiceModule->isInvoicePaid($model)): ?> | |||
<span class="label label-success">PAYÉE</span> | |||
<?php endif; ?> | |||
</span> | |||
@@ -208,13 +211,13 @@ $documentClass = $documentManager->getClass($model); | |||
class="btn btn-sm btn-default"><span class="glyphicon glyphicon-download-alt"></span> Télécharger | |||
(PDF)</a> | |||
<?php if ($documentManager->isStatusValid($model)): ?> | |||
<?php if ($documentModule->isStatusValid($model)): ?> | |||
<a href="<?= Yii::$app->urlManager->createUrl([Yii::$app->controller->getControllerUrl() . '/regenerate', 'id' => $model->id]) ?>" | |||
class="btn btn-sm btn-default"><span class="glyphicon glyphicon-repeat"></span> Regénérer | |||
(PDF)</a> | |||
<?php endif; ?> | |||
<?php if ($documentClass == 'Invoice' && $producerManager->getConfig('option_export_evoliz')): ?> | |||
<?php if ($documentClass == 'Invoice' && $producerModule->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> |
@@ -4,14 +4,14 @@ use yii\helpers\Html; | |||
use common\logic\Order\Order\Model\Order; | |||
use common\helpers\Price; | |||
$producerManager = $this->getProducerManager(); | |||
$producerModule = $this->getProducerModule(); | |||
$userModule = $this->getUserModule(); | |||
$documentManager = $this->getDocumentManager(); | |||
$orderManager = $this->getOrderManager(); | |||
$documentModule = $this->getDocumentModule(); | |||
$orderModule = $this->getOrderModule(); | |||
$displayPrices = Yii::$app->controller->getClass() != 'DeliveryNote' || (Yii::$app->controller->getClass() == 'DeliveryNote' && $producerManager->getConfig('document_display_prices_delivery_note')); | |||
$displayProductDescription = $producerManager->getConfig('document_display_product_description'); | |||
$documentPriceDecimals = (int) $producerManager->getConfig('option_document_price_decimals'); | |||
$displayPrices = Yii::$app->controller->getClass() != 'DeliveryNote' || (Yii::$app->controller->getClass() == 'DeliveryNote' && $producerModule->getConfig('document_display_prices_delivery_note')); | |||
$displayProductDescription = $producerModule->getConfig('document_display_product_description'); | |||
$documentPriceDecimals = (int) $producerModule->getConfig('option_document_price_decimals'); | |||
?> | |||
@@ -21,11 +21,11 @@ $documentPriceDecimals = (int) $producerManager->getConfig('option_document_pric | |||
<div class="producer"> | |||
<?php if (strlen($producer->logo)) : ?> | |||
<div class="logo"> | |||
<img style="max-height: 80px;" src="<?= $producerManager->getUrlLogo($producer) ?>"/> | |||
<img style="max-height: 80px;" src="<?= $producerModule->getUrlLogo($producer) ?>"/> | |||
</div> | |||
<?php endif; ?> | |||
<div class="address"> | |||
<?= $producerManager->getFullAddress($producer, true); ?> | |||
<?= $producerModule->getFullAddress($producer, true); ?> | |||
</div> | |||
<?php if (strlen($producer->document_infos_top)): ?> | |||
<div class="infos-top"> | |||
@@ -48,10 +48,10 @@ $documentPriceDecimals = (int) $producerManager->getConfig('option_document_pric | |||
</div> | |||
<div class="reference"> | |||
<?php if (strlen($document->reference)) : ?> | |||
<?= $documentManager->getType($document); ?> N°<?= $document->reference; ?> | |||
<?= $documentModule->getType($document); ?> N°<?= $document->reference; ?> | |||
<?php else: ?> | |||
<div class="block-is-draft"><?= $documentManager->getType($document); ?> non | |||
validé<?= ($documentManager->getType($document) == 'Facture') ? 'e' : '' ?></div> | |||
<div class="block-is-draft"><?= $documentModule->getType($document); ?> non | |||
validé<?= ($documentModule->getType($document) == 'Facture') ? 'e' : '' ?></div> | |||
<?php endif; ?> | |||
</div> | |||
<div class="name"> | |||
@@ -94,11 +94,11 @@ $documentPriceDecimals = (int) $producerManager->getConfig('option_document_pric | |||
</thead> | |||
<tbody> | |||
<?php if ($producerManager->isDocumentDisplayOrders($document)): ?> | |||
<?php if ($producerModule->isDocumentDisplayOrders($document)): ?> | |||
<?php foreach ($document->orders as $order): ?> | |||
<tr> | |||
<td> | |||
<strong><?= $orderManager->getOrderUsername($order); ?></strong> | |||
<strong><?= $orderModule->getOrderUsername($order); ?></strong> | |||
<?php if ($order->distribution): ?> | |||
le <?= date('d/m/Y', strtotime($order->distribution->date)) ?> | |||
<?php endif; ?> | |||
@@ -128,7 +128,7 @@ $documentPriceDecimals = (int) $producerManager->getConfig('option_document_pric | |||
<?php endforeach; ?> | |||
<?php endforeach; ?> | |||
<?php else: ?> | |||
<?php foreach ($documentManager->getProductsOrders($document) as $product): ?> | |||
<?php foreach ($documentModule->getProductsOrders($document) as $product): ?> | |||
<?php foreach ($product as $productOrder): ?> | |||
<?= $this->render('_download_product_line', [ | |||
'producer' => $producer, | |||
@@ -142,20 +142,20 @@ $documentPriceDecimals = (int) $producerManager->getConfig('option_document_pric | |||
<?php endforeach; ?> | |||
<?php endif; ?> | |||
<?php if ($displayPrices): ?> | |||
<?php $typeAmount = $documentManager->isInvoicePrice($document) ? Order::INVOICE_AMOUNT_TOTAL : Order::AMOUNT_TOTAL; ?> | |||
<?php $typeAmount = $documentModule->isInvoicePrice($document) ? Order::INVOICE_AMOUNT_TOTAL : Order::AMOUNT_TOTAL; ?> | |||
<?php if ($producer->taxRate->value != 0): ?> | |||
<tr> | |||
<td class="align-right" colspan="5"><strong>Total HT</strong></td> | |||
<td class="align-center"> | |||
<?= Price::format($documentManager->getAmount($document, $typeAmount)); ?> | |||
<?= Price::format($documentModule->getAmount($document, $typeAmount)); ?> | |||
</td> | |||
</tr> | |||
<?php | |||
$taxRateArray = $this->getTaxRateManager()->findTaxRatesAsArray(); | |||
foreach ($documentManager->getTotalVatArray($document, $typeAmount) as $idTaxRate => $totalVat): ?> | |||
$taxRateArray = $this-> getTaxRateModule()->findTaxRatesAsArray(); | |||
foreach ($documentModule->getTotalVatArray($document, $typeAmount) as $idTaxRate => $totalVat): ?> | |||
<tr> | |||
<td class="align-right" colspan="5"> | |||
<strong>TVA <?= $taxRateArray[$idTaxRate]->value * 100 ?> %</strong></td> | |||
@@ -168,12 +168,12 @@ $documentPriceDecimals = (int) $producerManager->getConfig('option_document_pric | |||
<!--<tr> | |||
<td class="align-right" colspan="5"><strong>TVA</strong></td> | |||
<td class="align-center"> | |||
<?= Price::format($documentManager->getAmountWithTax($document, $typeAmount) - $documentManager->getAmount($document, $typeAmount)) ?> | |||
<?= Price::format($documentModule->getAmountWithTax($document, $typeAmount) - $documentModule->getAmount($document, $typeAmount)) ?> | |||
</td> | |||
</tr>--> | |||
<tr> | |||
<td class="align-right" colspan="5"><strong>Total TTC</strong></td> | |||
<td class="align-center"><?= Price::format($documentManager->getAmountWithTax($document, $typeAmount)) ?></td> | |||
<td class="align-center"><?= Price::format($documentModule->getAmountWithTax($document, $typeAmount)) ?></td> | |||
</tr> | |||
<?php else: ?> | |||
<tr> | |||
@@ -181,7 +181,7 @@ $documentPriceDecimals = (int) $producerManager->getConfig('option_document_pric | |||
<strong>Total</strong><br/> | |||
TVA non applicable | |||
</td> | |||
<td class="align-center"><?= Price::format($documentManager->getAmount($document, $typeAmount)) ?></td> | |||
<td class="align-center"><?= Price::format($documentModule->getAmount($document, $typeAmount)) ?></td> | |||
</tr> | |||
<?php endif; ?> | |||
<?php endif; ?> | |||
@@ -195,7 +195,7 @@ $documentPriceDecimals = (int) $producerManager->getConfig('option_document_pric | |||
</div> | |||
<?php | |||
$fieldProducerDocumentInfo = 'document_infos_' . str_replace('deliverynote', 'delivery_note', strtolower($documentManager->getClass($document))); ?> | |||
$fieldProducerDocumentInfo = 'document_infos_' . str_replace('deliverynote', 'delivery_note', strtolower($documentModule->getClass($document))); ?> | |||
<?php if (strlen($producer->$fieldProducerDocumentInfo)): ?> | |||
<div class="block-infos"> | |||
<strong>Informations</strong><br/> |
@@ -2,17 +2,17 @@ | |||
use common\helpers\MeanPayment; | |||
use common\helpers\Price; | |||
use common\logic\Document\Document\Wrapper\DocumentManager; | |||
use common\logic\Document\Invoice\Wrapper\InvoiceManager; | |||
use common\logic\Payment\Wrapper\PaymentManager; | |||
use common\logic\Document\Document\Module\DocumentModule; | |||
use common\logic\Document\Invoice\Module\InvoiceModule; | |||
use common\logic\Payment\Module\PaymentModule; | |||
use yii\helpers\Html; | |||
use yii\widgets\ActiveForm; | |||
$documentManager = DocumentManager::getInstance(); | |||
$paymentManager = PaymentManager::getInstance(); | |||
$invoiceManager = InvoiceManager::getInstance(); | |||
$documentModule = DocumentModule::getInstance(); | |||
$paymentManager = PaymentModule::getInstance(); | |||
$invoiceModule = InvoiceModule::getInstance(); | |||
if($documentManager->isStatusValid($model)): ?> | |||
if($documentModule->isStatusValid($model)): ?> | |||
<div> | |||
<div class="panel panel-default"> | |||
<div class="panel-heading"> | |||
@@ -40,7 +40,7 @@ if($documentManager->isStatusValid($model)): ?> | |||
</table> | |||
<?php endif; ?> | |||
<?php if($invoiceManager->isDocumentInvoice($model) && !$invoiceManager->isInvoicePaid($model)): ?> | |||
<?php if( $invoiceModule->isDocumentInvoice($model) && ! $invoiceModule->isInvoicePaid($model)): ?> | |||
<div class="row"> | |||
<?php $form = ActiveForm::begin(); ?> | |||
<div class="col-md-3"> |
@@ -42,8 +42,8 @@ use common\helpers\Url; | |||
use common\logic\Document\Invoice\Model\Invoice; | |||
use common\logic\Order\Order\Model\Order; | |||
$producerManager = $this->getProducerManager(); | |||
$invoiceManager = $this->getInvoiceManager(); | |||
$producerModule = $this->getProducerModule(); | |||
$invoiceModule = $this-> getInvoiceModule(); | |||
$userModule = $this->getUserModule(); | |||
$this->setTitle('Factures'); | |||
@@ -67,8 +67,8 @@ $this->addButton(['label' => 'Nouvelle facture <span class="glyphicon glyphicon- | |||
'valid' => 'Valide', | |||
], | |||
'format' => 'raw', | |||
'value' => function ($invoice) use ($invoiceManager) { | |||
return $invoiceManager->getHtmlLabel($invoice); | |||
'value' => function ($invoice) use ( $invoiceModule) { | |||
return $invoiceModule->getHtmlLabel($invoice); | |||
} | |||
], | |||
[ | |||
@@ -105,9 +105,9 @@ $this->addButton(['label' => 'Nouvelle facture <span class="glyphicon glyphicon- | |||
'attribute' => 'amount', | |||
'header' => 'Montant', | |||
'format' => 'raw', | |||
'value' => function ($invoice) use ($invoiceManager) { | |||
$amountWithTax = $invoiceManager->getAmountWithTax($invoice, Order::INVOICE_AMOUNT_TOTAL); | |||
return $invoiceManager->getAmountWithTax($invoice, Order::INVOICE_AMOUNT_TOTAL, true); | |||
'value' => function ($invoice) use ( $invoiceModule) { | |||
$amountWithTax = $invoiceModule->getAmountWithTax($invoice, Order::INVOICE_AMOUNT_TOTAL); | |||
return $invoiceModule->getAmountWithTax($invoice, Order::INVOICE_AMOUNT_TOTAL, true); | |||
} | |||
], | |||
[ | |||
@@ -116,9 +116,9 @@ $this->addButton(['label' => 'Nouvelle facture <span class="glyphicon glyphicon- | |||
'headerOptions' => ['class' => 'column-hide-on-mobile'], | |||
'filterOptions' => ['class' => 'column-hide-on-mobile'], | |||
'contentOptions' => ['class' => 'column-hide-on-mobile'], | |||
'value' => function ($invoice) use ($invoiceManager) { | |||
$amountWithTax = $invoiceManager->getAmountWithTax($invoice, Order::INVOICE_AMOUNT_TOTAL); | |||
if($amountWithTax && $invoiceManager->isInvoicePaid($invoice)) { | |||
'value' => function ($invoice) use ( $invoiceModule) { | |||
$amountWithTax = $invoiceModule->getAmountWithTax($invoice, Order::INVOICE_AMOUNT_TOTAL); | |||
if($amountWithTax && $invoiceModule->isInvoicePaid($invoice)) { | |||
return '<span class="label label-success">Oui</span>'; | |||
} | |||
@@ -146,8 +146,8 @@ $this->addButton(['label' => 'Nouvelle facture <span class="glyphicon glyphicon- | |||
'headerOptions' => ['class' => 'column-actions'], | |||
'contentOptions' => ['class' => 'column-actions'], | |||
'buttons' => [ | |||
'validate' => function ($url, $invoice) use ($invoiceManager) { | |||
return ($invoiceManager->isStatusDraft($invoice) ? Html::a('<span class="glyphicon glyphicon-ok"></span>', $url, [ | |||
'validate' => function ($url, $invoice) use ( $invoiceModule) { | |||
return ( $invoiceModule->isStatusDraft($invoice) ? Html::a('<span class="glyphicon glyphicon-ok"></span>', $url, [ | |||
'title' => 'Valider', 'class' => 'btn btn-default' | |||
]) : ''); | |||
}, | |||
@@ -161,8 +161,8 @@ $this->addButton(['label' => 'Nouvelle facture <span class="glyphicon glyphicon- | |||
'title' => 'Télécharger', 'class' => 'btn btn-default' | |||
]); | |||
}, | |||
'export-csv-evoliz' => function ($url, $invoice) use ($producerManager) { | |||
if ($producerManager->getConfig('option_export_evoliz')) { | |||
'export-csv-evoliz' => function ($url, $invoice) use ($producerModule) { | |||
if ($producerModule->getConfig('option_export_evoliz')) { | |||
return Html::a('<span class="glyphicon glyphicon-save-file"></span> Evoliz', $url, [ | |||
'title' => 'Export CSV Evoliz', 'class' => 'btn btn-default' | |||
]); | |||
@@ -175,8 +175,8 @@ $this->addButton(['label' => 'Nouvelle facture <span class="glyphicon glyphicon- | |||
'title' => 'Modifier', 'class' => 'btn btn-default' | |||
]); | |||
}, | |||
'delete' => function ($url, $invoice) use ($invoiceManager) { | |||
return ($invoiceManager->isStatusDraft($invoice) ? Html::a('<span class="glyphicon glyphicon-trash"></span>', $url, [ | |||
'delete' => function ($url, $invoice) use ( $invoiceModule) { | |||
return ( $invoiceModule->isStatusDraft($invoice) ? Html::a('<span class="glyphicon glyphicon-trash"></span>', $url, [ | |||
'title' => 'Supprimer', 'class' => 'btn btn-default' | |||
]) : ''); | |||
} |
@@ -40,7 +40,7 @@ use yii\widgets\Breadcrumbs; | |||
use dmstr\widgets\Alert; | |||
use common\helpers\GlobalParam; | |||
$producerManager = $this->getProducerManager(); | |||
$producerModule = $this->getProducerModule(); | |||
?> | |||
<div class="content-wrapper"> | |||
@@ -80,7 +80,7 @@ $producerManager = $this->getProducerManager(); | |||
<section class="content"> | |||
<?php $producer = GlobalParam::getCurrentProducer(); ?> | |||
<?php if($producer && !$producerManager->isUpToDateWithOpendistribVersion($producer) && $producer->option_display_message_new_opendistrib_version): ?> | |||
<?php if($producer && !$producerModule->isUpToDateWithOpendistribVersion($producer) && $producer->option_display_message_new_opendistrib_version): ?> | |||
<div class="alert alert-warning"> | |||
<p>Opendistrib a été mis à jour vers la version <?= GlobalParam::getOpendistribVersion() ?> ! <a class="alert-link" href="<?= Yii::$app->urlManager->createUrl(['development/index']) ?>">Découvrir les nouveautés</a></p> | |||
<a href="<?= Yii::$app->urlManager->createUrl(['producer/update-opendistrib-version']) ?>" class="close"><span aria-hidden="true">×</span></a> |
@@ -37,8 +37,8 @@ | |||
*/ | |||
use common\helpers\Price; | |||
use common\logic\Producer\Producer\Wrapper\ProducerManager; | |||
use common\logic\User\User\Wrapper\UserModule; | |||
use common\logic\Producer\Producer\Module\ProducerModule; | |||
use common\logic\User\User\Module\UserModule; | |||
use yii\helpers\Html; | |||
use common\helpers\GlobalParam; | |||
@@ -46,7 +46,7 @@ use common\logic\Distribution\Distribution\Model\Distribution; | |||
use common\logic\Producer\Producer\Model\Producer; | |||
$userModule = UserModule::getInstance(); | |||
$producerManager = ProducerManager::getInstance(); | |||
$producerModule = ProducerModule::getInstance(); | |||
$producer = GlobalParam::getCurrentProducer(); | |||
$userCurrent = GlobalParam::getCurrentUser(); | |||
@@ -37,12 +37,12 @@ | |||
*/ | |||
use common\helpers\GlobalParam; | |||
use common\logic\User\User\Wrapper\UserModule; | |||
use common\logic\User\User\Module\UserModule; | |||
$producerManager = $this->getProducerManager(); | |||
$producerModule = $this->getProducerModule(); | |||
$userModule = UserModule::getInstance(); | |||
$userProducerManager = $this->getUserProducerManager(); | |||
$ticketManager = $this->getTicketManager(); | |||
$userProducerModule = $this->getUserProducerModule(); | |||
$ticketModule = $this->getTicketModule(); | |||
$producer = GlobalParam::getCurrentProducer(); | |||
$userCurrent = GlobalParam::getCurrentUser(); | |||
@@ -58,23 +58,23 @@ $isUserCurrentGrantedAsProducer = $userModule->getAuthorizationChecker()->isGran | |||
<?php | |||
$producer = GlobalParam::getCurrentProducer(); | |||
$newVersionOpendistribLabel = ''; | |||
if ($producer && !$producerManager->isUpToDateWithOpendistribVersion($producer)) { | |||
if ($producer && !$producerModule->isUpToDateWithOpendistribVersion($producer)) { | |||
$newVersionOpendistribLabel = '<span class="pull-right-container"><small class="label pull-right bg-green">'.GlobalParam::getOpendistribVersion().'</small></span>'; | |||
} | |||
$countTicketsProducerUnreadLabel = ''; | |||
$countTicketsProducerUnread = $ticketManager->countTicketsUnreadByUser($this->getUserCurrent()); | |||
$countTicketsProducerUnread = $ticketModule->countTicketsUnreadByUser($this->getUserCurrent()); | |||
if($countTicketsProducerUnread && !$isUserCurrentGrantedAsAdministrator) { | |||
$countTicketsProducerUnreadLabel = '<span class="pull-right-container"><small class="label pull-right bg-green">'.$countTicketsProducerUnread.'</small></span>'; | |||
} | |||
$countTicketsAdminUnreadLabel = ''; | |||
$countTicketsAdminUnread = $ticketManager->countTicketsAdminUnreadByUser($this->getUserCurrent()); | |||
$countTicketsAdminUnread = $ticketModule->countTicketsAdminUnreadByUser($this->getUserCurrent()); | |||
if($countTicketsAdminUnread && $isUserCurrentGrantedAsAdministrator) { | |||
$countTicketsAdminUnreadLabel = '<span class="pull-right-container"><small class="label pull-right bg-green">'.$countTicketsAdminUnread.'</small></span>'; | |||
} | |||
$sumUserProducerCredits = $userProducerManager->sumUserProducerCredits(); | |||
$sumUserProducerCredits = $userProducerModule->sumUserProducerCredits(); | |||
$sumUserProducerCreditsLabel = ''; | |||
//$sumUserProducerCreditsLabel = '<span class="pull-right-container"><small class="label pull-right '.($sumUserProducerCredits >= 0 ? 'bg-green' : 'bg-red') .'">'.number_format($sumUserProducerCredits, 2).' €</small></span>'; | |||
@@ -119,7 +119,7 @@ $isUserCurrentGrantedAsProducer = $userModule->getAuthorizationChecker()->isGran | |||
'icon' => 'euro', | |||
'url' => ['/credit/index'], | |||
'template' => '<a href="{url}">{icon} {label}' . $sumUserProducerCreditsLabel . '</a>', | |||
'visible' => $isUserCurrentGrantedAsProducer && $producerManager->getConfig('credit') | |||
'visible' => $isUserCurrentGrantedAsProducer && $producerModule->getConfig('credit') | |||
], | |||
['label' => 'Groupes', 'icon' => 'users', 'url' => ['/user-group/index'], 'visible' => $isUserCurrentGrantedAsProducer], | |||
], |
@@ -37,9 +37,9 @@ termes. | |||
*/ | |||
use common\logic\Order\Order\Model\Order; | |||
use common\logic\Order\Order\Wrapper\OrderManager; | |||
use common\logic\Order\Order\Module\OrderModule; | |||
$orderManager = OrderManager::getInstance(); | |||
$orderModule = OrderModule::getInstance(); | |||
$dayWeek = date('w', strtotime($date)); | |||
$dayWeekArray = [0 => 'sunday', 1 => 'monday', 2 => 'tuesday', 3 => 'wednesday', 4 => 'thursday', 5 => 'friday', 6 => 'saturday']; | |||
@@ -113,17 +113,17 @@ foreach ($pointsSaleArray as $pointSale) { | |||
$html .= '<td><strong>'.number_format($order->amount, 2) . ' € '; | |||
if($orderManager->getPaymentStatus($order) == Order::PAYMENT_PAID) | |||
if($orderModule->getPaymentStatus($order) == Order::PAYMENT_PAID) | |||
{ | |||
$html .= '(débité)' ; | |||
} | |||
elseif($orderManager->getPaymentStatus($order) == Order::PAYMENT_UNPAID && $orderManager->getOrderAmount($order, Order::AMOUNT_PAID)) | |||
elseif($orderModule->getPaymentStatus($order) == Order::PAYMENT_UNPAID && $orderModule->getOrderAmount($order, Order::AMOUNT_PAID)) | |||
{ | |||
$html .= '(reste '.$orderManager->getOrderAmount($order, Order::AMOUNT_REMAINING, true).' à débiter)' ; | |||
$html .= '(reste '.$orderModule->getOrderAmount($order, Order::AMOUNT_REMAINING, true).' à débiter)' ; | |||
} | |||
elseif($orderManager->getPaymentStatus($order) == Order::PAYMENT_SURPLUS) | |||
elseif($orderModule->getPaymentStatus($order) == Order::PAYMENT_SURPLUS) | |||
{ | |||
$html .= '(surplus : '.$orderManager->getOrderAmount($order, Order::PAYMENT_SURPLUS, true).' à recréditer)' ; | |||
$html .= '(surplus : '.$orderModule->getOrderAmount($order, Order::PAYMENT_SURPLUS, true).' à recréditer)' ; | |||
} | |||
$html .= '</strong></td>' ; | |||
@@ -136,7 +136,7 @@ foreach ($pointsSaleArray as $pointSale) { | |||
$strProducts = ''; | |||
foreach ($productsArray as $product) { | |||
$quantity = $orderManager->getProductQuantity($product, $pointSale->orders); | |||
$quantity = $orderModule->getProductQuantity($product, $pointSale->orders); | |||
$strQuantity = ''; | |||
if ($quantity) { | |||
$strQuantity = $quantity; | |||
@@ -174,7 +174,7 @@ foreach ($pointsSaleArray as $pointSale) | |||
{ | |||
$html .= '<tr><td>'.$pointSale->name.'</td><td>' ; | |||
foreach ($productsArray as $product) { | |||
$quantity = $orderManager->getProductQuantity($product, $pointSale->orders); | |||
$quantity = $orderModule->getProductQuantity($product, $pointSale->orders); | |||
$strQuantity = ($quantity) ? $quantity : '' ; | |||
if(strlen($strQuantity)) { | |||
@@ -193,7 +193,7 @@ foreach ($pointsSaleArray as $pointSale) | |||
// total | |||
$html .= '<tr><td><strong>Total</strong></td><td>' ; | |||
foreach ($productsArray as $product) { | |||
$quantity = $orderManager->getProductQuantity($product, $ordersArray); | |||
$quantity = $orderModule->getProductQuantity($product, $ordersArray); | |||
if($quantity) { | |||
$html .= $quantity . ' '.$product->name.', ' ; | |||
} |
@@ -40,9 +40,9 @@ use yii\helpers\Html; | |||
use yii\widgets\ActiveForm; | |||
use yii\helpers\ArrayHelper; | |||
use common\logic\Producer\Producer\Model\Producer; | |||
use common\logic\User\User\Wrapper\UserModule; | |||
use common\logic\User\User\Module\UserModule; | |||
$producerManager = $this->getProducerManager(); | |||
$producerModule = $this->getProducerModule(); | |||
$userModule = $this->getUserModule(); | |||
?> | |||
@@ -62,7 +62,7 @@ $userModule = $this->getUserModule(); | |||
->hint('Utilisé lors de la facturation'); ?> | |||
<?php | |||
$addHintCredit = ''; | |||
if (!$producerManager->getConfig('credit')): | |||
if (!$producerModule->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; | |||
@@ -74,7 +74,7 @@ $userModule = $this->getUserModule(); | |||
<?= $form->field($model, 'credit_functioning') | |||
->dropDownList([ | |||
'' => 'Paramètres globaux (' . Producer::$creditFunctioningArray[$producerManager->getConfig('credit_functioning')] . ')', | |||
'' => 'Paramètres globaux (' . Producer::$creditFunctioningArray[$producerModule->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], |
@@ -41,7 +41,7 @@ use yii\grid\GridView; | |||
use common\logic\PointSale\UserPointSale\Model\UserPointSale; | |||
use common\logic\Producer\Producer\Model\Producer; | |||
$pointSaleManager = $this->getPointSaleManager(); | |||
$pointSaleModule = $this->getPointSaleModule(); | |||
$this->setTitle('Points de vente'); | |||
$this->addBreadcrumb($this->getTitle()); | |||
@@ -92,8 +92,8 @@ $this->addButton( | |||
'saterday' => 'Samedi', | |||
'sunday' => 'Dimanche', | |||
], | |||
'value' => function ($model) use ($pointSaleManager) { | |||
return $pointSaleManager->getStrDeliveryDays($model); | |||
'value' => function ($model) use ($pointSaleModule) { | |||
return $pointSaleModule->getStrDeliveryDays($model); | |||
} | |||
], | |||
[ |
@@ -36,15 +36,15 @@ pris connaissance de la licence CeCILL, et que vous en avez accepté les | |||
termes. | |||
*/ | |||
use common\logic\Producer\Producer\Wrapper\ProducerManager; | |||
use common\logic\Producer\Producer\Module\ProducerModule; | |||
$this->setTitle('Facturation producteur ('.$producer->name.')') ; | |||
$this->addBreadcrumb(['label' => 'Producteurs', 'url' => ['index']]) ; | |||
$this->addBreadcrumb('Facturation') ; | |||
$producerManager = ProducerManager::getInstance(); | |||
$producerModule = ProducerModule::getInstance(); | |||
?> | |||
<div class="producer-billing"> | |||
<?= $producerManager->getSummaryAmountsToBeBilled($producer, '12 derniers mois', 12, 'billing'); ?> | |||
<?= $producerModule->getSummaryAmountsToBeBilled($producer, '12 derniers mois', 12, 'billing'); ?> | |||
</div> |
@@ -42,7 +42,7 @@ use common\logic\User\User\Model\User; | |||
use common\logic\Producer\Producer\Model\Producer; | |||
use common\helpers\Price; | |||
$producerManager = $this->getProducerManager(); | |||
$producerModule = $this->getProducerModule(); | |||
$this->setTitle('Producteurs') ; | |||
$this->addBreadcrumb($this->getTitle()) ; | |||
@@ -111,17 +111,17 @@ $this->addButton(['label' => 'Nouveau producteur <span class="glyphicon glyphico | |||
[ | |||
'label' => 'Facturation', | |||
'format' => 'raw', | |||
'value' => function($producer) use ($producerManager) { | |||
'value' => function($producer) use ($producerModule) { | |||
$str = ''; | |||
$str .= '<ul style="margin: 0px;padding-left: 15px;">'; | |||
$isBillingFrequencyMonthly = $producerManager->isBillingFrequencyMonthly($producer); | |||
$summaryMonthly = $producerManager->getSummaryAmountsToBeBilled($producer, 'Mois dernier', 1); | |||
$isBillingFrequencyQuaterly = $producerManager->isBillingFrequencyQuarterly($producer); | |||
$summaryQuaterly = $producerManager->getSummaryAmountsToBeBilled($producer, '3 derniers mois', 3); | |||
$isBillingFrequencyBiannual = $producerManager->isBillingFrequencyBiannual($producer); | |||
$summaryBiannual = $producerManager->getSummaryAmountsToBeBilled($producer, '6 derniers mois', 6); | |||
$isBillingFrequencyMonthly = $producerModule->isBillingFrequencyMonthly($producer); | |||
$summaryMonthly = $producerModule->getSummaryAmountsToBeBilled($producer, 'Mois dernier', 1); | |||
$isBillingFrequencyQuaterly = $producerModule->isBillingFrequencyQuarterly($producer); | |||
$summaryQuaterly = $producerModule->getSummaryAmountsToBeBilled($producer, '3 derniers mois', 3); | |||
$isBillingFrequencyBiannual = $producerModule->isBillingFrequencyBiannual($producer); | |||
$summaryBiannual = $producerModule->getSummaryAmountsToBeBilled($producer, '6 derniers mois', 6); | |||
if(($isBillingFrequencyMonthly && $summaryMonthly) | |||
|| ($isBillingFrequencyQuaterly && $summaryQuaterly) |
@@ -38,8 +38,8 @@ termes. | |||
use common\helpers\Price; | |||
$producerManager = $this->getProducerManager(); | |||
$producerPriceRangeManager = $this->getProducerPriceRangeManager(); | |||
$producerModule = $this->getProducerModule(); | |||
$producerPriceRangeModule = $this->getProducerPriceRangeModule(); | |||
$this->setTitle('Tarifs') ; | |||
$this->addBreadcrumb($this->getTitle()) ; | |||
@@ -48,19 +48,19 @@ $this->addBreadcrumb($this->getTitle()) ; | |||
<?php | |||
if($producerManager->isBillingTypeFreePrice($producer)) { | |||
if($producerModule->isBillingTypeFreePrice($producer)) { | |||
echo '<div class="alert alert-info">'; | |||
echo "Vous bénéficiez actuellement d'un abonnement à prix libre dont voici le montant : <strong>".$producer->getFreePrice()."</strong>"; | |||
echo '</div>'; | |||
} | |||
elseif($producerManager->isBillingTypeClassic($producer)) { | |||
elseif($producerModule->isBillingTypeClassic($producer)) { | |||
$month = date('Y-m', strtotime('-1 month')); | |||
$turnover = $producerManager->getTurnover($producer, $month); | |||
$amountBilledLastMonth = $producerPriceRangeManager->getAmountToBeBilledByTurnover($turnover); | |||
$turnover = $producerModule->getTurnover($producer, $month); | |||
$amountBilledLastMonth = $producerPriceRangeModule->getAmountToBeBilledByTurnover($turnover); | |||
if($amountBilledLastMonth) { | |||
echo '<div class="alert alert-info">'; | |||
echo "À titre d'information, voici le tarif retenu pour le mois dernier (".strftime('%B', strtotime('-1 month')).") : <strong>".$producerManager->getAmountToBeBilledByMonth($producer, $month, true)."</strong>"; | |||
echo "À titre d'information, voici le tarif retenu pour le mois dernier (".strftime('%B', strtotime('-1 month')).") : <strong>".$producerModule->getAmountToBeBilledByMonth($producer, $month, true)."</strong>"; | |||
echo "<br />Le chiffre d'affaire pris en compte pour ce calcul est : <strong>".Price::format($turnover)." HT</strong>"; | |||
echo '<br /><a href="'.Yii::$app->urlManager->createUrl(['stats/index']).'">Voir l\'évolution de mon chiffre d\'affaire</a>'; | |||
echo '</div>'; |
@@ -37,7 +37,7 @@ | |||
*/ | |||
use common\helpers\GlobalParam; | |||
use common\logic\User\User\Wrapper\UserModule; | |||
use common\logic\User\User\Module\UserModule; | |||
use yii\helpers\Html; | |||
use yii\widgets\ActiveForm; | |||
use common\logic\Producer\Producer\Model\Producer; |
@@ -8,8 +8,8 @@ use common\helpers\GlobalParam; | |||
use common\logic\Product\Product\Model\Product; | |||
use common\logic\PointSale\PointSale\Model\PointSale; | |||
$productCategoryManager = $this->getProductCategoryManager(); | |||
$taxRateManager = $this->getTaxRateManager(); | |||
$productCategoryModule = $this->getProductCategoryModule(); | |||
$taxRateModule = $this-> getTaxRateModule(); | |||
?> | |||
@@ -25,7 +25,7 @@ $taxRateManager = $this->getTaxRateManager(); | |||
<?= $form->field($model, 'status')->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($productCategoryManager->populateProductCategoriesDropdownList()); ?> | |||
<?= $form->field($model, 'id_product_category')->dropDownList($productCategoryModule->populateProductCategoriesDropdownList()); ?> | |||
<?= $form->field($model, 'description')->textInput(['maxlength' => 255]) ?> | |||
<?= $form->field($model, 'recipe')->textarea()->label('Description longue') ?> | |||
@@ -40,10 +40,10 @@ $taxRateManager = $this->getTaxRateManager(); | |||
$producer = \common\helpers\GlobalParam::getCurrentProducer(); | |||
$taxRateDefault = $producer->taxRate; | |||
$taxRateNamesArray = array_merge(array(0 => 'Tva par défaut'), ArrayHelper::map($taxRateManager->findTaxRates(), 'id', function ($model) { | |||
$taxRateNamesArray = array_merge(array(0 => 'Tva par défaut'), ArrayHelper::map($taxRateModule->findTaxRates(), 'id', function ($model) { | |||
return $model->name; | |||
})); | |||
$taxRateValuesArray = array_merge(array(0 => $taxRateDefault->value), ArrayHelper::map($taxRateManager->findTaxRates(), 'id', function ($model) { | |||
$taxRateValuesArray = array_merge(array(0 => $taxRateDefault->value), ArrayHelper::map($taxRateModule->findTaxRates(), 'id', function ($model) { | |||
return $model->value; | |||
})); | |||
foreach ($taxRateValuesArray as $key => $taxRateValue) { |
@@ -44,7 +44,7 @@ use \lo\widgets\Toggle; | |||
use common\helpers\Price; | |||
use common\logic\Product\Product\Model\Product; | |||
$productManager = $this->getProductManager(); | |||
$productModule = $this->getProductModule(); | |||
$this->setTitle('Produits'); | |||
$this->addBreadcrumb($this->getTitle()); | |||
@@ -125,10 +125,10 @@ $this->addButton(['label' => 'Nouveau produit <span class="glyphicon glyphicon-p | |||
], | |||
[ | |||
'attribute' => 'price', | |||
'value' => function ($model) use ($productManager) { | |||
'value' => function ($model) use ($productModule) { | |||
$return = ''; | |||
if ($model->price) { | |||
$return = Price::format($productManager->getPriceWithTax($model)) . ' (' . $productManager->strUnit($model->unit, 'wording_unit', true) . ')'; | |||
$return = Price::format($productModule->getPriceWithTax($model)) . ' (' . $productModule->strUnit($model->unit, 'wording_unit', true) . ')'; | |||
} | |||
return $return; |
@@ -39,7 +39,7 @@ | |||
use yii\bootstrap\ActiveForm; | |||
use yii\helpers\Html; | |||
$productManager = $this->getProductManager(); | |||
$productModule = $this->getProductModule(); | |||
$this->setTitle('Import prix produits'); | |||
$this->addBreadcrumb($this->getTitle()); |
@@ -3,10 +3,10 @@ | |||
use common\helpers\Price; | |||
$productManager = $this->getProductManager(); | |||
$productModule = $this->getProductModule(); | |||
?> | |||
<div class="alert alert-warning"> | |||
Prix de base : <strong><?= Price::format($productManager->getPrice($model)); ?> HT</strong> / <strong><?= Price::format($productManager->getPriceWithTax($model)); ?> TTC</strong><br /> | |||
Prix de base : <strong><?= Price::format($productModule->getPrice($model)); ?> HT</strong> / <strong><?= Price::format($productModule->getPriceWithTax($model)); ?> TTC</strong><br /> | |||
</div> |
@@ -5,9 +5,9 @@ use yii\bootstrap\ActiveForm; | |||
use common\helpers\GlobalParam; | |||
$userModule = $this->getUserModule(); | |||
$userGroupManager = $this->getUserGroupManager(); | |||
$pointSaleManager = $this->getPointSaleManager(); | |||
$productManager = $this->getProductManager(); | |||
$userGroupModule = $this->getUserGroupModule(); | |||
$pointSaleModule = $this->getPointSaleModule(); | |||
$productModule = $this->getProductModule(); | |||
?> | |||
@@ -25,9 +25,9 @@ $productManager = $this->getProductManager(); | |||
]); ?> | |||
<?= $form->field($model, 'id_user')->dropDownList($userModule->populateUserDropdownList()); ?> | |||
<?= $form->field($model, 'id_user_group')->dropDownList($userGroupManager->populateUserGroupDropdownList()); ?> | |||
<?= $form->field($model, 'id_point_sale')->dropDownList($pointSaleManager->populatePointSaleDropdownList()); ?> | |||
<?= $form->field($model, 'from_quantity')->label('À partir de la quantité ('. $productManager->strUnit($productManager->getRefUnit($modelProduct->unit), 'wording').')'); ?> | |||
<?= $form->field($model, 'id_user_group')->dropDownList($userGroupModule->populateUserGroupDropdownList()); ?> | |||
<?= $form->field($model, 'id_point_sale')->dropDownList($pointSaleModule->populatePointSaleDropdownList()); ?> | |||
<?= $form->field($model, 'from_quantity')->label('À partir de la quantité ('. $productModule->strUnit($productModule->getRefUnit($modelProduct->unit), 'wording').')'); ?> | |||
<?php | |||
$producer = GlobalParam::getCurrentProducer(); | |||
@@ -43,18 +43,18 @@ $productManager = $this->getProductManager(); | |||
<div class="col-xs-4"> | |||
<label for="reduction-increase-percent" class="control-label">Réduction / augmentation</label> | |||
<div class="input-group"> | |||
<input type="text" id="reduction-increase-percent" class="form-control" name="" value="" data-price-base="'.$productManager->getPrice($modelProduct).'"> | |||
<input type="text" id="reduction-increase-percent" class="form-control" name="" value="" data-price-base="'.$productModule->getPrice($modelProduct).'"> | |||
<span class="input-group-addon">%</span> | |||
</div> | |||
</div> | |||
<div class="col-xs-4"> | |||
<label for="product-price" class="control-label without-tax">Prix ('. $productManager->strUnit($productManager->getRefUnit($modelProduct->unit), 'wording_unit').') HT</label> | |||
<label for="product-price" class="control-label without-tax">Prix ('. $productModule->strUnit($productModule->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-4"> | |||
<label for="productprice-price-with-tax" class="control-label with-tax">Prix ('. $productManager->strUnit($productManager->getRefUnit($modelProduct->unit), 'wording_unit').') TTC</label> | |||
<label for="productprice-price-with-tax" class="control-label with-tax">Prix ('. $productModule->strUnit($productModule->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> |
@@ -36,13 +36,13 @@ | |||
* termes. | |||
*/ | |||
use common\logic\User\User\Wrapper\UserModule; | |||
use common\logic\User\User\Module\UserModule; | |||
use yii\helpers\Html; | |||
use common\helpers\Price; | |||
use yii\grid\GridView; | |||
use common\logic\Product\Product\Wrapper\ProductManager; | |||
use common\logic\Product\Product\Module\ProductModule; | |||
$productManager = ProductManager::getInstance(); | |||
$productModule = ProductModule::getInstance(); | |||
$userModule = UserModule::getInstance(); | |||
$this->setTitle('Liste des prix (' . Html::encode($model->name) . ')'); | |||
@@ -110,9 +110,9 @@ $this->render('../_nav', [ | |||
], | |||
[ | |||
'attribute' => 'from_quantity', | |||
'value' => function ($productPrice) use ($productManager) { | |||
'value' => function ($productPrice) use ($productModule) { | |||
if ($productPrice->from_quantity) { | |||
return $productPrice->from_quantity . ' ' . $productManager->strUnit($productManager->getRefUnit($productPrice->product->unit), 'wording'); | |||
return $productPrice->from_quantity . ' ' . $productModule->strUnit($productModule->getRefUnit($productPrice->product->unit), 'wording'); | |||
} | |||
return ''; | |||
@@ -160,8 +160,8 @@ $this->render('../_nav', [ | |||
<h3 class="panel-title">Rappel du prix de base</h3> | |||
</div> | |||
<div class="panel-body"> | |||
<p>Prix de base : <strong><?= Price::format($productManager->getPrice($model)); ?> HT</strong> / | |||
<strong><?= Price::format($productManager->getPriceWithTax($model)); ?> TTC</strong><br/></p> | |||
<p>Prix de base : <strong><?= Price::format($productModule->getPrice($model)); ?> HT</strong> / | |||
<strong><?= Price::format($productModule->getPriceWithTax($model)); ?> TTC</strong><br/></p> | |||
</div> | |||
</div> | |||
</div> |
@@ -41,7 +41,7 @@ use yii\grid\GridView; | |||
use common\logic\Order\Order\Model\Order; | |||
use yii\helpers\Html; | |||
$quotationManager = $this->getQuotationManager(); | |||
$quotationModule = $this->getQuotationModule(); | |||
$userModule = $this->getUserModule(); | |||
$this->setTitle('Devis'); | |||
@@ -64,8 +64,8 @@ $this->addButton(['label' => 'Nouveau devis <span class="glyphicon glyphicon-plu | |||
'valid' => 'Valide', | |||
], | |||
'format' => 'raw', | |||
'value' => function ($quotation) use ($quotationManager) { | |||
return $quotationManager->getHtmlLabel($quotation); | |||
'value' => function ($quotation) use ($quotationModule) { | |||
return $quotationModule->getHtmlLabel($quotation); | |||
} | |||
], | |||
[ | |||
@@ -101,8 +101,8 @@ $this->addButton(['label' => 'Nouveau devis <span class="glyphicon glyphicon-plu | |||
[ | |||
'attribute' => 'amount', | |||
'header' => 'Montant', | |||
'value' => function ($quotation) use ($quotationManager) { | |||
return $quotationManager->getAmountWithTax($quotation, Order::AMOUNT_TOTAL, true); | |||
'value' => function ($quotation) use ($quotationModule) { | |||
return $quotationModule->getAmountWithTax($quotation, Order::AMOUNT_TOTAL, true); | |||
} | |||
], | |||
[ | |||
@@ -111,13 +111,13 @@ $this->addButton(['label' => 'Nouveau devis <span class="glyphicon glyphicon-plu | |||
'headerOptions' => ['class' => 'column-actions'], | |||
'contentOptions' => ['class' => 'column-actions'], | |||
'buttons' => [ | |||
'transform' => function ($url, $quotation) use ($quotationManager) { | |||
return ($quotationManager->isStatusValid($quotation) ? Html::a('<span class="glyphicon glyphicon-check"></span>', $url, [ | |||
'transform' => function ($url, $quotation) use ($quotationModule) { | |||
return ($quotationModule->isStatusValid($quotation) ? Html::a('<span class="glyphicon glyphicon-check"></span>', $url, [ | |||
'title' => 'Transformer en facture', 'class' => 'btn btn-default' | |||
]) : ''); | |||
}, | |||
'validate' => function ($url, $quotation) use ($quotationManager) { | |||
return ($quotationManager->isStatusValid($quotation) ? Html::a('<span class="glyphicon glyphicon-ok"></span>', $url, [ | |||
'validate' => function ($url, $quotation) use ($quotationModule) { | |||
return ($quotationModule->isStatusValid($quotation) ? Html::a('<span class="glyphicon glyphicon-ok"></span>', $url, [ | |||
'title' => 'Valider', 'class' => 'btn btn-default' | |||
]) : ''); | |||
}, | |||
@@ -131,13 +131,13 @@ $this->addButton(['label' => 'Nouveau devis <span class="glyphicon glyphicon-plu | |||
'title' => 'Télécharger', 'class' => 'btn btn-default' | |||
]); | |||
}, | |||
'update' => function ($url, $quotation) use ($quotationManager) { | |||
return ($quotationManager->isStatusDraft($quotation) ? Html::a('<span class="glyphicon glyphicon-pencil"></span>', $url, [ | |||
'update' => function ($url, $quotation) use ($quotationModule) { | |||
return ($quotationModule->isStatusDraft($quotation) ? Html::a('<span class="glyphicon glyphicon-pencil"></span>', $url, [ | |||
'title' => 'Modifier', 'class' => 'btn btn-default' | |||
]) : ''); | |||
}, | |||
'delete' => function ($url, $quotation) use ($quotationManager) { | |||
return ($quotationManager->isStatusDraft($quotation) ? Html::a('<span class="glyphicon glyphicon-trash"></span>', $url, [ | |||
'delete' => function ($url, $quotation) use ($quotationModule) { | |||
return ($quotationModule->isStatusDraft($quotation) ? Html::a('<span class="glyphicon glyphicon-trash"></span>', $url, [ | |||
'title' => 'Supprimer', 'class' => 'btn btn-default' | |||
]) : ''); | |||
} |
@@ -44,7 +44,7 @@ use common\logic\Subscription\Subscription\Model\Subscription; | |||
\backend\assets\VuejsSubscriptionFormAsset::register($this); | |||
$userModule = $this->getUserModule(); | |||
$pointSaleManager = $this->getPointSaleManager(); | |||
$pointSaleModule = $this->getPointSaleModule(); | |||
?> | |||
@@ -65,7 +65,7 @@ $pointSaleManager = $this->getPointSaleManager(); | |||
<div class="clr"></div> | |||
<?= $form->field($model, 'id_producer')->hiddenInput() ?> | |||
<?= $form->field($model, 'id_point_sale')->dropDownList(ArrayHelper::map($pointSaleManager->findPointSales(), 'id', function($model, $defaultValue) { | |||
<?= $form->field($model, 'id_point_sale')->dropDownList(ArrayHelper::map($pointSaleModule->findPointSales(), 'id', function($model, $defaultValue) { | |||
return $model['name']; | |||
}), ['prompt' => '--','class' => 'form-control user-id']) ?> | |||
<?= $form->field($model, 'date_begin') ?> |
@@ -36,17 +36,17 @@ pris connaissance de la licence CeCILL, et que vous en avez accepté les | |||
termes. | |||
*/ | |||
use common\logic\Subscription\Subscription\Wrapper\SubscriptionManager; | |||
use common\logic\Subscription\Subscription\Module\SubscriptionModule; | |||
use yii\helpers\Html; | |||
use yii\grid\GridView; | |||
use common\helpers\GlobalParam ; | |||
use common\logic\Subscription\Subscription\Model\Subscription; | |||
use common\logic\PointSale\PointSale\Model\PointSale; | |||
use common\logic\Product\Product\Wrapper\ProductManager; | |||
use common\logic\Product\Product\Module\ProductModule; | |||
use yii\helpers\ArrayHelper; | |||
use common\logic\Product\Product\Model\Product; | |||
$subscriptionManager = SubscriptionManager::getInstance(); | |||
$subscriptionModule = SubscriptionModule::getInstance(); | |||
$this->setTitle('Abonnements') ; | |||
$this->addBreadcrumb($this->getTitle()) ; | |||
@@ -85,12 +85,12 @@ $subscriptionsArray = Subscription::searchAll() ; | |||
'filterOptions' => ['class' => 'column-hide-on-mobile'], | |||
'contentOptions' => ['class' => 'column-hide-on-mobile'], | |||
'value' => function($model) { | |||
$productManager = ProductManager::getInstance(); | |||
$productModule = ProductModule::getInstance(); | |||
$html = '' ; | |||
foreach($model->productSubscription as $productSubscription) | |||
{ | |||
if(isset($productSubscription->product)) { | |||
$html .= Html::encode($productSubscription->product->name).' ('.($productSubscription->quantity * Product::$unitsArray[$productSubscription->product->unit]['coefficient']).' '. $productManager->strUnit($productSubscription->product->unit, 'wording_short').')<br />' ; | |||
$html .= Html::encode($productSubscription->product->name).' ('.($productSubscription->quantity * Product::$unitsArray[$productSubscription->product->unit]['coefficient']).' '. $productModule->strUnit($productSubscription->product->unit, 'wording_short').')<br />' ; | |||
} | |||
else { | |||
$html .= 'Produit non défini<br />' ; | |||
@@ -125,8 +125,8 @@ $subscriptionsArray = Subscription::searchAll() ; | |||
'headerOptions' => ['class' => 'column-hide-on-mobile'], | |||
'filterOptions' => ['class' => 'column-hide-on-mobile'], | |||
'contentOptions' => ['class' => 'column-hide-on-mobile'], | |||
'value' => function($model) use ($subscriptionManager) { | |||
return $subscriptionManager->getPeriodAsHtml($model); | |||
'value' => function($model) use ($subscriptionModule) { | |||
return $subscriptionModule->getPeriodAsHtml($model); | |||
} | |||
], | |||
[ | |||
@@ -145,8 +145,8 @@ $subscriptionsArray = Subscription::searchAll() ; | |||
'headerOptions' => ['class' => 'column-hide-on-mobile'], | |||
'filterOptions' => ['class' => 'column-hide-on-mobile'], | |||
'contentOptions' => ['class' => 'text-small column-hide-on-mobile'], | |||
'value' => function($model) use ($subscriptionManager) { | |||
return $subscriptionManager->getDaysAsHtml($model); | |||
'value' => function($model) use ($subscriptionModule) { | |||
return $subscriptionModule->getDaysAsHtml($model); | |||
} | |||
], | |||
[ |
@@ -37,11 +37,11 @@ | |||
*/ | |||
use common\logic\Ticket\Ticket\Model\Ticket; | |||
use common\logic\Ticket\Ticket\Wrapper\TicketManager; | |||
use common\logic\Ticket\Ticket\Module\TicketModule; | |||
use yii\helpers\Html; | |||
use yii\grid\GridView; | |||
$ticketManager = TicketManager::getInstance(); | |||
$ticketModule = TicketModule::getInstance(); | |||
$userCurrent = $this->getUserCurrent(); | |||
$this->setTitle('Support & contact'); | |||
$this->addBreadcrumb($this->getTitle()); | |||
@@ -120,7 +120,7 @@ $this->addBreadcrumb($this->getTitle()); | |||
function ticketList($context, $searchTicket, $dataProviderTicket, $userCurrent) | |||
{ | |||
$ticketManager = TicketManager::getInstance(); | |||
$ticketModule = TicketModule::getInstance(); | |||
$columnCreatedAt = [ | |||
'attribute' => 'created_at', | |||
@@ -133,10 +133,10 @@ function ticketList($context, $searchTicket, $dataProviderTicket, $userCurrent) | |||
'attribute' => 'subject', | |||
'headerOptions' => ['class' => 'td-subject'], | |||
'format' => 'raw', | |||
'value' => function ($ticket) use ($ticketManager, $userCurrent) { | |||
'value' => function ($ticket) use ($ticketModule, $userCurrent) { | |||
if($ticketManager->isTicketUnread($ticket, $userCurrent)) { | |||
$firstTicketMessageUnread = $ticketManager->getFirstTicketMessageUnread($ticket, $userCurrent); | |||
if($ticketModule->isTicketUnread($ticket, $userCurrent)) { | |||
$firstTicketMessageUnread = $ticketModule->getFirstTicketMessageUnread($ticket, $userCurrent); | |||
$link = '<strong>'.Html::a($ticket->subject, ['view', 'id' => $ticket->id, '#' => $firstTicketMessageUnread->id]).'</strong>'; | |||
} | |||
else { | |||
@@ -189,8 +189,8 @@ function ticketList($context, $searchTicket, $dataProviderTicket, $userCurrent) | |||
'title' => 'Voir le ticket', 'class' => 'btn btn-default' | |||
]); | |||
}, | |||
'close-open' => function ($url, $ticket) use ($ticketManager) { | |||
if ($ticketManager->isTicketOpen($ticket)) { | |||
'close-open' => function ($url, $ticket) use ($ticketModule) { | |||
if ($ticketModule->isTicketOpen($ticket)) { | |||
$title = 'Fermer'; | |||
$url = ['close', 'id' => $ticket->id]; | |||
$glyphicon = 'glyphicon-folder-close'; |
@@ -1,12 +1,12 @@ | |||
<?php | |||
use common\helpers\GlobalParam; | |||
use common\logic\Ticket\Ticket\Wrapper\TicketManager; | |||
use common\logic\User\User\Wrapper\UserModule; | |||
use common\logic\Ticket\Ticket\Module\TicketModule; | |||
use common\logic\User\User\Module\UserModule; | |||
use yii\helpers\Html; | |||
use yii\widgets\ActiveForm; | |||
$ticketManager = TicketManager::getInstance(); | |||
$ticketModule = TicketModule::getInstance(); | |||
$userModule = UserModule::getInstance(); | |||
$userCurrent = GlobalParam::getCurrentUser(); | |||
$this->setTitle('Voir un ticket'); | |||
@@ -25,16 +25,16 @@ $this->addBreadcrumb('Voir un ticket'); | |||
</tr> | |||
<tr> | |||
<td><strong>Ouverture</strong></td> | |||
<td><?= $ticketManager->getTicketDateCreatedAtFormat($ticket); ?></td> | |||
<td><?= $ticketModule->getTicketDateCreatedAtFormat($ticket); ?></td> | |||
</tr> | |||
<tr> | |||
<td><strong>Statut</strong></td> | |||
<td><?= $ticketManager->getTicketStatusLabelAsHtml($ticket); ?></td> | |||
<td><?= $ticketModule->getTicketStatusLabelAsHtml($ticket); ?></td> | |||
</tr> | |||
<?php if($userModule->getAuthorizationChecker()->isGrantedAsAdministrator($userCurrent)): ?> | |||
<tr> | |||
<td><strong>Producteur</strong></td> | |||
<td><?= $ticketManager->isTicketUnread($ticket, $ticket->user) ? | |||
<td><?= $ticketModule->isTicketUnread($ticket, $ticket->user) ? | |||
'<span class="label label-warning">Non lu</span>' : | |||
'<span class="label label-success">Lu</span>'; ?> | |||
</td> | |||
@@ -78,10 +78,10 @@ $this->addBreadcrumb('Voir un ticket'); | |||
</div> | |||
</div> | |||
<div class="box <?= $ticketManager->isTicketOpen($ticket) ? 'box-danger' : 'box-success'; ?>"> | |||
<div class="box <?= $ticketModule->isTicketOpen($ticket) ? 'box-danger' : 'box-success'; ?>"> | |||
<div class="box-header"> | |||
<h3 class="box-title"> | |||
<?php if($ticketManager->isTicketOpen($ticket)): ?> | |||
<?php if($ticketModule->isTicketOpen($ticket)): ?> | |||
<i class="fa fa-folder"></i> Cliquez ici si vous souhaitez fermer le ticket | |||
<?php else: ?> | |||
<i class="fa fa-folder-open"></i> Cliquez ici si vous souhaitez rouvrir le ticket | |||
@@ -89,7 +89,7 @@ $this->addBreadcrumb('Voir un ticket'); | |||
</h3> | |||
</div> | |||
<div class="box-body"> | |||
<?php if($ticketManager->isTicketOpen($ticket)): ?> | |||
<?php if($ticketModule->isTicketOpen($ticket)): ?> | |||
<?= Html::a('Fermer le ticket', ['close', 'id' => $ticket->id], ['class' => 'btn btn-danger btn-sm']) ?> | |||
<?php else: ?> | |||
<?= Html::a('Rouvrir le ticket', ['open', 'id' => $ticket->id], ['class' => 'btn btn-success btn-sm']) ?> |
@@ -43,7 +43,7 @@ use yii\helpers\ArrayHelper; | |||
\backend\assets\VuejsUserFormAsset::register($this); | |||
$userModule = $this->getUserModule(); | |||
$producerManager = $this->getProducerManager(); | |||
$producerModule = $this->getProducerModule(); | |||
?> | |||
@@ -66,7 +66,7 @@ $producerManager = $this->getProducerManager(); | |||
<?= $form->field($model, 'newsletter')->checkbox() ?> | |||
<?= $form->field($model, 'address')->textarea() ?> | |||
<?php if ($producerManager->getConfig('option_export_evoliz')): ?> | |||
<?php if ($producerModule->getConfig('option_export_evoliz')): ?> | |||
<?= $form->field($model, 'evoliz_code')->textInput() ?> | |||
<?php endif; ?> | |||
@@ -43,8 +43,8 @@ use common\helpers\GlobalParam; | |||
use common\logic\Payment\Model\Payment; | |||
use common\helpers\MeanPayment; | |||
$paymentManager = $this->getPaymentManager(); | |||
$producerManager = $this->getProducerManager(); | |||
$paymentManager = $this->getPaymentModule(); | |||
$producerModule = $this->getProducerModule(); | |||
$userModule = $this->getUserModule(); | |||
$this->setTitle('Créditer <small>'.Html::encode($user->lastname.' '.$user->name).'</small>', 'Créditer '.Html::encode($user->lastname.' '.$user->name)) ; | |||
@@ -57,7 +57,7 @@ $this->addBreadcrumb('Créditer') ; | |||
<div class="user-credit"> | |||
<?php | |||
$producer = $producerManager->findOneProducerById(GlobalParam::getCurrentProducerId()); | |||
$producer = $producerModule->findOneProducerById(GlobalParam::getCurrentProducerId()); | |||
if(!$producer->credit) | |||
{ |
@@ -37,15 +37,15 @@ | |||
*/ | |||
use common\helpers\GlobalParam; | |||
use common\logic\Producer\Producer\Wrapper\ProducerManager; | |||
use common\logic\Producer\Producer\Module\ProducerModule; | |||
use yii\helpers\Html; | |||
use yii\grid\GridView; | |||
use common\logic\User\User\Wrapper\UserModule; | |||
use common\logic\User\User\Module\UserModule; | |||
use common\logic\Order\Order\Model\Order; | |||
use common\logic\User\UserProducer\Model\UserProducer; | |||
$userModule = UserModule::getInstance(); | |||
$producerManager = ProducerManager::getInstance(); | |||
$producerModule = ProducerModule::getInstance(); | |||
$userCurrent = GlobalParam::getCurrentUser(); | |||
$this->setTitle('Utilisateurs'); | |||
@@ -69,7 +69,7 @@ $this->render('_menu', [ | |||
<?= GridView::widget([ | |||
'dataProvider' => $dataProvider, | |||
'filterModel' => $searchModel, | |||
'summary' => $this->getProducerContainer()->getProducerPageSizer() | |||
'summary' => $this->getProducerModule()->getProducerPageSizer() | |||
->getPageSizeSummary($producer, 'user', 'Utilisateurs'), | |||
'columns' => [ | |||
[ |
@@ -40,7 +40,7 @@ use yii\grid\GridView; | |||
use yii\helpers\Html; | |||
$userModule = $this->getUserModule(); | |||
$orderManager = $this->getOrderManager(); | |||
$orderModule = $this->getOrderModule(); | |||
$this->setTitle('Commandes <small>' . Html::encode($userModule->getUsername($user)) . '</small>', 'Commandes de ' . Html::encode($userModule->getUsername($user))); | |||
$this->addBreadcrumb(['label' => 'Utilisateurs', 'url' => ['index']]); | |||
@@ -64,30 +64,30 @@ $this->addBreadcrumb('Commandes'); | |||
[ | |||
'label' => 'Historique', | |||
'format' => 'raw', | |||
'value' => function ($order) use ($orderManager) { | |||
return $orderManager->getHistorySummary($order); | |||
'value' => function ($order) use ($orderModule) { | |||
return $orderModule->getHistorySummary($order); | |||
} | |||
], | |||
[ | |||
'label' => 'Résumé', | |||
'format' => 'raw', | |||
'value' => function ($order) use ($orderManager) { | |||
return $orderManager->getCartSummary($order); | |||
'value' => function ($order) use ($orderModule) { | |||
return $orderModule->getCartSummary($order); | |||
} | |||
], | |||
[ | |||
'label' => 'Point de vente', | |||
'format' => 'raw', | |||
'value' => function ($order) use ($orderManager) { | |||
return $orderManager->getPointSaleSummary($order); | |||
'value' => function ($order) use ($orderModule) { | |||
return $orderModule->getPointSaleSummary($order); | |||
} | |||
], | |||
[ | |||
'label' => 'Montant', | |||
'format' => 'raw', | |||
'value' => function ($order) use ($orderManager) { | |||
$orderManager->initOrder($order); | |||
return $orderManager->getAmountSummary($order); | |||
'value' => function ($order) use ($orderModule) { | |||
$orderModule->initOrder($order); | |||
return $orderModule->getAmountSummary($order); | |||
} | |||
], | |||
[ |
@@ -9,44 +9,44 @@ class BusinessLogic | |||
{ | |||
use BusinessLogicTrait; | |||
public function getContainers() | |||
public function getModules() | |||
{ | |||
return [ | |||
$this->getTaxRateContainer(), | |||
$this->getUserUserGroupContainer(), | |||
$this->getUserGroupContainer(), | |||
$this->getPaymentContainer(), | |||
$this->getProducerPriceRangeContainer(), | |||
$this->getUserProducerContainer(), | |||
$this->getUserPointSaleContainer(), | |||
$this->getUserContainer(), | |||
$this->getPointSaleDistributionContainer(), | |||
$this->getProductDistributionContainer(), | |||
$this->getProductCategoryContainer(), | |||
$this->getProductPointSaleContainer(), | |||
$this->getProductOrderContainer(), | |||
$this->getProductPriceContainer(), | |||
$this->getProductSubscriptionContainer(), | |||
$this->getTicketUserContainer(), | |||
$this->getTicketMessageContainer(), | |||
$this->getTicketContainer(), | |||
$this->getQuotationContainer(), | |||
$this->getInvoiceContainer(), | |||
$this->getDeliveryNoteContainer(), | |||
$this->getDocumentContainer(), | |||
$this->getPointSaleContainer(), | |||
$this->getProductContainer(), | |||
$this->getSubscriptionContainer(), | |||
$this->getDistributionContainer(), | |||
$this->getProducerContainer(), | |||
$this->getOrderContainer(), | |||
$this->getTaxRateModule(), | |||
$this->getUserUserGroupModule(), | |||
$this->getUserGroupModule(), | |||
$this->getPaymentModule(), | |||
$this->getProducerPriceRangeModule(), | |||
$this->getUserProducerModule(), | |||
$this->getUserPointSaleModule(), | |||
$this->getUserModule(), | |||
$this->getPointSaleDistributionModule(), | |||
$this->getProductDistributionModule(), | |||
$this->getProductCategoryModule(), | |||
$this->getProductPointSaleModule(), | |||
$this->getProductOrderModule(), | |||
$this->getProductPriceModule(), | |||
$this->getProductSubscriptionModule(), | |||
$this->getTicketUserModule(), | |||
$this->getTicketMessageModule(), | |||
$this->getTicketModule(), | |||
$this->getQuotationModule(), | |||
$this->getInvoiceModule(), | |||
$this->getDeliveryNoteModule(), | |||
$this->getDocumentModule(), | |||
$this->getPointSaleModule(), | |||
$this->getProductModule(), | |||
$this->getSubscriptionModule(), | |||
$this->getDistributionModule(), | |||
$this->getProducerModule(), | |||
$this->getOrderModule(), | |||
]; | |||
} | |||
public function setProducerContext(Producer $producer) | |||
{ | |||
foreach($this->getContainers() as $container) { | |||
foreach($container->getServices() as $serviceClass) { | |||
foreach($this->getModules() as $module) { | |||
foreach($module->getServices() as $serviceClass) { | |||
$instanceService = $serviceClass::getInstance(); | |||
$instanceService->setProducerContext($producer); | |||
} | |||
@@ -57,13 +57,13 @@ class BusinessLogic | |||
* Hiérarchie des apps | |||
*/ | |||
public function getContainerLevelHierarchyByService($serviceClass): int | |||
public function getModuleLevelHierarchyByService($serviceClass): int | |||
{ | |||
$containersArray = $this->getContainers(); | |||
$modulesArray = $this->getModules(); | |||
$entityFqcnService = $this->getEntityFqcnByService($serviceClass); | |||
foreach($containersArray as $key => $container) { | |||
if($container->getEntityFqcn() == $entityFqcnService) { | |||
foreach($modulesArray as $key => $module) { | |||
if($module->getEntityFqcn() == $entityFqcnService) { | |||
return $key; | |||
} | |||
} | |||
@@ -71,14 +71,14 @@ class BusinessLogic | |||
public function getEntityFqcnByService(string $serviceClass): string | |||
{ | |||
$containersArray = $this->getContainers(); | |||
$modulesArray = $this->getModules(); | |||
foreach($containersArray as $container) { | |||
if(in_array($serviceClass, $container->getServices())) { | |||
return $container->getEntityFqcn(); | |||
foreach($modulesArray as $module) { | |||
if(in_array($serviceClass, $module->getServices())) { | |||
return $module->getEntityFqcn(); | |||
} | |||
} | |||
throw new ErrorException('Service '.$serviceClass.' introuvable dans les containers.'); | |||
throw new ErrorException('Service '.$serviceClass.' introuvable dans les modules.'); | |||
} | |||
} |
@@ -2,180 +2,151 @@ | |||
namespace common\components; | |||
use common\logic\Config\TaxRate\Wrapper\TaxRateContainer; | |||
use common\logic\Config\TaxRate\Wrapper\TaxRateManager; | |||
use common\logic\Distribution\Distribution\Wrapper\DistributionManager; | |||
use common\logic\Distribution\Distribution\Wrapper\DistributionContainer; | |||
use common\logic\Distribution\PointSaleDistribution\Wrapper\PointSaleDistributionContainer; | |||
use common\logic\Distribution\PointSaleDistribution\Wrapper\PointSaleDistributionManager; | |||
use common\logic\Distribution\ProductDistribution\Wrapper\ProductDistributionContainer; | |||
use common\logic\Distribution\ProductDistribution\Wrapper\ProductDistributionManager; | |||
use common\logic\Document\DeliveryNote\Wrapper\DeliveryNoteContainer; | |||
use common\logic\Document\DeliveryNote\Wrapper\DeliveryNoteManager; | |||
use common\logic\Document\Document\Wrapper\DocumentContainer; | |||
use common\logic\Document\Document\Wrapper\DocumentManager; | |||
use common\logic\Document\Invoice\Wrapper\InvoiceContainer; | |||
use common\logic\Document\Invoice\Wrapper\InvoiceManager; | |||
use common\logic\Document\Quotation\Wrapper\QuotationContainer; | |||
use common\logic\Document\Quotation\Wrapper\QuotationManager; | |||
use common\logic\Opinion\Wrapper\OpinionManager; | |||
use common\logic\Order\Order\Wrapper\OrderContainer; | |||
use common\logic\Order\Order\Wrapper\OrderManager; | |||
use common\logic\Order\ProductOrder\Wrapper\ProductOrderContainer; | |||
use common\logic\Order\ProductOrder\Wrapper\ProductOrderManager; | |||
use common\logic\Payment\Wrapper\PaymentContainer; | |||
use common\logic\Payment\Wrapper\PaymentManager; | |||
use common\logic\PointSale\PointSale\Wrapper\PointSaleContainer; | |||
use common\logic\PointSale\PointSale\Wrapper\PointSaleManager; | |||
use common\logic\PointSale\UserPointSale\Wrapper\UserPointSaleContainer; | |||
use common\logic\PointSale\UserPointSale\Wrapper\UserPointSaleManager; | |||
use common\logic\Producer\Producer\Wrapper\ProducerContainer; | |||
use common\logic\Producer\Producer\Wrapper\ProducerManager; | |||
use common\logic\Producer\ProducerPriceRange\Wrapper\ProducerPriceRangeContainer; | |||
use common\logic\Producer\ProducerPriceRange\Wrapper\ProducerPriceRangeManager; | |||
use common\logic\Product\Product\Wrapper\ProductContainer; | |||
use common\logic\Product\Product\Wrapper\ProductManager; | |||
use common\logic\Product\ProductCategory\Wrapper\ProductCategoryContainer; | |||
use common\logic\Product\ProductCategory\Wrapper\ProductCategoryManager; | |||
use common\logic\Product\ProductPointSale\Wrapper\ProductPointSaleContainer; | |||
use common\logic\Product\ProductPointSale\Wrapper\ProductPointSaleManager; | |||
use common\logic\Product\ProductPrice\Wrapper\ProductPriceContainer; | |||
use common\logic\Product\ProductPrice\Wrapper\ProductPriceManager; | |||
use common\logic\Subscription\ProductSubscription\Wrapper\ProductSubscriptionContainer; | |||
use common\logic\Subscription\ProductSubscription\Wrapper\ProductSubscriptionManager; | |||
use common\logic\Subscription\Subscription\Wrapper\SubscriptionContainer; | |||
use common\logic\Subscription\Subscription\Wrapper\SubscriptionManager; | |||
use common\logic\Ticket\Ticket\Wrapper\TicketContainer; | |||
use common\logic\Ticket\Ticket\Wrapper\TicketManager; | |||
use common\logic\Ticket\TicketMessage\Wrapper\TicketMessageContainer; | |||
use common\logic\Ticket\TicketMessage\Wrapper\TicketMessageManager; | |||
use common\logic\Ticket\TicketUser\Wrapper\TicketUserContainer; | |||
use common\logic\Ticket\TicketUser\Wrapper\TicketUserManager; | |||
use common\logic\User\User\Wrapper\UserContainer; | |||
use common\logic\User\User\Wrapper\UserManager; | |||
use common\logic\User\User\Wrapper\UserModule; | |||
use common\logic\User\UserGroup\Wrapper\UserGroupContainer; | |||
use common\logic\User\UserGroup\Wrapper\UserGroupManager; | |||
use common\logic\User\UserProducer\Wrapper\UserProducerContainer; | |||
use common\logic\User\UserProducer\Wrapper\UserProducerManager; | |||
use common\logic\User\UserUserGroup\Wrapper\UserUserGroupContainer; | |||
use common\logic\User\UserUserGroup\Wrapper\UserUserGroupManager; | |||
use common\logic\Config\TaxRate\Module\TaxRateModule; | |||
use common\logic\Distribution\Distribution\Module\DistributionModule; | |||
use common\logic\Distribution\PointSaleDistribution\Module\PointSaleDistributionModule; | |||
use common\logic\Distribution\ProductDistribution\Module\ProductDistributionModule; | |||
use common\logic\Document\DeliveryNote\Module\DeliveryNoteModule; | |||
use common\logic\Document\Document\Module\DocumentModule; | |||
use common\logic\Document\Invoice\Module\InvoiceModule; | |||
use common\logic\Document\Quotation\Module\QuotationModule; | |||
use common\logic\Opinion\Module\OpinionModule; | |||
use common\logic\Order\Order\Module\OrderModule; | |||
use common\logic\Order\ProductOrder\Module\ProductOrderModule; | |||
use common\logic\Payment\Module\PaymentModule; | |||
use common\logic\PointSale\PointSale\Module\PointSaleModule; | |||
use common\logic\PointSale\UserPointSale\Module\UserPointSaleModule; | |||
use common\logic\Producer\Producer\Module\ProducerModule; | |||
use common\logic\Producer\ProducerPriceRange\Module\ProducerPriceRangeModule; | |||
use common\logic\Product\Product\Module\ProductModule; | |||
use common\logic\Product\ProductCategory\Module\ProductCategoryModule; | |||
use common\logic\Product\ProductPointSale\Module\ProductPointSaleModule; | |||
use common\logic\Product\ProductPrice\Module\ProductPriceModule; | |||
use common\logic\Subscription\ProductSubscription\Module\ProductSubscriptionModule; | |||
use common\logic\Subscription\Subscription\Module\SubscriptionModule; | |||
use common\logic\Ticket\Ticket\Module\TicketModule; | |||
use common\logic\Ticket\TicketMessage\Module\TicketMessageModule; | |||
use common\logic\Ticket\TicketUser\Module\TicketUserModule; | |||
use common\logic\User\User\Module\UserModule; | |||
use common\logic\User\UserGroup\Module\UserGroupModule; | |||
use common\logic\User\UserProducer\Module\UserProducerModule; | |||
use common\logic\User\UserUserGroup\Module\UserUserGroupModule; | |||
trait BusinessLogicTrait | |||
{ | |||
public function getOpinionManager(): OpinionManager | |||
public function getOpinionModule(): OpinionModule | |||
{ | |||
return OpinionManager::getInstance(); | |||
return OpinionModule::getInstance(); | |||
} | |||
public function getUserProducerManager(): UserProducerManager | |||
public function getUserProducerModule(): UserProducerModule | |||
{ | |||
return UserProducerManager::getInstance(); | |||
return UserProducerModule::getInstance(); | |||
} | |||
public function getOrderManager(): OrderManager | |||
public function getOrderModule(): OrderModule | |||
{ | |||
return OrderManager::getInstance(); | |||
return OrderModule::getInstance(); | |||
} | |||
public function getTaxRateManager(): TaxRateManager | |||
public function getTaxRateModule(): TaxRateModule | |||
{ | |||
return TaxRateManager::getInstance(); | |||
return TaxRateModule::getInstance(); | |||
} | |||
public function getDistributionManager(): DistributionManager | |||
public function getDistributionModule(): DistributionModule | |||
{ | |||
return DistributionManager::getInstance(); | |||
return DistributionModule::getInstance(); | |||
} | |||
public function getPointSaleDistributionManager(): PointSaleDistributionManager | |||
public function getPointSaleDistributionModule(): PointSaleDistributionModule | |||
{ | |||
return PointSaleDistributionManager::getInstance(); | |||
return PointSaleDistributionModule::getInstance(); | |||
} | |||
public function getProductDistributionManager(): ProductDistributionManager | |||
public function getProductDistributionModule(): ProductDistributionModule | |||
{ | |||
return ProductDistributionManager::getInstance(); | |||
return ProductDistributionModule::getInstance(); | |||
} | |||
public function getDeliveryNoteManager(): DeliveryNoteManager | |||
public function getDeliveryNoteModule(): DeliveryNoteModule | |||
{ | |||
return DeliveryNoteManager::getInstance(); | |||
return DeliveryNoteModule::getInstance(); | |||
} | |||
public function getDocumentManager(): DocumentManager | |||
public function getDocumentModule(): DocumentModule | |||
{ | |||
return DocumentManager::getInstance(); | |||
return DocumentModule::getInstance(); | |||
} | |||
public function getInvoiceManager(): InvoiceManager | |||
public function getInvoiceModule(): InvoiceModule | |||
{ | |||
return InvoiceManager::getInstance(); | |||
return InvoiceModule::getInstance(); | |||
} | |||
public function getQuotationManager(): QuotationManager | |||
public function getQuotationModule(): QuotationModule | |||
{ | |||
return QuotationManager::getInstance(); | |||
return QuotationModule::getInstance(); | |||
} | |||
public function getProductOrderManager(): ProductOrderManager | |||
public function getProductOrderModule(): ProductOrderModule | |||
{ | |||
return ProductOrderManager::getInstance(); | |||
return ProductOrderModule::getInstance(); | |||
} | |||
public function getPointSaleManager(): PointSaleManager | |||
public function getPointSaleModule(): PointSaleModule | |||
{ | |||
return PointSaleManager::getInstance(); | |||
return PointSaleModule::getInstance(); | |||
} | |||
public function getUserPointSaleManager(): UserPointSaleManager | |||
public function getUserPointSaleModule(): UserPointSaleModule | |||
{ | |||
return UserPointSaleManager::getInstance(); | |||
return UserPointSaleModule::getInstance(); | |||
} | |||
public function getProducerManager(): ProducerManager | |||
public function getProducerModule(): ProducerModule | |||
{ | |||
return ProducerManager::getInstance(); | |||
return ProducerModule::getInstance(); | |||
} | |||
public function getProducerPriceRangeManager(): ProducerPriceRangeManager | |||
public function getProducerPriceRangeModule(): ProducerPriceRangeModule | |||
{ | |||
return ProducerPriceRangeManager::getInstance(); | |||
return ProducerPriceRangeModule::getInstance(); | |||
} | |||
public function getProductManager(): ProductManager | |||
public function getProductModule(): ProductModule | |||
{ | |||
return ProductManager::getInstance(); | |||
return ProductModule::getInstance(); | |||
} | |||
public function getProductCategoryManager(): ProductCategoryManager | |||
public function getProductCategoryModule(): ProductCategoryModule | |||
{ | |||
return ProductCategoryManager::getInstance(); | |||
return ProductCategoryModule::getInstance(); | |||
} | |||
public function getProductPointSaleManager(): ProductPointSaleManager | |||
public function getProductPointSaleModule(): ProductPointSaleModule | |||
{ | |||
return ProductPointSaleManager::getInstance(); | |||
return ProductPointSaleModule::getInstance(); | |||
} | |||
public function getProductPriceManager(): ProductPriceManager | |||
public function getProductPriceModule(): ProductPriceModule | |||
{ | |||
return ProductPriceManager::getInstance(); | |||
return ProductPriceModule::getInstance(); | |||
} | |||
public function getProductSubscriptionManager(): ProductSubscriptionManager | |||
public function getProductSubscriptionModule(): ProductSubscriptionModule | |||
{ | |||
return ProductSubscriptionManager::getInstance(); | |||
return ProductSubscriptionModule::getInstance(); | |||
} | |||
public function getSubscriptionManager(): SubscriptionManager | |||
public function getSubscriptionModule(): SubscriptionModule | |||
{ | |||
return SubscriptionManager::getInstance(); | |||
return SubscriptionModule::getInstance(); | |||
} | |||
public function getPaymentManager(): PaymentManager | |||
public function getPaymentModule(): PaymentModule | |||
{ | |||
return PaymentManager::getInstance(); | |||
return PaymentModule::getInstance(); | |||
} | |||
public function getUserModule(): UserModule | |||
@@ -183,168 +154,28 @@ trait BusinessLogicTrait | |||
return UserModule::getInstance(); | |||
} | |||
public function getUserContainer(): UserContainer | |||
public function getUserGroupModule(): UserGroupModule | |||
{ | |||
return UserContainer::getInstance(); | |||
return UserGroupModule::getInstance(); | |||
} | |||
public function getUserGroupManager(): UserGroupManager | |||
public function getUserUserGroupModule(): UserUserGroupModule | |||
{ | |||
return UserGroupManager::getInstance(); | |||
return UserUserGroupModule::getInstance(); | |||
} | |||
public function getUserUserGroupManager(): UserUserGroupManager | |||
public function getTicketModule(): TicketModule | |||
{ | |||
return UserUserGroupManager::getInstance(); | |||
return TicketModule::getInstance(); | |||
} | |||
public function getTicketManager(): TicketManager | |||
public function getTicketMessageModule(): TicketMessageModule | |||
{ | |||
return TicketManager::getInstance(); | |||
return TicketMessageModule::getInstance(); | |||
} | |||
public function getTicketMessageManager(): TicketMessageManager | |||
public function getTicketUserModule(): TicketUserModule | |||
{ | |||
return TicketMessageManager::getInstance(); | |||
} | |||
public function getTicketUserManager(): TicketUserManager | |||
{ | |||
return TicketUserManager::getInstance(); | |||
} | |||
public function getProducerContainer(): ProducerContainer | |||
{ | |||
return ProducerContainer::getInstance(); | |||
} | |||
public function getProducerPriceRangeContainer(): ProducerPriceRangeContainer | |||
{ | |||
return ProducerPriceRangeContainer::getInstance(); | |||
} | |||
public function getUserProducerContainer(): UserProducerContainer | |||
{ | |||
return UserProducerContainer::getInstance(); | |||
} | |||
public function getPaymentContainer(): PaymentContainer | |||
{ | |||
return PaymentContainer::getInstance(); | |||
} | |||
public function getDocumentContainer(): DocumentContainer | |||
{ | |||
return DocumentContainer::getInstance(); | |||
} | |||
public function getDeliveryNoteContainer(): DeliveryNoteContainer | |||
{ | |||
return DeliveryNoteContainer::getInstance(); | |||
} | |||
public function getInvoiceContainer(): InvoiceContainer | |||
{ | |||
return InvoiceContainer::getInstance(); | |||
} | |||
public function getQuotationContainer(): QuotationContainer | |||
{ | |||
return QuotationContainer::getInstance(); | |||
} | |||
public function getUserGroupContainer(): UserGroupContainer | |||
{ | |||
return UserGroupContainer::getInstance(); | |||
} | |||
public function getUserUserGroupContainer(): UserUserGroupContainer | |||
{ | |||
return UserUserGroupContainer::getInstance(); | |||
} | |||
public function getDistributionContainer(): DistributionContainer | |||
{ | |||
return DistributionContainer::getInstance(); | |||
} | |||
public function getTaxRateContainer(): TaxRateContainer | |||
{ | |||
return TaxRateContainer::getInstance(); | |||
} | |||
public function getOrderContainer(): OrderContainer | |||
{ | |||
return OrderContainer::getInstance(); | |||
} | |||
public function getUserPointSaleContainer(): UserPointSaleContainer | |||
{ | |||
return UserPointSaleContainer::getInstance(); | |||
} | |||
public function getPointSaleContainer(): PointSaleContainer | |||
{ | |||
return PointSaleContainer::getInstance(); | |||
} | |||
public function getProductOrderContainer(): ProductOrderContainer | |||
{ | |||
return ProductOrderContainer::getInstance(); | |||
} | |||
public function getProductContainer(): ProductContainer | |||
{ | |||
return ProductContainer::getInstance(); | |||
} | |||
public function getProductCategoryContainer(): ProductCategoryContainer | |||
{ | |||
return ProductCategoryContainer::getInstance(); | |||
} | |||
public function getProductPointSaleContainer(): ProductPointSaleContainer | |||
{ | |||
return ProductPointSaleContainer::getInstance(); | |||
} | |||
public function getProductPriceContainer(): ProductPriceContainer | |||
{ | |||
return ProductPriceContainer::getInstance(); | |||
} | |||
public function getSubscriptionContainer(): SubscriptionContainer | |||
{ | |||
return SubscriptionContainer::getInstance(); | |||
} | |||
public function getProductSubscriptionContainer(): ProductSubscriptionContainer | |||
{ | |||
return ProductSubscriptionContainer::getInstance(); | |||
} | |||
public function getPointSaleDistributionContainer(): PointSaleDistributionContainer | |||
{ | |||
return PointSaleDistributionContainer::getInstance(); | |||
} | |||
public function getProductDistributionContainer(): ProductDistributionContainer | |||
{ | |||
return ProductDistributionContainer::getInstance(); | |||
} | |||
public function getTicketContainer(): TicketContainer | |||
{ | |||
return TicketContainer::getInstance(); | |||
} | |||
public function getTicketMessageContainer(): TicketMessageContainer | |||
{ | |||
return TicketMessageContainer::getInstance(); | |||
} | |||
public function getTicketUserContainer(): TicketUserContainer | |||
{ | |||
return TicketUserContainer::getInstance(); | |||
return TicketUserModule::getInstance(); | |||
} | |||
} |
@@ -41,8 +41,8 @@ namespace common\forms; | |||
use common\logic\Product\Product\Model\Product; | |||
use common\logic\Subscription\ProductSubscription\Model\ProductSubscription; | |||
use common\logic\Subscription\Subscription\Model\Subscription; | |||
use common\logic\Subscription\Subscription\Wrapper\SubscriptionManager; | |||
use common\logic\User\User\Wrapper\UserModule; | |||
use common\logic\Subscription\Subscription\Module\SubscriptionModule; | |||
use common\logic\User\User\Module\UserModule; | |||
use Yii; | |||
use yii\base\Model; | |||
@@ -118,14 +118,14 @@ class SubscriptionForm extends Model | |||
public function save() | |||
{ | |||
$userModule = UserModule::getInstance(); | |||
$subscriptionManager = SubscriptionManager::getInstance(); | |||
$subscriptionModule = SubscriptionModule::getInstance(); | |||
if ($this->id) { | |||
$subscription = Subscription::searchOne(['id' => $this->id]) ; | |||
$subscription->populateUpdatedBy($userModule->getCurrent()); | |||
} | |||
else { | |||
$subscription = $subscriptionManager->instanciateSubscription($userModule->getCurrent()) ; | |||
$subscription = $subscriptionModule->instanciateSubscription($userModule->getCurrent()) ; | |||
} | |||
if ($subscription) { |
@@ -38,7 +38,7 @@ | |||
namespace common\helpers; | |||
use common\logic\Producer\Producer\Wrapper\ProducerManager; | |||
use common\logic\Producer\Producer\Module\ProducerModule; | |||
class CSV | |||
{ | |||
@@ -51,8 +51,8 @@ class CSV | |||
public static function array2csv(array &$array) | |||
{ | |||
$producerManager = ProducerManager::getInstance(); | |||
$separator = $producerManager->getConfig('option_csv_separator') ?: ';'; | |||
$producerModule = ProducerModule::getInstance(); | |||
$separator = $producerModule->getConfig('option_csv_separator') ?: ';'; | |||
if (count($array) == 0) { | |||
return null; |
@@ -39,7 +39,7 @@ | |||
namespace common\helpers; | |||
use common\logic\Producer\Producer\Model\Producer; | |||
use common\logic\Producer\Producer\Wrapper\ProducerManager; | |||
use common\logic\Producer\Producer\Module\ProducerModule; | |||
use common\logic\User\User\Service\UserSolver; | |||
class GlobalParam | |||
@@ -61,9 +61,9 @@ class GlobalParam | |||
public static function getCurrentProducer() | |||
{ | |||
$producerManager = ProducerManager::getInstance(); | |||
$producerModule = ProducerModule::getInstance(); | |||
if(!\Yii::$app->parameterBag->has('producer') || !\Yii::$app->parameterBag->get('producer')) { | |||
\Yii::$app->parameterBag->set('producer', $producerManager->findOneProducerById(self::getCurrentProducerId())); | |||
\Yii::$app->parameterBag->set('producer', $producerModule->findOneProducerById(self::getCurrentProducerId())); | |||
} | |||
return \Yii::$app->parameterBag->get('producer'); |
@@ -39,8 +39,8 @@ | |||
namespace common\helpers; | |||
use common\logic\Order\Order\Model\Order; | |||
use common\logic\Order\Order\Wrapper\OrderManager; | |||
use common\logic\Producer\Producer\Wrapper\ProducerManager; | |||
use common\logic\Order\Order\Module\OrderModule; | |||
use common\logic\Producer\Producer\Module\ProducerModule; | |||
use linslin\yii2\curl; | |||
class Tiller | |||
@@ -54,12 +54,12 @@ class Tiller | |||
public function __construct() | |||
{ | |||
$producerManager = ProducerManager::getInstance(); | |||
$producerModule = ProducerModule::getInstance(); | |||
$this->curl = new curl\Curl(); | |||
$this->producer_tiller = $producerManager->getConfig('tiller'); | |||
$this->provider_token = $producerManager->getConfig('tiller_provider_token'); | |||
$this->restaurant_token = $producerManager->getConfig('tiller_restaurant_token'); | |||
$this->producer_tiller = $producerModule->getConfig('tiller'); | |||
$this->provider_token = $producerModule->getConfig('tiller_provider_token'); | |||
$this->restaurant_token = $producerModule->getConfig('tiller_restaurant_token'); | |||
} | |||
public function getOrders($date) | |||
@@ -82,7 +82,7 @@ class Tiller | |||
public function isSynchro($date, $idOrder = null) | |||
{ | |||
$orderManager = OrderManager::getInstance(); | |||
$orderModule = OrderModule::getInstance(); | |||
if ($this->producer_tiller) { | |||
$ordersTiller = $this->getOrders($date); | |||
@@ -98,13 +98,13 @@ class Tiller | |||
if ($ordersOpendistrib) { | |||
foreach ($ordersOpendistrib as $orderOpendistrib) { | |||
$orderManager->initOrder($orderOpendistrib); | |||
$orderModule->initOrder($orderOpendistrib); | |||
$ordersOpendistribSynchro[$orderOpendistrib->id] = false; | |||
if (isset($ordersTiller->orders)) { | |||
foreach ($ordersTiller->orders as $orderTiller) { | |||
if ($orderOpendistrib->tiller_external_id == $orderTiller->id) { | |||
$amountTotalPaidOrderOpendistrib = (int)round( | |||
$orderManager->getOrderAmountWithTax($orderOpendistrib, Order::AMOUNT_PAID) * 100 | |||
$orderModule->getOrderAmountWithTax($orderOpendistrib, Order::AMOUNT_PAID) * 100 | |||
); | |||
if ($amountTotalPaidOrderOpendistrib >= (int)$orderTiller->currentPayedAmount | |||
|| $amountTotalPaidOrderOpendistrib >= (int)$orderTiller->currentBill) { |
@@ -1,11 +0,0 @@ | |||
<?php | |||
namespace common\logic; | |||
abstract class AbstractContainer extends AbstractSingleton implements ContainerInterface | |||
{ | |||
public function getEntityFqcn(): string | |||
{ | |||
return $this->getDefinition()->getEntityFqcn(); | |||
} | |||
} |
@@ -1,40 +0,0 @@ | |||
<?php | |||
namespace common\logic; | |||
use yii\base\ErrorException; | |||
abstract class AbstractManager extends AbstractSingleton implements ManagerInterface | |||
{ | |||
protected ContainerInterface $container; | |||
public function __call($method, $args) | |||
{ | |||
foreach($this->getContainer()->getServices() as $serviceClass) { | |||
if(method_exists($serviceClass, $method)) { | |||
return call_user_func_array( | |||
[$serviceClass::getInstance(), $method], | |||
$args | |||
); | |||
} | |||
} | |||
throw new ErrorException('La méthode '.$method.' est introuvable dans les services du container '.get_class($this->container)); | |||
} | |||
protected function setContainer(ContainerInterface $container): void | |||
{ | |||
$this->container = $container; | |||
} | |||
public function getContainer(): ContainerInterface | |||
{ | |||
return $this->container; | |||
} | |||
public function initContainer(): void | |||
{ | |||
$containerFqcn = $this->getContainerFqcn(); | |||
$this->setContainer($containerFqcn::getInstance()); | |||
} | |||
} |
@@ -47,8 +47,8 @@ abstract class AbstractService extends AbstractSingleton implements ServiceInter | |||
return true; | |||
} | |||
elseif($levelHierarchyServiceAsked == $levelHierarchyServiceCurrent | |||
&& $domain->getContainerLevelHierarchyByService($serviceClassAsked) | |||
< $domain->getContainerLevelHierarchyByService($serviceCurrentClass)) { | |||
&& $domain->getModuleLevelHierarchyByService($serviceClassAsked) | |||
< $domain->getModuleLevelHierarchyByService($serviceCurrentClass)) { | |||
return true; | |||
} |
@@ -25,10 +25,6 @@ abstract class AbstractSingleton | |||
if (!isset(self::$instances[$c])) { | |||
self::$instances[$c] = new $c; | |||
if(in_array(ManagerInterface::class, class_implements(self::$instances[$c]))) { | |||
self::$instances[$c]->initContainer(); | |||
} | |||
if(in_array(ServiceInterface::class, class_implements(self::$instances[$c]))) { | |||
self::$instances[$c]->loadDependencies(); | |||
} |
@@ -1,13 +1,18 @@ | |||
<?php | |||
namespace common\logic\Config\TaxRate\Wrapper; | |||
namespace common\logic\Config\TaxRate\Module; | |||
use common\logic\AbstractContainer; | |||
use common\logic\AbstractModule; | |||
use common\logic\Config\TaxRate\Repository\TaxRateRepository; | |||
use common\logic\Config\TaxRate\Service\TaxRateBuilder; | |||
use common\logic\Config\TaxRate\Service\TaxRateDefinition; | |||
class TaxRateContainer extends AbstractContainer | |||
/** | |||
* @mixin TaxRateDefinition | |||
* @mixin TaxRateRepository | |||
* @mixin TaxRateBuilder | |||
*/ | |||
class TaxRateModule extends AbstractModule | |||
{ | |||
public function getServices(): array | |||
{ |
@@ -1,21 +0,0 @@ | |||
<?php | |||
namespace common\logic\Config\TaxRate\Wrapper; | |||
use common\logic\AbstractManager; | |||
use common\logic\Config\TaxRate\Repository\TaxRateRepository; | |||
use common\logic\Config\TaxRate\Service\TaxRateBuilder; | |||
use common\logic\Config\TaxRate\Service\TaxRateDefinition; | |||
/** | |||
* @mixin TaxRateDefinition | |||
* @mixin TaxRateRepository | |||
* @mixin TaxRateBuilder | |||
*/ | |||
class TaxRateManager extends AbstractManager | |||
{ | |||
public function getContainerFqcn(): string | |||
{ | |||
return TaxRateContainer::class; | |||
} | |||
} |
@@ -1,9 +0,0 @@ | |||
<?php | |||
namespace common\logic; | |||
interface ContainerInterface | |||
{ | |||
public function getServices(): array; | |||
//public function getDefinition(): DefinitionInterface; | |||
} |
@@ -1,8 +1,9 @@ | |||
<?php | |||
namespace common\logic\Distribution\Distribution\Wrapper; | |||
namespace common\logic\Distribution\Distribution\Module; | |||
use common\logic\AbstractContainer; | |||
use common\logic\AbstractManager; | |||
use common\logic\AbstractModule; | |||
use common\logic\Distribution\Distribution\Repository\DistributionRepository; | |||
use common\logic\Distribution\Distribution\Service\DistributionBuilder; | |||
use common\logic\Distribution\Distribution\Service\DistributionDefinition; | |||
@@ -12,7 +13,17 @@ use common\logic\Distribution\Distribution\Service\DistributionReportPdfGenerato | |||
use common\logic\Distribution\Distribution\Service\DistributionShoppingCartLabelsPdfGenerator; | |||
use common\logic\Distribution\Distribution\Service\DistributionSolver; | |||
class DistributionContainer extends AbstractContainer | |||
/** | |||
* @mixin DistributionDefinition | |||
* @mixin DistributionSolver | |||
* @mixin DistributionRepository | |||
* @mixin DistributionBuilder | |||
* @mixin DistributionReportCsvGenerator | |||
* @mixin DistributionReportGridPdfGenerator | |||
* @mixin DistributionReportPdfGenerator | |||
* @mixin DistributionShoppingCartLabelsPdfGenerator | |||
*/ | |||
class DistributionModule extends AbstractModule | |||
{ | |||
public function getServices(): array | |||
{ | |||
@@ -33,8 +44,38 @@ class DistributionContainer extends AbstractContainer | |||
return DistributionDefinition::getInstance(); | |||
} | |||
public function getSolver(): DistributionSolver | |||
{ | |||
return DistributionSolver::getInstance(); | |||
} | |||
public function getRepository(): DistributionRepository | |||
{ | |||
return DistributionRepository::getInstance(); | |||
} | |||
public function getBuilder(): DistributionBuilder | |||
{ | |||
return DistributionBuilder::getInstance(); | |||
} | |||
public function getReportCsvGenerator(): DistributionReportCsvGenerator | |||
{ | |||
return DistributionReportCsvGenerator::getInstance(); | |||
} | |||
public function getReportGridPdfGenerator(): DistributionReportGridPdfGenerator | |||
{ | |||
return DistributionReportGridPdfGenerator::getInstance(); | |||
} | |||
public function getReportPdfGenerator(): DistributionReportPdfGenerator | |||
{ | |||
return DistributionReportPdfGenerator::getInstance(); | |||
} | |||
public function getShoppingCartLabelsPdfGenerator(): DistributionShoppingCartLabelsPdfGenerator | |||
{ | |||
return DistributionShoppingCartLabelsPdfGenerator::getInstance(); | |||
} | |||
} |
@@ -106,7 +106,7 @@ class DistributionReportCsvGenerator extends AbstractGenerator | |||
} | |||
$orderLine[$productsIndexArray[$productOrder->id_product]] .= $productOrder->quantity; | |||
if ($productOrder->product->unit != $productOrder->unit) { | |||
$orderLine[$productsIndexArray[$productOrder->id_product]] .= $productManager->strUnit( | |||
$orderLine[$productsIndexArray[$productOrder->id_product]] .= $productModule->strUnit( | |||
$productOrder->unit, | |||
'wording_short', | |||
true |
@@ -1,31 +0,0 @@ | |||
<?php | |||
namespace common\logic\Distribution\Distribution\Wrapper; | |||
use common\logic\AbstractManager; | |||
use common\logic\Distribution\Distribution\Repository\DistributionRepository; | |||
use common\logic\Distribution\Distribution\Service\DistributionBuilder; | |||
use common\logic\Distribution\Distribution\Service\DistributionDefinition; | |||
use common\logic\Distribution\Distribution\Service\DistributionReportCsvGenerator; | |||
use common\logic\Distribution\Distribution\Service\DistributionReportGridPdfGenerator; | |||
use common\logic\Distribution\Distribution\Service\DistributionReportPdfGenerator; | |||
use common\logic\Distribution\Distribution\Service\DistributionShoppingCartLabelsPdfGenerator; | |||
use common\logic\Distribution\Distribution\Service\DistributionSolver; | |||
/** | |||
* @mixin DistributionDefinition | |||
* @mixin DistributionSolver | |||
* @mixin DistributionRepository | |||
* @mixin DistributionBuilder | |||
* @mixin DistributionReportCsvGenerator | |||
* @mixin DistributionReportGridPdfGenerator | |||
* @mixin DistributionReportPdfGenerator | |||
* @mixin DistributionShoppingCartLabelsPdfGenerator | |||
*/ | |||
class DistributionManager extends AbstractManager | |||
{ | |||
public function getContainerFqcn(): string | |||
{ | |||
return DistributionContainer::class; | |||
} | |||
} |
@@ -1,13 +1,18 @@ | |||
<?php | |||
namespace common\logic\Distribution\PointSaleDistribution\Wrapper; | |||
namespace common\logic\Distribution\PointSaleDistribution\Module; | |||
use common\logic\AbstractContainer; | |||
use common\logic\AbstractModule; | |||
use common\logic\Distribution\PointSaleDistribution\Repository\PointSaleDistributionRepository; | |||
use common\logic\Distribution\PointSaleDistribution\Service\PointSaleDistributionBuilder; | |||
use common\logic\Distribution\PointSaleDistribution\Service\PointSaleDistributionDefinition; | |||
class PointSaleDistributionContainer extends AbstractContainer | |||
/** | |||
* @mixin PointSaleDistributionDefinition | |||
* @mixin PointSaleDistributionRepository | |||
* @mixin PointSaleDistributionBuilder | |||
*/ | |||
class PointSaleDistributionModule extends AbstractModule | |||
{ | |||
public function getServices(): array | |||
{ |
@@ -1,21 +0,0 @@ | |||
<?php | |||
namespace common\logic\Distribution\PointSaleDistribution\Wrapper; | |||
use common\logic\AbstractManager; | |||
use common\logic\Distribution\PointSaleDistribution\Repository\PointSaleDistributionRepository; | |||
use common\logic\Distribution\PointSaleDistribution\Service\PointSaleDistributionBuilder; | |||
use common\logic\Distribution\PointSaleDistribution\Service\PointSaleDistributionDefinition; | |||
/** | |||
* @mixin PointSaleDistributionDefinition | |||
* @mixin PointSaleDistributionRepository | |||
* @mixin PointSaleDistributionBuilder | |||
*/ | |||
class PointSaleDistributionManager extends AbstractManager | |||
{ | |||
public function getContainerFqcn(): string | |||
{ | |||
return PointSaleDistributionContainer::class; | |||
} | |||
} |
@@ -1,14 +1,18 @@ | |||
<?php | |||
namespace common\logic\Distribution\ProductDistribution\Wrapper; | |||
namespace common\logic\Distribution\ProductDistribution\Module; | |||
use common\logic\AbstractContainer; | |||
use common\logic\Distribution\ProductDistribution\Model\ProductDistribution; | |||
use common\logic\AbstractModule; | |||
use common\logic\Distribution\ProductDistribution\Repository\ProductDistributionRepository; | |||
use common\logic\Distribution\ProductDistribution\Service\ProductDistributionBuilder; | |||
use common\logic\Distribution\ProductDistribution\Service\ProductDistributionDefinition; | |||
class ProductDistributionContainer extends AbstractContainer | |||
/** | |||
* @mixin ProductDistributionDefinition | |||
* @mixin ProductDistributionRepository | |||
* @mixin ProductDistributionBuilder | |||
*/ | |||
class ProductDistributionModule extends AbstractModule | |||
{ | |||
public function getServices(): array | |||
{ |
@@ -1,21 +0,0 @@ | |||
<?php | |||
namespace common\logic\Distribution\ProductDistribution\Wrapper; | |||
use common\logic\AbstractManager; | |||
use common\logic\Distribution\ProductDistribution\Repository\ProductDistributionRepository; | |||
use common\logic\Distribution\ProductDistribution\Service\ProductDistributionBuilder; | |||
use common\logic\Distribution\ProductDistribution\Service\ProductDistributionDefinition; | |||
/** | |||
* @mixin ProductDistributionDefinition | |||
* @mixin ProductDistributionRepository | |||
* @mixin ProductDistributionBuilder | |||
*/ | |||
class ProductDistributionManager extends AbstractManager | |||
{ | |||
public function getContainerFqcn(): string | |||
{ | |||
return ProductDistributionContainer::class; | |||
} | |||
} |
@@ -1,14 +1,20 @@ | |||
<?php | |||
namespace common\logic\Document\DeliveryNote\Wrapper; | |||
namespace common\logic\Document\DeliveryNote\Module; | |||
use common\logic\AbstractContainer; | |||
use common\logic\Document\Document\Module\DocumentModule; | |||
use common\logic\Document\DeliveryNote\Repository\DeliveryNoteRepository; | |||
use common\logic\Document\DeliveryNote\Service\DeliveryNoteBuilder; | |||
use common\logic\Document\DeliveryNote\Service\DeliveryNoteDefinition; | |||
use common\logic\Document\DeliveryNote\Service\DeliveryNoteSolver; | |||
class DeliveryNoteContainer extends AbstractContainer | |||
/** | |||
* @mixin DeliveryNoteDefinition | |||
* @mixin DeliveryNoteSolver | |||
* @mixin DeliveryNoteRepository | |||
* @mixin DeliveryNoteBuilder | |||
*/ | |||
class DeliveryNoteModule extends DocumentModule | |||
{ | |||
public function getServices(): array | |||
{ |
@@ -1,23 +0,0 @@ | |||
<?php | |||
namespace common\logic\Document\DeliveryNote\Wrapper; | |||
use common\logic\Document\DeliveryNote\Repository\DeliveryNoteRepository; | |||
use common\logic\Document\DeliveryNote\Service\DeliveryNoteBuilder; | |||
use common\logic\Document\DeliveryNote\Service\DeliveryNoteDefinition; | |||
use common\logic\Document\DeliveryNote\Service\DeliveryNoteSolver; | |||
use common\logic\Document\Document\Wrapper\DocumentManager; | |||
/** | |||
* @mixin DeliveryNoteDefinition | |||
* @mixin DeliveryNoteSolver | |||
* @mixin DeliveryNoteRepository | |||
* @mixin DeliveryNoteBuilder | |||
*/ | |||
class DeliveryNoteManager extends DocumentManager | |||
{ | |||
public function getContainerFqcn(): string | |||
{ | |||
return DeliveryNoteContainer::class; | |||
} | |||
} |
@@ -1,8 +1,8 @@ | |||
<?php | |||
namespace common\logic\Document\Document\Wrapper; | |||
namespace common\logic\Document\Document\Module; | |||
use common\logic\AbstractContainer; | |||
use common\logic\AbstractModule; | |||
use common\logic\DefinitionInterface; | |||
use common\logic\Document\Document\Repository\DocumentRepository; | |||
use common\logic\Document\Document\Service\DocumentBuilder; | |||
@@ -10,7 +10,13 @@ use common\logic\Document\Document\Service\DocumentDefinition; | |||
use common\logic\Document\Document\Service\DocumentSolver; | |||
use common\logic\Document\Document\Service\DocumentUtils; | |||
class DocumentContainer extends AbstractContainer | |||
/** | |||
* @mixin DocumentDefinition | |||
* @mixin DocumentSolver | |||
* @mixin DocumentBuilder | |||
* @mixin DocumentUtils | |||
*/ | |||
class DocumentModule extends AbstractModule | |||
{ | |||
public function getServices(): array | |||
{ | |||
@@ -23,27 +29,27 @@ class DocumentContainer extends AbstractContainer | |||
]; | |||
} | |||
public function getDefinition(): DefinitionInterface | |||
public function getDefinition() | |||
{ | |||
return DocumentDefinition::getInstance(); | |||
} | |||
public function getSolver(): DocumentSolver | |||
public function getSolver() | |||
{ | |||
return DocumentSolver::getInstance(); | |||
} | |||
public function getRepository(): DocumentRepository | |||
public function getRepository() | |||
{ | |||
return DocumentRepository::getInstance(); | |||
} | |||
public function getBuilder(): DocumentBuilder | |||
public function getBuilder() | |||
{ | |||
return DocumentBuilder::getInstance(); | |||
} | |||
public function getUtils(): DocumentUtils | |||
public function getUtils() | |||
{ | |||
return DocumentUtils::getInstance(); | |||
} |
@@ -1,23 +0,0 @@ | |||
<?php | |||
namespace common\logic\Document\Document\Wrapper; | |||
use common\logic\AbstractManager; | |||
use common\logic\Document\Document\Service\DocumentBuilder; | |||
use common\logic\Document\Document\Service\DocumentDefinition; | |||
use common\logic\Document\Document\Service\DocumentSolver; | |||
use common\logic\Document\Document\Service\DocumentUtils; | |||
/** | |||
* @mixin DocumentDefinition | |||
* @mixin DocumentSolver | |||
* @mixin DocumentBuilder | |||
* @mixin DocumentUtils | |||
*/ | |||
class DocumentManager extends AbstractManager | |||
{ | |||
public function getContainerFqcn(): string | |||
{ | |||
return DocumentContainer::class; | |||
} | |||
} |
@@ -1,14 +1,20 @@ | |||
<?php | |||
namespace common\logic\Document\Invoice\Wrapper; | |||
namespace common\logic\Document\Invoice\Module; | |||
use common\logic\AbstractContainer; | |||
use common\logic\Document\Document\Module\DocumentModule; | |||
use common\logic\Document\Invoice\Repository\InvoiceRepository; | |||
use common\logic\Document\Invoice\Service\InvoiceBuilder; | |||
use common\logic\Document\Invoice\Service\InvoiceDefinition; | |||
use common\logic\Document\Invoice\Service\InvoiceSolver; | |||
class InvoiceContainer extends AbstractContainer | |||
/** | |||
* @mixin InvoiceDefinition | |||
* @mixin InvoiceSolver | |||
* @mixin InvoiceRepository | |||
* @mixin InvoiceBuilder | |||
*/ | |||
class InvoiceModule extends DocumentModule | |||
{ | |||
public function getServices(): array | |||
{ |
@@ -1,23 +0,0 @@ | |||
<?php | |||
namespace common\logic\Document\Invoice\Wrapper; | |||
use common\logic\Document\Document\Wrapper\DocumentManager; | |||
use common\logic\Document\Invoice\Repository\InvoiceRepository; | |||
use common\logic\Document\Invoice\Service\InvoiceBuilder; | |||
use common\logic\Document\Invoice\Service\InvoiceDefinition; | |||
use common\logic\Document\Invoice\Service\InvoiceSolver; | |||
/** | |||
* @mixin InvoiceDefinition | |||
* @mixin InvoiceSolver | |||
* @mixin InvoiceRepository | |||
* @mixin InvoiceBuilder | |||
*/ | |||
class InvoiceManager extends DocumentManager | |||
{ | |||
public function getContainerFqcn(): string | |||
{ | |||
return InvoiceContainer::class; | |||
} | |||
} |
@@ -1,14 +1,19 @@ | |||
<?php | |||
namespace common\logic\Document\Quotation\Wrapper; | |||
namespace common\logic\Document\Quotation\Module; | |||
use common\logic\AbstractContainer; | |||
use common\logic\Document\Document\Module\DocumentModule; | |||
use common\logic\Document\Document\Service\DocumentSolver; | |||
use common\logic\Document\Quotation\Repository\QuotationRepository; | |||
use common\logic\Document\Quotation\Service\QuotationBuilder; | |||
use common\logic\Document\Quotation\Service\QuotationDefinition; | |||
class QuotationContainer extends AbstractContainer | |||
/** | |||
* @mixin QuotationDefinition | |||
* @mixin QuotationRepository | |||
* @mixin QuotationBuilder | |||
*/ | |||
class QuotationModule extends DocumentModule | |||
{ | |||
public function getServices(): array | |||
{ | |||
@@ -29,7 +34,7 @@ class QuotationContainer extends AbstractContainer | |||
{ | |||
return DocumentSolver::getInstance(); | |||
} | |||
public function getRepository(): QuotationRepository | |||
{ | |||
return QuotationRepository::getInstance(); |
@@ -1,21 +0,0 @@ | |||
<?php | |||
namespace common\logic\Document\Quotation\Wrapper; | |||
use common\logic\Document\Document\Wrapper\DocumentManager; | |||
use common\logic\Document\Quotation\Repository\QuotationRepository; | |||
use common\logic\Document\Quotation\Service\QuotationBuilder; | |||
use common\logic\Document\Quotation\Service\QuotationDefinition; | |||
/** | |||
* @mixin QuotationDefinition | |||
* @mixin QuotationRepository | |||
* @mixin QuotationBuilder | |||
*/ | |||
class QuotationManager extends DocumentManager | |||
{ | |||
public function getContainerFqcn(): string | |||
{ | |||
return QuotationContainer::class; | |||
} | |||
} |
@@ -1,8 +0,0 @@ | |||
<?php | |||
namespace common\logic; | |||
interface ManagerInterface | |||
{ | |||
public function getContainerFqcn(): string; | |||
} |
@@ -0,0 +1,24 @@ | |||
<?php | |||
namespace common\logic\Opinion\Module; | |||
use common\logic\AbstractModule; | |||
use common\logic\Opinion\Service\OpinionUtils; | |||
/** | |||
* @mixin OpinionUtils | |||
*/ | |||
class OpinionModule extends AbstractModule | |||
{ | |||
public function getServices(): array | |||
{ | |||
return [ | |||
OpinionUtils::class | |||
]; | |||
} | |||
public function getUtils(): OpinionUtils | |||
{ | |||
return OpinionUtils::getInstance(); | |||
} | |||
} |
@@ -1,16 +0,0 @@ | |||
<?php | |||
namespace common\logic\Opinion\Wrapper; | |||
use common\logic\AbstractContainer; | |||
use common\logic\Opinion\Service\OpinionUtils; | |||
class OpinionContainer extends AbstractContainer | |||
{ | |||
public function getServices(): array | |||
{ | |||
return [ | |||
OpinionUtils::class | |||
]; | |||
} | |||
} |
@@ -1,17 +0,0 @@ | |||
<?php | |||
namespace common\logic\Opinion\Wrapper; | |||
use common\logic\AbstractManager; | |||
use common\logic\Opinion\Service\OpinionUtils; | |||
/** | |||
* @mixin OpinionUtils | |||
*/ | |||
class OpinionManager extends AbstractManager | |||
{ | |||
public function getContainerFqcn(): string | |||
{ | |||
return OpinionContainer::class; | |||
} | |||
} |
@@ -4,7 +4,7 @@ namespace common\logic\Order\Order\Event; | |||
use common\logic\Document\DeliveryNote\Event\DeliveryNoteCreateEvent; | |||
use common\logic\Document\DeliveryNote\Model\DeliveryNote; | |||
use common\logic\Order\Order\Wrapper\OrderManager; | |||
use common\logic\Order\Order\Module\OrderModule; | |||
use justcoded\yii2\eventlistener\observers\Observer; | |||
class DeliveryNoteObserver extends Observer | |||
@@ -18,7 +18,7 @@ class DeliveryNoteObserver extends Observer | |||
public function onDeliveryNoteCreate(DeliveryNoteCreateEvent $event) | |||
{ | |||
$orderManager = OrderManager::getInstance(); | |||
$orderManager->assignAllOrdersDeliveryNote($event->idOrders, $event->deliveryNote); | |||
$orderModule = OrderModule::getInstance(); | |||
$orderModule->assignAllOrdersDeliveryNote($event->idOrders, $event->deliveryNote); | |||
} | |||
} |
@@ -1,15 +1,21 @@ | |||
<?php | |||
namespace common\logic\Order\Order\Wrapper; | |||
namespace common\logic\Order\Order\Module; | |||
use common\logic\AbstractContainer; | |||
use common\logic\AbstractModule; | |||
use common\logic\Order\Order\Repository\OrderRepository; | |||
use common\logic\Order\Order\Service\OrderBuilder; | |||
use common\logic\Order\Order\Service\OrderDefinition; | |||
use common\logic\Order\Order\Service\OrderSolver; | |||
use common\logic\Order\Order\Service\OrderUtils; | |||
class OrderContainer extends AbstractContainer | |||
/** | |||
* @mixin OrderDefinition | |||
* @mixin OrderSolver | |||
* @mixin OrderRepository | |||
* @mixin OrderBuilder | |||
*/ | |||
class OrderModule extends AbstractModule | |||
{ | |||
public function getServices(): array | |||
{ |
@@ -1,23 +0,0 @@ | |||
<?php | |||
namespace common\logic\Order\Order\Wrapper; | |||
use common\logic\AbstractManager; | |||
use common\logic\Order\Order\Repository\OrderRepository; | |||
use common\logic\Order\Order\Service\OrderBuilder; | |||
use common\logic\Order\Order\Service\OrderDefinition; | |||
use common\logic\Order\Order\Service\OrderSolver; | |||
/** | |||
* @mixin OrderDefinition | |||
* @mixin OrderSolver | |||
* @mixin OrderRepository | |||
* @mixin OrderBuilder | |||
*/ | |||
class OrderManager extends AbstractManager | |||
{ | |||
public function getContainerFqcn(): string | |||
{ | |||
return OrderContainer::class; | |||
} | |||
} |
@@ -1,14 +1,20 @@ | |||
<?php | |||
namespace common\logic\Order\ProductOrder\Wrapper; | |||
namespace common\logic\Order\ProductOrder\Module; | |||
use common\logic\AbstractContainer; | |||
use common\logic\AbstractModule; | |||
use common\logic\Order\ProductOrder\Repository\ProductOrderRepository; | |||
use common\logic\Order\ProductOrder\Service\ProductOrderBuilder; | |||
use common\logic\Order\ProductOrder\Service\ProductOrderDefinition; | |||
use common\logic\Order\ProductOrder\Service\ProductOrderSolver; | |||
class ProductOrderContainer extends AbstractContainer | |||
/** | |||
* @mixin ProductOrderDefinition | |||
* @mixin ProductOrderSolver | |||
* @mixin ProductOrderRepository | |||
* @mixin ProductOrderBuilder | |||
*/ | |||
class ProductOrderModule extends AbstractModule | |||
{ | |||
public function getServices(): array | |||
{ |
@@ -1,23 +0,0 @@ | |||
<?php | |||
namespace common\logic\Order\ProductOrder\Wrapper; | |||
use common\logic\AbstractManager; | |||
use common\logic\Order\ProductOrder\Repository\ProductOrderRepository; | |||
use common\logic\Order\ProductOrder\Service\ProductOrderBuilder; | |||
use common\logic\Order\ProductOrder\Service\ProductOrderDefinition; | |||
use common\logic\Order\ProductOrder\Service\ProductOrderSolver; | |||
/** | |||
* @mixin ProductOrderDefinition | |||
* @mixin ProductOrderSolver | |||
* @mixin ProductOrderRepository | |||
* @mixin ProductOrderBuilder | |||
*/ | |||
class ProductOrderManager extends AbstractManager | |||
{ | |||
public function getContainerFqcn(): string | |||
{ | |||
return ProductOrderContainer::class; | |||
} | |||
} |