load->database(); } function saveMapping($data){ //echo '
'; print_r($data);die; $this->db->where('form_name', $data['form_name']); $checking = $this->db->get('form_template_mapping')->result(); if(empty($checking)){ $this->db->insert('form_template_mapping', $data); $main_id=$this->db->insert_id(); if($main_id){ $output['msg']='Added Successfully.'; $output['code']='200'; }else{ $output['msg']='Error.'; $output['code']='404'; } return $output; }else{ $output['msg']='Duplicate Name'; $output['code']='404'; return $output; } } function updateMapping($data,$id){ //echo ''; print_r($data);die; $this->db->where('id', $id); $this->db->update('form_template_mapping', $data); $main_id=$this->db->affected_rows(); if($main_id){ $output['msg']='Update Successfully.'; $output['code']='200'; } return $output; } function getFormDataByName($name){ $this->db->order_by('id', 'DESC')->where('form_name',$name); $query = $this->db->get('form_template_mapping')->row(); return $query; } function total_list(){ $query = $this->db->get('form_template_mapping'); $output=$query->result(); return count($output); } function getNameByLimitBySearch($limit, $start, $search) { // $this->db->like('id', $search); // $this->db->order_by('id', 'desc'); // $this->db->or_like('name', $search); // $this->db->or_like('status', $search); $this->db->limit($limit, $start); $query = $this->db->get('form_template_mapping'); return $query->result(); } function getNameByLimit($limit, $start, $orderColumn, $orderType) { // if($orderColumn==0) // $this->db->order_by('id', $orderType); // else if($orderColumn==1) // $this->db->order_by('name', $orderType); // else if($orderColumn==2) // $this->db->order_by('status', $orderType); $this->db->limit($limit, $start); //$this->db->join("forms", "bill.patient_id = form_template_mapping.id"); $query = $this->db->get('form_template_mapping')->result(); $template_name=""; foreach($query as $q){ $temp_arr=explode(',', $q->template_id); foreach($temp_arr as $tid){ $template_data=$this->db->get_where('forms',array('id' =>$tid))->row(); if($template_data->form_name!=""){ $template_name.=$template_data->form_name.','; } } $q->template_name=$template_name; $template_name=""; } // echo $template_name; // die; return $query; } function get_mapping_data($id){ $mapping_data=$this->db->get_where('form_template_mapping',array('id' =>$id))->row(); return $mapping_data; } }