extranet/library/Scores/GestionCommandes.php
2011-06-28 13:47:02 +00:00

90 lines
2.2 KiB
PHP

<?php
class GestionCommande
{
protected $db = null;
public function __construct()
{
$dbConfig = new Zend_Config_Ini(APPLICATION_PATH.'/configs/databases.ini');
$this->db = Zend_Db::factory($dbConfig->db->sdv1);
}
/**
* Liste les commandes Kbis par n° SIREN
* @param string $siren
*/
public function listCommandesKbisBySiren($siren)
{
$commandes = new Application_Model_CommandesKbis($this->db);
return $commandes->getCommandesKbisBySiren($siren);
}
/**
* Liste les commandes Kbis par numéro de commande
* @param string $num G<NNNN>
* @return array
*/
public function listCommandesKbisByNum($num)
{
$commandes = new Application_Model_CommandesKbis($this->db);
$id = substr($num, 1);
return $commandes->getCommandesKbisById($id);
}
/**
* Liste les commandes Kbis
* @param string $date
* @param int $etat
* @param string $mode
* @return array
*/
public function listCommandesKbis($date, $etat, $mode)
{
$commandes = new Application_Model_CommandesKbis($this->db);
$dateTDebut = mktime(0, 0, 0, date('m', $date), 1, date('Y', $date));
$dateDebut = date('Y-m',$dateTDebut);
$sql = $commandes->select()->where('dateCommande LIKE ?', $dateDebut.'%');
if (!empty($etat)){
$sql->where('statutCommande = ?', $etat);
}
if (!empty($mode) && $mode != '-'){
$sql->where('type = ?', $mode);
}
$sql->order('dateCommande ASC');
return $commandes->fetchAll($sql)->toArray();
}
public function listCommandesGreffeByNum($id)
{
$commandes = new Application_Model_Commandes($this->db);
$id = substr($num, 1);
return $commandes->getCommandesById($id);
}
public function listCommandesGreffeBySiren($siren)
{
$commandes = new Application_Model_Commandes($this->db);
return $commandes->getCommandesBySiren($siren);
}
public function listCommandesGreffeByLogin($login)
{
$commandes = new Application_Model_Commandes($this->db);
return $commandes->getCommandesByLogin($login);
}
/**
*
* Enter description here ...
*/
public function listStatus()
{
$commandeStatut = new Application_Model_CommandesStatut($this->db);
$sql = $commandeStatut->select('*')
->where('typeCommande = ?', 'C')
->order('ordre ASC');
return $commandeStatut->fetchAll($sql)->toArray();
}
}