Browse Source

Adaptations producer/order/index

refactoring
Guillaume Bourgeois 6 years ago
parent
commit
7a847ab5fe
24 changed files with 462 additions and 430 deletions
  1. +92
    -84
      backend/controllers/OrderController.php
  2. +2
    -2
      backend/controllers/ProducerAdminController.php
  3. +1
    -1
      backend/controllers/SiteController.php
  4. +1
    -1
      backend/controllers/UserController.php
  5. +4
    -4
      backend/views/order/_total_orders.php
  6. +40
    -40
      backend/views/order/index.php
  7. +61
    -69
      backend/views/order/report.php
  8. +2
    -2
      backend/views/site/index.php
  9. BIN
      backend/web/.sass-cache/2a0ffb00578c9d5a537db16d14c734a22b18f35c/screen.scssc
  10. +82
    -82
      backend/web/css/screen.css
  11. +48
    -61
      backend/web/js/lechatdesnoisettes.js
  12. +38
    -38
      backend/web/sass/screen.scss
  13. +7
    -4
      common/components/ActiveRecordCommon.php
  14. +1
    -1
      common/models/CreditHistory.php
  15. +12
    -9
      common/models/Distribution.php
  16. +16
    -10
      common/models/Order.php
  17. +9
    -7
      common/models/PointSale.php
  18. +2
    -2
      common/models/PointSaleDistribution.php
  19. +1
    -1
      common/models/Product.php
  20. +1
    -1
      common/models/ProductDistribution.php
  21. +10
    -10
      common/models/Subscription.php
  22. +1
    -1
      common/models/User.php
  23. +15
    -0
      console/migrations/m181224_161347_change_column_order_type.php
  24. +16
    -0
      console/migrations/m181226_100720_rename_column_subscription_date_begin.php

+ 92
- 84
backend/controllers/OrderController.php View File

