Procházet zdrojové kódy

[Administration] Utilisateurs : vue récapitulative et nouveau menu de navigation

feature/souke
Guillaume Bourgeois před 9 měsíci
rodič
revize
a9ecdc9c5c
10 změnil soubory, kde provedl 305 přidání a 166 odebrání
  1. +1
    -0
      backend/controllers/UserController.php
  2. +1
    -1
      backend/views/online-admin/index.php
  3. +155
    -116
      backend/views/user/credit.php
  4. +10
    -10
      backend/views/user/orders.php
  5. +40
    -0
      backend/views/user/view.php
  6. +39
    -29
      backend/web/css/screen.css
  7. +22
    -8
      backend/web/sass/screen.scss
  8. +34
    -0
      domain/Order/Order/OrderRepository.php
  9. +2
    -2
      domain/Payment/PaymentSolver.php
  10. +1
    -0
      domain/Producer/Producer/ProducerRepository.php

+ 1
- 0
backend/controllers/UserController.php Zobrazit soubor

@@ -171,6 +171,7 @@ class UserController extends BackendController

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


+ 1
- 1
backend/views/online-admin/index.php Zobrazit soubor

@@ -103,7 +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]); ?>">
<a title="Voir" href="<?= $this->getUrlManagerBackend()->createUrl(['user/view', 'id' => $userWithStatusUserOnline->id]); ?>">
<?= $userModule->getSolver()->getUsername($userWithStatusUserOnline); ?>
</a>
</h3>

+ 155
- 116
backend/views/user/credit.php Zobrazit soubor

@@ -73,129 +73,168 @@ $this->addBreadcrumb('Crédit') ;
. ' Pensez à l\'activer si vous souhaitez qu\'elle soit visible de vos utilisateurs.</div>' ;
}
?>
<div class="col-md-4 col-no-padding-left">
<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-6">
<?= $form->field($creditForm, 'send_mail')->checkbox() ?>
</div>
<div class="col-md-6">
<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 col-no-padding-right">
<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>

+ 10
- 10
backend/views/user/orders.php Zobrazit soubor

@@ -59,35 +59,35 @@ $this->addBreadcrumb('Commandes') ;

<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);
}
],
[

+ 40
- 0
backend/views/user/view.php Zobrazit soubor

@@ -37,10 +37,12 @@ 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.')') ;
@@ -226,6 +228,44 @@ $this->addBreadcrumb('Récapitulatif') ;
</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>

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

+ 39
- 29
backend/web/css/screen.css Zobrazit soubor

@@ -1403,30 +1403,40 @@ a.btn.btn-primary .glyphicon-triangle-bottom, button.btn.btn-primary .glyphicon-

/* line 1378, ../sass/screen.scss */
.user-credit .the-credit {
float: right;
font-size: 28px;
font-weight: bold;
background-color: #F39C12;
color: white;
-moz-border-radius: 8px;
-webkit-border-radius: 8px;
border-radius: 8px;
padding: 3px 10px;
padding-top: 7px;
text-align: center;
color: #333;
}
/* line 1384, ../sass/screen.scss */
.user-credit .the-credit .glyphicon {
float: left;
}
/* line 1390, ../sass/screen.scss */
.user-credit p.info {
padding: 10px;
}
/* line 1395, ../sass/screen.scss */
.user-credit .panel-form-credit-debit .field-creditform-send_mail {
position: relative;
top: -12px;
top: 11px;
}
/* line 1399, ../sass/screen.scss */
.user-credit .panel-form-credit-debit .form-buttons {
margin: 0px !important;
}

