extranet/application/models/RapportsGiants.php
2011-09-29 15:15:14 +00:00

57 lines
1.8 KiB
PHP

<?php
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
class Application_Model_RapportsGiants extends Zend_Db_Table_Abstract
{
protected $_name = 'rapports_giants';
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);
}
}
public function getReportById($companyId)
{
$sql = $this->select('report')
->where('companyId = ?', $companyId);
$result = $this->getAdapter()->fetchAll($sql);
return ($result);
}
public function getReportByIdAndType($companyId, $type)
{
if($type == 'CR') {
$where = 'type="FU" or type="CO"';
} else $where = 'type = "FU"';
$sql = $this->select()
->where('companyId = ? and '.$where, $companyId);
$result = $this->getAdapter()->fetchRow($sql);
if($type == 'FU') {
$where = $this->getAdapter()->quoteInto('companyId = ? AND type = "CR" OR type = "CO"' , $companyId);
//var_dump($where);exit;
$this->delete($where);
} else if($type == 'CO') {
$where = $this->getAdapter()->quoteInto('companyId = ? and type = "CR"', $companyId);
$this->delete($where);
}
return ($result['report']);
}
public function getReportDate($companyId, $type)
{
$sql = $this->select('date')
->where('companyId = ?', $companyId)
->where('type = ?', $type);
$result = $this->getAdapter()->fetchAll($sql);
return ($result);
}
}
?>