diff --git a/api/application/models/Data_Dump_Model.php b/api/application/models/Data_Dump_Model.php index a126f210..a617dba7 100644 --- a/api/application/models/Data_Dump_Model.php +++ b/api/application/models/Data_Dump_Model.php @@ -70,5 +70,50 @@ class Data_Dump_Model extends SPARQ_Model { } } - } + } + + function getRequestForDataDump($pdid,$fd=null,$td=null,$type){ + $this->db->select('t_pd_form_details_json.pd_form_detail_json_id, t_pd_form_details_json.fk_pd_id, t_pd_form_details_json.fk_form_id, t_pd_form_details_json.isactive, t_pd_form_details_json.json, DATE_FORMAT(t_pd_form_details_json.createdon,"%d/%m/%Y %H:%i:%s") as createdon, t_pd_form_details_json.processed_json, t_pd_form_details_json.updatedon'); + $this->db->from('t_pd_form_details_json'); + + if(!empty($pdid)) + { + + $this->db->where_in('t_pd_form_details_json.fk_pd_id',$pdid); + } + if(($fd != "" || $fd != null) && ($td != "" || $td != null)) { + if($type == "Createdon" ){ + $this->db->where('t_pd_form_details_json.createdon BETWEEN '. "'$fd'". ' AND '. "'$td'" ); + }else if($type == "Updatedon" ){ + $this->db->where('t_pd_form_details_json.updatedon BETWEEN '. "'$fd'". ' AND '. "'$td'" ); + }else{ + $this->db->where('t_pd_form_details_json.updatedon BETWEEN '. "'$fd'". ' AND '. "'$td'" ); + } + } + else if($fd != "" && $fd != null) { + if($type == "Createdon" ){ + $this->db->where("DATE_FORMAT(t_pd_form_details_json.createdon,'%Y-%m-%d')",$fd); + }else if($type == "Updatedon" ){ + $this->db->where("DATE_FORMAT(t_pd_form_details_json.updatedon,'%Y-%m-%d')",$fd); + }else{ + $this->db->where("DATE_FORMAT(t_pd_form_details_json.updatedon,'%Y-%m-%d')",$fd); + } + } + else if($td != "" && $td != null) { + if($type == "Createdon" ){ + $this->db->where("DATE_FORMAT(t_pd_form_details_json.createdon,'%Y-%m-%d')",$td); + }else if($type == "Updatedon" ){ + $this->db->where("DATE_FORMAT(t_pd_form_details_json.updatedon,'%Y-%m-%d')",$td); + }else{ + $this->db->where("DATE_FORMAT(t_pd_form_details_json.updatedon,'%Y-%m-%d')",$td); + } + } + $this->db->WHERE('t_pd_form_details_json.isactive',1); + $this->db->order_by('t_pd_form_details_json.pd_form_detail_json_id','desc'); + $result = $this->db->get()->result_array(); + // echo count($result);print_r($result);die(); + // print_r($this->db->last_query());die(); + return $result; + + } } \ No newline at end of file