/* facturation */
/* line 1393, ../sass/screen.scss */
/* line 1407, ../sass/screen.scss */
#free-price {
padding: 20px;
background-color: #F9F9F9;
}
/* line 1397, ../sass/screen.scss */
/* line 1411, ../sass/screen.scss */
#free-price h2 {
font-family: "myriadpro-it";
}
/* line 1401, ../sass/screen.scss */
/* line 1415, ../sass/screen.scss */
#free-price .amount span {
font-size: 25px;
color: white;
@@ -1438,25 +1448,25 @@ a.btn.btn-primary .glyphicon-triangle-bottom, button.btn.btn-primary .glyphicon-
padding-top: 7px;
font-family: "myriadpro-regular";
}
/* line 1412, ../sass/screen.scss */
/* line 1426, ../sass/screen.scss */
#free-price label {
text-transform: uppercase;
font-family: "myriadpro-light";
font-size: 20px;
}
/* line 1417, ../sass/screen.scss */
/* line 1431, ../sass/screen.scss */
#free-price label span {
font-size: 16px;
}
/* line 1423, ../sass/screen.scss */
/* line 1437, ../sass/screen.scss */
#free-price .field-producer-free_price .input-group {
width: 200px;
}
/* line 1429, ../sass/screen.scss */
/* line 1443, ../sass/screen.scss */
#free-price .field-user-free_price label {
display: none;
}
/* line 1434, ../sass/screen.scss */
/* line 1448, ../sass/screen.scss */
#free-price #producer-free_price {
width: 100px;
height: 60px;
@@ -1465,37 +1475,37 @@ a.btn.btn-primary .glyphicon-triangle-bottom, button.btn.btn-primary .glyphicon-
text-align: center;
}

/* line 1444, ../sass/screen.scss */
/* line 1458, ../sass/screen.scss */
.development-index ul#tabs-status-developments {
margin-bottom: 30px;
border-bottom: solid 3px #F39C12;
}
/* line 1448, ../sass/screen.scss */
/* line 1462, ../sass/screen.scss */
.development-index ul#tabs-status-developments a {
text-transform: uppercase;
}
/* line 1451, ../sass/screen.scss */
/* line 1465, ../sass/screen.scss */
.development-index ul#tabs-status-developments .active {
border: 0px none;
background: none;
}
/* line 1454, ../sass/screen.scss */
/* line 1468, ../sass/screen.scss */
.development-index ul#tabs-status-developments .active a {
background-color: #F39C12;
color: white;
}
/* line 1462, ../sass/screen.scss */
/* line 1476, ../sass/screen.scss */
.development-index #tab-developments .btn-group-priority {
width: 100%;
margin-bottom: 5px;
}
/* line 1466, ../sass/screen.scss */
/* line 1480, ../sass/screen.scss */
.development-index #tab-developments .btn-group-priority .btn-priority {
display: block;
float: none;
width: 100%;
}
/* line 1473, ../sass/screen.scss */
/* line 1487, ../sass/screen.scss */
.development-index #tab-developments .label-priority {
display: block;
width: 100%;
@@ -1504,24 +1514,24 @@ a.btn.btn-primary .glyphicon-triangle-bottom, button.btn.btn-primary .glyphicon-
}

/* stats */
/* line 1486, ../sass/screen.scss */
/* line 1500, ../sass/screen.scss */
.stats-products #nav-year {
float: right;
}
/* line 1491, ../sass/screen.scss */
/* line 1505, ../sass/screen.scss */
.stats-products tr.month th {
text-align: center;
}
/* line 1496, ../sass/screen.scss */
/* line 1510, ../sass/screen.scss */
.stats-products tr.sub-head th {
font-weight: normal;
font-size: 12px;
}
/* line 1502, ../sass/screen.scss */
/* line 1516, ../sass/screen.scss */
.stats-products td.name {
text-transform: uppercase;
}
/* line 1506, ../sass/screen.scss */
/* line 1520, ../sass/screen.scss */
.stats-products td.align-center {
text-align: center;
}

+ 22
- 8
backend/web/sass/screen.scss Zobrazit soubor

@@ -1376,15 +1376,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;
}
}
}


+ 34
- 0
domain/Order/Order/OrderRepository.php Zobrazit soubor

@@ -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()
@@ -696,4 +705,29 @@ class OrderRepository extends AbstractRepository
'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 Zobrazit soubor

@@ -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';
}
}


+ 1
- 0
domain/Producer/Producer/ProducerRepository.php Zobrazit soubor

@@ -175,6 +175,7 @@ class ProducerRepository extends AbstractRepository
SELECT SUM(product_order.price * product_order.quantity) AS turnover
FROM `order`, product_order, distribution
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

Načítá se…
Zrušit
Uložit