Преглед на файлове

Merge branch 'develop'

master
Guillaume Bourgeois преди 9 месеца
родител
ревизия
c4a40fd50c
променени са 38 файла, в които са добавени 1495 реда и са изтрити 781 реда
  1. +1
    -1
      backend/controllers/CommunicateController.php
  2. +5
    -1
      backend/controllers/DistributionController.php
  3. +1
    -1
      backend/controllers/ReportController.php
  4. +6
    -1
      backend/controllers/StatsController.php
  5. +15
    -3
      backend/controllers/UserController.php
  6. +16
    -1
      backend/models/MailForm.php
  7. +13
    -7
      backend/views/communicate/email.php
  8. +10
    -7
      backend/views/distribution/index.php
  9. +58
    -56
      backend/views/layouts/left.php
  10. +1
    -3
      backend/views/online-admin/index.php
  11. +2
    -6
      backend/views/producer/update.php
  12. +9
    -0
      backend/views/stats-admin/customer_orders.php
  13. +9
    -0
      backend/views/stats-admin/turnover.php
  14. +80
    -55
      backend/views/stats/index.php
  15. +36
    -84
      backend/views/user/_form.php
  16. +0
    -0
      backend/views/user/_menu_filter.php
  17. +32
    -0
      backend/views/user/_menu_navigation.php
  18. +168
    -121
      backend/views/user/credit.php
  19. +64
    -61
      backend/views/user/index.php
  20. +23
    -15
      backend/views/user/orders.php
  21. +12
    -3
      backend/views/user/update.php
  22. +301
    -0
      backend/views/user/view.php
  23. +409
    -324
      backend/web/css/screen.css
  24. +46
    -3
      backend/web/sass/_adminlte.scss
  25. +8
    -0
      backend/web/sass/distribution/_index.scss
  26. +29
    -9
      backend/web/sass/screen.scss
  27. +15
    -0
      backend/web/sass/user/_index.scss
  28. +9
    -0
      backend/web/sass/user/_view.scss
  29. +2
    -1
      common/config/params.php
  30. +26
    -0
      common/versions/24.2.C.php
  31. +8
    -0
      domain/Distribution/Distribution/DistributionRepository.php
  32. +6
    -0
      domain/Distribution/Distribution/DistributionRepositoryQuery.php
  33. +41
    -0
      domain/Order/Order/OrderRepository.php
  34. +2
    -2
      domain/Payment/PaymentSolver.php
  35. +20
    -12
      domain/Producer/Producer/ProducerRepository.php
  36. +3
    -2
      domain/Product/Product/ProductSolver.php
  37. +6
    -0
      domain/User/User/User.php
  38. +3
    -2
      tests/codeception/common/unit/ExampleTest.php

+ 1
- 1
backend/controllers/CommunicateController.php Целия файл

@@ -170,7 +170,7 @@ class CommunicateController extends BackendController
$this->setFlash('error', $messageError);
}

return $this->redirect(['mail', 'idPointSale' => $idPointSale]);
return $this->redirect(['email', 'idPointSale' => $idPointSale]);
}

$incomingDistributionsArray = $distributionModule->findDistributionsIncoming();

+ 5
- 1
backend/controllers/DistributionController.php Целия файл

@@ -288,19 +288,23 @@ class DistributionController extends BackendController

// montant et poids des commandes
$revenues = 0;
$revenuesWithTax = 0;
$weight = 0;
if ($ordersArray) {
foreach ($ordersArray as $order) {
$orderModule->initOrder($order);
if (is_null($order->date_delete)) {
$revenues += $orderModule->getOrderAmountWithTax($order);
$revenues += $orderModule->getOrderAmount($order);
$revenuesWithTax += $orderModule->getOrderAmountWithTax($order);
$weight += $order->weight;
}
}
}
$distributionJsonData['revenues'] = Price::format($revenues);
$distributionJsonData['revenues_with_tax'] = Price::format($revenuesWithTax);
$distributionJsonData['weight'] = number_format($weight, 2);
$distributionJsonData['potential_revenues'] = Price::format($productModule->getProductDistributionPotentialRevenues($productsArray));
$distributionJsonData['potential_revenues_with_tax'] = Price::format($productModule->getProductDistributionPotentialRevenues($productsArray, true));
$distributionJsonData['potential_weight'] = number_format($productModule->getProductDistributionPotentialWeight($productsArray), 2);

return $distributionJsonData;

+ 1
- 1
backend/controllers/ReportController.php Целия файл

@@ -94,7 +94,7 @@ class ReportController extends BackendController
}

$distributionsByMonthArray = [];
$distributionsArray = $distributionModule->findDistributionsActive();
$distributionsArray = $distributionModule->findDistributionsWithOrders();
foreach ($distributionsArray as $distribution) {
$month = date('Y-m', strtotime($distribution->date));
if (!isset($distributionsByMonthArray[$month])) {

+ 6
- 1
backend/controllers/StatsController.php Целия файл

@@ -74,15 +74,20 @@ class StatsController extends BackendController
$year = date('Y');
}

$isVatNotApplicable = !$producerCurrent->taxRate->value;
$yearsWithTurnoverArray = $this->getProducerModule()->getRepository()->getYearsWithTurnover($producerCurrent);
$dataChartTurnover = $this->getProducerModule()->getRepository()->getDatasChartTurnoverStatistics($producerCurrent, $year, $displayBy);
$dataChartTurnoverWithTax = $this->getProducerModule()->getRepository()->getDatasChartTurnoverStatistics($producerCurrent, $year, $displayBy, true);


return $this->render('index', [
'isVatNotApplicable' => $isVatNotApplicable,
'displayBy' => $displayBy,
'yearCurrent' => $year,
'dataLabels' => $dataChartTurnover['labels'],
'data' => $dataChartTurnover['data'],
'yearsWithTurnoverArray' => $yearsWithTurnoverArray
'dataWithTax' => $dataChartTurnoverWithTax['data'],
'yearsWithTurnoverArray' => $yearsWithTurnoverArray,
]);
}


+ 15
- 3
backend/controllers/UserController.php Целия файл

@@ -169,6 +169,18 @@ class UserController extends BackendController

}

public function actionView($id)
{
$orderModule = $this->getOrderModule();
$pointSaleModule = $this->getPointSaleModule();
$model = $this->findModel($id);

return $this->render('view', [
'model' => $model,
'pointSaleBillingArray' => $pointSaleModule->findByBillingUser($model)
]);
}

public function actionUpdate($id)
{
$userModule = $this->getUserModule();
@@ -199,7 +211,7 @@ class UserController extends BackendController
}

$this->setFlash('success', 'Utilisateur <strong>' . Html::encode($userModule->getUsername($model)) . '</strong> modifié.');
return $this->redirect(['index']);
return $this->redirect(['view', 'id' => $model->id]);
}

// Email de bienvenue
@@ -207,7 +219,7 @@ class UserController extends BackendController
if ($mailWelcome) {
$this->getUserModule()->getManager()->welcome($model);
$this->setFlash('success', 'Email de bienvenue envoyé à <strong>' . Html::encode($userModule->getSolver()->getUsername($model)) . '</strong>.');
return $this->redirect(['update', 'id' => $model->id]);
return $this->redirect(['view', 'id' => $model->id]);
}

