2011-08-25 08:57:37 +00:00
|
|
|
<?php
|
|
|
|
class Application_Model_RapportsGiants extends Zend_Db_Table_Abstract
|
|
|
|
{
|
|
|
|
protected $_name = 'rapports_giants';
|
|
|
|
|
|
|
|
public function getReportById($companyId)
|
|
|
|
{
|
|
|
|
$sql = $this->select('report')
|
|
|
|
->where('companyId = ?', $companyId);
|
|
|
|
$result = $this->getAdapter()->fetchAll($sql);
|
|
|
|
return ($result);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getReportByIdAndType($companyId, $type)
|
|
|
|
{
|
2011-09-06 12:40:31 +00:00
|
|
|
if($type == 'CR') {
|
2011-09-07 08:41:39 +00:00
|
|
|
$where = 'type="FU" or type="CO"';
|
|
|
|
} else $where = 'type = "FU"';
|
2011-08-25 08:57:37 +00:00
|
|
|
$sql = $this->select()
|
2011-09-07 08:41:39 +00:00
|
|
|
->where('companyId = ? and '.$where, $companyId);
|
2011-08-25 08:57:37 +00:00
|
|
|
$result = $this->getAdapter()->fetchRow($sql);
|
2011-09-06 12:40:31 +00:00
|
|
|
if($type == 'FU') {
|
2011-09-07 08:41:39 +00:00
|
|
|
$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);
|
2011-09-06 12:40:31 +00:00
|
|
|
$this->delete($where);
|
|
|
|
}
|
2011-08-25 08:57:37 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|