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.master
@@ -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) |
@@ -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> |
@@ -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 ; | |||
} | |||
} |