public function actionIndex($section = 'producers') | public function actionIndex($section = 'producers') | ||||
{ | { | ||||
$producerManager = $this->getProducerManager(); | |||||
$producerModule = $this->getProducerModule(); | |||||
$userModule = $this->getUserModule(); | $userModule = $this->getUserModule(); | ||||
if ($section == 'producers') { | if ($section == 'producers') { | ||||
$producers = $producerManager->findProducersActive(); | |||||
$producers = $producerModule->findProducersActive(); | |||||
$usersArray = []; | $usersArray = []; | ||||
$users = []; | $users = []; | ||||
foreach ($producers as $producer) { | foreach ($producers as $producer) { |
public function actionIndex() | public function actionIndex() | ||||
{ | { | ||||
$producer = $this->getProducerCurrent(); | $producer = $this->getProducerCurrent(); | ||||
$pointsSaleArray = $this->getPointSaleManager()->findPointSales(); | |||||
$pointsSaleArray = $this->getPointSaleModule()->findPointSales(); | |||||
return $this->render('index', [ | return $this->render('index', [ | ||||
'producer' => $producer, | 'producer' => $producer, |
public function actionIndex() | public function actionIndex() | ||||
{ | { | ||||
$userModule = $this->getUserModule(); | $userModule = $this->getUserModule(); | ||||
$userProducerManager = $this->getUserProducerManager(); | |||||
$userProducerModule = $this->getUserProducerModule(); | |||||
$dataProviderUsersWithNegativeCredit = new ActiveDataProvider([ | $dataProviderUsersWithNegativeCredit = new ActiveDataProvider([ | ||||
'query' => $userModule->queryUsersWithNegativeCredit(), | 'query' => $userModule->queryUsersWithNegativeCredit(), | ||||
]); | ]); | ||||
return $this->render('index', [ | return $this->render('index', [ | ||||
'sumUserProducerCredits' => $userProducerManager->sumUserProducerCredits(), | |||||
'sumUserProducerCredits' => $userProducerModule->sumUserProducerCredits(), | |||||
'dataProviderUsersWithNegativeCredit' => $dataProviderUsersWithNegativeCredit | 'dataProviderUsersWithNegativeCredit' => $dataProviderUsersWithNegativeCredit | ||||
]); | ]); | ||||
} | } |
*/ | */ | ||||
public function actionProcessOrders($key = '', $forceDate = '') | 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(); | $userModule = $this->getUserModule(); | ||||
if ($key == '64ac0bdab7e9f5e48c4d991ec5201d57') { | if ($key == '64ac0bdab7e9f5e48c4d991ec5201d57') { | ||||
$date = date('Y-m-d', time() + 24 * 60 * 60); | $date = date('Y-m-d', time() + 24 * 60 * 60); | ||||
} | } | ||||
} | } | ||||
$arrayProducers = $producerManager->findProducers(); | |||||
$arrayProducers = $producerModule->findProducers(); | |||||
foreach ($arrayProducers as $producer) { | foreach ($arrayProducers as $producer) { | ||||
$countOrders = 0; | $countOrders = 0; | ||||
$mailOrdersSend = false; | $mailOrdersSend = false; | ||||
$distribution = $distributionManager | |||||
$distribution = $distributionModule | |||||
->findOneDistribution($date, true); | ->findOneDistribution($date, true); | ||||
if ($distribution) { | if ($distribution) { | ||||
'conditions' => 'date_delete IS NULL' | 'conditions' => 'date_delete IS NULL' | ||||
]); | ]); | ||||
$configCredit = $producerManager->getConfig('credit'); | |||||
$configCredit = $producerModule->getConfig('credit'); | |||||
if ($arrayOrders && is_array($arrayOrders)) { | if ($arrayOrders && is_array($arrayOrders)) { | ||||
foreach ($arrayOrders as $order) { | foreach ($arrayOrders as $order) { | ||||
$orderManager->initOrder($order); | |||||
$orderModule->initOrder($order); | |||||
if ($order->auto_payment && $configCredit) { | 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); | $paymentManager->payOrder($order, MeanPayment::CREDIT, $userModule->findOneUserById(User::ID_USER_SYSTEM), false); | ||||
$countOrders++; | $countOrders++; | ||||
} | } | ||||
* Envoi des commandes par email au producteur | * 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([ | $arrayOrders = Order::searchAll([ | ||||
'distribution.date' => $date, | 'distribution.date' => $date, | ||||
'distribution.id_producer' => $producer->id | 'distribution.id_producer' => $producer->id |
{ | { | ||||
return $this->render('index', [ | return $this->render('index', [ | ||||
'producer' => $this->getProducerCurrent(), | '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() | |||||
]); | ]); | ||||
} | } | ||||
} | } |
*/ | */ | ||||
public function actionIndex() | public function actionIndex() | ||||
{ | { | ||||
$producerManager = $this->getProducerManager(); | |||||
$producerModule = $this->getProducerModule(); | |||||
$versionsArray = Opendistrib::getVersions(); | $versionsArray = Opendistrib::getVersions(); | ||||
$versionsRenderArray = []; | $versionsRenderArray = []; | ||||
foreach ($versionsArray as $version) { | foreach ($versionsArray as $version) { | ||||
]; | ]; | ||||
} | } | ||||
$producerManager->updateOpendistribVersion($this->getProducerCurrent()); | |||||
$producerModule->updateOpendistribVersion($this->getProducerCurrent()); | |||||
return $this->render('index', [ | return $this->render('index', [ | ||||
'versionsArray' => $versionsRenderArray | 'versionsArray' => $versionsRenderArray |
{ | { | ||||
$this->checkProductsPointsSale(); | $this->checkProductsPointsSale(); | ||||
$orderManager = $this->getOrderManager(); | |||||
$orderModule = $this->getOrderModule(); | |||||
$format = 'Y-m-d'; | $format = 'Y-m-d'; | ||||
$theDate = ''; | $theDate = ''; | ||||
$orderUpdate = null; | $orderUpdate = null; | ||||
if ($idOrderUpdate) { | if ($idOrderUpdate) { | ||||
$orderUpdate = $orderManager->findOneOrderById($idOrderUpdate); | |||||
$orderUpdate = $orderModule->findOneOrderById($idOrderUpdate); | |||||
} | } | ||||
return $this->render('index', [ | return $this->render('index', [ | ||||
{ | { | ||||
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; | \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(); | $userModule = $this->getUserModule(); | ||||
$producer = $this->getProducerCurrent(); | $producer = $this->getProducerCurrent(); | ||||
$json['units'] = Product::$unitsArray; | $json['units'] = Product::$unitsArray; | ||||
if ($dateObject && $dateObject->format($format) === $date) { | 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; | $ordersArrayObject = $ordersArray; | ||||
$productsArray = $productManager->findProductsByDistribution($distribution, false); | |||||
$productsArray = $productModule->findProductsByDistribution($distribution, false); | |||||
$json['products'] = $this->buildAjaxInfosResponseProducts($distribution, $productsArray, $ordersArray); | $json['products'] = $this->buildAjaxInfosResponseProducts($distribution, $productsArray, $ordersArray); | ||||
$json['distribution'] = $this->buildAjaxInfosResponseDistribution($distribution, $ordersArrayObject, $productsArray); | $json['distribution'] = $this->buildAjaxInfosResponseDistribution($distribution, $ordersArrayObject, $productsArray); | ||||
$json['delivery_notes'] = $this->buildAjaxInfosResponseDeliveryNotes($date); | $json['delivery_notes'] = $this->buildAjaxInfosResponseDeliveryNotes($date); | ||||
$json['order_create'] = $this->buildAjaxInfosResponseOrderCreate($distribution, $productsArray); | $json['order_create'] = $this->buildAjaxInfosResponseOrderCreate($distribution, $productsArray); | ||||
$json['users'] = $userModule->findUsers(); | $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['tiller_is_synchro'] = $this->buildAjaxInfosResponseTiller($producer, $date); | ||||
$json['missing_subscriptions'] = $this->buildAjaxInfosResponseMissingSubscriptions($date, $distribution, $ordersArrayObject); | $json['missing_subscriptions'] = $this->buildAjaxInfosResponseMissingSubscriptions($date, $distribution, $ordersArrayObject); | ||||
} | } | ||||
public function buildAjaxInfosResponsePointsSale(Distribution $distribution) | 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 | // @TODO : à gérer autrement | ||||
foreach($pointsSaleArray as &$pointSaleArray) { | foreach($pointsSaleArray as &$pointSaleArray) { | ||||
$idPointSale = $pointSaleArray['id']; | $idPointSale = $pointSaleArray['id']; | ||||
$pointSale = $pointSaleManager->findOnePointSaleById($idPointSale); | |||||
$pointSale = $pointSaleModule->findOnePointSaleById($idPointSale); | |||||
if(!isset($pointSaleArray['pointSaleDistribution']) || !$pointSaleArray['pointSaleDistribution'] || !count($pointSaleArray['pointSaleDistribution'])) { | if(!isset($pointSaleArray['pointSaleDistribution']) || !$pointSaleArray['pointSaleDistribution'] || !count($pointSaleArray['pointSaleDistribution'])) { | ||||
$pointSaleDistribution = $pointSaleDistributionManager->createPointSaleDistributionIfNotExist($distribution, $pointSale); | |||||
$pointSaleDistribution = $pointSaleDistributionModule->createPointSaleDistributionIfNotExist($distribution, $pointSale); | |||||
$pointSaleArray['pointSaleDistribution'] = [ | $pointSaleArray['pointSaleDistribution'] = [ | ||||
[ | [ | ||||
'id_distribution' => $pointSaleDistribution->id_distribution, | 'id_distribution' => $pointSaleDistribution->id_distribution, | ||||
]; | ]; | ||||
} | } | ||||
$pointSaleArray['credit_functioning'] = $producerManager->getPointSaleCreditFunctioning($pointSale); | |||||
$pointSaleArray['credit_functioning'] = $producerModule->getPointSaleCreditFunctioning($pointSale); | |||||
} | } | ||||
return $pointsSaleArray; | return $pointsSaleArray; | ||||
public function buildAjaxInfosResponseProducts(Distribution $distribution, array $productsArray, array $ordersArray) | public function buildAjaxInfosResponseProducts(Distribution $distribution, array $productsArray, array $ordersArray) | ||||
{ | { | ||||
$distributionManager = $this->getDistributionManager(); | |||||
$orderManager = $this->getOrderManager(); | |||||
$distributionModule = $this-> getDistributionModule(); | |||||
$orderModule = $this->getOrderModule(); | |||||
$jsonProductsArray = []; | $jsonProductsArray = []; | ||||
foreach ($productsArray as $product) { | foreach ($productsArray as $product) { | ||||
$jsonProduct = $product->getAttributes(); | $jsonProduct = $product->getAttributes(); | ||||
$quantityOrder = $orderManager->getProductQuantity($product, $ordersArray); | |||||
$quantityOrder = $orderModule->getProductQuantity($product, $ordersArray); | |||||
$jsonProduct['quantity_ordered'] = $quantityOrder; | $jsonProduct['quantity_ordered'] = $quantityOrder; | ||||
if (!isset($product->productDistribution[0])) { | if (!isset($product->productDistribution[0])) { | ||||
$productDistributionAdd = $distributionManager->addProduct($distribution, $product); | |||||
$productDistributionAdd = $distributionModule->addProduct($distribution, $product); | |||||
if($productDistributionAdd) { | if($productDistributionAdd) { | ||||
$jsonProduct['productDistribution'][0] = $productDistributionAdd->getAttributes(); | $jsonProduct['productDistribution'][0] = $productDistributionAdd->getAttributes(); | ||||
$product->populateRelation('productDistribution', [$productDistributionAdd]); | $product->populateRelation('productDistribution', [$productDistributionAdd]); | ||||
public function buildAjaxInfosResponseDistribution(Distribution $distribution, array $ordersArray, array $productsArray) | 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 = [ | $distributionJsonData = [ | ||||
'id' => $distribution->id, | 'id' => $distribution->id, | ||||
'url_export_shopping_cart_labels' => $this->getUrlManagerBackend()->createUrl( | 'url_export_shopping_cart_labels' => $this->getUrlManagerBackend()->createUrl( | ||||
['distribution/export-shopping-cart-labels', 'date' => $distribution->date] | ['distribution/export-shopping-cart-labels', 'date' => $distribution->date] | ||||
), | ), | ||||
'url_order' => $distributionManager->getLinkOrder($distribution), | |||||
'url_order' => $distributionModule->getLinkOrder($distribution), | |||||
]; | ]; | ||||
// montant et poids des commandes | // montant et poids des commandes | ||||
$weight = 0; | $weight = 0; | ||||
if ($ordersArray) { | if ($ordersArray) { | ||||
foreach ($ordersArray as $order) { | foreach ($ordersArray as $order) { | ||||
$orderManager->initOrder($order); | |||||
$orderModule->initOrder($order); | |||||
if (is_null($order->date_delete)) { | if (is_null($order->date_delete)) { | ||||
$revenues += $orderManager->getOrderAmountWithTax($order); | |||||
$revenues += $orderModule->getOrderAmountWithTax($order); | |||||
$weight += $order->weight; | $weight += $order->weight; | ||||
} | } | ||||
} | } | ||||
} | } | ||||
$distributionJsonData['revenues'] = Price::format($revenues); | $distributionJsonData['revenues'] = Price::format($revenues); | ||||
$distributionJsonData['weight'] = number_format($weight, 2); | $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; | return $distributionJsonData; | ||||
} | } | ||||
public function buildAjaxInfosResponseOrders(array $ordersArray, array $productsArray) | public function buildAjaxInfosResponseOrders(array $ordersArray, array $productsArray) | ||||
{ | { | ||||
$userModule = $this->getUserModule(); | $userModule = $this->getUserModule(); | ||||
$orderManager = $this->getOrderManager(); | |||||
$paymentManager = $this->getPaymentManager(); | |||||
$orderModule = $this->getOrderModule(); | |||||
$paymentManager = $this->getPaymentModule(); | |||||
if ($ordersArray) { | if ($ordersArray) { | ||||
foreach ($ordersArray as &$order) { | foreach ($ordersArray as &$order) { | ||||
$orderManager->initOrder($order); | |||||
$orderModule->initOrder($order); | |||||
$productOrderArray = []; | $productOrderArray = []; | ||||
foreach ($order->productOrder as $productOrder) { | foreach ($order->productOrder as $productOrder) { | ||||
$order = array_merge($order->getAttributes(), [ | $order = array_merge($order->getAttributes(), [ | ||||
'selected' => false, | 'selected' => false, | ||||
'weight' => $order->weight, | '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( | 'user' => (isset($order->user)) ? array_merge( | ||||
$order->user->getAttributes(), | $order->user->getAttributes(), | ||||
$arrayCreditUser | $arrayCreditUser | ||||
'productOrder' => $productOrderArray, | 'productOrder' => $productOrderArray, | ||||
'paymentsArray' => $paymentArray, | 'paymentsArray' => $paymentArray, | ||||
'oneProductUnactivated' => $oneProductUnactivated, | '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, | 'debitCredit' => false, | ||||
]); | ]); | ||||
} | } | ||||
public function buildAjaxInfosResponseOrderCreate(Distribution $distribution, array $productsArray) | public function buildAjaxInfosResponseOrderCreate(Distribution $distribution, array $productsArray) | ||||
{ | { | ||||
$pointSaleManager = $this->getPointSaleManager(); | |||||
$pointSaleDefault = $pointSaleManager->findOnePointSaleDefaultByDistribution($distribution); | |||||
$pointSaleModule = $this->getPointSaleModule(); | |||||
$pointSaleDefault = $pointSaleModule->findOnePointSaleDefaultByDistribution($distribution); | |||||
$productOrderArray = []; | $productOrderArray = []; | ||||
foreach ($productsArray as $product) { | foreach ($productsArray as $product) { | ||||
public function buildAjaxInfosResponseMissingSubscriptions(string $date, Distribution $distribution, array $ordersArray) | public function buildAjaxInfosResponseMissingSubscriptions(string $date, Distribution $distribution, array $ordersArray) | ||||
{ | { | ||||
$subscriptionManager = $this->getSubscriptionManager(); | |||||
$subscriptionModule = $this->getSubscriptionModule(); | |||||
$missingSubscriptionsArray = []; | $missingSubscriptionsArray = []; | ||||
$arraySubscriptions = $subscriptionManager->findSubscriptionsByDate($date); | |||||
$arraySubscriptions = $subscriptionModule->findSubscriptionsByDate($date); | |||||
if ($distribution->active) { | if ($distribution->active) { | ||||
foreach ($arraySubscriptions as $subscription) { | foreach ($arraySubscriptions as $subscription) { | ||||
if (!$subscriptionManager->hasOrderAlreadyExist($subscription, $ordersArray) | |||||
if (!$subscriptionModule->hasOrderAlreadyExist($subscription, $ordersArray) | |||||
&& $subscription->productSubscription && count($subscription->productSubscription) | && $subscription->productSubscription && count($subscription->productSubscription) | ||||
&& $subscription->id_point_sale && $subscription->id_point_sale > 0) { | && $subscription->id_point_sale && $subscription->id_point_sale > 0) { | ||||
$missingSubscriptionsArray[] = [ | $missingSubscriptionsArray[] = [ | ||||
'username' => $subscriptionManager->getUsername($subscription) | |||||
'username' => $subscriptionModule->getUsername($subscription) | |||||
]; | ]; | ||||
} | } | ||||
} | } | ||||
{ | { | ||||
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; | \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; | ||||
$userModule = $this->getUserModule(); | $userModule = $this->getUserModule(); | ||||
$orderManager = $this->getOrderManager(); | |||||
$orderModule = $this->getOrderModule(); | |||||
$user = $userModule->findOneUserById($idUser); | $user = $userModule->findOneUserById($idUser); | ||||
$idFavoritePointSale = 0; | $idFavoritePointSale = 0; | ||||
if($user) { | if($user) { | ||||
$favoritePointSale = $orderManager->getUserFavoritePointSale($user); | |||||
$favoritePointSale = $orderModule->getUserFavoritePointSale($user); | |||||
if ($favoritePointSale) { | if ($favoritePointSale) { | ||||
$idFavoritePointSale = $favoritePointSale->id; | $idFavoritePointSale = $favoritePointSale->id; | ||||
} | } | ||||
{ | { | ||||
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; | \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; | ||||
$distributionManager = $this->getDistributionManager(); | |||||
$orderManager = $this->getOrderManager(); | |||||
$distributionModule = $this-> getDistributionModule(); | |||||
$orderModule = $this->getOrderModule(); | |||||
$userModule = $this->getUserModule(); | $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); | $user = $userModule->findOneUserById($idUser); | ||||
$pointSale = $pointSaleManager->findOnePointSaleById($idPointSale); | |||||
$pointSale = $pointSaleModule->findOnePointSaleById($idPointSale); | |||||
$productsArray = Product::find() | $productsArray = Product::find() | ||||
->where([ | ->where([ | ||||
$productOrderArray = []; | $productOrderArray = []; | ||||
foreach ($productsArray as $product) { | foreach ($productsArray as $product) { | ||||
$priceArray = $productManager->getPriceArray($product, $user, $pointSale); | |||||
$priceArray = $productModule->getPriceArray($product, $user, $pointSale); | |||||
$quantity = 0; | $quantity = 0; | ||||
$invoicePrice = null; | $invoicePrice = null; | ||||
'unit' => $product->unit, | 'unit' => $product->unit, | ||||
'prices' => $priceArray, | 'prices' => $priceArray, | ||||
'active' => $product->productDistribution[0]->active | 'active' => $product->productDistribution[0]->active | ||||
&& (!$pointSale || $productManager->isAvailableOnPointSale($product, $pointSale)), | |||||
&& (!$pointSale || $productModule->isAvailableOnPointSale($product, $pointSale)), | |||||
'invoice_price' => $invoicePrice | 'invoice_price' => $invoicePrice | ||||
]; | ]; | ||||
} | } | ||||
public function actionAjaxUpdateInvoicePrices($idOrder) | 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()) { | if ($order && $order->distribution->id_producer == GlobalParam::getCurrentProducerId()) { | ||||
$userProducer = null; | $userProducer = null; | ||||
if ($order->id_user) { | if ($order->id_user) { | ||||
$userProducer = $userProducerManager->findOneUserProducer($order->user); | |||||
$userProducer = $userProducerModule->findOneUserProducer($order->user); | |||||
} | } | ||||
foreach ($order->productOrder as $productOrder) { | 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, | 'point_sale' => $order->pointSale, | ||||
'user_producer' => $userProducer, | 'user_producer' => $userProducer, | ||||
'quantity' => $productOrder->quantity | 'quantity' => $productOrder->quantity | ||||
$idProducer = $this->getProducerCurrent()->id; | $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); | $this->getLogic()->setProducerContext($producerCurrent); | ||||
$distribution = $distributionManager->findOneDistribution($date); | |||||
$distribution = $distributionModule->findOneDistribution($date); | |||||
if ($distribution) { | if ($distribution) { | ||||
if ($type == 'pdf') { | if ($type == 'pdf') { | ||||
return $distributionManager->generateDistributionReportPdf($distribution, $save); | |||||
return $distributionModule->generateDistributionReportPdf($distribution, $save); | |||||
} | } | ||||
elseif ($type == 'csv') { | elseif ($type == 'csv') { | ||||
$distributionManager->generateDistributionReportCsv($distribution); | |||||
$distributionModule->generateDistributionReportCsv($distribution); | |||||
} | } | ||||
} | } | ||||
} | } | ||||
$idProducer = $this->getProducerCurrent()->id; | $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); | $this->getLogic()->setProducerContext($producerCurrent); | ||||
$distribution = $distributionManager->findOneDistribution($date); | |||||
$distribution = $distributionModule->findOneDistribution($date); | |||||
if ($distribution) { | if ($distribution) { | ||||
return $distributionManager->generateDistributionReportGridPdf($distribution, $save); | |||||
return $distributionModule->generateDistributionReportGridPdf($distribution, $save); | |||||
} | } | ||||
} | } | ||||
public function actionExportShoppingCartLabels(string $date) | public function actionExportShoppingCartLabels(string $date) | ||||
{ | { | ||||
$distributionManager = $this->getDistributionManager(); | |||||
$distribution = $distributionManager->findOneDistribution($date); | |||||
$distributionModule = $this-> getDistributionModule(); | |||||
$distribution = $distributionModule->findOneDistribution($date); | |||||
if($distribution) { | if($distribution) { | ||||
return $distributionManager->generateDistributionShoppingCartLabelsPdf($distribution); | |||||
return $distributionModule->generateDistributionShoppingCartLabelsPdf($distribution); | |||||
} | } | ||||
} | } | ||||
public function actionAjaxProcessProductQuantityMax($idDistribution, $idProduct, $quantityMax) | public function actionAjaxProcessProductQuantityMax($idDistribution, $idProduct, $quantityMax) | ||||
{ | { | ||||
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; | \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; | ||||
$productDistributionManager = $this->getProductDistributionManager(); | |||||
$productDistributionModule = $this->getProductDistributionManager(); | |||||
$productDistribution = $this->getProductDistribution($idProduct, $idDistribution); | $productDistribution = $this->getProductDistribution($idProduct, $idDistribution); | ||||
$productDistributionManager->updateProductDistributionQuantityMax($productDistribution, (float) $quantityMax); | |||||
$productDistributionModule->updateProductDistributionQuantityMax($productDistribution, (float) $quantityMax); | |||||
return ['success']; | return ['success']; | ||||
} | } | ||||
public function actionAjaxProcessActiveProduct(int $idDistribution, int $idProduct, int $active) | public function actionAjaxProcessActiveProduct(int $idDistribution, int $idProduct, int $active) | ||||
{ | { | ||||
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; | \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; | ||||
$productDistributionManager = $this->getProductDistributionManager(); | |||||
$productDistributionModule = $this->getProductDistributionManager(); | |||||
$productDistribution = $this->getProductDistribution($idProduct, $idDistribution); | $productDistribution = $this->getProductDistribution($idProduct, $idDistribution); | ||||
$productDistributionManager->updateProductDistributionActive($productDistribution, $active); | |||||
$productDistributionModule->updateProductDistributionActive($productDistribution, $active); | |||||
return ['success']; | return ['success']; | ||||
} | } | ||||
{ | { | ||||
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; | \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; | $pointSaleDistribution->delivery = $delivery; | ||||
$pointSaleDistributionManager->update($pointSaleDistribution); | |||||
$pointSaleDistributionModule->update($pointSaleDistribution); | |||||
return ['success']; | return ['success']; | ||||
} | } | ||||
public function getProductDistribution(int $idProduct, int $idDistribution) | 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) | |||||
); | ); | ||||
} | } | ||||
public function actionAjaxProcessActiveDistribution(int $idDistribution = 0, string $date = '', bool $active = false) | public function actionAjaxProcessActiveDistribution(int $idDistribution = 0, string $date = '', bool $active = false) | ||||
{ | { | ||||
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; | \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; | ||||
$distributionManager = $this->getDistributionManager(); | |||||
$distributionModule = $this-> getDistributionModule(); | |||||
if ($idDistribution) { | if ($idDistribution) { | ||||
$distribution = $distributionManager->findOneDistributionById($idDistribution); | |||||
$distribution = $distributionModule->findOneDistributionById($idDistribution); | |||||
} | } | ||||
$format = 'Y-m-d'; | $format = 'Y-m-d'; | ||||
$dateObject = DateTime::createFromFormat($format, $date); | $dateObject = DateTime::createFromFormat($format, $date); | ||||
if ($dateObject && $dateObject->format($format) === $date) { | if ($dateObject && $dateObject->format($format) === $date) { | ||||
$distribution = $distributionManager->createDistributionIfNotExist($date); | |||||
$distribution = $distributionModule->createDistributionIfNotExist($date); | |||||
} | } | ||||
if (isset($distribution) && $distribution) { | if (isset($distribution) && $distribution) { | ||||
$distributionManager->activeDistribution($distribution, $active); | |||||
$distributionModule->activeDistribution($distribution, $active); | |||||
return ['success']; | return ['success']; | ||||
} | } | ||||
*/ | */ | ||||
public function actionAjaxProcessAddSubscriptions($date) | public function actionAjaxProcessAddSubscriptions($date) | ||||
{ | { | ||||
$ordersArray = $this->getOrderManager()->createAllOrdersFromSubscriptions($date, true); | |||||
$ordersArray = $this->getOrderModule()->createAllOrdersFromSubscriptions($date, true); | |||||
if($ordersArray && count($ordersArray)) { | if($ordersArray && count($ordersArray)) { | ||||
return Ajax::responseSuccess('Les abonnements ont bien été importés.'); | return Ajax::responseSuccess('Les abonnements ont bien été importés.'); | ||||
{ | { | ||||
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; | \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 = []; | $return = []; | ||||
$producerTiller = $producerManager->getConfig('tiller'); | |||||
$producerTiller = $producerModule->getConfig('tiller'); | |||||
if ($producerTiller) { | if ($producerTiller) { | ||||
$tiller = new Tiller(); | $tiller = new Tiller(); | ||||
if ($orders && count($orders)) { | if ($orders && count($orders)) { | ||||
foreach ($orders as $order) { | foreach ($orders as $order) { | ||||
$orderManager->initOrder($order); | |||||
$orderModule->initOrder($order); | |||||
$lines = []; | $lines = []; | ||||
foreach ($order->productOrder as $productOrder) { | foreach ($order->productOrder as $productOrder) { | ||||
$lines[] = [ | $lines[] = [ | ||||
'name' => $productOrder->product->name, | 'name' => $productOrder->product->name, | ||||
'price' => $productOrderManager->getPriceWithTax($productOrder) * 100 * $productOrder->quantity, | |||||
'price' => $productOrderModule->getPriceWithTax($productOrder) * 100 * $productOrder->quantity, | |||||
'tax' => $productOrder->taxRate->value * 100, | 'tax' => $productOrder->taxRate->value * 100, | ||||
'date' => $strDate, | 'date' => $strDate, | ||||
'quantity' => $productOrder->quantity | 'quantity' => $productOrder->quantity | ||||
'payments' => [ | 'payments' => [ | ||||
[ | [ | ||||
'type' => $typePaymentTiller, | 'type' => $typePaymentTiller, | ||||
'amount' => $orderManager->getOrderAmountWithTax( | |||||
'amount' => $orderModule->getOrderAmountWithTax( | |||||
$order, | $order, | ||||
Order::AMOUNT_PAID | Order::AMOUNT_PAID | ||||
) * 100, | ) * 100, | ||||
public function actionAjaxGenerateDeliveryNotePointSale($idOrders) | public function actionAjaxGenerateDeliveryNotePointSale($idOrders) | ||||
{ | { | ||||
$orderManager = $this->getOrderManager(); | |||||
$deliveryNoteManager = $this->getDeliveryNoteManager(); | |||||
$orderModule = $this->getOrderModule(); | |||||
$deliveryNoteModule = $this->getDeliveryNoteModule(); | |||||
if (strlen($idOrders)) { | if (strlen($idOrders)) { | ||||
$idOrders = json_decode($idOrders, true); | $idOrders = json_decode($idOrders, true); | ||||
if (is_array($idOrders) && count($idOrders) > 0) { | if (is_array($idOrders) && count($idOrders) > 0) { | ||||
reset($idOrders); | reset($idOrders); | ||||
$firstOrder = $orderManager->findOneOrderById((int)$idOrders[key($idOrders)]); | |||||
$firstOrder = $orderModule->findOneOrderById((int)$idOrders[key($idOrders)]); | |||||
$ordersArray = Order::searchAll(['id' => $idOrders,]); | $ordersArray = Order::searchAll(['id' => $idOrders,]); | ||||
$deliveryNote = $deliveryNoteManager->getOneDeliveryNoteExistingFromOrders($ordersArray); | |||||
$deliveryNote = $deliveryNoteModule->getOneDeliveryNoteExistingFromOrders($ordersArray); | |||||
$isUpdate = (bool) $deliveryNote; | $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é.'); | return Ajax::responseError('Vous ne pouvez pas modifier un bon de livraison déjà validé.'); | ||||
} | } | ||||
if ($firstOrder) { | if ($firstOrder) { | ||||
if (!$deliveryNote) { | if (!$deliveryNote) { | ||||
$deliveryNoteManager->createDeliveryNoteForPointSale( | |||||
$deliveryNoteModule->createDeliveryNoteForPointSale( | |||||
$firstOrder->pointSale, | $firstOrder->pointSale, | ||||
$firstOrder->distribution, | $firstOrder->distribution, | ||||
$idOrders | $idOrders | ||||
public function generateDeliveryNote(int $idOrder) | 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) | public function actionAjaxValidateDeliveryNotes($idOrders) | ||||
{ | { | ||||
$orderManager = $this->getOrderManager(); | |||||
$deliveryNoteManager = $this->getDeliveryNoteManager(); | |||||
$orderModule = $this->getOrderModule(); | |||||
$deliveryNoteModule = $this->getDeliveryNoteModule(); | |||||
if (strlen($idOrders)) { | if (strlen($idOrders)) { | ||||
$idOrders = json_decode($idOrders, true); | $idOrders = json_decode($idOrders, true); | ||||
if (is_array($idOrders) && count($idOrders) > 0) { | if (is_array($idOrders) && count($idOrders) > 0) { | ||||
foreach ($idOrders as $idOrder) { | 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) { | if($deliveryNote) { | ||||
$deliveryNoteManager->validateDocument($deliveryNote); | |||||
$deliveryNoteModule->validateDocument($deliveryNote); | |||||
} | } | ||||
} | } | ||||
} | } |
public function actionCreate() | public function actionCreate() | ||||
{ | { | ||||
$documentManager = $this->getDocumentManager(); | |||||
$documentModule = $this->getDocumentModule(); | |||||
$class = $this->getClass(); | $class = $this->getClass(); | ||||
$class = 'common\\logic\\Document\\'.$class.'\\Model\\'.$class; | $class = 'common\\logic\\Document\\'.$class.'\\Model\\'.$class; | ||||
$model = new $class(); | $model = new $class(); | ||||
$documentManager->initTaxCalculationMethod($model); | |||||
$documentModule->initTaxCalculationMethod($model); | |||||
if ($model->load(\Yii::$app->request->post())) { | if ($model->load(\Yii::$app->request->post())) { | ||||
$model->id_producer = GlobalParam::getCurrentProducerId(); | $model->id_producer = GlobalParam::getCurrentProducerId(); | ||||
public function processInvoiceViaDeliveryNotes($model) | 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)) { | if ($model->deliveryNotes && is_array($model->deliveryNotes) && count($model->deliveryNotes)) { | ||||
foreach ($model->deliveryNotes as $key => $idDeliveryNote) { | foreach ($model->deliveryNotes as $key => $idDeliveryNote) { | ||||
$deliveryNote = $deliveryNoteManager->findOneDeliveryNoteById($idDeliveryNote); | |||||
$orderManager->assignAllOrdersInvoiceByDeliveryNote($model, $deliveryNote); | |||||
$deliveryNote = $deliveryNoteModule->findOneDeliveryNoteById($idDeliveryNote); | |||||
$orderModule->assignAllOrdersInvoiceByDeliveryNote($model, $deliveryNote); | |||||
} | } | ||||
} | } | ||||
} | } | ||||
public function processInvoiceViaOrders($model) | 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)) { | if ($model->ordersOnCreate && is_array($model->ordersOnCreate) && count($model->ordersOnCreate)) { | ||||
foreach ($model->ordersOnCreate as $key => $idOrder) { | foreach ($model->ordersOnCreate as $key => $idOrder) { | ||||
$order = $orderManager->findOneOrderById($idOrder); | |||||
$orderManager->updateOrderInvoice($order, $model); | |||||
$order = $orderModule->findOneOrderById($idOrder); | |||||
$orderModule->updateOrderInvoice($order, $model); | |||||
} | } | ||||
} | } | ||||
} | } | ||||
public function actionUpdate($id) | public function actionUpdate($id) | ||||
{ | { | ||||
$documentManager = $this->getDocumentManager(); | |||||
$paymentManager = $this->getPaymentManager(); | |||||
$documentModule = $this->getDocumentModule(); | |||||
$paymentManager = $this->getPaymentModule(); | |||||
$document = $this->findModel($id); | $document = $this->findModel($id); | ||||
if (!$document) { | if (!$document) { | ||||
} | } | ||||
$payment = null; | $payment = null; | ||||
if($documentManager->isDocumentInvoice($document) && $documentManager->isStatusValid($document)) { | |||||
if($documentModule->isDocumentInvoice($document) && $documentModule->isStatusValid($document)) { | |||||
$payment = $paymentManager->instanciatePayment( | $payment = $paymentManager->instanciatePayment( | ||||
Payment::TYPE_PAYMENT, | 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(), | $this->getProducerCurrent(), | ||||
null, | null, | ||||
null, | null, | ||||
public function actionDelete($id) | public function actionDelete($id) | ||||
{ | { | ||||
$documentManager = $this->getDocumentManager(); | |||||
$documentModule = $this->getDocumentModule(); | |||||
$model = $this->findModel($id); | $model = $this->findModel($id); | ||||
if ($documentManager->isStatusValid($model)) { | |||||
if ($documentModule->isStatusValid($model)) { | |||||
throw new UserException('Vous ne pouvez pas supprimer un document validé.'); | throw new UserException('Vous ne pouvez pas supprimer un document validé.'); | ||||
} | } | ||||
$documentManager->delete($model); | |||||
$documentModule->delete($model); | |||||
if ($this->getClass() == 'DeliveryNote') { | if ($this->getClass() == 'DeliveryNote') { | ||||
Order::updateAll([ | Order::updateAll([ | ||||
public function actionExportCsvEvoliz(int $id) | public function actionExportCsvEvoliz(int $id) | ||||
{ | { | ||||
$documentManager = $this->getDocumentManager(); | |||||
$productOrderManager = $this->getProductOrderManager(); | |||||
$documentModule = $this->getDocumentModule(); | |||||
$productOrderModule = $this->getProductOrderModule(); | |||||
$datas = []; | $datas = []; | ||||
$document = $this->findModel($id); | $document = $this->findModel($id); | ||||
'Code Classification vente', | 'Code Classification vente', | ||||
]; | ]; | ||||
foreach ($documentManager->getProductsOrders($document) as $productOrderArray) { | |||||
foreach ($documentModule->getProductsOrders($document) as $productOrderArray) { | |||||
foreach ($productOrderArray as $productOrder) { | foreach ($productOrderArray as $productOrder) { | ||||
$price = $productOrder->getPrice(); | $price = $productOrder->getPrice(); | ||||
if ($documentManager->isInvoicePrice($document) && $productOrder->getInvoicePrice()) { | |||||
if ($documentModule->isInvoicePrice($document) && $productOrder->getInvoicePrice()) { | |||||
$price = $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( | $tva = Price::getVat( | ||||
$priceTotal, | $priceTotal, | ||||
$productOrder->taxRate->value, | $productOrder->taxRate->value, | ||||
// status | // status | ||||
$status = ''; | $status = ''; | ||||
if ($documentManager->isStatusDraft($document)) { | |||||
if ($documentModule->isStatusDraft($document)) { | |||||
$status = 'brouillon_'; | $status = 'brouillon_'; | ||||
} | } | ||||
public function actionDownload($id) | public function actionDownload($id) | ||||
{ | { | ||||
$documentManager = $this->getDocumentManager(); | |||||
$documentModule = $this->getDocumentModule(); | |||||
$document = $this->findModel($id); | $document = $this->findModel($id); | ||||
return $documentManager->downloadPdf($document); | |||||
return $documentModule->downloadPdf($document); | |||||
} | } | ||||
public function actionRegenerate($id) | public function actionRegenerate($id) | ||||
{ | { | ||||
$documentManager = $this->getDocumentManager(); | |||||
$documentModule = $this->getDocumentModule(); | |||||
$document = $this->findModel($id); | $document = $this->findModel($id); | ||||
$documentManager->downloadPdf($document, true); | |||||
$documentModule->downloadPdf($document, true); | |||||
$this->setFlash('success', 'Le document PDF a bien été regénéré.'); | $this->setFlash('success', 'Le document PDF a bien été regénéré.'); | ||||
return $this->redirect([$this->getControllerUrl() . '/update', 'id' => $id]); | return $this->redirect([$this->getControllerUrl() . '/update', 'id' => $id]); | ||||
public function actionSend(int $id, $backUpdateForm = false) | public function actionSend(int $id, $backUpdateForm = false) | ||||
{ | { | ||||
$documentManager = $this->getDocumentManager(); | |||||
$documentModule = $this->getDocumentModule(); | |||||
$document = $this->findModel($id); | $document = $this->findModel($id); | ||||
if ($documentManager->sendDocument($document)) { | |||||
if ($documentModule->sendDocument($document)) { | |||||
$this->setFlash('success', $this->getFlashMessage('send', $document)); | $this->setFlash('success', $this->getFlashMessage('send', $document)); | ||||
} else { | } else { | ||||
$this->setFlash('danger', $this->getFlashMessage('send', $document)); | $this->setFlash('danger', $this->getFlashMessage('send', $document)); | ||||
public function actionAjaxUserInfos($typeAction, $idUser, $classDocument, $idDocument = false) | public function actionAjaxUserInfos($typeAction, $idUser, $classDocument, $idDocument = false) | ||||
{ | { | ||||
$userModule = $this->getUserModule(); | $userModule = $this->getUserModule(); | ||||
$documentManager = $this->getDocumentManager(); | |||||
$orderManager = $this->getOrderManager(); | |||||
$producerManager = $this->getProducerManager(); | |||||
$documentModule = $this->getDocumentModule(); | |||||
$orderModule = $this->getOrderModule(); | |||||
$producerModule = $this->getProducerModule(); | |||||
$producerCurrent = $this->getProducerCurrent(); | $producerCurrent = $this->getProducerCurrent(); | ||||
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; | \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; | ||||
if ($user) { | if ($user) { | ||||
$document = null; | $document = null; | ||||
if ($documentManager->isValidClass($classDocument) && $idDocument) { | |||||
if ($documentModule->isValidClass($classDocument) && $idDocument) { | |||||
$document = $this->findModel($idDocument, $classDocument); | $document = $this->findModel($idDocument, $classDocument); | ||||
} | } | ||||
$json['orders_create_array'] = []; | $json['orders_create_array'] = []; | ||||
$json['orders_update_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') { | 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; | return $json; | ||||
public function initOrdersArray(array $ordersArray) | public function initOrdersArray(array $ordersArray) | ||||
{ | { | ||||
$orderManager = $this->getOrderManager(); | |||||
$orderModule = $this->getOrderModule(); | |||||
$ordersReturnArray = []; | $ordersReturnArray = []; | ||||
foreach($ordersArray as &$order) { | foreach($ordersArray as &$order) { | ||||
$orderManager->initOrder($order); | |||||
$orderModule->initOrder($order); | |||||
$ordersReturnArray[] = [ | $ordersReturnArray[] = [ | ||||
'id' => $order->id, | 'id' => $order->id, | ||||
'date' => $order->distribution->date, | 'date' => $order->distribution->date, | ||||
'name' => date('d/m/Y', strtotime($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) | |||||
]; | ]; | ||||
} | } | ||||
public function addDeliveryNoteToArray($deliveryNote, $isCreate = true) | public function addDeliveryNoteToArray($deliveryNote, $isCreate = true) | ||||
{ | { | ||||
$deliveryNoteManager = $this->getDeliveryNoteManager(); | |||||
$deliveryNoteModule = $this->getDeliveryNoteModule(); | |||||
$deliveryNoteData = array_merge( | $deliveryNoteData = array_merge( | ||||
$deliveryNote->getAttributes(), | $deliveryNote->getAttributes(), | ||||
[ | [ | ||||
'url' => $this->getUrlManagerBackend()->createUrl(['delivery-note/update', 'id' => $deliveryNote->id]), | '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; | return $deliveryNoteData; | ||||
} | } | ||||
public function actionValidate($id, $backUpdateForm = false) | public function actionValidate($id, $backUpdateForm = false) | ||||
{ | { | ||||
$documentManager = $this->getDocumentManager(); | |||||
$documentModule = $this->getDocumentModule(); | |||||
$classDocument = $this->getClass(); | $classDocument = $this->getClass(); | ||||
if ($id > 0 && $documentManager->isValidClass($classDocument)) { | |||||
if ($id > 0 && $documentModule->isValidClass($classDocument)) { | |||||
$document = $this->findModel($id); | $document = $this->findModel($id); | ||||
if ($document) { | if ($document) { | ||||
$documentManager->validateDocument($document); | |||||
$documentModule->validateDocument($document); | |||||
// @TODO : gérer via un événement | // @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)); | $this->setFlash('success', $this->getFlashMessage('validate', $document)); | ||||
{ | { | ||||
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; | \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); | $document = $this->findModel($idDocument, $classDocument); | ||||
if ($document) { | if ($document) { | ||||
$ordersArray = []; | $ordersArray = []; | ||||
$productsArray = $productManager->findProducts(false); | |||||
$productsArray = $productModule->findProducts(false); | |||||
foreach ($document->orders as $order) { | foreach ($document->orders as $order) { | ||||
$orderManager->initOrder($order); | |||||
$orderModule->initOrder($order); | |||||
$productsOrderArray = []; | $productsOrderArray = []; | ||||
foreach ($order->productOrder as $productOrder) { | foreach ($order->productOrder as $productOrder) { | ||||
$ordersArray[$order->id] = array_merge( | $ordersArray[$order->id] = array_merge( | ||||
$order->getAttributes(), | $order->getAttributes(), | ||||
[ | [ | ||||
'username' => $orderManager->getOrderUsername($order), | |||||
'username' => $orderModule->getOrderUsername($order), | |||||
'distribution_date' => isset($order->distribution) ? date( | 'distribution_date' => isset($order->distribution) ? date( | ||||
'd/m/Y', | 'd/m/Y', | ||||
strtotime( | strtotime( | ||||
); | ); | ||||
} | } | ||||
$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 = yii\helpers\ArrayHelper::map( | ||||
$productsArray, | $productsArray, | ||||
'order', | 'order', | ||||
function ($product) use ($document, $userProducer, $pointSale, $productManager) { | |||||
function ($product) use ($document, $userProducer, $pointSale, $productModule) { | |||||
return array_merge($product->getAttributes(), [ | return array_merge($product->getAttributes(), [ | ||||
'unit_coefficient' => Product::$unitsArray[$product->unit]['coefficient'], | '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, | 'wording_unit' => $product->wording_unit, | ||||
'tax_rate' => $product->taxRate->value | 'tax_rate' => $product->taxRate->value | ||||
]); | ]); | ||||
'return' => 'success', | 'return' => 'success', | ||||
'tax_rate_producer' => GlobalParam::getCurrentProducer()->taxRate->value, | 'tax_rate_producer' => GlobalParam::getCurrentProducer()->taxRate->value, | ||||
'document' => array_merge($document->getAttributes(), [ | '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, | 'id_user' => $document->user->id, | ||||
'products' => $productsArray, | 'products' => $productsArray, | ||||
'orders' => $ordersArray, | '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, | $document, | ||||
Order::INVOICE_AMOUNT_TOTAL | 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, | $document, | ||||
Order::INVOICE_AMOUNT_TOTAL | 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 | |||||
]; | ]; | ||||
} | } | ||||
} | } | ||||
public function actionAjaxAddProduct($idDocument, $classDocument, $idProduct, $quantity, $price) | 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); | $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 ($document && $product) { | ||||
if (count($document->orders) == 0) { | if (count($document->orders) == 0) { | ||||
public function actionAjaxDeleteProductOrder($idProductOrder) | public function actionAjaxDeleteProductOrder($idProductOrder) | ||||
{ | { | ||||
$productOrderManager = $this->getProductOrderManager(); | |||||
$productOrderModule = $this->getProductOrderModule(); | |||||
$productOrder = $productOrderManager->findOneProductOrderById($idProductOrder); | |||||
$productOrder = $productOrderModule->findOneProductOrderById($idProductOrder); | |||||
if ($productOrder) { | if ($productOrder) { | ||||
$productOrderManager->delete($productOrder); | |||||
$productOrderModule->delete($productOrder); | |||||
return Ajax::responseSuccess('Produit supprimé'); | return Ajax::responseSuccess('Produit supprimé'); | ||||
} | } | ||||
public function actionAjaxAddOrder($idDocument, $classDocument, $idOrder) | 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."); | return Ajax::responseSuccess("Commande ajoutée à la facture."); | ||||
} | } | ||||
public function actionAjaxDeleteOrder($idDocument, $classDocument, $idOrder) | 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.'); | return Ajax::responseSuccess('Commande supprimée de la facture.'); | ||||
public function actionAjaxIgnoreOrderWhenInvoicing($idDocument, $classDocument, $idOrder) | 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."); | return Ajax::responseSuccess("La commande sera maintenant ignorée au moment de la facturation."); | ||||
} | } | ||||
else { | else { | ||||
*/ | */ | ||||
protected function findModel($idDocument, $classDocument = null) | 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) { | if ($model) { | ||||
return $model; | return $model; |
public function actionAjaxDeleteDeliveryNote($idInvoice, $idDeliveryNote) | 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.'); | return Ajax::responseSuccess('Bon de livraison supprimé de la facture.'); | ||||
} else { | } else { | ||||
return Ajax::responseError('Une erreur est survenue lors de la suppression du bon de livraison.'); | return Ajax::responseError('Une erreur est survenue lors de la suppression du bon de livraison.'); | ||||
public function actionAjaxAddDeliveryNote($idInvoice, $idDeliveryNote) | 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."); | return Ajax::responseSuccess("Bon de livraison ajouté à la facture."); | ||||
} else { | } else { | ||||
return Ajax::responseError("Une erreur est survenue lors de l'ajout du bon de livraison."); | return Ajax::responseError("Une erreur est survenue lors de l'ajout du bon de livraison."); |
array $users | array $users | ||||
) | ) | ||||
{ | { | ||||
$orderManager = $this->getOrderManager(); | |||||
$pointSaleManager = $this->getPointSaleManager(); | |||||
$orderModule = $this->getOrderModule(); | |||||
$pointSaleModule = $this->getPointSaleModule(); | |||||
if ($date != '') { | if ($date != '') { | ||||
$orders = $orderManager->findOrdersByDistribution($distribution); | |||||
$orders = $orderModule->findOrdersByDistribution($distribution); | |||||
foreach ($pointsSale as $point) { | foreach ($pointsSale as $point) { | ||||
$orderManager->initPointSaleOrders($point, $orders); | |||||
$orderModule->initPointSaleOrders($point, $orders); | |||||
if (isset($_POST['submit_pv']) && $_POST['submit_pv']) { | if (isset($_POST['submit_pv']) && $_POST['submit_pv']) { | ||||
// modifs | // modifs | ||||
} | } | ||||
} | } | ||||
$orderManager->generateOrderReference($order); | |||||
$orderModule->generateOrderReference($order); | |||||
} | } | ||||
} | } | ||||
} | } | ||||
*/ | */ | ||||
public function actionIndex($date = '', $returnData = false) | 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()) { | if (!Product::searchCount() || !PointSale::searchCount()) { | ||||
$this->redirect(['dashboard/index', 'error_products_points_sale' => 1]); | $this->redirect(['dashboard/index', 'error_products_points_sale' => 1]); | ||||
$arrayUsers[$user->id] = $user->name . ' ' . $user->lastname; | $arrayUsers[$user->id] = $user->name . ' ' . $user->lastname; | ||||
} | } | ||||
$distribution = $distributionManager->createDistributionIfNotExist($date); | |||||
$distribution = $distributionModule->createDistributionIfNotExist($date); | |||||
if ($distribution) { | if ($distribution) { | ||||
$arrayPointsSale = PointSale::find() | $arrayPointsSale = PointSale::find() | ||||
]) | ]) | ||||
->all(); | ->all(); | ||||
} else { | } else { | ||||
$arrayPointsSale = $pointSaleManager->findPointSales(); | |||||
$arrayPointsSale = $pointSaleModule->findPointSales(); | |||||
} | } | ||||
$arrayProducts = $productManager->findProducts(); | |||||
$arrayProducts = $productModule->findProducts(); | |||||
$this->processOrderForm($distribution, $date, $arrayPointsSale, $arrayProducts, $users); | $this->processOrderForm($distribution, $date, $arrayPointsSale, $arrayProducts, $users); | ||||
// commandes | // commandes | ||||
$arrayOrders = $orderManager->findOrdersByDistribution($distribution); | |||||
$arrayOrders = $orderModule->findOrdersByDistribution($distribution); | |||||
$revenues = 0; | $revenues = 0; | ||||
$weight = 0; | $weight = 0; | ||||
$revenuesDelivered = 0; | $revenuesDelivered = 0; | ||||
// init commandes point de vente | // init commandes point de vente | ||||
foreach ($arrayPointsSale as $pointSale) { | foreach ($arrayPointsSale as $pointSale) { | ||||
$orderManager->initPointSaleOrders($pointSale, $arrayOrders); | |||||
$orderModule->initPointSaleOrders($pointSale, $arrayOrders); | |||||
$dataSelectOrders = []; | $dataSelectOrders = []; | ||||
$dataOptionsOrders = []; | $dataOptionsOrders = []; | ||||
foreach ($arrayProducts as $product) { | foreach ($arrayProducts as $product) { | ||||
$productDistribution = $productDistributionManager->findOneProductDistribution($distribution, $product); | |||||
$productDistribution = $productDistributionModule->findOneProductDistribution($distribution, $product); | |||||
if (!$productDistribution) { | if (!$productDistribution) { | ||||
$productDistribution = new ProductDistribution(); | $productDistribution = new ProductDistribution(); | ||||
$productDistribution->quantity_max = null; | $productDistribution->quantity_max = null; | ||||
} | } | ||||
$productDistributionManager->saveCreate($productDistribution); | |||||
$productDistributionModule->saveCreate($productDistribution); | |||||
} | } | ||||
if (isset($_POST['Product'][$product->id]['active'])) { | if (isset($_POST['Product'][$product->id]['active'])) { | ||||
$productDistribution->quantity_max = null; | $productDistribution->quantity_max = null; | ||||
} | } | ||||
$productDistributionManager->saveUpdate($productDistribution); | |||||
$productDistributionModule->saveUpdate($productDistribution); | |||||
} | } | ||||
} | } | ||||
} | } | ||||
$arrayProductsSelected = []; | $arrayProductsSelected = []; | ||||
if ($distribution) { | 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 | // poids total de la production et CA potentiel | ||||
} | } | ||||
} | } | ||||
$arrayDistributionDays = $distributionManager->findDistributionsActive(); | |||||
$arrayDistributionDays = $distributionModule->findDistributionsActive(); | |||||
// commandes auto | // commandes auto | ||||
$subscriptionForm = new SubscriptionForm(); | $subscriptionForm = new SubscriptionForm(); | ||||
*/ | */ | ||||
public function actionDownload($date = '', $idPointSale = 0, $global = 0) | 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) { | foreach ($pointsSaleArray as $pointSale) { | ||||
$pointSaleManager->initOrders($pointSale, $ordersArray); | |||||
$pointSaleModule->initOrders($pointSale, $ordersArray); | |||||
} | } | ||||
/* | /* | ||||
$strProducts = ''; | $strProducts = ''; | ||||
foreach ($productsArray as $product) { | foreach ($productsArray as $product) { | ||||
if (isset($selectedProductsArray[$product->id]['active']) && $selectedProductsArray[$product->id]['active']) { | if (isset($selectedProductsArray[$product->id]['active']) && $selectedProductsArray[$product->id]['active']) { | ||||
$quantity = $orderManager->getProductQuantity($product, $pointSale->orders); | |||||
$quantity = $orderModule->getProductQuantity($product, $pointSale->orders); | |||||
$strQuantity = ''; | $strQuantity = ''; | ||||
if ($quantity) { | if ($quantity) { | ||||
$strQuantity = $quantity; | $strQuantity = $quantity; | ||||
$strProducts = ''; | $strProducts = ''; | ||||
foreach ($productsArray as $product) { | foreach ($productsArray as $product) { | ||||
if (isset($selectedProductsArray[$product->id]['active']) && $selectedProductsArray[$product->id]['active']) { | if (isset($selectedProductsArray[$product->id]['active']) && $selectedProductsArray[$product->id]['active']) { | ||||
$quantity = $orderManager->getProductQuantity($product, $ordersArray); | |||||
$quantity = $orderModule->getProductQuantity($product, $ordersArray); | |||||
$strQuantity = ''; | $strQuantity = ''; | ||||
if ($quantity) { | if ($quantity) { | ||||
$strQuantity = $quantity; | $strQuantity = $quantity; | ||||
*/ | */ | ||||
public function contentRecapCSV(string $date, array $products, array $pointsSale, array $orders) | 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 = []; | $data = []; | ||||
$filename = 'summary_' . $date; | $filename = 'summary_' . $date; | ||||
$distribution = $distributionManager->findOneDistribution($date); | |||||
$selectedProductsArray = $productDistributionManager->findProductDistributionsByDistribution($distribution); | |||||
$distribution = $distributionModule->findOneDistribution($date); | |||||
$selectedProductsArray = $productDistributionModule->findProductDistributionsByDistribution($distribution); | |||||
// head | // head | ||||
$data[0] = ['Lieu']; | $data[0] = ['Lieu']; | ||||
$dataAdd = [$pointSale->name]; | $dataAdd = [$pointSale->name]; | ||||
foreach ($products as $product) { | foreach ($products as $product) { | ||||
if (isset($selectedProductsArray[$product->id]['active']) && $selectedProductsArray[$product->id]['active']) { | if (isset($selectedProductsArray[$product->id]['active']) && $selectedProductsArray[$product->id]['active']) { | ||||
$dataAdd[] = $orderManager->getProductQuantity($product, $pointSale->orders); | |||||
$dataAdd[] = $orderModule->getProductQuantity($product, $pointSale->orders); | |||||
} | } | ||||
} | } | ||||
$data[] = $dataAdd; | $data[] = $dataAdd; | ||||
$dataAdd = ['Total']; | $dataAdd = ['Total']; | ||||
foreach ($products as $product) { | foreach ($products as $product) { | ||||
if (isset($selectedProductsArray[$product->id]['active']) && $selectedProductsArray[$product->id]['active']) { | if (isset($selectedProductsArray[$product->id]['active']) && $selectedProductsArray[$product->id]['active']) { | ||||
$dataAdd[] = $orderManager->getProductQuantity($product, $orders); | |||||
$dataAdd[] = $orderModule->getProductQuantity($product, $orders); | |||||
} | } | ||||
} | } | ||||
$data[] = $dataAdd; | $data[] = $dataAdd; | ||||
*/ | */ | ||||
public function contentPointSaleCSV($date, $products, $pointsSale, $idPointSale) | public function contentPointSaleCSV($date, $products, $pointsSale, $idPointSale) | ||||
{ | { | ||||
$distributionManager = $this->getDistributionManager(); | |||||
$productDistributionManager = $this->getProductDistributionManager(); | |||||
$distributionModule = $this-> getDistributionModule(); | |||||
$productDistributionModule = $this->getProductDistributionManager(); | |||||
$data = []; | $data = []; | ||||
$distribution = $distributionManager->findOneDistribution($date); | |||||
$selectedProductsArray = $productDistributionManager->findProductDistributionsByDistribution($distribution); | |||||
$distribution = $distributionModule->findOneDistribution($date); | |||||
$selectedProductsArray = $productDistributionModule->findProductDistributionsByDistribution($distribution); | |||||
// datas | // datas | ||||
foreach ($pointsSale as $pointSale) { | foreach ($pointsSale as $pointSale) { | ||||
*/ | */ | ||||
public function actionChangeState(string $date, bool $active, bool $redirect = true) | 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) { | if ($redirect) { | ||||
$this->redirect(['index', 'date' => $date]); | $this->redirect(['index', 'date' => $date]); | ||||
*/ | */ | ||||
public function actionChangeStateWeek(string $date, bool $active) | 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))); | $week = sprintf('%02d', date('W', strtotime($date))); | ||||
$start = strtotime(date('Y', strtotime($date)) . 'W' . $week); | $start = strtotime(date('Y', strtotime($date)) . 'W' . $week); | ||||
{ | { | ||||
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; | \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) { | if ($order) { | ||||
$orderManager->deleteOrder($order); | |||||
$orderModule->deleteOrder($order); | |||||
} | } | ||||
return ['success']; | return ['success']; | ||||
*/ | */ | ||||
public function actionDelete(string $date, int $idOrder) | public function actionDelete(string $date, int $idOrder) | ||||
{ | { | ||||
$orderManager = $this->getOrderManager(); | |||||
$order = $orderManager->findOneOrderById($idOrder); | |||||
$orderModule = $this->getOrderModule(); | |||||
$order = $orderModule->findOneOrderById($idOrder); | |||||
if ($order) { | if ($order) { | ||||
$orderManager->deleteOrder($order); | |||||
$orderModule->deleteOrder($order); | |||||
} | } | ||||
$this->redirect(['index', 'date' => $date]); | $this->redirect(['index', 'date' => $date]); | ||||
{ | { | ||||
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; | \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(); | $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); | $products = json_decode($products); | ||||
$pointSale = $pointSaleManager->findOnePointSaleById($idPointSale); | |||||
$distribution = $distributionManager->findOneDistribution($date); | |||||
$pointSale = $pointSaleModule->findOnePointSaleById($idPointSale); | |||||
$distribution = $distributionModule->findOneDistribution($date); | |||||
$producerCurrent = $this->getProducerCurrent(); | $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) | if (preg_match("/^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$/", $date) | ||||
$order->id_user = $idUser; | $order->id_user = $idUser; | ||||
// commentaire du point de vente | // commentaire du point de vente | ||||
$userPointSale = $userPointSaleManager->findOneUserPointSale($userModule->findOneUserById($idUser), $pointSale); | |||||
$userPointSale = $userPointSaleModule->findOneUserPointSale($userModule->findOneUserById($idUser), $pointSale); | |||||
if ($userPointSale && strlen($userPointSale->comment)) { | if ($userPointSale && strlen($userPointSale->comment)) { | ||||
$order->comment_point_sale = $userPointSale->comment; | $order->comment_point_sale = $userPointSale->comment; | ||||
if (isset($order->user) && $order->user) { | if (isset($order->user) && $order->user) { | ||||
$user = $order->user; | $user = $order->user; | ||||
$userProducer = $userProducerManager->findOneUserProducer($user); | |||||
$userProducer = $userProducerModule->findOneUserProducer($user); | |||||
} | } | ||||
foreach ($products as $key => $dataProductOrder) { | foreach ($products as $key => $dataProductOrder) { | ||||
$product = $productManager->findOneProductById($key); | |||||
$product = $productModule->findOneProductById($key); | |||||
if(isset(Product::$unitsArray[$dataProductOrder->unit]) && Product::$unitsArray[$dataProductOrder->unit]['coefficient']) { | if(isset(Product::$unitsArray[$dataProductOrder->unit]) && Product::$unitsArray[$dataProductOrder->unit]['coefficient']) { | ||||
$quantity = $dataProductOrder->quantity / Product::$unitsArray[$dataProductOrder->unit]['coefficient']; | $quantity = $dataProductOrder->quantity / Product::$unitsArray[$dataProductOrder->unit]['coefficient']; | ||||
if ($product && $quantity) { | if ($product && $quantity) { | ||||
if ($dataProductOrder->price) { | if ($dataProductOrder->price) { | ||||
$productOrder->price = $dataProductOrder->price; | $productOrder->price = $dataProductOrder->price; | ||||
} else { | } else { | ||||
$productOrder->price = $productManager->getPrice($product, [ | |||||
$productOrder->price = $productModule->getPrice($product, [ | |||||
'user' => $user, | 'user' => $user, | ||||
'user_producer' => $userProducer, | 'user_producer' => $userProducer, | ||||
'point_sale' => $order->pointSale, | 'point_sale' => $order->pointSale, | ||||
} | } | ||||
} | } | ||||
$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) { | if ($order) { | ||||
$orderManager->generateOrderReference($order); | |||||
$orderManager->updateOrderTillerSynchronization($order); | |||||
$orderModule->generateOrderReference($order); | |||||
$orderModule->updateOrderTillerSynchronization($order); | |||||
} | } | ||||
// lien utilisateur / point de vente | // lien utilisateur / point de vente | ||||
if ($idUser && $pointSale) { | if ($idUser && $pointSale) { | ||||
$pointSaleManager->addUser($user, $pointSale); | |||||
$pointSaleModule->addUser($user, $pointSale); | |||||
} | } | ||||
} | } | ||||
{ | { | ||||
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; | \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; | ||||
$orderManager = $this->getOrderManager(); | |||||
$orderModule = $this->getOrderModule(); | |||||
$userModule = $this->getUserModule(); | $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; | $request = \Yii::$app->request; | ||||
$date = $request->post('date'); | $date = $request->post('date'); | ||||
$comment = $request->post('comment'); | $comment = $request->post('comment'); | ||||
$debitCredit = $request->post('debitCredit'); | $debitCredit = $request->post('debitCredit'); | ||||
$order = $orderManager->findOneOrderById($idOrder); | |||||
$orderManager->initOrder($order); | |||||
$order = $orderModule->findOneOrderById($idOrder); | |||||
$orderModule->initOrder($order); | |||||
$user = $userModule->findOneUserById($idUser); | $user = $userModule->findOneUserById($idUser); | ||||
$pointSale = $pointSaleManager->findOnePointSaleById($idPointSale); | |||||
$pointSale = $pointSaleModule->findOnePointSaleById($idPointSale); | |||||
if ($order | if ($order | ||||
&& $order->distribution->id_producer == GlobalParam::getCurrentProducerId()) { | && $order->distribution->id_producer == GlobalParam::getCurrentProducerId()) { | ||||
// Si changement d'user : on rembourse l'ancien user | // Si changement d'user : on rembourse l'ancien user | ||||
$oldIdUser = $order->id_user; | $oldIdUser = $order->id_user; | ||||
$amountPaid = $orderManager->getOrderAmountWithTax($order, Order::AMOUNT_PAID); | |||||
$amountPaid = $orderModule->getOrderAmountWithTax($order, Order::AMOUNT_PAID); | |||||
if ($oldIdUser != $idUser && $amountPaid > 0) { | if ($oldIdUser != $idUser && $amountPaid > 0) { | ||||
$paymentManager->refundOrderCredit($order, $this->getUserCurrent()); | $paymentManager->refundOrderCredit($order, $this->getUserCurrent()); | ||||
$order = $orderManager->findOneOrderById($idOrder); | |||||
$orderManager->initOrder($order); | |||||
$order = $orderModule->findOneOrderById($idOrder); | |||||
$orderModule->initOrder($order); | |||||
} | } | ||||
if ($idUser) { | if ($idUser) { | ||||
$order->id_user = $idUser; | $order->id_user = $idUser; | ||||
// commentaire du point de vente | // commentaire du point de vente | ||||
$userPointSale = $userPointSaleManager->findOneUserPointSale($user, $pointSale); | |||||
$userPointSale = $userPointSaleModule->findOneUserPointSale($user, $pointSale); | |||||
if ($userPointSale && strlen($userPointSale->comment)) { | if ($userPointSale && strlen($userPointSale->comment)) { | ||||
$order->comment_point_sale = $userPointSale->comment; | $order->comment_point_sale = $userPointSale->comment; | ||||
} | } | ||||
if ($dataProductOrder->price) { | if ($dataProductOrder->price) { | ||||
$productOrder->price = $dataProductOrder->price; | $productOrder->price = $dataProductOrder->price; | ||||
} else { | } else { | ||||
$productOrder->price = $productManager->getPrice($product, [ | |||||
$productOrder->price = $productModule->getPrice($product, [ | |||||
'user' => $user, | 'user' => $user, | ||||
'user_producer' => $userProducer, | 'user_producer' => $userProducer, | ||||
'point_sale' => $order->pointSale, | 'point_sale' => $order->pointSale, | ||||
$order->save(); | $order->save(); | ||||
$order = Order::searchOne(['id' => $order->id]); | $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); | |||||
} | } | ||||
} | } | ||||
} | } | ||||
*/ | */ | ||||
public function actionPaymentStatus(int $idOrder) | 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) { | if ($order) { | ||||
$html = ''; | $html = ''; | ||||
]) | ]) | ||||
->one(); | ->one(); | ||||
$amountPaid = $orderManager->getOrderAmount($order, Order::AMOUNT_PAID); | |||||
$amountPaid = $orderModule->getOrderAmount($order, Order::AMOUNT_PAID); | |||||
if (abs($order->amount - $amountPaid) < 0.0001) { | if (abs($order->amount - $amountPaid) < 0.0001) { | ||||
$html .= '<span class="label label-success">Payé</span>'; | $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) { | } elseif ($order->amount > $amountPaid) { | ||||
$amountToPay = $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'; | $html .= '<span class="label label-danger">Non payé</span> reste <strong>' . number_format($amountToPay, 2) . ' €</strong> à débiter'; | ||||
{ | { | ||||
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; | \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) { | if ($order) { | ||||
$paymentManager->payOrRefundOrder($type, $order, $meanPayment, $this->getUserCurrent()); | $paymentManager->payOrRefundOrder($type, $order, $meanPayment, $this->getUserCurrent()); | ||||
{ | { | ||||
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; | \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) { | if ($order) { | ||||
$orderManager->updateOrderTillerSynchronization($order, (int) $boolSynchroTiller); | |||||
$orderModule->updateOrderTillerSynchronization($order, (int) $boolSynchroTiller); | |||||
return ['success']; | return ['success']; | ||||
} | } | ||||
*/ | */ | ||||
public function actionCreate() | 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()) { | 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']); | return $this->redirect(['index']); | ||||
} else { | } else { | ||||
*/ | */ | ||||
public function actionUpdate(int $id) | public function actionUpdate(int $id) | ||||
{ | { | ||||
$distributionManager = $this->getDistributionManager(); | |||||
$pointSaleManager = $this->getPointSaleManager(); | |||||
$distributionModule = $this-> getDistributionModule(); | |||||
$pointSaleModule = $this->getPointSaleModule(); | |||||
$model = PointSale::find() | $model = PointSale::find() | ||||
->with('userPointSale') | ->with('userPointSale') | ||||
if ($model->load(\Yii::$app->request->post()) && $model->save()) { | 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é.'); | $this->setFlash('success', 'Point de vente modifié.'); | ||||
*/ | */ | ||||
public function actionDelete(int $id, $confirm = false) | public function actionDelete(int $id, $confirm = false) | ||||
{ | { | ||||
$orderManager = $this->getOrderManager(); | |||||
$distributionManager = $this->getDistributionManager(); | |||||
$orderModule = $this->getOrderModule(); | |||||
$distributionModule = $this-> getDistributionModule(); | |||||
$pointSale = $this->findModel($id); | $pointSale = $this->findModel($id); | ||||
UserPointSale::deleteAll(['id_point_sale' => $id]); | UserPointSale::deleteAll(['id_point_sale' => $id]); | ||||
// Suppression du lien PointSaleDistribution pour toutes les distributions à venir | // Suppression du lien PointSaleDistribution pour toutes les distributions à venir | ||||
$incomingDistributions = $distributionManager->findDistributionsIncoming(true); | |||||
$incomingDistributions = $distributionModule->findDistributionsIncoming(true); | |||||
foreach ($incomingDistributions as $distribution) { | foreach ($incomingDistributions as $distribution) { | ||||
PointSaleDistribution::deleteAll(['id_point_sale' => $id, 'id_distribution' => $distribution->id]); | PointSaleDistribution::deleteAll(['id_point_sale' => $id, 'id_distribution' => $distribution->id]); | ||||
} | } | ||||
if ($ordersArray) { | if ($ordersArray) { | ||||
foreach ($ordersArray as $order) { | foreach ($ordersArray as $order) { | ||||
$orderManager->deleteOrder($order, true); | |||||
$orderModule->deleteOrder($order, true); | |||||
} | } | ||||
} | } | ||||
*/ | */ | ||||
public function actionDefault(int $id) | public function actionDefault(int $id) | ||||
{ | { | ||||
$pointSaleManager = $this->getPointSaleManager(); | |||||
$pointSaleModule = $this->getPointSaleModule(); | |||||
$pointSale = $this->findModel($id); | $pointSale = $this->findModel($id); | ||||
if ($pointSale) { | if ($pointSale) { | ||||
if (!$pointSale->default) { | if (!$pointSale->default) { | ||||
$pointSale->default = 1; | $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.'); | $this->setFlash('success', 'Point de vente <strong>' . Html::encode($pointSale->name) . '</strong> défini par défaut.'); | ||||
} else { | } else { |
*/ | */ | ||||
public function actionIndex() | public function actionIndex() | ||||
{ | { | ||||
$producerManager = $this->getProducerManager(); | |||||
$producerModule = $this->getProducerModule(); | |||||
$dataProviderProducer = new ActiveDataProvider([ | $dataProviderProducer = new ActiveDataProvider([ | ||||
'query' => Producer::find() | 'query' => Producer::find() | ||||
], | ], | ||||
]); | ]); | ||||
$producersArray = $producerManager->findProducersActive(); | |||||
$producersArray = $producerModule->findProducersActive(); | |||||
$sumPrices = 0; | $sumPrices = 0; | ||||
foreach ($producersArray as $producer) { | foreach ($producersArray as $producer) { | ||||
$sumPrices += $producerManager->getAmountBilledLastMonth($producer); | |||||
$sumPrices += $producerModule->getAmountBilledLastMonth($producer); | |||||
} | } | ||||
return $this->render('index', [ | return $this->render('index', [ | ||||
*/ | */ | ||||
public function actionCreate() | 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éé.'); | $this->setFlash('success', 'Producteur créé.'); | ||||
return $this->redirect(['index']); | return $this->redirect(['index']); | ||||
} else { | } else { | ||||
*/ | */ | ||||
public function actionUpdate(int $id) | public function actionUpdate(int $id) | ||||
{ | { | ||||
$producerManager = $this->getProducerManager(); | |||||
$producerModule = $this->getProducerModule(); | |||||
$producer = $this->findProducer($id); | $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é.'); | $this->setFlash('success', 'Producteur modifié.'); | ||||
return $this->redirect(['index']); | return $this->redirect(['index']); | ||||
} else { | } else { | ||||
public function actionDolibarr(int $id) | public function actionDolibarr(int $id) | ||||
{ | { | ||||
$producerManager = $this->getProducerManager(); | |||||
$producerModule = $this->getProducerModule(); | |||||
$producer = $this->findProducer($id); | $producer = $this->findProducer($id); | ||||
if($producer->dolibarr_socid) { | 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)."\""); | return Ajax::responseSuccess("Facture générée sur Dolibarr pour le producteur \"".Html::encode($producer->name)."\""); | ||||
} | } | ||||
else { | else { | ||||
public function actionUserTransfer($fromProducerId, $toProducerId, $withOrders = 1) | public function actionUserTransfer($fromProducerId, $toProducerId, $withOrders = 1) | ||||
{ | { | ||||
$producerManager = $this->getProducerManager(); | |||||
$producerModule = $this->getProducerModule(); | |||||
$userModule = $this->getUserModule(); | $userModule = $this->getUserModule(); | ||||
$fromProducerId = (int)$fromProducerId; | $fromProducerId = (int)$fromProducerId; | ||||
} | } | ||||
if (($withOrders && $countOrders) || !$withOrders) { | if (($withOrders && $countOrders) || !$withOrders) { | ||||
$producerManager->addUser( | |||||
$producerModule->addUser( | |||||
$userModule->findOneUserById($idUser), | $userModule->findOneUserById($idUser), | ||||
$producerManager->findOneProducerById($toProducerId) | |||||
$producerModule->findOneProducerById($toProducerId) | |||||
); | ); | ||||
$count++; | $count++; | ||||
} | } | ||||
*/ | */ | ||||
protected function findProducer(int $id) | 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; | return $model; | ||||
} else { | } else { | ||||
throw new NotFoundHttpException('Producteur introuvable.'); | throw new NotFoundHttpException('Producteur introuvable.'); |
*/ | */ | ||||
public function actionUpdate() | public function actionUpdate() | ||||
{ | { | ||||
$producerContainer = $this->getProducerContainer(); | |||||
$producerBuilder = $producerContainer->getBuilder(); | |||||
$producerModule = $this->getProducerModule(); | |||||
$producerBuilder = $producerModule->getBuilder(); | |||||
$request = Yii::$app->request; | $request = Yii::$app->request; | ||||
$model = $this->findModel(GlobalParam::getCurrentProducerId()); | $model = $this->findModel(GlobalParam::getCurrentProducerId()); | ||||
public function actionUpdateOpendistribVersion() | public function actionUpdateOpendistribVersion() | ||||
{ | { | ||||
$producerManager = $this->getProducerManager(); | |||||
$producerManager->updateOpendistribVersion($this->getProducerCurrent()); | |||||
$producerModule = $this->getProducerModule(); | |||||
$producerModule->updateOpendistribVersion($this->getProducerCurrent()); | |||||
return $this->redirect(\Yii::$app->request->referrer); | return $this->redirect(\Yii::$app->request->referrer); | ||||
} | } | ||||
$entity = $request->post('entity'); | $entity = $request->post('entity'); | ||||
$pageSize = $request->post('pagesize'); | $pageSize = $request->post('pagesize'); | ||||
$this->getProducerContainer()->getProducerPageSizer() | |||||
$this->getProducerModule()->getProducerPageSizer() | |||||
->updatePagesize($producerCurrent, $entity, $pageSize); | ->updatePagesize($producerCurrent, $entity, $pageSize); | ||||
} | } | ||||
*/ | */ | ||||
public function actionCreate() | public function actionCreate() | ||||
{ | { | ||||
$producerPriceRangeManager = $this->getProducerPriceRangeManager(); | |||||
$producerPriceRange = $producerPriceRangeManager->instanciateProducerPriceRange(); | |||||
$producerPriceRangeModule = $this->getProducerPriceRangeModule(); | |||||
$producerPriceRange = $producerPriceRangeModule->instanciateProducerPriceRange(); | |||||
if ($producerPriceRange->load(\Yii::$app->request->post()) | if ($producerPriceRange->load(\Yii::$app->request->post()) | ||||
&& $producerPriceRangeManager->saveCreate($producerPriceRange)) { | |||||
&& $producerPriceRangeModule->saveCreate($producerPriceRange)) { | |||||
$this->setFlash('success', 'Tranche de prix créée.'); | $this->setFlash('success', 'Tranche de prix créée.'); | ||||
*/ | */ | ||||
public function actionUpdate(int $id) | public function actionUpdate(int $id) | ||||
{ | { | ||||
$producerPriceRangeManager = $this->getProducerPriceRangeManager(); | |||||
$producerPriceRangeModule = $this->getProducerPriceRangeModule(); | |||||
$producerPriceRange = $this->findModel($id); | $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.'); | $this->setFlash('success', 'Tranche de prix éditée.'); | ||||
return $this->redirect(['index']); | return $this->redirect(['index']); | ||||
} else { | } else { | ||||
*/ | */ | ||||
public function actionDelete(int $id) | public function actionDelete(int $id) | ||||
{ | { | ||||
$producerPriceRangeManager = $this->getProducerPriceRangeManager(); | |||||
$producerPriceRangeModule = $this->getProducerPriceRangeModule(); | |||||
$producerPriceRange = $this->findModel($id); | $producerPriceRange = $this->findModel($id); | ||||
$producerPriceRangeManager->delete($producerPriceRange); | |||||
$producerPriceRangeModule->delete($producerPriceRange); | |||||
$this->setFlash('success', 'Tranche de prix supprimée.'); | $this->setFlash('success', 'Tranche de prix supprimée.'); | ||||
return $this->redirect(['producer-price-range-admin/index']); | return $this->redirect(['producer-price-range-admin/index']); | ||||
protected function findModel($id) | protected function findModel($id) | ||||
{ | { | ||||
$producerPriceRangeManager = $this->getProducerPriceRangeManager(); | |||||
if (($producerPriceRange = $producerPriceRangeManager->findOneProducerPriceRangeById($id)) !== null) { | |||||
$producerPriceRangeModule = $this->getProducerPriceRangeModule(); | |||||
if (($producerPriceRange = $producerPriceRangeModule->findOneProducerPriceRangeById($id)) !== null) { | |||||
return $producerPriceRange; | return $producerPriceRange; | ||||
} else { | } else { | ||||
throw new NotFoundHttpException('The requested page does not exist.'); | throw new NotFoundHttpException('The requested page does not exist.'); |
*/ | */ | ||||
public function actionCreate() | public function actionCreate() | ||||
{ | { | ||||
$productCategoryManager = $this->getProductCategoryManager(); | |||||
$productCategory = $productCategoryManager->instanciateProductCategory(); | |||||
$productCategoryModule = $this->getProductCategoryModule(); | |||||
$productCategory = $productCategoryModule->instanciateProductCategory(); | |||||
$productCategory->id_producer = GlobalParam::getCurrentProducerId(); | $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."); | $this->setFlash('success', "Catégorie ajoutée."); | ||||
return $this->redirect(['index']); | return $this->redirect(['index']); | ||||
} else { | } else { | ||||
*/ | */ | ||||
public function actionUpdate(int $id) | public function actionUpdate(int $id) | ||||
{ | { | ||||
$productCategoryManager = $this->getProductCategoryManager(); | |||||
$productCategoryModule = $this->getProductCategoryModule(); | |||||
$productCategory = $this->findModel($id); | $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."); | $this->setFlash('success', "Catégorie modifiée."); | ||||
return $this->redirect(['index']); | return $this->redirect(['index']); | ||||
} else { | } else { | ||||
*/ | */ | ||||
public function actionDelete($id) | public function actionDelete($id) | ||||
{ | { | ||||
$productCategoryManager = $this->getProductCategoryManager(); | |||||
$productCategoryModule = $this->getProductCategoryModule(); | |||||
$productCategory = $this->findModel($id); | $productCategory = $this->findModel($id); | ||||
$productCategoryManager->delete($productCategory); | |||||
$productCategoryModule->delete($productCategory); | |||||
Product::updateAll(['id_product_category' => null], ['id_product_category' => $id]); | Product::updateAll(['id_product_category' => null], ['id_product_category' => $id]); | ||||
$this->setFlash('success', 'Catégorie <strong>' . Html::encode($productCategory->name) . '</strong> supprimée.'); | $this->setFlash('success', 'Catégorie <strong>' . Html::encode($productCategory->name) . '</strong> supprimée.'); | ||||
*/ | */ | ||||
protected function findModel($id) | protected function findModel($id) | ||||
{ | { | ||||
$productCategoryManager = $this->getProductCategoryManager(); | |||||
if (($productCategory = $productCategoryManager->findOneProductCategoryById($id)) !== null) { | |||||
$productCategoryModule = $this->getProductCategoryModule(); | |||||
if (($productCategory = $productCategoryModule->findOneProductCategoryById($id)) !== null) { | |||||
return $productCategory; | return $productCategory; | ||||
} else { | } else { | ||||
throw new NotFoundHttpException('The requested page does not exist.'); | throw new NotFoundHttpException('The requested page does not exist.'); |
*/ | */ | ||||
public function actionCreate() | 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->status = Product::STATUS_ONLINE; | ||||
$model->id_producer = GlobalParam::getCurrentProducerId(); | $model->id_producer = GlobalParam::getCurrentProducerId(); | ||||
if ($lastProductOrder) { | if ($lastProductOrder) { | ||||
$model->order = ++$lastProductOrder->order; | $model->order = ++$lastProductOrder->order; | ||||
} | } | ||||
$productManager->create($model); | |||||
$productModule->create($model); | |||||
if($model->photoFile) { | if($model->photoFile) { | ||||
Upload::uploadFile($model, 'photoFile', 'photo'); | Upload::uploadFile($model, 'photoFile', 'photo'); | ||||
} | } | ||||
$this->processAvailabilityPointsSale($model); | $this->processAvailabilityPointsSale($model); | ||||
$distributionManager->addProductIncomingDistributions($model); | |||||
$distributionModule->addProductIncomingDistributions($model); | |||||
$this->setFlash('success', 'Produit <strong>' . Html::encode($model->name) . '</strong> ajouté'); | $this->setFlash('success', 'Produit <strong>' . Html::encode($model->name) . '</strong> ajouté'); | ||||
*/ | */ | ||||
public function actionUpdate($id) | public function actionUpdate($id) | ||||
{ | { | ||||
$productManager = $this->getProductManager(); | |||||
$distributionManager = $this->getDistributionManager(); | |||||
$productModule = $this->getProductModule(); | |||||
$distributionModule = $this-> getDistributionModule(); | |||||
$request = Yii::$app->request; | $request = Yii::$app->request; | ||||
$model = $this->findModel($id); | $model = $this->findModel($id); | ||||
$this->processAvailabilityPointsSale($model); | $this->processAvailabilityPointsSale($model); | ||||
if ($model->apply_distributions) { | 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é'); | $this->setFlash('success', 'Produit <strong>' . Html::encode($model->name) . '</strong> modifié'); | ||||
return $this->redirect(['index']); | return $this->redirect(['index']); | ||||
*/ | */ | ||||
public function processAvailabilityPointsSale($product) | public function processAvailabilityPointsSale($product) | ||||
{ | { | ||||
$pointSaleManager = $this->getPointSaleManager(); | |||||
$productPointSaleManager = $this->getProductPointSaleManager(); | |||||
$pointSaleModule = $this->getPointSaleModule(); | |||||
$productPointSaleModule = $this->getProductPointSaleModule(); | |||||
ProductPointSale::deleteAll(['id_product' => $product->id]); | ProductPointSale::deleteAll(['id_product' => $product->id]); | ||||
if (is_array($product->pointsSale) && count($product->pointsSale)) { | if (is_array($product->pointsSale) && count($product->pointsSale)) { | ||||
foreach ($product->pointsSale as $key => $idPointSale) { | foreach ($product->pointsSale as $key => $idPointSale) { | ||||
$pointSale = $pointSaleManager->findOnePointSaleById($idPointSale); | |||||
$pointSale = $pointSaleModule->findOnePointSaleById($idPointSale); | |||||
if ($pointSale) { | if ($pointSale) { | ||||
$productPointSaleManager->createProductPointSale( | |||||
$productPointSaleModule->createProductPointSale( | |||||
$product, | $product, | ||||
$pointSale, | $pointSale, | ||||
($product->available_on_points_sale) ? false : true | ($product->available_on_points_sale) ? false : true | ||||
*/ | */ | ||||
public function actionDelete(int $id, bool $confirm = false) | public function actionDelete(int $id, bool $confirm = false) | ||||
{ | { | ||||
$productContainer = $this->getProductContainer(); | |||||
$productDistributionContainer = $this->getProductDistributionContainer(); | |||||
$productModule = $this->getProductModule(); | |||||
$productDistributionModule = $this->getProductDistributionModule(); | |||||
$product = $this->findModel($id); | $product = $this->findModel($id); | ||||
if ($confirm) { | 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é'); | $this->setFlash('success', 'Produit <strong>' . Html::encode($product->name) . '</strong> supprimé'); | ||||
} else { | } else { | ||||
{ | { | ||||
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; | \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; | ||||
$distributionManager = $this->getDistributionManager(); | |||||
$distributionModule = $this-> getDistributionModule(); | |||||
$product = $this->findModel($id); | $product = $this->findModel($id); | ||||
$product->status = (int) $status; | $product->status = (int) $status; | ||||
$product->save(); | $product->save(); | ||||
$distributionManager->addProductIncomingDistributions($product); | |||||
$distributionModule->addProductIncomingDistributions($product); | |||||
return ['success', 'id' => $id, 'status' => $status]; | return ['success', 'id' => $id, 'status' => $status]; | ||||
} | } | ||||
*/ | */ | ||||
public function actionPriceImport() | 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(); | $userModule = $this->getUserModule(); | ||||
$model = new ProductPriceUploadForm(); | $model = new ProductPriceUploadForm(); | ||||
$quantityFrom = (float)$productPriceCsv[4]; | $quantityFrom = (float)$productPriceCsv[4]; | ||||
$price = (float) str_replace(',', '.', $productPriceCsv[5]); | $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; | $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) | if (($productName && !$product) | ||||
|| (count($userArray) > 1 && !$user) | || (count($userArray) > 1 && !$user) | ||||
// prix de base | // prix de base | ||||
if (!$user && !$userGroup && !$pointSale && !$quantityFrom) { | if (!$user && !$userGroup && !$pointSale && !$quantityFrom) { | ||||
$product->price = $price; | $product->price = $price; | ||||
$productManager->saveUpdate($product); | |||||
$productModule->saveUpdate($product); | |||||
$countUpdate++; | $countUpdate++; | ||||
} // prix spécifique | } // prix spécifique | ||||
else { | else { | ||||
$productPrice = $productPriceManager->findOneProductPriceBy($product, $user, $userGroup, $pointSale, $quantityFrom); | |||||
$productPrice = $productPriceModule->findOneProductPriceBy($product, $user, $userGroup, $pointSale, $quantityFrom); | |||||
if ($productPrice) { | if ($productPrice) { | ||||
$productPrice->price = $price; | $productPrice->price = $price; | ||||
$productPriceManager->saveUpdate($productPrice); | |||||
$productPriceModule->saveUpdate($productPrice); | |||||
$countUpdate++; | $countUpdate++; | ||||
} | } | ||||
// Création automatique du prix spécifique | // Création automatique du prix spécifique | ||||
else { | 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 ++; | $countCreate ++; | ||||
} | } | ||||
} | } | ||||
*/ | */ | ||||
public function actionPriceExport() | public function actionPriceExport() | ||||
{ | { | ||||
$productManager = $this->getProductManager(); | |||||
$productPriceManager = $this->getProductPriceManager(); | |||||
$productModule = $this->getProductModule(); | |||||
$productPriceModule = $this->getProductPriceModule(); | |||||
$userModule = $this->getUserModule(); | $userModule = $this->getUserModule(); | ||||
$data = []; | $data = []; | ||||
"Prix HT" | "Prix HT" | ||||
]; | ]; | ||||
$productArray = $productManager->findProducts(); | |||||
$productArray = $productModule->findProducts(); | |||||
foreach($productArray as $product) { | foreach($productArray as $product) { | ||||
// prix produit | // prix produit | ||||
// prix spécifiques | // prix spécifiques | ||||
foreach($product->productPrice as $productPrice) { | 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) { | if($productPrice->user || $productPrice->userGroup || $productPrice->pointSale || $productPrice->from_quantity) { | ||||
$data[] = [ | $data[] = [ | ||||
*/ | */ | ||||
protected function findModel(int $id) | 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; | return $product; | ||||
} else { | } else { | ||||
throw new NotFoundHttpException('The requested page does not exist.'); | throw new NotFoundHttpException('The requested page does not exist.'); | ||||
protected function findModelProductPrice($id) | protected function findModelProductPrice($id) | ||||
{ | { | ||||
$productPriceManager = $this->getProductPriceManager(); | |||||
if (($productPrice = $productPriceManager->findOneProductPriceById($id)) !== null) { | |||||
$productPriceModule = $this->getProductPriceModule(); | |||||
if (($productPrice = $productPriceModule->findOneProductPriceById($id)) !== null) { | |||||
return $productPrice; | return $productPrice; | ||||
} else { | } else { | ||||
throw new NotFoundHttpException('The requested page does not exist.'); | throw new NotFoundHttpException('The requested page does not exist.'); |
public function actionTransform($id) | public function actionTransform($id) | ||||
{ | { | ||||
$quotationManager = $this->getQuotationManager(); | |||||
$invoiceManager = $this->getInvoiceManager(); | |||||
$quotationModule = $this->getQuotationModule(); | |||||
$invoiceModule = $this-> getInvoiceModule(); | |||||
$quotation = $this->findModel($id); | $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_producer = GlobalParam::getCurrentProducerId(); | ||||
$invoice->id_user = $quotation->id_user; | $invoice->id_user = $quotation->id_user; | ||||
$invoice->address = $quotation->address; | $invoice->address = $quotation->address; | ||||
$invoice->comment = $quotation->comment; | $invoice->comment = $quotation->comment; | ||||
$invoice->name = str_replace(['Devis', 'devis'], 'Facture', $quotation->name); | $invoice->name = str_replace(['Devis', 'devis'], 'Facture', $quotation->name); | ||||
$invoiceManager->saveCreate($invoice); | |||||
$invoiceModule->saveCreate($invoice); | |||||
Order::updateAll([ | Order::updateAll([ | ||||
'order.id_invoice' => $invoice->id | 'order.id_invoice' => $invoice->id |
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; | \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; | ||||
$userModule = $this->getUserModule(); | $userModule = $this->getUserModule(); | ||||
$pointSaleManager = $this->getPointSaleManager(); | |||||
$distributionManager = $this->getDistributionManager(); | |||||
$pointSaleModule = $this->getPointSaleModule(); | |||||
$distributionModule = $this-> getDistributionModule(); | |||||
$usersArray = $userModule->findUsers(); | $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)); | $firstYear = date('Y', strtotime($firstDistribution->date)); | ||||
$lastYear = date('Y', strtotime($lastDistribution->date)); | $lastYear = date('Y', strtotime($lastDistribution->date)); | ||||
} | } | ||||
$distributionsByMonthArray = []; | $distributionsByMonthArray = []; | ||||
$distributionsArray = $distributionManager->findDistributionsActive(); | |||||
$distributionsArray = $distributionModule->findDistributionsActive(); | |||||
foreach ($distributionsArray as $distribution) { | foreach ($distributionsArray as $distribution) { | ||||
$month = date('Y-m', strtotime($distribution->date)); | $month = date('Y-m', strtotime($distribution->date)); | ||||
if (!isset($distributionsByMonthArray[$month])) { | if (!isset($distributionsByMonthArray[$month])) { |
public function actionSwitchProducer(int $id) | public function actionSwitchProducer(int $id) | ||||
{ | { | ||||
$user = $this->getUserCurrent(); | $user = $this->getUserCurrent(); | ||||
$producer = $this->getProducerContainer()->getRepository()->findOneProducerById($id); | |||||
$producer = $this->getProducerModule()->getRepository()->findOneProducerById($id); | |||||
if($producer) { | if($producer) { | ||||
$this->getUserModule()->getBuilder()->switchProducer($user, $producer); | $this->getUserModule()->getBuilder()->switchProducer($user, $producer); |
public function actionCustomerOrders() | public function actionCustomerOrders() | ||||
{ | { | ||||
$orderManager = $this->getOrderManager(); | |||||
$orderModule = $this->getOrderModule(); | |||||
$data = []; | $data = []; | ||||
$dataLabels = []; | $dataLabels = []; | ||||
$dateStart = date('Y-m-d', time() - 60 * 60 * 24 * 30); | $dateStart = date('Y-m-d', time() - 60 * 60 * 24 * 30); | ||||
foreach ($period as $date) { | foreach ($period as $date) { | ||||
$dateFormat = date('d/m/Y', $date->getTimestamp()); | $dateFormat = date('d/m/Y', $date->getTimestamp()); | ||||
$dataLabels[] = $dateFormat; | $dataLabels[] = $dateFormat; | ||||
$data[] = $orderManager->countGlobalOrdersByDateAndOrigin($date); | |||||
$data[] = $orderModule->countGlobalOrdersByDateAndOrigin($date); | |||||
} | } | ||||
return $this->render('customer_orders', [ | return $this->render('customer_orders', [ |
*/ | */ | ||||
public function actionIndex(int $year = null) | public function actionIndex(int $year = null) | ||||
{ | { | ||||
$producerManager = $this->getProducerManager(); | |||||
$producerModule = $this->getProducerModule(); | |||||
$producerCurrent = $this->getProducerCurrent(); | $producerCurrent = $this->getProducerCurrent(); | ||||
if(!$year) { | if(!$year) { | ||||
$year = date('Y'); | $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', [ | return $this->render('index', [ | ||||
'yearCurrent' => $year, | 'yearCurrent' => $year, | ||||
*/ | */ | ||||
public function actionProducts(int $year = 0, $section = 1) | public function actionProducts(int $year = 0, $section = 1) | ||||
{ | { | ||||
$productManager = $this->getProductManager(); | |||||
$productModule = $this->getProductModule(); | |||||
if (!$year) { | if (!$year) { | ||||
$year = date('Y'); | $year = date('Y'); | ||||
} | } | ||||
$productsArray = $productManager->findProducts(); | |||||
$productsArray = $productModule->findProducts(); | |||||
$dataProducts = []; | $dataProducts = []; | ||||
$dataProducts[self::TOTALS] = ['max' => [], 'orders' => []]; | $dataProducts[self::TOTALS] = ['max' => [], 'orders' => []]; |
*/ | */ | ||||
public function actionCreate($idOrder = 0) | 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 = new SubscriptionForm(); | ||||
$model->isAdmin = true; | $model->isAdmin = true; | ||||
$model->id_producer = GlobalParam::getCurrentProducerId(); | $model->id_producer = GlobalParam::getCurrentProducerId(); | ||||
if ($idOrder) { | if ($idOrder) { | ||||
$order = $orderManager->findOneOrderById($idOrder); | |||||
$order = $orderModule->findOneOrderById($idOrder); | |||||
if ($order) { | if ($order) { | ||||
$model->id_user = $order->id_user; | $model->id_user = $order->id_user; | ||||
$model->username = $order->username; | $model->username = $order->username; | ||||
$dateDay = strtolower(date('l', strtotime($order->distribution->date))); | $dateDay = strtolower(date('l', strtotime($order->distribution->date))); | ||||
$model->$dateDay = 1; | $model->$dateDay = 1; | ||||
$model->week_frequency = 1; | $model->week_frequency = 1; | ||||
if ($model->id_user && $producerManager->getConfig('credit')) { | |||||
if ($model->id_user && $producerModule->getConfig('credit')) { | |||||
$model->auto_payment = 1; | $model->auto_payment = 1; | ||||
} | } | ||||
} | } | ||||
// produits | // produits | ||||
$productsArray = $productManager->findProducts(); | |||||
$productsArray = $productModule->findProducts(); | |||||
if ($model->load(\Yii::$app->request->post()) && $model->validate() && $model->save()) { | if ($model->load(\Yii::$app->request->post()) && $model->validate() && $model->save()) { | ||||
$this->setFlash('success', 'Abonnement ajouté'); | $this->setFlash('success', 'Abonnement ajouté'); | ||||
$subscription = $subscriptionManger->findOneSubscriptionById($model->id); | $subscription = $subscriptionManger->findOneSubscriptionById($model->id); | ||||
$matchedDistributionsArray = $distributionManager->findDistributionsIncomingMatchWithSubscrtiption($subscription); | |||||
$matchedDistributionsArray = $distributionModule->findDistributionsIncomingMatchWithSubscrtiption($subscription); | |||||
if (count($matchedDistributionsArray)) { | if (count($matchedDistributionsArray)) { | ||||
return $this->redirect(['subscription/update-distributions', 'idSubscription' => $subscription->id]); | return $this->redirect(['subscription/update-distributions', 'idSubscription' => $subscription->id]); | ||||
*/ | */ | ||||
public function actionUpdate($id) | 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 = new SubscriptionForm; | ||||
$model->isAdmin = true; | $model->isAdmin = true; | ||||
$subscription = $subscriptionManager->findOneSubscriptionById($id); | |||||
$subscription = $subscriptionModule->findOneSubscriptionById($id); | |||||
if ($subscription) { | if ($subscription) { | ||||
$model->id = $id; | $model->id = $id; | ||||
$model->comment = $subscription->comment; | $model->comment = $subscription->comment; | ||||
} | } | ||||
$arrayProductsSubscription = $productSubscriptionManager->findProductSubscriptionsBySubscription($subscription); | |||||
$arrayProductsSubscription = $productSubscriptionModule->findProductSubscriptionsBySubscription($subscription); | |||||
foreach ($arrayProductsSubscription as $productSubscription) { | foreach ($arrayProductsSubscription as $productSubscription) { | ||||
$model->products['product_' . $productSubscription->id_product] = $productSubscription->quantity; | $model->products['product_' . $productSubscription->id_product] = $productSubscription->quantity; | ||||
} | } | ||||
} | } | ||||
// produits | // produits | ||||
$productsArray = $productManager->findProducts(); | |||||
$productsArray = $productModule->findProducts(); | |||||
if ($model->load(\Yii::$app->request->post()) && $model->validate()) { | if ($model->load(\Yii::$app->request->post()) && $model->validate()) { | ||||
if ($model->save()) { | if ($model->save()) { | ||||
$subscription = $subscriptionManager->findOneSubscriptionById($model->id); | |||||
$subscription = $subscriptionModule->findOneSubscriptionById($model->id); | |||||
$messageOrdersDeleted = ''; | $messageOrdersDeleted = ''; | ||||
if ($model->date_end) { | if ($model->date_end) { | ||||
$countOrdersDeleted = $orderManager->deleteOrdersIncomingDistributionsFromSubscription($subscription, true); | |||||
$countOrdersDeleted = $orderModule->deleteOrdersIncomingDistributionsFromSubscription($subscription, true); | |||||
if ($countOrdersDeleted) { | if ($countOrdersDeleted) { | ||||
$messageOrdersDeleted = '<br />' . $countOrdersDeleted . ' commandes supprimées'; | $messageOrdersDeleted = '<br />' . $countOrdersDeleted . ' commandes supprimées'; | ||||
} | } | ||||
$this->setFlash('success', 'Abonnement modifié' . $messageOrdersDeleted); | $this->setFlash('success', 'Abonnement modifié' . $messageOrdersDeleted); | ||||
$matchedDistributionsArray = $distributionManager->findDistributionsIncomingMatchWithSubscrtiption($subscription); | |||||
$matchedDistributionsArray = $distributionModule->findDistributionsIncomingMatchWithSubscrtiption($subscription); | |||||
if (count($matchedDistributionsArray)) { | if (count($matchedDistributionsArray)) { | ||||
return $this->redirect(['subscription/update-distributions', 'idSubscription' => $subscription->id, 'update' => true]); | return $this->redirect(['subscription/update-distributions', 'idSubscription' => $subscription->id, 'update' => true]); | ||||
} else { | } else { | ||||
*/ | */ | ||||
public function actionDelete(int $id) | 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é'); | $this->setFlash('success', 'Abonnement supprimé'); | ||||
public function actionUpdateDistributions(int $idSubscription, bool $generate = false, bool $update = false) | 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 ($generate) { | ||||
if ($update) { | if ($update) { | ||||
$orderManager->deleteOrdersIncomingDistributionsFromSubscription($subscription); | |||||
$orderModule->deleteOrdersIncomingDistributionsFromSubscription($subscription); | |||||
} | } | ||||
foreach ($matchedDistributionsArray as $distribution) { | 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.'); | $this->setFlash('success', 'Commandes ' . ($update ? 're-' : '') . 'générées dans les distributions futures.'); | ||||
return $this->redirect(['subscription/index']); | return $this->redirect(['subscription/index']); | ||||
{ | { | ||||
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; | \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; | ||||
$productManager = $this->getProductManager(); | |||||
$productModule = $this->getProductModule(); | |||||
$productsQuery = Product::find() | $productsQuery = Product::find() | ||||
->where(['id_producer' => GlobalParam::getCurrentProducerId()]) | ->where(['id_producer' => GlobalParam::getCurrentProducerId()]) | ||||
$productsArray = $productsQuery->asArray()->orderBy('order ASC')->all(); | $productsArray = $productsQuery->asArray()->orderBy('order ASC')->all(); | ||||
foreach ($productsArray as &$theProduct) { | 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])) { | if (isset($theProduct['productSubscription'][0])) { | ||||
$theProduct['quantity'] = $theProduct['productSubscription'][0]['quantity'] * Product::$unitsArray[$theProduct['unit']]['coefficient']; | $theProduct['quantity'] = $theProduct['productSubscription'][0]['quantity'] * Product::$unitsArray[$theProduct['unit']]['coefficient']; |
public function actionCreate() | public function actionCreate() | ||||
{ | { | ||||
$userCurrent = $this->getUserCurrent(); | $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éé.'); | $this->setFlash('success', 'Le ticket a bien été créé.'); | ||||
return $this->redirect(['view', 'id' => $ticket->id]); | return $this->redirect(['view', 'id' => $ticket->id]); | ||||
} else { | } else { | ||||
public function actionView(int $id) | public function actionView(int $id) | ||||
{ | { | ||||
$ticketManager = $this->getTicketManager(); | |||||
$ticketMessageManager = $this->getTicketMessageManager(); | |||||
$ticketModule = $this->getTicketModule(); | |||||
$ticketMessageModule = $this->getTicketMessageModule(); | |||||
$ticket = $this->findTicket($id); | $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']); | return $this->redirect(['view', 'id' => $ticket->id, '#' => 'bottom']); | ||||
} | } | ||||
public function actionClose(int $id) | public function actionClose(int $id) | ||||
{ | { | ||||
$ticketManager = $this->getTicketManager(); | |||||
$ticketModule = $this->getTicketModule(); | |||||
$ticket = $this->findTicket($id); | $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é."); | $this->addFlash('success', "Le ticket <strong>".Html::encode($ticket->subject)."</strong> a bien été fermé."); | ||||
return $this->redirect(['index']); | return $this->redirect(['index']); | ||||
} | } | ||||
public function actionOpen(int $id) | public function actionOpen(int $id) | ||||
{ | { | ||||
$ticketManager = $this->getTicketManager(); | |||||
$ticketModule = $this->getTicketModule(); | |||||
$ticket = $this->findTicket($id); | $ticket = $this->findTicket($id); | ||||
$ticketManager->openTicket($ticket); | |||||
$ticketModule->openTicket($ticket); | |||||
$this->addFlash('success', "Le ticket a bien été ouvert."); | $this->addFlash('success', "Le ticket a bien été ouvert."); | ||||
return $this->redirect(['index']); | return $this->redirect(['index']); | ||||
} | } | ||||
public function findTicket(int $id) | 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; | return $ticket; | ||||
} else { | } else { | ||||
throw new NotFoundHttpException("Le ticket est introuvable."); | throw new NotFoundHttpException("Le ticket est introuvable."); |
public function actionCreate() | public function actionCreate() | ||||
{ | { | ||||
$model = $this->getTaxRateManager()->instanciateTaxRate(); | |||||
$model = $this-> getTaxRateModule()->instanciateTaxRate(); | |||||
if ($model->load(\Yii::$app->request->post()) && $model->save()) { | if ($model->load(\Yii::$app->request->post()) && $model->save()) { | ||||
$this->setFlash('success', 'Taxe créée.'); | $this->setFlash('success', 'Taxe créée.'); | ||||
public function actionDelete(int $id) | public function actionDelete(int $id) | ||||
{ | { | ||||
$taxRateManager = $this->getTaxRateManager(); | |||||
$taxRateModule = $this-> getTaxRateModule(); | |||||
$taxRate = $this->findModel($id); | $taxRate = $this->findModel($id); | ||||
$taxRateManager->delete($taxRate); | |||||
$taxRateModule->delete($taxRate); | |||||
$this->setFlash('success', 'Taxe supprimé'); | $this->setFlash('success', 'Taxe supprimé'); | ||||
protected function findModel($id) | protected function findModel($id) | ||||
{ | { | ||||
$taxRateManager = $this->getTaxRateManager(); | |||||
if (($taxRate = $taxRateManager->findOneTaxRateById($id)) !== null) { | |||||
$taxRateModule = $this-> getTaxRateModule(); | |||||
if (($taxRate = $taxRateModule->findOneTaxRateById($id)) !== null) { | |||||
return $taxRate; | return $taxRate; | ||||
} else { | } else { | ||||
throw new NotFoundHttpException('The requested page does not exist.'); | throw new NotFoundHttpException('The requested page does not exist.'); |
bool $sectionSubscribers = false, | bool $sectionSubscribers = false, | ||||
bool $sectionInactiveUsers = false) | bool $sectionInactiveUsers = false) | ||||
{ | { | ||||
$pointSaleManager = $this->getPointSaleManager(); | |||||
$pointSaleModule = $this->getPointSaleModule(); | |||||
$searchModel = new UserSearch(); | $searchModel = new UserSearch(); | ||||
$dataProvider = $searchModel->search([ | $dataProvider = $searchModel->search([ | ||||
]); | ]); | ||||
$producer = $this->getProducerCurrent(); | $producer = $this->getProducerCurrent(); | ||||
$pointsSaleArray = $pointSaleManager->findPointSales(); | |||||
$pointsSaleArray = $pointSaleModule->findPointSales(); | |||||
return $this->render('index', [ | return $this->render('index', [ | ||||
'searchModel' => $searchModel, | 'searchModel' => $searchModel, | ||||
public function actionCreate() | public function actionCreate() | ||||
{ | { | ||||
$userModule = $this->getUserModule(); | $userModule = $this->getUserModule(); | ||||
$producerManager = $this->getProducerManager(); | |||||
$producerModule = $this->getProducerModule(); | |||||
$producerCurrent = $this->getProducerCurrent(); | $producerCurrent = $this->getProducerCurrent(); | ||||
$model = $userModule->instanciateUser(); | $model = $userModule->instanciateUser(); | ||||
$posts = Yii::$app->request->post(); | $posts = Yii::$app->request->post(); | ||||
} | } | ||||
if ($userExist) { | if ($userExist) { | ||||
$producerManager->addUser($userExist, $producerCurrent); | |||||
$producerModule->addUser($userExist, $producerCurrent); | |||||
$this->processLinkPointSale($userExist); | $this->processLinkPointSale($userExist); | ||||
$this->processLinkUserGroup($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."); | $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."); | ||||
public function actionUpdate($id) | public function actionUpdate($id) | ||||
{ | { | ||||
$userModule = $this->getUserModule(); | $userModule = $this->getUserModule(); | ||||
$pointSaleManager = $this->getPointSaleManager(); | |||||
$pointSaleModule = $this->getPointSaleModule(); | |||||
$model = $this->findModel($id); | $model = $this->findModel($id); | ||||
$previousMail = $model->email; | $previousMail = $model->email; | ||||
return $this->render('update', array_merge($this->initForm($model), [ | return $this->render('update', array_merge($this->initForm($model), [ | ||||
'model' => $model, | 'model' => $model, | ||||
'pointSaleBillingArray' => $pointSaleManager->findByBillingUser($model) | |||||
'pointSaleBillingArray' => $pointSaleModule->findByBillingUser($model) | |||||
])); | ])); | ||||
} | } | ||||
public function initForm($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) { | if ($model->id) { | ||||
$userPointSaleArray = $userPointSaleManager->findUserPointSalesByUser($model); | |||||
$userPointSaleArray = $userPointSaleModule->findUserPointSalesByUser($model); | |||||
if ($userPointSaleArray && count($userPointSaleArray) > 0) { | if ($userPointSaleArray && count($userPointSaleArray) > 0) { | ||||
foreach ($userPointSaleArray as $userPointSale) { | foreach ($userPointSaleArray as $userPointSale) { | ||||
$model->points_sale[] = $userPointSale->id_point_sale; | $model->points_sale[] = $userPointSale->id_point_sale; | ||||
} | } | ||||
} | } | ||||
$userUserGroupsArray = $userUserGroupManager->findUserUserGroupsByUser($model); | |||||
$userUserGroupsArray = $userUserGroupModule->findUserUserGroupsByUser($model); | |||||
if ($userUserGroupsArray && count($userUserGroupsArray) > 0) { | if ($userUserGroupsArray && count($userUserGroupsArray) > 0) { | ||||
foreach ($userUserGroupsArray as $userUserGroup) { | foreach ($userUserGroupsArray as $userUserGroup) { | ||||
$model->user_groups[] = $userUserGroup->id_user_group; | $model->user_groups[] = $userUserGroup->id_user_group; | ||||
} | } | ||||
} | } | ||||
$userProducer = $userProducerManager->findOneUserProducer($model); | |||||
$userProducer = $userProducerModule->findOneUserProducer($model); | |||||
$model->product_price_percent = $userProducer->product_price_percent; | $model->product_price_percent = $userProducer->product_price_percent; | ||||
} | } | ||||
}]) | }]) | ||||
->all(); | ->all(); | ||||
$userGroupsArray = $userGroupManager->findUserGroups(); | |||||
$userGroupsArray = $userGroupModule->findUserGroups(); | |||||
return [ | return [ | ||||
'pointsSaleArray' => $pointsSaleArray, | 'pointsSaleArray' => $pointsSaleArray, | ||||
public function processLinkPointSale(User $modelUser) | public function processLinkPointSale(User $modelUser) | ||||
{ | { | ||||
$posts = Yii::$app->request->post(); | $posts = Yii::$app->request->post(); | ||||
$userPointSaleManager = $this->getUserPointSaleManager(); | |||||
$pointSaleManager = $this->getPointSaleManager(); | |||||
$userPointSaleModule = $this->getUserPointSaleModule(); | |||||
$pointSaleModule = $this->getPointSaleModule(); | |||||
UserPointSale::deleteAll([ | UserPointSale::deleteAll([ | ||||
'id_user' => $modelUser->id | 'id_user' => $modelUser->id | ||||
]); | ]); | ||||
if (is_array($modelUser->points_sale) && count($modelUser->points_sale) > 0) { | if (is_array($modelUser->points_sale) && count($modelUser->points_sale) > 0) { | ||||
foreach ($modelUser->points_sale as $pointSaleId) { | 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) { | if (!$userPointSale) { | ||||
$userPointSale = new UserPointSale; | $userPointSale = new UserPointSale; | ||||
public function actionDelete(int $id) | public function actionDelete(int $id) | ||||
{ | { | ||||
$userModule = $this->getUserModule(); | $userModule = $this->getUserModule(); | ||||
$userProducerManager = $this->getUserProducerManager(); | |||||
$userProducerModule = $this->getUserProducerModule(); | |||||
$user = $userModule->findOneUserById($id); | $user = $userModule->findOneUserById($id); | ||||
$userProducer = $userProducerManager->findOneUserProducer($user); | |||||
$userProducer = $userProducerModule->findOneUserProducer($user); | |||||
if ($userProducer) { | 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."); | $this->setFlash('error', "Vous ne pouvez pas supprimer cet utilisateur car il a toujours du crédit en cours."); | ||||
} | } | ||||
else { | else { | ||||
$userProducerManager->unlinkUserProducer($userProducer); | |||||
$userProducerModule->unlinkUserProducer($userProducer); | |||||
$this->setFlash('success', 'L\'utilisateur a bien été supprimé de votre établissement.'); | $this->setFlash('success', 'L\'utilisateur a bien été supprimé de votre établissement.'); | ||||
} | } | ||||
} else { | } else { | ||||
public function actionCredit(int $id) | public function actionCredit(int $id) | ||||
{ | { | ||||
$userModule = $this->getUserModule(); | $userModule = $this->getUserModule(); | ||||
$paymentContainer = $this->getPaymentContainer(); | |||||
$userProducerContainer = $this->getUserProducerContainer(); | |||||
$paymentModule = $this->getPaymentModule(); | |||||
$userProducerModule = $this->getUserProducerModule(); | |||||
$user = $userModule->findOneUserById($id); | $user = $userModule->findOneUserById($id); | ||||
$userProducer = $userProducerContainer->getRepository()->findOneUserProducer($user); | |||||
$userProducer = $userProducerModule->getRepository()->findOneUserProducer($user); | |||||
if ($userProducer) { | if ($userProducer) { | ||||
$creditForm = new CreditForm(); | $creditForm = new CreditForm(); | ||||
if ($creditForm->load(\Yii::$app->request->post()) && $creditForm->validate()) { | 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) { | if($creditForm->send_mail) { | ||||
$paymentContainer->getNotifier() | |||||
->notifyUserCreditMovement($user, $creditForm->type, $creditForm->amount); | |||||
$paymentModule->getNotifier() | |||||
->notifyUserCreditMovement( | |||||
$user, | |||||
$creditForm->type, | |||||
$creditForm->amount | |||||
); | |||||
if(!$user->email) { | if(!$user->email) { | ||||
$this->addFlash('error', "L'utilisateur n'a pas pu être prévenu car son adresse email n'est pas définie."); | $this->addFlash('error', "L'utilisateur n'a pas pu être prévenu car son adresse email n'est pas définie."); | ||||
} | } | ||||
'user' => $user, | 'user' => $user, | ||||
'userProducer' => $userProducer, | 'userProducer' => $userProducer, | ||||
'creditForm' => $creditForm, | 'creditForm' => $creditForm, | ||||
'dataProvider' => $paymentContainer->getRepository() | |||||
'dataProvider' => $paymentModule->getRepository() | |||||
->queryPaymentsCreditHistoryByUser($user)->getDataProvider(20), | ->queryPaymentsCreditHistoryByUser($user)->getDataProvider(20), | ||||
]); | ]); | ||||
} else { | } else { | ||||
public function actionStateCredit($idUser, $state) | public function actionStateCredit($idUser, $state) | ||||
{ | { | ||||
$userModule = $this->getUserModule(); | $userModule = $this->getUserModule(); | ||||
$userProducerManager = $this->getUserProducerManager(); | |||||
$userProducerModule = $this->getUserProducerModule(); | |||||
$user = $userModule->findOneUserById($idUser); | $user = $userModule->findOneUserById($idUser); | ||||
$userProducer = $userProducerManager->findOneUserProducer($user); | |||||
$userProducer = $userProducerModule->findOneUserProducer($user); | |||||
if ($userProducer) { | if ($userProducer) { | ||||
$userProducer->credit_active = $state; | $userProducer->credit_active = $state; | ||||
$usersPointSaleHasOrder = 0) | $usersPointSaleHasOrder = 0) | ||||
{ | { | ||||
$userModule = $this->getUserModule(); | $userModule = $this->getUserModule(); | ||||
$distributionManager = $this->getDistributionManager(); | |||||
$distributionModule = $this-> getDistributionModule(); | |||||
if ($idPointSale && !$usersPointSaleLink && !$usersPointSaleHasOrder) { | if ($idPointSale && !$usersPointSaleLink && !$usersPointSaleHasOrder) { | ||||
$usersPointSaleLink = 1; | $usersPointSaleLink = 1; | ||||
return $this->redirect(['mail', 'idPointSale' => $idPointSale]); | return $this->redirect(['mail', 'idPointSale' => $idPointSale]); | ||||
} | } | ||||
$incomingDistributions = $distributionManager->findDistributionsIncoming(); | |||||
$incomingDistributions = $distributionModule->findDistributionsIncoming(); | |||||
$incomingDistributionsArray = ['0' => '--']; | $incomingDistributionsArray = ['0' => '--']; | ||||
foreach ($incomingDistributions as $distribution) { | foreach ($incomingDistributions as $distribution) { | ||||
$incomingDistributionsArray[$distribution->id] = strftime('%A %d %B %Y', strtotime($distribution->date)); | $incomingDistributionsArray[$distribution->id] = strftime('%A %d %B %Y', strtotime($distribution->date)); |
*/ | */ | ||||
public function actionCreate() | public function actionCreate() | ||||
{ | { | ||||
$userGroupManager = $this->getUserGroupManager(); | |||||
$userGroupModule = $this->getUserGroupModule(); | |||||
$model = $userGroupManager->instanciateUserGroup(); | |||||
$model = $userGroupModule->instanciateUserGroup(); | |||||
$model->id_producer = GlobalParam::getCurrentProducerId(); | $model->id_producer = GlobalParam::getCurrentProducerId(); | ||||
if ($model->load(\Yii::$app->request->post()) && $model->save()) { | if ($model->load(\Yii::$app->request->post()) && $model->save()) { | ||||
*/ | */ | ||||
protected function findModel(int $id) | 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; | return $model; | ||||
} else { | } else { | ||||
throw new NotFoundHttpException('The requested page does not exist.'); | throw new NotFoundHttpException('The requested page does not exist.'); |
namespace backend\models; | namespace backend\models; | ||||
use common\helpers\GlobalParam; | 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; | use yii\base\Model; | ||||
/** | /** | ||||
public function save() | public function save() | ||||
{ | { | ||||
$userModule = UserModule::getInstance(); | $userModule = UserModule::getInstance(); | ||||
$userProducerManager = UserProducerManager::getInstance(); | |||||
$paymentManager = PaymentManager::getInstance(); | |||||
$userProducerModule = UserProducerModule::getInstance(); | |||||
$paymentManager = PaymentModule::getInstance(); | |||||
if ($this->validate()) { | if ($this->validate()) { | ||||
$user = $userModule->findOneUserById($this->id_user); | $user = $userModule->findOneUserById($this->id_user); | ||||
// on prévient l'utilisateur que son compte vient d'être crédité | // on prévient l'utilisateur que son compte vient d'être crédité | ||||
if($this->send_mail) { | if($this->send_mail) { | ||||
$producer = GlobalParam::getCurrentProducer() ; | $producer = GlobalParam::getCurrentProducer() ; | ||||
$userProducer = $userProducerManager->findOneUserProducer($user); | |||||
$userProducer = $userProducerModule->findOneUserProducer($user); | |||||
\Yii::$app->mailerService->sendFromProducer( | \Yii::$app->mailerService->sendFromProducer( | ||||
'Mouvement de crédit', | 'Mouvement de crédit', |
use common\helpers\GlobalParam; | use common\helpers\GlobalParam; | ||||
use common\helpers\Mailjet; | use common\helpers\Mailjet; | ||||
use common\logic\Distribution\Distribution\Model\Distribution; | 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\Model\Product; | ||||
use common\logic\Product\Product\Wrapper\ProductManager; | |||||
use common\logic\Product\Product\Module\ProductModule; | |||||
use Yii; | use Yii; | ||||
use yii\base\Model; | use yii\base\Model; | ||||
use common\helpers\Price ; | use common\helpers\Price ; | ||||
*/ | */ | ||||
public function sendEmail($usersArray, $fromProducer = true) | 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( | $mj = new \Mailjet\Client( | ||||
Mailjet::getApiKey('public'), | Mailjet::getApiKey('public'), | ||||
if($distribution) { | if($distribution) { | ||||
$linkOrder = $distributionManager->getLinkOrder($distribution); | |||||
$linkOrder = $distributionModule->getLinkOrder($distribution); | |||||
$dateOrder = strftime('%A %d %B %Y', strtotime($distribution->date)) ; | $dateOrder = strftime('%A %d %B %Y', strtotime($distribution->date)) ; | ||||
$messageAutoHtml .= '<a href="'.$linkOrder.'">Passer ma commande du '.$dateOrder.'</a>' ; | $messageAutoHtml .= '<a href="'.$linkOrder.'">Passer ma commande du '.$dateOrder.'</a>' ; | ||||
$messageAutoText .= 'Suivez ce lien pour passer votre commande du '.$dateOrder.' : | $messageAutoText .= 'Suivez ce lien pour passer votre commande du '.$dateOrder.' : | ||||
$productDescription .= ' / '.$product->description ; | $productDescription .= ' / '.$product->description ; | ||||
} | } | ||||
if($product->price) { | 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.' | $messageAutoText .= '- '.$productDescription.' | ||||
if($fromProducer) { | if($fromProducer) { | ||||
$producer = GlobalParam::getCurrentProducer() ; | $producer = GlobalParam::getCurrentProducer() ; | ||||
$fromEmail = $producerManager->getEmailOpendistrib($producer) ; | |||||
$fromEmail = $producerModule->getEmailOpendistrib($producer) ; | |||||
$fromName = $producer->name ; | $fromName = $producer->name ; | ||||
// Message inscription newsletter | // Message inscription newsletter |
use common\helpers\GlobalParam; | use common\helpers\GlobalParam; | ||||
use common\logic\Order\Order\Model\Order; | 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 ; | use yii\helpers\Html ; | ||||
$userModule = UserModule::getInstance(); | $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'); | $this->setTitle('Tableau de bord'); | ||||
<td><?= date('d/m/Y à H:i', strtotime($subscription->created_at)); ?></td> | <td><?= date('d/m/Y à H:i', strtotime($subscription->created_at)); ?></td> | ||||
<td><?= $userModule->getUsername($subscription->user); ?></td> | <td><?= $userModule->getUsername($subscription->user); ?></td> | ||||
<td><?= Html::encode($subscription->pointSale->name); ?></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> | <td> | ||||
<a href="<?= $this->getUrlManager()->createUrl(['subscription/update', 'id' => $subscription->id]) ?>" class="btn btn-default"> | <a href="<?= $this->getUrlManager()->createUrl(['subscription/update', 'id' => $subscription->id]) ?>" class="btn btn-default"> | ||||
<span class="glyphicon glyphicon-pencil"></span> | <span class="glyphicon glyphicon-pencil"></span> | ||||
</thead> | </thead> | ||||
<tbody> | <tbody> | ||||
<?php foreach($ordersArray as $order): ?> | <?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"> | <td class="date"> | ||||
<div class="block-date"> | <div class="block-date"> | ||||
<div class="day"><?= strftime('%A', strtotime($order->distribution->date)) ?></div> | <div class="day"><?= strftime('%A', strtotime($order->distribution->date)) ?></div> | ||||
</div> | </div> | ||||
</td> | </td> | ||||
<td> | <td> | ||||
<?= $orderManager->getOrderUsername($order); ?><br /> | |||||
<?= $orderModule->getOrderUsername($order); ?><br /> | |||||
<?php if(strlen($order->comment)): ?> | <?php if(strlen($order->comment)): ?> | ||||
<div class="comment"><span class="glyphicon glyphicon-comment"></span> <?= nl2br(Html::encode($order->comment)) ; ?></div> | <div class="comment"><span class="glyphicon glyphicon-comment"></span> <?= nl2br(Html::encode($order->comment)) ; ?></div> | ||||
<?php endif; ?> | <?php endif; ?> | ||||
</td> | </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> | </tr> | ||||
<?php endforeach; ?> | <?php endforeach; ?> | ||||
</tbody> | </tbody> |
use common\logic\Order\Order\Model\Order; | use common\logic\Order\Order\Model\Order; | ||||
use yii\helpers\Html; | use yii\helpers\Html; | ||||
use yii\helpers\ArrayHelper; | 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->setTitle('Bons de livraison'); | ||||
$this->addBreadcrumb($this->getTitle()); | $this->addBreadcrumb($this->getTitle()); | ||||
'valid' => 'Valide', | 'valid' => 'Valide', | ||||
], | ], | ||||
'format' => 'raw', | 'format' => 'raw', | ||||
'value' => function ($model) use ($deliveryNoteManager) { | |||||
return $deliveryNoteManager->getHtmlLabel($model); | |||||
'value' => function ($model) use ($deliveryNoteModule) { | |||||
return $deliveryNoteModule->getHtmlLabel($model); | |||||
} | } | ||||
], | ], | ||||
[ | [ | ||||
'headerOptions' => ['class' => 'column-hide-on-mobile'], | 'headerOptions' => ['class' => 'column-hide-on-mobile'], | ||||
'filterOptions' => ['class' => 'column-hide-on-mobile'], | 'filterOptions' => ['class' => 'column-hide-on-mobile'], | ||||
'contentOptions' => ['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)) : ''; | return $distribution ? date('d/m/Y', strtotime($distribution->date)) : ''; | ||||
} | } | ||||
], | ], | ||||
'headerOptions' => ['class' => 'column-hide-on-mobile'], | 'headerOptions' => ['class' => 'column-hide-on-mobile'], | ||||
'filterOptions' => ['class' => 'column-hide-on-mobile'], | 'filterOptions' => ['class' => 'column-hide-on-mobile'], | ||||
'contentOptions' => ['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) : ''; | return $pointSale ? Html::encode($pointSale->name) : ''; | ||||
} | } | ||||
], | ], | ||||
[ | [ | ||||
'attribute' => 'amount', | 'attribute' => 'amount', | ||||
'header' => 'Montant', | '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); | |||||
} | } | ||||
], | ], | ||||
[ | [ | ||||
'headerOptions' => ['class' => 'column-actions'], | 'headerOptions' => ['class' => 'column-actions'], | ||||
'contentOptions' => ['class' => 'column-actions'], | 'contentOptions' => ['class' => 'column-actions'], | ||||
'buttons' => [ | '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, [ | return ((isset($deliveryNote->user) && strlen($deliveryNote->user->email) > 0) ? Html::a('<span class="glyphicon glyphicon-send"></span>', $url, [ | ||||
'title' => 'Envoyer', 'class' => 'btn btn-default' | 'title' => 'Envoyer', 'class' => 'btn btn-default' | ||||
]) : ''); | ]) : ''); | ||||
'title' => 'Télécharger', 'class' => 'btn btn-default' | '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' | 'title' => 'Valider', 'class' => 'btn btn-default' | ||||
]) : ''); | ]) : ''); | ||||
}, | }, | ||||
'title' => 'Modifier', 'class' => 'btn btn-default' | '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' | 'title' => 'Supprimer', 'class' => 'btn btn-default' | ||||
]) : ''); | ]) : ''); | ||||
} | } |
*/ | */ | ||||
use common\helpers\Price; | 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\Model\Product; | ||||
use common\logic\Product\Product\Wrapper\ProductManager; | |||||
use common\logic\Product\Product\Module\ProductModule; | |||||
use common\logic\User\UserProducer\Model\UserProducer; | use common\logic\User\UserProducer\Model\UserProducer; | ||||
$productManager = ProductManager::getInstance(); | |||||
$orderManager = OrderManager::getInstance(); | |||||
$productModule = ProductModule::getInstance(); | |||||
$orderModule = OrderModule::getInstance(); | |||||
$dayWeek = date('w', strtotime($date)); | $dayWeek = date('w', strtotime($date)); | ||||
$dayWeekArray = [0 => 'sunday', 1 => 'monday', 2 => 'tuesday', 3 => 'wednesday', 4 => 'thursday', 5 => 'friday', 6 => 'saturday']; | $dayWeekArray = [0 => 'sunday', 1 => 'monday', 2 => 'tuesday', 3 => 'wednesday', 4 => 'thursday', 5 => 'friday', 6 => 'saturday']; | ||||
$strUser = ''; | $strUser = ''; | ||||
// username | // username | ||||
$strUser = $orderManager->getOrderUsername($order) ; | |||||
$strUser = $orderModule->getOrderUsername($order) ; | |||||
if(strlen($order->comment_point_sale)) | if(strlen($order->comment_point_sale)) | ||||
{ | { | ||||
$add = false; | $add = false; | ||||
foreach ($order->productOrder as $productOrder) { | foreach ($order->productOrder as $productOrder) { | ||||
if($product->id == $productOrder->id_product) { | 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 />'; | $strProducts .= $product->name . ' (' .$productOrder->quantity .$unit.')<br />'; | ||||
$add = true; | $add = true; | ||||
} | } | ||||
$cpt = 0 ; | $cpt = 0 ; | ||||
foreach ($productsArray as $product) { | foreach ($productsArray as $product) { | ||||
foreach( Product::$unitsArray as $unit => $dataUnit) { | foreach( Product::$unitsArray as $unit => $dataUnit) { | ||||
$quantity = $orderManager->getProductQuantity($product, $pointSale->orders, false, $unit); | |||||
$quantity = $orderModule->getProductQuantity($product, $pointSale->orders, false, $unit); | |||||
if ($quantity) { | 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 />'; | $strProducts .= $product->name . ' (' .$quantity .$theUnit.')<br />'; | ||||
} | } | ||||
} | } | ||||
$cpt = 0 ; | $cpt = 0 ; | ||||
foreach ($productsArray as $product) { | foreach ($productsArray as $product) { | ||||
foreach( Product::$unitsArray as $unit => $dataUnit) { | foreach( Product::$unitsArray as $unit => $dataUnit) { | ||||
$quantity = $orderManager->getProductQuantity($product, $pointSale->orders, false, $unit); | |||||
$quantity = $orderModule->getProductQuantity($product, $pointSale->orders, false, $unit); | |||||
if ($quantity) { | 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 />'; | $html .= $product->name . ' (' .$quantity .$theUnit.')<br />'; | ||||
} | } | ||||
} | } | ||||
$cpt = 0 ; | $cpt = 0 ; | ||||
foreach ($productsArray as $product) { | foreach ($productsArray as $product) { | ||||
foreach( Product::$unitsArray as $unit => $dataUnit) { | foreach( Product::$unitsArray as $unit => $dataUnit) { | ||||
$quantity = $orderManager->getProductQuantity($product, $ordersArray, false, $unit); | |||||
$quantity = $orderModule->getProductQuantity($product, $ordersArray, false, $unit); | |||||
if ($quantity) { | 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 />'; | $html .= $product->name . ' (' .$quantity .$theUnit.')<br />'; | ||||
} | } | ||||
} | } |
<?php | <?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\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 = ''; | $html = ''; | ||||
foreach ($orders as $order) { | foreach ($orders as $order) { | ||||
$html .= '<th class="th-user" text-rotate="90">' | $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>' | //.'<div class="amount">'.number_format($order->amount_with_tax, 2) .' € </div>' | ||||
. '</th>'; | . '</th>'; | ||||
} | } | ||||
foreach ($orders as $order) { | foreach ($orders as $order) { | ||||
$html .= '<tr>'; | $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) { | if ($producer->option_order_reference_type == Producer::ORDER_REFERENCE_TYPE_YEARLY && $order->reference && strlen($order->reference) > 0) { | ||||
$strUser .= '<br />' . $order->reference; | $strUser .= '<br />' . $order->reference; | ||||
} | } | ||||
function line_product($product, $orders) | function line_product($product, $orders) | ||||
{ | { | ||||
$productManager = ProductManager::getInstance(); | |||||
$productModule = ProductModule::getInstance(); | |||||
$html = ''; | $html = ''; | ||||
if (has_quantity($product, $orders)) { | if (has_quantity($product, $orders)) { | ||||
$quantity = ''; | $quantity = ''; | ||||
foreach ($order->productOrder as $productOrder) { | foreach ($order->productOrder as $productOrder) { | ||||
if ($product->id == $productOrder->id_product) { | 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; | $quantity .= $productOrder->quantity . $unit; | ||||
if ($productOrder->quantity > 1) { | if ($productOrder->quantity > 1) { |
<?php | <?php | ||||
use common\logic\Order\Order\Wrapper\OrderManager; | |||||
use common\logic\Order\Order\Module\OrderModule; | |||||
use yii\helpers\Html; | use yii\helpers\Html; | ||||
$orderManager = OrderManager::getInstance(); | |||||
$orderModule = OrderModule::getInstance(); | |||||
$index = 0 | $index = 0 | ||||
?> | ?> | ||||
<div class="shopping-cart-label shopping-cart-label-<?= $index ?>"> | <div class="shopping-cart-label shopping-cart-label-<?= $index ?>"> | ||||
<div class="inner"> | <div class="inner"> | ||||
<div class="username"> | <div class="username"> | ||||
<?= $orderManager->getOrderUsername($order); ?> | |||||
<?= $orderModule->getOrderUsername($order); ?> | |||||
</div> | </div> | ||||
<div class="point-sale"> | <div class="point-sale"> | ||||
<?= Html::encode($order->pointSale->name); ?> • <?= date('d/m', strtotime($distribution->date)); ?> | <?= Html::encode($order->pointSale->name); ?> • <?= date('d/m', strtotime($distribution->date)); ?> | ||||
</div> | </div> | ||||
<div class="products"> | <div class="products"> | ||||
<?= $orderManager->getCartSummary($order); ?> | |||||
<?= $orderModule->getCartSummary($order); ?> | |||||
</div> | </div> | ||||
</div> | </div> | ||||
</div> | </div> |
use common\logic\Product\Product\Model\Product; | use common\logic\Product\Product\Model\Product; | ||||
use yii\helpers\Html; | use yii\helpers\Html; | ||||
$documentManager = $this->getDocumentManager(); | |||||
$productManager = $this->getProductManager(); | |||||
$documentModule = $this->getDocumentModule(); | |||||
$productModule = $this->getProductModule(); | |||||
?> | ?> | ||||
<?php | <?php | ||||
$price = $productOrder->getPrice() ; | $price = $productOrder->getPrice() ; | ||||
if($documentManager->isInvoicePrice($document) && $productOrder->getInvoicePrice()) { | |||||
if($documentModule->isInvoicePrice($document) && $productOrder->getInvoicePrice()) { | |||||
$price = $productOrder->getInvoicePrice() ; | $price = $productOrder->getInvoicePrice() ; | ||||
} | } | ||||
?> | ?> | ||||
<td class="align-center"> | <td class="align-center"> | ||||
<?= $productOrder->quantity * Product::$unitsArray[$productOrder->unit]['coefficient'] ?> | <?= $productOrder->quantity * Product::$unitsArray[$productOrder->unit]['coefficient'] ?> | ||||
</td> | </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($displayPrices): ?> | ||||
<?php if($producer->taxRate->value != 0): ?> | <?php if($producer->taxRate->value != 0): ?> | ||||
<td class="align-center"><?= $productOrder->taxRate->value * 100 ?> %</td> | <td class="align-center"><?= $productOrder->taxRate->value * 100 ?> %</td> | ||||
<?php endif; ?> | <?php endif; ?> | ||||
<td class="align-center"> | <td class="align-center"> | ||||
<?php if($documentManager->getClass($document) == ''): ?> | |||||
<?php if($documentModule->getClass($document) == ''): ?> | |||||
<?= Price::format($price * $productOrder->quantity) ?> | <?= Price::format($price * $productOrder->quantity) ?> | ||||
<?php else: ?> | <?php else: ?> | ||||
<?= Price::format($price * $productOrder->quantity) ?> | <?= Price::format($price * $productOrder->quantity) ?> |
* termes. | * 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\helpers\Html; | ||||
use yii\widgets\ActiveForm; | use yii\widgets\ActiveForm; | ||||
\backend\assets\VuejsDocumentFormAsset::register($this); | \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(); | $userModule = UserModule::getInstance(); | ||||
$paymentManager = PaymentManager::getInstance(); | |||||
$paymentManager = PaymentModule::getInstance(); | |||||
$documentClass = $documentManager->getClass($model); | |||||
$documentClass = $documentModule->getClass($model); | |||||
?> | ?> | ||||
<div class="info-box-content"> | <div class="info-box-content"> | ||||
<span class="info-box-text"> | <span class="info-box-text"> | ||||
Total<span v-if="taxRateProducer != 0"> (TTC)</span> | 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> | <span class="label label-success">PAYÉE</span> | ||||
<?php endif; ?> | <?php endif; ?> | ||||
</span> | </span> | ||||
class="btn btn-sm btn-default"><span class="glyphicon glyphicon-download-alt"></span> Télécharger | class="btn btn-sm btn-default"><span class="glyphicon glyphicon-download-alt"></span> Télécharger | ||||
(PDF)</a> | (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]) ?>" | <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 | class="btn btn-sm btn-default"><span class="glyphicon glyphicon-repeat"></span> Regénérer | ||||
(PDF)</a> | (PDF)</a> | ||||
<?php endif; ?> | <?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]) ?>" | <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 | class="btn btn-sm btn-default"><span class="glyphicon glyphicon-save-file"></span> Export Evoliz | ||||
(CSV)</a> | (CSV)</a> |
use common\logic\Order\Order\Model\Order; | use common\logic\Order\Order\Model\Order; | ||||
use common\helpers\Price; | use common\helpers\Price; | ||||
$producerManager = $this->getProducerManager(); | |||||
$producerModule = $this->getProducerModule(); | |||||
$userModule = $this->getUserModule(); | $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'); | |||||
?> | ?> | ||||
<div class="producer"> | <div class="producer"> | ||||
<?php if (strlen($producer->logo)) : ?> | <?php if (strlen($producer->logo)) : ?> | ||||
<div class="logo"> | <div class="logo"> | ||||
<img style="max-height: 80px;" src="<?= $producerManager->getUrlLogo($producer) ?>"/> | |||||
<img style="max-height: 80px;" src="<?= $producerModule->getUrlLogo($producer) ?>"/> | |||||
</div> | </div> | ||||
<?php endif; ?> | <?php endif; ?> | ||||
<div class="address"> | <div class="address"> | ||||
<?= $producerManager->getFullAddress($producer, true); ?> | |||||
<?= $producerModule->getFullAddress($producer, true); ?> | |||||
</div> | </div> | ||||
<?php if (strlen($producer->document_infos_top)): ?> | <?php if (strlen($producer->document_infos_top)): ?> | ||||
<div class="infos-top"> | <div class="infos-top"> | ||||
</div> | </div> | ||||
<div class="reference"> | <div class="reference"> | ||||
<?php if (strlen($document->reference)) : ?> | <?php if (strlen($document->reference)) : ?> | ||||
<?= $documentManager->getType($document); ?> N°<?= $document->reference; ?> | |||||
<?= $documentModule->getType($document); ?> N°<?= $document->reference; ?> | |||||
<?php else: ?> | <?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; ?> | <?php endif; ?> | ||||
</div> | </div> | ||||
<div class="name"> | <div class="name"> | ||||
</thead> | </thead> | ||||
<tbody> | <tbody> | ||||
<?php if ($producerManager->isDocumentDisplayOrders($document)): ?> | |||||
<?php if ($producerModule->isDocumentDisplayOrders($document)): ?> | |||||
<?php foreach ($document->orders as $order): ?> | <?php foreach ($document->orders as $order): ?> | ||||
<tr> | <tr> | ||||
<td> | <td> | ||||
<strong><?= $orderManager->getOrderUsername($order); ?></strong> | |||||
<strong><?= $orderModule->getOrderUsername($order); ?></strong> | |||||
<?php if ($order->distribution): ?> | <?php if ($order->distribution): ?> | ||||
le <?= date('d/m/Y', strtotime($order->distribution->date)) ?> | le <?= date('d/m/Y', strtotime($order->distribution->date)) ?> | ||||
<?php endif; ?> | <?php endif; ?> | ||||
<?php endforeach; ?> | <?php endforeach; ?> | ||||
<?php endforeach; ?> | <?php endforeach; ?> | ||||
<?php else: ?> | <?php else: ?> | ||||
<?php foreach ($documentManager->getProductsOrders($document) as $product): ?> | |||||
<?php foreach ($documentModule->getProductsOrders($document) as $product): ?> | |||||
<?php foreach ($product as $productOrder): ?> | <?php foreach ($product as $productOrder): ?> | ||||
<?= $this->render('_download_product_line', [ | <?= $this->render('_download_product_line', [ | ||||
'producer' => $producer, | 'producer' => $producer, | ||||
<?php endforeach; ?> | <?php endforeach; ?> | ||||
<?php endif; ?> | <?php endif; ?> | ||||
<?php if ($displayPrices): ?> | <?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): ?> | <?php if ($producer->taxRate->value != 0): ?> | ||||
<tr> | <tr> | ||||
<td class="align-right" colspan="5"><strong>Total HT</strong></td> | <td class="align-right" colspan="5"><strong>Total HT</strong></td> | ||||
<td class="align-center"> | <td class="align-center"> | ||||
<?= Price::format($documentManager->getAmount($document, $typeAmount)); ?> | |||||
<?= Price::format($documentModule->getAmount($document, $typeAmount)); ?> | |||||
</td> | </td> | ||||
</tr> | </tr> | ||||
<?php | <?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> | <tr> | ||||
<td class="align-right" colspan="5"> | <td class="align-right" colspan="5"> | ||||
<strong>TVA <?= $taxRateArray[$idTaxRate]->value * 100 ?> %</strong></td> | <strong>TVA <?= $taxRateArray[$idTaxRate]->value * 100 ?> %</strong></td> | ||||
<!--<tr> | <!--<tr> | ||||
<td class="align-right" colspan="5"><strong>TVA</strong></td> | <td class="align-right" colspan="5"><strong>TVA</strong></td> | ||||
<td class="align-center"> | <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> | </td> | ||||
</tr>--> | </tr>--> | ||||
<tr> | <tr> | ||||
<td class="align-right" colspan="5"><strong>Total TTC</strong></td> | <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> | </tr> | ||||
<?php else: ?> | <?php else: ?> | ||||
<tr> | <tr> | ||||
<strong>Total</strong><br/> | <strong>Total</strong><br/> | ||||
TVA non applicable | TVA non applicable | ||||
</td> | </td> | ||||
<td class="align-center"><?= Price::format($documentManager->getAmount($document, $typeAmount)) ?></td> | |||||
<td class="align-center"><?= Price::format($documentModule->getAmount($document, $typeAmount)) ?></td> | |||||
</tr> | </tr> | ||||
<?php endif; ?> | <?php endif; ?> | ||||
<?php endif; ?> | <?php endif; ?> | ||||
</div> | </div> | ||||
<?php | <?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)): ?> | <?php if (strlen($producer->$fieldProducerDocumentInfo)): ?> | ||||
<div class="block-infos"> | <div class="block-infos"> | ||||
<strong>Informations</strong><br/> | <strong>Informations</strong><br/> |
use common\helpers\MeanPayment; | use common\helpers\MeanPayment; | ||||
use common\helpers\Price; | 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\helpers\Html; | ||||
use yii\widgets\ActiveForm; | 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> | ||||
<div class="panel panel-default"> | <div class="panel panel-default"> | ||||
<div class="panel-heading"> | <div class="panel-heading"> | ||||
</table> | </table> | ||||
<?php endif; ?> | <?php endif; ?> | ||||
<?php if($invoiceManager->isDocumentInvoice($model) && !$invoiceManager->isInvoicePaid($model)): ?> | |||||
<?php if( $invoiceModule->isDocumentInvoice($model) && ! $invoiceModule->isInvoicePaid($model)): ?> | |||||
<div class="row"> | <div class="row"> | ||||
<?php $form = ActiveForm::begin(); ?> | <?php $form = ActiveForm::begin(); ?> | ||||
<div class="col-md-3"> | <div class="col-md-3"> |
use common\logic\Document\Invoice\Model\Invoice; | use common\logic\Document\Invoice\Model\Invoice; | ||||
use common\logic\Order\Order\Model\Order; | use common\logic\Order\Order\Model\Order; | ||||
$producerManager = $this->getProducerManager(); | |||||
$invoiceManager = $this->getInvoiceManager(); | |||||
$producerModule = $this->getProducerModule(); | |||||
$invoiceModule = $this-> getInvoiceModule(); | |||||
$userModule = $this->getUserModule(); | $userModule = $this->getUserModule(); | ||||
$this->setTitle('Factures'); | $this->setTitle('Factures'); | ||||
'valid' => 'Valide', | 'valid' => 'Valide', | ||||
], | ], | ||||
'format' => 'raw', | 'format' => 'raw', | ||||
'value' => function ($invoice) use ($invoiceManager) { | |||||
return $invoiceManager->getHtmlLabel($invoice); | |||||
'value' => function ($invoice) use ( $invoiceModule) { | |||||
return $invoiceModule->getHtmlLabel($invoice); | |||||
} | } | ||||
], | ], | ||||
[ | [ | ||||
'attribute' => 'amount', | 'attribute' => 'amount', | ||||
'header' => 'Montant', | 'header' => 'Montant', | ||||
'format' => 'raw', | '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); | |||||
} | } | ||||
], | ], | ||||
[ | [ | ||||
'headerOptions' => ['class' => 'column-hide-on-mobile'], | 'headerOptions' => ['class' => 'column-hide-on-mobile'], | ||||
'filterOptions' => ['class' => 'column-hide-on-mobile'], | 'filterOptions' => ['class' => 'column-hide-on-mobile'], | ||||
'contentOptions' => ['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>'; | return '<span class="label label-success">Oui</span>'; | ||||
} | } | ||||
'headerOptions' => ['class' => 'column-actions'], | 'headerOptions' => ['class' => 'column-actions'], | ||||
'contentOptions' => ['class' => 'column-actions'], | 'contentOptions' => ['class' => 'column-actions'], | ||||
'buttons' => [ | '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' | 'title' => 'Valider', 'class' => 'btn btn-default' | ||||
]) : ''); | ]) : ''); | ||||
}, | }, | ||||
'title' => 'Télécharger', 'class' => 'btn btn-default' | '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, [ | return Html::a('<span class="glyphicon glyphicon-save-file"></span> Evoliz', $url, [ | ||||
'title' => 'Export CSV Evoliz', 'class' => 'btn btn-default' | 'title' => 'Export CSV Evoliz', 'class' => 'btn btn-default' | ||||
]); | ]); | ||||
'title' => 'Modifier', 'class' => 'btn btn-default' | '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' | 'title' => 'Supprimer', 'class' => 'btn btn-default' | ||||
]) : ''); | ]) : ''); | ||||
} | } |
use dmstr\widgets\Alert; | use dmstr\widgets\Alert; | ||||
use common\helpers\GlobalParam; | use common\helpers\GlobalParam; | ||||
$producerManager = $this->getProducerManager(); | |||||
$producerModule = $this->getProducerModule(); | |||||
?> | ?> | ||||
<div class="content-wrapper"> | <div class="content-wrapper"> | ||||
<section class="content"> | <section class="content"> | ||||
<?php $producer = GlobalParam::getCurrentProducer(); ?> | <?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"> | <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> | <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> | <a href="<?= Yii::$app->urlManager->createUrl(['producer/update-opendistrib-version']) ?>" class="close"><span aria-hidden="true">×</span></a> |
*/ | */ | ||||
use common\helpers\Price; | 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 yii\helpers\Html; | ||||
use common\helpers\GlobalParam; | use common\helpers\GlobalParam; | ||||
use common\logic\Producer\Producer\Model\Producer; | use common\logic\Producer\Producer\Model\Producer; | ||||
$userModule = UserModule::getInstance(); | $userModule = UserModule::getInstance(); | ||||
$producerManager = ProducerManager::getInstance(); | |||||
$producerModule = ProducerModule::getInstance(); | |||||
$producer = GlobalParam::getCurrentProducer(); | $producer = GlobalParam::getCurrentProducer(); | ||||
$userCurrent = GlobalParam::getCurrentUser(); | $userCurrent = GlobalParam::getCurrentUser(); | ||||
*/ | */ | ||||
use common\helpers\GlobalParam; | 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(); | $userModule = UserModule::getInstance(); | ||||
$userProducerManager = $this->getUserProducerManager(); | |||||
$ticketManager = $this->getTicketManager(); | |||||
$userProducerModule = $this->getUserProducerModule(); | |||||
$ticketModule = $this->getTicketModule(); | |||||
$producer = GlobalParam::getCurrentProducer(); | $producer = GlobalParam::getCurrentProducer(); | ||||
$userCurrent = GlobalParam::getCurrentUser(); | $userCurrent = GlobalParam::getCurrentUser(); | ||||
<?php | <?php | ||||
$producer = GlobalParam::getCurrentProducer(); | $producer = GlobalParam::getCurrentProducer(); | ||||
$newVersionOpendistribLabel = ''; | $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>'; | $newVersionOpendistribLabel = '<span class="pull-right-container"><small class="label pull-right bg-green">'.GlobalParam::getOpendistribVersion().'</small></span>'; | ||||
} | } | ||||
$countTicketsProducerUnreadLabel = ''; | $countTicketsProducerUnreadLabel = ''; | ||||
$countTicketsProducerUnread = $ticketManager->countTicketsUnreadByUser($this->getUserCurrent()); | |||||
$countTicketsProducerUnread = $ticketModule->countTicketsUnreadByUser($this->getUserCurrent()); | |||||
if($countTicketsProducerUnread && !$isUserCurrentGrantedAsAdministrator) { | if($countTicketsProducerUnread && !$isUserCurrentGrantedAsAdministrator) { | ||||
$countTicketsProducerUnreadLabel = '<span class="pull-right-container"><small class="label pull-right bg-green">'.$countTicketsProducerUnread.'</small></span>'; | $countTicketsProducerUnreadLabel = '<span class="pull-right-container"><small class="label pull-right bg-green">'.$countTicketsProducerUnread.'</small></span>'; | ||||
} | } | ||||
$countTicketsAdminUnreadLabel = ''; | $countTicketsAdminUnreadLabel = ''; | ||||
$countTicketsAdminUnread = $ticketManager->countTicketsAdminUnreadByUser($this->getUserCurrent()); | |||||
$countTicketsAdminUnread = $ticketModule->countTicketsAdminUnreadByUser($this->getUserCurrent()); | |||||
if($countTicketsAdminUnread && $isUserCurrentGrantedAsAdministrator) { | if($countTicketsAdminUnread && $isUserCurrentGrantedAsAdministrator) { | ||||
$countTicketsAdminUnreadLabel = '<span class="pull-right-container"><small class="label pull-right bg-green">'.$countTicketsAdminUnread.'</small></span>'; | $countTicketsAdminUnreadLabel = '<span class="pull-right-container"><small class="label pull-right bg-green">'.$countTicketsAdminUnread.'</small></span>'; | ||||
} | } | ||||
$sumUserProducerCredits = $userProducerManager->sumUserProducerCredits(); | |||||
$sumUserProducerCredits = $userProducerModule->sumUserProducerCredits(); | |||||
$sumUserProducerCreditsLabel = ''; | $sumUserProducerCreditsLabel = ''; | ||||
//$sumUserProducerCreditsLabel = '<span class="pull-right-container"><small class="label pull-right '.($sumUserProducerCredits >= 0 ? 'bg-green' : 'bg-red') .'">'.number_format($sumUserProducerCredits, 2).' €</small></span>'; | //$sumUserProducerCreditsLabel = '<span class="pull-right-container"><small class="label pull-right '.($sumUserProducerCredits >= 0 ? 'bg-green' : 'bg-red') .'">'.number_format($sumUserProducerCredits, 2).' €</small></span>'; | ||||
'icon' => 'euro', | 'icon' => 'euro', | ||||
'url' => ['/credit/index'], | 'url' => ['/credit/index'], | ||||
'template' => '<a href="{url}">{icon} {label}' . $sumUserProducerCreditsLabel . '</a>', | '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], | ['label' => 'Groupes', 'icon' => 'users', 'url' => ['/user-group/index'], 'visible' => $isUserCurrentGrantedAsProducer], | ||||
], | ], |
*/ | */ | ||||
use common\logic\Order\Order\Model\Order; | 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)); | $dayWeek = date('w', strtotime($date)); | ||||
$dayWeekArray = [0 => 'sunday', 1 => 'monday', 2 => 'tuesday', 3 => 'wednesday', 4 => 'thursday', 5 => 'friday', 6 => 'saturday']; | $dayWeekArray = [0 => 'sunday', 1 => 'monday', 2 => 'tuesday', 3 => 'wednesday', 4 => 'thursday', 5 => 'friday', 6 => 'saturday']; | ||||
$html .= '<td><strong>'.number_format($order->amount, 2) . ' € '; | $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é)' ; | $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>' ; | $html .= '</strong></td>' ; | ||||
$strProducts = ''; | $strProducts = ''; | ||||
foreach ($productsArray as $product) { | foreach ($productsArray as $product) { | ||||
$quantity = $orderManager->getProductQuantity($product, $pointSale->orders); | |||||
$quantity = $orderModule->getProductQuantity($product, $pointSale->orders); | |||||
$strQuantity = ''; | $strQuantity = ''; | ||||
if ($quantity) { | if ($quantity) { | ||||
$strQuantity = $quantity; | $strQuantity = $quantity; | ||||
{ | { | ||||
$html .= '<tr><td>'.$pointSale->name.'</td><td>' ; | $html .= '<tr><td>'.$pointSale->name.'</td><td>' ; | ||||
foreach ($productsArray as $product) { | foreach ($productsArray as $product) { | ||||
$quantity = $orderManager->getProductQuantity($product, $pointSale->orders); | |||||
$quantity = $orderModule->getProductQuantity($product, $pointSale->orders); | |||||
$strQuantity = ($quantity) ? $quantity : '' ; | $strQuantity = ($quantity) ? $quantity : '' ; | ||||
if(strlen($strQuantity)) { | if(strlen($strQuantity)) { | ||||
// total | // total | ||||
$html .= '<tr><td><strong>Total</strong></td><td>' ; | $html .= '<tr><td><strong>Total</strong></td><td>' ; | ||||
foreach ($productsArray as $product) { | foreach ($productsArray as $product) { | ||||
$quantity = $orderManager->getProductQuantity($product, $ordersArray); | |||||
$quantity = $orderModule->getProductQuantity($product, $ordersArray); | |||||
if($quantity) { | if($quantity) { | ||||
$html .= $quantity . ' '.$product->name.', ' ; | $html .= $quantity . ' '.$product->name.', ' ; | ||||
} | } |
use yii\widgets\ActiveForm; | use yii\widgets\ActiveForm; | ||||
use yii\helpers\ArrayHelper; | use yii\helpers\ArrayHelper; | ||||
use common\logic\Producer\Producer\Model\Producer; | 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(); | $userModule = $this->getUserModule(); | ||||
?> | ?> | ||||
->hint('Utilisé lors de la facturation'); ?> | ->hint('Utilisé lors de la facturation'); ?> | ||||
<?php | <?php | ||||
$addHintCredit = ''; | $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>'; | $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; | endif; | ||||
<?= $form->field($model, 'credit_functioning') | <?= $form->field($model, 'credit_functioning') | ||||
->dropDownList([ | ->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_OPTIONAL => Producer::$creditFunctioningArray[Producer::CREDIT_FUNCTIONING_OPTIONAL], | ||||
Producer::CREDIT_FUNCTIONING_MANDATORY => Producer::$creditFunctioningArray[Producer::CREDIT_FUNCTIONING_MANDATORY], | Producer::CREDIT_FUNCTIONING_MANDATORY => Producer::$creditFunctioningArray[Producer::CREDIT_FUNCTIONING_MANDATORY], | ||||
Producer::CREDIT_FUNCTIONING_USER => Producer::$creditFunctioningArray[Producer::CREDIT_FUNCTIONING_USER], | Producer::CREDIT_FUNCTIONING_USER => Producer::$creditFunctioningArray[Producer::CREDIT_FUNCTIONING_USER], |
use common\logic\PointSale\UserPointSale\Model\UserPointSale; | use common\logic\PointSale\UserPointSale\Model\UserPointSale; | ||||
use common\logic\Producer\Producer\Model\Producer; | use common\logic\Producer\Producer\Model\Producer; | ||||
$pointSaleManager = $this->getPointSaleManager(); | |||||
$pointSaleModule = $this->getPointSaleModule(); | |||||
$this->setTitle('Points de vente'); | $this->setTitle('Points de vente'); | ||||
$this->addBreadcrumb($this->getTitle()); | $this->addBreadcrumb($this->getTitle()); | ||||
'saterday' => 'Samedi', | 'saterday' => 'Samedi', | ||||
'sunday' => 'Dimanche', | 'sunday' => 'Dimanche', | ||||
], | ], | ||||
'value' => function ($model) use ($pointSaleManager) { | |||||
return $pointSaleManager->getStrDeliveryDays($model); | |||||
'value' => function ($model) use ($pointSaleModule) { | |||||
return $pointSaleModule->getStrDeliveryDays($model); | |||||
} | } | ||||
], | ], | ||||
[ | [ |
termes. | termes. | ||||
*/ | */ | ||||
use common\logic\Producer\Producer\Wrapper\ProducerManager; | |||||
use common\logic\Producer\Producer\Module\ProducerModule; | |||||
$this->setTitle('Facturation producteur ('.$producer->name.')') ; | $this->setTitle('Facturation producteur ('.$producer->name.')') ; | ||||
$this->addBreadcrumb(['label' => 'Producteurs', 'url' => ['index']]) ; | $this->addBreadcrumb(['label' => 'Producteurs', 'url' => ['index']]) ; | ||||
$this->addBreadcrumb('Facturation') ; | $this->addBreadcrumb('Facturation') ; | ||||
$producerManager = ProducerManager::getInstance(); | |||||
$producerModule = ProducerModule::getInstance(); | |||||
?> | ?> | ||||
<div class="producer-billing"> | <div class="producer-billing"> | ||||
<?= $producerManager->getSummaryAmountsToBeBilled($producer, '12 derniers mois', 12, 'billing'); ?> | |||||
<?= $producerModule->getSummaryAmountsToBeBilled($producer, '12 derniers mois', 12, 'billing'); ?> | |||||
</div> | </div> |
use common\logic\Producer\Producer\Model\Producer; | use common\logic\Producer\Producer\Model\Producer; | ||||
use common\helpers\Price; | use common\helpers\Price; | ||||
$producerManager = $this->getProducerManager(); | |||||
$producerModule = $this->getProducerModule(); | |||||
$this->setTitle('Producteurs') ; | $this->setTitle('Producteurs') ; | ||||
$this->addBreadcrumb($this->getTitle()) ; | $this->addBreadcrumb($this->getTitle()) ; | ||||
[ | [ | ||||
'label' => 'Facturation', | 'label' => 'Facturation', | ||||
'format' => 'raw', | 'format' => 'raw', | ||||
'value' => function($producer) use ($producerManager) { | |||||
'value' => function($producer) use ($producerModule) { | |||||
$str = ''; | $str = ''; | ||||
$str .= '<ul style="margin: 0px;padding-left: 15px;">'; | $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) | if(($isBillingFrequencyMonthly && $summaryMonthly) | ||||
|| ($isBillingFrequencyQuaterly && $summaryQuaterly) | || ($isBillingFrequencyQuaterly && $summaryQuaterly) |
use common\helpers\Price; | use common\helpers\Price; | ||||
$producerManager = $this->getProducerManager(); | |||||
$producerPriceRangeManager = $this->getProducerPriceRangeManager(); | |||||
$producerModule = $this->getProducerModule(); | |||||
$producerPriceRangeModule = $this->getProducerPriceRangeModule(); | |||||
$this->setTitle('Tarifs') ; | $this->setTitle('Tarifs') ; | ||||
$this->addBreadcrumb($this->getTitle()) ; | $this->addBreadcrumb($this->getTitle()) ; | ||||
<?php | <?php | ||||
if($producerManager->isBillingTypeFreePrice($producer)) { | |||||
if($producerModule->isBillingTypeFreePrice($producer)) { | |||||
echo '<div class="alert alert-info">'; | 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 "Vous bénéficiez actuellement d'un abonnement à prix libre dont voici le montant : <strong>".$producer->getFreePrice()."</strong>"; | ||||
echo '</div>'; | echo '</div>'; | ||||
} | } | ||||
elseif($producerManager->isBillingTypeClassic($producer)) { | |||||
elseif($producerModule->isBillingTypeClassic($producer)) { | |||||
$month = date('Y-m', strtotime('-1 month')); | $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) { | if($amountBilledLastMonth) { | ||||
echo '<div class="alert alert-info">'; | 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 />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 '<br /><a href="'.Yii::$app->urlManager->createUrl(['stats/index']).'">Voir l\'évolution de mon chiffre d\'affaire</a>'; | ||||
echo '</div>'; | echo '</div>'; |
*/ | */ | ||||
use common\helpers\GlobalParam; | use common\helpers\GlobalParam; | ||||
use common\logic\User\User\Wrapper\UserModule; | |||||
use common\logic\User\User\Module\UserModule; | |||||
use yii\helpers\Html; | use yii\helpers\Html; | ||||
use yii\widgets\ActiveForm; | use yii\widgets\ActiveForm; | ||||
use common\logic\Producer\Producer\Model\Producer; | use common\logic\Producer\Producer\Model\Producer; |
use common\logic\Product\Product\Model\Product; | use common\logic\Product\Product\Model\Product; | ||||
use common\logic\PointSale\PointSale\Model\PointSale; | use common\logic\PointSale\PointSale\Model\PointSale; | ||||
$productCategoryManager = $this->getProductCategoryManager(); | |||||
$taxRateManager = $this->getTaxRateManager(); | |||||
$productCategoryModule = $this->getProductCategoryModule(); | |||||
$taxRateModule = $this-> getTaxRateModule(); | |||||
?> | ?> | ||||
<?= $form->field($model, 'status')->radioList([1 => 'Oui', 0 => 'Non']) ?> | <?= $form->field($model, 'status')->radioList([1 => 'Oui', 0 => 'Non']) ?> | ||||
<?= $form->field($model, 'name')->textInput(['maxlength' => 255]) ?> | <?= $form->field($model, 'name')->textInput(['maxlength' => 255]) ?> | ||||
<?= $form->field($model, 'reference')->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, 'description')->textInput(['maxlength' => 255]) ?> | ||||
<?= $form->field($model, 'recipe')->textarea()->label('Description longue') ?> | <?= $form->field($model, 'recipe')->textarea()->label('Description longue') ?> | ||||
$producer = \common\helpers\GlobalParam::getCurrentProducer(); | $producer = \common\helpers\GlobalParam::getCurrentProducer(); | ||||
$taxRateDefault = $producer->taxRate; | $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; | 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; | return $model->value; | ||||
})); | })); | ||||
foreach ($taxRateValuesArray as $key => $taxRateValue) { | foreach ($taxRateValuesArray as $key => $taxRateValue) { |
use common\helpers\Price; | use common\helpers\Price; | ||||
use common\logic\Product\Product\Model\Product; | use common\logic\Product\Product\Model\Product; | ||||
$productManager = $this->getProductManager(); | |||||
$productModule = $this->getProductModule(); | |||||
$this->setTitle('Produits'); | $this->setTitle('Produits'); | ||||
$this->addBreadcrumb($this->getTitle()); | $this->addBreadcrumb($this->getTitle()); | ||||
], | ], | ||||
[ | [ | ||||
'attribute' => 'price', | 'attribute' => 'price', | ||||
'value' => function ($model) use ($productManager) { | |||||
'value' => function ($model) use ($productModule) { | |||||
$return = ''; | $return = ''; | ||||
if ($model->price) { | 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; | return $return; |
use yii\bootstrap\ActiveForm; | use yii\bootstrap\ActiveForm; | ||||
use yii\helpers\Html; | use yii\helpers\Html; | ||||
$productManager = $this->getProductManager(); | |||||
$productModule = $this->getProductModule(); | |||||
$this->setTitle('Import prix produits'); | $this->setTitle('Import prix produits'); | ||||
$this->addBreadcrumb($this->getTitle()); | $this->addBreadcrumb($this->getTitle()); |
use common\helpers\Price; | use common\helpers\Price; | ||||
$productManager = $this->getProductManager(); | |||||
$productModule = $this->getProductModule(); | |||||
?> | ?> | ||||
<div class="alert alert-warning"> | <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> | </div> |
use common\helpers\GlobalParam; | use common\helpers\GlobalParam; | ||||
$userModule = $this->getUserModule(); | $userModule = $this->getUserModule(); | ||||
$userGroupManager = $this->getUserGroupManager(); | |||||
$pointSaleManager = $this->getPointSaleManager(); | |||||
$productManager = $this->getProductManager(); | |||||
$userGroupModule = $this->getUserGroupModule(); | |||||
$pointSaleModule = $this->getPointSaleModule(); | |||||
$productModule = $this->getProductModule(); | |||||
?> | ?> | ||||
]); ?> | ]); ?> | ||||
<?= $form->field($model, 'id_user')->dropDownList($userModule->populateUserDropdownList()); ?> | <?= $form->field($model, 'id_user')->dropDownList($userModule->populateUserDropdownList()); ?> | ||||
<?= $form->field($model, 'id_user_group')->dropDownList($userGroupManager->populateUserGroupDropdownList()); ?> | |||||
<?= $form->field($model, 'id_point_sale')->dropDownList($pointSaleManager->populatePointSaleDropdownList()); ?> | |||||
<?= $form->field($model, 'from_quantity')->label('À partir de la quantité ('. $productManager->strUnit($productManager->getRefUnit($modelProduct->unit), 'wording').')'); ?> | |||||
<?= $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 | <?php | ||||
$producer = GlobalParam::getCurrentProducer(); | $producer = GlobalParam::getCurrentProducer(); | ||||
<div class="col-xs-4"> | <div class="col-xs-4"> | ||||
<label for="reduction-increase-percent" class="control-label">Réduction / augmentation</label> | <label for="reduction-increase-percent" class="control-label">Réduction / augmentation</label> | ||||
<div class="input-group"> | <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> | <span class="input-group-addon">%</span> | ||||
</div> | </div> | ||||
</div> | </div> | ||||
<div class="col-xs-4"> | <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"> | <div class="input-group"> | ||||
{input} <span class="input-group-addon"><span class="glyphicon glyphicon-euro"></span></span> | {input} <span class="input-group-addon"><span class="glyphicon glyphicon-euro"></span></span> | ||||
</div> | </div> | ||||
</div> | </div> | ||||
<div class="col-xs-4"> | <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"> | <div class="input-group"> | ||||
<input type="text" id="productprice-price-with-tax" class="form-control" name="" value="" data-tax-rate-value="'.$taxRateValue.'"> | <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> | <span class="input-group-addon"><span class="glyphicon glyphicon-euro"></span></span> |
* termes. | * termes. | ||||
*/ | */ | ||||
use common\logic\User\User\Wrapper\UserModule; | |||||
use common\logic\User\User\Module\UserModule; | |||||
use yii\helpers\Html; | use yii\helpers\Html; | ||||
use common\helpers\Price; | use common\helpers\Price; | ||||
use yii\grid\GridView; | 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(); | $userModule = UserModule::getInstance(); | ||||
$this->setTitle('Liste des prix (' . Html::encode($model->name) . ')'); | $this->setTitle('Liste des prix (' . Html::encode($model->name) . ')'); | ||||
], | ], | ||||
[ | [ | ||||
'attribute' => 'from_quantity', | 'attribute' => 'from_quantity', | ||||
'value' => function ($productPrice) use ($productManager) { | |||||
'value' => function ($productPrice) use ($productModule) { | |||||
if ($productPrice->from_quantity) { | 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 ''; | return ''; | ||||
<h3 class="panel-title">Rappel du prix de base</h3> | <h3 class="panel-title">Rappel du prix de base</h3> | ||||
</div> | </div> | ||||
<div class="panel-body"> | <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> | </div> | ||||
</div> | </div> |
use common\logic\Order\Order\Model\Order; | use common\logic\Order\Order\Model\Order; | ||||
use yii\helpers\Html; | use yii\helpers\Html; | ||||
$quotationManager = $this->getQuotationManager(); | |||||
$quotationModule = $this->getQuotationModule(); | |||||
$userModule = $this->getUserModule(); | $userModule = $this->getUserModule(); | ||||
$this->setTitle('Devis'); | $this->setTitle('Devis'); | ||||
'valid' => 'Valide', | 'valid' => 'Valide', | ||||
], | ], | ||||
'format' => 'raw', | 'format' => 'raw', | ||||
'value' => function ($quotation) use ($quotationManager) { | |||||
return $quotationManager->getHtmlLabel($quotation); | |||||
'value' => function ($quotation) use ($quotationModule) { | |||||
return $quotationModule->getHtmlLabel($quotation); | |||||
} | } | ||||
], | ], | ||||
[ | [ | ||||
[ | [ | ||||
'attribute' => 'amount', | 'attribute' => 'amount', | ||||
'header' => 'Montant', | '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); | |||||
} | } | ||||
], | ], | ||||
[ | [ | ||||
'headerOptions' => ['class' => 'column-actions'], | 'headerOptions' => ['class' => 'column-actions'], | ||||
'contentOptions' => ['class' => 'column-actions'], | 'contentOptions' => ['class' => 'column-actions'], | ||||
'buttons' => [ | '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' | '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' | 'title' => 'Valider', 'class' => 'btn btn-default' | ||||
]) : ''); | ]) : ''); | ||||
}, | }, | ||||
'title' => 'Télécharger', 'class' => 'btn btn-default' | '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' | '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' | 'title' => 'Supprimer', 'class' => 'btn btn-default' | ||||
]) : ''); | ]) : ''); | ||||
} | } |
\backend\assets\VuejsSubscriptionFormAsset::register($this); | \backend\assets\VuejsSubscriptionFormAsset::register($this); | ||||
$userModule = $this->getUserModule(); | $userModule = $this->getUserModule(); | ||||
$pointSaleManager = $this->getPointSaleManager(); | |||||
$pointSaleModule = $this->getPointSaleModule(); | |||||
?> | ?> | ||||
<div class="clr"></div> | <div class="clr"></div> | ||||
<?= $form->field($model, 'id_producer')->hiddenInput() ?> | <?= $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']; | return $model['name']; | ||||
}), ['prompt' => '--','class' => 'form-control user-id']) ?> | }), ['prompt' => '--','class' => 'form-control user-id']) ?> | ||||
<?= $form->field($model, 'date_begin') ?> | <?= $form->field($model, 'date_begin') ?> |
termes. | termes. | ||||
*/ | */ | ||||
use common\logic\Subscription\Subscription\Wrapper\SubscriptionManager; | |||||
use common\logic\Subscription\Subscription\Module\SubscriptionModule; | |||||
use yii\helpers\Html; | use yii\helpers\Html; | ||||
use yii\grid\GridView; | use yii\grid\GridView; | ||||
use common\helpers\GlobalParam ; | use common\helpers\GlobalParam ; | ||||
use common\logic\Subscription\Subscription\Model\Subscription; | use common\logic\Subscription\Subscription\Model\Subscription; | ||||
use common\logic\PointSale\PointSale\Model\PointSale; | 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 yii\helpers\ArrayHelper; | ||||
use common\logic\Product\Product\Model\Product; | use common\logic\Product\Product\Model\Product; | ||||
$subscriptionManager = SubscriptionManager::getInstance(); | |||||
$subscriptionModule = SubscriptionModule::getInstance(); | |||||
$this->setTitle('Abonnements') ; | $this->setTitle('Abonnements') ; | ||||
$this->addBreadcrumb($this->getTitle()) ; | $this->addBreadcrumb($this->getTitle()) ; | ||||
'filterOptions' => ['class' => 'column-hide-on-mobile'], | 'filterOptions' => ['class' => 'column-hide-on-mobile'], | ||||
'contentOptions' => ['class' => 'column-hide-on-mobile'], | 'contentOptions' => ['class' => 'column-hide-on-mobile'], | ||||
'value' => function($model) { | 'value' => function($model) { | ||||
$productManager = ProductManager::getInstance(); | |||||
$productModule = ProductModule::getInstance(); | |||||
$html = '' ; | $html = '' ; | ||||
foreach($model->productSubscription as $productSubscription) | foreach($model->productSubscription as $productSubscription) | ||||
{ | { | ||||
if(isset($productSubscription->product)) { | 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 { | else { | ||||
$html .= 'Produit non défini<br />' ; | $html .= 'Produit non défini<br />' ; | ||||
'headerOptions' => ['class' => 'column-hide-on-mobile'], | 'headerOptions' => ['class' => 'column-hide-on-mobile'], | ||||
'filterOptions' => ['class' => 'column-hide-on-mobile'], | 'filterOptions' => ['class' => 'column-hide-on-mobile'], | ||||
'contentOptions' => ['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); | |||||
} | } | ||||
], | ], | ||||
[ | [ | ||||
'headerOptions' => ['class' => 'column-hide-on-mobile'], | 'headerOptions' => ['class' => 'column-hide-on-mobile'], | ||||
'filterOptions' => ['class' => 'column-hide-on-mobile'], | 'filterOptions' => ['class' => 'column-hide-on-mobile'], | ||||
'contentOptions' => ['class' => 'text-small 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); | |||||
} | } | ||||
], | ], | ||||
[ | [ |
*/ | */ | ||||
use common\logic\Ticket\Ticket\Model\Ticket; | 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\helpers\Html; | ||||
use yii\grid\GridView; | use yii\grid\GridView; | ||||
$ticketManager = TicketManager::getInstance(); | |||||
$ticketModule = TicketModule::getInstance(); | |||||
$userCurrent = $this->getUserCurrent(); | $userCurrent = $this->getUserCurrent(); | ||||
$this->setTitle('Support & contact'); | $this->setTitle('Support & contact'); | ||||
$this->addBreadcrumb($this->getTitle()); | $this->addBreadcrumb($this->getTitle()); | ||||
function ticketList($context, $searchTicket, $dataProviderTicket, $userCurrent) | function ticketList($context, $searchTicket, $dataProviderTicket, $userCurrent) | ||||
{ | { | ||||
$ticketManager = TicketManager::getInstance(); | |||||
$ticketModule = TicketModule::getInstance(); | |||||
$columnCreatedAt = [ | $columnCreatedAt = [ | ||||
'attribute' => 'created_at', | 'attribute' => 'created_at', | ||||
'attribute' => 'subject', | 'attribute' => 'subject', | ||||
'headerOptions' => ['class' => 'td-subject'], | 'headerOptions' => ['class' => 'td-subject'], | ||||
'format' => 'raw', | '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>'; | $link = '<strong>'.Html::a($ticket->subject, ['view', 'id' => $ticket->id, '#' => $firstTicketMessageUnread->id]).'</strong>'; | ||||
} | } | ||||
else { | else { | ||||
'title' => 'Voir le ticket', 'class' => 'btn btn-default' | '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'; | $title = 'Fermer'; | ||||
$url = ['close', 'id' => $ticket->id]; | $url = ['close', 'id' => $ticket->id]; | ||||
$glyphicon = 'glyphicon-folder-close'; | $glyphicon = 'glyphicon-folder-close'; |
<?php | <?php | ||||
use common\helpers\GlobalParam; | 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\helpers\Html; | ||||
use yii\widgets\ActiveForm; | use yii\widgets\ActiveForm; | ||||
$ticketManager = TicketManager::getInstance(); | |||||
$ticketModule = TicketModule::getInstance(); | |||||
$userModule = UserModule::getInstance(); | $userModule = UserModule::getInstance(); | ||||
$userCurrent = GlobalParam::getCurrentUser(); | $userCurrent = GlobalParam::getCurrentUser(); | ||||
$this->setTitle('Voir un ticket'); | $this->setTitle('Voir un ticket'); | ||||
</tr> | </tr> | ||||
<tr> | <tr> | ||||
<td><strong>Ouverture</strong></td> | <td><strong>Ouverture</strong></td> | ||||
<td><?= $ticketManager->getTicketDateCreatedAtFormat($ticket); ?></td> | |||||
<td><?= $ticketModule->getTicketDateCreatedAtFormat($ticket); ?></td> | |||||
</tr> | </tr> | ||||
<tr> | <tr> | ||||
<td><strong>Statut</strong></td> | <td><strong>Statut</strong></td> | ||||
<td><?= $ticketManager->getTicketStatusLabelAsHtml($ticket); ?></td> | |||||
<td><?= $ticketModule->getTicketStatusLabelAsHtml($ticket); ?></td> | |||||
</tr> | </tr> | ||||
<?php if($userModule->getAuthorizationChecker()->isGrantedAsAdministrator($userCurrent)): ?> | <?php if($userModule->getAuthorizationChecker()->isGrantedAsAdministrator($userCurrent)): ?> | ||||
<tr> | <tr> | ||||
<td><strong>Producteur</strong></td> | <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-warning">Non lu</span>' : | ||||
'<span class="label label-success">Lu</span>'; ?> | '<span class="label label-success">Lu</span>'; ?> | ||||
</td> | </td> | ||||
</div> | </div> | ||||
</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"> | <div class="box-header"> | ||||
<h3 class="box-title"> | <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 | <i class="fa fa-folder"></i> Cliquez ici si vous souhaitez fermer le ticket | ||||
<?php else: ?> | <?php else: ?> | ||||
<i class="fa fa-folder-open"></i> Cliquez ici si vous souhaitez rouvrir le ticket | <i class="fa fa-folder-open"></i> Cliquez ici si vous souhaitez rouvrir le ticket | ||||
</h3> | </h3> | ||||
</div> | </div> | ||||
<div class="box-body"> | <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']) ?> | <?= Html::a('Fermer le ticket', ['close', 'id' => $ticket->id], ['class' => 'btn btn-danger btn-sm']) ?> | ||||
<?php else: ?> | <?php else: ?> | ||||
<?= Html::a('Rouvrir le ticket', ['open', 'id' => $ticket->id], ['class' => 'btn btn-success btn-sm']) ?> | <?= Html::a('Rouvrir le ticket', ['open', 'id' => $ticket->id], ['class' => 'btn btn-success btn-sm']) ?> |
\backend\assets\VuejsUserFormAsset::register($this); | \backend\assets\VuejsUserFormAsset::register($this); | ||||
$userModule = $this->getUserModule(); | $userModule = $this->getUserModule(); | ||||
$producerManager = $this->getProducerManager(); | |||||
$producerModule = $this->getProducerModule(); | |||||
?> | ?> | ||||
<?= $form->field($model, 'newsletter')->checkbox() ?> | <?= $form->field($model, 'newsletter')->checkbox() ?> | ||||
<?= $form->field($model, 'address')->textarea() ?> | <?= $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() ?> | <?= $form->field($model, 'evoliz_code')->textInput() ?> | ||||
<?php endif; ?> | <?php endif; ?> | ||||
use common\logic\Payment\Model\Payment; | use common\logic\Payment\Model\Payment; | ||||
use common\helpers\MeanPayment; | use common\helpers\MeanPayment; | ||||
$paymentManager = $this->getPaymentManager(); | |||||
$producerManager = $this->getProducerManager(); | |||||
$paymentManager = $this->getPaymentModule(); | |||||
$producerModule = $this->getProducerModule(); | |||||
$userModule = $this->getUserModule(); | $userModule = $this->getUserModule(); | ||||
$this->setTitle('Créditer <small>'.Html::encode($user->lastname.' '.$user->name).'</small>', 'Créditer '.Html::encode($user->lastname.' '.$user->name)) ; | $this->setTitle('Créditer <small>'.Html::encode($user->lastname.' '.$user->name).'</small>', 'Créditer '.Html::encode($user->lastname.' '.$user->name)) ; | ||||
<div class="user-credit"> | <div class="user-credit"> | ||||
<?php | <?php | ||||
$producer = $producerManager->findOneProducerById(GlobalParam::getCurrentProducerId()); | |||||
$producer = $producerModule->findOneProducerById(GlobalParam::getCurrentProducerId()); | |||||
if(!$producer->credit) | if(!$producer->credit) | ||||
{ | { |
*/ | */ | ||||
use common\helpers\GlobalParam; | use common\helpers\GlobalParam; | ||||
use common\logic\Producer\Producer\Wrapper\ProducerManager; | |||||
use common\logic\Producer\Producer\Module\ProducerModule; | |||||
use yii\helpers\Html; | use yii\helpers\Html; | ||||
use yii\grid\GridView; | 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\Order\Order\Model\Order; | ||||
use common\logic\User\UserProducer\Model\UserProducer; | use common\logic\User\UserProducer\Model\UserProducer; | ||||
$userModule = UserModule::getInstance(); | $userModule = UserModule::getInstance(); | ||||
$producerManager = ProducerManager::getInstance(); | |||||
$producerModule = ProducerModule::getInstance(); | |||||
$userCurrent = GlobalParam::getCurrentUser(); | $userCurrent = GlobalParam::getCurrentUser(); | ||||
$this->setTitle('Utilisateurs'); | $this->setTitle('Utilisateurs'); | ||||
<?= GridView::widget([ | <?= GridView::widget([ | ||||
'dataProvider' => $dataProvider, | 'dataProvider' => $dataProvider, | ||||
'filterModel' => $searchModel, | 'filterModel' => $searchModel, | ||||
'summary' => $this->getProducerContainer()->getProducerPageSizer() | |||||
'summary' => $this->getProducerModule()->getProducerPageSizer() | |||||
->getPageSizeSummary($producer, 'user', 'Utilisateurs'), | ->getPageSizeSummary($producer, 'user', 'Utilisateurs'), | ||||
'columns' => [ | 'columns' => [ | ||||
[ | [ |
use yii\helpers\Html; | use yii\helpers\Html; | ||||
$userModule = $this->getUserModule(); | $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->setTitle('Commandes <small>' . Html::encode($userModule->getUsername($user)) . '</small>', 'Commandes de ' . Html::encode($userModule->getUsername($user))); | ||||
$this->addBreadcrumb(['label' => 'Utilisateurs', 'url' => ['index']]); | $this->addBreadcrumb(['label' => 'Utilisateurs', 'url' => ['index']]); | ||||
[ | [ | ||||
'label' => 'Historique', | 'label' => 'Historique', | ||||
'format' => 'raw', | 'format' => 'raw', | ||||
'value' => function ($order) use ($orderManager) { | |||||
return $orderManager->getHistorySummary($order); | |||||
'value' => function ($order) use ($orderModule) { | |||||
return $orderModule->getHistorySummary($order); | |||||
} | } | ||||
], | ], | ||||
[ | [ | ||||
'label' => 'Résumé', | 'label' => 'Résumé', | ||||
'format' => 'raw', | 'format' => 'raw', | ||||
'value' => function ($order) use ($orderManager) { | |||||
return $orderManager->getCartSummary($order); | |||||
'value' => function ($order) use ($orderModule) { | |||||
return $orderModule->getCartSummary($order); | |||||
} | } | ||||
], | ], | ||||
[ | [ | ||||
'label' => 'Point de vente', | 'label' => 'Point de vente', | ||||
'format' => 'raw', | 'format' => 'raw', | ||||
'value' => function ($order) use ($orderManager) { | |||||
return $orderManager->getPointSaleSummary($order); | |||||
'value' => function ($order) use ($orderModule) { | |||||
return $orderModule->getPointSaleSummary($order); | |||||
} | } | ||||
], | ], | ||||
[ | [ | ||||
'label' => 'Montant', | 'label' => 'Montant', | ||||
'format' => 'raw', | '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); | |||||
} | } | ||||
], | ], | ||||
[ | [ |
{ | { | ||||
use BusinessLogicTrait; | use BusinessLogicTrait; | ||||
public function getContainers() | |||||
public function getModules() | |||||
{ | { | ||||
return [ | 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) | 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 = $serviceClass::getInstance(); | ||||
$instanceService->setProducerContext($producer); | $instanceService->setProducerContext($producer); | ||||
} | } | ||||
* Hiérarchie des apps | * Hiérarchie des apps | ||||
*/ | */ | ||||
public function getContainerLevelHierarchyByService($serviceClass): int | |||||
public function getModuleLevelHierarchyByService($serviceClass): int | |||||
{ | { | ||||
$containersArray = $this->getContainers(); | |||||
$modulesArray = $this->getModules(); | |||||
$entityFqcnService = $this->getEntityFqcnByService($serviceClass); | $entityFqcnService = $this->getEntityFqcnByService($serviceClass); | ||||
foreach($containersArray as $key => $container) { | |||||
if($container->getEntityFqcn() == $entityFqcnService) { | |||||
foreach($modulesArray as $key => $module) { | |||||
if($module->getEntityFqcn() == $entityFqcnService) { | |||||
return $key; | return $key; | ||||
} | } | ||||
} | } | ||||
public function getEntityFqcnByService(string $serviceClass): string | 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.'); | |||||
} | } | ||||
} | } |
namespace common\components; | 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 | 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 | public function getUserModule(): UserModule | ||||
return UserModule::getInstance(); | 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(); | |||||
} | } | ||||
} | } |
use common\logic\Product\Product\Model\Product; | use common\logic\Product\Product\Model\Product; | ||||
use common\logic\Subscription\ProductSubscription\Model\ProductSubscription; | use common\logic\Subscription\ProductSubscription\Model\ProductSubscription; | ||||
use common\logic\Subscription\Subscription\Model\Subscription; | 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; | ||||
use yii\base\Model; | use yii\base\Model; | ||||
public function save() | public function save() | ||||
{ | { | ||||
$userModule = UserModule::getInstance(); | $userModule = UserModule::getInstance(); | ||||
$subscriptionManager = SubscriptionManager::getInstance(); | |||||
$subscriptionModule = SubscriptionModule::getInstance(); | |||||
if ($this->id) { | if ($this->id) { | ||||
$subscription = Subscription::searchOne(['id' => $this->id]) ; | $subscription = Subscription::searchOne(['id' => $this->id]) ; | ||||
$subscription->populateUpdatedBy($userModule->getCurrent()); | $subscription->populateUpdatedBy($userModule->getCurrent()); | ||||
} | } | ||||
else { | else { | ||||
$subscription = $subscriptionManager->instanciateSubscription($userModule->getCurrent()) ; | |||||
$subscription = $subscriptionModule->instanciateSubscription($userModule->getCurrent()) ; | |||||
} | } | ||||
if ($subscription) { | if ($subscription) { |
namespace common\helpers; | namespace common\helpers; | ||||
use common\logic\Producer\Producer\Wrapper\ProducerManager; | |||||
use common\logic\Producer\Producer\Module\ProducerModule; | |||||
class CSV | class CSV | ||||
{ | { | ||||
public static function array2csv(array &$array) | 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) { | if (count($array) == 0) { | ||||
return null; | return null; |
namespace common\helpers; | namespace common\helpers; | ||||
use common\logic\Producer\Producer\Model\Producer; | 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; | use common\logic\User\User\Service\UserSolver; | ||||
class GlobalParam | class GlobalParam | ||||
public static function getCurrentProducer() | public static function getCurrentProducer() | ||||
{ | { | ||||
$producerManager = ProducerManager::getInstance(); | |||||
$producerModule = ProducerModule::getInstance(); | |||||
if(!\Yii::$app->parameterBag->has('producer') || !\Yii::$app->parameterBag->get('producer')) { | 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'); | return \Yii::$app->parameterBag->get('producer'); |
namespace common\helpers; | namespace common\helpers; | ||||
use common\logic\Order\Order\Model\Order; | 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; | use linslin\yii2\curl; | ||||
class Tiller | class Tiller | ||||
public function __construct() | public function __construct() | ||||
{ | { | ||||
$producerManager = ProducerManager::getInstance(); | |||||
$producerModule = ProducerModule::getInstance(); | |||||
$this->curl = new curl\Curl(); | $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) | public function getOrders($date) | ||||
public function isSynchro($date, $idOrder = null) | public function isSynchro($date, $idOrder = null) | ||||
{ | { | ||||
$orderManager = OrderManager::getInstance(); | |||||
$orderModule = OrderModule::getInstance(); | |||||
if ($this->producer_tiller) { | if ($this->producer_tiller) { | ||||
$ordersTiller = $this->getOrders($date); | $ordersTiller = $this->getOrders($date); | ||||
if ($ordersOpendistrib) { | if ($ordersOpendistrib) { | ||||
foreach ($ordersOpendistrib as $orderOpendistrib) { | foreach ($ordersOpendistrib as $orderOpendistrib) { | ||||
$orderManager->initOrder($orderOpendistrib); | |||||
$orderModule->initOrder($orderOpendistrib); | |||||
$ordersOpendistribSynchro[$orderOpendistrib->id] = false; | $ordersOpendistribSynchro[$orderOpendistrib->id] = false; | ||||
if (isset($ordersTiller->orders)) { | if (isset($ordersTiller->orders)) { | ||||
foreach ($ordersTiller->orders as $orderTiller) { | foreach ($ordersTiller->orders as $orderTiller) { | ||||
if ($orderOpendistrib->tiller_external_id == $orderTiller->id) { | if ($orderOpendistrib->tiller_external_id == $orderTiller->id) { | ||||
$amountTotalPaidOrderOpendistrib = (int)round( | $amountTotalPaidOrderOpendistrib = (int)round( | ||||
$orderManager->getOrderAmountWithTax($orderOpendistrib, Order::AMOUNT_PAID) * 100 | |||||
$orderModule->getOrderAmountWithTax($orderOpendistrib, Order::AMOUNT_PAID) * 100 | |||||
); | ); | ||||
if ($amountTotalPaidOrderOpendistrib >= (int)$orderTiller->currentPayedAmount | if ($amountTotalPaidOrderOpendistrib >= (int)$orderTiller->currentPayedAmount | ||||
|| $amountTotalPaidOrderOpendistrib >= (int)$orderTiller->currentBill) { | || $amountTotalPaidOrderOpendistrib >= (int)$orderTiller->currentBill) { |
<?php | |||||
namespace common\logic; | |||||
abstract class AbstractContainer extends AbstractSingleton implements ContainerInterface | |||||
{ | |||||
public function getEntityFqcn(): string | |||||
{ | |||||
return $this->getDefinition()->getEntityFqcn(); | |||||
} | |||||
} |
<?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()); | |||||
} | |||||
} |
return true; | return true; | ||||
} | } | ||||
elseif($levelHierarchyServiceAsked == $levelHierarchyServiceCurrent | elseif($levelHierarchyServiceAsked == $levelHierarchyServiceCurrent | ||||
&& $domain->getContainerLevelHierarchyByService($serviceClassAsked) | |||||
< $domain->getContainerLevelHierarchyByService($serviceCurrentClass)) { | |||||
&& $domain->getModuleLevelHierarchyByService($serviceClassAsked) | |||||
< $domain->getModuleLevelHierarchyByService($serviceCurrentClass)) { | |||||
return true; | return true; | ||||
} | } |
if (!isset(self::$instances[$c])) { | if (!isset(self::$instances[$c])) { | ||||
self::$instances[$c] = new $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]))) { | if(in_array(ServiceInterface::class, class_implements(self::$instances[$c]))) { | ||||
self::$instances[$c]->loadDependencies(); | self::$instances[$c]->loadDependencies(); | ||||
} | } |
<?php | <?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\Repository\TaxRateRepository; | ||||
use common\logic\Config\TaxRate\Service\TaxRateBuilder; | use common\logic\Config\TaxRate\Service\TaxRateBuilder; | ||||
use common\logic\Config\TaxRate\Service\TaxRateDefinition; | 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 | public function getServices(): array | ||||
{ | { |
<?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; | |||||
} | |||||
} |
<?php | |||||
namespace common\logic; | |||||
interface ContainerInterface | |||||
{ | |||||
public function getServices(): array; | |||||
//public function getDefinition(): DefinitionInterface; | |||||
} |
<?php | <?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\Repository\DistributionRepository; | ||||
use common\logic\Distribution\Distribution\Service\DistributionBuilder; | use common\logic\Distribution\Distribution\Service\DistributionBuilder; | ||||
use common\logic\Distribution\Distribution\Service\DistributionDefinition; | use common\logic\Distribution\Distribution\Service\DistributionDefinition; | ||||
use common\logic\Distribution\Distribution\Service\DistributionShoppingCartLabelsPdfGenerator; | use common\logic\Distribution\Distribution\Service\DistributionShoppingCartLabelsPdfGenerator; | ||||
use common\logic\Distribution\Distribution\Service\DistributionSolver; | 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 | public function getServices(): array | ||||
{ | { | ||||
return DistributionDefinition::getInstance(); | return DistributionDefinition::getInstance(); | ||||
} | } | ||||
public function getSolver(): DistributionSolver | |||||
{ | |||||
return DistributionSolver::getInstance(); | |||||
} | |||||
public function getRepository(): DistributionRepository | public function getRepository(): DistributionRepository | ||||
{ | { | ||||
return DistributionRepository::getInstance(); | 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(); | |||||
} | |||||
} | } |
} | } | ||||
$orderLine[$productsIndexArray[$productOrder->id_product]] .= $productOrder->quantity; | $orderLine[$productsIndexArray[$productOrder->id_product]] .= $productOrder->quantity; | ||||
if ($productOrder->product->unit != $productOrder->unit) { | if ($productOrder->product->unit != $productOrder->unit) { | ||||
$orderLine[$productsIndexArray[$productOrder->id_product]] .= $productManager->strUnit( | |||||
$orderLine[$productsIndexArray[$productOrder->id_product]] .= $productModule->strUnit( | |||||
$productOrder->unit, | $productOrder->unit, | ||||
'wording_short', | 'wording_short', | ||||
true | true |
<?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; | |||||
} | |||||
} |
<?php | <?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\Repository\PointSaleDistributionRepository; | ||||
use common\logic\Distribution\PointSaleDistribution\Service\PointSaleDistributionBuilder; | use common\logic\Distribution\PointSaleDistribution\Service\PointSaleDistributionBuilder; | ||||
use common\logic\Distribution\PointSaleDistribution\Service\PointSaleDistributionDefinition; | 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 | public function getServices(): array | ||||
{ | { |
<?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; | |||||
} | |||||
} |
<?php | <?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\Repository\ProductDistributionRepository; | ||||
use common\logic\Distribution\ProductDistribution\Service\ProductDistributionBuilder; | use common\logic\Distribution\ProductDistribution\Service\ProductDistributionBuilder; | ||||
use common\logic\Distribution\ProductDistribution\Service\ProductDistributionDefinition; | 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 | public function getServices(): array | ||||
{ | { |
<?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; | |||||
} | |||||
} |
<?php | <?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\Repository\DeliveryNoteRepository; | ||||
use common\logic\Document\DeliveryNote\Service\DeliveryNoteBuilder; | use common\logic\Document\DeliveryNote\Service\DeliveryNoteBuilder; | ||||
use common\logic\Document\DeliveryNote\Service\DeliveryNoteDefinition; | use common\logic\Document\DeliveryNote\Service\DeliveryNoteDefinition; | ||||
use common\logic\Document\DeliveryNote\Service\DeliveryNoteSolver; | 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 | public function getServices(): array | ||||
{ | { |
<?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; | |||||
} | |||||
} |
<?php | <?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\DefinitionInterface; | ||||
use common\logic\Document\Document\Repository\DocumentRepository; | use common\logic\Document\Document\Repository\DocumentRepository; | ||||
use common\logic\Document\Document\Service\DocumentBuilder; | use common\logic\Document\Document\Service\DocumentBuilder; | ||||
use common\logic\Document\Document\Service\DocumentSolver; | use common\logic\Document\Document\Service\DocumentSolver; | ||||
use common\logic\Document\Document\Service\DocumentUtils; | 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 | public function getServices(): array | ||||
{ | { | ||||
]; | ]; | ||||
} | } | ||||
public function getDefinition(): DefinitionInterface | |||||
public function getDefinition() | |||||
{ | { | ||||
return DocumentDefinition::getInstance(); | return DocumentDefinition::getInstance(); | ||||
} | } | ||||
public function getSolver(): DocumentSolver | |||||
public function getSolver() | |||||
{ | { | ||||
return DocumentSolver::getInstance(); | return DocumentSolver::getInstance(); | ||||
} | } | ||||
public function getRepository(): DocumentRepository | |||||
public function getRepository() | |||||
{ | { | ||||
return DocumentRepository::getInstance(); | return DocumentRepository::getInstance(); | ||||
} | } | ||||
public function getBuilder(): DocumentBuilder | |||||
public function getBuilder() | |||||
{ | { | ||||
return DocumentBuilder::getInstance(); | return DocumentBuilder::getInstance(); | ||||
} | } | ||||
public function getUtils(): DocumentUtils | |||||
public function getUtils() | |||||
{ | { | ||||
return DocumentUtils::getInstance(); | return DocumentUtils::getInstance(); | ||||
} | } |
<?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; | |||||
} | |||||
} |
<?php | <?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\Repository\InvoiceRepository; | ||||
use common\logic\Document\Invoice\Service\InvoiceBuilder; | use common\logic\Document\Invoice\Service\InvoiceBuilder; | ||||
use common\logic\Document\Invoice\Service\InvoiceDefinition; | use common\logic\Document\Invoice\Service\InvoiceDefinition; | ||||
use common\logic\Document\Invoice\Service\InvoiceSolver; | 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 | public function getServices(): array | ||||
{ | { |
<?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; | |||||
} | |||||
} |
<?php | <?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\Document\Service\DocumentSolver; | ||||
use common\logic\Document\Quotation\Repository\QuotationRepository; | use common\logic\Document\Quotation\Repository\QuotationRepository; | ||||
use common\logic\Document\Quotation\Service\QuotationBuilder; | use common\logic\Document\Quotation\Service\QuotationBuilder; | ||||
use common\logic\Document\Quotation\Service\QuotationDefinition; | 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 | public function getServices(): array | ||||
{ | { | ||||
{ | { | ||||
return DocumentSolver::getInstance(); | return DocumentSolver::getInstance(); | ||||
} | } | ||||
public function getRepository(): QuotationRepository | public function getRepository(): QuotationRepository | ||||
{ | { | ||||
return QuotationRepository::getInstance(); | return QuotationRepository::getInstance(); |
<?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; | |||||
} | |||||
} |
<?php | |||||
namespace common\logic; | |||||
interface ManagerInterface | |||||
{ | |||||
public function getContainerFqcn(): string; | |||||
} |
<?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(); | |||||
} | |||||
} |
<?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 | |||||
]; | |||||
} | |||||
} |
<?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; | |||||
} | |||||
} |
use common\logic\Document\DeliveryNote\Event\DeliveryNoteCreateEvent; | use common\logic\Document\DeliveryNote\Event\DeliveryNoteCreateEvent; | ||||
use common\logic\Document\DeliveryNote\Model\DeliveryNote; | 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; | use justcoded\yii2\eventlistener\observers\Observer; | ||||
class DeliveryNoteObserver extends Observer | class DeliveryNoteObserver extends Observer | ||||
public function onDeliveryNoteCreate(DeliveryNoteCreateEvent $event) | public function onDeliveryNoteCreate(DeliveryNoteCreateEvent $event) | ||||
{ | { | ||||
$orderManager = OrderManager::getInstance(); | |||||
$orderManager->assignAllOrdersDeliveryNote($event->idOrders, $event->deliveryNote); | |||||
$orderModule = OrderModule::getInstance(); | |||||
$orderModule->assignAllOrdersDeliveryNote($event->idOrders, $event->deliveryNote); | |||||
} | } | ||||
} | } |
<?php | <?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\Repository\OrderRepository; | ||||
use common\logic\Order\Order\Service\OrderBuilder; | use common\logic\Order\Order\Service\OrderBuilder; | ||||
use common\logic\Order\Order\Service\OrderDefinition; | use common\logic\Order\Order\Service\OrderDefinition; | ||||
use common\logic\Order\Order\Service\OrderSolver; | use common\logic\Order\Order\Service\OrderSolver; | ||||
use common\logic\Order\Order\Service\OrderUtils; | 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 | public function getServices(): array | ||||
{ | { |
<?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; | |||||
} | |||||
} |
<?php | <?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\Repository\ProductOrderRepository; | ||||
use common\logic\Order\ProductOrder\Service\ProductOrderBuilder; | use common\logic\Order\ProductOrder\Service\ProductOrderBuilder; | ||||
use common\logic\Order\ProductOrder\Service\ProductOrderDefinition; | use common\logic\Order\ProductOrder\Service\ProductOrderDefinition; | ||||
use common\logic\Order\ProductOrder\Service\ProductOrderSolver; | 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 | public function getServices(): array | ||||
{ | { |
<?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; | |||||
} | |||||
} |