extranet/application/models/Commandes.php
2012-01-30 09:25:39 +00:00

65 lines
1.8 KiB
PHP

<?php
class Application_Model_Commandes extends Zend_Db_Table_Abstract
{
protected $_name = 'commandes';
/**
* 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);
}
$this->getAdapter()->setFetchMode(Zend_Db::FETCH_OBJ);
$result = $this->getAdapter()->fetchAll($sql);
return $result;
}
public function getCommandesById($id)
{
$sql = $this->select()->where('idCommande = ?', $id);
$this->getAdapter()->setFetchMode(Zend_Db::FETCH_OBJ);
$result = $this->getAdapter()->fetchAll($sql);
return $result;
}
public function getCommandesBySiren($siren)
{
$sql = $this->select()
->where('siren = ?', $siren)
->order('dateCommande ASC');
$this->getAdapter()->setFetchMode(Zend_Db::FETCH_OBJ);
$result = $this->getAdapter()->fetchAll($sql);
return $result;
}
public function getCommandesByLogin($login, $timestamp)
{
$dateTDebut = mktime(0, 0, 0, date('m', $timestamp), 1, date('Y', $timestamp));
$dateDebut = date('Y-m',$dateTDebut);
$sql = $this->select()
->where('login = ?', $login)
->order('dateCommande ASC')
->where('dateCommande LIKE ?', $dateDebut.'%');
$this->getAdapter()->setFetchMode(Zend_Db::FETCH_OBJ);
$result = $this->getAdapter()->fetchAll($sql);
return $result;
}
}