Browse Source

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

feature/souke
Guillaume Bourgeois 8 months ago
parent
commit
a9ecdc9c5c
10 changed files with 305 additions and 166 deletions
  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 View File



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



+ 1
- 1
backend/views/online-admin/index.php View File

<div class="box box-primary box-user"> <div class="box box-primary box-user">
<div class="box-body box-profile"> <div class="box-body box-profile">
<h3 class="profile-username text-center"> <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); ?> <?= $userModule->getSolver()->getUsername($userWithStatusUserOnline); ?>
</a> </a>
</h3> </h3>

+ 155
- 116
backend/views/user/credit.php View File

. ' Pensez à l\'activer si vous souhaitez qu\'elle soit visible de vos utilisateurs.</div>' ; . ' 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>
<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> </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> </div>
<?php ActiveForm::end(); ?>
</div> </div>
</div> </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>

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

+ 10
- 10
backend/views/user/orders.php View File



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

+ 40
- 0
backend/views/user/view.php View File

*/ */


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


$orderModule = OrderModule::getInstance();
$userModule = UserModule::getInstance(); $userModule = UserModule::getInstance();
$username = Html::encode($userModule->getSolver()->getUsername($model)); $username = Html::encode($userModule->getSolver()->getUsername($model));
$this->setTitle($username.' (#'.$model->id.')') ; $this->setTitle($username.' (#'.$model->id.')') ;
</ul> </ul>
</div> </div>
</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>
<div class="clr"></div> <div class="clr"></div>
</div> </div>

+ 39
- 29
backend/web/css/screen.css View File



/* line 1378, ../sass/screen.scss */ /* line 1378, ../sass/screen.scss */
.user-credit .the-credit { .user-credit .the-credit {
float: right;
font-size: 28px;
font-weight: bold; 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; position: relative;
top: -12px;
top: 11px;
}
/* line 1399, ../sass/screen.scss */
.user-credit .panel-form-credit-debit .form-buttons {
margin: 0px !important;
} }


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


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


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

+ 22
- 8
backend/web/sass/screen.scss View File



.user-credit { .user-credit {
.the-credit { .the-credit {
float: right ;
font-size: 28px;
font-weight: bold ; 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 View File

->find(); ->find();
} }


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

public function queryOrdersHistory(Producer $producer, User $user) public function queryOrdersHistory(Producer $producer, User $user)
{ {
$queryIncoming = clone $this->createDefaultQuery() $queryIncoming = clone $this->createDefaultQuery()
'id_user' => $user->id, 'id_user' => $user->id,
], ['conditions' => 'date_delete IS NULL']); ], ['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 View File

} }


if ($order && $order->distribution) { 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 { } else {
$str .= '<br />Commande supprimée';
$str .= ' : commande supprimée';
} }
} }



+ 1
- 0
domain/Producer/Producer/ProducerRepository.php View File

SELECT SUM(product_order.price * product_order.quantity) AS turnover SELECT SUM(product_order.price * product_order.quantity) AS turnover
FROM `order`, product_order, distribution FROM `order`, product_order, distribution
WHERE `order`.id = product_order.id_order WHERE `order`.id = product_order.id_order
AND `order`.date_delete IS NULL
AND distribution.id_producer = :id_producer AND distribution.id_producer = :id_producer
AND `order`.id_distribution = distribution.id AND `order`.id_distribution = distribution.id
AND distribution.date > :date_start AND distribution.date > :date_start

Loading…
Cancel
Save