Browse Source

Export commandes (tri)

Trier les commandes par numéro de boîte.
master
keun 7 years ago
parent
commit
120c140356
3 changed files with 19 additions and 8 deletions
  1. +2
    -1
      backend/controllers/CommandeController.php
  2. +1
    -1
      backend/controllers/SiteController.php
  3. +16
    -6
      common/models/Commande.php

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

@@ -67,7 +67,8 @@ class CommandeController extends BackendController {
$commandes = Commande::findBy([
'date' => $date,
'id_etablissement' => $id_etablissement
'id_etablissement' => $id_etablissement,
'orderby' => 'commentaire_point_vente ASC, user.nom ASC'
]) ;

foreach ($commandes as $c)

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

@@ -88,7 +88,7 @@ class SiteController extends BackendController
// dernières commandes
$commandes = Commande::findBy([
'order' => 'DESC',
'orderby' => 'date DESC',
'limit' => 15
]) ;
foreach($commandes as $c)

+ 16
- 6
common/models/Commande.php View File

@@ -360,26 +360,36 @@ class Commande extends \yii\db\ActiveRecord
$params['id_etablissement'] = Yii::$app->user->identity->id_etablissement ;
$commandes = Commande::find()
->with('commandeProduits', 'user', 'creditHistorique', 'pointVente')
->joinWith('production')
->with('commandeProduits', 'creditHistorique', 'pointVente')
->joinWith(['production','user'])
->where(['production.id_etablissement' => $params['id_etablissement']]) ;
if(isset($params['date']))
$commandes = $commandes->andWhere(['production.date' => $params['date']]);
/*$orderby = 'date' ;
if(isset($params['orderby']))
$orderby = $params['orderby'] ;
if(isset($params['order']))
$commandes = $commandes->orderBy('date '.$params['order']);
$commandes = $commandes->orderBy($orderby.' '.$params['order']);
else
$commandes = $commandes->orderBy($orderby.' ASC');*/
if(isset($params['orderby']))
{
$commandes = $commandes->orderBy($params['orderby']);
}
else {
$commandes = $commandes->orderBy('date ASC');
}
if(isset($params['limit']))
$commandes = $commandes->limit($params['limit']) ;
$commandes = $commandes->all() ;
return $commandes ;
return $commandes ;
}
public function getEtat()

Loading…
Cancel
Save