Browse Source

Merge branch 'develop'

master
Guillaume 1 year ago
parent
commit
6dee542b12
33 changed files with 440 additions and 156 deletions
  1. +2
    -1
      backend/controllers/DashboardController.php
  2. +1
    -1
      backend/controllers/DocumentController.php
  3. +4
    -5
      backend/controllers/StatsController.php
  4. +2
    -2
      backend/models/MailForm.php
  5. +108
    -68
      backend/views/dashboard/index.php
  6. +9
    -0
      backend/views/distribution/index.php
  7. +1
    -1
      backend/views/distribution/shopping-cart-labels.php
  8. +1
    -1
      backend/views/document/download.php
  9. +14
    -1
      backend/views/stats/index.php
  10. +10
    -0
      backend/views/support/index.php
  11. +7
    -0
      backend/web/js/vuejs/distribution-index.js
  12. +11
    -9
      backend/web/js/vuejs/document-form.js
  13. +6
    -2
      common/components/AbstractApi.php
  14. +11
    -0
      common/components/ForumFlarumClient.php
  15. +11
    -6
      common/config/main.php
  16. +1
    -1
      common/config/params.php
  17. +7
    -1
      common/logic/Distribution/Distribution/Export/DistributionReportPdfGenerator.php
  18. +36
    -1
      common/logic/Distribution/Distribution/Export/DistributionShoppingCartLabelsPdfGenerator.php
  19. +11
    -7
      common/logic/Document/Document/Service/DocumentSolver.php
  20. +43
    -13
      common/logic/Producer/Producer/Repository/ProducerRepository.php
  21. +24
    -1
      common/logic/Product/Product/Service/ProductSolver.php
  22. +4
    -2
      common/logic/Setting/SettingDetails/Admin/AdminSettingDefinition.php
  23. +17
    -0
      common/logic/Setting/SettingDetails/Admin/General/ForumFlarumUrlAdminSetting.php
  24. +1
    -2
      common/logic/Subscription/Subscription/Repository/SubscriptionRepository.php
  25. +3
    -9
      common/logic/Subscription/Subscription/Repository/SubscriptionRepositoryQuery.php
  26. +4
    -1
      common/logic/User/User/Service/UserSolver.php
  27. +29
    -0
      common/versions/23.12.C.php
  28. +25
    -0
      common/versions/24.1.A.php
  29. +6
    -0
      frontend/views/layouts/main.php
  30. +3
    -1
      producer/controllers/OrderController.php
  31. +7
    -1
      producer/views/order/order.php
  32. +19
    -18
      producer/web/css/screen.css
  33. +2
    -1
      producer/web/sass/order/_order.scss

+ 2
- 1
backend/controllers/DashboardController.php View File

@@ -80,7 +80,8 @@ class DashboardController extends BackendController
'pointsSaleCount' => $this->getPointSaleModule()->getRepository()->countPointSales(),
'distributionsArray' => $this->getDistributionModule()->getRepository()->findDistributionsDashboard(),
'ordersArray' => $this->getOrderModule()->getRepository()->findOrdersDashboard(),
'subscriptionsLatestAddedArray' => $this->getSubscriptionModule()->getRepository()->findSubscriptionsLatestAdded()
'subscriptionsLatestAddedArray' => $this->getSubscriptionModule()->getRepository()->findSubscriptionsLatestAdded(),
'forumDiscussionsArray' => \Yii::$app->forumFlarumClient->getLastDiscussions()
]);
}
}

+ 1
- 1
backend/controllers/DocumentController.php View File

@@ -300,7 +300,7 @@ class DocumentController extends BackendController
'Code Classification vente',
];

