@@ -49,7 +49,7 @@ return [ | |||
'basePath' => dirname(__DIR__), | |||
'name' => 'distrib', | |||
'controllerNamespace' => 'backend\controllers', | |||
'defaultRoute' => 'site/index', | |||
'defaultRoute' => 'dashboard/index', | |||
'bootstrap' => ['log'], | |||
'modules' => [], | |||
'components' => [ |
@@ -56,7 +56,7 @@ class BackendController extends CommonController | |||
// Pas de producteur défini | |||
if(!$producerCurrent) { | |||
$this->redirect(\Yii::$app->urlManagerFrontend->createAbsoluteUrl(['site/index'])); | |||
$this->redirect(\Yii::$app->urlManagerFrontend->createAbsoluteUrl(['dashboard/index'])); | |||
return false; | |||
} | |||
@@ -70,7 +70,7 @@ class BackendController extends CommonController | |||
public function checkProductsPointsSale() | |||
{ | |||
if (!Product::searchCount() || !PointSale::searchCount()) { | |||
$this->redirect(['site/index', 'error_products_points_sale' => 1]); | |||
$this->redirect(['dashboard/index', 'error_products_points_sale' => 1]); | |||
} | |||
} | |||
@@ -38,6 +38,7 @@ | |||
namespace backend\controllers; | |||
use common\helpers\GlobalParam; | |||
use common\helpers\MeanPayment; | |||
use common\logic\Order\Order\Model\Order; | |||
use common\logic\User\User\Model\User; | |||
@@ -156,7 +157,7 @@ class CronController extends BackendController | |||
'conditions' => 'date_delete IS NULL' | |||
]); | |||
$configCredit = $producerManager->getConfig('credit', $producer->id); | |||
$configCredit = $producerManager->getConfig('credit'); | |||
if ($arrayOrders && is_array($arrayOrders)) { | |||
foreach ($arrayOrders as $order) { | |||
@@ -174,7 +175,7 @@ class CronController extends BackendController | |||
* Envoi des commandes par email au producteur | |||
*/ | |||
if (!strlen($forceDate) && $producerManager->getConfig('option_notify_producer_order_summary', $producer->id)) { | |||
if (!strlen($forceDate) && $producerManager->getConfig('option_notify_producer_order_summary')) { | |||
$arrayOrders = Order::searchAll([ | |||
'distribution.date' => $date, | |||
'distribution.id_producer' => $producer->id |
@@ -0,0 +1,88 @@ | |||
<?php | |||
/** | |||
* Copyright distrib (2018) | |||
* | |||
* contact@opendistrib.net | |||
* | |||
* Ce logiciel est un programme informatique servant à aider les producteurs | |||
* à distribuer leur production en circuits courts. | |||
* | |||
* Ce logiciel est régi par la licence CeCILL soumise au droit français et | |||
* respectant les principes de diffusion des logiciels libres. Vous pouvez | |||
* utiliser, modifier et/ou redistribuer ce programme sous les conditions | |||
* de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA | |||
* sur le site "http://www.cecill.info". | |||
* | |||
* En contrepartie de l'accessibilité au code source et des droits de copie, | |||
* de modification et de redistribution accordés par cette licence, il n'est | |||
* offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, | |||
* seule une responsabilité restreinte pèse sur l'auteur du programme, le | |||
* titulaire des droits patrimoniaux et les concédants successifs. | |||
* | |||
* A cet égard l'attention de l'utilisateur est attirée sur les risques | |||
* associés au chargement, à l'utilisation, à la modification et/ou au | |||
* développement et à la reproduction du logiciel par l'utilisateur étant | |||
* donné sa spécificité de logiciel libre, qui peut le rendre complexe à | |||
* manipuler et qui le réserve donc à des développeurs et des professionnels | |||
* avertis possédant des connaissances informatiques approfondies. Les | |||
* utilisateurs sont donc invités à charger et tester l'adéquation du | |||
* logiciel à leurs besoins dans des conditions permettant d'assurer la | |||
* sécurité de leurs systèmes et ou de leurs données et, plus généralement, | |||
* à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. | |||
* | |||
* Le fait que vous puissiez accéder à cet en-tête signifie que vous avez | |||
* pris connaissance de la licence CeCILL, et que vous en avez accepté les | |||
* termes. | |||
*/ | |||
namespace backend\controllers; | |||
use yii\filters\AccessControl; | |||
use yii\filters\VerbFilter; | |||
/** | |||
* Dashboard controller | |||
*/ | |||
class DashboardController extends BackendController | |||
{ | |||
/** | |||
* @inheritdoc | |||
*/ | |||
public function behaviors() | |||
{ | |||
return [ | |||
'access' => [ | |||
'class' => AccessControl::class, | |||
'rules' => [ | |||
[ | |||
'allow' => true, | |||
'roles' => ['@'], | |||
'matchCallback' => function ($rule, $action) { | |||
return $this->getUserManager()->hasAccessBackend(); | |||
} | |||
], | |||
], | |||
], | |||
'verbs' => [ | |||
'class' => VerbFilter::class, | |||
'actions' => [ | |||
], | |||
], | |||
]; | |||
} | |||
/** | |||
* Affiche le tableau de bord avec les distributions à venir et les dernières commandes passées ou modifiées. | |||
*/ | |||
public function actionIndex() | |||
{ | |||
return $this->render('index', [ | |||
'producer' => $this->getProducerCurrent(), | |||
'productsCount' => $this->getProductContainer()->getRepository()->countProducts(), | |||
'pointsSaleCount' => $this->getPointSaleContainer()->getRepository()->countPointSales(), | |||
'distributionsArray' => $this->getDistributionContainer()->getRepository()->findDistributionsDashboard(), | |||
'ordersArray' => $this->getOrderContainer()->getRepository()->findOrdersDashboard(), | |||
]); | |||
} | |||
} |
@@ -127,6 +127,7 @@ class DistributionController extends BackendController | |||
$json['means_payment'] = MeanPayment::getAll(); | |||
$json['producer'] = $this->buildAjaxInfosResponseProducer($producer); | |||
$json['distributions'] = $this->buildAjaxInfosResponseDistributions($dateObject); | |||
$json['units'] = Product::$unitsArray; | |||
if ($dateObject && $dateObject->format($format) === $date) { | |||
$distribution = $distributionManager->createDistributionIfNotExist($date); | |||
@@ -208,8 +209,11 @@ class DistributionController extends BackendController | |||
$jsonProduct['quantity_form'] = 0; | |||
if (!$product->taxRate) { | |||
$jsonProduct['taxRate'] = $this->getProducerCurrent()->taxRate; | |||
if ($product->taxRate) { | |||
$jsonProduct['taxRate'] = $product->taxRate->getAttributes(); | |||
} | |||
else { | |||
$jsonProduct['taxRate'] = $this->getProducerCurrent()->taxRate->getAttributes(); | |||
} | |||
$jsonProductsArray[] = $jsonProduct; | |||
@@ -346,6 +350,7 @@ class DistributionController extends BackendController | |||
$arrayCreditUser = []; | |||
if(isset($order->user)) { | |||
$arrayCreditUser['credit'] = $userManager->getCredit($order->user); | |||
$arrayCreditUser['credit_active'] = $userManager->getCreditActive($order->user); | |||
} | |||
$oneProductUnactivated = false; | |||
@@ -532,7 +537,6 @@ class DistributionController extends BackendController | |||
$productOrderArray[$product['id']] = [ | |||
'quantity' => $quantity, | |||
'unit' => $product->unit, | |||
'unit_coefficient' => Product::$unitsArray[$product->unit]['coefficient'], | |||
'prices' => $priceArray, | |||
'active' => $product->productDistribution[0]->active | |||
&& (!$pointSale || $productManager->isAvailableOnPointSale($product, $pointSale)), |
@@ -463,6 +463,11 @@ class DocumentController extends BackendController | |||
$json['orders_update_array'] = $document ? $this->initOrdersArray($orderManager->findOrdersByUserAndInvoice($user, $document)) : []; | |||
} | |||
if ($classDocument == 'DeliveryNote') { | |||
$json['orders_create_array'] = $this->initOrdersArray($orderManager->findOrdersByUserNotLinkedDeliveryNote($user)); | |||
$json['orders_update_array'] = $document ? $this->initOrdersArray($orderManager->findOrdersByUserAndDeliveryNote($user, $document)) : []; | |||
} | |||
return $json; | |||
} | |||
} | |||
@@ -703,6 +708,64 @@ class DocumentController extends BackendController | |||
return Ajax::responseError('Une erreur est survenue lors de la suppression du produit.'); | |||
} | |||
public function actionAjaxAddOrder($idDocument, $classDocument, $idOrder) | |||
{ | |||
$documentManager = $this->getDocumentManager(); | |||
$orderManager = $this->getOrderManager(); | |||
$document = $documentManager->findOneDocumentByIdAndClass($idDocument, $classDocument); | |||
$order = $orderManager->findOneOrderById($idOrder); | |||
if ($document && $documentManager->isStatusDraft($document) && $order) { | |||
$orderManager->updateOrderDocument($order, $document); | |||
return Ajax::responseSuccess("Commande ajoutée à la facture."); | |||
} | |||
else { | |||
return Ajax::responseError("Une erreur est survenue lors de l'ajout de la commande."); | |||
} | |||
} | |||
public function actionAjaxDeleteOrder($idDocument, $classDocument, $idOrder) | |||
{ | |||
$documentManager = $this->getDocumentManager(); | |||
$orderManager = $this->getOrderManager(); | |||
$document = $documentManager->findOneDocumentByIdAndClass($idDocument, $classDocument); | |||
$order = $orderManager->findOneOrderById($idOrder); | |||
if ($document && $documentManager->isStatusDraft($document)) { | |||
if($documentManager->isDocumentDeliveryNote($document)) { | |||
$orderManager->updateOrderDeliveryNote($order, null); | |||
} | |||
elseif($documentManager->isDocumentInvoice($document)) { | |||
$orderManager->updateOrderInvoice($order, null); | |||
} | |||
return Ajax::responseSuccess('Commande supprimée de la facture.'); | |||
} | |||
else { | |||
return Ajax::responseError('Une erreur est survenue lors de la suppression de la commande.'); | |||
} | |||
} | |||
public function actionAjaxIgnoreOrderWhenInvoicing($idDocument, $classDocument, $idOrder) | |||
{ | |||
$documentManager = $this->getDocumentManager(); | |||
$orderManager = $this->getOrderManager(); | |||
$document = $documentManager->findOneDocumentByIdAndClass($idDocument, $classDocument); | |||
$order = $orderManager->findOneOrderById($idOrder); | |||
if ($document && $documentManager->isStatusDraft($document) && $order) { | |||
$orderManager->updateOrderIgnoreWhenInvoicing($order, true); | |||
return Ajax::responseSuccess("La commande sera maintenant ignorée au moment de la facturation."); | |||
} | |||
else { | |||
return Ajax::responseError("Une erreur est survenue."); | |||
} | |||
} | |||
public function getClass() | |||
{ | |||
$class = get_class($this); |
@@ -90,55 +90,4 @@ class InvoiceController extends DocumentController | |||
return Ajax::responseError("Une erreur est survenue lors de l'ajout du bon de livraison."); | |||
} | |||
} | |||
public function actionAjaxAddOrder($idInvoice, $idOrder) | |||
{ | |||
$invoiceManager = $this->getInvoiceManager(); | |||
$orderManager = $this->getOrderManager(); | |||
$invoice = $invoiceManager->findOneInvoiceById($idInvoice); | |||
$order = $orderManager->findOneOrderById($idOrder); | |||
if ($invoice && $invoiceManager->isStatusDraft($invoice) && $order) { | |||
$orderManager->updateOrderInvoice($order, $invoice); | |||
return Ajax::responseSuccess("Commande ajoutée à la facture."); | |||
} | |||
else { | |||
return Ajax::responseError("Une erreur est survenue lors de l'ajout de la commande."); | |||
} | |||
} | |||
public function actionAjaxDeleteOrder($idInvoice, $idOrder) | |||
{ | |||
$invoiceManager = $this->getInvoiceManager(); | |||
$orderManager = $this->getOrderManager(); | |||
$invoice = $invoiceManager->findOneInvoiceById($idInvoice); | |||
$order = $orderManager->findOneOrderById($idOrder); | |||
if ($invoice && $invoiceManager->isStatusDraft($invoice)) { | |||
$orderManager->updateOrderInvoice($order, null); | |||
return Ajax::responseSuccess('Commande supprimée de la facture.'); | |||
} | |||
else { | |||
return Ajax::responseError('Une erreur est survenue lors de la suppression de la commande.'); | |||
} | |||
} | |||
public function actionAjaxIgnoreOrderWhenInvoicing($idInvoice, $idOrder) | |||
{ | |||
$invoiceManager = $this->getInvoiceManager(); | |||
$orderManager = $this->getOrderManager(); | |||
$invoice = $invoiceManager->findOneInvoiceById($idInvoice); | |||
$order = $orderManager->findOneOrderById($idOrder); | |||
if ($invoice && $invoiceManager->isStatusDraft($invoice) && $order) { | |||
$orderManager->updateOrderIgnoreWhenInvoicing($order, true); | |||
return Ajax::responseSuccess("La commande sera maintenant ignorée au moment de la facturation."); | |||
} | |||
else { | |||
return Ajax::responseError("Une erreur est survenue."); | |||
} | |||
} | |||
} |
@@ -176,7 +176,7 @@ class OrderController extends BackendController | |||
$productDistributionManager = $this->getProductDistributionManager(); | |||
if (!Product::searchCount() || !PointSale::searchCount()) { | |||
$this->redirect(['site/index', 'error_products_points_sale' => 1]); | |||
$this->redirect(['dashboard/index', 'error_products_points_sale' => 1]); | |||
} | |||
$orders = []; | |||
@@ -957,8 +957,10 @@ class OrderController extends BackendController | |||
$productOrder->quantity = $quantity; | |||
$productOrder->price = $dataProductOrder->price; | |||
if($dataProductOrder->invoice_price && $dataProductOrder->invoice_price != $dataProductOrder->price) { | |||
//die('invoice price : '.$dataProductOrder->invoice_price); | |||
if(isset($dataProductOrder->invoice_price) | |||
&& $dataProductOrder->invoice_price | |||
&& $dataProductOrder->invoice_price != $dataProductOrder->price) { | |||
$productOrder->invoice_price = $dataProductOrder->invoice_price; | |||
} | |||
} else { |
@@ -38,12 +38,6 @@ | |||
namespace backend\controllers; | |||
use common\helpers\Alwaysdata; | |||
use common\helpers\GlobalParam; | |||
use common\logic\Distribution\Distribution\Model\Distribution; | |||
use common\logic\Order\Order\Model\Order; | |||
use common\logic\PointSale\PointSale\Model\PointSale; | |||
use common\logic\Product\Product\Model\Product; | |||
use common\logic\User\User\Model\User; | |||
use Yii; | |||
use yii\filters\AccessControl; | |||
@@ -69,7 +63,7 @@ class SiteController extends BackendController | |||
'allow' => true, | |||
], | |||
[ | |||
'actions' => ['logout', 'index'], | |||
'actions' => ['logout'], | |||
'allow' => true, | |||
'roles' => ['@'], | |||
'matchCallback' => function ($rule, $action) { | |||
@@ -77,7 +71,7 @@ class SiteController extends BackendController | |||
} | |||
], | |||
[ | |||
'actions' => ['change-producer'], | |||
'actions' => ['switch-producer'], | |||
'allow' => true, | |||
'roles' => ['@'], | |||
'matchCallback' => function ($rule, $action) { | |||
@@ -106,96 +100,6 @@ class SiteController extends BackendController | |||
]; | |||
} | |||
/** | |||
* Affiche le tableau de bord du backend avec les dernières commandes | |||
* réalisées, les dernières inscriptions, la liste des clients ayant un crédit | |||
* négatif etc. | |||
* | |||
* @return mixed | |||
*/ | |||
public function actionIndex() | |||
{ | |||
$userManager = $this->getUserManager(); | |||
$producerManager = $this->getProducerManager(); | |||
$optionDashboardNumberDistributions = $producerManager->getConfig('option_dashboard_number_distributions'); | |||
$dashboardNumberDistributions = $optionDashboardNumberDistributions ? $optionDashboardNumberDistributions : 3; | |||
$optionDashboardDateStart = $producerManager->getConfig('option_dashboard_date_start'); | |||
$optionDashboardDateEnd = $producerManager->getConfig('option_dashboard_date_end'); | |||
$queryDistributions = Distribution::find()->with('order'); | |||
if ($optionDashboardDateStart || $optionDashboardDateEnd) { | |||
if ($optionDashboardDateStart) { | |||
$queryDistributions->andWhere(['>=', 'distribution.date', $optionDashboardDateStart]); | |||
} | |||
if ($optionDashboardDateEnd) { | |||
$queryDistributions->andWhere(['<=', 'distribution.date', $optionDashboardDateEnd]); | |||
} | |||
} else { | |||
$queryDistributions->andWhere(['>=', 'distribution.date', date('Y-m-d')]); | |||
} | |||
$distributionsArray = $queryDistributions->andWhere([ | |||
'distribution.id_producer' => GlobalParam::getCurrentProducerId(), | |||
'distribution.active' => 1 | |||
]) | |||
->orderBy('date ASC') | |||
->limit($dashboardNumberDistributions) | |||
->all(); | |||
// dernières commandes | |||
$paramsOrders = []; | |||
if ($optionDashboardDateStart || $optionDashboardDateEnd) { | |||
$conditionsOrders = ''; | |||
if ($optionDashboardDateStart) { | |||
$conditionsOrders .= 'distribution.date >= :date_start'; | |||
$paramsOrders[':date_start'] = $optionDashboardDateStart; | |||
} | |||
if ($optionDashboardDateEnd) { | |||
if ($optionDashboardDateStart) { | |||
$conditionsOrders .= ' AND '; | |||
} | |||
$conditionsOrders .= 'distribution.date <= :date_end'; | |||
$paramsOrders[':date_end'] = $optionDashboardDateEnd; | |||
} | |||
} else { | |||
$conditionsOrders = 'distribution.date >= :date_start'; | |||
$paramsOrders[':date_start'] = date('Y-m-d 00:00:00'); | |||
} | |||
$ordersArray = Order::searchAll([], [ | |||
'orderby' => 'date DESC', | |||
'conditions' => $conditionsOrders . ' AND (origin = \'' . Order::ORIGIN_USER . '\' OR origin = \'' . Order::ORIGIN_ADMIN . '\' OR (origin = \'' . Order::ORIGIN_AUTO . '\' AND (date_update IS NOT NULL OR date_delete IS NOT NULL)))', | |||
'params' => $paramsOrders, | |||
]); | |||
// clients | |||
$usersArray = $userManager->queryUsersBy() | |||
->orderBy('created_at DESC') | |||
->limit(5) | |||
->all(); | |||
$usersNegativeCredit = $userManager->queryUsersBy(['id_producer' => GlobalParam::getCurrentProducerId()]) | |||
->andWhere('user_producer.credit < 0') | |||
->all(); | |||
$producerCurrent = GlobalParam::getCurrentProducer(); | |||
$productsCount = Product::searchCount(); | |||
$pointsSaleCount = PointSale::searchCount(); | |||
return $this->render('index', [ | |||
'distributionsArray' => $distributionsArray, | |||
'ordersArray' => $ordersArray, | |||
'usersArray' => $usersArray, | |||
'usersNegativeCredit' => $usersNegativeCredit, | |||
'producer' => $producerCurrent, | |||
'productsCount' => $productsCount, | |||
'pointsSaleCount' => $pointsSaleCount | |||
]); | |||
} | |||
/** | |||
* Affiche la page de connexion. | |||
*/ | |||
@@ -229,10 +133,18 @@ class SiteController extends BackendController | |||
* Change le producteur courant de l'utilisateur connecté. | |||
* Permet de passer d'un producteur à un autre en tant qu'administrateur. | |||
*/ | |||
public function actionChangeProducer(int $id) | |||
public function actionSwitchProducer(int $id) | |||
{ | |||
Yii::$app->user->identity->id_producer = $id; | |||
Yii::$app->user->identity->save(); | |||
$this->redirect(['site/index']); | |||
$user = $this->getUserCurrent(); | |||
$producer = $this->getProducerContainer()->getRepository()->findOneProducerById($id); | |||
if($producer) { | |||
$this->getUserContainer()->getBuilder()->switchProducer($user, $producer); | |||
} | |||
else { | |||
$this->addFlash('error', 'Producteur introuvable.'); | |||
} | |||
$this->redirect(['dashboard/index']); | |||
} | |||
} |
@@ -391,38 +391,38 @@ class UserController extends BackendController | |||
public function actionCredit(int $id) | |||
{ | |||
$userManager = $this->getUserManager(); | |||
$user = $userManager->findOneUserById($id); | |||
$userProducer = UserProducer::findOne(['id_user' => $id, 'id_producer' => $this->getProducerCurrent()->id]); | |||
$paymentContainer = $this->getPaymentContainer(); | |||
$userProducerContainer = $this->getUserProducerContainer(); | |||
if (($userProducer) || $this->isUserCurrentAdmin()) { | |||
$user = $userManager->findOneUserById($id); | |||
$userProducer = $userProducerContainer->getRepository()->findOneUserProducer($user); | |||
if ($userProducer) { | |||
$creditForm = new CreditForm(); | |||
if ($creditForm->load(\Yii::$app->request->post()) && $creditForm->validate()) { | |||
$creditForm->id_user = $id; | |||
$creditForm->save(); | |||
$creditForm = new CreditForm; | |||
$user = $userManager->findOneUserById($id); | |||
} | |||
$paymentContainer->getUtils() | |||
->creditOrDebitUser($creditForm->type, $user, $creditForm->amount, $creditForm->mean_payment, $user); | |||
$history = Payment::find() | |||
->with(['order', 'userAction']) | |||
->where([ | |||
'id_user' => $user->id, | |||
'id_producer' => $this->getProducerCurrent()->id, | |||
]) | |||
->andWhere("payment.type = 'initial-credit' OR payment.type = 'credit' OR payment.type = 'debit' OR (payment.type = 'payment' AND payment.mean_payment = 'credit') OR (payment.type = 'refund' AND payment.mean_payment = 'credit')") | |||
->orderBy('date DESC') | |||
->all(); | |||
if($creditForm->send_mail) { | |||
$paymentContainer->getNotifier() | |||
->notifyUserCreditMovement($user, $creditForm->type, $creditForm->amount); | |||
} | |||
$this->setFlash('success', 'Crédit mis à jour.'); | |||
return $this->refresh(); | |||
} | |||
return $this->render('credit', [ | |||
'user' => $user, | |||
'userProducer' => $userProducer, | |||
'creditForm' => $creditForm, | |||
'history' => $history | |||
'dataProvider' => $paymentContainer->getRepository() | |||
->queryPaymentsCreditHistoryByUser($user)->getDataProvider(20), | |||
]); | |||
} else { | |||
throw new UserException("Vous ne pouvez pas créditer un utilisateur qui n'est pas associé à votre établissement."); | |||
throw new UserException("Utilisateur introuvable."); | |||
} | |||
} | |||
@@ -45,7 +45,7 @@ $orderManager = OrderManager::getInstance(); | |||
$this->setTitle('Tableau de bord'); | |||
?> | |||
<div class="site-index"> | |||
<div class="dashboard-index"> | |||
<?php if(Yii::$app->request->get('error_products_points_sale')): ?> | |||
<div class="alert alert-warning"> |
@@ -251,7 +251,8 @@ $this->setPageTitle('Distributions') ; | |||
:producer="producer" | |||
:orders="ordersUpdate" | |||
:loading-update-product-order="loadingUpdateProductOrder" | |||
@close="showModalFormOrderCreate = false" | |||
:units="units" | |||
@close="closeModalOrderForm(true)" | |||
@ordercreatedupdated="orderCreatedUpdated" | |||
@updateproductorderprices="updateProductOrderPrices" | |||
></order-form> | |||
@@ -278,8 +279,8 @@ $this->setPageTitle('Distributions') ; | |||
<span class="caret"></span> | |||
</button> | |||
<ul class="dropdown-menu" aria-labelledby="dropdownMenu1"> | |||
<li><a v-if="idActivePointSale > 0" @click="generateDeliveryNotePointSale" href="javascript:void(0);" >Générer un bon de livraison pour ce point de vente</a></li> | |||
<li><a @click="generateDeliveryNoteEachUser" href="javascript:void(0);">Générer un bon de livraison pour chaque client</a></li> | |||
<li><a v-if="idActivePointSale > 0 && pointSaleActive.button_generate_delivery_note_point_sale == 1" @click="generateDeliveryNotePointSale" href="javascript:void(0);" >Générer un bon de livraison pour ce point de vente</a></li> | |||
<li><a v-if="idActivePointSale > 0 && pointSaleActive.button_generate_delivery_note_each_user == 1" @click="generateDeliveryNoteEachUser" href="javascript:void(0);">Générer un bon de livraison pour chaque client</a></li> | |||
<li><a @click="validateDeliveryNotes" href="javascript:void(0);">Valider les bons de livraisons</a></li> | |||
</ul> | |||
</div> | |||
@@ -367,7 +368,7 @@ $this->setPageTitle('Distributions') ; | |||
{{ order.user.lastname+' '+order.user.name }} | |||
</template> | |||
<span class="shortcuts btn-group" role="group"> | |||
<a class="btn btn-default btn-sm" :href="baseUrl+'/user/credit?id='+order.id_user" data-toggle="popover" data-trigger="hover" data-placement="bottom" :data-content="order.user.credit.toFixed(2)+' €'"><span class="glyphicon glyphicon-euro"></span></a> | |||
<a :class="order.user.credit_active ? 'btn btn-success btn-sm' : 'btn btn-default btn-sm'" :href="baseUrl+'/user/credit?id='+order.id_user" data-toggle="popover" data-trigger="hover" data-placement="bottom" :data-content="order.user.credit.toFixed(2)+' €'"><span class="glyphicon glyphicon-euro"></span></a> | |||
<a class="btn btn-default btn-sm" :href="baseUrl+'/user/update?id='+order.id_user" data-toggle="popover" data-trigger="hover" data-placement="bottom" data-content="Modifier"><span class="glyphicon glyphicon-user"></span></a> | |||
<a class="btn btn-default btn-sm" :href="baseUrl+'/user/orders?id='+order.id_user" data-toggle="popover" data-trigger="hover" data-placement="bottom" data-content="Voir les commandes"><span class="glyphicon glyphicon-eye-open"></span></a> | |||
</span> | |||
@@ -528,7 +529,8 @@ $this->setPageTitle('Distributions') ; | |||
:orders="ordersUpdate" | |||
:producer="producer" | |||
:loading-update-product-order="loadingUpdateProductOrder" | |||
@close="showModalFormOrderUpdate = false" | |||
:units="units" | |||
@close="closeModalOrderForm(false)" | |||
@ordercreatedupdated="orderCreatedUpdated" | |||
@updateproductorderprices="updateProductOrderPrices" | |||
@updateinvoiceprices="updateInvoicePrices" | |||
@@ -572,10 +574,8 @@ $this->setPageTitle('Distributions') ; | |||
<table class="table table-condensed table-bordered table-hover" v-if="order.paymentsArray && order.paymentsArray.length > 0"> | |||
<thead> | |||
<tr> | |||
<!--<td>Utilisateur</td> | |||
<td>Action</td> | |||
<td>Origine action</td>--> | |||
<td>Date</td> | |||
<td>Origine action</td> | |||
<td>Type</td> | |||
<td>Moyen</td> | |||
<td>Montant</td> | |||
@@ -583,10 +583,8 @@ $this->setPageTitle('Distributions') ; | |||
</thead> | |||
<tbody> | |||
<tr v-for="payment in order.paymentsArray"> | |||
<!--<td>{{ payment.user }}</td> | |||
<td v-html="payment.wording"></td> | |||
<td>{{ payment.user_action }}</td>--> | |||
<td>{{ payment.date }}</td> | |||
<td>{{ payment.user_action }}</td> | |||
<td>{{ payment.wording_type }}</td> | |||
<td>{{ payment.wording_mean_payment }}</td> | |||
<td v-html="payment.amount"></td> |
@@ -240,65 +240,13 @@ $documentClass = $documentManager->getClass($model); | |||
</div> | |||
<div class="clr"></div> | |||
<?php if ($action == 'update' && $documentClass == 'DeliveryNote'): ?> | |||
<?= $this->render('form/_orders'); ?> | |||
<?php endif; ?> | |||
<?php if ($action == 'update' && $documentClass == 'Invoice'): ?> | |||
<?php if($documentManager->isStatusValid($model)): ?> | |||
<div> | |||
<div class="panel panel-default"> | |||
<div class="panel-heading"> | |||
Règlement | |||
</div> | |||
<div class="panel-body"> | |||
<?php if($model->payments && count($model->payments) > 0): ?> | |||
<table class="table table-bordered"> | |||
<thead> | |||
<tr> | |||
<th>Moyen de paiement</th> | |||
<th>Date transaction</th> | |||
<th>Montant</th> | |||
</tr> | |||
</thead> | |||
<tbody> | |||
<?php foreach($model->payments as $payment): ?> | |||
<tr> | |||
<td><?= $paymentManager->getStrMeanPayment($payment); ?></td> | |||
<td><?= $payment->date_transaction ? date('d/m/Y', strtotime($payment->date_transaction)) : '' ?></td> | |||
<td><?= Price::format($payment->amount); ?></td> | |||
</tr> | |||
<?php endforeach; ?> | |||
</tbody> | |||
</table> | |||
<?php endif; ?> | |||
<?php if($invoiceManager->isDocumentInvoice($model) && !$invoiceManager->isInvoicePaid($model)): ?> | |||
<div class="row"> | |||
<?php $form = ActiveForm::begin(); ?> | |||
<div class="col-md-3"> | |||
<?= $form->field($payment, 'mean_payment')->dropDownList(MeanPayment::getAll()); ?> | |||
</div> | |||
<div class="col-md-3"> | |||
<?= $form->field($payment, 'date_transaction')->textInput([ | |||
'class' => 'datepicker form-control' | |||
]); ?> | |||
</div> | |||
<div class="col-md-3"> | |||
<?= $form->field($payment, 'amount', [ | |||
'template' => '{label}<div class="input-group">{input}<span class="input-group-addon"><span class="glyphicon glyphicon-euro"></span></span></div>{hint}', | |||
])->textInput(); ?> | |||
</div> | |||
<div class="col-md-3"> | |||
<div class="form-group"> | |||
<br> | |||
<?= Html::submitButton('Ajouter', ['class' => 'btn btn-primary']) ?> | |||
</div> | |||
</div> | |||
<?php ActiveForm::end(); ?> | |||
</div> | |||
<?php endif; ?> | |||
</div> | |||
</div> | |||
</div> | |||
<?php endif; ?> | |||
<?= $this->render('form/_payment', ['model' => $model]); ?> | |||
<div v-if="(deliveryNoteUpdateArray && deliveryNoteUpdateArray.length > 0) || (deliveryNoteCreateArray && deliveryNoteCreateArray.length > 0)"> | |||
<div class="panel panel-default"> | |||
@@ -348,51 +296,7 @@ $documentClass = $documentManager->getClass($model); | |||
</div> | |||
</div> | |||
<div v-else> | |||
<div class="panel panel-default"> | |||
<div class="panel-heading"> | |||
Commandes | |||
</div> | |||
<div class="panel-body"> | |||
<table v-if="ordersUpdateArray && ordersUpdateArray.length > 0" class="table table-bordered"> | |||
<thead> | |||
<tr> | |||
<th>Date</th> | |||
<th v-if="taxRateProducer != 0">Montant (TTC)</th> | |||
<th v-else>Montant</th> | |||
<th v-if="document.status == 'draft'"></th> | |||
</tr> | |||
</thead> | |||
<tbody> | |||
<tr v-for="order in ordersUpdateArray"> | |||
<td>{{ order.name }}</td> | |||
<td>{{ formatPrice(order.amount_with_tax) }}</td> | |||
<td v-if="document.status == 'draft'"> | |||
<a class="btn btn-default" href="javascript:void(0);" @click="deleteOrderFromInvoice" | |||
:data-id="order.id"> | |||
<span class="glyphicon glyphicon-trash"></span> | |||
</a> | |||
</td> | |||
</tr> | |||
</tbody> | |||
</table> | |||
<div v-else class="alert alert-warning">Aucune commande associée.</div> | |||
<div v-if="document.status == 'draft'" id="order-add"> | |||
<div class="col-md-8"> | |||
<select class="form-control" v-model="orderAddId"> | |||
<option value="0" selected="selected">--</option> | |||
<option v-for="order in ordersCreateArray" :value="order.id"> | |||
{{ order.name }} | |||
</option> | |||
</select> | |||
</div> | |||
<div class="col-md-4"> | |||
<button class="btn btn-primary" value="Ajouter" @click="submitOrderAddToInvoice">Ajouter</button> | |||
<button class="btn btn-danger" value="Ignorer" @click="submitOrderIgnoreWhenInvoicing">Ignorer</button> | |||
</div> | |||
</div> | |||
</div> | |||
</div> | |||
<?= $this->render('form/_orders'); ?> | |||
</div> | |||
<div class="clr"></div> | |||
<?php endif; ?> |
@@ -0,0 +1,45 @@ | |||
<div class="panel panel-default"> | |||
<div class="panel-heading"> | |||
Commandes | |||
</div> | |||
<div class="panel-body"> | |||
<table v-if="ordersUpdateArray && ordersUpdateArray.length > 0" class="table table-bordered"> | |||
<thead> | |||
<tr> | |||
<th>Date</th> | |||
<th v-if="taxRateProducer != 0">Montant (TTC)</th> | |||
<th v-else>Montant</th> | |||
<th v-if="document.status == 'draft'"></th> | |||
</tr> | |||
</thead> | |||
<tbody> | |||
<tr v-for="order in ordersUpdateArray"> | |||
<td>{{ order.name }}</td> | |||
<td>{{ formatPrice(order.amount_with_tax) }}</td> | |||
<td v-if="document.status == 'draft'"> | |||
<a class="btn btn-default" href="javascript:void(0);" @click="deleteOrderFromDocument" | |||
:data-id="order.id"> | |||
<span class="glyphicon glyphicon-trash"></span> | |||
</a> | |||
</td> | |||
</tr> | |||
</tbody> | |||
</table> | |||
<div v-else class="alert alert-warning">Aucune commande associée.</div> | |||
<div v-if="document.status == 'draft'" id="order-add"> | |||
<div class="col-md-8"> | |||
<select class="form-control" v-model="orderAddId"> | |||
<option value="0" selected="selected">--</option> | |||
<option v-for="order in ordersCreateArray" :value="order.id"> | |||
{{ order.name }} | |||
</option> | |||
</select> | |||
</div> | |||
<div class="col-md-4"> | |||
<button class="btn btn-primary" value="Ajouter" @click="submitOrderAddToDocument">Ajouter</button> | |||
<button class="btn btn-danger" value="Ignorer" @click="submitOrderIgnoreWhenInvoicing">Ignorer</button> | |||
</div> | |||
</div> | |||
</div> | |||
</div> |
@@ -0,0 +1,71 @@ | |||
<?php | |||
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 yii\helpers\Html; | |||
use yii\widgets\ActiveForm; | |||
$documentManager = DocumentManager::getInstance(); | |||
$paymentManager = PaymentManager::getInstance(); | |||
$invoiceManager = InvoiceManager::getInstance(); | |||
if($documentManager->isStatusValid($model)): ?> | |||
<div> | |||
<div class="panel panel-default"> | |||
<div class="panel-heading"> | |||
Règlement | |||
</div> | |||
<div class="panel-body"> | |||
<?php if($model->payments && count($model->payments) > 0): ?> | |||
<table class="table table-bordered"> | |||
<thead> | |||
<tr> | |||
<th>Moyen de paiement</th> | |||
<th>Date transaction</th> | |||
<th>Montant</th> | |||
</tr> | |||
</thead> | |||
<tbody> | |||
<?php foreach($model->payments as $payment): ?> | |||
<tr> | |||
<td><?= $paymentManager->getStrMeanPayment($payment); ?></td> | |||
<td><?= $payment->date_transaction ? date('d/m/Y', strtotime($payment->date_transaction)) : '' ?></td> | |||
<td><?= Price::format($payment->amount); ?></td> | |||
</tr> | |||
<?php endforeach; ?> | |||
</tbody> | |||
</table> | |||
<?php endif; ?> | |||
<?php if($invoiceManager->isDocumentInvoice($model) && !$invoiceManager->isInvoicePaid($model)): ?> | |||
<div class="row"> | |||
<?php $form = ActiveForm::begin(); ?> | |||
<div class="col-md-3"> | |||
<?= $form->field($payment, 'mean_payment')->dropDownList(MeanPayment::getAll()); ?> | |||
</div> | |||
<div class="col-md-3"> | |||
<?= $form->field($payment, 'date_transaction')->textInput([ | |||
'class' => 'datepicker form-control' | |||
]); ?> | |||
</div> | |||
<div class="col-md-3"> | |||
<?= $form->field($payment, 'amount', [ | |||
'template' => '{label}<div class="input-group">{input}<span class="input-group-addon"><span class="glyphicon glyphicon-euro"></span></span></div>{hint}', | |||
])->textInput(); ?> | |||
</div> | |||
<div class="col-md-3"> | |||
<div class="form-group"> | |||
<br> | |||
<?= Html::submitButton('Ajouter', ['class' => 'btn btn-primary']) ?> | |||
</div> | |||
</div> | |||
<?php ActiveForm::end(); ?> | |||
</div> | |||
<?php endif; ?> | |||
</div> | |||
</div> | |||
</div> | |||
<?php endif; ?> |
@@ -109,7 +109,7 @@ $producer = GlobalParam::getCurrentProducer(); | |||
<?php foreach ($producersArray as $producer): ?> | |||
<?php if ($producer->active == 1): ?> | |||
<li class="producer"> | |||
<a href="<?= Yii::$app->urlManagerBackend->createUrl(['site/change-producer', 'id' => $producer->id]); ?>"><?= Html::encode($producer->name) ?></a> | |||
<a href="<?= Yii::$app->urlManagerBackend->createUrl(['site/switch-producer', 'id' => $producer->id]); ?>"><?= Html::encode($producer->name) ?></a> | |||
</li> | |||
<?php endif; ?> | |||
<?php endforeach; ?> | |||
@@ -118,7 +118,7 @@ $producer = GlobalParam::getCurrentProducer(); | |||
<?php foreach ($producersArray as $producer): ?> | |||
<?php if ($producer->active != 1): ?> | |||
<li class="producer"> | |||
<a href="<?= Yii::$app->urlManagerBackend->createUrl(['site/change-producer', 'id' => $producer->id]); ?>"> | |||
<a href="<?= Yii::$app->urlManagerBackend->createUrl(['site/switch-producer', 'id' => $producer->id]); ?>"> | |||
<label class="label label-danger">Hors-ligne</label> | |||
<?= Html::encode($producer->name) ?> | |||
</a> |
@@ -90,7 +90,7 @@ $producer = GlobalParam::getCurrentProducer(); | |||
'template' => '<a href="{url}">{icon} {label}' . $countTicketsProducerUnreadLabel . '</a>' | |||
], | |||
['label' => $producer->name, 'options' => ['class' => 'header'], 'visible' => $userManager->isCurrentProducer()], | |||
['label' => 'Tableau de bord', 'icon' => 'dashboard', 'url' => ['/site/index'], 'visible' => $userManager->isCurrentProducer()], | |||
['label' => 'Tableau de bord', 'icon' => 'dashboard', 'url' => ['/dashboard/index'], 'visible' => $userManager->isCurrentProducer()], | |||
['label' => 'Distributions', 'icon' => 'calendar', 'url' => ['/distribution/index'], 'visible' => $userManager->isCurrentProducer()], | |||
[ | |||
'label' => 'Produits', |
@@ -52,16 +52,14 @@ $userManager = $this->getUserManager(); | |||
<?php $form = ActiveForm::begin(); ?> | |||
<div class="col-md-8"> | |||
<?= $form->field($model, 'name')->textInput(['maxlength' => 255]) ?> | |||
<?= $form->field($model, 'locality')->textInput(['maxlength' => 255]) ?> | |||
<?= $form->field($model, 'address')->textarea(['rows' => 6]) ?> | |||
<?= $form->field($model, 'id_user', [ | |||
'template' => '{label} <a href="' . Yii::$app->urlManager->createUrl(['user/create']) . '" class="btn btn-xs btn-default">Nouvel utilisateur <span class="glyphicon glyphicon-plus"></span></a><div>{input}</div>{hint}', | |||
'template' => '{label} <a href="' . Yii::$app->urlManager->createUrl(['user/create']) . '" class="btn btn-xs btn-default">Nouvel utilisateur <span class="glyphicon glyphicon-plus"></span></a><div>{input}</div>{hint}', | |||
]) | |||
->dropDownList($userManager->populateUserDropdownList(), ['class' => 'select2']) | |||
->hint('Utilisé lors de la facturation'); ?> | |||
->dropDownList($userManager->populateUserDropdownList(), ['class' => 'select2']) | |||
->hint('Utilisé lors de la facturation'); ?> | |||
<?php | |||
$addHintCredit = ''; | |||
if (!$producerManager->getConfig('credit')): | |||
@@ -113,32 +111,45 @@ $userManager = $this->getUserManager(); | |||
<?= $form->field($model, 'infos_sunday')->textarea(['rows' => 3]) ?> | |||
</div> | |||
<div class="col-md-4"> | |||
<?= $form->field($model, 'code') | |||
<div class="panel panel-default"> | |||
<div class="panel-heading"> | |||
<h3 class="panel-title">Accès</h3> | |||
</div> | |||
<div class="panel-body"> | |||
<?= $form->field($model, 'code') | |||
->label('Code d\'accès') | |||
->hint('Renseignez ce champs si vous souhaitez protéger ce point de vente par un code.') | |||
?> | |||
<?= $form->field($model, 'restricted_access') | |||
?> | |||
<?= $form->field($model, 'restricted_access') | |||
->checkbox() | |||
->hint('Cochez cette case si seulement un groupe restreint d\'utilisateurs peuvent accéder à ce point de vente.<br />' | |||
. 'Dans le cas des boîtes à pain, il vous est possible de spécifier un commentaire pour chaque utilisateur sélectionné afin de lui renseigner son numéro de boîte ou son code.') ?> | |||
<div id="users"> | |||
. 'Dans le cas des boîtes à pain, il vous est possible de spécifier un commentaire pour chaque utilisateur sélectionné afin de lui renseigner son numéro de boîte ou son code.') ?> | |||
<div id="users"> | |||
<?= Html::activeCheckboxList($model, 'users', ArrayHelper::map($users, 'user_id', function ($model_user, $defaultValue) use ($model) { | |||
$userManager = UserManager::getInstance(); | |||
return Html::encode($userManager->getUsernameFromArray($model_user)) . '<br />' | |||
. Html::activeTextInput( | |||
$model, | |||
'users_comment[' . $model_user['user_id'] . ']', | |||
[ | |||
'class' => 'form-control commentaire', | |||
'placeholder' => 'Commentaire', | |||
'value' => (isset($model->users_comment[$model_user['user_id']])) ? Html::encode($model->users_comment[$model_user['user_id']]) : '' | |||
]); | |||
$userManager = UserManager::getInstance(); | |||
return Html::encode($userManager->getUsernameFromArray($model_user)) . '<br />' | |||
. Html::activeTextInput( | |||
$model, | |||
'users_comment[' . $model_user['user_id'] . ']', | |||
[ | |||
'class' => 'form-control commentaire', | |||
'placeholder' => 'Commentaire', | |||
'value' => (isset($model->users_comment[$model_user['user_id']])) ? Html::encode($model->users_comment[$model_user['user_id']]) : '' | |||
]); | |||
}), ['encode' => false, 'class' => '']) ?> | |||
</div> | |||
</div> | |||
</div> | |||
<div class="panel panel-default"> | |||
<div class="panel-heading"> | |||
<h3 class="panel-title">Génération des bons de livraison</h3> | |||
</div> | |||
<div class="panel-body"> | |||
<?= $form->field($model, 'button_generate_delivery_note_point_sale')->checkbox() ?> | |||
<?= $form->field($model, 'button_generate_delivery_note_each_user')->checkbox() ?> | |||
</div> | |||
</div> | |||
</div> | |||
<div class="clr"></div> | |||
@@ -36,6 +36,7 @@ pris connaissance de la licence CeCILL, et que vous en avez accepté les | |||
termes. | |||
*/ | |||
use yii\grid\GridView; | |||
use yii\helpers\Html; | |||
use yii\widgets\ActiveForm; | |||
use common\helpers\GlobalParam; | |||
@@ -113,51 +114,57 @@ $this->addBreadcrumb('Créditer') ; | |||
<div class="col-md-8"> | |||
<h2>Historique <span class="the-credit"><?= number_format($userManager->getCredit($user), 2); ?> €</span></h2> | |||
<table class="table table-bordered"> | |||
<thead> | |||
<tr> | |||
<th>Date</th> | |||
<th>Utilisateur</th> | |||
<th>Type</th> | |||
<th>- Débit</th> | |||
<th>+ Crédit</th> | |||
<th>Paiement</th> | |||
<th>Commentaire</th> | |||
</tr> | |||
</thead> | |||
<tbody> | |||
<?php if(count($history)): ?> | |||
<?php foreach($history as $creditHistory): ?> | |||
<tr> | |||
<td><?= $paymentManager->getDate($creditHistory, true) ; ?></td> | |||
<td><?= Html::encode($paymentManager->getStrUserAction($creditHistory)); ?></td> | |||
<td><?= $paymentManager->getStrWording($creditHistory); ?></td> | |||
<td> | |||
<?php if($paymentManager->isTypeDebit($creditHistory)): ?> | |||
- <?= $paymentManager->getAmount($creditHistory, true); ?> | |||
<?php endif; ?> | |||
</td> | |||
<td> | |||
<?php if($paymentManager->isTypeCredit($creditHistory)): ?> | |||
+ <?= $paymentManager->getAmount($creditHistory, true); ?> | |||
<?php endif; ?> | |||
</td> | |||
<td> | |||
<?= $paymentManager->getStrMeanPayment($creditHistory) ?> | |||
</td> | |||
<td> | |||
<?php if(strlen($creditHistory->getComment())): ?> | |||
<?= nl2br($creditHistory->getComment()); ?> | |||
<?php endif; ?> | |||
</td> | |||
</tr> | |||
<?php endforeach; ?> | |||
<?php else: ?> | |||
<tr><td colspan="4">Aucun résultat</td></tr> | |||
<?php endif; ?> | |||
</tbody> | |||
</table> | |||
<?= GridView::widget([ | |||
'dataProvider' => $dataProvider, | |||
'columns' => [ | |||
[ | |||
'attribute' => 'date', | |||
'value' => function ($model) use ($paymentManager) { | |||
return $paymentManager->getDate($model, true); | |||
} | |||
], | |||
[ | |||
'attribute' => 'id_user_action', | |||
'value' => function ($model) use ($paymentManager) { | |||
return $paymentManager->getStrUserAction($model); | |||
} | |||
], | |||
[ | |||
'label' => 'Type', | |||
'format' => 'raw', | |||
'value' => function ($model) use ($paymentManager) { | |||
return $paymentManager->getStrWording($model); | |||
} | |||
], | |||
[ | |||
'attribute' => 'mean_payment', | |||
'value' => function ($model) use ($paymentManager) { | |||
return $paymentManager->getStrMeanPayment($model); | |||
} | |||
], | |||
[ | |||
'label' => '- Débit', | |||
'format' => 'raw', | |||
'value' => function ($model) use ($paymentManager) { | |||
if ($paymentManager->isTypeDebit($model)) { | |||
return '- ' . $paymentManager->getAmount($model, true); | |||
} | |||
return ''; | |||
} | |||
], | |||
[ | |||
'label' => '+ Crédit', | |||
'format' => 'raw', | |||
'value' => function ($model) use ($paymentManager) { | |||
if ($paymentManager->isTypeCredit($model)) { | |||
return '+ ' . $paymentManager->getAmount($model, true); | |||
} | |||
return ''; | |||
} | |||
], | |||
], | |||
]); ?> | |||
</div> | |||
</div> |
@@ -1894,29 +1894,29 @@ body.login-page .login-box .login-box-body a:hover { | |||
opacity: 0; | |||
} | |||
/* line 4, ../sass/site/_index.scss */ | |||
.site-index #distributions .info-box { | |||
/* line 4, ../sass/dashboard/_index.scss */ | |||
.dashboard-index #distributions .info-box { | |||
border: solid 1px #e0e0e0; | |||
} | |||
/* line 6, ../sass/site/_index.scss */ | |||
.site-index #distributions .info-box .date { | |||
/* line 6, ../sass/dashboard/_index.scss */ | |||
.dashboard-index #distributions .info-box .date { | |||
text-transform: uppercase; | |||
font-size: 12px; | |||
line-height: 20px; | |||
padding-top: 10px; | |||
} | |||
/* line 12, ../sass/site/_index.scss */ | |||
.site-index #distributions .info-box .date span { | |||
/* line 12, ../sass/dashboard/_index.scss */ | |||
.dashboard-index #distributions .info-box .date span { | |||
display: block; | |||
} | |||
/* line 18, ../sass/site/_index.scss */ | |||
.site-index #distributions .info-box .date .num { | |||
/* line 18, ../sass/dashboard/_index.scss */ | |||
.dashboard-index #distributions .info-box .date .num { | |||
font-size: 30px; | |||
padding-top: 5px; | |||
padding-bottom: 5px; | |||
} | |||
/* line 30, ../sass/site/_index.scss */ | |||
.site-index #distributions .info-box-content .buttons { | |||
/* line 30, ../sass/dashboard/_index.scss */ | |||
.dashboard-index #distributions .info-box-content .buttons { | |||
margin-top: 10px; | |||
} | |||
@@ -80,6 +80,7 @@ var app = new Vue({ | |||
messageGenerateDeliveryNoteDisplayed: false, | |||
missingSubscriptions: false, | |||
loadingUpdateProductOrder: false, | |||
units: [], | |||
calendar: { | |||
mode: 'single', | |||
attrs: [], | |||
@@ -156,6 +157,7 @@ var app = new Vue({ | |||
axios.get("ajax-infos", {params: {date: this.getDate()}}) | |||
.then(function (response) { | |||
app.calendar.attrs = []; | |||
app.units = response.data.units; | |||
app.distribution = response.data.distribution; | |||
app.producer = response.data.producer; | |||
app.products = response.data.products; | |||
@@ -565,6 +567,16 @@ var app = new Vue({ | |||
this.showModalProducts = false; | |||
this.init(this.idActivePointSale); | |||
}, | |||
closeModalOrderForm: function(create) { | |||
if(create) { | |||
this.showModalFormOrderCreate = false | |||
} | |||
else { | |||
this.showModalFormOrderUpdate = false | |||
} | |||
this.init(this.idActivePointSale); | |||
}, | |||
cloneOrder: function (order) { | |||
var clone = Object.assign({}, order); | |||
@@ -788,7 +800,6 @@ var app = new Vue({ | |||
if (app.showModalFormOrderCreate) { | |||
Vue.set(app.orderCreate.productOrder[idProduct], 'prices', response.data[idProduct].prices); | |||
Vue.set(app.orderCreate.productOrder[idProduct], 'active', response.data[idProduct].active); | |||
Vue.set(app.orderCreate.productOrder[idProduct], 'unit_coefficient', response.data[idProduct].unit_coefficient); | |||
Vue.set(app.orderCreate.productOrder[idProduct], 'price', app.getBestProductPrice(app.orderCreate, idProduct, app.orderCreate.productOrder[idProduct].quantity, false)); | |||
Vue.set(app.orderCreate.productOrder[idProduct], 'price_with_tax', app.getBestProductPrice(app.orderCreate, idProduct, app.orderCreate.productOrder[idProduct].quantity, true)); | |||
} | |||
@@ -798,7 +809,6 @@ var app = new Vue({ | |||
if (order.id == app.idOrderUpdate) { | |||
Vue.set(app.ordersUpdate[keyOrderUpdate].productOrder[idProduct], 'prices', response.data[idProduct].prices); | |||
Vue.set(app.ordersUpdate[keyOrderUpdate].productOrder[idProduct], 'active', response.data[idProduct].active); | |||
Vue.set(app.ordersUpdate[keyOrderUpdate].productOrder[idProduct], 'unit_coefficient', response.data[idProduct].unit_coefficient); | |||
Vue.set(app.ordersUpdate[keyOrderUpdate].productOrder[idProduct], 'invoice_price', response.data[idProduct].invoice_price); | |||
if (updatePricesOnUpdateOrder) { | |||
@@ -849,9 +859,11 @@ var app = new Vue({ | |||
} | |||
}, | |||
getBestProductPrice: function (order, idProduct, theQuantity, withTax) { | |||
var product = this.getProduct(idProduct); | |||
var thePrice = 9999; | |||
var pricesArray = order.productOrder[idProduct].prices; | |||
var unitCoefficient = order.productOrder[idProduct].unit_coefficient; | |||
var unitCoefficient = this.getUnitCoefficient(product.unit); | |||
if (theQuantity) { | |||
theQuantity = theQuantity / unitCoefficient; | |||
} | |||
@@ -870,7 +882,6 @@ var app = new Vue({ | |||
} | |||
} | |||
} else { | |||
var product = this.getProduct(idProduct); | |||
if (withTax) { | |||
thePrice = getPriceWithTax(product.price, product.taxRate.value); | |||
} else { | |||
@@ -909,6 +920,9 @@ var app = new Vue({ | |||
} | |||
return count; | |||
}, | |||
getUnitCoefficient: function(unit) { | |||
return this.units[unit].coefficient; | |||
} | |||
}, | |||
}); | |||
@@ -923,7 +937,7 @@ Vue.component('modal', { | |||
}); | |||
Vue.component('order-form', { | |||
props: ['date', 'dateFormat', 'pointsSale', 'idActivePointSale', 'meansPayment', 'users', 'products', 'order', 'orders', 'producer', 'loadingUpdateProductOrder', 'create'], | |||
props: ['date', 'dateFormat', 'pointsSale', 'idActivePointSale', 'meansPayment', 'users', 'products', 'order', 'orders', 'producer', 'loadingUpdateProductOrder', 'create', 'units'], | |||
emits: ['updateProductPrice', 'updateInvoicePrices'], | |||
data: function () { | |||
return { | |||
@@ -1132,20 +1146,32 @@ Vue.component('order-form', { | |||
} | |||
}, | |||
getProductQuantityRemaining: function(product) { | |||
var order = null; | |||
var app = this; | |||
var quantityRemaining = 0; | |||
var productQuantityOrder = 0; | |||
var unit = product.unit; | |||
for(key in app.orders) { | |||
order = app.orders[key]; | |||
productQuantityOrder += order.productOrder[product.id].quantity; | |||
for(key in this.orders) { | |||
productQuantityOrder += this.getProductQuantityProductOrder(this.orders[key], product); | |||
} | |||
if(this.create == 1) { | |||
productQuantityOrder += this.getProductQuantityProductOrder(this.order, product); | |||
} | |||
if(app.create == 1) { | |||
productQuantityOrder += app.order.productOrder[product.id].quantity; | |||
quantityRemaining = product.productDistribution[0].quantity_max - productQuantityOrder; | |||
if(unit != 'piece') { | |||
quantityRemaining = quantityRemaining.toFixed(2); | |||
} | |||
return product.productDistribution[0].quantity_max - productQuantityOrder; | |||
return quantityRemaining; | |||
}, | |||
getProductQuantityProductOrder: function(order, product) { | |||
var productOrder = order.productOrder[product.id]; | |||
var unit = productOrder.unit; | |||
var unitCoefficient = this.getUnitCoefficient(unit); | |||
return parseFloat(productOrder.quantity / unitCoefficient); | |||
}, | |||
getUnitCoefficient: function(unit) { | |||
return this.units[unit].coefficient; | |||
} | |||
} | |||
}); |
@@ -182,11 +182,12 @@ var app = new Vue({ | |||
app.init(); | |||
}); | |||
}, | |||
submitOrderAddToInvoice: function() { | |||
submitOrderAddToDocument: function() { | |||
var app = this; | |||
axios.get(UrlManager.getBaseUrlAbsolute() + "invoice/ajax-add-order", { | |||
axios.get(UrlManager.getBaseUrlAbsolute() + "document/ajax-add-order", { | |||
params: { | |||
idInvoice: this.getDocumentId(), | |||
idDocument: this.getDocumentId(), | |||
classDocument: this.getDocumentClass(), | |||
idOrder: app.orderAddId | |||
} | |||
}) | |||
@@ -198,9 +199,10 @@ var app = new Vue({ | |||
}, | |||
submitOrderIgnoreWhenInvoicing: function() { | |||
var app = this; | |||
axios.get(UrlManager.getBaseUrlAbsolute() + "invoice/ajax-ignore-order-when-invoicing", { | |||
axios.get(UrlManager.getBaseUrlAbsolute() + "document/ajax-ignore-order-when-invoicing", { | |||
params: { | |||
idInvoice: this.getDocumentId(), | |||
idDocument: this.getDocumentId(), | |||
classDocument: this.getDocumentClass(), | |||
idOrder: app.orderAddId | |||
} | |||
}) | |||
@@ -210,13 +212,14 @@ var app = new Vue({ | |||
app.init(); | |||
}); | |||
}, | |||
deleteOrderFromInvoice: function() { | |||
deleteOrderFromDocument: function() { | |||
var app = this; | |||
var idOrder = event.currentTarget.getAttribute('data-id'); | |||
axios.get(UrlManager.getBaseUrlAbsolute() + "invoice/ajax-delete-order", { | |||
axios.get(UrlManager.getBaseUrlAbsolute() + "document/ajax-delete-order", { | |||
params: { | |||
idInvoice: app.getDocumentId(), | |||
idDocument: app.getDocumentId(), | |||
classDocument: this.getDocumentClass(), | |||
idOrder: idOrder | |||
} | |||
}) |
@@ -1,5 +1,5 @@ | |||
.site-index { | |||
.dashboard-index { | |||
#distributions { | |||
.info-box { | |||
border: solid 1px #e0e0e0 ; |
@@ -1514,7 +1514,7 @@ a.btn, button.btn { | |||
@import "_adminlte.scss" ; | |||
@import "_alerts.scss" ; | |||
@import "site/_index.scss" ; | |||
@import "dashboard/_index.scss" ; | |||
@import "subscription/_index.scss" ; | |||
@import "subscription/_form.scss" ; | |||
@import "product/_index.scss" ; |
@@ -37,7 +37,7 @@ | |||
*/ | |||
return [ | |||
'version' => '23.9.D', | |||
'version' => '23.9.E', | |||
'siteName' => 'Opendistrib', | |||
'adminEmail' => 'contact@opendistrib.net', | |||
'supportEmail' => 'contact@opendistrib.net', |
@@ -0,0 +1,15 @@ | |||
<?php | |||
namespace common\logic; | |||
use common\components\MailerService; | |||
abstract class AbstractNotifier extends AbstractService implements NotifierInterface | |||
{ | |||
protected MailerService $mailer; | |||
public function loadDependencies(): void | |||
{ | |||
$this->mailer = \Yii::$app->mailerService; | |||
} | |||
} |
@@ -2,6 +2,8 @@ | |||
namespace common\logic; | |||
use yii\data\ActiveDataProvider; | |||
abstract class AbstractRepository extends AbstractService implements RepositoryInterface | |||
{ | |||
const WITH = 'with'; |
@@ -4,6 +4,7 @@ namespace common\logic; | |||
use common\components\ActiveRecordCommon; | |||
use common\logic\Distribution\Distribution\Service\DistributionDefinition; | |||
use yii\data\ActiveDataProvider; | |||
use yii\db\ActiveQuery; | |||
abstract class AbstractRepositoryQuery extends AbstractService implements RepositoryQueryInterface | |||
@@ -74,4 +75,15 @@ abstract class AbstractRepositoryQuery extends AbstractService implements Reposi | |||
return $this; | |||
} | |||
public function getDataProvider(int $pageSize): ActiveDataProvider | |||
{ | |||
return new ActiveDataProvider([ | |||
'query' => $this->query, | |||
'sort' => false, | |||
'pagination' => [ | |||
'pageSize' => $pageSize, | |||
], | |||
]); | |||
} | |||
} |
@@ -16,6 +16,7 @@ abstract class AbstractService extends AbstractSingleton implements ServiceInter | |||
RepositoryQueryInterface::class, | |||
RepositoryInterface::class, | |||
BuilderInterface::class, | |||
NotifierInterface::class, | |||
ResolverInterface::class, | |||
GeneratorInterface::class, | |||
UtilsInterface::class, |
@@ -6,6 +6,8 @@ use common\helpers\GlobalParam; | |||
use common\logic\AbstractRepository; | |||
use common\logic\Distribution\Distribution\Model\Distribution; | |||
use common\logic\Distribution\Distribution\Service\DistributionSolver; | |||
use common\logic\Producer\Producer\Repository\ProducerRepository; | |||
use common\logic\Producer\Producer\Service\ProducerSolver; | |||
use common\logic\RepositoryQueryInterface; | |||
use common\logic\Subscription\Subscription\Model\Subscription; | |||
use common\logic\Subscription\Subscription\Service\SubscriptionSolver; | |||
@@ -15,12 +17,14 @@ class DistributionRepository extends AbstractRepository | |||
protected DistributionRepositoryQuery $query; | |||
protected DistributionSolver $distributionSolver; | |||
protected SubscriptionSolver $subscriptionSolver; | |||
protected ProducerSolver $producerSolver; | |||
public function loadDependencies(): void | |||
{ | |||
$this->loadQuery(DistributionRepositoryQuery::class); | |||
$this->distributionSolver = $this->loadService(DistributionSolver::class); | |||
$this->subscriptionSolver = $this->loadService(SubscriptionSolver::class); | |||
$this->producerSolver = $this->loadService(ProducerSolver::class); | |||
} | |||
public function getDefaultOptionsSearch(): array | |||
@@ -162,4 +166,35 @@ class DistributionRepository extends AbstractRepository | |||
return $oneDistributionWeekActive; | |||
} | |||
public function findDistributionsDashboard(): array | |||
{ | |||
$optionDashboardNumberDistributions = $this->producerSolver->getConfig('option_dashboard_number_distributions'); | |||
$optionDashboardDateStart = $this->producerSolver->getConfig('option_dashboard_date_start'); | |||
$optionDashboardDateEnd = $this->producerSolver->getConfig('option_dashboard_date_end'); | |||
$dashboardNumberDistributions = $optionDashboardNumberDistributions ?: 3; | |||
$queryDistributions = Distribution::find()->with('order'); | |||
if ($optionDashboardDateStart || $optionDashboardDateEnd) { | |||
if ($optionDashboardDateStart) { | |||
$queryDistributions->andWhere(['>=', 'distribution.date', $optionDashboardDateStart]); | |||
} | |||
if ($optionDashboardDateEnd) { | |||
$queryDistributions->andWhere(['<=', 'distribution.date', $optionDashboardDateEnd]); | |||
} | |||
} else { | |||
$queryDistributions->andWhere(['>=', 'distribution.date', date('Y-m-d')]); | |||
} | |||
$distributionsArray = $queryDistributions->andWhere([ | |||
'distribution.id_producer' => $this->getProducerContextId(), | |||
'distribution.active' => 1 | |||
]) | |||
->orderBy('date ASC') | |||
->limit($dashboardNumberDistributions) | |||
->all(); | |||
return $distributionsArray; | |||
} | |||
} |
@@ -10,6 +10,7 @@ use common\logic\Order\Order\Service\OrderBuilder; | |||
use common\logic\Order\Order\Service\OrderSolver; | |||
use common\logic\PointSale\PointSale\Repository\PointSaleRepository; | |||
use common\logic\Producer\Producer\Repository\ProducerRepository; | |||
use common\logic\Producer\Producer\Service\ProducerSolver; | |||
use common\logic\Product\Product\Model\Product; | |||
use common\logic\Product\Product\Repository\ProductRepository; | |||
use common\logic\Product\Product\Service\ProductSolver; | |||
@@ -23,6 +24,7 @@ class DistributionReportCsvGenerator extends AbstractGenerator | |||
protected OrderSolver $orderSolver; | |||
protected PointSaleRepository $pointSaleRepository; | |||
protected OrderBuilder $orderBuilder; | |||
protected ProducerSolver $producerSolver; | |||
public function loadDependencies(): void | |||
{ | |||
@@ -33,6 +35,7 @@ class DistributionReportCsvGenerator extends AbstractGenerator | |||
$this->orderSolver = $this->loadService(OrderSolver::class); | |||
$this->pointSaleRepository = $this->loadService(PointSaleRepository::class); | |||
$this->orderBuilder = $this->loadService(OrderBuilder::class); | |||
$this->producerSolver = $this->loadService(ProducerSolver::class); | |||
} | |||
public function generateDistributionReportCsv(Distribution $distribution) | |||
@@ -40,8 +43,8 @@ class DistributionReportCsvGenerator extends AbstractGenerator | |||
$datas = []; | |||
$ordersArray = $this->orderRepository->findOrdersByDistribution($distribution); | |||
$productsArray = $this->productRepository->findProductsByDistribution($distribution); | |||
$optionCsvExportAllProducts = $this->producerRepository->getConfig('option_csv_export_all_products'); | |||
$optionCsvExportByPiece = $this->producerRepository->getConfig('option_csv_export_by_piece'); | |||
$optionCsvExportAllProducts = $this->producerSolver->getConfig('option_csv_export_all_products'); | |||
$optionCsvExportByPiece = $this->producerSolver->getConfig('option_csv_export_by_piece'); | |||
$pointsSaleArray = $this->pointSaleRepository->findPointSales(); | |||
foreach ($pointsSaleArray as $pointSale) { | |||
$this->orderBuilder->initPointSaleOrders($pointSale, $ordersArray); |
@@ -30,4 +30,9 @@ class DistributionContainer extends AbstractContainer | |||
{ | |||
return DistributionDefinition::getInstance(); | |||
} | |||
public function getRepository(): DistributionRepository | |||
{ | |||
return DistributionRepository::getInstance(); | |||
} | |||
} |
@@ -6,19 +6,19 @@ use common\logic\AbstractBuilder; | |||
use common\logic\Document\Document\Model\Document; | |||
use common\logic\Document\Document\Model\DocumentInterface; | |||
use common\logic\Document\Document\Repository\DocumentRepository; | |||
use common\logic\Producer\Producer\Repository\ProducerRepository; | |||
use common\logic\Producer\Producer\Service\ProducerSolver; | |||
class DocumentBuilder extends AbstractBuilder | |||
{ | |||
protected DocumentSolver $documentSolver; | |||
protected DocumentRepository $documentRepository; | |||
protected ProducerRepository $producerRepository; | |||
protected ProducerSolver $producerSolver; | |||
public function loadDependencies(): void | |||
{ | |||
$this->documentSolver = $this->loadService(DocumentSolver::class); | |||
$this->documentRepository = $this->loadService(DocumentRepository::class); | |||
$this->producerRepository = $this->loadService(ProducerRepository::class); | |||
$this->producerSolver = $this->loadService(ProducerSolver::class); | |||
} | |||
public function initDocumentProducer(Document $document): void | |||
@@ -35,7 +35,7 @@ class DocumentBuilder extends AbstractBuilder | |||
$classLower = 'delivery_note'; | |||
} | |||
$prefix = $this->producerRepository->getConfig('document_' . $classLower . '_prefix'); | |||
$prefix = $this->producerSolver->getConfig('document_' . $classLower . '_prefix'); | |||
$oneDocumentExist = $classComplete::searchOne(['status' => Document::STATUS_VALID], ['orderby' => 'reference DESC']); | |||
if ($oneDocumentExist) { | |||
@@ -48,7 +48,7 @@ class DocumentBuilder extends AbstractBuilder | |||
$reference = $prefix . $numReference; | |||
} else { | |||
$firstReference = $this->producerRepository->getConfig('document_' . $classLower . '_first_reference'); | |||
$firstReference = $this->producerSolver->getConfig('document_' . $classLower . '_first_reference'); | |||
if (strlen($firstReference) > 0) { | |||
$reference = $firstReference; | |||
@@ -79,7 +79,7 @@ class DocumentBuilder extends AbstractBuilder | |||
public function initTaxCalculationMethod(DocumentInterface $document): void | |||
{ | |||
$producerTaxCalculationMethod = $this->producerRepository->getConfig('option_tax_calculation_method'); | |||
$producerTaxCalculationMethod = $this->producerSolver->getConfig('option_tax_calculation_method'); | |||
if ($producerTaxCalculationMethod) { | |||
$document->tax_calculation_method = $producerTaxCalculationMethod; |
@@ -5,7 +5,6 @@ namespace common\logic\Document\Document\Service; | |||
use common\helpers\GlobalParam; | |||
use common\logic\AbstractService; | |||
use common\logic\Document\Document\Model\DocumentInterface; | |||
use common\logic\Producer\Producer\Repository\ProducerRepository; | |||
use common\logic\Producer\Producer\Service\ProducerSolver; | |||
use common\logic\UtilsInterface; | |||
use kartik\mpdf\Pdf; | |||
@@ -17,14 +16,12 @@ class DocumentUtils extends AbstractService implements UtilsInterface | |||
protected DocumentSolver $documentSolver; | |||
protected DocumentBuilder $documentBuilder; | |||
protected ProducerSolver $producerSolver; | |||
protected ProducerRepository $producerRepository; | |||
public function loadDependencies(): void | |||
{ | |||
$this->documentSolver = $this->loadService(DocumentSolver::class); | |||
$this->documentBuilder = $this->loadService(DocumentBuilder::class); | |||
$this->producerSolver = $this->loadService(ProducerSolver::class); | |||
$this->producerRepository = $this->loadService(ProducerRepository::class); | |||
} | |||
public function generatePdf(DocumentInterface $document, string $destination): ?string | |||
@@ -53,7 +50,7 @@ class DocumentUtils extends AbstractService implements UtilsInterface | |||
$contentFooter .= '</div>'; | |||
$marginBottom = 10; | |||
if (strlen($this->producerRepository->getConfig('document_infos_bottom')) > 0) { | |||
if (strlen($this->producerSolver->getConfig('document_infos_bottom')) > 0) { | |||
$marginBottom = 40; | |||
} | |||
@@ -0,0 +1,8 @@ | |||
<?php | |||
namespace common\logic; | |||
interface NotifierInterface | |||
{ | |||
} |
@@ -8,6 +8,7 @@ use common\logic\AbstractRepository; | |||
use common\logic\Distribution\Distribution\Model\Distribution; | |||
use common\logic\Distribution\Distribution\Repository\DistributionRepository; | |||
use common\logic\Distribution\ProductDistribution\Repository\ProductDistributionRepository; | |||
use common\logic\Document\DeliveryNote\Model\DeliveryNote; | |||
use common\logic\Document\Invoice\Model\Invoice; | |||
use common\logic\Document\Invoice\Repository\InvoiceRepository; | |||
use common\logic\Document\Invoice\Service\InvoiceSolver; | |||
@@ -21,6 +22,7 @@ use common\logic\PointSale\PointSale\Repository\PointSaleRepository; | |||
use common\logic\PointSale\UserPointSale\Repository\UserPointSaleRepository; | |||
use common\logic\Producer\Producer\Model\Producer; | |||
use common\logic\Producer\Producer\Repository\ProducerRepository; | |||
use common\logic\Producer\Producer\Service\ProducerSolver; | |||
use common\logic\Product\Product\Service\ProductSolver; | |||
use common\logic\Subscription\Subscription\Model\Subscription; | |||
use common\logic\User\User\Model\User; | |||
@@ -42,6 +44,7 @@ class OrderRepository extends AbstractRepository | |||
protected InvoiceRepository $invoiceRepository; | |||
protected InvoiceSolver $invoiceSolver; | |||
protected PaymentSolver $paymentSolver; | |||
protected ProducerSolver $producerSolver; | |||
public function loadDependencies(): void | |||
{ | |||
@@ -58,6 +61,7 @@ class OrderRepository extends AbstractRepository | |||
$this->invoiceRepository = $this->loadService(InvoiceRepository::class); | |||
$this->invoiceSolver = $this->loadService(InvoiceSolver::class); | |||
$this->paymentSolver = $this->loadService(PaymentSolver::class); | |||
$this->producerSolver = $this->loadService(ProducerSolver::class); | |||
} | |||
public function getDefaultOptionsSearch(): array | |||
@@ -140,6 +144,16 @@ class OrderRepository extends AbstractRepository | |||
->find(); | |||
} | |||
public function findOrdersByUserAndDeliveryNote(User $user, DeliveryNote $deliveryNote) | |||
{ | |||
return $this | |||
->createDefaultQuery() | |||
->filterByUser($user) | |||
->filterIsLinkedDeliveryNote($deliveryNote) | |||
->filterIsValid() | |||
->find(); | |||
} | |||
public function findOrdersByUserNotInvoiced(User $user) | |||
{ | |||
return $this | |||
@@ -154,6 +168,20 @@ class OrderRepository extends AbstractRepository | |||
->find(); | |||
} | |||
public function findOrdersByUserNotLinkedDeliveryNote(User $user) | |||
{ | |||
return $this | |||
->createDefaultQuery() | |||
->filterByUser($user) | |||
->filterIsNotLinkedDeliveryNote() | |||
->filterIsPassed() | |||
->filterIsValid() | |||
->filterIsNotIgnoreWhenInvoicing() | |||
->orderByDistributionDate('DESC') | |||
->limit(20) | |||
->find(); | |||
} | |||
public function queryOrdersHistory(Producer $producer, User $user) | |||
{ | |||
$queryIncoming = clone $this->createDefaultQuery() | |||
@@ -212,7 +240,7 @@ class OrderRepository extends AbstractRepository | |||
public function getAmountSummary(Order $order): string | |||
{ | |||
$html = ''; | |||
$creditActive = $this->producerRepository->getConfig('credit'); | |||
$creditActive = $this->producerSolver->getConfig('credit'); | |||
$html .= $this->orderSolver->getOrderAmountWithTax($order, Order::AMOUNT_TOTAL, true); | |||
if ($creditActive) { | |||
@@ -249,26 +277,14 @@ class OrderRepository extends AbstractRepository | |||
$todayHour = date('G'); | |||
$dayDistribution = strtolower(date('l', strtotime($order->distribution->date))); | |||
$orderDelay = $this->producerRepository->getConfig( | |||
'order_delay', | |||
$order->distribution->id_producer | |||
); | |||
$orderDelaySpecific = $this->producerRepository->getConfig( | |||
'order_delay_' . $dayDistribution, | |||
$order->distribution->id_producer | |||
); | |||
$orderDelay = $this->producerSolver->getConfig('order_delay'); | |||
$orderDelaySpecific = $this->producerSolver->getConfig('order_delay_' . $dayDistribution,); | |||
if ($orderDelaySpecific) { | |||
$orderDelay = $orderDelaySpecific; | |||
} | |||
$orderDeadline = $this->producerRepository->getConfig( | |||
'order_deadline', | |||
$order->distribution->id_producer | |||
); | |||
$orderDeadlineSpecific = $this->producerRepository->getConfig( | |||
'order_deadline_' . $dayDistribution, | |||
$order->distribution->id_producer | |||
); | |||
$orderDeadline = $this->producerSolver->getConfig('order_deadline',); | |||
$orderDeadlineSpecific = $this->producerSolver->getConfig('order_deadline_' . $dayDistribution,); | |||
if ($orderDeadlineSpecific) { | |||
$orderDeadline = $orderDeadlineSpecific; | |||
} | |||
@@ -339,7 +355,7 @@ class OrderRepository extends AbstractRepository | |||
if($pointSale) { | |||
$creditFunctioning = $this->producerRepository->getPointSaleCreditFunctioning($pointSale); | |||
if ($order->id_user && $this->producerRepository->getConfig('credit') && $pointSale->credit) { | |||
if ($order->id_user && $this->producerSolver->getConfig('credit') && $pointSale->credit) { | |||
if($order->mean_payment == MeanPayment::CREDIT || $creditFunctioning == Producer::CREDIT_FUNCTIONING_MANDATORY) { | |||
return true; | |||
} | |||
@@ -360,7 +376,7 @@ class OrderRepository extends AbstractRepository | |||
public function isCreditContext(Order $order) | |||
{ | |||
if(!$this->producerRepository->getConfig('credit')) { | |||
if(!$this->producerSolver->getConfig('credit')) { | |||
return false; | |||
} | |||
@@ -369,7 +385,7 @@ class OrderRepository extends AbstractRepository | |||
if($pointSale) { | |||
$creditFunctioning = $this->producerRepository->getPointSaleCreditFunctioning($pointSale); | |||
if ($order->id_user && $this->producerRepository->getConfig('credit') && $pointSale->credit) { | |||
if ($order->id_user && $this->producerSolver->getConfig('credit') && $pointSale->credit) { | |||
if($order->mean_payment == MeanPayment::CREDIT | |||
|| $creditFunctioning == Producer::CREDIT_FUNCTIONING_MANDATORY | |||
|| $creditFunctioning == Producer::CREDIT_FUNCTIONING_OPTIONAL) { | |||
@@ -597,4 +613,37 @@ class OrderRepository extends AbstractRepository | |||
return false; | |||
} | |||
public function findOrdersDashboard(): array | |||
{ | |||
$optionDashboardDateStart = $this->producerSolver->getConfig('option_dashboard_date_start'); | |||
$optionDashboardDateEnd = $this->producerSolver->getConfig('option_dashboard_date_end'); | |||
$paramsOrders = []; | |||
if ($optionDashboardDateStart || $optionDashboardDateEnd) { | |||
$conditionsOrders = ''; | |||
if ($optionDashboardDateStart) { | |||
$conditionsOrders .= 'distribution.date >= :date_start'; | |||
$paramsOrders[':date_start'] = $optionDashboardDateStart; | |||
} | |||
if ($optionDashboardDateEnd) { | |||
if ($optionDashboardDateStart) { | |||
$conditionsOrders .= ' AND '; | |||
} | |||
$conditionsOrders .= 'distribution.date <= :date_end'; | |||
$paramsOrders[':date_end'] = $optionDashboardDateEnd; | |||
} | |||
} else { | |||
$conditionsOrders = 'distribution.date >= :date_start'; | |||
$paramsOrders[':date_start'] = date('Y-m-d 00:00:00'); | |||
} | |||
$ordersArray = Order::searchAll([], [ | |||
'orderby' => 'IF(ISNULL(date_update), `order`.`date`, `order`.`date_update`) DESC', | |||
'conditions' => $conditionsOrders . ' AND (origin = \'' . Order::ORIGIN_USER . '\' OR origin = \'' . Order::ORIGIN_ADMIN . '\' OR (origin = \'' . Order::ORIGIN_AUTO . '\' AND (date_update IS NOT NULL OR date_delete IS NOT NULL)))', | |||
'params' => $paramsOrders, | |||
]); | |||
return $ordersArray; | |||
} | |||
} |
@@ -3,6 +3,7 @@ | |||
namespace common\logic\Order\Order\Repository; | |||
use common\logic\AbstractRepositoryQuery; | |||
use common\logic\Document\DeliveryNote\Model\DeliveryNote; | |||
use common\logic\Document\Invoice\Model\Invoice; | |||
use common\logic\Order\Order\Service\OrderDefinition; | |||
use common\logic\User\User\Model\User; | |||
@@ -84,6 +85,14 @@ class OrderRepositoryQuery extends AbstractRepositoryQuery | |||
return $this; | |||
} | |||
public function filterIsLinkedDeliveryNote(DeliveryNote $deliveryNote): self | |||
{ | |||
$this->andWhere('order.id_delivery_note IS NOT NULL AND order.id_delivery_note = :id_delivery_note') | |||
->params([':id_delivery_note' => $deliveryNote->id]); | |||
return $this; | |||
} | |||
public function filterIsNotInvoiced(): self | |||
{ | |||
$this->andWhere('order.id_invoice IS NULL'); | |||
@@ -91,6 +100,13 @@ class OrderRepositoryQuery extends AbstractRepositoryQuery | |||
return $this; | |||
} | |||
public function filterIsNotLinkedDeliveryNote(): self | |||
{ | |||
$this->andWhere('order.id_delivery_note IS NULL'); | |||
return $this; | |||
} | |||
public function filterIsNotIgnoreWhenInvoicing(): self | |||
{ | |||
$this->andWhere('order.ignore_when_invoicing IS NULL'); |
@@ -13,6 +13,8 @@ use common\logic\Distribution\Distribution\Service\DistributionSolver; | |||
use common\logic\Document\DeliveryNote\Model\DeliveryNote; | |||
use common\logic\Document\DeliveryNote\Service\DeliveryNoteBuilder; | |||
use common\logic\Document\Document\Model\Document; | |||
use common\logic\Document\Document\Model\DocumentInterface; | |||
use common\logic\Document\Document\Service\DocumentSolver; | |||
use common\logic\Document\Invoice\Model\Invoice; | |||
use common\logic\Order\Order\Event\OrderDeleteEvent; | |||
use common\logic\Order\Order\Model\Order; | |||
@@ -29,6 +31,7 @@ use common\logic\PointSale\PointSale\Repository\PointSaleRepository; | |||
use common\logic\PointSale\UserPointSale\Repository\UserPointSaleRepository; | |||
use common\logic\Producer\Producer\Model\Producer; | |||
use common\logic\Producer\Producer\Repository\ProducerRepository; | |||
use common\logic\Producer\Producer\Service\ProducerSolver; | |||
use common\logic\Product\Product\Service\ProductSolver; | |||
use common\logic\Subscription\Subscription\Model\Subscription; | |||
use common\logic\Subscription\Subscription\Service\SubscriptionBuilder; | |||
@@ -61,6 +64,8 @@ class OrderBuilder extends AbstractBuilder | |||
protected DistributionSolver $distributionSolver; | |||
protected UserRepository $userRepository; | |||
protected DeliveryNoteBuilder $deliveryNoteBuilder; | |||
protected DocumentSolver $documentSolver; | |||
protected ProducerSolver $producerSolver; | |||
public function loadDependencies(): void | |||
{ | |||
@@ -84,6 +89,8 @@ class OrderBuilder extends AbstractBuilder | |||
$this->distributionSolver = $this->loadService(DistributionSolver::class); | |||
$this->userRepository = $this->loadService(UserRepository::class); | |||
$this->deliveryNoteBuilder = $this->loadService(DeliveryNoteBuilder::class); | |||
$this->documentSolver = $this->loadService(DocumentSolver::class); | |||
$this->producerSolver = $this->loadService(ProducerSolver::class); | |||
} | |||
public function instanciateOrder(Distribution $distribution): Order | |||
@@ -256,7 +263,7 @@ class OrderBuilder extends AbstractBuilder | |||
$order->auto_payment = 0; | |||
if ($subscription->auto_payment == Subscription::AUTO_PAYMENT_DEDUCTED) { | |||
if ($order->id_user && $this->producerRepository->getConfig('credit') && $pointSale->credit) { | |||
if ($order->id_user && $this->producerSolver->getConfig('credit') && $pointSale->credit) { | |||
if ($creditFunctioning == Producer::CREDIT_FUNCTIONING_OPTIONAL) { | |||
$order->auto_payment = 0; | |||
} elseif ($creditFunctioning == Producer::CREDIT_FUNCTIONING_MANDATORY) { | |||
@@ -396,8 +403,8 @@ class OrderBuilder extends AbstractBuilder | |||
$this->initOrder($order); | |||
// delete | |||
if ($this->producerRepository->getConfig('option_behavior_cancel_order') == Producer::BEHAVIOR_DELETE_ORDER_DELETE || | |||
($this->producerRepository->getConfig('option_behavior_cancel_order') == Producer::BEHAVIOR_DELETE_ORDER_STATUS && strlen($order->date_delete)) | |||
if ($this->producerSolver->getConfig('option_behavior_cancel_order') == Producer::BEHAVIOR_DELETE_ORDER_DELETE || | |||
($this->producerSolver->getConfig('option_behavior_cancel_order') == Producer::BEHAVIOR_DELETE_ORDER_STATUS && strlen($order->date_delete)) | |||
|| $force) { | |||
$this->productOrderBuilder->deleteProductOrdersByOrder($order); | |||
@@ -405,7 +412,7 @@ class OrderBuilder extends AbstractBuilder | |||
$return = $this->delete($order); | |||
} | |||
// status 'delete' | |||
elseif ($this->producerRepository->getConfig('option_behavior_cancel_order') == Producer::BEHAVIOR_DELETE_ORDER_STATUS) { | |||
elseif ($this->producerSolver->getConfig('option_behavior_cancel_order') == Producer::BEHAVIOR_DELETE_ORDER_STATUS) { | |||
$order->date_delete = date('Y-m-d H:i:s'); | |||
$return = $this->update($order); | |||
} | |||
@@ -558,12 +565,6 @@ class OrderBuilder extends AbstractBuilder | |||
} | |||
} | |||
public function updateOrderDeliveryNote(Order $order, DeliveryNote $deliveryNote): bool | |||
{ | |||
$order->id_delivery_note = $deliveryNote->id; | |||
return $order->save(); | |||
} | |||
public function assignAllOrdersDeliveryNote(array $idOrders, DeliveryNote $deliveryNote) | |||
{ | |||
$this->unassignAllOrdersDeliveryNote($deliveryNote); | |||
@@ -626,6 +627,16 @@ class OrderBuilder extends AbstractBuilder | |||
$this->update($order); | |||
} | |||
public function updateOrderDocument(Order $order, DocumentInterface $document = null) | |||
{ | |||
if($this->documentSolver->isDocumentInvoice($document)) { | |||
$this->updateOrderInvoice($order, $document); | |||
} | |||
elseif($this->documentSolver->isDocumentDeliveryNote($document)) { | |||
$this->updateOrderDeliveryNote($order, $document); | |||
} | |||
} | |||
public function updateOrderInvoice(Order $order, Invoice $invoice = null) | |||
{ | |||
if($invoice) { | |||
@@ -637,4 +648,16 @@ class OrderBuilder extends AbstractBuilder | |||
$this->update($order); | |||
} | |||
public function updateOrderDeliveryNote(Order $order, DeliveryNote $deliveryNote = null) | |||
{ | |||
if($deliveryNote) { | |||
$order->populateDeliveryNote($deliveryNote); | |||
} | |||
else { | |||
$order->id_delivery_note = null; | |||
} | |||
$this->update($order); | |||
} | |||
} |
@@ -1,96 +0,0 @@ | |||
<?php | |||
/** | |||
Copyright distrib (2018) | |||
contact@opendistrib.net | |||
Ce logiciel est un programme informatique servant à aider les producteurs | |||
à distribuer leur production en circuits courts. | |||
Ce logiciel est régi par la licence CeCILL soumise au droit français et | |||
respectant les principes de diffusion des logiciels libres. Vous pouvez | |||
utiliser, modifier et/ou redistribuer ce programme sous les conditions | |||
de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA | |||
sur le site "http://www.cecill.info". | |||
En contrepartie de l'accessibilité au code source et des droits de copie, | |||
de modification et de redistribution accordés par cette licence, il n'est | |||
offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, | |||
seule une responsabilité restreinte pèse sur l'auteur du programme, le | |||
titulaire des droits patrimoniaux et les concédants successifs. | |||
A cet égard l'attention de l'utilisateur est attirée sur les risques | |||
associés au chargement, à l'utilisation, à la modification et/ou au | |||
développement et à la reproduction du logiciel par l'utilisateur étant | |||
donné sa spécificité de logiciel libre, qui peut le rendre complexe à | |||
manipuler et qui le réserve donc à des développeurs et des professionnels | |||
avertis possédant des connaissances informatiques approfondies. Les | |||
utilisateurs sont donc invités à charger et tester l'adéquation du | |||
logiciel à leurs besoins dans des conditions permettant d'assurer la | |||
sécurité de leurs systèmes et ou de leurs données et, plus généralement, | |||
à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. | |||
Le fait que vous puissiez accéder à cet en-tête signifie que vous avez | |||
pris connaissance de la licence CeCILL, et que vous en avez accepté les | |||
termes. | |||
*/ | |||
namespace common\logic\Payment\Model; | |||
use common\helpers\GlobalParam; | |||
use common\helpers\MeanPayment; | |||
use common\logic\Payment\Repository\PaymentRepository; | |||
use yii\data\ActiveDataProvider; | |||
class CreditHistorySearch extends Payment | |||
{ | |||
public function rules(): array | |||
{ | |||
return [ | |||
[['id_user', 'id_user_action', 'id_order', 'id_producer'], 'integer'], | |||
[['date'], 'safe'], | |||
[['amount'], 'double'], | |||
[['type', 'mean_payment', 'comment'], 'string', 'max' => 255], | |||
]; | |||
} | |||
public function search($params) | |||
{ | |||
$paymentRepository = PaymentRepository::getInstance(); | |||
$optionsSearch = $paymentRepository->getDefaultOptionsSearch() ; | |||
$query = Payment::find() | |||
->with($optionsSearch['with']) | |||
->innerJoinWith($optionsSearch['join_with'], true) | |||
->where([ | |||
'payment.id_producer' => GlobalParam::getCurrentProducerId(), | |||
]) | |||
->andWhere("payment.type = 'initial-credit' OR payment.type = 'credit' OR payment.type = 'debit' OR (payment.type = 'payment' AND payment.mean_payment = 'credit') OR (payment.type = 'refund' AND payment.mean_payment = 'credit')") | |||
->orderBy('id DESC') | |||
; | |||
$dataProvider = new ActiveDataProvider([ | |||
'query' => $query, | |||
'sort' => false, | |||
'pagination' => [ | |||
'pageSize' => 20, | |||
], | |||
]); | |||
$this->load($params); | |||
if (!$this->validate()) { | |||
return $dataProvider; | |||
} | |||
if(isset($this->id_user) && is_numeric($this->id_user)) { | |||
$query->andWhere([ | |||
'payment.id_user' => $this->id_user | |||
]) ; | |||
} | |||
return $dataProvider; | |||
} | |||
} |
@@ -5,6 +5,7 @@ namespace common\logic\Payment\Repository; | |||
use common\logic\AbstractRepository; | |||
use common\logic\Order\Order\Model\Order; | |||
use common\logic\Payment\Model\Payment; | |||
use common\logic\User\User\Model\User; | |||
class PaymentRepository extends AbstractRepository | |||
{ | |||
@@ -19,7 +20,9 @@ class PaymentRepository extends AbstractRepository | |||
{ | |||
return [ | |||
self::WITH => [ | |||
'user' | |||
'user', | |||
'order', | |||
'userAction' | |||
], | |||
self::JOIN_WITH => [], | |||
self::ORDER_BY => Payment::tableName() . '.date ASc', | |||
@@ -33,4 +36,17 @@ class PaymentRepository extends AbstractRepository | |||
->filterByOrder($order) | |||
->find(); | |||
} | |||
public function queryPaymentsCreditHistoryByUser(User $user) | |||
{ | |||
return $this->createDefaultQuery() | |||
->filterByUser($user) | |||
->filterIsCredit() | |||
->orderBy('date DESC'); | |||
} | |||
public function findPaymentsCreditHistoryByUser(User $user): array | |||
{ | |||
return $this->queryPaymentsCreditHistoryByUser($user)->find(); | |||
} | |||
} |
@@ -5,6 +5,7 @@ namespace common\logic\Payment\Repository; | |||
use common\logic\AbstractRepositoryQuery; | |||
use common\logic\Order\Order\Model\Order; | |||
use common\logic\Payment\Service\PaymentDefinition; | |||
use common\logic\User\User\Model\User; | |||
class PaymentRepositoryQuery extends AbstractRepositoryQuery | |||
{ | |||
@@ -20,4 +21,16 @@ class PaymentRepositoryQuery extends AbstractRepositoryQuery | |||
$this->andWhere(['id_order' => $order->id]); | |||
return $this; | |||
} | |||
public function filterByUser(User $user): self | |||
{ | |||
$this->andWhere(['id_user' => $user->id]); | |||
return $this; | |||
} | |||
public function filterIsCredit() | |||
{ | |||
$this->andWhere("payment.type = 'initial-credit' OR payment.type = 'credit' OR payment.type = 'debit' OR (payment.type = 'payment' AND payment.mean_payment = 'credit') OR (payment.type = 'refund' AND payment.mean_payment = 'credit')"); | |||
return $this; | |||
} | |||
} |
@@ -0,0 +1,38 @@ | |||
<?php | |||
namespace common\logic\Payment\Service; | |||
use common\logic\AbstractNotifier; | |||
use common\logic\User\User\Model\User; | |||
use common\logic\User\User\Repository\UserRepository; | |||
class PaymentNotifier extends AbstractNotifier | |||
{ | |||
protected UserRepository $userRepository; | |||
public function loadDependencies(): void | |||
{ | |||
parent::loadDependencies(); | |||
$this->userRepository = $this->loadService(UserRepository::class); | |||
} | |||
public function notifyUserCreditMovement(User $user, string $type, float $amount) | |||
{ | |||
$producer = $this->getProducerContext(); | |||
$credit = $this->userRepository->getCredit($user, true); | |||
$this->mailer->sendFromProducer( | |||
'Mouvement de crédit', | |||
'creditUser', | |||
[ | |||
'user' => $user, | |||
'producer' => $producer, | |||
'credit' => $credit, | |||
'type' => $type, | |||
'amount' => $amount | |||
], | |||
$user->email, | |||
$producer | |||
); | |||
} | |||
} |
@@ -7,7 +7,7 @@ use common\logic\AbstractService; | |||
use common\logic\Order\Order\Model\Order; | |||
use common\logic\Order\Order\Service\OrderSolver; | |||
use common\logic\Payment\Model\Payment; | |||
use common\logic\Producer\Producer\Repository\ProducerRepository; | |||
use common\logic\Producer\Producer\Service\ProducerSolver; | |||
use common\logic\User\User\Model\User; | |||
use common\logic\User\User\Repository\UserRepository; | |||
use common\logic\UtilsInterface; | |||
@@ -17,15 +17,15 @@ class PaymentUtils extends AbstractService implements UtilsInterface | |||
{ | |||
protected PaymentBuilder $paymentBuilder; | |||
protected OrderSolver $orderSolver; | |||
protected ProducerRepository $producerRepository; | |||
protected UserRepository $userRepository; | |||
protected ProducerSolver $producerSolver; | |||
public function loadDependencies(): void | |||
{ | |||
$this->paymentBuilder = $this->loadService(PaymentBuilder::class); | |||
$this->orderSolver = $this->loadService(OrderSolver::class); | |||
$this->producerRepository = $this->loadService(ProducerRepository::class); | |||
$this->userRepository = $this->loadService(UserRepository::class); | |||
$this->producerSolver = $this->loadService(ProducerSolver::class); | |||
} | |||
public function creditUser(User $user, float $amount, string $meanPayment, User $userAction): void | |||
@@ -91,7 +91,7 @@ class PaymentUtils extends AbstractService implements UtilsInterface | |||
$amountRemaining = round($this->orderSolver->getOrderAmountWithTax($order, Order::AMOUNT_REMAINING), 2); | |||
if($checkCreditLimit) { | |||
$creditLimit = $this->producerRepository->getConfig('credit_limit'); | |||
$creditLimit = $this->producerSolver->getConfig('credit_limit'); | |||
$creditUser = $this->userRepository->getCredit($order->user); | |||
if (!is_null($creditLimit) && $amountRemaining > $creditUser - $creditLimit) { |
@@ -4,6 +4,7 @@ namespace common\logic\Payment\Wrapper; | |||
use common\logic\AbstractContainer; | |||
use common\logic\Payment\Repository\PaymentRepository; | |||
use common\logic\Payment\Service\PaymentNotifier; | |||
use common\logic\Payment\Service\PaymentUtils; | |||
use common\logic\Payment\Service\PaymentBuilder; | |||
use common\logic\Payment\Service\PaymentDefinition; | |||
@@ -18,6 +19,7 @@ class PaymentContainer extends AbstractContainer | |||
PaymentSolver::class, | |||
PaymentBuilder::class, | |||
PaymentRepository::class, | |||
PaymentNotifier::class, | |||
PaymentUtils::class, | |||
]; | |||
} | |||
@@ -42,7 +44,12 @@ class PaymentContainer extends AbstractContainer | |||
return PaymentRepository::getInstance(); | |||
} | |||
public function getPaymentUtils(): PaymentUtils | |||
public function getNotifier(): PaymentNotifier | |||
{ | |||
return PaymentNotifier::getInstance(); | |||
} | |||
public function getUtils(): PaymentUtils | |||
{ | |||
return PaymentUtils::getInstance(); | |||
} |
@@ -79,7 +79,8 @@ class PointSale extends ActiveRecordCommon | |||
'infos_saturday', 'infos_sunday', 'credit_functioning', 'bread_box_code'], 'string'], | |||
[['point_production', 'credit', 'delivery_monday', 'delivery_tuesday', | |||
'delivery_wednesday', 'delivery_thursday', 'delivery_friday', | |||
'delivery_saturday', 'delivery_sunday', 'default', 'is_bread_box'], 'boolean'], | |||
'delivery_saturday', 'delivery_sunday', 'default', 'is_bread_box', | |||
'button_generate_delivery_note_point_sale', 'button_generate_delivery_note_each_user'], 'boolean'], | |||
['point_production', 'default', 'value' => 0], | |||
[['id_producer', 'id_user', 'maximum_number_orders', 'status'], 'integer'], | |||
['id_producer', 'required'], | |||
@@ -118,12 +119,14 @@ class PointSale extends ActiveRecordCommon | |||
'code' => 'Code', | |||
'credit_functioning' => 'Utilisation du Crédit par l\'utilisateur', | |||
'default' => 'Point de vente par défaut', | |||
'id_user' => 'Contact', | |||
'id_user' => 'Contact facturation', | |||
'product_price_percent' => 'Prix produits : pourcentage', | |||
'maximum_number_orders' => 'Nombre maximum de commandes', | |||
'is_bread_box' => 'Boîte à pain', | |||
'bread_box_code' => 'Code boîte à pain', | |||
'status' => 'Statut' | |||
'status' => 'Statut', | |||
'button_generate_delivery_note_point_sale' => 'Activer le bouton de génération de bon de livraison par point de vente', | |||
'button_generate_delivery_note_each_user' => 'Activer le bouton de génération de bon de livraison par client' | |||
]; | |||
} | |||
@@ -232,7 +232,7 @@ class ProducerRepository extends AbstractRepository | |||
public function getOnlinePaymentMinimumAmount(): float | |||
{ | |||
$onlinePaymentMinimumAmount = $this->getConfig('option_online_payment_minimum_amount'); | |||
$onlinePaymentMinimumAmount = $this->producerSolver->getConfig('option_online_payment_minimum_amount'); | |||
if (!$onlinePaymentMinimumAmount) { | |||
$onlinePaymentMinimumAmount = Producer::ONLINE_PAYMENT_MINIMUM_AMOUNT_DEFAULT; | |||
} | |||
@@ -240,27 +240,6 @@ class ProducerRepository extends AbstractRepository | |||
return $onlinePaymentMinimumAmount; | |||
} | |||
/** | |||
* Retourne une configuration d'un producteur donné | |||
*/ | |||
public function getConfig(string $config = '', int $idProducer = 0) | |||
{ | |||
if (strlen($config)) { | |||
if (!$idProducer) { | |||
$producer = $this->getProducerContext(); | |||
} | |||
else { | |||
$producer = $this->findOneProducerById($idProducer); | |||
} | |||
if ($producer) { | |||
return $producer->$config; | |||
} | |||
} | |||
return null; | |||
} | |||
public function getNameProducer(User $user): string | |||
{ | |||
$producer = $this->findOneProducerById($user->id_producer); | |||
@@ -270,8 +249,8 @@ class ProducerRepository extends AbstractRepository | |||
public function isDocumentDisplayOrders(DocumentInterface $document): bool | |||
{ | |||
return ($this->documentSolver->getClass($document) == 'Invoice') ? | |||
$this->getConfig('document_display_orders_invoice') : | |||
$this->getConfig('document_display_orders_delivery_note'); | |||
$this->producerSolver->getConfig('document_display_orders_invoice') : | |||
$this->producerSolver->getConfig('document_display_orders_delivery_note'); | |||
} | |||
/** | |||
@@ -281,7 +260,7 @@ class ProducerRepository extends AbstractRepository | |||
{ | |||
return strlen($pointSale->credit_functioning) > 0 ? | |||
$pointSale->credit_functioning : | |||
$this->getConfig('credit_functioning'); | |||
$this->producerSolver->getConfig('credit_functioning'); | |||
} | |||
public function findProducersActive() |
@@ -255,4 +255,13 @@ class ProducerSolver extends AbstractService implements SolverInterface | |||
return 'Points de vente'; | |||
} | |||
public function getConfig(string $config, Producer $producer = null): ?string | |||
{ | |||
if(!$producer) { | |||
$producer = $this->getProducerContext(); | |||
} | |||
return $producer->$config; | |||
} | |||
} |
@@ -178,7 +178,7 @@ class Product extends ActiveRecordCommon | |||
public function afterFind() | |||
{ | |||
if ($this->taxRate == null) { | |||
if($this->id_producer == GlobalParam::getCurrentProducerId()) { | |||
if(GlobalParam::getCurrentProducerId() && $this->id_producer == GlobalParam::getCurrentProducerId()) { | |||
$producer = GlobalParam::getCurrentProducer(); | |||
} | |||
else { |
@@ -67,24 +67,24 @@ class UserRepository extends AbstractRepository | |||
* Retourne le crédit de l'utilisateur pour un producteur donné. | |||
* | |||
*/ | |||
public function getCredit(User $user): float | |||
public function getCredit(User $user, bool $reloadUserProducer = false): float | |||
{ | |||
// @TODO : optimisation à refactorer | |||
$userProducer = null; | |||
$producerId = $this->getProducerContextId(); | |||
foreach($user->userProducer as $userProducerRelation) { | |||
if($userProducerRelation->id_producer == $producerId) { | |||
$userProducer = $userProducerRelation; | |||
} | |||
} | |||
if(!$userProducer) { | |||
if($reloadUserProducer) { | |||
$userProducer = $this->userProducerRepository->findOneUserProducer($user); | |||
} | |||
else { | |||
$userProducer = $this->userSolver->getUserProducer($user); | |||
} | |||
return $userProducer ? $userProducer->credit : 0; | |||
} | |||
public function getCreditActive(User $user): bool | |||
{ | |||
$userProducer = $this->userSolver->getUserProducer($user); | |||
return $userProducer ? $userProducer->credit_active : false; | |||
} | |||
/** | |||
* Recherche des utilisateurs suivant les paramètres : id_etablissement, | |||
* inactifs, id_point_vente, nom, prenom, email, telephone. |
@@ -97,4 +97,10 @@ class UserBuilder extends AbstractBuilder | |||
return false; | |||
} | |||
public function switchProducer(User $user, Producer $producer) | |||
{ | |||
$user->id_producer = $producer->id; | |||
$this->update($user); | |||
} | |||
} |
@@ -6,6 +6,7 @@ use common\logic\AbstractService; | |||
use common\logic\SolverInterface; | |||
use common\logic\User\User\Model\User; | |||
use common\logic\User\UserGroup\Model\UserGroup; | |||
use common\logic\User\UserProducer\Model\UserProducer; | |||
use common\logic\User\UserUserGroup\Model\UserUserGroup; | |||
class UserSolver extends AbstractService implements SolverInterface | |||
@@ -231,4 +232,16 @@ class UserSolver extends AbstractService implements SolverInterface | |||
return false; | |||
} | |||
public function getUserProducer(User $user): ?UserProducer | |||
{ | |||
$userProducer = null; | |||
$producerId = $this->getProducerContextId(); | |||
foreach($user->userProducer as $userProducerRelation) { | |||
if($userProducerRelation->id_producer == $producerId) { | |||
$userProducer = $userProducerRelation; | |||
} | |||
} | |||
return $userProducer; | |||
} | |||
} |
@@ -11,6 +11,7 @@ use common\logic\Payment\Model\Payment; | |||
use common\logic\Payment\Service\PaymentSolver; | |||
use common\logic\Producer\Producer\Model\Producer; | |||
use common\logic\Producer\Producer\Repository\ProducerRepository; | |||
use common\logic\Producer\Producer\Service\ProducerSolver; | |||
use common\logic\User\User\Model\User; | |||
use common\logic\User\User\Repository\UserRepository; | |||
use common\logic\User\UserProducer\Model\UserProducer; | |||
@@ -24,6 +25,7 @@ class UserProducerBuilder extends AbstractBuilder | |||
protected ProducerRepository $producerRepository; | |||
protected OrderSolver $orderSolver; | |||
protected UserRepository $userRepository; | |||
protected ProducerSolver $producerSolver; | |||
public function loadDependencies(): void | |||
{ | |||
@@ -33,6 +35,7 @@ class UserProducerBuilder extends AbstractBuilder | |||
$this->producerRepository = $this->loadService(ProducerRepository::class); | |||
$this->orderSolver = $this->loadService(OrderSolver::class); | |||
$this->userRepository = $this->loadService(UserRepository::class); | |||
$this->producerSolver = $this->loadService(ProducerSolver::class); | |||
} | |||
public function instanciateUserProducer(User $user, Producer $producer, bool $bookmark = true, bool $newsletter = true) | |||
@@ -143,7 +146,7 @@ class UserProducerBuilder extends AbstractBuilder | |||
public function isCreditLimitCrossed($oldCredit, $newCredit) | |||
{ | |||
$creditLimitReminder = $this->producerRepository->getConfig('credit_limit_reminder'); | |||
$creditLimitReminder = $this->producerSolver->getConfig('credit_limit_reminder'); | |||
return !is_null($creditLimitReminder) && | |||
$oldCredit > $creditLimitReminder |
@@ -45,9 +45,9 @@ use common\helpers\Price; | |||
<p>Bonjour <?= Html::encode($user->name); ?>,</p> | |||
<p>Votre producteur <strong><?= Html::encode($producer->name); ?></strong> vient | |||
de <?php if($creditForm->type == Payment::TYPE_CREDIT): ?>créditer<?php else: ?>débiter<?php endif; ?> votre compte de <strong><?= Price::format($creditForm->amount); ?></strong> sur le site <a href="http://www.opendistrib.net/">Opendistrib</a>.</p> | |||
de <?php if($type == Payment::TYPE_CREDIT): ?>créditer<?php else: ?>débiter<?php endif; ?> votre compte de <strong><?= Price::format($amount); ?></strong> sur le site <a href="http://www.opendistrib.net/">Opendistrib</a>.</p> | |||
<p>Votre compte est désormais à <strong><?= Price::format($userProducer->credit); ?></strong><br /> | |||
<p>Votre compte est désormais à <strong><?= Price::format($credit); ?></strong><br /> | |||
<a href="<?= Yii::$app->urlManagerProducer->createAbsoluteUrl(['credit/history','slug_producer' => $producer->slug]) ?>">Cliquez ici</a> pour voir l'historique de votre crédit.</p> | |||
<p>À bientôt.</p> |
@@ -43,9 +43,9 @@ use common\logic\Payment\Model\Payment; | |||
Bonjour <?= $user->name; ?>,</p> | |||
Votre producteur <?= $producer->name; ?> vient de <?php if($creditForm->type == Payment::TYPE_CREDIT): ?>créditer<?php else: ?>débiter<?php endif; ?> votre compte de <?= Price::format($creditForm->amount); ?> sur le site http://www.opendistrib.net/ | |||
Votre producteur <?= $producer->name; ?> vient de <?php if($type == Payment::TYPE_CREDIT): ?>créditer<?php else: ?>débiter<?php endif; ?> votre compte de <?= Price::format($amount); ?> sur le site http://www.opendistrib.net/ | |||
Votre compte est désormais à : <?= Price::format($userProducer->credit); ?>. | |||
Votre compte est désormais à : <?= Price::format($credit); ?>. | |||
Suivez ce lien pour voir l'historique de votre crédit : <?= Yii::$app->urlManagerProducer->createAbsoluteUrl(['credit/history','slug_producer' => $producer->slug]) ?>"> | |||
À bientôt |
@@ -49,7 +49,7 @@ use common\logic\User\User\Model\User; | |||
<strong><?= Html::encode($user->email) ?></strong></p> | |||
<?php if($user->status == User::STATUS_PRODUCER): ?> | |||
<p>Vous pouvez dès maintenant vous connecter à l'<a href="<?= Yii::$app->urlManagerBackend->createAbsoluteUrl(['site/index']); ?>">administration</a> pour configurer votre compte producteur.</p> | |||
<p>Vous pouvez dès maintenant vous connecter à l'<a href="<?= Yii::$app->urlManagerBackend->createAbsoluteUrl(['dashboard/index']); ?>">administration</a> pour configurer votre compte producteur.</p> | |||
<p>Si vous avez des questions ou si vous avez besoin d'être accompagné lors de cette étape, n'hésitez pas à me contacter en réponse à ce mail ou directement au <strong><?= Yii::$app->parameterBag->get('adminPhoneNumber') ?></strong>.</p> | |||
<?php else: ?> | |||
<?php if(!is_null($producer)): ?> |
@@ -49,10 +49,9 @@ Voici votre identifiant de connexion : | |||
<?php if($user->status == User::STATUS_PRODUCER): ?> | |||
Vous pouvez dès maintenant vous connecter à l'administration pour configurer votre compte : | |||
<?= Yii::$app->urlManagerBackend->createAbsoluteUrl(['site/index']); ?> | |||
<?= Yii::$app->urlManagerBackend->createAbsoluteUrl(['dashboard/index']); ?> | |||
Si vous avez des questions ou si vous avez besoin d'être accompagné lors de cette étape, n'hésitez pas à me contacter en réponse à ce mail ou directement au <?= Yii::$app->parameterBag->get('adminPhoneNumber'); ?>. | |||
<?= Yii::$app->urlManagerBackend->createAbsoluteUrl(['site/index']); ?> | |||
<?php else: ?> | |||
<?php if(!is_null($producer)): ?> | |||
Vous pouvez maintenant passer commande chez votre producteur "<?= $producer->name ?>" : |
@@ -0,0 +1,26 @@ | |||
<?php | |||
require_once dirname(__FILE__).'/_macros.php'; | |||
version( | |||
'27/09/2023', | |||
[ | |||
[ | |||
"[Administration] Tableau de bord : tri des commandes par date de création et de modification", | |||
"[Administration] Distributions > génération des bons de livraison : configuration des boutons d'action affichés (par point de vente et/ou pour chaque client) en fonction du point de vente", | |||
"[Administration] Distributions > liste commandes : mise en évidence \"crédit obligatoire\" du client (bouton \"€\" en vert)", | |||
"[Administration] Bons de livraison : gestion des commandes liées (ajouter/supprimer/ignorer)", | |||
"[Espace producteur] Commander > étape produits : s'il y a des catégories, ouverture de la première catégorie par défaut", | |||
], | |||
[ | |||
"[Administration] Distributions > édition commande : correctif changement de prix", | |||
"[Administration] Distributions : correctif affichage des quantités restantes", | |||
] | |||
], | |||
[ | |||
[], | |||
[] | |||
], | |||
); | |||
?> |
@@ -59,7 +59,7 @@ if ($userManager->isCurrentProducer()) { | |||
// Items du menu | |||
$itemAdministration = [ | |||
'label' => '<span class="glyphicon glyphicon-cog"></span> <span class="link-text">Administration</span>', | |||
'url' => $this->getUrlManagerBackend()->createAbsoluteUrl(['site/index']), | |||
'url' => $this->getUrlManagerBackend()->createAbsoluteUrl(['dashboard/index']), | |||
'visible' => $userManager->isCurrentProducer(), | |||
'linkOptions' => ['class' => 'btn btn-default navbar-btn'] | |||
]; |
@@ -0,0 +1,28 @@ | |||
<?php | |||
use yii\db\Migration; | |||
use yii\db\Schema; | |||
/** | |||
* Class m230925_074317_add_columns_point_sale_active_button_generate_delivery_note | |||
*/ | |||
class m230925_074317_add_columns_point_sale_active_button_generate_delivery_note extends Migration | |||
{ | |||
/** | |||
* {@inheritdoc} | |||
*/ | |||
public function safeUp() | |||
{ | |||
$this->addColumn('point_sale', 'button_generate_delivery_note_point_sale', Schema::TYPE_BOOLEAN.' DEFAULT 1'); | |||
$this->addColumn('point_sale', 'button_generate_delivery_note_each_user', Schema::TYPE_BOOLEAN.' DEFAULT 1'); | |||
} | |||
/** | |||
* {@inheritdoc} | |||
*/ | |||
public function safeDown() | |||
{ | |||
$this->dropColumn('point_sale', 'button_generate_delivery_note_point_sale'); | |||
$this->dropColumn('point_sale', 'button_generate_delivery_note_each_user'); | |||
} | |||
} |
@@ -41,8 +41,8 @@ namespace producer\controllers; | |||
use common\helpers\GlobalParam; | |||
use common\helpers\MeanPayment; | |||
use common\logic\Payment\Model\Payment; | |||
use common\logic\Payment\Model\CreditHistorySearch; | |||
use producer\models\CreditForm; | |||
use yii\data\ActiveDataProvider; | |||
use yii\filters\VerbFilter; | |||
class CreditController extends ProducerBaseController | |||
@@ -83,15 +83,13 @@ class CreditController extends ProducerBaseController | |||
*/ | |||
public function actionHistory(string $returnPayment = '') | |||
{ | |||
$producer = $this->getProducerCurrent(); | |||
if (\Yii::$app->user->isGuest) { | |||
return $this->redirect($this->getUrlManagerFrontend()->createAbsoluteUrl(['site/producer', 'id' => $producer->id])); | |||
} | |||
$searchModel = new CreditHistorySearch(); | |||
$searchModel->id_user = GlobalParam::getCurrentUserId(); | |||
$dataProvider = $searchModel->search(\Yii::$app->request->queryParams); | |||
$userProducer = $this->getUserProducerManager()->findOneUserProducer($this->getUserCurrent()); | |||
$userContainer = $this->getUserContainer(); | |||
$paymentContainer = $this->getPaymentContainer(); | |||
$userCurrent = $this->getUserCurrent(); | |||
if (strlen($returnPayment)) { | |||
if ($returnPayment == 'success') { | |||
@@ -103,9 +101,9 @@ class CreditController extends ProducerBaseController | |||
} | |||
return $this->render('history', [ | |||
'searchModel' => $searchModel, | |||
'dataProvider' => $dataProvider, | |||
'creditUser' => $userProducer->credit | |||
'dataProvider' => $paymentContainer->getRepository() | |||
->queryPaymentsCreditHistoryByUser($userCurrent)->getDataProvider(20), | |||
'creditUser' => $userContainer->getRepository()->getCredit($userCurrent) | |||
]); | |||
} | |||
@@ -394,6 +394,9 @@ class OrderController extends ProducerBaseController | |||
$order->delivery_home = isset($posts['Order']['delivery_home']) ? $posts['Order']['delivery_home'] : false; | |||
$order->delivery_address = (isset($posts['Order']['delivery_address']) && $order->delivery_home) ? $posts['Order']['delivery_address'] : null; | |||
$order->comment = isset($posts['Order']['comment']) ? $posts['Order']['comment'] : null; | |||
if(!$isNewOrder) { | |||
$order->date_update = date('Y-m-d H:i:s'); | |||
} | |||
$order->save(); | |||
$orderManager->generateOrderReference($order); | |||
@@ -428,7 +431,7 @@ class OrderController extends ProducerBaseController | |||
} | |||
$productOrder->quantity = $quantity; | |||
$productOrder->price = $productManager->getPrice($product, [ | |||
'user' => GlobalParam::getCurrentUser(), | |||
'user' => $this->getUserCurrent(), | |||
'user_producer' => $userProducer, | |||
'point_sale' => $pointSale, | |||
'quantity' => $quantity |
@@ -186,10 +186,6 @@ var app = new Vue({ | |||
} | |||
} | |||
if(response.data.categories) { | |||
app.categories = response.data.categories ; | |||
app.setCategoryCurrent(response.data.categories[0]) ; | |||
} | |||
app.producer = response.data.producer; | |||
app.user = response.data.user; | |||
app.useCredit = response.data.producer.use_credit_checked_default; | |||
@@ -251,6 +247,16 @@ var app = new Vue({ | |||
} | |||
} | |||
if(response.data.categories) { | |||
app.categories = response.data.categories ; | |||
if(app.countProductsByCategory(response.data.categories[0])) { | |||
app.setCategoryCurrent(response.data.categories[0]) ; | |||
} | |||
else { | |||
app.setCategoryCurrent(response.data.categories[1]) ; | |||
} | |||
} | |||
setTimeout(function() { | |||
app.responsive(); | |||
opendistrib_products(); |