[eluser]cestaz18[/eluser]
MODEL
Code:
<?
class At_reports_db extends Model {
function At_reports_db()
{
parent::Model();
}
function getList()
{
$sortname = $this->input->post('sortname');
$sortorder = $this->input->post('sortorder');
$page = $this->input->post('page');
$rp = $this->input->post('rp');
$query = $this->input->post('query');
$qtype = $this->input->post('qtype');
$stype = $this->input->post('s_type');
$otype = $this->input->post('o_type');
$skey = $this->input->post('s_key');
if (!$sortname) $sortname = 'module_id';
if (!$sortorder) $sortorder = 'DESC';
if (!$page) $page = 1;
if (!$rp) $rp = 25;
$start = (($page-1) * $rp);
$this->db->start_cache();
if ($stype)
{
foreach ($stype as $key => $value)
{
if ($skey[$key])
{
if ($stype[$key]=='so_date') $match = convertDate($skey[$key]);
else $match = $skey[$key];
switch ($otype[$key])
{
case "=":
$this->db->where($stype[$key],$match);
break;
case "!=":
$this->db->where($stype[$key]." !=",$match);
break;
case "like":
$this->db->like($stype[$key],$match);
break;
case ">":
$this->db->where($stype[$key]." >",$match);
break;
case "<":
$this->db->where($stype[$key]." <",$match);
break;
}
}
}
}
$this->db->from('sec_reports');
$this->db->select('module_id as pkey, module_name');
$num = $this->db->count_all_results();
$this->db->order_by($sortname,$sortorder);
$this->db->limit($rp, $start);
$query = $this->db->get("sec_reports");
$this->db->flush_cache();
$data['db'] = $query;
$data['page'] = $page;
$data['num'] = $num;
return $data;
}
function countDetailList($data)
{
$this->db->where($data);
$this->db->from('sec_reports_parameters');
$count['detFlex1'] = $this->db->count_all_results();
return $count;
}
function getDetails($cond) {
$data['module_id'] = $cond['module_id'];
$this->db->select("*");
$this->db->from("sec_reports");
$this->db->where($data);
return $this->db->get('sec_reports')->row_array();
}
function getDetailsByName($cond) {
$data['module_name'] = $cond['module_name'];
$this->db->select("*");
$this->db->from("sec_reports");
$this->db->where($data);
return $this->db->get('sec_reports')->row_array();
}
function getParameters() {
$item = $this->input->post('item');
$sortname = $this->input->post('sortname');
$sortorder = $this->input->post('sortorder');
if (!$sortname) $sortname = 'parameter_id';
if (!$sortorder) $sortorder = 'ASC';
$page = 1;
$this->db->start_cache();
$this->db->from('sec_reports_parameters');
//$this->db->where('sec_reports_parameters.parameter_id',$item);
$num = $this->db->count_all_results();
$this->db->select("parameter_id as pkey,parameter_id, parameter_label, parameter_name, parameter_type");
$this->db->order_by($sortname,$sortorder);
$query = $this->db->get("sec_reports_parameters");
$this->db->flush_cache();
$data['db'] = $query;
$data['page'] = $page;
$data['num'] = $num;
return $data;
//return $num;
}