2011-05-11 14:16:42 +00:00
|
|
|
<?php
|
|
|
|
class Application_Model_Commandes extends Zend_Db_Table_Abstract
|
|
|
|
{
|
|
|
|
protected $_name = 'commandes';
|
2011-06-27 16:08:18 +00:00
|
|
|
|
2011-08-04 16:00:20 +00:00
|
|
|
/**
|
|
|
|
* Liste les commandes suivant la
|
|
|
|
* @param unknown_type $timestamp
|
|
|
|
* @param unknown_type $etat
|
|
|
|
* @param unknown_type $mode
|
|
|
|
*/
|
|
|
|
public function getCommandes($timestamp, $etat, $mode)
|
|
|
|
{
|
|
|
|
$dateTDebut = mktime(0, 0, 0, date('m', $timestamp), 1, date('Y', $timestamp));
|
|
|
|
$dateDebut = date('Y-m',$dateTDebut);
|
|
|
|
$sql = $this->select()->where('dateCommande LIKE ?', $dateDebut.'%');
|
|
|
|
if (!empty($mode)){
|
|
|
|
if ( $mode == 'G' ) {
|
|
|
|
$sql->where('typeCommande IN (?) ', array('', $mode));
|
|
|
|
} else {
|
|
|
|
$sql->where('typeCommande = ?', $mode);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!empty($etat)){
|
|
|
|
$sql->where('statutCommande = ?', $etat);
|
|
|
|
}
|
|
|
|
$result = $this->getAdapter()->fetchAll($sql);
|
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
|
2011-06-27 16:08:18 +00:00
|
|
|
public function getCommandesById($id)
|
|
|
|
{
|
|
|
|
$sql = $this->select()->where('idCommande = ?', $id);
|
|
|
|
$result = $this->getAdapter()->fetchAll($sql);
|
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getCommandesBySiren($siren)
|
|
|
|
{
|
|
|
|
$sql = $this->select()
|
|
|
|
->where('siren = ?', $siren)
|
|
|
|
->order('dateCommande ASC');
|
|
|
|
$result = $this->getAdapter()->fetchAll($sql);
|
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
|
2011-08-22 13:00:34 +00:00
|
|
|
public function getCommandesByLogin($login, $timestamp)
|
2011-06-27 16:08:18 +00:00
|
|
|
{
|
2011-08-22 13:00:34 +00:00
|
|
|
$dateTDebut = mktime(0, 0, 0, date('m', $timestamp), 1, date('Y', $timestamp));
|
|
|
|
$dateDebut = date('Y-m',$dateTDebut);
|
|
|
|
|
2011-06-27 16:08:18 +00:00
|
|
|
$sql = $this->select()
|
|
|
|
->where('login = ?', $login)
|
2011-08-22 13:00:34 +00:00
|
|
|
->order('dateCommande ASC')
|
|
|
|
->where('dateCommande LIKE ?', $dateDebut.'%');
|
|
|
|
|
2011-06-27 16:08:18 +00:00
|
|
|
$result = $this->getAdapter()->fetchAll($sql);
|
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
|
2011-05-11 14:16:42 +00:00
|
|
|
}
|