extranet/application/models/CommandesKbis.php

52 lines
1.5 KiB
PHP
Raw Normal View History

2011-05-19 08:46:55 +00:00
<?php
class Application_Model_CommandesKbis extends Zend_Db_Table_Abstract
{
protected $_name = 'commandes_kbis';
public function __construct()
{
if (empty($config) && Zend_Registry::isRegistered('configuration')){
$configuration = Zend_Registry::get('configuration');
$this->_db = Zend_Db::factory($configuration->databases->db->sdv1);
} elseif(empty($config)){
$dbConfig = new Zend_Config_Ini(APPLICATION_PATH.'/configs/configuration.ini', 'databases');
$this->_db = Zend_Db::factory($dbConfig->db->sdv1);
}
2011-12-07 12:34:01 +00:00
$this->_db->setFetchMode(Zend_Db::FETCH_OBJ);
}
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');
$result = $this->getAdapter()->fetchAll($sql);
return $result;
}
public function getCommandesKbisById($id)
{
$sql = $this->select()
->where('id = ?', $id);
$result = $this->getAdapter()->fetchAll($sql);
return $result;
}
public function getCommandesKbisBySiren($siren)
{
$sql = $this->select()
->where('siren = ?', $siren)
->order('dateCommande ASC');
$result = $this->getAdapter()->fetchAll($sql);
return $result;
}
2011-05-19 08:46:55 +00:00
}