extranet/application/models/RapportsGiants.php

42 lines
1.3 KiB
PHP

<?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)
{
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);
}
}
?>