@@ -87,12 +87,12 @@ class OrderController extends BackendController
$idProducer = Producer::getId() ;
}
$arrayOrders = Order::searchAll([
'date' => $date,
'date_delete' => 'NULL'
$ordersArray = Order::searchAll([
'distribution.date' => $date,
],
[
'orderby' => 'comment_point_sale ASC, user.name ASC'
'orderby' => 'comment_point_sale ASC, user.name ASC',
'conditions' => 'date_delete IS NULL'
]) ;
$distribution = Distribution::searchOne([],[
@@ -101,24 +101,26 @@ class OrderController extends BackendController
]) ;
if ($distribution) {
$arraySelectedProducts = ProductDistribution::searchProducts($distribution->id) ;
$arrayPointsSale = PointSale::searchAll() ;
$selectedProductsArray = ProductDistribution::searchByDistribution($distribution->id) ;
$pointsSaleArray = PointSale::searchAll() ;
foreach ($arrayPointsSale as $pointSale) {
$pointSale->initOrders($orders) ;
foreach ($pointsSaleArray as $pointSale) {
$pointSale->initOrders($ordersArray) ;
}
// produits
$arrayProducts = Product::searchAll() ;
$productsArray = Product::searchAll() ;

// get your HTML raw content without any layouts or scripts
$content = $this->renderPartial('report', [
'distribution' => $distribution,
'date' => $date,
'arraySelectedProducts' => $arraySelectedProducts,
'arrayPointsSale' => $arrayPointsSale,
'arrayProducts' => $arrayProducts,
'arrayOrders' => $arrayOrders
'distribution' => $distribution,
'selectedProductsArray' => $selectedProductsArray,
'pointsSaleArray' => $pointsSaleArray,
'productsArray' => $productsArray,
'ordersArray' => $ordersArray
]);

$dateStr = date('d/m/Y', strtotime($date));
@@ -138,7 +140,7 @@ class OrderController extends BackendController
'orientation' => Pdf::ORIENT_PORTRAIT,
// stream to browser inline
'destination' => $destination,
'filename' => Yii::getAlias('@app/web/pdf/Commandes-' . $date . '-' . $idProducert . '.pdf'),
'filename' => Yii::getAlias('@app/web/pdf/Commandes-' . $date . '-' . $idProducer . '.pdf'),
// your html content input
'content' => $content,
// format content from your own css file if needed or use the
@@ -195,7 +197,7 @@ class OrderController extends BackendController
/**
* Traite le formulaire d'ajout/modification de commande.
*
* @param Production $production
* @param Distribution $distribution
* @param string $date
* @param array $points_vente
* @param array $produits
@@ -207,11 +209,11 @@ class OrderController extends BackendController
if ($date != '') {
// commandes
$orders = Order::searchAll([
'production.date' => $date
'distribution.date' => $date
]) ;

foreach ($pointsSale as $point) {
$point->initOrder($orders);
$point->initOrders($orders);

if (isset($_POST['submit_pv']) && $_POST['submit_pv']) {
// modifs
@@ -318,26 +320,28 @@ class OrderController extends BackendController
$this->processOrderForm($distribution, $date, $arrayPointsSale, $arrayProducts, $users);

// commandes
$arrayOrders = Commande::searchAll([
'date' => $date,
'date_delete' => 'NULL'
$arrayOrders = Order::searchAll([
'distribution.date' => $date,
], [
'conditions' => 'date_delete IS NULL'
]);
$revenues = 0;
$weight = 0 ;
$revenuesDelivered = 0;

foreach ($arrayOrders as $order) {
if(is_null($order->date_delete)) {
$revenues += $order->amount;
if ($order->id_point_sale != 1) {
$revenuesDelivered += $order->amount;
if($arrayOrders) {
foreach ($arrayOrders as $order) {
if(is_null($order->date_delete)) {
$revenues += $order->amount;
if ($order->id_point_sale != 1) {
$revenuesDelivered += $order->amount;
}
$weight += $order->weight;
}
$weight += $order->weight;
}
}
$revenues = number_format($revenues, 2);

// init commandes point de vente
@@ -348,23 +352,23 @@ class OrderController extends BackendController
$dataOptionsOrders = [];
foreach ($pointSale->orders as $order) {
if ($order->user) {
$dataSelectOrders[$order->id] = $order->user->name . ' ' . $c->user->lastname;
$dataSelectOrders[$order->id] = $order->user->name . ' ' . $order->user->lastname;
} else {
$dataSelectOrders[$order->id] = $order->username;
}

$dataOptionsOrders[$order->id] = [];
$arrayOptions = [];
$arrayOptions[$order->id]['amount'] = $c->montant;
$arrayOptions[$order->id]['str_amount'] = number_format($c->montant, 2, ',', '') . ' €';
$arrayOptions[$order->id]['amount_paid'] = $c->montant_paye;
$arrayOptions[$order->id]['amount'] = $order->amount;
$arrayOptions[$order->id]['str_amount'] = number_format($order->amount, 2, ',', '') . ' €';
$arrayOptions[$order->id]['paid_amount'] = $order->paid_amount;
$arrayOptions[$order->id]['products'] = [];
$arrayOptions[$order->id]['comment'] = Html::encode($c->commentaire);
$arrayOptions[$order->id]['comment'] = Html::encode($order->comment);
foreach ($order->productOrder as $productOrder) {
$arrayOptions[$order->id]['products'][$productOrder->id_product] = $productOrder->quantity;
}

$dataOptionsOrders[$order->id]['data-commande'] = json_encode($arrayOptions[$order->id]);
$dataOptionsOrders[$order->id]['data-order'] = json_encode($arrayOptions[$order->id]);
$dataOptionsOrders[$order->id]['value'] = $order->id;
}
$pointSale->data_select_orders = $dataSelectOrders ;
@@ -372,7 +376,7 @@ class OrderController extends BackendController
}

// gestion produits selec
if (isset($_POST['validate_product_selec'])) {
if (isset($_POST['valider_produit_selec'])) {

if (isset($_POST['Product'])) {

@@ -455,18 +459,22 @@ class OrderController extends BackendController
$oointsSaleDistribution = [];
if ($distribution) {
$oointsSaleDistribution = PointSaleDistribution::searchAll() ;
$pointsSaleDistribution = PointSaleDistribution::searchAll([
'id_distribution' => $distribution->id
]) ;
}

$arrayPointsSaleDistribution = [];
foreach ($arrayPointsSaleDistribution as $pointSaleDistribution) {
$key = $pointSaleDistribution->id_distribution . '-' . $pointSaleDistribution->id_point_sale;
if ($pointSaleDistribution->delivery == 1) {
$pointSaleDistribution->points_sale_distribution[] = $key;
}
if(isset($pointSaleDistribution->pointSale) && strlen($pointSaleDistribution->pointSale->name)) {
$arrayPointsSaleDistribution[$key] = Html::encode($pointSaleDistribution->pointSale->name);
if(isset($pointsSaleDistribution)) {
foreach ($pointsSaleDistribution as $pointSaleDistrib) {
$key = $pointSaleDistrib->id_distribution . '-' . $pointSaleDistrib->id_point_sale;
if ($pointSaleDistrib->delivery == 1) {
$pointSaleDistribution->points_sale_distribution[] = $key;
}
if(isset($pointSaleDistrib->pointSale) && strlen($pointSaleDistrib->pointSale->name)) {
$arrayPointsSaleDistribution[$key] = Html::encode($pointSaleDistrib->pointSale->name);
}
}
}
@@ -500,7 +508,7 @@ class OrderController extends BackendController
if($weekDistribution) {
$oneDistributionWeekActive = true ;
}
$datas = [
'arrayProducts' => $arrayProducts,
'arrayPointsSale' => $arrayPointsSale,
@@ -521,7 +529,7 @@ class OrderController extends BackendController
'oneDistributionWeekActive' => $oneDistributionWeekActive
];

if ($return_data) {
if ($returnData) {
return $datas;
} else {
return $this->render('index', $datas);
@@ -662,9 +670,9 @@ class OrderController extends BackendController
*
* @see OrderController::actionDownload()
* @param string $date
* @param array $produits
* @param array $points_vente
* @param array $commandes
* @param array $products
* @param array $pointsSale
* @param array $orders
* @return array
*/
public function contentRecapCSV($date, $products, $pointsSale, $orders)
@@ -888,7 +896,7 @@ class OrderController extends BackendController
$order->distribution->id_producer == Producer::getId()) {
$products = json_decode($products);
foreach ($produits as $key => $quantity) {
foreach ($products as $key => $quantity) {
$productOrder = ProductOrder::findOne([
'id_order' => $idOrder,
'id_product' => $key
@@ -957,10 +965,10 @@ class OrderController extends BackendController
if ($order) {
// remboursement si l'utilisateur a payé pour cette commande
$amountPaid = $order->getAmount(Order::AMOUNT_PAID);
if ($montantPaid > 0.01) {
if ($amountPaid > 0.01) {
$order->saveCreditHistory(
CreditHistory::TYPE_REFUND,
$montantPaid,
$amountPaid,
Producer::getId(),
$order->id_user,
User::getCurrentId()
@@ -1014,7 +1022,7 @@ class OrderController extends BackendController
$order->date = date('Y-m-d H:i:s', strtotime($date . ' ' . date('H:i:s')));
$order->id_point_sale = $idPointSale;
$order->id_distribution = $distribution->id;
$order->type = Order::ORIGIN_ADMIN;
$order->origin = Order::ORIGIN_ADMIN;
$order->comment = $comment;

if ($idUser) {
@@ -1034,7 +1042,7 @@ class OrderController extends BackendController
$order->id_user = 0;
}

$commande->save();
$order->save();

foreach ($products as $key => $quantity) {
$product = Product::findOne($key);
@@ -1043,7 +1051,7 @@ class OrderController extends BackendController
$productOrder->id_order = $order->id;
$productOrder->id_product = $key;
$productOrder->quantity = $quantity;
$productOrder->price = $produit->price;
$productOrder->price = $product->price;
$productOrder->save();
}
}
@@ -1083,22 +1091,22 @@ class OrderController extends BackendController
$strComment = ' <span class="glyphicon glyphicon-comment"></span>';
}

$strLabelOrderType = '';
if ($order->type) {
$strLabelOrderType = ' <span class="label label-warning">vous</span>';
$strLabelOrderOrigin = '';
if ($order->origin) {
$strLabelOrderOrigin = ' <span class="label label-warning">vous</span>';
}

echo json_encode([
'id_order' => $order->id,
'total_point_sale' => number_format($point_sale->revenues, 2) . ' €',
'total_point_sale' => number_format($pointSale->revenues, 2) . ' €',
'order' => '<li>'
. '<a class="btn btn-default" href="javascript:void(0);" '
. 'data-point-sale-id="' . $id_point_sale . '" '
. 'data-id-order="' . $order->id . '" '
. 'data-order=\'' . $jsonOrder. '\' '
. 'data-pv-id="' . $idPointSale . '" '
. 'data-id-commande="' . $order->id . '" '
. 'data-commande=\'' . $jsonOrder. '\' '
. 'data-date="' . date('d/m H:i', strtotime($order->date)) . '">'
. '<span class="amount">' . number_format($order->amount, 2) . ' €</span>'
. '<span class="user">' . $strLabelOrderType . ' ' . $str_user . '</span>'
. '<span class="montant">' . number_format($order->amount, 2) . ' €</span>'
. '<span class="user">' . $strLabelOrderOrigin . ' ' . $strUser . '</span>'
. $strComment
. '</a></li>',
]);
@@ -1120,7 +1128,7 @@ class OrderController extends BackendController

if ($distribution) {
// produits
$products = Product::searchOne() ;
$products = Product::searchAll() ;

// commandes
$orders = Order::searchAll([
@@ -1145,7 +1153,7 @@ class OrderController extends BackendController
if ($selectedProduct['active']) {
foreach ($products as $product) {
if ($product->id == $idSelectedProduct) {
$potentialTurnover += $slectedProduct['quantity_max'] * $product->price;
$potentialTurnover += $selectedProduct['quantity_max'] * $product->price;
$totalWeight += $selectedProduct['quantity_max'] * $product->weight / 1000;
}
}
@@ -1153,9 +1161,9 @@ class OrderController extends BackendController
}

$htmlTotals = $this->renderPartial('_total_orders.php', [
'products' => $products,
'orders' => $orders,
'selectedProducts' => $selectedProducts,
'arrayProducts' => $products,
'arrayOrders' => $orders,
'arrayProductsSelected' => $selectedProducts,
'revenues' => $revenues,
'totalWeight' => $totalWeight,
'potentialTurnover' => $potentialTurnover,
@@ -1197,36 +1205,36 @@ class OrderController extends BackendController
/**
* Retourne l'état du paiement (historique, crédit) d'une commande donnée.
*
* @param integer $id_commande
* @param integer $idOrder
*/
public function actionPaymentStatus($idOrder)
{
$order = Order::searchOne(['id' => $idOrder]) ;
if ($order) {
$html = '';

if ($order->id_user) {
$userProducer = UserProducer::find()
->where([
'id_user' => $order->id_user,
'id_producer' => $order->distribution->id_producer
])
->one();
->where([
'id_user' => $order->id_user,
'id_producer' => $order->distribution->id_producer
])
->one();

$amountPaid = $order->getAmount(Order::AMOUNT_PAID);

if (abs($order->amount - $amountPaid) < 0.0001) {
$html .= '<span class="label label-success">Payé</span>';
$buttonsCredit = Html::a('Rembourser ' . $order->getAmount(Order::AMOUNT_TOTAL, true), 'javascript:void(0);', ['class' => 'btn btn-default btn-xs refund', 'data-amount' => $order->amount, 'data-type' => 'refund']);
$buttonsCredit = Html::a('Rembourser ' . $order->getAmount(Order::AMOUNT_TOTAL, true), 'javascript:void(0);', ['class' => 'btn btn-default btn-xs rembourser', 'data-montant' => $order->amount, 'data-type' => 'refund']);
} elseif ($order->amount > $amountPaid) {
$amountToPay = $order->amount - $amountPaid;
$html .= '<span class="label label-danger">Non payé</span> reste <strong>' . number_format($amountToPay, 2) . ' €</strong> à payer';
$buttonsCredit = Html::a('Payer ' . number_format($amountToPay, 2) . ' €', 'javascript:void(0);', ['class' => 'btn btn-default btn-xs pay', 'data-amount' => $amountToPay, 'data-type' => 'payment']);
$buttonsCredit = Html::a('Payer ' . number_format($amountToPay, 2) . ' €', 'javascript:void(0);', ['class' => 'btn btn-default btn-xs payer', 'data-montant' => $amountToPay, 'data-type' => 'payment']);
} elseif ($order->amount < $amountPaid) {
$amountToRefund = $amountPaid - $order->amount;
$html .= ' <span class="label label-success">Payé</span> <strong>' . number_format($amountToRefund, 2) . ' €</strong> à rembourser';
$buttonsCredit = Html::a('Rembourser ' . number_format($amountToRefund, 2) . ' €', 'javascript:void(0);', ['class' => 'btn btn-default btn-xs refund', 'data-aùount' => $amountToRefund, 'data-type' => 'refund']);
$buttonsCredit = Html::a('Rembourser ' . number_format($amountToRefund, 2) . ' €', 'javascript:void(0);', ['class' => 'btn btn-default btn-xs rembourser', 'data-montant' => $amountToRefund, 'data-type' => 'refund']);
}

$html .= '<span class="buttons-credit">'
@@ -1249,7 +1257,7 @@ class OrderController extends BackendController
$html .= '<tr>'
. '<td>' . date('d/m/Y H:i:s', strtotime($h->date)) . '</td>'
. '<td>' . Html::encode($h->strUserAction()) . '</td>'
. '<td>' . $h->getStrLibelle() . '</td>'
. '<td>' . $h->getStrWording() . '</td>'
. '<td>' . ($h->isTypeDebit() ? '- '.$h->getAmount(Order::AMOUNT_TOTAL,true) : '') . '</td>'
. '<td>' . ($h->isTypeCredit() ? '+ '.$h->getAmount(Order::AMOUNT_TOTAL,true) : '') . '</td>'
. '</tr>';
@@ -1264,8 +1272,8 @@ class OrderController extends BackendController
}

echo json_encode([
'html_statut_paiement' => $html,
'json_commande' => $commande->getDataJson()
'html_payment_status' => $html,
'json_order' => $order->getDataJson()
]);
}


+ 2
- 2
backend/controllers/ProducerAdminController.php View File

@@ -51,7 +51,7 @@ use common\models\Invoice;
/**
* UserController implements the CRUD actions for User model.
*/
class EtablissementAdminController extends BackendController
class ProducerAdminController extends BackendController
{

public function behaviors()
@@ -87,7 +87,7 @@ class EtablissementAdminController extends BackendController
{
$dataProviderProducer = new ActiveDataProvider([
'query' => Producer::find()
->with('userEtablissement', 'user')
->with('userProducer', 'user')
->orderBy('date_creation DESC'),
'pagination' => [
'pageSize' => 1000,

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

@@ -132,7 +132,7 @@ class SiteController extends BackendController
// dernières commandes
$ordersArray = Order::searchAll([],[
'orderby' => 'date DESC',
'conditions' => 'distribution.date > :date AND (origin = \'' . Order::ORIGIN_USER . '\' OR type = \'' . Order::ORIGIN_ADMIN . '\' OR (type = \'' . Order::ORIGIN_AUTO . '\' AND (date_update IS NOT NULL OR date_delete IS NOT NULL)))',
'conditions' => 'distribution.date > :date AND (origin = \'' . Order::ORIGIN_USER . '\' OR origin = \'' . Order::ORIGIN_ADMIN . '\' OR (origin = \'' . Order::ORIGIN_AUTO . '\' AND (date_update IS NOT NULL OR date_delete IS NOT NULL)))',
'params' => [':date' => date('Y-m-d 00:00:00')],
]);


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

@@ -200,7 +200,7 @@ class UserController extends BackendController
$userProducer->save() ;
}
else {
throw new \yii\web\NotFoundHttpException('L\'enregistrement UserEtablissement est introuvable', 404) ;
throw new \yii\web\NotFoundHttpException('L\'enregistrement UserProducer est introuvable', 404) ;
}
$params = Yii::$app->getRequest()->getQueryParams() ;

+ 4
- 4
backend/views/order/_total_orders.php View File

@@ -58,11 +58,11 @@ use yii\helpers\Html ;
<?php
foreach ($arrayProducts as $p) {
if ((isset($arrayProductsSelected[$p->id]['active']) && $arrayProductsSelected[$p->id]['active']) ||
(!$arrayProductsSelected[$p->id]['active'] && Commande::getQuantiteProduit($p->id, $arrayOrders)))
(!$arrayProductsSelected[$p->id]['active'] && Order::getProductQuantity($p->id, $arrayOrders)))
{
(!$arrayProductsSelected[$p->id]['active']) ? $class_disabled = 'disabled' : $class_disabled = '' ;
echo '<th class="rotate-45 '.$class_disabled.'"><div><span>'.Html::encode($p->getLibelleAdmin()).'</span></div></th>' ;
echo '<th class="rotate-45 '.$class_disabled.'"><div><span>'.Html::encode($p->getStrWordingAdmin()).'</span></div></th>' ;
}
}
?>
@@ -70,7 +70,7 @@ use yii\helpers\Html ;
<tr>
<?php
foreach ($arrayProducts as $p) {
$quantity = Commande::getQuantiteProduit($p->id, $arrayOrders);
$quantity = Order::getProductQuantity($p->id, $arrayOrders);
if ((isset($arrayProductsSelected[$p->id]['active']) && $arrayProductsSelected[$p->id]['active']) || $quantity)
{
$strQuantity = '';
@@ -79,7 +79,7 @@ use yii\helpers\Html ;
}
$class = 'total';
if ($strQuantity > $arrayProductsSelected[$p->id]['quantity_max'] && !$arrayProductsSelected[$p->id]['vrac'])
if ($strQuantity > $arrayProductsSelected[$p->id]['quantity_max'])
{
$class .= ' depasse';
}

+ 40
- 40
backend/views/order/index.php View File

@@ -75,8 +75,8 @@ $this->title = 'Commande';
<?php if ($date != ''): ?>
<div id="bloc-production">
<input type="hidden" id="date-distribution" value="<?= $date ?>" />
<input type="hidden" id="id-distribution" value="<?= $distribution->id ?>" />
<input type="hidden" id="date-production" value="<?= $date ?>" />
<input type="hidden" id="id-production" value="<?= $distribution->id ?>" />
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">Distribution du <strong><?php echo date('d/m/Y', strtotime($date)); ?></strong></h3>
@@ -97,7 +97,7 @@ $this->title = 'Commande';
<?php endif; ?>

<?php if($distribution->delivery && count($arrayPointsSaleDistribution)): ?>
<div id="distribution-points-sale">
<div id="productions-point-vente">
<strong>Points de vente : </strong>
<div class="checkbox-list">
<?= Html::activeCheckboxList(
@@ -114,35 +114,35 @@ $this->title = 'Commande';
<?php endif; ?>
<?php if ($distribution): ?>
<div id="block-products">
<div id="bloc-produits">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">Produits</h3>
</div>
<div class="panel-body">
<!-- produits sélectionnés -->
<form id="products-distribution" action="<?php echo Yii::$app->urlManager->createUrl(['order/index', 'date' => $date]); ?>" method="post">
<form id="produits-production" action="<?php echo Yii::$app->urlManager->createUrl(['order/index', 'date' => $date]); ?>" method="post">
<div class="overflow">
<table class="table table-condensed">
<thead>
<tr>
<th class="td-active">Actif</th>
<th class="td-product">Produit</th>
<th class="td-produit">Produit</th>
<th class="td-max">Max. <span class="glyphicon glyphicon-info-sign" data-toggle="tooltip" data-placement="top" data-original-title="Quantité disponible à la commande. Laisser vide si vous ne souhaitez pas avoir de limite de commande. La valeur par défaut est configurable dans vos produits."></span></th>
</tr>
</thead>
<tbody>
<?php foreach ($arrayProducts as $p): ?>
<tr<?php if ($p->vrac): ?> style="display:none;"<?php endif; ?> <?php if (isset($arrayProductsSelected[$p->id]['active']) && $arrayProductsSelected[$p->id]['active']): ?>class="active"<?php endif; ?>>
<td class="td-active"><input id="product-<?php echo $p->id; ?>" name="Product[<?php echo $p->id; ?>][active]" type="checkbox" <?php if (isset($arrayProductsSelected[$p->id]['active']) && $arrayProductsSelected[$p->id]['active']): ?>checked="checked"<?php endif; ?> /></td>
<td class="td-product"><label for="product-<?php echo $p->id; ?>"><?= Html::encode($p->name) ?></label></td>
<td class="td-max"><input class="quantity-max" name="Product[<?php echo $p->id; ?>][quantity_max]" type="text" value="<?php if (isset($arrayProductsSelected[$p->id])) echo $arrayProductsSelected[$p->id]['quantity_max']; ?>" /></td>
<tr <?php if (isset($selectedProducts[$p->id]['active']) && $selectedProducts[$p->id]['active']): ?>class="active"<?php endif; ?>>
<td class="td-active"><input id="product-<?php echo $p->id; ?>" name="Product[<?php echo $p->id; ?>][active]" type="checkbox" <?php if (isset($selectedProducts[$p->id]['active']) && $selectedProducts[$p->id]['active']): ?>checked="checked"<?php endif; ?> /></td>
<td class="td-produit"><label for="product-<?php echo $p->id; ?>"><?= Html::encode($p->name) ?></label></td>
<td class="td-max"><input class="quantity-max" name="Product[<?php echo $p->id; ?>][quantity_max]" type="text" value="<?php if (isset($selectedProducts[$p->id])) echo $selectedProducts[$p->id]['quantity_max']; ?>" /></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<input type="submit" name="valider_product_selec" class="btn btn-default" value="Valider" />
<input type="submit" name="valider_produit_selec" class="btn btn-default" value="Valider" />
</form>
</div>
</div>
@@ -153,7 +153,7 @@ $this->title = 'Commande';
<div class="col-md-9" id="col-right">
<input type="hidden" value="<?php echo $date; ?>" id="current-date" />
<ul id="distribution-days">
<ul id="jours-production">
<?php foreach ($arrayDistributionDays as $distributionDay) : ?>
<li><?php echo $distributionDay->date; ?></li>
<?php endforeach; ?>
@@ -162,9 +162,9 @@ $this->title = 'Commande';
<div id="bloc-totaux">
<?= $this->render('_total_orders.php',[
'arrayPoducts' => $arrayProducts,
'arrayProducts' => $arrayProducts,
'arrayOrders' => $arrayOrders,
'arraySelectedProducts' => $arrayProductsSelected,
'arrayProductsSelected' => $selectedProducts,
'revenues' => $revenues,
'weight' => $weight,
'potentialTurnover' => $potentialTurnover,
@@ -179,7 +179,7 @@ $this->title = 'Commande';
$champs_horaires_point_vente = 'horaires_' . $arr_jour_semaine[$num_jour_semaine];
?>
<div class="panel panel-default" id="panel-orders">
<div class="panel panel-default" id="panel-commandes">
<div class="panel-heading">
<h3 class="panel-title">
Commandes
@@ -188,10 +188,10 @@ $this->title = 'Commande';
<?php endif; ?>
<?php if (count($arrayOrders)): ?>
<a id="btn-export-orders" class="btn btn-primary" href="<?php echo Yii::$app->urlManager->createUrl(['order/report', 'date' => $date, 'idPointSale' => 0, 'global' => 1]); ?>"><span class="glyphicon glyphicon-download-alt"></span> Exporter</a>
<a id="btn-export-commandes" class="btn btn-primary" href="<?php echo Yii::$app->urlManager->createUrl(['order/report', 'date' => $date, 'idPointSale' => 0, 'global' => 1]); ?>"><span class="glyphicon glyphicon-download-alt"></span> Exporter</a>
<?php endif; ?>
<div id="btn-subscription" class="btn-group">
<div id="btn-commandes-auto" class="btn-group">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="glyphicon glyphicon-repeat"></span> Abonnements <span class="caret"></span>
</button>
@@ -210,43 +210,43 @@ $this->title = 'Commande';
<!-- Nav tabs -->
<ul id="tabs-points-vente" class="nav nav-tabs" role="tablist">
<?php foreach($arrayPointsSaleDistribution as $pointSale): ?>
<?php foreach($arrayPointsSale as $pointSale): ?>
<li role="presentation" class="<?php if($pointSale->point_production): ?>active<?php endif; ?>">
<a href="#point-vente-<?= $pointSale->id ?>" id="btn-point-sale-<?= $pointSale->id ?>" aria-controls="point-sale-<?= $pointSale->id ?>" role="tab" data-toggle="tab"><?= Html::encode($pointSale->name) ?> <span class="badge badge-<?php if(count($pointSale->orders)): ?>success<?php else: ?>danger<?php endif; ?>"><?php echo count($pointSale->orders); ?></span></a>
<a href="#point-vente-<?= $pointSale->id ?>" id="btn-point-vente-<?= $pointSale->id ?>" aria-controls="point-sale-<?= $pointSale->id ?>" role="tab" data-toggle="tab"><?= Html::encode($pointSale->name) ?> <span class="badge badge-<?php if(count($pointSale->orders)): ?>success<?php else: ?>danger<?php endif; ?>"><?php echo count($pointSale->orders); ?></span></a>
</li>
<?php endforeach; ?>
</ul>

<!-- Tab panes -->
<div class="tab-content" id="orders-points-sale">
<div class="tab-content" id="commandes-points-vente">
<?php foreach($arrayPointsSale as $pointSale): ?>
<div role="tabpanel" data-id-pv="<?= $pointSale->id ?>" class="bloc-point-sale tab-pane <?php if($pointSale->point_production): ?> active<?php endif; ?>" id="point-sale-<?= $pointSale->id ?>">
<div role="tabpanel" data-id-pv="<?= $pointSale->id ?>" class="bloc-point-vente tab-pane <?php if($pointSale->point_production): ?> active<?php endif; ?>" id="point-vente-<?= $pointSale->id ?>">
<div class="col-md-12">
<div class="alert alert-warning recap-point-sale <?php if(!count($pointSale->orders)): ?>no-order<?php endif; ?>">
<div class="alert alert-warning recap-pv <?php if(!count($pointSale->orders)): ?>no-order<?php endif; ?>">
<?php if(count($pointSale->orders)): ?>
<strong class="orders"><?= count($pointSale->orders) ?> commande<?php if(count($pointSale->orders) > 1): ?>s<?php endif; ?></strong>
<span class="revenues"><?= number_format($pointSale->revenues, 2) ?> €</span>
<strong class="commandes"><?= count($pointSale->orders) ?> commande<?php if(count($pointSale->orders) > 1): ?>s<?php endif; ?></strong>
<span class="recettes"><?= number_format($pointSale->revenues, 2) ?> €</span>
<?php else: ?>
<strong class="orders">Aucune commande</strong>
<span class="revenues"></span>
<strong class="commandes">Aucune commande</strong>
<span class="recettes"></span>
<?php endif; ?>
</div>
<ul class="liste-orders btn-group-vertical<?php if(!count($pointSale->orders)): ?> no-order<?php endif; ?>">
<ul class="liste-commandes btn-group-vertical<?php if(!count($pointSale->orders)): ?> no-order<?php endif; ?>">
<?php foreach($pointSale->orders as $order): ?>
<li>
<a href="javascript:void(0);" class="btn btn-default" data-point-sale-id="<?= $pointSale->id ?>" data-id-order="<?= $order->id ?>" data-order='<?= $pointSale->data_options_orders[$order->id]['data-order'] ?>' data-comment="<?= Html::encode($order->comment) ?>" data-date="<?= date('d/m à H:i',strtotime($order->date)); ?>">
<span class="amount <?php if(number_format($order->paid_amount,2) >= number_format($order->amount,2)): ?>paid<?php endif; ?>">
<a href="javascript:void(0);" class="btn btn-default" data-pv-id="<?= $pointSale->id ?>" data-id-commande="<?= $order->id ?>" data-commande='<?= $pointSale->data_options_orders[$order->id]['data-order'] ?>' data-commentaire="<?= Html::encode($order->comment) ?>" data-date="<?= date('d/m à H:i',strtotime($order->date)); ?>">
<span class="montant <?php if(number_format($order->paid_amount,2) >= number_format($order->amount,2)): ?>paye<?php endif; ?>">
<?= Html::encode(number_format($order->amount, 2)); ?> €
<?php if($order->paid_amount - $order->amount > 0.01): ?><span class="glyphicon glyphicon-warning-sign"></span><?php endif; ?>
</span>
<span class="user">
<?php if($order->type): ?>
<?php if($order->type == Order::ORIGIN_ADMIN): ?>
<?php if($order->origin): ?>
<?php if($order->origin == Order::ORIGIN_ADMIN): ?>
<span class="label label-warning">vous</span>
<?php elseif($order->type == Order::ORIGIN_AUTO): ?>
<?php elseif($order->origin == Order::ORIGIN_AUTO): ?>
<span class="label label-default">auto</span>
<?php elseif($order->type == Order::ORIGIN_USER): ?>
<?php elseif($order->origin == Order::ORIGIN_USER): ?>
<span class="label label-success">client</span>
<?php endif; ?>
<?php endif; ?>
@@ -268,10 +268,10 @@ $this->title = 'Commande';
</li>
<?php endforeach; ?>
</ul>
<?= Html::a('<span class="glyphicon glyphicon-plus"></span> Créer une commande', 'javascript:void(0);', ['class' => 'btn btn-default create-corder', 'data-point-sale-id' => $pointSale->id]) ?>
<?= Html::a('<span class="glyphicon glyphicon-plus"></span> Créer une commande', 'javascript:void(0);', ['class' => 'btn btn-default creer-commande', 'data-pv-id' => $pointSale->id]) ?>
</div>
<div class="col-md-12 block-order">
<div class="col-md-12 bloc-commande">
<h2 class="title-user">
<span class="buttons-edit-remove">
<?= Html::a('<span class="glyphicon glyphicon-trash"></span> Supprimer', 'javascript:void(0);', ['class' => 'btn btn-default btn-remove']) ?>
@@ -291,13 +291,13 @@ $this->title = 'Commande';
</h2>
<div class="commentaire alert alert-info">
</div>
<textarea name="comment" class="form-control textarea-comment" placeholder="Commentaire"></textarea>
<table class="table table-bordered table-condensed tab-content table-products">
<textarea name="comment" class="form-control textarea-commentaire" placeholder="Commentaire"></textarea>
<table class="table table-bordered table-condensed tab-content table-produits">
<tbody>
<?php foreach ($arrayProducts as $p): ?>
<tr class="product-<?= $p->id ?> <?php if(!$arrayProductsSelected[$p->id]['active']): ?> disabled<?php endif; ?>" data-id-product="<?= $p->id ?>">
<td class="td-order"></td>
<td class="td-product"><?php echo Html::encode($p->getLibelleAdmin()); ?></td>
<tr class="produit-<?= $p->id ?> <?php if(!$selectedProducts[$p->id]['active']): ?> disabled<?php endif; ?>" data-id-produit="<?= $p->id ?>">
<td class="td-commande"></td>
<td class="td-produit"><?php echo Html::encode($p->getStrWordingAdmin()); ?></td>
</tr>
<?php endforeach; ?>
<tr class="tr-total">

+ 61
- 69
backend/views/order/report.php View File

@@ -38,22 +38,18 @@ termes.

use common\models\Order ;

$num_jour_semaine = date('w', strtotime($date));
$arr_jour_semaine = [0 => 'dimanche', 1 => 'lundi', 2 => 'mardi', 3 => 'mercredi', 4 => 'jeudi', 5 => 'vendredi', 6 => 'samedi'];
$champs_horaires_point_vente = 'horaires_' . $arr_jour_semaine[$num_jour_semaine];
$dayWeek = date('w', strtotime($date));
$dayWeekArray = [0 => 'sunday', 1 => 'monday', 2 => 'tuesday', 3 => 'wednesday', 4 => 'thursday', 5 => 'friday', 6 => 'saterday'];
$fieldInfosPointSale = 'infos_' . $dayWeekArray[$dayWeek];

$html = '' ;

// par point de vente
foreach ($points_vente as $pv) {
if (count($pv->order) && strlen($pv->$champs_horaires_point_vente)) {
foreach ($pointsSaleArray as $pointSale) {
if (count($pointSale->orders) && strlen($pointSale->$fieldInfosPointSale)) {
$html .= '<h3>'.$pv->name.'</h3>' ;

$col_credit_pain = '' ;
if($pv->credit) {
$col_credit = '<th>Rappel crédit</th>' ;
}
$html .= '<h3>'.$pointSale->name.'</h3>' ;
$colCredit = ($pointSale->credit) ? '<th>Rappel crédit</th>' : '' ;
$html .= '<table class="table table-bordered">'
. '<thead>'
@@ -61,70 +57,70 @@ foreach ($points_vente as $pv) {
. '<th>Client</th>'
. '<th>Produits</th>'
. '<th>Commentaire</th>'
. $col_credit
. $colCredit
. '<th>Montant</th>'
. '</tr>'
. '<tbody>';
foreach ($pv->orders as $c) {
foreach ($pointSale->orders as $order) {
$html .= '<tr>' ;
$str_user = '';
$strUser = '';

// username
if ($c->user) {
$str_user = $c->user->name . " " . $c->user->lastname;
if ($order->user) {
$strUser = $order->user->name . " " . $order->user->lastname;
} else {
$str_user = $c->username;
$strUser = $order->username;
}
if(strlen($c->comment_point_sale))
if(strlen($order->comment_point_sale))
{
$str_user .= '<br /><em>'.$c->comment_point_sale.'</em>' ;
$strUser .= '<br /><em>'.$order->comment_point_sale.'</em>' ;
}
// téléphone
if (isset($c->user) && strlen($c->user->phone)) {
$str_user .= '<br />' . $c->user->phone . '';
if (isset($order->user) && strlen($order->user->phone)) {
$strUser .= '<br />' . $order->user->phone . '';
}

$html .= '<td>'.$str_user.'</td>';
$html .= '<td>'.$strUser.'</td>';
// produits
$str_produits = '';
foreach ($produits as $p) {
$strProducts = '';
foreach ($productsArray as $product) {
$add = false;
foreach ($c->productOrder as $cp) {
if ($p->id == $cp->id_product) {
$str_produits .= $cp->quantity . '&nbsp;' . $p->name . ', ';
foreach ($order->productOrder as $productOrder) {
if ($product->id == $productOrder->id_product) {
$strProducts .= $productOrder->quantity . '&nbsp;' . $product->name . ', ';
$add = true;
}
}
}
$html .= '<td>'.substr($str_produits, 0, strlen($str_produits) - 2).'</td>';
$html .= '<td>'.$c->comment.'</td>';
$html .= '<td>'.substr($strProducts, 0, strlen($strProducts) - 2).'</td>';
$html .= '<td>'.$order->comment.'</td>';
if($pv->credit) {
if($pointSale->credit) {
$credit = '' ;
if(isset($c->user) && isset($c->user->userProducer)) {
$credit = number_format($c->user->userProducer[0]->credit,2).' €' ;
if(isset($order->user) && isset($order->user->userProducer)) {
$credit = number_format($order->user->userProducer[0]->credit,2).' €' ;
}
$html .= '<td>'.$credit.'</td>' ;
}
$html .= '<td><strong>'.number_format($c->amount, 2) . ' € ';
$html .= '<td><strong>'.number_format($order->amount, 2) . ' € ';

if($c->getStatusPayment() == Order::PAYMENT_PAID)
if($order->getPaymentStatus() == Order::PAYMENT_PAID)
{
$html .= '(payé)' ;
}
elseif($c->getStatusPayment() == Order::PAYMENT_UNPAID && $c->getAmount(Order::AMOUNT_PAID))
elseif($order->getPaymentStatus() == Order::PAYMENT_UNPAID && $order->getAmount(Order::AMOUNT_PAID))
{
$html .= '(reste '.$c->getAmount(Order::AMOUNT_REMAINING, true).' à payer)' ;
$html .= '(reste '.$order->getAmount(Order::AMOUNT_REMAINING, true).' à payer)' ;
}
elseif($c->getStatusPayment() == Order::PAYMENT_SURPLUS)
elseif($order->getPaymentStatus() == Order::PAYMENT_SURPLUS)
{
$html .= '(surplus : '.$c->getAmount(Order::PAYMENT_SURPLUS, true).' à rembourser)' ;
$html .= '(surplus : '.$order->getAmount(Order::PAYMENT_SURPLUS, true).' à rembourser)' ;
}
$html .= '</strong></td>' ;
@@ -135,23 +131,23 @@ foreach ($points_vente as $pv) {

$html .= '<tr><td><strong>Total</strong></td>' ;
$str_produits = '';
foreach ($produits as $p) {
$quantite = Order::getProductQuantity($p->id, $pv->orders);
$str_quantite = '';
if ($quantite) {
$str_quantite = $quantite;
$str_produits .= $str_quantite .'&nbsp;'. $p->name . ', ';
$strProducts = '';
foreach ($productsArray as $product) {
$quantity = Order::getProductQuantity($product->id, $pointSale->orders);
$strQuantity = '';
if ($quantity) {
$strQuantity = $quantity;
$strProducts .= $strQuantity .'&nbsp;'. $product->name . ', ';
}
}
$str_produits = substr($str_produits, 0, strlen($str_produits) - 2) ;
$strProducts = substr($strProducts, 0, strlen($strProducts) - 2) ;
$html .= '<td>'.$str_produits.'</td><td></td>' ;
if($pv->credit) {
$html .= '<td>'.$strProducts.'</td><td></td>' ;
if($pointSale->credit) {
$html .= '<td></td>' ;
}
$html .= '<td><strong>'.number_format($pv->revenues, 2) . ' €</strong></td>';
$html .= '<td><strong>'.number_format($pointSale->revenues, 2) . ' €</strong></td>';
$html .= '</tbody></table><pagebreak>' ;
}
@@ -168,45 +164,41 @@ $html .= '<table class="table table-bordered">'
. '</tr>'
. '<tbody>';

$recettes = 0 ;
foreach ($points_vente as $pv)
$revenues = 0 ;
foreach ($pointsSaleArray as $pointSale)
{
if (count($pv->orders) && strlen($pv->$champs_horaires_point_vente))
if (count($pointSale->orders) && strlen($pointSale->$fieldInfosPointSale))
{
$html .= '<tr><td>'.$pv->name.'</td><td>' ;
foreach ($produits as $p) {
$quantite = Order::getProductQuantity($p->id, $pv->orders);
$str_quantite = '';

if ($quantite) {
$str_quantite = $quantite;
}
$html .= '<tr><td>'.$pointSale->name.'</td><td>' ;
foreach ($productsArray as $product) {
$quantity = Order::getProductQuantity($product->id, $pointSale->orders);
$strQuantity = ($quantity) ? $quantity : '' ;
if(strlen($str_quantite)) {
$html .= $str_quantite . '&nbsp;'.$p->name.', ' ;
if(strlen($strQuantity)) {
$html .= $strQuantity . '&nbsp;'.$product->name.', ' ;
}
}
$html = substr($html, 0, strlen($html) - 2) ;
$html .= '</td><td>'.number_format($pv->revenues, 2).' €</td></tr>' ;
$recettes += $pv->revenues ;
$html .= '</td><td>'.number_format($pointSale->revenues, 2).' €</td></tr>' ;
$revenues += $pointSale->revenues ;
}
}

// total
$html .= '<tr><td><strong>Total</strong></td><td>' ;
foreach ($produits as $p) {
$quantite = Order::getProductQuantity($p->id, $orders);
if($quantite) {
$html .= $quantite . '&nbsp;'.$p->name.', ' ;
foreach ($productsArray as $product) {
$quantity = Order::getProductQuantity($product->id, $ordersArray);
if($quantity) {
$html .= $quantity . '&nbsp;'.$product->name.', ' ;
}
}

$html = substr($html, 0, strlen($html) - 2) ;

$html .= '</td><td><strong>'.number_format($recettes, 2).' €</strong></td></tr>' ;
$html .= '</td><td><strong>'.number_format($revenues, 2).' €</strong></td></tr>' ;

$html .= '</tbody></table>' ;


+ 2
- 2
backend/views/site/index.php View File

@@ -203,7 +203,7 @@ $this->title = 'Tableau de bord';
</tr>
<tr>
<td>Délai de commande</td>
<td><?= $producer->prder_delay ?> jour<?php if($producer->order_delay > 1): ?>s<?php endif; ?></td>
<td><?= $producer->order_delay ?> jour<?php if($producer->order_delay > 1): ?>s<?php endif; ?></td>
</tr>
<tr>
<td>Heure limite de commande</td>
@@ -275,7 +275,7 @@ $this->title = 'Tableau de bord';
<tbody>
<?php foreach($ordersArray as $order): ?>
<tr class="<?= $order->getClassHistory() ; ?>">
<td class="infos"><?= $order->getStrType(true); ?></td>
<td class="infos"><?= $order->getStrOrigin(true); ?></td>
<td class="date">
<div class="block-date">
<div class="day"><?= strftime('%A', strtotime($order->distribution->date)) ?></div>

BIN
backend/web/.sass-cache/2a0ffb00578c9d5a537db16d14c734a22b18f35c/screen.scssc View File


+ 82
- 82
backend/web/css/screen.css View File

@@ -488,7 +488,7 @@ a:hover, a:focus, a:active {
padding-left: 20px;
}
/* line 432, ../sass/screen.scss */
#page-order #distribution-days {
#page-order #jours-production {
display: none;
}
/* line 437, ../sass/screen.scss */
@@ -547,17 +547,17 @@ a:hover, a:focus, a:active {
margin-top: 10px;
}
/* line 488, ../sass/screen.scss */
#page-order #block-distribution .label {
#page-order #bloc-production .label {
float: right;
font-size: 13px;
}
/* line 493, ../sass/screen.scss */
#page-order #block-distribution .btn-success {
#page-order #bloc-production .btn-success {
background-color: #5cb85c;
border-color: #4cae4c;
}
/* line 498, ../sass/screen.scss */
#page-order #block-distribution #distributions-points-sale {
#page-order #bloc-production #productions-point-vente {
margin-top: 15px;
padding: 10px;
border: solid 1px #e0e0e0;
@@ -567,76 +567,76 @@ a:hover, a:focus, a:active {
border-radius: 5px;
}
/* line 504, ../sass/screen.scss */
#page-order #block-distribution #distributions-points-sale label {
#page-order #bloc-production #productions-point-vente label {
display: block;
font-weight: normal;
}
/* line 509, ../sass/screen.scss */
#page-order #block-distribution #distributions-points-sale .checkbox-list {
#page-order #bloc-production #productions-point-vente .checkbox-list {
margin-left: 10px;
margin-top: 10px;
}
/* line 520, ../sass/screen.scss */
#page-order #products-distribution .overflow table {
#page-order #produits-production .overflow table {
width: 100%;
}
/* line 524, ../sass/screen.scss */
#page-order #products-distribution .overflow thead, #page-order #products-distribution .overflow tbody, #page-order #products-distribution .overflow tr, #page-order #products-distribution .overflow td, #page-order #products-distribution .overflow th {
#page-order #produits-production .overflow thead, #page-order #produits-production .overflow tbody, #page-order #produits-production .overflow tr, #page-order #produits-production .overflow td, #page-order #produits-production .overflow th {
display: block;
}
/* line 526, ../sass/screen.scss */
#page-order #products-distribution .overflow tr:after {
#page-order #produits-production .overflow tr:after {
content: ' ';
display: block;
visibility: hidden;
clear: both;
}
/* line 533, ../sass/screen.scss */
#page-order #products-distribution .overflow thead th {
#page-order #produits-production .overflow thead th {
height: 30px;
}
/* line 538, ../sass/screen.scss */
#page-order #products-distribution .overflow tbody {
#page-order #produits-production .overflow tbody {
height: 500px;
overflow-y: auto;
}
/* line 546, ../sass/screen.scss */
#page-order #products-distribution .overflow thead th {
#page-order #produits-production .overflow thead th {
width: 32%;
float: left;
}
/* line 551, ../sass/screen.scss */
#page-order #products-distribution .overflow tbody td {
#page-order #produits-production .overflow tbody td {
width: 33%;
float: left;
}
/* line 556, ../sass/screen.scss */
#page-order #products-distribution .overflow .td-product {
#page-order #produits-production .overflow .td-produit {
width: 60%;
}
/* line 559, ../sass/screen.scss */
#page-order #products-distribution .overflow .td-active, #page-order #products-distribution .overflow .td-max {
#page-order #produits-production .overflow .td-active, #page-order #produits-production .overflow .td-max {
width: 20%;
text-align: center;
}
/* line 565, ../sass/screen.scss */
#page-order #products-distribution .overflow thead .td-product {
#page-order #produits-production .overflow thead .td-product {
width: 57%;
}
/* line 571, ../sass/screen.scss */
#page-order #products-distribution input.quantity-max {
#page-order #produits-production input.quantity-max {
background-color: white;
border: 1px solid #e0e0e0;
text-align: center;
width: 50px;
}
/* line 579, ../sass/screen.scss */
#page-order #products-distribution td label {
#page-order #produits-production td label {
font-weight: normal;
}
/* line 585, ../sass/screen.scss */
#page-order #btn-export-orders,
#page-order #btn-subscription {
#page-order #btn-export-commandes,
#page-order #btn-commandes-auto {
float: right;
position: relative;
top: -5px;
@@ -644,43 +644,43 @@ a:hover, a:focus, a:active {
padding: 2px 5px;
}
/* line 594, ../sass/screen.scss */
#page-order #btn-export-orders,
#page-order #btn-subscription {
#page-order #btn-export-commandes,
#page-order #btn-commandes-auto {
color: white;
margin-left: 10px;
padding: 1px 5px;
}
/* line 601, ../sass/screen.scss */
#page-order #btn-subscription {
#page-order #btn-commandes-auto {
top: -7px;
}
/* line 603, ../sass/screen.scss */
#page-order #btn-subscription .btn {
#page-order #btn-commandes-auto .btn {
padding: 2px 5px;
}
/* line 605, ../sass/screen.scss */
#page-order #btn-subscription .btn span {
#page-order #btn-commandes-auto .btn span {
top: 2px;
}
/* line 613, ../sass/screen.scss */
#page-order #block-totals .table-products .depasse {
#page-order #bloc-totaux .table-products .depasse {
color: #b32815;
}
/* line 617, ../sass/screen.scss */
#page-order #block-totals .table-products .total strong span {
#page-order #bloc-totaux .table-products .total strong span {
font-weight: normal;
font-size: 13px;
}
/* line 626, ../sass/screen.scss */
#page-order #orders-points-sale .tab-pane {
#page-order #commandes-points-vente .tab-pane {
padding-top: 20px;
}
/* line 633, ../sass/screen.scss */
#page-order #orders-points-sale .recap-point-sale.no-order .revenues {
#page-order #commandes-points-vente .recap-pv.no-commande .recettes {
display: none;
}
/* line 638, ../sass/screen.scss */
#page-order #orders-points-sale .recap-point-sale .revenues {
#page-order #commandes-points-vente .recap-pv .recettes {
float: right;
color: #BB8757;
border: solid 1px #BB8757;
@@ -693,11 +693,11 @@ a:hover, a:focus, a:active {
top: -3px;
}
/* line 650, ../sass/screen.scss */
#page-order #orders-points-sale .alert.comment {
#page-order #commandes-points-vente .alert.comment {
display: none;
}
/* line 654, ../sass/screen.scss */
#page-order #orders-points-sale ul.liste-orders {
#page-order #commandes-points-vente ul.liste-commandes {
margin-top: 10px;
list-style-type: none;
height: 100%;
@@ -709,16 +709,16 @@ a:hover, a:focus, a:active {
overflow-y: scroll;
}
/* line 665, ../sass/screen.scss */
#page-order #orders-points-sale ul.liste-orders.no-order {
#page-order #commandes-points-vente ul.liste-commandes.no-commande {
display: none;
}
/* line 669, ../sass/screen.scss */
#page-order #orders-points-sale ul.liste-orders li {
#page-order #commandes-points-vente ul.liste-commandes li {
padding: 0;
margin: 0;
}
/* line 672, ../sass/screen.scss */
#page-order #orders-points-sale ul.liste-orders li a {
#page-order #commandes-points-vente ul.liste-commandes li a {
text-align: left;
-moz-border-radius: 0px;
-webkit-border-radius: 0px;
@@ -728,22 +728,22 @@ a:hover, a:focus, a:active {
color: #333;
}
/* line 679, ../sass/screen.scss */
#page-order #orders-points-sale ul.liste-orders li a .amount {
#page-order #commandes-points-vente ul.liste-commandes li a .montant {
float: right;
color: #BB8757;
font-weight: bold;
}
/* line 684, ../sass/screen.scss */
#page-order #orders-points-sale ul.liste-orders li a .amount.paid {
#page-order #commandes-points-vente ul.liste-commandes li a .montant.paye {
color: #5cb85c;
color: #519951;
}
/* line 690, ../sass/screen.scss */
#page-order #orders-points-sale ul.liste-orders li a .glyphicon-comment {
#page-order #commandes-points-vente ul.liste-commandes li a .glyphicon-comment {
color: #BB8757;
}
/* line 694, ../sass/screen.scss */
#page-order #orders-points-sale ul.liste-orders li a:hover, #page-order #orders-points-sale ul.liste-orders li a:active, #page-order #orders-points-sale ul.liste-orders li a.active {
#page-order #commandes-points-vente ul.liste-commandes li a:hover, #page-order #commandes-points-vente ul.liste-commandes li a:active, #page-order #commandes-points-vente ul.liste-commandes li a.active {
text-decoration: none;
background-color: #FCF8E3;
outline: none;
@@ -754,86 +754,86 @@ a:hover, a:focus, a:active {
transition: all 0.1s;
}
/* line 705, ../sass/screen.scss */
#page-order #orders-points-sale .create-order,
#page-order #orders-points-sale .subscriptions {
#page-order #commandes-points-vente .creer-commande,
#page-order #commandes-points-vente .commandes-auto {
width: 100%;
margin-bottom: 10px;
}
/* line 711, ../sass/screen.scss */
#page-order #orders-points-sale .block-order {
#page-order #commandes-points-vente .bloc-commande {
padding-top: 20px;
margin-top: 20px;
display: none;
}
/* line 717, ../sass/screen.scss */
#page-order #orders-points-sale .title-user {
#page-order #commandes-points-vente .title-user {
display: none;
font-size: 19px;
margin-top: 0px;
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
}
/* line 723, ../sass/screen.scss */
#page-order #orders-points-sale .title-user .btn-edit, #page-order #orders-points-sale .title-user .btn-remove,
#page-order #orders-points-sale .title-user .btn-cancel, #page-order #orders-points-sale .title-user .btn-save {
#page-order #commandes-points-vente .title-user .btn-edit, #page-order #commandes-points-vente .title-user .btn-remove,
#page-order #commandes-points-vente .title-user .btn-cancel, #page-order #commandes-points-vente .title-user .btn-save {
float: right;
position: relative;
top: -6px;
}
/* line 730, ../sass/screen.scss */
#page-order #orders-points-sale .title-user .btn-edit, #page-order #orders-points-sale .title-user .btn-cancel {
#page-order #commandes-points-vente .title-user .btn-edit, #page-order #commandes-points-vente .title-user .btn-cancel {
margin-right: 10px;
}
/* line 734, ../sass/screen.scss */
#page-order #orders-points-sale .title-user .buttons-save-cancel {
#page-order #commandes-points-vente .title-user .buttons-save-cancel {
display: none;
}
/* line 738, ../sass/screen.scss */
#page-order #orders-points-sale .title-user .choice-user {
#page-order #commandes-points-vente .title-user .choix-user {
display: none;
}
/* line 741, ../sass/screen.scss */
#page-order #orders-points-sale .title-user .choice-user .form-control {
#page-order #commandes-points-vente .title-user .choix-user .form-control {
width: 200px;
display: inline;
}
/* line 749, ../sass/screen.scss */
#page-order #orders-points-sale table.table-products .td-order {
#page-order #commandes-points-vente table.table-produits .td-order {
text-align: center;
}
/* line 752, ../sass/screen.scss */
#page-order #orders-points-sale table.table-products input.form-control {
#page-order #commandes-points-vente table.table-produits input.form-control {
text-align: center;
}
/* line 757, ../sass/screen.scss */
#page-order #orders-points-sale table.table-products tr.disabled .td-product {
#page-order #commandes-points-vente table.table-produits tr.disabled .td-product {
color: gray;
}
/* line 763, ../sass/screen.scss */
#page-order #orders-points-sale .td-product,
#page-order #orders-points-sale .th-product {
#page-order #commandes-points-vente .td-produit,
#page-order #commandes-points-vente .th-produit {
width: 70%;
}
/* line 768, ../sass/screen.scss */
#page-order #orders-points-sale .td-order,
#page-order #orders-points-sale .th-order {
#page-order #commandes-points-vente .td-commande,
#page-order #commandes-points-vente .th-commande {
width: 30%;
text-align: center;
}
/* line 774, ../sass/screen.scss */
#page-order #orders-points-sale .td-product {
#page-order #commandes-points-vente .td-produit {
text-transform: uppercase;
}
/* line 778, ../sass/screen.scss */
#page-order #orders-points-sale .td-order {
#page-order #commandes-points-vente .td-commande {
font-weight: bold;
}
/* line 782, ../sass/screen.scss */
#page-order #orders-points-sale .td-total {
#page-order #commandes-points-vente .td-total {
font-size: 18px;
text-align: center;
}
/* line 786, ../sass/screen.scss */
#page-order #orders-points-sale .td-total span {
#page-order #commandes-points-vente .td-total span {
padding: 2px 10px;
background-color: #BB8757;
color: white;
@@ -843,33 +843,33 @@ a:hover, a:focus, a:active {
border-radius: 8px;
}
/* line 796, ../sass/screen.scss */
#page-order #orders-points-sale .td-payment .buttons-credit {
#page-order #commandes-points-vente .td-paiement .buttons-credit {
float: right;
}
/* line 802, ../sass/screen.scss */
#page-order #orders-points-sale .panel-order-auto .field-subscriptionform-id_user,
#page-order #orders-points-sale .panel-order-auto .field-subscriptionform-id_producer {
#page-order #commandes-points-vente .panel-commande-auto .field-subscriptionform-id_user,
#page-order #commandes-points-vente .panel-commande-auto .field-subscriptionform-id_producer {
display: none;
}
/* line 809, ../sass/screen.scss */
#page-order #orders-points-sale .panel-order-auto .days .form-group {
#page-order #commandes-points-vente .panel-commande-auto .days .form-group {
float: left;
margin-right: 10px;
}
/* line 818, ../sass/screen.scss */
#page-order #old-orders {
#page-order #old-commandes {
display: none;
}
/* line 822, ../sass/screen.scss */
#page-order .form-orders-point-sale {
#page-order .form-commandes-point-vente {
margin-top: 20px;
}
/* line 826, ../sass/screen.scss */
#page-order .form-orders-point-sale table {
#page-order .form-commandes-point-vente table {
border-bottom: solid 1px #e0e0e0;
}
/* line 830, ../sass/screen.scss */
#page-order .form-orders-point-sale .title-point-sale {
#page-order .form-commandes-point-vente .title-point-sale {
background-color: #fff8e2;
border-left: solid 3px #BB8757;
font-weight: bold;
@@ -877,68 +877,68 @@ a:hover, a:focus, a:active {
padding: 10px;
}
/* line 838, ../sass/screen.scss */
#page-order .form-orders-point-sale .title-totals {
#page-order .form-commandes-point-vente .title-totals {
text-align: center;
}
/* line 842, ../sass/screen.scss */
#page-order .form-orders-point-sale .border-left {
#page-order .form-commandes-point-vente .border-left {
border-left: solid 1px #e0e0e0;
}
/* line 846, ../sass/screen.scss */
#page-order .form-orders-point-sale .border-right {
#page-order .form-commandes-point-vente .border-right {
border-right: solid 1px #e0e0e0;
}
/* line 850, ../sass/screen.scss */
#page-order .form-orders-point-sale input.quantity {
#page-order .form-commandes-point-vente input.quantity {
width: 30px;
background-color: white;
border: solid 1px #e0e0e0;
text-align: center;
}
/* line 857, ../sass/screen.scss */
#page-order .form-orders-point-sale .td-product {
#page-order .form-commandes-point-vente .td-product {
text-align: center;
}
/* line 861, ../sass/screen.scss */
#page-order .form-orders-point-sale .submit-point-sale {
#page-order .form-commandes-point-vente .submit-point-sale {
float: right;
}
/* line 865, ../sass/screen.scss */
#page-order .form-orders-point-sale .select-user {
#page-order .form-commandes-point-vente .select-user {
background-color: #F9F9F9;
border: solid 1px #e0e0e0;
}
/* line 870, ../sass/screen.scss */
#page-order .form-orders-point-sale .date-order {
#page-order .form-commandes-point-vente .date-order {
font-size: 12px;
}
/* line 874, ../sass/screen.scss */
#page-order .form-orders-point-sale .datepicker, #page-order .form-orders-point-sale .text {
#page-order .form-commandes-point-vente .datepicker, #page-order .form-commandes-point-vente .text {
background-color: white;
border: solid 1px #e0e0e0;
margin-top: 3px;
width: 100px;
}
/* line 882, ../sass/screen.scss */
#page-order .form-orders-point-sale td.center {
#page-order .form-commandes-point-vente td.center {
text-align: center;
}
/* line 886, ../sass/screen.scss */
#page-order .form-orders-point-sale .depasse {
#page-order .form-commandes-point-vente .depasse {
color: #b32815;
}
/* line 890, ../sass/screen.scss */
#page-order .form-orders-point-sale .total strong span {
#page-order .form-commandes-point-vente .total strong span {
font-weight: normal;
font-size: 13px;
}
/* line 895, ../sass/screen.scss */
#page-order .form-orders-point-sale td.user {
#page-order .form-commandes-point-vente td.user {
text-align: left;
padding: 3px;
}
/* line 898, ../sass/screen.scss */
#page-order .form-orders-point-sale td.user .date-order {
#page-order .form-commandes-point-vente td.user .date-order {
color: gray;
}
/* line 905, ../sass/screen.scss */

