Browse Source

[Backend] Tableau de bord : ajout des commandes ajoutées par les producteurs

Les commandes listées sur le tableau de bord comprennent désormais les commandes ajoutées par le producteur et celles effectuées directement par les clients.
prodstable
keun 6 years ago
parent
commit
202b9db9ea
3 changed files with 28 additions and 3 deletions
  1. +1
    -2
      backend/controllers/SiteController.php
  2. +2
    -0
      backend/views/site/index.php
  3. +25
    -1
      common/models/Commande.php

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

@@ -88,10 +88,9 @@ class SiteController extends BackendController
// dernières commandes
$commandes = Commande::findBy([
'type' => Commande::TYPE_USER,
'orderby' => 'date DESC',
'limit' => 15,
'condition' => 'production.date > \''.date('Y-m-d 00:00:00').'\''
'condition' => 'production.date > \''.date('Y-m-d 00:00:00').'\' AND (type = \''.Commande::TYPE_USER.'\' OR type = \''.Commande::TYPE_ADMIN.'\')'
]) ;
foreach($commandes as $c)

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

@@ -205,6 +205,7 @@ $this->title = 'Tableau de bord';
<table class="table table-condensed table-bordered">
<thead>
<tr>
<th></th>
<th>Date</th>
<th>Client</th>
<th>Produits</th>
@@ -215,6 +216,7 @@ $this->title = 'Tableau de bord';
<tbody>
<?php foreach($commandes as $c): ?>
<tr>
<td><?= $c->getStrType(true); ?></td>
<td class="date">
<div class="bloc-date">
<div class="jour"><?= strftime('%A', strtotime($c->production->date)) ?></div>

+ 25
- 1
common/models/Commande.php View File

@@ -369,8 +369,9 @@ class Commande extends \yii\db\ActiveRecord
if(isset($params['date']))
$commandes = $commandes->andWhere(['production.date' => $params['date']]);
if(isset($params['type']))
if(isset($params['type']))
$commandes = $commandes->andWhere(['commande.type' => $params['type']]);
if(isset($params['orderby']))
$commandes = $commandes->orderBy($params['orderby']);
@@ -410,4 +411,27 @@ class Commande extends \yii\db\ActiveRecord
return self::ETAT_PREPARATION ;
}
public function getStrType($with_label = false) {
$class_label = '' ;
$str = '' ;
if($this->type == self::TYPE_USER) {
$class_label = 'success' ;
$str = 'Client' ;
}
elseif($this->type == self::TYPE_AUTO) {
$class_label = 'default' ;
$str = 'Auto' ;
}
elseif($this->type == self::TYPE_ADMIN) {
$class_label = 'warning' ;
$str = 'Vous' ;
}
if($with_label)
return '<span class="label label-'.$class_label.'">'.$str.'</span>' ;
else
return $str ;
}
}

Loading…
Cancel
Save