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

43 lines
1.2 KiB
PHP

<?php
class Application_Model_CommandesKbis extends Zend_Db_Table_Abstract
{
protected $_name = 'commandes_kbis';
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($etat)){
$sql->where('statutCommande = ?', $etat);
}
if (!empty($mode) && $mode != '-'){
$sql->where('type = ?', $mode);
}
$sql->order('dateCommande ASC');
$this->getAdapter()->setFetchMode(Zend_Db::FETCH_OBJ);
$result = $this->getAdapter()->fetchAll($sql);
return $result;
}
public function getCommandesKbisById($id)
{
$sql = $this->select()
->where('id = ?', $id);
$this->getAdapter()->setFetchMode(Zend_Db::FETCH_OBJ);
$result = $this->getAdapter()->fetchAll($sql);
return $result;
}
public function getCommandesKbisBySiren($siren)
{
$sql = $this->select()
->where('siren = ?', $siren)
->order('dateCommande ASC');
$this->getAdapter()->setFetchMode(Zend_Db::FETCH_OBJ);
$result = $this->getAdapter()->fetchAll($sql);
return $result;
}
}