Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Rameshwar-ghodke/c6185b534103c903ec54492c919fb4d0 to your computer and use it in GitHub Desktop.
Save Rameshwar-ghodke/c6185b534103c903ec54492c919fb4d0 to your computer and use it in GitHub Desktop.
following code paste in Master.php controller
public function reception()
{
try {
$table1='tbl_master_reception';
$where1=array('is_deleted'=>'N');
$data['reception_data_to_display'] = $this->Master_model->select_table_data($table1,$where1);
if(empty($data['reception_data_to_display']))
{
throw new Exception('No data Found');
}
else
{
$this->load->view('Add_reception',$data);
}
} catch (Exception $e) {
$this->load->view('Add_reception');
$this->session->set_flashdata('success_msg', $e->getMessage());
}
}
public function save_reception_details()
{
$response=$this->Master_model->save_reception_details_data();
if($response>0)
{
$this->session->set_flashdata('Success', 'Reception Added Successfully...');
redirect('Masters/reception', 'refresh');
}
else
{
$this->session->set_flashdata('Fail', 'Unable to add Reception');
redirect('Masters/reception', 'refresh');
}
}
public function edit_reception($reception_id)
{
$result['edit_reception_data_to_display']=$this->Master_model->reception_edit($reception_id);
//print_r($result);
$this->load->view('Add_reception',$result);
}
public function delete_reception($reception_id)
{
$result ['edit_reception_data_to_display']=$this->Master_model->reception_delete($reception_id);
if($result==1)
{
$this->session->set_flashdata('success_msg', 'Record Deleted Successfully');
}
if($result==0)
{
$this->session->set_flashdata('success_msg', 'Record Not Deleted Successfully');
}
redirect('Masters/reception','refresh');
}
/************** reception master end ***************/
// Paste following code in Master_model.php
public function save_reception_details_data()
{
date_default_timezone_set('Asia/Kolkata');
$created_time = date('Y-m-dH:i:s');
$hidden_path_photo=$this->input->post('hiddenpath1');
$response=$this->doctor_image_upload();
$extension=end(explode(".",$response[0]));
//$imgurl1=base_url()."upload_image/".$response[0];
if($response[0]!='')
{
$imgurl1=base_url()."upload_image/".$created_time .".".$extension;
//echo $imgurl1;
}
else
{
$imgurl1=$hidden_path_photo;
}
if($this->input->post('check')=='')
{
$insertdata = array(
'first_name' => $this->input->post('first_name'),
'last_name' => $this->input->post('last_name'),
'dob' => date("Y-m-d",strtotime($this->input->post('dob'))),
'age' => $this->input->post('age'),
'photo' => $imgurl1,
'mobile_number' => $this->input->post('mobile_number'),
'email_address' => $this->input->post('email_address'),
'is_active' => $_POST['is_active'],
'created_time' => date("Y-m-d H:i:s"),
'created_by' =>$this->session->userdata('employee_id'),
'source' =>'web',
'application_id' =>$this->session->userdata('application_id')
);
//print_r($insertdata);
$this->db->insert('tbl_master_reception', $insertdata);
//echo $this->db->last_query();
return $last_id=$this->db->insert_id();
}
else
{
$updatedata = array(
'first_name' => $this->input->post('first_name'),
'last_name' => $this->input->post('last_name'),
'dob' => date("Y-m-d",strtotime($this->input->post('dob'))),
'age' => $this->input->post('age'),
'photo' => $imgurl1,
'mobile_number' => $this->input->post('mobile_number'),
'email_address' => $this->input->post('email_address'),
'is_active' => $_POST['is_active'],
'updated_time' => date("Y-m-d H:i:s"),
'updated_by' =>$this->session->userdata('employee_id'),
'source' =>'web',
'application_id' =>$this->session->userdata('application_id')
);
//print_r($updatedata);
$this->db->where('id',$this->input->post('check'));
$this->db->update('tbl_master_reception', $updatedata);
//echo $this->db->last_query();
return $this->db->affected_rows();
}
}
public function reception_edit($reception_id)
{
$query = $this->db->query("SELECT * from tbl_master_reception where id ='".$reception_id."' and is_deleted='N'");
//echo $this->db->last_query();
return $query->result();
}
public function reception_delete($reception_id)
{
$deletedata = array('is_deleted' =>'Y');
$this->db->where('id',$reception_id);
$this->db->update('tbl_master_reception', $deletedata);
//echo $this->db->last_query();
if($this->db->affected_rows() != 1)
{
return '0';
}
else{
return '1';
}
}
/****** reception model *******/
// for view add_reception see next gist
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment