extranet/application/models/Commandes.php

65 lines
1.8 KiB
PHP
Raw Normal View History

2011-05-11 14:16:42 +00:00
<?php
class Application_Model_Commandes extends Zend_Db_Table_Abstract
{
protected $_name = 'commandes';
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);
2012-01-30 09:25:39 +00:00
}
$this->getAdapter()->setFetchMode(Zend_Db::FETCH_OBJ);
2011-08-04 16:00:20 +00:00
$result = $this->getAdapter()->fetchAll($sql);
return $result;
}
public function getCommandesById($id)
{
$sql = $this->select()->where('idCommande = ?', $id);
2012-01-30 09:25:39 +00:00
$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');
2012-01-30 09:25:39 +00:00
$this->getAdapter()->setFetchMode(Zend_Db::FETCH_OBJ);
$result = $this->getAdapter()->fetchAll($sql);
return $result;
}
2011-08-22 13:00:34 +00:00
public function getCommandesByLogin($login, $timestamp)
{
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);
$sql = $this->select()
->where('login = ?', $login)
2011-08-22 13:00:34 +00:00
->order('dateCommande ASC')
->where('dateCommande LIKE ?', $dateDebut.'%');
2012-01-30 09:25:39 +00:00
$this->getAdapter()->setFetchMode(Zend_Db::FETCH_OBJ);
$result = $this->getAdapter()->fetchAll($sql);
return $result;
}
2011-05-11 14:16:42 +00:00
}