foreach ($documentModule->getProductsOrders($document) as $productOrderArray) {
foreach ($documentModule->getProductsOrders($document, true) as $productOrderArray) {
foreach ($productOrderArray as $productOrder) {

$price = $productOrder->getPrice();

+ 4
- 5
backend/controllers/StatsController.php View File

@@ -67,19 +67,18 @@ class StatsController extends BackendController
/**
* Affiche le CA réalisé par mois sur une année donnée
*/
public function actionIndex(int $year = null)
public function actionIndex(int $year = null, string $displayBy = 'month')
{
$producerModule = $this->getProducerModule();
$producerCurrent = $this->getProducerCurrent();

if(!$year) {
$year = date('Y');
}

$yearsWithTurnoverArray = $producerModule->getYearsWithTurnover($producerCurrent);
$dataChartTurnover = $producerModule->getDatasChartTurnoverStatistics($producerCurrent, $year);
$yearsWithTurnoverArray = $this->getProducerModule()->getRepository()->getYearsWithTurnover($producerCurrent);
$dataChartTurnover = $this->getProducerModule()->getRepository()->getDatasChartTurnoverStatistics($producerCurrent, $year, $displayBy);

return $this->render('index', [
'displayBy' => $displayBy,
'yearCurrent' => $year,
'dataLabels' => $dataChartTurnover['labels'],
'data' => $dataChartTurnover['data'],

+ 2
- 2
backend/models/MailForm.php View File

@@ -194,9 +194,9 @@ Me désinscrire : ".$linkUnsubscribe;
}

// Tests
$usersArray = [
/*$usersArray = [
['email' => 'contact@guillaumebourgeois.fr', 'name' => '', 'lastname' => '']
];
];*/

foreach($usersArray as $user) {
$body['Messages'][] = [

+ 108
- 68
backend/views/dashboard/index.php View File

@@ -41,6 +41,7 @@ use common\logic\Distribution\Distribution\Module\DistributionModule;
use common\logic\Order\Order\Model\Order;
use common\logic\Order\Order\Module\OrderModule;
use common\logic\Producer\Producer\Module\ProducerModule;
use common\logic\Setting\SettingModule;
use common\logic\Subscription\Subscription\Module\SubscriptionModule;
use common\logic\User\User\Module\UserModule;
use yii\helpers\Html ;
@@ -50,90 +51,129 @@ $userModule = UserModule::getInstance();
$orderModule = OrderModule::getInstance();
$subscriptionModule = SubscriptionModule::getInstance();
$producerModule = ProducerModule::getInstance();
$settingModule = SettingModule::getInstance();
$adminSettingBag = $settingModule->getAdminSettingBag();

$this->setTitle('Tableau de bord');

?>
<div class="dashboard-index">

<?php if(Yii::$app->request->get('error_products_points_sale')): ?>
<div class="alert alert-warning">
Vous devez ajouter <?php if(!$productsCount): ?> des produits<?php endif; ?>
<?php if(!$productsCount && !$pointsSaleCount): ?> et<?php endif; ?>
<?php if(!$pointsSaleCount): ?> un ou des points de vente <?php endif; ?>
avant d'effectuer cette action.
</div>
<?php endif; ?>
<div <?php if($adminSettingBag->get('forumFlarumUrl')): ?>class="col-md-8"<?php endif; ?>>
<?php if(Yii::$app->request->get('error_products_points_sale')): ?>
<div class="alert alert-warning">
Vous devez ajouter <?php if(!$productsCount): ?> des produits<?php endif; ?>
<?php if(!$productsCount && !$pointsSaleCount): ?> et<?php endif; ?>
<?php if(!$pointsSaleCount): ?> un ou des points de vente <?php endif; ?>
avant d'effectuer cette action.
</div>
<?php endif; ?>

<?php if(!$productsCount): ?>
<div class="info-box">
<span class="info-box-icon bg-yellow"><i class="fa fa-clone"></i></span>
<div class="info-box-content">
<span class="info-box-text"><br /><?= Html::a('Ajouter des produits', ['product/create'], ['class' => 'btn btn-default']); ?></span>
<?php if(!$productsCount): ?>
<div class="info-box">
<span class="info-box-icon bg-yellow"><i class="fa fa-clone"></i></span>
<div class="info-box-content">
<span class="info-box-text"><br /><?= Html::a('Ajouter des produits', ['product/create'], ['class' => 'btn btn-default']); ?></span>
</div>
</div>
</div>
<?php endif; ?>
<?php endif; ?>

<?php if(!$pointsSaleCount): ?>
<div class="info-box">
<span class="info-box-icon bg-yellow"><i class="fa fa-map-marker"></i></span>
<div class="info-box-content">
<span class="info-box-text"><br /><?= Html::a('Ajouter des points de vente', ['point-sale/create'], ['class' => 'btn btn-default']); ?></span>
<?php if(!$pointsSaleCount): ?>
<div class="info-box">
<span class="info-box-icon bg-yellow"><i class="fa fa-map-marker"></i></span>
<div class="info-box-content">
<span class="info-box-text"><br /><?= Html::a('Ajouter des points de vente', ['point-sale/create'], ['class' => 'btn btn-default']); ?></span>
</div>
</div>
</div>
<?php endif; ?>
<?php endif; ?>

<?php if($productsCount && $pointsSaleCount && !count($distributionsArray)): ?>
<div class="info-box">
<span class="info-box-icon bg-yellow"><i class="fa fa-calendar"></i></span>
<div class="info-box-content">
<span class="info-box-text"><br /><?= Html::a('Ajouter des jours de distribution', ['distribution/index'], ['class' => 'btn btn-default']); ?></span>
<?php if($productsCount && $pointsSaleCount && !count($distributionsArray)): ?>
<div class="info-box">
<span class="info-box-icon bg-yellow"><i class="fa fa-calendar"></i></span>
<div class="info-box-content">
<span class="info-box-text"><br /><?= Html::a('Ajouter des jours de distribution', ['distribution/index'], ['class' => 'btn btn-default']); ?></span>
</div>
</div>
<?php endif; ?>

<?php if(count($distributionsArray)): ?>
<div id="distributions">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">
Prochaines distributions
</h3>
</div>
<div class="panel-body">
<!-- distributions -->
<?php foreach($distributionsArray as $distribution): ?>
<div class="col-md-6 col-sm-12 col-xs-12">
<div class="info-box">
<span class="info-box-icon bg-green date">
<span class="day"><?= strftime('%A', strtotime($distribution->date)) ?></span>
<span class="num"><?= date('d', strtotime($distribution->date)) ?></span>
<span class="month"><?= strftime('%B', strtotime($distribution->date)) ?></span>
</span>
<div class="info-box-content">
<span class="info-box-text">
<?php if(count($distribution->order)): ?>
<strong><?= count($distribution->order); ?></strong> COMMANDES
<?php else: ?>
AUCUNE COMMANDE
<?php endif; ?>
</span>
<span class="info-box-number"></span>
<div class="buttons">
<?= Html::a('<span class="fa fa-eye"></span>', ['distribution/index', 'date' => $distribution->date], ['class' => 'btn btn-default']); ?>
<?php if(count($distribution->order)): ?>
<?php
$exportsEnabledArray = $distributionModule->getExportManager()->getAllEnabled();
foreach($exportsEnabledArray as $name => $export) {
echo Html::a('<span class="fa fa-download"></span>', ['distribution/export', 'name' => $name, 'date' => $distribution->date], ['class' => 'btn btn-default', 'title' => $export[0]]).' ';
}
?>
<?php endif; ?>
</div>
</div>
</div>
</div>
<?php endforeach; ?>
</div>
</div>
</div>
<?php endif; ?>
<?php endif; ?>
</div>

<?php if(count($distributionsArray)): ?>
<div id="distributions">
<?php if($adminSettingBag->get('forumFlarumUrl')): ?>
<div class="col-md-4">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">
Prochaines distributions
</h3>
<h3 class="panel-title">
Derniers sujets sur le forum
</h3>
</div>
<div class="panel-body">
<!-- distributions -->
<?php foreach($distributionsArray as $distribution): ?>
<div class="col-md-4 col-sm-12 col-xs-12">
<div class="info-box">
<span class="info-box-icon bg-green date">
<span class="day"><?= strftime('%A', strtotime($distribution->date)) ?></span>
<span class="num"><?= date('d', strtotime($distribution->date)) ?></span>
<span class="month"><?= strftime('%B', strtotime($distribution->date)) ?></span>
</span>
<div class="info-box-content">
<span class="info-box-text">
<?php if(count($distribution->order)): ?>
<strong><?= count($distribution->order); ?></strong> COMMANDES
<?php else: ?>
AUCUNE COMMANDE
<?php endif; ?>
</span>
<span class="info-box-number"></span>
<div class="buttons">
<?= Html::a('<span class="fa fa-eye"></span>', ['distribution/index', 'date' => $distribution->date], ['class' => 'btn btn-default']); ?>
<?php if(count($distribution->order)): ?>
<?php
$exportsEnabledArray = $distributionModule->getExportManager()->getAllEnabled();
foreach($exportsEnabledArray as $name => $export) {
echo Html::a('<span class="fa fa-download"></span>', ['distribution/export', 'name' => $name, 'date' => $distribution->date], ['class' => 'btn btn-default', 'title' => $export[0]]).' ';
}
?>
<?php endif; ?>
</div>
</div>
</div>
</div>
<?php endforeach; ?>
<?php //echo print_r($forumDiscussionsArray); ?>
<?php if($forumDiscussionsArray && count($forumDiscussionsArray['data'])): ?>
<table class="table">
<?php $forumDiscussionsLimitedArray = array_slice($forumDiscussionsArray['data'], 0, min(3, count($forumDiscussionsArray['data']))); ?>
<?php foreach($forumDiscussionsLimitedArray as $forumDiscussion): ?>
<tr>
<?php //echo print_r($forumDiscussion); ?>
<td><?= $forumDiscussion['attributes']['title']; ?></td>
<td><?= date('d/m à H:i', strtotime($forumDiscussion['attributes']['lastPostedAt'])); ?></td>
</tr>
<?php endforeach; ?>
</table>
<?php else: ?>
<p>Aucun sujet sur le forum.</p>
<?php endif; ?>
<p>
<a href="<?= $settingModule->getAdminSettingBag()->get('forumFlarumUrl'); ?>" class="btn btn-default">
<span class="fa fa-comments"></span>
Consulter le forum
</a>
</p>
</div>
</div>
</div>
@@ -147,7 +187,7 @@ $this->setTitle('Tableau de bord');
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">
Derniers abonnements créés
Derniers abonnements créés/modifiés
</h3>
</div>
<div class="panel-body">
@@ -166,7 +206,7 @@ $this->setTitle('Tableau de bord');
<tbody>
<?php foreach($subscriptionsLatestAddedArray as $subscription): ?>
<tr>
<td><?= date('d/m/Y à H:i', strtotime($subscription->created_at)); ?></td>
<td><?= date('d/m/Y à H:i', strtotime($subscription->updated_at ?: $subscription->created_at)); ?></td>
<td><?= $userModule->getUsername($subscription->user); ?></td>
<td><?= Html::encode($subscription->pointSale->name); ?></td>
<td><?= $subscriptionModule->getProductsListAsHtml($subscription); ?></td>

+ 9
- 0
backend/views/distribution/index.php View File

@@ -294,6 +294,11 @@ $this->setPageTitle('Distributions') ;
<button id="btn-add-subscriptions" @click="addSubscriptions" class="btn btn-default btn-xs"><span class="glyphicon glyphicon-plus"></span> Importer les abonnements</button>
<template v-if="producer && producer.tiller == true">
<button v-if="tillerIsSynchro" id="btn-tiller" class="btn btn-success btn-xs" disabled><span class="glyphicon glyphicon-refresh"></span> Synchronisé avec Tiller</button>
<template v-else-if="!isDistributionToday()">
<span data-toggle="tooltip" data-placement="top" data-original-title="Synchronisation possible uniquement le jour de la distribution">
<button id="btn-tiller" class="btn btn-xs btn-default" disabled><span class="glyphicon glyphicon-refresh"></span> Synchroniser avec Tiller</button>
</span>
</template>
<button v-else id="btn-tiller" class="btn btn-xs btn-default" @click="synchroTiller"><span class="glyphicon glyphicon-refresh"></span> Synchroniser avec Tiller</button>
</template>
<button v-if="producer && producer.credit" id="btn-pay-orders" class="btn btn-default btn-xs" @click="payOrders"><span class="glyphicon glyphicon-euro"></span> Débiter les commandes</button>
@@ -644,6 +649,10 @@ $this->setPageTitle('Distributions') ;
<a v-if="producer && producer.credit && order.id_user > 0 && user.id_user == order.id_user" class="btn btn-xs btn-primary btn-credit" :href="baseUrl+'/user/credit?id='+user.id_user" v-for="user in users">{{ parseFloat(user.credit).toFixed(2).replace(/(\d)(?=(\d{3})+(?:\.\d+)?$)/g, "$1,")+'&nbsp;€' }}</a>
<label class="control-label" for="select-id-user">
Utilisateur
<a v-if="!order.id_user || order.id_user == 0" class="btn btn-default btn-xs" href="<?= Yii::$app->urlManager->createUrl('user/create'); ?>">
<span class="glyphicon glyphicon-plus"></span>
Créer un utilisateur
</a>
</label>
<select class="form-control select2-order-form" v-model="order.id_user" @change="userChange">
<option value="0">--</option>

+ 1
- 1
backend/views/distribution/shopping-cart-labels.php View File

@@ -8,7 +8,7 @@ $i = 0;
foreach($ordersArray as $key => $order) {
$index ++;

echo $distributionShoppingCartLabelsPdfGenerator->getShoppingCartLabelAsHtml($order, $index);
echo $distributionShoppingCartLabelsPdfGenerator->getShoppingCartLabelAsHtml($order, $index, $isSpecificFormat);

if($index == $shoppingCartLabelsPerColumn) {
$index = 0;

+ 1
- 1
backend/views/document/download.php View File

@@ -137,7 +137,7 @@ $documentPriceDecimals = (int) $producerModule->getConfig('option_document_price
<?php endforeach; ?>
<?php endforeach; ?>
<?php else: ?>
<?php foreach ($documentModule->getProductsOrders($document) as $product): ?>
<?php foreach ($documentModule->getProductsOrders($document, true) as $product): ?>
<?php foreach ($product as $productOrder): ?>
<?= $this->render('_download_product_line', [
'producer' => $producer,

+ 14
- 1
backend/views/stats/index.php View File

@@ -44,13 +44,26 @@ $this->addBreadcrumb('Statistiques (chiffre d\'affaire)') ;

?>

Affichage :
<?php
echo Html::a('Mois',
['stats/index', 'year' => $yearCurrent, 'displayBy' => 'month'],
['class' => 'btn btn-xs '.(($displayBy == 'month') ? 'btn-primary' : 'btn-default')]).' ';
echo Html::a('Semaine',
['stats/index', 'year' => $yearCurrent, 'displayBy' => 'week'],
['class' => 'btn btn-xs '.(($displayBy == 'week') ? 'btn-primary' : 'btn-default')]).' ';

?>

<br><br>

<?php
foreach($yearsWithTurnoverArray as $year) {
$classBtn = 'btn-default';
if($yearCurrent == $year) {
$classBtn = 'btn-primary';
}
echo Html::a($year, ['stats/index', 'year' => $year], ['class' => 'btn '.$classBtn]).' ';
echo Html::a($year, ['stats/index', 'year' => $year, 'displayBy' => $displayBy], ['class' => 'btn '.$classBtn]).' ';
}
?>


+ 10
- 0
backend/views/support/index.php View File

@@ -98,6 +98,16 @@ $this->addBreadcrumb($this->getTitle());
</div>
</div>
</div>
<?php if($adminSettingBag->get('forumFlarumUrl')): ?>
<div class="col-md-6 col-left">
<div class="info-box">
<span class="info-box-icon bg-yellow"><i class="fa fa-users"></i></span>
<div class="info-box-content">
<span class="info-box-text"><br/><?= Html::a("Ouvrir une discussion sur le forum", $adminSettingBag->get('forumFlarumUrl'), ['class' => 'btn btn-sm btn-default', 'target' => '_blank']); ?></span>
</div>
</div>
</div>
<?php endif; ?>
</div>
<div class="clr"></div>
<?php endif; ?>

+ 7
- 0
backend/web/js/vuejs/distribution-index.js View File

@@ -150,6 +150,13 @@ var app = new Vue({
}
return false;
},
isDistributionToday: function() {
var today = new Date();
return this.date
&& today.getFullYear() == this.date.getFullYear()
&& today.getMonth() == this.date.getMonth()
&& today.getDay() == this.date.getDay();
},
init: function (idActivePointSale) {
var app = this;
this.showLoading = true;

+ 11
- 9
backend/web/js/vuejs/document-form.js View File

@@ -249,17 +249,19 @@ var app = new Vue({
var pricesArray = product.prices;
var unitCoefficient = product.unit_coefficient;

if (theQuantity) {
theQuantity = theQuantity / unitCoefficient;
}
if(pricesArray && unitCoefficient) {
if (theQuantity) {
theQuantity = theQuantity / unitCoefficient;
}

for (var i = 0; i < pricesArray.length; i++) {
if(pricesArray[i]) {
var price = pricesArray[i].price;
var fromQuantity = pricesArray[i].from_quantity;
for (var i = 0; i < pricesArray.length; i++) {
if(pricesArray[i]) {
var price = pricesArray[i].price;
var fromQuantity = pricesArray[i].from_quantity;

if (price < thePrice && fromQuantity <= theQuantity) {
thePrice = price;
if (price < thePrice && fromQuantity <= theQuantity) {
thePrice = price;
}
}
}
}

+ 6
- 2
common/components/AbstractApi.php View File

@@ -11,7 +11,7 @@ abstract class AbstractApi
public string $url;
public array $auth;

public function __construct(string $url, array $auth)
public function __construct(string $url, array $auth = [])
{
$this->url = $url;
$this->auth = $auth;
@@ -41,7 +41,11 @@ abstract class AbstractApi
private function getClient()
{
$curl = new Curl();
$curl->setHeader($this->auth[0], $this->auth[1]);

if(count($this->auth)) {
$curl->setHeader($this->auth[0], $this->auth[1]);
}

return $curl;
}


+ 11
- 0
common/components/ForumFlarumClient.php View File

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

namespace common\components;

class ForumFlarumClient extends AbstractApi
{
public function getLastDiscussions()
{
return $this->get('discussions', ['offset' => 1]);
}
}

+ 11
- 6
common/config/main.php View File

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

use common\components\BusinessLogic;
use common\components\DolibarrApi;
use common\components\ForumFlarumClient;
use common\logic\Distribution\Distribution\Model\Distribution;
use common\logic\Document\DeliveryNote\Model\DeliveryNote;
use common\logic\Order\Order\Model\Order;
@@ -83,6 +84,16 @@ return [
'alwaysdataClient' => [
'class' => 'common\components\AlwaysdataClient'
],
'forumFlarumClient' => function() {

return new ForumFlarumClient(Yii::$app->logic->getSettingModule()->getAdminSettingBag()->get('forumFlarumUrl').'api/');
},
'dolibarrApi' => function() {
return new DolibarrApi(
Yii::$app->parameterBag->get('dolibarrApiUrl'),
['DOLAPIKEY', \Yii::$app->parameterBag->get('dolibarrApiKey')]
);
},
'assetManager' => [
'linkAssets' => YII_ENV == "dev" ? 'true' : false,
],
@@ -167,12 +178,6 @@ return [
'enableStrictParsing' => false,
'rules' => [],
],
'dolibarrApi' => function() {
return new DolibarrApi(
Yii::$app->parameterBag->get('dolibarrApiUrl'),
['DOLAPIKEY', \Yii::$app->parameterBag->get('dolibarrApiKey')]
);
},
'logic' => function () {
return new BusinessLogic();
},

+ 1
- 1
common/config/params.php View File

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

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

+ 7
- 1
common/logic/Distribution/Distribution/Export/DistributionReportPdfGenerator.php View File

@@ -119,6 +119,10 @@ class DistributionReportPdfGenerator extends AbstractGenerator implements Distri
.payment-detail-remaining-surplus {
font-size: 10px;
}
.td-order-amount.is-order-paid {
background-color: #ddd;
}
',
'methods' => [
'SetHeader' => ['Commandes du ' . date('d/m/Y', strtotime($distribution->date))],
@@ -293,7 +297,9 @@ class DistributionReportPdfGenerator extends AbstractGenerator implements Distri

public function columnOrderAmount(Order $order): string
{
$html = '<td class="td-order-amount"><strong>'.number_format($order->amount_with_tax, 2) . ' €</strong>';
$isOrderPaid = $this->orderRepository->isOrderPaid($order);

$html = '<td class="td-order-amount'.(($isOrderPaid) ? ' is-order-paid' : '').'"><strong>'.number_format($order->amount_with_tax, 2) . ' €</strong>';

$paymentLabelPaid = $this->orderRepository->getPaymentLabelPaid($order);
if($paymentLabelPaid && strlen($paymentLabelPaid)) {

+ 36
- 1
common/logic/Distribution/Distribution/Export/DistributionShoppingCartLabelsPdfGenerator.php View File

@@ -9,6 +9,7 @@ use common\logic\Feature\Feature\FeatureChecker;
use common\logic\Feature\Feature\FeatureManager;
use common\logic\Order\Order\Model\Order;
use common\logic\Order\Order\Repository\OrderRepository;
use common\logic\Order\Order\Service\OrderBuilder;
use common\logic\Order\Order\Service\OrderSolver;
use common\logic\Producer\Producer\Service\ProducerSolver;
use kartik\mpdf\Pdf;
@@ -24,6 +25,7 @@ class DistributionShoppingCartLabelsPdfGenerator extends AbstractGenerator imple
protected OrderRepository $orderRepository;
protected OrderSolver $orderSolver;
protected FeatureChecker $featureChecker;
protected OrderBuilder $orderBuilder;

public function loadDependencies(): void
{
@@ -31,6 +33,7 @@ class DistributionShoppingCartLabelsPdfGenerator extends AbstractGenerator imple
$this->orderRepository = $this->loadService(OrderRepository::class);
$this->orderSolver = $this->loadService(OrderSolver::class);
$this->featureChecker = $this->loadService(FeatureChecker::class);
$this->orderBuilder = $this->loadService(OrderBuilder::class);
}

public function getSpecificFormatDetailsArray(): array
@@ -57,6 +60,10 @@ class DistributionShoppingCartLabelsPdfGenerator extends AbstractGenerator imple
$ordersArray = $this->orderRepository->findOrdersByDistribution($distribution);
$ordersArray = $this->filterOrdersExcludedUsersAndPointSales($ordersArray);

foreach($ordersArray as $order) {
$this->orderBuilder->initOrder($order);
}

$content = \Yii::$app->getView()->render('@backend/views/distribution/shopping-cart-labels.php', [
'distribution' => $distribution,
'ordersArray' => $ordersArray,
@@ -161,6 +168,21 @@ class DistributionShoppingCartLabelsPdfGenerator extends AbstractGenerator imple
height: '.$specificFormatHeight.'mm;
display: block;
float: left;
}
.shopping-cart-label .amount-and-payment {
margin-top: 8px;
font-size: 10px;
/*border-top: dotted 1px gray;*/
}
.shopping-cart-label .amount-and-payment .amount {
display: inline-block;
background-color: #e0e0e0;
color: #333;
font-weight: bold;
padding: 3px 8px;
border-radius: 8px;
}';
}
else {
@@ -181,8 +203,20 @@ class DistributionShoppingCartLabelsPdfGenerator extends AbstractGenerator imple
return $css;
}

public function getShoppingCartLabelAsHtml(Order $order, int $index): string
public function getShoppingCartLabelAsHtml(Order $order, int $index, bool $isSpecificFormat): string
{
$amountAndPayment = '';
if($isSpecificFormat) {
$amountAndPayment = '<div class="amount-and-payment">';
$amountAndPayment .= '<span class="amount">'.$this->orderSolver->getOrderAmountWithTax($order, Order::AMOUNT_TOTAL, true).'</span>';

$paymentLabelPaid = $this->orderRepository->getPaymentLabelPaid($order);
if($paymentLabelPaid && strlen($paymentLabelPaid)) {
$amountAndPayment .= ' / '.$paymentLabelPaid;
}
$amountAndPayment .= '</div>';
}

return '<div class="shopping-cart-label shopping-cart-label-'.$index.'">
<div class="inner">
<div class="username">
@@ -195,6 +229,7 @@ class DistributionShoppingCartLabelsPdfGenerator extends AbstractGenerator imple
<div class="products">
'.$this->orderRepository->getCartSummary($order).'
</div>
'.$amountAndPayment.'
</div>
</div>';
}

+ 11
- 7
common/logic/Document/Document/Service/DocumentSolver.php View File

@@ -189,7 +189,7 @@ class DocumentSolver extends AbstractService implements SolverInterface
return $this->isStatus($document, Document::STATUS_VALID);
}

public function getProductsOrders(DocumentInterface $document): array
public function getProductsOrders(DocumentInterface $document, bool $groupByInvoicePrice = false): array
{
$productsOrdersArray = [];
$ordersArray = $document->orders;
@@ -205,12 +205,16 @@ class DocumentSolver extends AbstractService implements SolverInterface
} else {
$productOrderMatch = false;
foreach ($productsOrdersArray[$indexProductOrder] as &$theProductOrder) {
if ($theProductOrder->unit == $productOrder->unit
&& $theProductOrder->price == $productOrder->price
&& $theProductOrder->invoice_price == $productOrder->invoice_price) {

$theProductOrder->quantity += $productOrder->quantity;
$productOrderMatch = true;
if ($theProductOrder->unit == $productOrder->unit) {
if($groupByInvoicePrice && $theProductOrder->invoice_price == $productOrder->invoice_price) {
$theProductOrder->quantity += $productOrder->quantity;
$productOrderMatch = true;
}
elseif($theProductOrder->price == $productOrder->price
&& $theProductOrder->invoice_price == $productOrder->invoice_price) {
$theProductOrder->quantity += $productOrder->quantity;
$productOrderMatch = true;
}
}
}
if (!$productOrderMatch) {

+ 43
- 13
common/logic/Producer/Producer/Repository/ProducerRepository.php View File

@@ -152,6 +152,25 @@ class ProducerRepository extends AbstractRepository
$period = date('Y-m');
}

$dateStart = date('Y-m-31', strtotime("-1 month", strtotime($period)));
$dateEnd = date('Y-m-01', strtotime("+1 month", strtotime($period)));

return $this->getTurnoverByDateStartEnd($producer, $dateStart, $dateEnd, $format);
}

public function getTurnoverByWeek(Producer $producer, int $year, int $week, bool $format = false)
{
$date = new \DateTime();
$date->setISODate($year, $week);
$dateStart = $date->format('Y-m-d');
$date->modify('+6 days');
$dateEnd = $date->format('Y-m-d');

return $this->getTurnoverByDateStartEnd($producer, $dateStart, $dateEnd, $format);
}

public function getTurnoverByDateStartEnd(Producer $producer, string $dateStart, string $dateEnd, bool $format = false)
{
$connection = \Yii::$app->getDb();
$command = $connection->createCommand(
'
@@ -160,11 +179,11 @@ class ProducerRepository extends AbstractRepository
WHERE `order`.id = product_order.id_order
AND distribution.id_producer = :id_producer
AND `order`.id_distribution = distribution.id
AND distribution.date > :date_begin
AND distribution.date > :date_start
AND distribution.date < :date_end',
[
':date_begin' => date('Y-m-31', strtotime("-1 month", strtotime($period))),
':date_end' => date('Y-m-01', strtotime("+1 month", strtotime($period))),
':date_start' => $dateStart,
':date_end' => $dateEnd,
':id_producer' => $producer->id
]
);
@@ -198,9 +217,11 @@ class ProducerRepository extends AbstractRepository
return $this->producerPriceRangeRepository->getAmountToBeBilledByTurnover($turnover, $format);
}

public function getDatasChartTurnoverStatistics(Producer $producer, int $year)
public function getDatasChartTurnoverStatistics(Producer $producer, int $year, string $displayBy = 'month')
{
$interval = new \DateInterval('P1M');
$data = [];
$dataLabels = [];

$start = new \DateTime($year.'-01-01');
if($year == date('Y')) {
$end = new \DateTime('last day of this month');
@@ -208,16 +229,25 @@ class ProducerRepository extends AbstractRepository
else {
$end = new \DateTime($year.'-12-31');
}
$period = new \DatePeriod($start, $interval, $end);

$data = [];
$dataLabels = [];
$interval = new \DateInterval(($displayBy == 'week') ? 'P1W' : 'P1M');
$period = new \DatePeriod($start, $interval, $end);

foreach ($period as $date) {
$month = $date->format('m/Y');
$dataLabels[] = $month;
$turnover = $this->getTurnover($producer, $date->format('Y-m'));
$data[$month] = $turnover;
if($displayBy == 'week') {
foreach ($period as $date) {
$week = $date->format('W');
$dataLabels[] = $week;
$turnover = $this->getTurnoverByWeek($producer, $year, $date->format('W'));
$data[$week] = $turnover;
}
}
else {
foreach ($period as $date) {
$month = $date->format('m/Y');
$dataLabels[] = $month;
$turnover = $this->getTurnover($producer, $date->format('Y-m'));
$data[$month] = $turnover;
}
}

// création d'un tableau sans index car chart.js n'accepte pas les index

+ 24
- 1
common/logic/Product/Product/Service/ProductSolver.php View File

@@ -7,6 +7,7 @@ use common\helpers\Price;
use common\logic\AbstractService;
use common\logic\Config\Unit\Service\UnitDefinition;
use common\logic\Config\Unit\Service\UnitSolver;
use common\logic\Order\ProductOrder\Model\ProductOrder;
use common\logic\PointSale\PointSale\Model\PointSale;
use common\logic\PointSale\PointSale\Service\PointSaleSolver;
use common\logic\Product\Product\Model\Product;
@@ -98,6 +99,24 @@ class ProductSolver extends AbstractService implements SolverInterface
return $product->price;
}

public function getPriceUnitReference(Product $product): ?float
{
$productPrice = $product->price;
if($product->unit == 'piece') {
if($product->weight) {
$price = (1000 * $productPrice) / $product->weight;
}
else {
return null;
}
}
else {
$price = $product->price;
}

return $price;
}

/**
* Retourne le prix du produit avec taxe
*/
@@ -188,7 +207,11 @@ class ProductSolver extends AbstractService implements SolverInterface
return $product->reference;
}

return $product->name;
$productName = $product->name;
// le caractère "<" crée un problème dans le récapitulatif PDF des commandes
$productName = str_replace('<', '', $productName);

return $productName;
}

public function isProductActiveByDay(Product $product, string $day): bool

+ 4
- 2
common/logic/Setting/SettingDetails/Admin/AdminSettingDefinition.php View File

@@ -5,6 +5,7 @@ namespace common\logic\Setting\SettingDetails\Admin;
use common\logic\Setting\SettingDefinition;
use common\logic\Setting\SettingDetails\Admin\General\AdministratorEmailAdminSetting;
use common\logic\Setting\SettingDetails\Admin\General\AdministratorPhoneNumberAdminSetting;
use common\logic\Setting\SettingDetails\Admin\General\ForumFlarumUrlAdminSetting;

class AdminSettingDefinition extends SettingDefinition
{
@@ -16,8 +17,9 @@ class AdminSettingDefinition extends SettingDefinition
return [
self::SECTION_GENERAL => [
self::SUBSECTION_GENERAL => [
new AdministratorEmailAdminSetting,
new AdministratorPhoneNumberAdminSetting,
new AdministratorEmailAdminSetting(),
new AdministratorPhoneNumberAdminSetting(),
new ForumFlarumUrlAdminSetting(),
]
],
];

+ 17
- 0
common/logic/Setting/SettingDetails/Admin/General/ForumFlarumUrlAdminSetting.php View File

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

namespace common\logic\Setting\SettingDetails\Admin\General;

use common\logic\Setting\SettingDetails\AbstractSettingDetail;

class ForumFlarumUrlAdminSetting extends AbstractSettingDetail
{
public function __construct()
{
$this
->setName('forumFlarumUrl')
->setLabel("Url du forum Flarum")
->setTypeString()
->setFormTypeInput();
}
}

+ 1
- 2
common/logic/Subscription/Subscription/Repository/SubscriptionRepository.php View File

@@ -71,8 +71,7 @@ class SubscriptionRepository extends AbstractRepository
public function findSubscriptionsLatestAdded()
{
return $this->createDefaultQuery()
->filterByCreatedDuringPastWeek()
->filterByCreatedByUser()
->filterByCreatedOrUpdatedByUserDuringPastWeek()
->find();
}
}

+ 3
- 9
common/logic/Subscription/Subscription/Repository/SubscriptionRepositoryQuery.php View File

@@ -21,17 +21,11 @@ class SubscriptionRepositoryQuery extends AbstractRepositoryQuery
return $this;
}

public function filterByCreatedDuringPastWeek(): self
public function filterByCreatedOrUpdatedByUserDuringPastWeek(): self
{
$datePastWeek = new \DateTime('-7 days');
$this->andWhere('subscription.created_at >= :created_at')
->addParams(['created_at' => $datePastWeek->format('Y-m-d H:i:s')]);
return $this;
}

public function filterByCreatedByUser(): self
{
$this->andWhere('subscription.id_user = subscription.id_created_by');
$this->andWhere('(subscription.id_user = subscription.id_created_by AND subscription.created_at >= :date_past_week) OR (subscription.id_user = subscription.id_updated_by AND subscription.updated_at >= :date_past_week)')
->addParams(['date_past_week' => $datePastWeek->format('Y-m-d H:i:s')]);
return $this;
}
}

+ 4
- 1
common/logic/User/User/Service/UserSolver.php View File

@@ -98,7 +98,10 @@ class UserSolver extends AbstractService implements SolverInterface

public function getUsername(User $user, $withType = false): string
{
if (isset($user->name_legal_person) && strlen($user->name_legal_person)) {
if ($this->isTypeLegalPerson($user)
&& isset($user->name_legal_person)
&& strlen($user->name_legal_person)) {

$username = $user->name_legal_person;
} else {
$username = $user->lastname . ' ' . $user->name;

+ 29
- 0
common/versions/23.12.C.php View File

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

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

version(
'18/12/2023',
[
[
"[Administration] Tableau de bord : affichage des abonnements modifiés récemment",
"[Administration] Export étiquettes PDF : ajout de l'information du paiement de la commande",
"[Administration] Export commandes PDF : cellule du montant grisée quand la commande est payée",
"[Administration] Statistiques > Chiffre d'affaires : vue semaine par semaine",
],
[
"[Administration] Utilisateur : correctif affichage nom personne légale",
"[Administration] Distributions > Synchronisation Tiller : activation uniquement le jour des distribution",
"[Administration] Export commandes PDF : correctif problème caractère \"<\" dans le nom des produits",
]
],
[
[
],
[
]
],
$userCurrent
);

?>

+ 25
- 0
common/versions/24.1.A.php View File

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

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

version(
'15/01/2024',
[
[
"[Administration] Export commandes PDF : cellule du montant en gris quand la commande est payée",
"[Administration] Distribution > Création commande : ajout lien pour créer un utilisateur",
"[Boutique] Commander : affichage du prix au kg pour les produits vendus à la pièce"
],
[
]
],
[
[
],
[
]
],
$userCurrent
);

?>

+ 6
- 0
frontend/views/layouts/main.php View File

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

use common\helpers\GlobalParam;
use common\logic\Setting\SettingModule;
use common\logic\User\User\Module\UserModule;
use yii\helpers\Html;
use yii\bootstrap\Nav;
@@ -53,6 +54,8 @@ $producer = null;
if ($isUserCurrentGrantedAsProducer) {
$producer = Producer::searchOne(['id' => \Yii::$app->user->identity->id_producer]);
}
$settingModule = SettingModule::getInstance();
$adminSettingBag = $settingModule->getAdminSettingBag();

?>
<?php $this->beginPage() ?>
@@ -173,6 +176,9 @@ if ($isUserCurrentGrantedAsProducer) {
<div class="container">
<a href="<?php echo $this->getUrlManager()->createUrl('site/service'); ?>">Fonctionnalités, services & tarifs</a> <span class="bull">&bull;</span>
<a href="<?php echo $this->getUrlManager()->createUrl('site/opinion'); ?>">Avis & suggestions</a> <span class="bull">&bull;</span>
<?php if($adminSettingBag->get('forumFlarumUrl')): ?>
<!--<a href="<?php echo $adminSettingBag->get('forumFlarumUrl'); ?>">Forum</a> <span class="bull">&bull;</span>-->
<?php endif; ?>
<a href="<?php echo $this->getUrlManager()->createUrl('site/mentions'); ?>">Mentions légales</a> <span class="bull">&bull;</span>
<a href="<?php echo $this->getUrlManager()->createUrl('site/cgv'); ?>">Conditions générales de service</a> <span class="bull">&bull;</span>
<a href="<?php echo $this->getUrlManager()->createUrl('site/source-code'); ?>">Code source</a>

+ 3
- 1
producer/controllers/OrderController.php View File

@@ -158,6 +158,7 @@ class OrderController extends ProducerBaseController
$orderModule = $this->getOrderModule();
$producerModule = $this->getProducerModule();
$userModule = $this->getUserModule();
$productOrderModule = $this->getProductOrderModule();

$producer = $this->getProducerCurrent();
$redirect = null;
@@ -259,7 +260,7 @@ class OrderController extends ProducerBaseController
true
) . ')',
],
'unit_amount' => $productOrder->price * 100 * $productOrder->quantity,
'unit_amount' => intval($productOrderModule->getSolver()->getPriceWithTax($productOrder) * 100 * $productOrder->quantity),
],
'quantity' => 1,
];
@@ -921,6 +922,7 @@ class OrderController extends ProducerBaseController
[
'unit_coefficient' => Product::$unitsArray[$product->unit]['coefficient'],
'prices' => $productModule->getPriceArray($product, $user, $pointSale),
'price_unit_ref' => $productModule->getSolver()->getPriceUnitReference($product),
'productDistribution' => $product['productDistribution'],
'productPointSale' => $product['productPointSale'],
]

+ 7
- 1
producer/views/order/order.php View File

@@ -356,7 +356,13 @@ $this->setTitle('Commander');
<div>
{{ formatPrice(getBestProductPrice(product.id,
product.quantity_form)) }}<br/>
<span class="unit">{{ product.wording_unit }}</span>
<span class="price-infos">{{ product.wording_unit }}</span>
<template v-if="product.unit == 'piece' && product.weight">
<br />
<span class="price-infos">
{{ formatPrice(product.price_unit_ref) }} / kg
</span>
</template>
</div>
<div v-if="productHasPriceWithFromQuantity(product)"
class="alert alert-info decreasing-prices">

+ 19
- 18
producer/web/css/screen.css View File

@@ -1545,20 +1545,21 @@ termes.
text-align: center;
}
/* line 309, ../sass/order/_order.scss */
.order-order #main #app-order-order table#products .price-unit .unit, .order-order #main #app-order-order table#products .price-total .unit {
.order-order #main #app-order-order table#products .price-unit .price-infos, .order-order #main #app-order-order table#products .price-total .price-infos {
color: gray;
font-size: 13px;
line-height: 15px;
}
/* line 314, ../sass/order/_order.scss */
/* line 315, ../sass/order/_order.scss */
.order-order #main #app-order-order table#products .td-quantity {
width: 175px;
}
/* line 316, ../sass/order/_order.scss */
/* line 317, ../sass/order/_order.scss */
.order-order #main #app-order-order table#products .td-quantity input.quantity {
text-align: center;
border-right: 0px none;
}
/* line 320, ../sass/order/_order.scss */
/* line 321, ../sass/order/_order.scss */
.order-order #main #app-order-order table#products .td-quantity .input-group-addon {
padding: 5px;
padding-left: 0px;
@@ -1566,69 +1567,69 @@ termes.
border-left: 0px none;
border-right: 0px none;
}
/* line 331, ../sass/order/_order.scss */
/* line 332, ../sass/order/_order.scss */
.order-order #main #app-order-order table#products tr.total .summary h3 {
margin-top: 0px;
font-family: "capsuularegular";
text-transform: none;
margin-bottom: 5px;
}
/* line 338, ../sass/order/_order.scss */
/* line 339, ../sass/order/_order.scss */
.order-order #main #app-order-order table#products tr.total .summary ul {
margin-bottom: 15px;
padding-left: 20px;
font-size: 23px;
}
/* line 345, ../sass/order/_order.scss */
/* line 346, ../sass/order/_order.scss */
.order-order #main #app-order-order table#products tr.total .summary ul li .quantity {
font-size: 18px;
}
/* line 349, ../sass/order/_order.scss */
/* line 350, ../sass/order/_order.scss */
.order-order #main #app-order-order table#products tr.total .summary ul li .name {
font-family: "capsuularegular";
font-size: 24px;
}
/* line 353, ../sass/order/_order.scss */
/* line 354, ../sass/order/_order.scss */
.order-order #main #app-order-order table#products tr.total .summary ul li .other {
font-family: "capsuularegular";
font-size: 18px;
}
/* line 361, ../sass/order/_order.scss */
/* line 362, ../sass/order/_order.scss */
.order-order #main #app-order-order table#products tr.total .price-total {
font-size: 23px;
}
/* line 369, ../sass/order/_order.scss */
/* line 370, ../sass/order/_order.scss */
.order-order #main #app-order-order #content-step-payment .delivery {
margin-bottom: 20px;
}
/* line 372, ../sass/order/_order.scss */
/* line 373, ../sass/order/_order.scss */
.order-order #main #app-order-order #content-step-payment .delivery .delivery-home {
margin-bottom: 20px;
}
/* line 381, ../sass/order/_order.scss */
/* line 382, ../sass/order/_order.scss */
.order-order #main #app-order-order #content-step-payment .comment {
margin-bottom: 20px;
}
/* line 386, ../sass/order/_order.scss */
/* line 387, ../sass/order/_order.scss */
.order-order #main #app-order-order #content-step-payment .credit .info {
margin-left: 20px;
color: gray;
}
/* line 393, ../sass/order/_order.scss */
/* line 394, ../sass/order/_order.scss */
.order-order #main #app-order-order #specific-delays {
margin-top: 15px;
}
/* line 401, ../sass/order/_order.scss */
/* line 402, ../sass/order/_order.scss */
.order-order #main #app-order-order #infos {
margin-top: 30px;
}
/* line 403, ../sass/order/_order.scss */
/* line 404, ../sass/order/_order.scss */
.order-order #main #app-order-order #infos .panel-body {
padding-top: 0px;
white-space: pre-line;
}

/* line 413, ../sass/order/_order.scss */
/* line 414, ../sass/order/_order.scss */
#main #content .panel h3 {
font-family: "highvoltageregular";
margin: 0px;

+ 2
- 1
producer/web/sass/order/_order.scss View File

@@ -306,9 +306,10 @@
width: 135px ;
text-align: center ;
.unit {
.price-infos {
color: gray ;
font-size: 13px ;
line-height: 15px;
}
}
.td-quantity {

Loading…
Cancel
Save