// Mot de passe oublié
@@ -215,7 +227,7 @@ class UserController extends BackendController
if ($newPassword) {
$this->getUserModule()->getManager()->newPassword($model);
$this->setFlash('success', 'Nouveau mot de passe envoyé à <strong>' . Html::encode($userModule->getSolver()->getUsername($model)) . '</strong>.');
return $this->redirect(['update', 'id' => $model->id]);
return $this->redirect(['view', 'id' => $model->id]);
}
} else {
throw new UserException("Vous ne pouvez pas modifier cet utilisateur.");

+ 16
- 1
backend/models/MailForm.php Целия файл

@@ -109,12 +109,27 @@ class MailForm extends Model
$messageAutoText = '' ;
$messageAutoHtml = '' ;

$messageAutoHtml .= ' <style type="text/css">
h1, h2, h3, h4, h5, h6 {
padding: 0px;
margin: 0px;
margin-bottom: 10px;
}
p {
margin: 0px;
padding: 0px;
margin-bottom: 5px;
}
</style>';

if($this->id_distribution) {
$messageAutoText = '

' ;
$messageAutoHtml = '<br /><br />' ;
$messageAutoHtml .= '<br /><br />' ;
$distribution = Distribution::searchOne(['id' => $this->id_distribution]) ;

+ 13
- 7
backend/views/communicate/email.php Целия файл

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

<?=

$this->render('@backend/views/user/_menu.php',[
$this->render('@backend/views/user/_menu_filter.php',[
'section' => 'email',
'idPointSaleActive' => $idPointSaleActive,
'sectionInactiveUsers' => isset($sectionInactiveUsers) ? $sectionInactiveUsers : null,
@@ -61,7 +61,7 @@ $this->render('@backend/views/user/_menu.php',[
?>

<div id="">
<div class="col-md-6">
<div class="col-md-8">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">Envoyer un email</h3>
@@ -72,15 +72,21 @@ $this->render('@backend/views/user/_menu.php',[
->hint("Sélectionnez une distribution pour ajouter automatiquement au message un lien vers la prise de commande de cette distribution"); ?>
<?= $form->field($mailForm, 'integrate_product_list')->checkbox() ; ?>
<?= $form->field($mailForm, 'subject')->textInput() ; ?>
<?= $form->field($mailForm, 'message')->textarea(['rows' => '15']) ; ?>
<div class="form-group">
<?php //$form->field($mailForm, 'message')->textarea(['rows' => '15']) ; ?>
<?= $form->field($mailForm, 'message')->widget(letyii\tinymce\Tinymce::class, [
'configs' => [
'plugins' => Yii::$app->parameterBag->get('tinyMcePlugins'),
]
]); ?>

<div class="form-group form-buttons">
<?= Html::submitButton( 'Envoyer', ['class' => 'btn btn-primary']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>
</div>
</div>
<div class="col-md-6">
<div class="col-md-4">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">
@@ -88,13 +94,13 @@ $this->render('@backend/views/user/_menu.php',[
</h3>
</div>
<div class="panel-body">
<?php if($idPointSaleActive): ?>
<a class="btn btn-xs <?php if($usersPointSaleLink): ?>btn-primary<?php else: ?>btn-default<?php endif; ?>" href="<?= Yii::$app->urlManager->createUrl(['communicate/email','idPointSale' => $idPointSaleActive, 'idDistribution' => $idDistributionActive, 'usersPointSaleLink' => 1]); ?>">Liés au point de vente</a>
<a class="btn btn-xs <?php if($usersPointSaleHasOrder): ?>btn-primary<?php else: ?>btn-default<?php endif; ?>" href="<?= Yii::$app->urlManager->createUrl(['communicate/email','idPointSale' => $idPointSaleActive, 'idDistribution' => $idDistributionActive, 'usersPointSaleHasOrder' => 1]); ?>">Déjà commandés dans ce point de vente</a>
<br /><br />
<?php endif; ?>
<?= implode(', ', $usersArray); ?>
</div>
</div>

+ 10
- 7
backend/views/distribution/index.php Целия файл

@@ -205,8 +205,11 @@ $this->setPageTitle('Distributions') ;
<div id="summary-ca-weight" class="info-box col-md-4">
<span class="info-box-icon bg-yellow"><i class="fa fa-euro"></i></span>
<div class="info-box-content">
<span class="info-box-text">CA (TTC)</span>
<span class="info-box-number">{{ distribution.revenues }} <span class="normal" v-if="distribution.potential_revenues != '0,00 €'">/ {{ distribution.potential_revenues }}</span></span>
<span class="info-box-text">CA réel / potentiel (HT)</span>
<span class="info-box-number">
<span data-toggle="tooltip" data-placement="bottom" :data-original-title="distribution.revenues_with_tax+' TTC'">{{ distribution.revenues }}</span>
<span class="normal" v-if="distribution.potential_revenues != '0,00 €'">/ <span data-toggle="tooltip" data-placement="bottom" :data-original-title="distribution.potential_revenues_with_tax+' TTC'">{{ distribution.potential_revenues }}</span></span>
</span>
<span class="info-box-text">Poids</span>
<span class="info-box-number">{{ distribution.weight }} kg <span class="normal" v-if="distribution.potential_weight > 0">/ {{ distribution.potential_weight }} kg</span></span>
</div>
@@ -383,19 +386,19 @@ $this->setPageTitle('Distributions') ;
<span class="label label-success" v-if="!order.date_update && !order.date_delete"><span class="glyphicon glyphicon-check"></span></span>
</td>
<td class="column-user">
<span v-if="order.user">
<a :href="baseUrl+'/user/view?id='+order.id_user" target="_blank" v-if="order.user">
<template v-if="order.user.name_legal_person && order.user.name_legal_person.length">
{{ order.user.name_legal_person }}
</template>
<template v-else>
{{ order.user.lastname+' '+order.user.name }}
</template>
<span class="shortcuts btn-group" role="group">
<!--<span class="shortcuts btn-group" role="group">
<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>
</span>
</span>-->
</a>
<span v-else class="no-user">{{ order.username }}</span>
<span v-if="order.comment && order.comment.length > 0" class="glyphicon glyphicon-comment"></span>
<span v-if="order.delivery_home && order.delivery_address && order.delivery_address.length > 0" class="glyphicon glyphicon-home"></span>
@@ -421,7 +424,7 @@ $this->setPageTitle('Distributions') ;
</td>
<td class="column-credit" v-if="!idActivePointSale || (pointSaleActive && pointSaleActive.credit == 1)">
<template v-if="order.isCreditContext">
<a :href="baseUrl+'/user/credit?id='+order.id_user" :class="order.user.credit >= 0 ? 'positive' : 'negative'">
<a :href="baseUrl+'/user/credit?id='+order.id_user" target="_blank" :class="order.user.credit >= 0 ? 'positive' : 'negative'">
{{ order.user.credit.toFixed(2).replace(/(\d)(?=(\d{3})+(?:\.\d+)?$)/g, "$1,")+'&nbsp;€' }}
</a>
</template>

+ 58
- 56
backend/views/layouts/left.php Целия файл

@@ -60,9 +60,13 @@ $isUserCurrentGrantedAsProducer = $userModule->getAuthorizationChecker()->isGran
<section class="sidebar">
<?php
$producer = GlobalParam::getCurrentProducer();
$newVersionOpendistribLabel = '';
if ($producer && !$producerModule->isUpToDateWithOpendistribVersion($producer)) {
$newVersionOpendistribLabel = '<span class="pull-right-container"><small class="label pull-right bg-green">' . GlobalParam::getOpendistribVersion() . '</small></span>';
$versionOpendistribLabel = '';
if ($producer) {
$backgroundLabelVersionOpendistrib = 'black';
if(!$producerModule->isUpToDateWithOpendistribVersion($producer)) {
$backgroundLabelVersionOpendistrib = 'green';
}
$versionOpendistribLabel = '<span class="pull-right-container"><small class="label pull-right bg-'.$backgroundLabelVersionOpendistrib.'">' . GlobalParam::getOpendistribVersion() . '</small></span>';
}

$countTicketsProducerUnreadLabel = '';
@@ -91,28 +95,12 @@ $isUserCurrentGrantedAsProducer = $userModule->getAuthorizationChecker()->isGran
$sumUserProducerCreditsLabel = '';
//$sumUserProducerCreditsLabel = '<span class="pull-right-container"><small class="label pull-right '.($sumUserProducerCredits >= 0 ? 'bg-green' : 'bg-red') .'">'.number_format($sumUserProducerCredits, 2).' €</small></span>';

$countUsersWithStatusProducerOnline = $userModule->getRepository()->countUsersStatusProducerOnline();
$countUsersWithStatusProducerOnlineLabel = '';
if ($countUsersWithStatusProducerOnline) {
$countUsersWithStatusProducerOnlineLabel = '<small class="label pull-right bg-red">' . $countUsersWithStatusProducerOnline . '</small>';
}

$countUsersWithStatusProducerOnline = $userModule->getRepository()->countUsersStatusProducerOnline();
$countUsersWithStatusUserOnline = $userModule->getRepository()->countUsersStatusUserOnline();
$countUsersWithStatusUserOnlineLabel = '';
if ($countUsersWithStatusUserOnline) {
$countUsersWithStatusUserOnlineLabel = '<small class="label pull-right bg-blue">' . $countUsersWithStatusUserOnline . '</small>';
}

$countUsersOnlineLabel = '';
$countUsersProducersOnlineLabel = '';
if ($countUsersWithStatusProducerOnline || $countUsersWithStatusUserOnline) {
$countUsersOnlineLabel = '<span class="pull-right-container">';
if ($countUsersWithStatusUserOnline) {
$countUsersOnlineLabel .= $countUsersWithStatusUserOnlineLabel;
}
if ($countUsersWithStatusProducerOnline) {
$countUsersOnlineLabel .= $countUsersWithStatusProducerOnlineLabel;
}
$countUsersOnlineLabel .= '</span>';
$countUsersProducersOnlineLabel = '<span class="pull-right-container"><small class="label pull-right bg-blue">' . ($countUsersWithStatusProducerOnline + $countUsersWithStatusUserOnline) . '</small></span>';
}

$countProducerInvoicesUnpaidLabel = '';
@@ -129,6 +117,49 @@ $isUserCurrentGrantedAsProducer = $userModule->getAuthorizationChecker()->isGran
[
'options' => ['class' => 'sidebar-menu tree', 'data-widget' => 'tree'],
'items' => [

// Administration
['label' => 'Administration', 'options' => ['class' => 'header'], 'visible' => $isUserCurrentGrantedAsAdministrator],
[
'label' => 'En ligne',
'icon' => 'wifi',
'url' => ['online-admin/index'],
'visible' => $isUserCurrentGrantedAsAdministrator,
'template' => '<a href="{url}">{icon} {label}' . $countUsersProducersOnlineLabel . '</a>'
],
[
'label' => 'Support',
'icon' => 'comments',
'url' => ['support-admin/index'],
'visible' => $isUserCurrentGrantedAsAdministrator,
'template' => '<a href="{url}">{icon} {label}' . $countTicketsLabel . '</a>'
],
['label' => 'Producteurs', 'icon' => 'th-list', 'url' => ['/producer-admin/index'], 'visible' => $isUserCurrentGrantedAsAdministrator],
[
'label' => 'Statistiques',
'icon' => 'line-chart',
'url' => ['/stats-admin/matomo'],
'visible' => $isUserCurrentGrantedAsAdministrator,
'items' => [
['label' => 'Matomo', 'icon' => 'line-chart', 'url' => ['/stats-admin/matomo'], 'visible' => $isUserCurrentGrantedAsAdministrator],
['label' => 'Chiffre d\'affaire', 'icon' => 'line-chart', 'url' => ['/stats-admin/turnover'], 'visible' => $isUserCurrentGrantedAsAdministrator],
['label' => 'Commandes clients', 'icon' => 'calendar', 'url' => ['/stats-admin/customer-orders'], 'visible' => $isUserCurrentGrantedAsAdministrator],
],
],
[
'label' => 'Configuration',
'icon' => 'cog',
'url' => ['/setting-admin/index'],
'visible' => $isUserCurrentGrantedAsAdministrator,
'items' => [
['label' => 'Paramètres', 'icon' => 'cog', 'url' => ['/setting-admin/index'], 'visible' => $isUserCurrentGrantedAsAdministrator && $featureChecker->isEnabled(Feature::ALIAS_SETTINGS)],
['label' => 'Fonctionnalités', 'icon' => 'flag', 'url' => ['/feature-admin/index'], 'visible' => $isUserCurrentGrantedAsAdministrator],
['label' => 'Tranches de prix', 'icon' => 'eur', 'url' => ['/producer-price-range-admin/index'], 'visible' => $isUserCurrentGrantedAsAdministrator],
['label' => 'Taxes', 'icon' => 'eur', 'url' => ['/tax-rate-admin/index'], 'visible' => $isUserCurrentGrantedAsAdministrator],
],
],

// Support
['label' => "Besoin d'aide ?", 'options' => ['class' => 'header'], 'visible' => $isUserCurrentGrantedAsProducer],
[
'label' => 'Support',
@@ -137,6 +168,8 @@ $isUserCurrentGrantedAsProducer = $userModule->getAuthorizationChecker()->isGran
'visible' => $isUserCurrentGrantedAsProducer,
'template' => '<a href="{url}">{icon} {label} <span class="pull-right-container">' . $developerOnlineLabel . $countTicketsProducerUnreadLabel . '</span></a>'
],

// Producteur
['label' => $producer->name, 'options' => ['class' => 'header'], 'visible' => $isUserCurrentGrantedAsProducer],
['label' => 'Tableau de bord', 'icon' => 'dashboard', 'url' => ['/dashboard/index'], 'visible' => $isUserCurrentGrantedAsProducer],
['label' => 'Distributions', 'icon' => 'calendar', 'url' => ['/distribution/index'], 'visible' => $isUserCurrentGrantedAsProducer],
@@ -219,45 +252,14 @@ $isUserCurrentGrantedAsProducer = $userModule->getAuthorizationChecker()->isGran
'url' => ['/development/index'],
'visible' => $isUserCurrentGrantedAsProducer,
'active' => Yii::$app->controller->id == 'development',
'template' => '<a href="{url}">{icon} {label}' . $newVersionOpendistribLabel . '</a>'
],
['label' => 'Administration', 'options' => ['class' => 'header'], 'visible' => $isUserCurrentGrantedAsAdministrator],
[
'label' => 'En ligne',
'icon' => 'wifi',
'url' => ['online-admin/index'],
'visible' => $isUserCurrentGrantedAsAdministrator,
'template' => '<a href="{url}">{icon} {label}' . $countUsersOnlineLabel . '</a>'
],
[
'label' => 'Support',
'icon' => 'comments',
'url' => ['support-admin/index'],
'visible' => $isUserCurrentGrantedAsAdministrator,
'template' => '<a href="{url}">{icon} {label}' . $countTicketsLabel . '</a>'
],
['label' => 'Producteurs', 'icon' => 'th-list', 'url' => ['/producer-admin/index'], 'visible' => $isUserCurrentGrantedAsAdministrator],
[
'label' => 'Statistiques',
'icon' => 'line-chart',
'url' => ['/stats-admin/matomo'],
'visible' => $isUserCurrentGrantedAsAdministrator,
'items' => [
['label' => 'Matomo', 'icon' => 'line-chart', 'url' => ['/stats-admin/matomo'], 'visible' => $isUserCurrentGrantedAsAdministrator],
['label' => 'Chiffre d\'affaire', 'icon' => 'line-chart', 'url' => ['/stats-admin/turnover'], 'visible' => $isUserCurrentGrantedAsAdministrator],
['label' => 'Commandes clients', 'icon' => 'calendar', 'url' => ['/stats-admin/customer-orders'], 'visible' => $isUserCurrentGrantedAsAdministrator],
],
'template' => '<a href="{url}">{icon} {label}' . $versionOpendistribLabel . '</a>'
],
['label' => 'Paramètres', 'icon' => 'cog', 'url' => ['/setting-admin/index'], 'visible' => $isUserCurrentGrantedAsAdministrator && $featureChecker->isEnabled(Feature::ALIAS_SETTINGS)],
['label' => 'Fonctionnalités', 'icon' => 'flag', 'url' => ['/feature-admin/index'], 'visible' => $isUserCurrentGrantedAsAdministrator],
['label' => 'Tranches de prix', 'icon' => 'eur', 'url' => ['/producer-price-range-admin/index'], 'visible' => $isUserCurrentGrantedAsAdministrator],
['label' => 'Taxes', 'icon' => 'eur', 'url' => ['/tax-rate-admin/index'], 'visible' => $isUserCurrentGrantedAsAdministrator],
['label' => 'Communiquer', 'icon' => 'bullhorn', 'url' => ['/communicate-admin/index'], 'visible' => $isUserCurrentGrantedAsAdministrator],

//['label' => 'Communiquer', 'icon' => 'bullhorn', 'url' => ['/communicate-admin/index'], 'visible' => $isUserCurrentGrantedAsAdministrator],
//['label' => 'Outils', 'options' => ['class' => 'header'], 'visible' => $isUserCurrentGrantedAsAdministrator],
//['label' => 'Gii', 'icon' => 'file-code-o', 'url' => ['/gii'], 'visible' => $isUserCurrentGrantedAsAdministrator],
//['label' => 'Debug', 'icon' => 'dashboard', 'url' => ['/debug'], 'visible' => $isUserCurrentGrantedAsAdministrator],
['label' => 'Login', 'url' => ['site/login'], 'visible' => !$userModule->isCurrentConnected()],
//['label' => 'Login', 'url' => ['site/login'], 'visible' => !$userModule->isCurrentConnected()],
],
]
) ?>

+ 1
- 3
backend/views/online-admin/index.php Целия файл

@@ -103,9 +103,7 @@ $this->setMetaRefresh(true);
<div class="box box-primary box-user">
<div class="box-body box-profile">
<h3 class="profile-username text-center">
<a title="Prendre la main" href="<?= $this->getUrlManagerBackend()->createUrl(['user/switch-identity', 'id' => $userWithStatusUserOnline->id]); ?>">
<?= $userModule->getSolver()->getUsername($userWithStatusUserOnline); ?>
</a>
<?= $userModule->getSolver()->getUsername($userWithStatusUserOnline); ?>
</h3>
<p class="text-muted text-center">
<?php $userProducerArray = $userWithStatusUserOnline->userProducer; ?>

+ 2
- 6
backend/views/producer/update.php Целия файл

@@ -105,12 +105,8 @@ $this->addBreadcrumb($this->getTitle());
->hint('Affiché sur la page d\'accueil')*/ ?>

<?= $form->field($model, 'description')->widget(letyii\tinymce\Tinymce::class, [
'options' => [
'id' => 'testid',
],
'configs' => [ // Read more: https://www.tiny.cloud/docs/tinymce/6/full-featured-open-source-demo/
//'plugins' => 'preview importcss searchreplace autolink autosave save directionality code visualblocks visualchars fullscreen image link media template codesample table charmap pagebreak nonbreaking anchor insertdatetime advlist lists wordcount help charmap quickbars emoticons accordion' ,
'plugins' => 'preview searchreplace autolink autosave save directionality code visualblocks visualchars fullscreen image link lists wordcount help' ,
'configs' => [
'plugins' => Yii::$app->parameterBag->get('tinyMcePlugins'),
]
])->hint('Affiché sur la page d\'accueil') ; ?>


+ 9
- 0
backend/views/stats-admin/customer_orders.php Целия файл

@@ -49,6 +49,15 @@ $this->addBreadcrumb('Statistiques commandes clients') ;
'height' => 400,
'width' => 1100
],
'clientOptions' => [
'scales' => [
'yAxes' => [[
'ticks' => [
'beginAtZero' => true
]
]],
],
],
'data' => [
'labels' => $dataLabels,
'datasets' => [

+ 9
- 0
backend/views/stats-admin/turnover.php Целия файл

@@ -49,6 +49,15 @@ $this->addBreadcrumb('Statistiques (chiffres d\'affaires)') ;
'height' => 400,
'width' => 1100
],
'clientOptions' => [
'scales' => [
'yAxes' => [[
'ticks' => [
'beginAtZero' => true
]
]],
],
],
'data' => [
'labels' => $dataLabels,
'datasets' => [

+ 80
- 55
backend/views/stats/index.php Целия файл

@@ -1,90 +1,115 @@
<?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.
*/
/**
* 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.
*/

use dosamigos\chartjs\ChartJs;
use yii\helpers\Html;

$this->setTitle('Statistiques - Chiffre d\'affaire') ;
$this->addBreadcrumb('Statistiques (chiffre d\'affaire)') ;
$this->setTitle('Statistiques - Chiffre d\'affaire');
$this->addBreadcrumb('Statistiques (chiffre d\'affaire)');

?>

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

?>

<br><br>
<br><br>

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

if($isVatNotApplicable) {
$datasets = [
[
'label' => 'Recettes commandes',
'borderColor' => "#F39C12",
'data' => $data,
]
];
}
else {
$datasets = [
[
'label' => 'Recettes commandes (HT)',
'borderColor' => "#b4b4b4",
'data' => $data,
],
[
'label' => 'Recettes commandes (TTC)',
'borderColor' => "#F39C12",
'data' => $dataWithTax
]
];
}

?>

<?= ChartJs::widget([
'type' => 'line',
'options' => [
'height' => 400,
'width' => 1100
'width' => 1100,
],
'clientOptions' => [
'scales' => [
'yAxes' => [[
'ticks' => [
'beginAtZero' => true
]
]],
],
],
'data' => [
'labels' => $dataLabels,
'datasets' => [
[
'label' => 'Recettes commandes',
'backgroundColor' => "rgb(255,127,0,0.5)",
'borderColor' => "rgb(255,127,0,1)",
'pointBackgroundColor' => "rgb(255,127,0,1)",
'pointStrokeColor' => "#fff",
'data' => $data
]
]
'datasets' => $datasets
]
]);


+ 36
- 84
backend/views/user/_form.php Целия файл

@@ -55,11 +55,11 @@ $distributionModule = DistributionModule::getInstance();

<div class="user-form" id="app-user-form">

<div class="col-md-8">
<?php $form = ActiveForm::begin([
'enableClientValidation' => false
]); ?>
<?php $form = ActiveForm::begin([
'enableClientValidation' => false
]); ?>

<div class="col-md-8 col-no-padding-left">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">
@@ -84,47 +84,6 @@ $distributionModule = DistributionModule::getInstance();
</div>
</div>

<div class="panel panel-default panel-newsletter">
<div class="panel-heading">
<h3 class="panel-title">
<i class="fa fa-paper-plane"></i>
Bulletin d'information
</h3>
</div>
<div class="panel-body">
<?= $form->field($model, 'newsletter')->widget(Toggle::class,
[
'options' => [
'data-id' => $model->id,
'data-on' => 'Oui',
'data-off' => 'Non',
],
]
); ?>
</div>
</div>

<?php if (
$distributionModule->getExportManager()->isEnabled(ExportManager::SHOPPING_CART_LABELS_PDF)
|| $producerModule->getSolver()->getConfig('option_export_evoliz')): ?>
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">
<i class="fa fa-download"></i>
Exports
</h3>
</div>
<div class="panel-body">
<?php if($distributionModule->getExportManager()->isEnabled(ExportManager::SHOPPING_CART_LABELS_PDF)): ?>
<?= $form->field($model, 'exclude_export_shopping_cart_labels')->checkbox(); ?>
<?php endif; ?>
<?php if ($producerModule->getSolver()->getConfig('option_export_evoliz')): ?>
<?= $form->field($model, 'evoliz_code')->textInput() ?>
<?php endif; ?>
</div>
</div>
<?php endif; ?>

<?php if($pointsSaleArray && count($pointsSaleArray) > 0): ?>
<div class="panel panel-default panel-point-sales">
<div class="panel-heading">
@@ -178,58 +137,51 @@ $distributionModule = DistributionModule::getInstance();
<?= Html::submitButton($model->isNewRecord ? 'Créer' : 'Modifier', ['class' => 'btn btn-primary']) ?>
</div>

<?php ActiveForm::end(); ?>
</div>

<div class="col-md-4">

<?php if($model->email): ?>
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">
<i class="fa fa-envelope"></i>
Envoi d'emails
</h3>
</div>
<div class="panel-body">
<?php $form = ActiveForm::begin(); ?>
<div class="form-group">
<?= Html::submitButton(
'<i class="fa fa-home"></i> Envoyer l\'email de bienvenue',
['class' => 'btn btn-default', 'name' => 'submit_mail_welcome', 'value' => 1]
) ?>
</div>
<?php ActiveForm::end(); ?>

<?php $form = ActiveForm::begin(); ?>
<div class="form-group">
<?= Html::submitButton(
'<i class="fa fa-key"></i> Envoyer un nouveau mot de passe',
['class' => 'btn btn-default', 'name' => 'submit_new_password', 'value' => 1]
) ?>
</div>
<?php ActiveForm::end(); ?>
</div>
<div class="panel panel-default panel-newsletter">
<div class="panel-heading">
<h3 class="panel-title">
<i class="fa fa-paper-plane"></i>
Bulletin d'information
</h3>
</div>
<?php endif; ?>
<div class="panel-body">
<?= $form->field($model, 'newsletter')->widget(Toggle::class,
[
'options' => [
'data-id' => $model->id,
'data-on' => 'Oui',
'data-off' => 'Non',
],
]
); ?>
</div>
</div>

<?php if(isset($pointSaleBillingArray) && $pointSaleBillingArray && count($pointSaleBillingArray) > 0): ?>
<?php if (
$distributionModule->getExportManager()->isEnabled(ExportManager::SHOPPING_CART_LABELS_PDF)
|| $producerModule->getSolver()->getConfig('option_export_evoliz')): ?>
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">
<i class="fa fa-sticky-note-o"></i>
Facturation
<i class="fa fa-download"></i>
Exports
</h3>
</div>
<div class="panel-body">
<?php foreach($pointSaleBillingArray as $pointSale): ?>
<a class="btn btn-default btn-sm" href="<?= Yii::$app->urlManager->createUrl(['point-sale/update', 'id' => $pointSale->id]) ?>">
<i class="fa fa-map-marker"></i>
<?= $pointSale->name ?>
</a><br />
<?php endforeach; ?>
<?php if($distributionModule->getExportManager()->isEnabled(ExportManager::SHOPPING_CART_LABELS_PDF)): ?>
<?= $form->field($model, 'exclude_export_shopping_cart_labels')->checkbox(); ?>
<?php endif; ?>
<?php if ($producerModule->getSolver()->getConfig('option_export_evoliz')): ?>
<?= $form->field($model, 'evoliz_code')->textInput() ?>
<?php endif; ?>
</div>
</div>
<?php endif; ?>
</div>

<?php ActiveForm::end(); ?>
</div>

backend/views/user/_menu.php → backend/views/user/_menu_filter.php Целия файл


+ 32
- 0
backend/views/user/_menu_navigation.php Целия файл

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

use domain\Order\Order\OrderModule;
use domain\User\User\User;
use domain\User\User\UserModule;
use common\helpers\Price;

$userModule = UserModule::getInstance();
$orderModule = OrderModule::getInstance();

$credit = $userModule->getRepository()->getCredit($user);
$countOrders = $orderModule->getRepository()->countOrdersByUser($user);

?>

<ul class="nav nav-tabs">
<?= menu_navigation_item('view', 'Récapitulatif', $action, $user) ?>
<?= menu_navigation_item('update', 'Profil', $action, $user) ?>
<?= menu_navigation_item('credit', 'Crédit <span class="label label-default badge">'.Price::format($credit).'</span>', $action, $user) ?>
<?= menu_navigation_item('orders', 'Commandes <span class="label label-default badge">'.$countOrders.'</span>', $action, $user) ?>
</ul>


<?php

function menu_navigation_item(string $action, string $label, string $currentAction, User $user) {
$classActive = ($action == $currentAction) ? ' class="active"' : '';
$url = Yii::$app->urlManager->createUrl(['user/'.$action, 'id' => $user->id]);
return '<li'.$classActive.'><a href="'.$url.'">'.$label.'</a></li>';
}

?>

+ 168
- 121
backend/views/user/credit.php Целия файл

@@ -39,6 +39,7 @@ termes.
use common\helpers\GlobalParam;
use common\helpers\MeanPayment;
use domain\Payment\Payment;
use domain\User\User\UserModule;
use yii\grid\GridView;
use yii\helpers\Html;
use yii\widgets\ActiveForm;
@@ -47,14 +48,21 @@ $paymentManager = $this->getPaymentModule();
$producerModule = $this->getProducerModule();
$userModule = $this->getUserModule();

$this->setTitle('Créditer <small>'.Html::encode($user->lastname.' '.$user->name).'</small>', 'Créditer '.Html::encode($user->lastname.' '.$user->name)) ;
$userModule = UserModule::getInstance();
$username = Html::encode($userModule->getSolver()->getUsername($user));
$this->setTitle($username.' (#'.$user->id.')') ;
$this->addBreadcrumb(['label' => 'Utilisateurs', 'url' => ['index']]) ;
$this->addBreadcrumb(['label' => Html::encode($user->lastname.' '.$user->name)]) ;
$this->addBreadcrumb('Créditer') ;
$this->addBreadcrumb(['label' => $username]) ;
$this->addBreadcrumb('Crédit') ;

?>

<div class="user-credit">
<?= $this->render('_menu_navigation', [
'action' => 'credit',
'user' => $user
]); ?>

<div class="user-credit tab-content">
<?php
$producer = $producerModule->findOneProducerById(GlobalParam::getCurrentProducerId());
@@ -65,129 +73,168 @@ $this->addBreadcrumb('Créditer') ;
. ' Pensez à l\'activer si vous souhaitez qu\'elle soit visible de vos utilisateurs.</div>' ;
}
?>
<div class="col-md-4">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">
Crédit obligatoire
<?= Html::a($userProducer->credit_active ? 'Désactiver' : 'Activer', ['user/state-credit', 'idUser' => $user->id,'state' => !$userProducer->credit_active], ['class' => 'btn btn-default btn-xs']); ?>
</h3>

<div class="row">
<div class="col-md-4">
<div class="panel panel-default">
<div class="panel-heading">
<div class="the-credit">
<span class="glyphicon glyphicon-piggy-bank"></span>
<?= number_format($userModule->getCredit($user), 2); ?> €
</div>
</div>
</div>
<div class="panel-body">
<?php if($userProducer->credit_active): ?>
<div class="alert alert-success">Activé</div>
<?php else: ?>
<div class="alert alert-danger">Désactivé</div>
<?php endif; ?>
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">
Crédit obligatoire
<?= Html::a($userProducer->credit_active ? 'Désactiver' : 'Activer', ['user/state-credit', 'idUser' => $user->id,'state' => !$userProducer->credit_active], ['class' => 'btn btn-default btn-xs']); ?>
</h3>
</div>
<div class="panel-body">
<p class="info">
<span class="glyphicon glyphicon-info-sign"></span>
Active ou désactive le crédit de l'utilisateur pour les points de vente
avec l'option <em>Basée sur l'utilisateur</em>.
</p>
<?php if($userProducer->credit_active): ?>
<div class="alert alert-success">Activé</div>
<?php else: ?>
<div class="alert alert-danger">Désactivé</div>
<?php endif; ?>
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">Crédit / débit</h3>
</div>
<div class="panel-body">
<?php $form = ActiveForm::begin(); ?>
<?= $form->field($creditForm, 'type')->dropDownList([
Payment::TYPE_CREDIT => 'Crédit',
Payment::TYPE_DEBIT => 'Débit',
]) ?>
<?= $form->field($creditForm, 'amount')->textInput() ?>
<?= $form->field($creditForm, 'mean_payment')->dropDownList([
MeanPayment::MONEY => MeanPayment::getStrBy(MeanPayment::MONEY),
MeanPayment::CREDIT_CARD => MeanPayment::getStrBy(MeanPayment::CREDIT_CARD),
MeanPayment::CHEQUE => MeanPayment::getStrBy(MeanPayment::CHEQUE),
MeanPayment::TRANSFER => MeanPayment::getStrBy(MeanPayment::TRANSFER),
MeanPayment::OTHER => MeanPayment::getStrBy(MeanPayment::OTHER),
]) ?>
<?= $form->field($creditForm, 'comment')->textarea() ?>
<?= $form->field($creditForm, 'date_transaction')->textInput([
'class' => 'datepicker form-control'
]) ?>
<?= $form->field($creditForm, 'send_mail')->checkbox() ?>

<div class="form-group">
<?= Html::submitButton( 'Créditer', ['class' => 'btn btn-primary']) ?>

<div class="col-md-8 ">
<div class="panel panel-default panel-form-credit-debit">
<div class="panel-heading">
<h3 class="panel-title">
Crédit / débit
</h3>
</div>
<div class="panel-body">
<?php $form = ActiveForm::begin(); ?>
<div class="row">
<div class="col-md-6">
<?= $form->field($creditForm, 'type')->dropDownList([
Payment::TYPE_CREDIT => 'Crédit',
Payment::TYPE_DEBIT => 'Débit',
]) ?>
<?= $form->field($creditForm, 'mean_payment')->dropDownList([
MeanPayment::MONEY => MeanPayment::getStrBy(MeanPayment::MONEY),
MeanPayment::CREDIT_CARD => MeanPayment::getStrBy(MeanPayment::CREDIT_CARD),
MeanPayment::CHEQUE => MeanPayment::getStrBy(MeanPayment::CHEQUE),
MeanPayment::TRANSFER => MeanPayment::getStrBy(MeanPayment::TRANSFER),
MeanPayment::OTHER => MeanPayment::getStrBy(MeanPayment::OTHER),
]) ?>
<?= $form->field($creditForm, 'amount')->textInput() ?>
</div>
<div class="col-md-6">
<?= $form->field($creditForm, 'comment')->textarea() ?>
<?= $form->field($creditForm, 'date_transaction')->textInput([
'class' => 'datepicker form-control'
]) ?>
<div class="row">
<div class="col-md-8">
<?= $form->field($creditForm, 'send_mail')->checkbox() ?>
</div>
<div class="col-md-4">
<div class="form-group form-buttons">
<?= Html::submitButton( 'Créditer', ['class' => 'btn btn-primary']) ?>
</div>
</div>
</div>
</div>
</div>
<?php ActiveForm::end(); ?>
</div>
<?php ActiveForm::end(); ?>
</div>
</div>
</div>
<div class="col-md-8">
<h2>Historique <span class="the-credit"><?= number_format($userModule->getCredit($user), 2); ?> €</span></h2>

<?= 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 '-&nbsp;' . $paymentManager->getAmount($model, true);
}
return '';
}
],
[
'label' => '+ Crédit',
'format' => 'raw',
'value' => function ($model) use ($paymentManager) {
if ($paymentManager->isTypeCredit($model)) {
return '+&nbsp;' . $paymentManager->getAmount($model, true);
}
return '';
}
],
[
'label' => 'Commentaire',
'format' => 'raw',
'value' => function ($model) {
if($model->comment) {
return nl2br($model->comment);
}
return '';
}
],
[
'label' => 'Transaction',
'format' => 'raw',
'value' => function ($model) {
if($model->date_transaction) {
return date('d/m/Y', strtotime($model->date_transaction));
}
return '';
}
],
],
]); ?>
<div class="row">
<div class="col-md-12">
<div class="panel panel-default panel-form-credit-debit">
<div class="panel-heading">
<h3 class="panel-title">
Historique
</h3>
</div>
<div class="panel-body">
<?= 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 '-&nbsp;' . $paymentManager->getAmount($model, true);
}
return '';
}
],
[
'label' => '+ Crédit',
'format' => 'raw',
'value' => function ($model) use ($paymentManager) {
if ($paymentManager->isTypeCredit($model)) {
return '+&nbsp;' . $paymentManager->getAmount($model, true);
}
return '';
}
],
[
'label' => 'Commentaire',
'format' => 'raw',
'value' => function ($model) {
if($model->comment) {
return nl2br($model->comment);
}
return '';
}
],
[
'label' => 'Transaction',
'format' => 'raw',
'value' => function ($model) {
if($model->date_transaction) {
return date('d/m/Y', strtotime($model->date_transaction));
}
return '';
}
],
],
]); ?>
</div>
</div>
</div>
</div>

<div class="clr"></div>
</div>

+ 64
- 61
backend/views/user/index.php Целия файл

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

use common\helpers\GlobalParam;
use common\helpers\Price;
use domain\Order\Order\Order;
use domain\Producer\Producer\ProducerModule;
use domain\User\User\UserModule;
@@ -58,7 +59,7 @@ $this->addButton(['label' => 'Nouvel utilisateur <span class="glyphicon glyphico

<?=

$this->render('_menu', [
$this->render('_menu_filter', [
'idPointSaleActive' => $idPointSaleActive,
'idDistributionActive' => 0,
'sectionInactiveUsers' => $sectionInactiveUsers,
@@ -117,46 +118,27 @@ $this->render('_menu', [
}
],
[
'attribute' => 'id_user_user_group',
'header' => 'Groupes',
'attribute' => 'credit',
'format' => 'raw',
'headerOptions' => ['class' => 'column-hide-on-mobile'],
'filterOptions' => ['class' => 'column-hide-on-mobile'],
'contentOptions' => ['class' => 'column-hide-on-mobile'],
'filter' => $userGroupModule->getRepository()->populateUserGroupDropdownList(false),
'value' => function ($user) {
$html = '';
foreach($user->userUserGroup as $userUserGroup) {
$html .= '<span class="label label-default">'.$userUserGroup->userGroup->name.'</span> ';
}
'contentOptions' => ['class' => 'column-hide-on-mobile align-center'],
'value' => function ($model) use ($producer) {
$userProducer = UserProducer::searchOne([
'id_user' => $model->id
]);
$credit = $userProducer ? $userProducer->credit : 0;
$classBtnCredit = $userProducer->credit_active ? 'btn-success' : 'btn-default';
$html = '<a class="btn '.$classBtnCredit.'" href="'.Yii::$app->urlManager->createUrl(['user/credit', 'id' => $model->id]).'">'.Price::format($credit).'</a>';
return $html;
}
],
[
'attribute' => 'newsletter',
'header' => "Inscrit au bulletin<br/>d'information",
'format' => 'raw',
'headerOptions' => ['class' => 'column-hide-on-mobile'],
'filterOptions' => ['class' => 'column-hide-on-mobile'],
'contentOptions' => ['class' => 'column-hide-on-mobile'],
'filter' => [
0 => 'Non',
1 => 'Oui'
],
'value' => function ($user) use ($userModule) {
if($userModule->isUserSubscribedNewsletter($user)) {
return '<span class="label label-success">Oui</span>';
}
return '<span class="label label-danger">Non</span>';
}
],
[
'class' => 'yii\grid\ActionColumn',
'header' => 'Commandes',
'template' => '{orders}',
'headerOptions' => ['class' => 'actions column-hide-on-mobile'],
'filterOptions' => ['class' => 'column-hide-on-mobile'],
'contentOptions' => ['class' => 'column-hide-on-mobile'],
'contentOptions' => ['class' => 'column-hide-on-mobile align-center'],
'buttons' => [
'orders' => function ($url, $model) {
$url = Yii::$app->urlManager->createUrl(['user/orders', 'id' => $model['id']]);
@@ -166,11 +148,11 @@ $this->render('_menu', [

$html = '';
if ($countOrders) {
$html .= Html::a('<span class="glyphicon glyphicon-eye-open"></span> ' . $countOrders, $url, [
$html .= Html::a($countOrders.' commande'.($countOrders > 1 ? 's' : ''), $url, [
'title' => 'Commandes', 'class' => 'btn btn-default '
]);;
} else {
$html .= 'Aucune commande';
$html .= 'Aucune';
}

return $html;
@@ -178,38 +160,59 @@ $this->render('_menu', [
],
],
[
'attribute' => 'credit',
'attribute' => 'newsletter',
'header' => "Inscrit au bulletin<br/>d'information",
'format' => 'raw',
'value' => function ($model) use ($producer) {
$userProducer = UserProducer::searchOne([
'id_user' => $model->id
]);
$credit = $userProducer ? $userProducer->credit : 0;
$classBtnCredit = $userProducer->credit_active ? 'btn-success' : 'btn-default';

$html = '<div class="input-group">
<input type="text" class="form-control input-credit" readonly="readonly" value="' . number_format($credit, 2) . ' €" placeholder="">
<span class="input-group-btn">
' . Html::a(
'<span class="glyphicon glyphicon-euro"></span>',
Yii::$app->urlManager->createUrl(['user/credit', 'id' => $model->id]),
[
'title' => 'Crédit',
'class' => 'btn ' . $classBtnCredit
]
) . '
</span>
</div>';

'headerOptions' => ['class' => 'column-hide-on-mobile'],
'filterOptions' => ['class' => 'column-hide-on-mobile'],
'contentOptions' => ['class' => 'column-hide-on-mobile align-center'],
'filter' => [
0 => 'Non',
1 => 'Oui'
],
'value' => function ($user) use ($userModule) {
if($userModule->isUserSubscribedNewsletter($user)) {
return '<span class="label label-success">Oui</span>';
}
return '<span class="label label-danger">Non</span>';
}
],
[
'attribute' => 'id_user_user_group',
'header' => 'Groupes',
'format' => 'raw',
'headerOptions' => ['class' => 'column-hide-on-mobile'],
'filterOptions' => ['class' => 'column-hide-on-mobile'],
'contentOptions' => ['class' => 'column-hide-on-mobile'],
'filter' => $userGroupModule->getRepository()->populateUserGroupDropdownList(false),
'value' => function ($user) {
$html = '';
foreach($user->userUserGroup as $userUserGroup) {
$html .= '<span class="label label-default">'.$userUserGroup->userGroup->name.'</span> ';
}
return $html;
}
],
[
'class' => 'yii\grid\ActionColumn',
'template' => '{update} {delete} {switch}',
'template' => '{view} {update}
<div class="wrapper-button-dropdown">
<button type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" class="btn btn-default dropdown-toggle"><span class="caret"></span></button>
<ul class="dropdown-menu">
<li>{delete}</li>
<li>{switch}</li>
</ul></div>',
'headerOptions' => ['class' => 'column-actions'],
'contentOptions' => ['class' => 'column-actions'],
'buttons' => [
'view' => function ($url, $user) {
return Html::a('<span class="glyphicon glyphicon-eye-open"></span>',
Yii::$app->urlManager->createUrl(['user/view', 'id' => $user->id]),
[
'title' => 'Voir',
'class' => 'btn btn-default'
]);
},
'update' => function ($url, $user) {
return Html::a('<span class="glyphicon glyphicon-pencil"></span>',
Yii::$app->urlManager->createUrl(['user/update', 'id' => $user->id]),
@@ -219,20 +222,20 @@ $this->render('_menu', [
]);
},
'delete' => function ($url, $model) {
return Html::a('<span class="glyphicon glyphicon-trash"></span>',
return Html::a('<span class="glyphicon glyphicon-minus"></span> Enlever',
Yii::$app->urlManager->createUrl(array_merge(['user/delete', 'id' => $model->id], Yii::$app->getRequest()->getQueryParams())),
[
'title' => 'Supprimer',
'class' => 'btn btn-default btn-confirm-delete'
'title' => 'Enlever',
'class' => 'btn-confirm-delete'
]);
},
'switch' => function($url, $model) use ($userModule, $userCurrent) {
if($userModule->getAuthorizationChecker()->isGrantedAsAdministrator($userCurrent)) {
return Html::a('<span class="glyphicon glyphicon-user"></span>',
return Html::a('<i class="fa fa-fw fa-user-secret"></i> Prendre la main',
Yii::$app->urlManager->createUrl(['user/switch-identity', 'id' => $model->id]),
[
'title' => 'Prendre la main',
'class' => 'btn btn-default'
'class' => ''
]);
}
}

+ 23
- 15
backend/views/user/orders.php Целия файл

@@ -36,50 +36,58 @@
* termes.
*/

use domain\User\User\UserModule;
use yii\grid\GridView;
use yii\helpers\Html;

$userModule = $this->getUserModule();
$orderModule = $this->getOrderModule();

$this->setTitle('Commandes <small>' . Html::encode($userModule->getUsername($user)) . '</small>', 'Commandes de ' . Html::encode($userModule->getUsername($user)));
$this->addBreadcrumb(['label' => 'Utilisateurs', 'url' => ['index']]);
$this->addBreadcrumb(['label' => Html::encode($user->lastname . ' ' . $user->name)]);
$this->addBreadcrumb('Commandes');
$userModule = UserModule::getInstance();
$username = Html::encode($userModule->getSolver()->getUsername($user));
$this->setTitle($username.' (#'.$user->id.')') ;
$this->addBreadcrumb(['label' => 'Utilisateurs', 'url' => ['index']]) ;
$this->addBreadcrumb(['label' => $username]) ;
$this->addBreadcrumb('Commandes') ;

?>

<div class="user-orders">
<?= $this->render('_menu_navigation', [
'action' => 'orders',
'user' => $user
]); ?>

<div class="user-orders tab-content">
<?= GridView::widget([
'filterModel' => $searchModel,
//'filterModel' => $searchModel,
'dataProvider' => $dataProvider,
'columns' => [
[
'attribute' => 'distribution.date',
'label' => 'Date de livraison',
'label' => 'Date',
'value' => function ($user) {
return date('d/m/Y',strtotime($user->distribution->date));
}
],
[
'label' => 'Historique',
'label' => 'Point de vente',
'format' => 'raw',
'value' => function ($order) use ($orderModule) {
return $orderModule->getHistorySummary($order);
return $orderModule->getPointSaleSummary($order);
}
],
[
'label' => 'Résumé',
/*[
'label' => 'Historique',
'format' => 'raw',
'value' => function ($order) use ($orderModule) {
return $orderModule->getCartSummary($order);
return $orderModule->getHistorySummary($order);
}
],
],*/
[
'label' => 'Point de vente',
'label' => 'Produits',
'format' => 'raw',
'value' => function ($order) use ($orderModule) {
return $orderModule->getPointSaleSummary($order);
return $orderModule->getCartSummary($order);
}
],
[

+ 12
- 3
backend/views/user/update.php Целия файл

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

use domain\User\User\UserModule;
use yii\helpers\Html;

$this->setTitle('Modifier un client (#'.$model->id.')') ;
$userModule = UserModule::getInstance();
$username = Html::encode($userModule->getSolver()->getUsername($model));
$this->setTitle($username.' (#'.$model->id.')') ;
$this->addBreadcrumb(['label' => 'Utilisateurs', 'url' => ['index']]) ;
$this->addBreadcrumb(['label' => Html::encode($model->lastname.' '.$model->name)]) ;
$this->addBreadcrumb(['label' => $username]) ;
$this->addBreadcrumb('Modifier') ;

?>

<div class="user-update">
<?= $this->render('_menu_navigation', [
'action' => 'update',
'user' => $model
]); ?>

<div class="user-update tab-content">
<?= $this->render('_form', [
'model' => $model,
'pointsSaleArray' => $pointsSaleArray,
'userGroupsArray' => $userGroupsArray,
'pointSaleBillingArray' => $pointSaleBillingArray
]) ?>
<div class="clr"></div>
</div>

+ 301
- 0
backend/views/user/view.php Целия файл

@@ -0,0 +1,301 @@
<?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.
*/

use common\helpers\Price;
use domain\Order\Order\OrderModule;
use domain\User\User\UserModule;
use yii\helpers\Html;
use yii\widgets\ActiveForm;

$orderModule = OrderModule::getInstance();
$userModule = UserModule::getInstance();
$username = Html::encode($userModule->getSolver()->getUsername($model));
$this->setTitle($username.' (#'.$model->id.')') ;
$this->addBreadcrumb(['label' => 'Utilisateurs', 'url' => ['index']]) ;
$this->addBreadcrumb(['label' => $username]) ;
$this->addBreadcrumb('Récapitulatif') ;

?>

<?= $this->render('_menu_navigation', [
'action' => 'view',
'user' => $model
]); ?>

<div class="user-view tab-content">
<div class="col-md-6 col-no-padding-left">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">
<i class="fa fa-user"></i>
Profil
<a class="btn btn-default btn-xs" href="<?= Yii::$app->urlManager->createUrl(['user/update','id' => $model->id]) ?>">
<span class="glyphicon glyphicon-pencil"></span>
Modifier
</a>
</h3>
</div>
<div class="panel-body">
<ul class="list-group list-group-unbordered">
<li class="list-group-item">
<strong>Type</strong>
<span class="pull-right">
<?= $userModule->getSolver()->getTypeLabel($model->type) ?>
</span>
</li>
<li class="list-group-item">
<strong>Nom</strong>
<span class="pull-right">
<?= $userModule->getSolver()->getUsername($model) ?>
</span>
</li>
<?php if($model->phone): ?>
<li class="list-group-item">
<strong>Téléphone</strong>
<span class="pull-right">
<span class="glyphicon glyphicon-phone"></span>
<?= $model->phone ?>
</span>
</li>
<?php endif; ?>
<?php if($model->email): ?>
<li class="list-group-item">
<strong>Email</strong>
<span class="pull-right">
<span class="glyphicon glyphicon-envelope"></span>
<a href="mailto:<?= $model->email ?>"><?= $model->email ?></a>
</span>
</li>
<?php endif; ?>
<?php if($model->address): ?>
<li class="list-group-item list-group-item-address">
<strong>Adresse</strong>
<span class="pull-right">
<?= nl2br($model->address) ?>
</span>
<div class="clr"></div>
</li>
<?php endif; ?>
<li class="list-group-item">
<strong>Bulletin d'information</strong>
<span class="pull-right">
<?php $isUserSubscribedNewsletter = $userModule->getNewsletterManager()->isUserSubscribedNewsletter($model); ?>
<span class="label label-<?= $isUserSubscribedNewsletter ? 'success' : 'default' ?>">
<?= $isUserSubscribedNewsletter ? 'Oui' : 'Non' ?>
</span>
</span>
</li>
<?php if($model->userPointSale): ?>
<li class="list-group-item">
<strong>Points de vente</strong>
<span class="pull-right">
<?php foreach($model->userPointSale as $userPointSale): ?>
<span class="label label-default"><?= $userPointSale->pointSale->name; ?></span>
<?php endforeach; ?>
</span>
</li>
<?php endif; ?>
<?php if($model->userUserGroup): ?>
<li class="list-group-item">
<strong>Groupes d'utilisateurs</strong>
<span class="pull-right">
<?php foreach($model->userUserGroup as $userUserGroup): ?>
<span class="label label-default"><?= $userUserGroup->userGroup->name; ?></span>
<?php endforeach; ?>
</span>
</li>
<?php endif; ?>
</ul>
</div>
</div>

<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">
<span class="glyphicon glyphicon-log-in"></span>
Dernière connexion et inscription
</h3>
</div>
<div class="panel-body">
<ul class="list-group list-group-unbordered">
<li class="list-group-item">
<strong>Dernière connexion</strong>
<span class="pull-right">
<?php if($model->date_last_connection): ?>
<?= date('d/m/Y à H:i:s', strtotime($model->date_last_connection)) ?>
<?php else: ?>
--
<?php endif; ?>
</span>
</li>
<li class="list-group-item">
<strong>Inscription</strong>
<span class="pull-right">
<?= date('d/m/Y à H:i:s', $model->created_at) ?>
</span>
</li>
</ul>
</div>
</div>

<?php if($model->email): ?>
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">
<i class="fa fa-envelope"></i>
Emails accès
</h3>
</div>
<div class="panel-body">
<?php $form = ActiveForm::begin(); ?>
<div class="form-group">
<?= Html::submitButton(
'<i class="fa fa-key"></i> Envoyer un nouveau mot de passe',
['class' => 'btn btn-default', 'name' => 'submit_new_password', 'value' => 1]
) ?>
</div>
<?php ActiveForm::end(); ?>

<?php $form = ActiveForm::begin(); ?>
<div class="form-group">
<?= Html::submitButton(
'<i class="fa fa-home"></i> Envoyer l\'email de bienvenue',
['class' => 'btn btn-default', 'name' => 'submit_mail_welcome', 'value' => 1]
) ?>
</div>
<?php ActiveForm::end(); ?>
</div>
</div>
<?php endif; ?>

</div>
<div class="col-md-6 col-no-padding-right">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">
<i class="glyphicon glyphicon-piggy-bank"></i>
Crédit
<a class="btn btn-default btn-xs" href="<?= Yii::$app->urlManager->createUrl(['user/credit','id' => $model->id]) ?>">
<span class="glyphicon glyphicon-euro"></span>
Voir / créditer
</a>
</h3>
</div>
<div class="panel-body">
<ul class="list-group list-group-unbordered">
<li class="list-group-item">
<strong>Montant</strong>
<span class="pull-right">
<?php $credit = $userModule->getRepository()->getCredit($model); ?>
<span class="label label-<?= $credit > 0 ? 'success' : 'danger' ?>">
<?= Price::format($credit) ?>
</span>
</span>
</li>
<li class="list-group-item">
<strong>Crédit obligatoire</strong>
<span class="pull-right">
<?php $creditActive = $userModule->getRepository()->getCreditActive($model) ?>
<span class="label label-<?= $creditActive ? 'success' : 'default' ?>">
<?= $creditActive ? 'Oui' : 'Non' ?>
</span>
</span>
</li>
</ul>
</div>
</div>

<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">
<i class="glyphicon glyphicon-th-list"></i>
Commandes
<a class="btn btn-default btn-xs" href="<?= Yii::$app->urlManager->createUrl(['user/orders','id' => $model->id]) ?>">
<span class="glyphicon glyphicon-eye-open"></span>
Voir
</a>
</h3>
</div>
<div class="panel-body">

<?php $countOrders = $orderModule->getRepository()->countOrdersByUser($model); ?>
<?php if($countOrders): ?>
<ul class="list-group list-group-unbordered">
<li class="list-group-item">
<strong>Nombre</strong>
<span class="pull-right">
<?= $orderModule->getRepository()->countOrdersByUser($model) ?>
</span>
</li>
<li class="list-group-item">
<strong>Panier moyen</strong>
<span class="pull-right">
<?= Price::format($orderModule->getRepository()->getAverageBasketByUser($model)); ?>
</span>
</li>
</ul>
<?php else: ?>
<div class="alert alert-info">
Aucune commande
</div>
<?php endif; ?>
</div>
</div>

<?php if(isset($pointSaleBillingArray) && $pointSaleBillingArray && count($pointSaleBillingArray) > 0): ?>
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">
<i class="fa fa-sticky-note-o"></i>
Contact facturation
</h3>
</div>
<div class="panel-body">
<?php foreach($pointSaleBillingArray as $pointSale): ?>
<a class="btn btn-default btn-sm" href="<?= Yii::$app->urlManager->createUrl(['point-sale/update', 'id' => $pointSale->id]) ?>">
<i class="fa fa-map-marker"></i>
<?= $pointSale->name ?>
</a><br />
<?php endforeach; ?>
</div>
</div>
<?php endif; ?>

</div>
<div class="clr"></div>
</div>

+ 409
- 324
backend/web/css/screen.css
Файловите разлики са ограничени, защото са твърде много
Целия файл


+ 46
- 3
backend/web/sass/_adminlte.scss Целия файл

@@ -174,6 +174,12 @@ body.skin-black {
.sidebar-menu > li.header {
color: #899397;
}

.label {
padding-top: 5px;
position: relative;
top: -3px;
}
}

.sidebar-menu > li.active > a {
@@ -217,9 +223,22 @@ body.skin-black {
}
}

.col-no-padding-left {
padding-left: 0px;
}

.col-no-padding-right {
padding-right: 0px;
}

a {
color: darken($color1, 5) ;
}

.label {
padding-top: 4px;
padding-bottom: 1px;
}
.btn {
color: white ;
@@ -235,8 +254,26 @@ body.skin-black {
color: white ;
border-color: $color1 ;
}

.nav.nav-tabs {
.badge {
margin-left: 4px;
background-color: #e0e0e0;
color: #444;
}
}

.tab-content {
border-left: solid 1px #ddd;
border-bottom: solid 1px #ddd;
border-right: solid 1px #ddd;
padding: 30px 15px 15px 15px;
background-color: white;
}

.alert {
position: relative;

a {
color: white ;
}
@@ -247,8 +284,9 @@ body.skin-black {

.close {
font-size: 30px;
position: relative;
top: -25px;
position: absolute;
top: 10px;
right: 15px;
text-decoration: none;
color: white;
opacity: 0.6;
@@ -319,6 +357,11 @@ body.skin-black {
margin-left: 10px;
}
}

.form-buttons {
margin-top: 25px;
text-align: right;
}
}
.main-footer {

+ 8
- 0
backend/web/sass/distribution/_index.scss Целия файл

@@ -261,6 +261,14 @@ termes.
display: block;
}

a {
color: #333;

&:hover {
text-decoration: underline;
}
}

.shortcuts {
display: none;
float: right;

+ 29
- 9
backend/web/sass/screen.scss Целия файл

@@ -67,6 +67,10 @@ a {
float: left;
}

.align-center {
text-align: center ;
}

#block-demo {
padding: 10px 0px ;
background-color: $color2 ;
@@ -1376,15 +1380,29 @@ a.btn, button.btn {

.user-credit {
.the-credit {
float: right ;
font-size: 28px;
font-weight: bold ;
background-color: $color1 ;
color: white ;
@include border-radius(8px) ;
padding: 3px 10px ;
padding-top: 7px ;
position: relative ;
top: -12px ;
text-align: center;
color: #333;

.glyphicon {
//display: none;
float: left;
}
}

p.info {
padding: 10px;
}

.panel-form-credit-debit {
.field-creditform-send_mail {
position: relative;
top: 11px;
}
.form-buttons {
margin: 0px !important;
}
}
}

@@ -1519,7 +1537,9 @@ a.btn, button.btn {
@import "distribution/_index.scss" ;
@import "user/_emails.scss" ;
@import "user/_credit.scss" ;
@import "user/_form.scss" ;
@import "user/_form.scss" ;
@import "user/_view.scss" ;
@import "user/_index.scss" ;
@import "producer/_update.scss" ;
@import "point_sale/_index.scss" ;
@import "point_sale/_form.scss" ;

+ 15
- 0
backend/web/sass/user/_index.scss Целия файл

@@ -0,0 +1,15 @@

.user-index {
.wrapper-button-dropdown {
display: inline-block;
position: relative;

.dropdown-menu {
left: -138px;

a {
color: #333;
}
}
}
}

+ 9
- 0
backend/web/sass/user/_view.scss Целия файл

@@ -0,0 +1,9 @@

.user-view {
.list-group-item-address {
.pull-right {
text-align: right;
}
}
}


+ 2
- 1
common/config/params.php Целия файл

@@ -37,9 +37,10 @@
*/

return [
'version' => '24.2.B',
'version' => '24.2.C',
'maintenanceMode' => false,
'siteName' => 'Opendistrib',
'tinyMcePlugins' => 'preview searchreplace autolink autosave save directionality code visualblocks visualchars fullscreen image link lists wordcount help',
'adminEmail' => 'contact@opendistrib.net',
'supportEmail' => 'contact@opendistrib.net',
'user.passwordResetTokenExpire' => 3600,

+ 26
- 0
common/versions/24.2.C.php Целия файл

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

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

version(
'19/02/2024',
[
[
"[Administration] Utilisateurs : vue récapitulative et nouveau menu de navigation",
"[Administration] Communication > Email : champs texte du message enrichi",
"[Administration] Statistiques > Chiffre d'affaire : échelle statique (début à 0€) et affichage du CA en TTC et HT",
"[Administration] Distributions > CA : affichage du CA journalier en TTC et HT"
],
[
]
],
[
[
],
[
]
],
$userCurrent
);

?>

+ 8
- 0
domain/Distribution/Distribution/DistributionRepository.php Целия файл

@@ -71,6 +71,14 @@ class DistributionRepository extends AbstractRepository
->find();
}

public function findDistributionsWithOrders()
{
return $this->createDefaultQuery()
->filterHasOrders()
->orderBy('date ASC')
->find();
}

/**
* Récupère les distributions futures.
*/

+ 6
- 0
domain/Distribution/Distribution/DistributionRepositoryQuery.php Целия файл

@@ -28,6 +28,12 @@ class DistributionRepositoryQuery extends AbstractRepositoryQuery
return $this;
}

public function filterHasOrders(): self
{
$this->innerJoinWith('order');
return $this;
}

public function filterByDateBetterThanToday(): self
{
$this->query

+ 41
- 0
domain/Order/Order/OrderRepository.php Целия файл

@@ -187,6 +187,15 @@ class OrderRepository extends AbstractRepository
->find();
}

public function findOrdersByUser(User $user)
{
return $this
->createDefaultQuery()
->filterByUser($user)
->filterIsValid()
->find();
}

public function queryOrdersHistory(Producer $producer, User $user)
{
$queryIncoming = clone $this->createDefaultQuery()
@@ -689,4 +698,36 @@ class OrderRepository extends AbstractRepository

return $ordersArray;
}

public function countOrdersByUser(User $user)
{
return Order::searchCount([
'id_user' => $user->id,
], ['conditions' => 'date_delete IS NULL']);
}

public function getTotalAmountSpent(User $user): float
{
$orderBuilder = OrderBuilder::getInstance();
$totalAmountSpent = 0;
$ordersArray = $this->findOrdersByUser($user);
foreach($ordersArray as $order) {
$orderBuilder->initOrder($order);
$totalAmountSpent += $this->orderSolver->getOrderAmountWithTax($order);
}

return $totalAmountSpent;
}

public function getAverageBasketByUser(User $user): ?float
{
$countOrders = $this->countOrdersByUser($user);
$totalAmountSpent = $this->getTotalAmountSpent($user);

if($countOrders && $totalAmountSpent) {
return $totalAmountSpent / $countOrders;
}

return null;
}
}

+ 2
- 2
domain/Payment/PaymentSolver.php Целия файл

@@ -77,9 +77,9 @@ class PaymentSolver extends AbstractService implements SolverInterface
}

if ($order && $order->distribution) {
$str .= '<br />Commande du <a href="'.\Yii::$app->urlManager->createUrl(['distribution/index', 'date' => $order->distribution->date]).'">' . date('d/m/Y', strtotime($order->distribution->date)).'</a>';
$str .= ' : commande du <a href="'.\Yii::$app->urlManager->createUrl(['distribution/index', 'date' => $order->distribution->date]).'">' . date('d/m/Y', strtotime($order->distribution->date)).'</a>';
} else {
$str .= '<br />Commande supprimée';
$str .= ' : commande supprimée';
}
}


+ 20
- 12
domain/Producer/Producer/ProducerRepository.php Целия файл

@@ -113,7 +113,7 @@ class ProducerRepository extends AbstractRepository
public function getTurnoverLastMonth(Producer $producer, bool $format = false)
{
$period = date('Y-m', strtotime('-1 month'));
return $this->getTurnover($producer, $period, $format);
return $this->getTurnover($producer, $period, false, $format);
}

public function getYearsWithTurnover(Producer $producer): array
@@ -144,7 +144,7 @@ class ProducerRepository extends AbstractRepository
/**
* Retourne le CA du producteur pour un mois donné
*/
public function getTurnover(Producer $producer, string $period = '', bool $format = false)
public function getTurnover(Producer $producer, string $period = '', bool $withTax = false, bool $format = false)
{
if (!$period) {
$period = date('Y-m');
@@ -153,10 +153,10 @@ class ProducerRepository extends AbstractRepository
$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);
return $this->getTurnoverByDateStartEnd($producer, $dateStart, $dateEnd, $withTax, $format);
}

public function getTurnoverByWeek(Producer $producer, int $year, int $week, bool $format = false)
public function getTurnoverByWeek(Producer $producer, int $year, int $week, bool $withTax = false, bool $format = false)
{
$date = new \DateTime();
$date->setISODate($year, $week);
@@ -164,21 +164,29 @@ class ProducerRepository extends AbstractRepository
$date->modify('+6 days');
$dateEnd = $date->format('Y-m-d');

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

public function getTurnoverByDateStartEnd(Producer $producer, string $dateStart, string $dateEnd, bool $format = false)
public function getTurnoverByDateStartEnd(Producer $producer, string $dateStart, string $dateEnd, bool $withTax = false, bool $format = false)
{
$connection = \Yii::$app->getDb();

$selectSum = 'product_order.price * product_order.quantity';
if($withTax) {
$selectSum .= ' * (tax_rate.value + 1)';
}

$command = $connection->createCommand(
'
SELECT SUM(product_order.price * product_order.quantity) AS turnover
FROM `order`, product_order, distribution
SELECT SUM('.$selectSum.') AS turnover
FROM `order`, product_order, distribution, tax_rate
WHERE `order`.id = product_order.id_order
AND `order`.date_delete IS NULL
AND distribution.id_producer = :id_producer
AND `order`.id_distribution = distribution.id
AND distribution.date > :date_start
AND distribution.date < :date_end',
AND distribution.date < :date_end
AND product_order.id_tax_rate = tax_rate.id',
[
':date_start' => $dateStart,
':date_end' => $dateEnd,
@@ -215,7 +223,7 @@ class ProducerRepository extends AbstractRepository
return $this->producerPriceRangeRepository->getAmountToBeBilledByTurnover($turnover, $format);
}

public function getDatasChartTurnoverStatistics(Producer $producer, int $year, string $displayBy = 'month')
public function getDatasChartTurnoverStatistics(Producer $producer, int $year, string $displayBy = 'month', bool $withTax = false)
{
$data = [];
$dataLabels = [];
@@ -235,7 +243,7 @@ class ProducerRepository extends AbstractRepository
foreach ($period as $date) {
$week = $date->format('W');
$dataLabels[] = $week;
$turnover = $this->getTurnoverByWeek($producer, $year, $date->format('W'));
$turnover = $this->getTurnoverByWeek($producer, $year, $date->format('W'), $withTax);
$data[$week] = $turnover;
}
}
@@ -243,7 +251,7 @@ class ProducerRepository extends AbstractRepository
foreach ($period as $date) {
$month = $date->format('m/Y');
$dataLabels[] = $month;
$turnover = $this->getTurnover($producer, $date->format('Y-m'));
$turnover = $this->getTurnover($producer, $date->format('Y-m'), $withTax);
$data[$month] = $turnover;
}
}

+ 3
- 2
domain/Product/Product/ProductSolver.php Целия файл

@@ -275,13 +275,14 @@ class ProductSolver extends AbstractService implements SolverInterface
return $productArrayFilter;
}

public function getProductDistributionPotentialRevenues(array $productsArray)
public function getProductDistributionPotentialRevenues(array $productsArray, bool $withTax = false)
{
$potentialRevenues = 0;

foreach ($productsArray as $product) {
if (isset($product['productDistribution'][0]) && $product['productDistribution'][0]['active'] && $product['productDistribution'][0]['quantity_max']) {
$potentialRevenues += $product['productDistribution'][0]['quantity_max'] * $product['price'];
$price = $withTax ? $product['price_with_tax'] : $product['price'];
$potentialRevenues += $product['productDistribution'][0]['quantity_max'] * $price;
}
}


+ 6
- 0
domain/User/User/User.php Целия файл

@@ -40,6 +40,7 @@ namespace domain\User\User;

use common\components\ActiveRecordCommon;
use domain\Order\Order\Order;
use domain\PointSale\UserPointSale\UserPointSale;
use domain\Producer\Producer\Producer;
use domain\User\UserProducer\UserProducer;
use domain\User\UserUserGroup\UserUserGroup;
@@ -254,6 +255,11 @@ class User extends ActiveRecordCommon implements IdentityInterface
return $this->hasMany(UserProducer::class, ['id_user' => 'id']);
}

public function getUserPointSale()
{
return $this->hasMany(UserPointSale::class, ['id_user' => 'id']);
}

public function getUserUserGroup()
{
return $this->hasMany(UserUserGroup::class, ['id_user' => 'id']);

+ 3
- 2
tests/codeception/common/unit/ExampleTest.php Целия файл

@@ -5,6 +5,7 @@ namespace tests\codeception\common\unit;
//use \Tests\Support\UnitTester;

use domain\Producer\Producer\Producer;
use domain\Producer\Producer\ProducerModule;
use tests\codeception\common\UnitTester;

class ExampleTest extends \Codeception\Test\Unit
@@ -17,8 +18,8 @@ class ExampleTest extends \Codeception\Test\Unit

public function testMe()
{
$producerContainer = ProducerContainer::getInstance();
$producer = $producerContainer->getBuilder()->instanciateProducer();
$producerModule = ProducerModule::getInstance();
$producer = $producerModule->getBuilder()->instanciateProducer();
$this->assertTrue($producer instanceof Producer, 'Producer instancié');
}
}

Loading…
Отказ
Запис