+ 48
- 61
backend/web/js/lechatdesnoisettes.js View File

@@ -75,9 +75,9 @@ function chat_nl2br(str, is_xhtml) {

function chat_index_commandes_points_vente_livraison() {
$('#productionpointvente-productions_point_vente input[type=checkbox]').change(function() {
$('#pointsaledistribution-points_sale_distribution input[type=checkbox]').change(function() {
var nb = $('#productionpointvente-productions_point_vente input[type=checkbox]:checked').size() ;
var nb = $('#pointsaledistribution-points_sale_distribution input[type=checkbox]:checked').size() ;
if(nb == 0) {
$(this).prop('checked',true) ;
@@ -91,10 +91,10 @@ function chat_index_commandes_points_vente_livraison() {
if($(this).prop('checked'))
livraison = 1 ;

$.get(UrlManager.getBaseUrl()+'commande/ajax-point-vente-livraison',{
id_production: arr_val[0],
id_point_vente: arr_val[1],
bool_livraison: livraison
$.get(UrlManager.getBaseUrl()+'order/ajax-point-sale-delivery',{
idDistribution: arr_val[0],
idPointSale: arr_val[1],
boolDelivery: livraison
}, function(data) {
chat_alert('success','Point de vente modifié') ;
}) ;
@@ -108,7 +108,7 @@ function chat_index_commandes_points_vente_livraison() {
function chat_index_commandes_maj_points_vente() {
if($('#productions-point-vente').size()) {
var nb = $('#productionpointvente-productions_point_vente input[type=checkbox]:checked').size() ;
var nb = $('#pointsaledistribution-points_sale_distribution input[type=checkbox]:checked').size() ;
if(nb == 0)
{
$('#panel-commandes #tabs-points-vente, #panel-commandes #commandes-points-vente').hide() ;
@@ -123,10 +123,11 @@ function chat_index_commandes_maj_points_vente() {
var id_production = $('#id-production').val() ;
if(id_production) {
$('#tabs-points-vente li').each(function() {
var id_point_vente = $(this).find('a').attr('id').replace('btn-point-vente-','') ;
var nb_commandes = parseInt($(this).find('.badge-success').html()) ;
var checked = $('#productionpointvente-productions_point_vente input[value='+id_production+'-'+id_point_vente+']').prop('checked') ;
var checked = $('#pointsaledistribution-points_sale_distribution input[value='+id_production+'-'+id_point_vente+']').prop('checked') ;
if(checked || nb_commandes > 0)
{
$(this).show() ;
@@ -193,7 +194,7 @@ function chat_points_vente_acces_event() {

function chat_select_etablissement() {
$('select[name="select_etablissement"]').change(function() {
window.location.href = UrlManager.getBaseUrlAbsolute()+'/site/change-etablissement?id='+$(this).val() ;
window.location.href = UrlManager.getBaseUrlAbsolute()+'/site/change-producer?id='+$(this).val() ;
}) ;
}

@@ -235,9 +236,9 @@ function chat_index_commandes_points_vente() {
var id_commande = $(this).data('id-commande') ;
$(this).attr('disabled', 'disabled') ;

$.get(UrlManager.getBaseUrl()+'commande/ajax-delete',{
$.get(UrlManager.getBaseUrl()+'order/ajax-delete',{
date: $('#date-production').val(),
id_commande: id_commande
idOrder: id_commande
}, function(data) {
$('#point-vente-'+id_pv+' .btn-remove').removeAttr('disabled') ;

@@ -260,7 +261,7 @@ function chat_index_commandes_points_vente() {
$('#point-vente-'+id_pv+' .creer-commande').trigger('click') ;
}
}
chat_index_commandes_maj_recap_pv(id_pv, data.total_pv) ;
chat_index_commandes_maj_recap_pv(id_pv, data.total_point_sale) ;
chat_index_commandes_maj_total_commandes() ;
chat_alert('success','Commande supprimée') ;
}, 'json') ;
@@ -293,22 +294,22 @@ function chat_index_commandes_points_vente() {

$(this).attr('disabled', 'disabled') ;

$.get(UrlManager.getBaseUrl()+'commande/ajax-create',{
$.get(UrlManager.getBaseUrl()+'order/ajax-create',{
date: $('#date-production').val(),
id_pv: id_pv,
id_user: $('#point-vente-'+id_pv+' .user-id').val(),
idPointSale: id_pv,
idUser: $('#point-vente-'+id_pv+' .user-id').val(),
username: $('#point-vente-'+id_pv+' .username').val(),
produits: JSON.stringify(tab_produits),
commentaire: $('#point-vente-'+id_pv+' .textarea-commentaire').val()
products: JSON.stringify(tab_produits),
comment: $('#point-vente-'+id_pv+' .textarea-commentaire').val()
}, function(data) {
$('#point-vente-'+id_pv+' .btn-save').removeAttr('disabled') ;
$('#point-vente-'+id_pv+' .btn-save').removeClass('is-create') ;

$('#point-vente-'+id_pv+' .liste-commandes').append(data.commande) ;
$('#point-vente-'+id_pv+' .liste-commandes').append(data.order) ;

chat_index_commandes_points_vente() ;

chat_index_commandes_maj_recap_pv(id_pv, data.total_pv) ;
chat_index_commandes_maj_recap_pv(id_pv, data.total_point_sale) ;

$('#point-vente-'+id_pv+' .buttons-edit-remove').show() ;
$('#point-vente-'+id_pv+' .buttons-save-cancel').hide() ;
@@ -329,20 +330,20 @@ function chat_index_commandes_points_vente() {
var id_commande = $(this).data('id-commande') ;

$(this).attr('disabled', 'disabled') ;
$.get(UrlManager.getBaseUrl()+'commande/ajax-update',{
id_commande: id_commande,
produits: JSON.stringify(tab_produits),
$.get(UrlManager.getBaseUrl()+'order/ajax-update',{
idOrder: id_commande,
products: JSON.stringify(tab_produits),
date: $('#date-production').val(),
commentaire: $('#point-vente-'+id_pv+' .textarea-commentaire').val()
comment: $('#point-vente-'+id_pv+' .textarea-commentaire').val()
}, function(data) {
$('#point-vente-'+id_pv+' .btn-save').removeAttr('disabled') ;
$('#point-vente-'+id_pv+' a[data-id-commande='+id_commande+']').attr('data-commande',data.json_commande);
$('#point-vente-'+id_pv+' a[data-id-commande='+id_commande+'] .montant').html(data.json_commande.str_montant) ;
$('#point-vente-'+id_pv+' a[data-id-commande='+id_commande+']').attr('data-commande',data.json_order);
$('#point-vente-'+id_pv+' a[data-id-commande='+id_commande+'] .montant').html(data.json_order.str_amount) ;
chat_index_commandes_affiche_commande(id_pv, id_commande) ;
chat_index_commandes_maj_recap_pv(id_pv, data.total_pv) ;
chat_index_commandes_maj_recap_pv(id_pv, data.total_point_sale) ;

$('#point-vente-'+id_pv+' .buttons-edit-remove').show() ;
$('#point-vente-'+id_pv+' .buttons-save-cancel').hide() ;
@@ -361,6 +362,7 @@ function chat_index_commandes_points_vente() {

// create
$('.creer-commande').unbind('click').click(function() {
var id_pv = $(this).data('pv-id') ;
$('#point-vente-'+id_pv+' .bloc-commande').fadeIn() ;
$('#point-vente-'+id_pv+' .liste-commandes a.active').removeClass('active') ;
@@ -373,12 +375,6 @@ function chat_index_commandes_points_vente() {
$('#point-vente-'+id_pv+' .choix-user .username').val('') ;
$('#point-vente-'+id_pv+' .commentaire').hide() ;
$('#point-vente-'+id_pv+' .btn-save').addClass('is-create');

/*if(!$('#point-vente-'+id_pv+' .btn-cancel').data('id-commande') &&
$('#point-vente-'+id_pv+' .liste-commandes li').size()) {
$('#point-vente-'+id_pv+' .btn-cancel').data('id-commande',$('#point-vente-'+id_pv+' .liste-commandes li:first a').data('id-commande')) ;
}*/

$('#point-vente-'+id_pv+' .btn-save').data('id-commande',0) ;

chat_index_commandes_inputs_commande(id_pv, false) ;
@@ -395,10 +391,10 @@ function chat_index_commandes_points_vente() {
}

function chat_index_commandes_maj_total_commandes() {
$.get(UrlManager.getBaseUrl()+'commande/ajax-total-commandes',{
$.get(UrlManager.getBaseUrl()+'order/ajax-total-orders',{
date: $('#date-production').val()
}, function(data) {
$('#bloc-totaux').html(data.html_totaux) ;
$('#bloc-totaux').html(data.html_totals) ;
}, 'json') ;
}

@@ -517,22 +513,21 @@ function chat_index_commandes_affiche_commande(id_pv, id_commande) {
$('#point-vente-'+id_pv+' a[data-id-commande='+id_commande+'] .montant .glyphicon').remove() ;
$('#point-vente-'+id_pv+' a[data-id-commande='+id_commande+'] .montant').html() ;

$('#point-vente-'+id_pv+' a[data-id-commande='+id_commande+'] .montant').html(commande.str_montant) ;
if(commande.montant_paye >= commande.montant) {
$('#point-vente-'+id_pv+' a[data-id-commande='+id_commande+'] .montant').html(commande.str_amount) ;
if(commande.paid_amount >= commande.amount) {
$('#point-vente-'+id_pv+' a[data-id-commande='+id_commande+'] .montant').addClass('paye') ;

if(commande.montant_paye > commande.montant) {
if(commande.paid_amount > commande.amount) {
$('#point-vente-'+id_pv+' a[data-id-commande='+id_commande+'] .montant').append(' <span class="glyphicon glyphicon-warning-sign"></span>') ;
}
}
// commentaire
if(commande.commentaire && commande.commentaire.length) {
if(commande.comment && commande.comment.length) {
if(!$('#point-vente-'+id_pv+' a[data-id-commande='+id_commande+'] .glyphicon-comment').size()) {
$('#point-vente-'+id_pv+' a[data-id-commande='+id_commande+']').append(' <span class="glyphicon glyphicon-comment"></span>') ;
}
console.log(id_pv+' '+commande.commentaire) ;
$('#point-vente-'+id_pv+' .commentaire').html(chat_nl2br(commande.commentaire)).show() ;
$('#point-vente-'+id_pv+' .commentaire').html(chat_nl2br(commande.comment)).show() ;
}
else {
$('#point-vente-'+id_pv+' a[data-id-commande='+id_commande+'] .glyphicon-comment').remove() ;
@@ -558,21 +553,13 @@ function chat_index_commandes_affiche_commande(id_pv, id_commande) {
$('#point-vente-'+id_pv+' .td-total').html('') ;
$('#point-vente-'+id_pv+' tr').removeClass('active') ;

$.each(commande.produits, function(i, item) {
$.each(commande.products, function(i, item) {
$('#point-vente-'+id_pv+' .produit-'+i+' .td-commande').html(item) ;
$('#point-vente-'+id_pv+' .produit-'+i).addClass('active') ;
}) ;
$('#point-vente-'+id_pv+' .td-total').html('<span>'+commande.str_montant+'</span>') ;
$('#point-vente-'+id_pv+' .td-total').html('<span>'+commande.str_amount+'</span>') ;
$('#point-vente-'+id_pv+' .tr-total').show() ;

/*var commentaire = link.data('commentaire') ;
if(commentaire) {
$('#point-vente-'+id_pv+' .commentaire').html(commentaire).show() ;
}
else {
$('#point-vente-'+id_pv+' .commentaire').hide() ;
}*/

$('#point-vente-'+id_pv+' .title-user span.the-title').html(link.find('.user').html()+" <small>"+link.data('date')+"</small>") ;

$('#point-vente-'+id_pv+' .bloc-commande').fadeIn() ;
@@ -580,11 +567,11 @@ function chat_index_commandes_affiche_commande(id_pv, id_commande) {
$('#point-vente-'+id_pv+' .tr-total').show() ;

// paiement
$.get(UrlManager.getBaseUrl()+'commande/statut-paiement',{
id_commande: id_commande
$.get(UrlManager.getBaseUrl()+'order/payment-status',{
idOrder: id_commande
}, function(data) {
$('#point-vente-'+id_pv+' .bloc-commande .td-paiement').html(data.html_statut_paiement) ;
$('#point-vente-'+id_pv+' a[data-id-commande='+id_commande+']').attr('data-commande',data.json_commande) ;
$('#point-vente-'+id_pv+' .bloc-commande .td-paiement').html(data.html_payment_status) ;
$('#point-vente-'+id_pv+' a[data-id-commande='+id_commande+']').attr('data-commande',data.json_order) ;
chat_index_commandes_boutons_paiement(id_pv, id_commande) ;
},'json') ;
}
@@ -596,13 +583,13 @@ function chat_index_commandes_affiche_commande(id_pv, id_commande) {
function chat_index_commandes_boutons_paiement(id_pv, id_commande) {
// boutons paiement/remboursement
$('#point-vente-'+id_pv+' .payer, #point-vente-'+id_pv+' .rembourser').click(function() {
$.get(UrlManager.getBaseUrl()+'commande/paiement',{
id_commande: id_commande,
$.get(UrlManager.getBaseUrl()+'order/payment',{
idOrder: id_commande,
type: $(this).data('type'),
montant: $(this).data('montant')
amount: $(this).data('montant')
}, function(data) {
$('#point-vente-'+id_pv+' .bloc-commande .td-paiement').html(data.html_statut_paiement) ;
$('#point-vente-'+id_pv+' a[data-id-commande='+id_commande+']').attr('data-commande',data.json_commande) ;
$('#point-vente-'+id_pv+' .bloc-commande .td-paiement').html(data.html_payment_status) ;
$('#point-vente-'+id_pv+' a[data-id-commande='+id_commande+']').attr('data-commande',data.json_order) ;
chat_index_commandes_affiche_commande(id_pv, id_commande) ;
chat_index_commandes_boutons_paiement(id_pv, id_commande) ;
}, 'json') ;
@@ -722,7 +709,7 @@ function chat_datepicker() {

function chat_calendar() {
if($('#page-commande').size()) {
if($('#page-order').size()) {
var events = new Array ;
$('ul#jours-production li').each(function() {
var date = $(this).html() ;

+ 38
- 38
backend/web/sass/screen.scss View File

@@ -416,9 +416,9 @@ a {
}
h1 {
.btn-group {
float: right ;
}
.btn-group {
float: right ;
}
}
#col-left, #col-right {
@@ -429,7 +429,7 @@ a {
padding-left: 20px ;
}
#distribution-days {
#jours-production {
display: none ;
}
@@ -483,7 +483,7 @@ a {
margin-top: 10px ;
}
#block-distribution {
#bloc-production {
.label {
float: right ;
@@ -495,7 +495,7 @@ a {
border-color: #4cae4c ;
}
#distributions-points-sale {
#productions-point-vente {
margin-top: 15px ;
padding: 10px ;
border: solid 1px #e0e0e0 ;
@@ -513,7 +513,7 @@ a {
}
}
#products-distribution {
#produits-production {
.overflow {
@@ -553,7 +553,7 @@ a {
float: left;
}
.td-product {
.td-produit {
width: 60% ;
}
.td-active, .td-max {
@@ -582,8 +582,8 @@ a {
}
}
#btn-export-orders,
#btn-subscription {
#btn-export-commandes,
#btn-commandes-auto {
float: right ;
position: relative;
top: -5px ;
@@ -591,14 +591,14 @@ a {
padding: 2px 5px ;
}
#btn-export-orders,
#btn-subscription {
#btn-export-commandes,
#btn-commandes-auto {
color: white ;
margin-left: 10px ;
padding: 1px 5px ;
}
#btn-subscription {
#btn-commandes-auto {
top: -7px ;
.btn {
padding: 2px 5px;
@@ -608,7 +608,7 @@ a {
}
}
#block-totals {
#bloc-totaux {
.table-products {
.depasse {
color: #b32815 ;
@@ -621,21 +621,21 @@ a {
}
}
#orders-points-sale {
#commandes-points-vente {
.tab-pane {
padding-top: 20px ;
}
.recap-point-sale {
.recap-pv {
&.no-order {
.revenues {
&.no-commande {
.recettes {
display: none;
}
}
.revenues {
.recettes {
float: right ;
color: $color1 ;
border: solid 1px $color1 ;
@@ -651,7 +651,7 @@ a {
display: none ;
}
ul.liste-orders {
ul.liste-commandes {
margin-top: 10px ;
list-style-type: none ;
height: 100% ;
@@ -662,7 +662,7 @@ a {
width: 100% ;
overflow-y: scroll ;

&.no-order {
&.no-commande {
display: none ;
}
@@ -676,12 +676,12 @@ a {
padding: 7px ;
color: #333 ;
.amount {
.montant {
float: right ;
color: $color1 ;
font-weight: bold ;
&.paid {
&.paye {
color: #5cb85c ;
color: #519951 ;
}
@@ -702,13 +702,13 @@ a {
}
}
.create-order,
.subscriptions {
.creer-commande,
.commandes-auto {
width: 100% ;
margin-bottom: 10px ;
}
.block-order {
.bloc-commande {
padding-top: 20px ;
margin-top: 20px ;
display: none ;
@@ -735,7 +735,7 @@ a {
display: none ;
}
.choice-user {
.choix-user {
display: none ;
.form-control {
@@ -745,7 +745,7 @@ a {
}
}
table.table-products {
table.table-produits {
.td-order {
text-align: center ;
}
@@ -760,22 +760,22 @@ a {
}
}
.td-product,
.th-product {
.td-produit,
.th-produit {
width: 70% ;
}
.td-order,
.th-order {
.td-commande,
.th-commande {
width: 30% ;
text-align: center ;
}
.td-product {
.td-produit {
text-transform: uppercase ;
}
.td-order {
.td-commande {
font-weight: bold ;
}
@@ -792,13 +792,13 @@ a {
}
}
.td-payment {
.td-paiement {
.buttons-credit {
float: right ;
}
}
.panel-order-auto {
.panel-commande-auto {
.field-subscriptionform-id_user,
.field-subscriptionform-id_producer
{
@@ -815,11 +815,11 @@ a {
}
#old-orders {
#old-commandes {
display: none ;
}
.form-orders-point-sale {
.form-commandes-point-vente {
margin-top: 20px ;

+ 7
- 4
common/components/ActiveRecordCommon.php View File

@@ -113,6 +113,11 @@ class ActiveRecordCommon extends \yii\db\ActiveRecord
}
}
// Params
if(isset($options['params']) && is_array($options['params']) && count($options['params'])) {
$records = $records->params($options['params']) ;
}
// Paramètres
if(is_array($params) && count($params)) {
foreach($params as $key => $val) {
@@ -146,14 +151,12 @@ class ActiveRecordCommon extends \yii\db\ActiveRecord
if($record) {
return $record ;
}
else {
throw new NotFoundHttpException(
'Le modèle '.$class.' #'.((int) $params[$pk]).' n\'a pas été trouvé.');
}
}
elseif($options['type_search'] == self::SEARCH_COUNT) {
return $records->count() ;
}
return false ;
}
/**

+ 1
- 1
common/models/CreditHistory.php View File

@@ -180,7 +180,7 @@ class CreditHistory extends ActiveRecordCommon
parent::save($runValidation, $attributeNames);

// mise à jour du crédit au niveau de UserEtablissement
// mise à jour du crédit au niveau de UserProducer
$userProducer = UserProducer::searchOne([
'id_user' => $this->id_user,
'id_producer' => $this->id_producer

+ 12
- 9
common/models/Distribution.php View File

@@ -152,7 +152,10 @@ class Distribution extends ActiveRecordCommon
{
$distribution = null ;
if ($date != '') {
$distribution = Distribution::searchOne(['date' => $date]) ;
$distribution = Distribution::find()
->where(['date' => $date])
->one() ;
if (!$distribution) {
$distribution = new Distribution;
$distribution->date = $date;
@@ -189,26 +192,26 @@ class Distribution extends ActiveRecordCommon
$productDistribution->id_distribution = $distribution->id;
$productDistribution->id_product = $product->id;

$productDistribution->actif = 0;
if ($product->actif && $dayDistribution == 1 && $product->monday) {
$productDistribution->active = 0;
if ($product->active && $dayDistribution == 1 && $product->monday) {
$productDistribution->active = 1;
}
if ($product->actif && $dayDistribution == 2 && $product->tuesday) {
if ($product->active && $dayDistribution == 2 && $product->tuesday) {
$productDistribution->active = 1;
}
if ($product->actif && $dayDistribution == 3 && $product->wednesday) {
if ($product->active && $dayDistribution == 3 && $product->wednesday) {
$productDistribution->active = 1;
}
if ($product->actif && $dayDistribution == 4 && $product->thursday) {
if ($product->active && $dayDistribution == 4 && $product->thursday) {
$productDistribution->active = 1;
}
if ($product->actif && $dayDistribution == 5 && $product->friday) {
if ($product->active && $dayDistribution == 5 && $product->friday) {
$productDistribution->active = 1;
}
if ($product->actif && $dayDistribution == 6 && $product->saterday) {
if ($product->active && $dayDistribution == 6 && $product->saterday) {
$productDistribution->active = 1;
}
if ($product->actif && $dayDistribution == 7 && $product->sunday) {
if ($product->active && $dayDistribution == 7 && $product->sunday) {
$productDistribution->active = 1;
}

+ 16
- 10
common/models/Order.php View File

@@ -75,7 +75,7 @@ class Order extends ActiveRecordCommon
const STATE_OPEN = 'open';
const STATE_PREPARATION = 'preparation';
const STATE_DELIVERED = 'livree';
const STATE_DELIVERED = 'delivered';
/**
* @inheritdoc
@@ -265,7 +265,7 @@ class Order extends ActiveRecordCommon
'products' => [],
'amount' => $order->amount,
'str_amount' => $order->getAmount(self::AMOUNT_TOTAL, true),
'paid_amount' => $order->getPaidAmount(self::AMOUNT_PAID),
'paid_amount' => $order->getAmount(self::AMOUNT_PAID),
'comment' => $order->comment,
];

@@ -278,13 +278,13 @@ class Order extends ActiveRecordCommon
}

/**
* Enregistre un modèle de type CreditHistorique.
* Enregistre un modèle de type CreditHistory.
*
* @param string $type
* @param float $montant
* @param integer $id_producer
* @param integer $id_user
* @param integer $id_user_action
* @param integer $idProducer
* @param integer $idUser
* @param integer $idUserAction
*/
public function saveCreditHistory($type, $amount, $idProducer, $idUser, $idUserAction)
{
@@ -470,15 +470,15 @@ class Order extends ActiveRecordCommon
$classLabel = '';
$str = '';

if ($this->type == self::ORIGIN_USER) {
if ($this->origin == self::ORIGIN_USER) {
$classLabel = 'success';
$str = 'Client';
}
elseif ($this->type == self::ORIGIN_AUTO) {
elseif ($this->origin == self::ORIGIN_AUTO) {
$classLabel = 'default';
$str = 'Auto';
}
elseif ($this->type == self::ORIGIN_ADMIN) {
elseif ($this->origin == self::ORIGIN_ADMIN) {
$classLabel = 'warning';
$str = 'Vous';
}
@@ -603,7 +603,13 @@ class Order extends ActiveRecordCommon
}
else {
$order = $orders ;
return $order->init() ;
if(is_a($order, 'common\models\Order')) {
return $order->init() ;
}
// count
else {
return $order ;
}
}
return false ;

+ 9
- 7
common/models/PointSale.php View File

@@ -159,19 +159,21 @@ class PointSale extends ActiveRecordCommon
/**
* Initialise les commandes liées au point de vente.
*
* @param array $commandes
* @param array $ordersArray
*/
public function initOrders($orders)
public function initOrders($ordersArray)
{
$this->orders = [];
$this->revenues = 0;

foreach ($orders as $o) {
if ($this->id == $c->id_point_sale) {
$this->orders[] = $o;
if($ordersArray) {
foreach ($ordersArray as $order) {
if ($this->id == $order->id_point_sale) {
$this->orders[] = $order;

if(is_null($o->date_delete)) {
$this->revenues += (float) $o->amount;
if(is_null($order->date_delete)) {
$this->revenues += (float) $order->amount;
}
}
}
}

+ 2
- 2
common/models/PointSaleDistribution.php View File

@@ -123,7 +123,7 @@ class PointSaleDistribution extends ActiveRecordCommon
*/
public static function setAll($idDistribution, $boolDelivery)
{
$countPointSaleDistribution = Distribution::searchCount([
$countPointSaleDistribution = self::searchCount([
'id_distribution' => $idDistribution
]) ;

@@ -138,7 +138,7 @@ class PointSaleDistribution extends ActiveRecordCommon
}
}

$distribution = Distribution::findOne($idProduction);
$distribution = Distribution::findOne($idDistribution);

if ($distribution) {
$day = date('N', strtotime($distribution->date));

+ 1
- 1
common/models/Product.php View File

@@ -121,7 +121,7 @@ class Product extends ActiveRecordCommon
'with' => [],
'join_with' => [],
'orderby' => 'order ASC',
'attribute_id_producer' => 'order.id_producer'
'attribute_id_producer' => 'product.id_producer'
] ;
}


+ 1
- 1
common/models/ProductDistribution.php View File

@@ -48,7 +48,7 @@ use common\components\ActiveRecordCommon ;
* @property integer $id
* @property integer $id_distribution
* @property integer $id_product
* @property integer $actif
* @property integer $active
*/
class ProductDistribution extends ActiveRecordCommon
{

+ 10
- 10
common/models/Subscription.php View File

@@ -168,12 +168,12 @@ class Subscription extends ActiveRecordCommon
*/
public function add($date)
{
// production
$production = Production::searchOne([
'production.date' => date('Y-m-d', strtotime($date))
// distribution
$distribution = Distribution::searchOne([
'distribution.date' => date('Y-m-d', strtotime($date))
]) ;

if ($production && count($this->productSubscription)) {
if ($distribution && count($this->productSubscription)) {
// commande
$order = new Order;
if (strlen($this->username)) {
@@ -186,7 +186,7 @@ class Subscription extends ActiveRecordCommon
$order->date = date('Y-m-d H:i:s');
$order->origin = Order::ORIGIN_AUTO;
$order->id_point_sale = $this->id_point_sale;
$order->id_production = $production->id;
$order->id_distribution = $distribution->id;
$order->auto_payment = $this->auto_payment ;
$userPointSale = UserPointSale::searchOne([
@@ -213,7 +213,7 @@ class Subscription extends ActiveRecordCommon
$productsAdd = true;
}

if (!$products_add) {
if (!$productsAdd) {
$order->delete();
}
}
@@ -227,13 +227,13 @@ class Subscription extends ActiveRecordCommon
*/
public static function addAll($date, $force = false)
{
$production = Production::searchOne([
$distribution = Distribution::searchOne([
'date' => date('Y-m-d', strtotime($date))
]) ;

if ($production) {
if ($distribution) {
$countOrdersProd = Order::searchCount([
Order::tableName().'.id_production' => $production->id
Order::tableName().'.id_distribution' => $distribution->id
]) ;

if (!$countOrdersProd || $force) {
@@ -266,7 +266,7 @@ class Subscription extends ActiveRecordCommon
{
// périodicite
$nbDays = (strtotime($date) - strtotime($s->date_begin)) / (24 * 60 * 60);
if ($nbDays % ($c->week_frequency * 7) < 7) {
if ($nbDays % ($s->week_frequency * 7) < 7) {
// jour de la semaine
$day = date('N', strtotime($date));
switch ($day) {

+ 1
- 1
common/models/User.php View File

@@ -138,7 +138,7 @@ class User extends ActiveRecordCommon implements IdentityInterface
public static function defaultOptionsSearch() {
return [
'with' => [],
'join_with' => ['userEtablissement'],
'join_with' => ['userProducer'],
'orderby' => 'user.name ASC, user.lastname ASC',
'attribute_id_producer' => ''
] ;

+ 15
- 0
console/migrations/m181224_161347_change_column_order_type.php View File

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

use yii\db\Migration;

class m181224_161347_change_column_order_type extends Migration {

public function up() {
$this->renameColumn('order', 'type', 'origin');
}

public function down() {
$this->renameColumn('order', 'origin', 'type');
}

}

+ 16
- 0
console/migrations/m181226_100720_rename_column_subscription_date_begin.php View File

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

use yii\db\Migration;

class m181226_100720_rename_column_subscription_date_begin extends Migration
{
public function up()
{
$this->renameColumn('subscription', 'date_debin', 'date_begin');
}

public function down()
{
$this->renameColumn('subscription', 'date_begin', 'date_debin') ;
}
}

Loading…
Cancel
Save