//my controller...
function edit($id) {
// $this->form_validation->set_rules('phone', 'Phone', 'callback_Check_Phone');
$this->form_validation->set_rules('email', 'Email', 'callback_Check_email');
$this->form_validation->set_rules('uname', 'Uname', 'callback_Check_User');
if ($this->form_validation->run() == TRUE) {
$hospitalid = $this->input->post("hospitalid");
$hospitalname = $this->input->post("hospitalname");
$doctorname = $this->input->post('docname');
$babyname = $this->input->post('babyname');
$sex = $this->input->post("sex");
$weight = $this->input->post('weight');
$parentname = $this->input->post('parentname');
$address = $this->input->post("address");
$email = $this->input->post('email');
$phone = $this->input->post('phone');
$username = $this->input->post("uname");
$dob = $this->input->post('dob');
$today_date = date("d-m-Y");
$dateTimestamp1 = strtotime($today_date);
$dateTimestamp2 = strtotime($dob);
$this->session->set_userdata('pid', $id);
$id = $this->session->userdata('pid');
$pass = $this->input->post('password');
if ($dateTimestamp1 < $dateTimestamp2) {
$sess_id = $this->session->userdata('id');
$this->session->set_flashdata('msg', 'Invalid Date of Birth');
$result['query'] = $this->panel_model->hospitaldetails($sess_id);
$result['query1'] = $this->register_model->edit_patient($id);
$this->load->view('innerheader', $result);
$this->load->view('edit_patient', $result);
} else {
$sess_id = $this->session->userdata('id');
$querys = $this->db->query("SELECT days FROM vaccine_details WHERE hospitalid='$sess_id'");
if ($querys->result()) {
if (strcmp($pass , $phone)== 0) {
$items = array();
$j = 0;
foreach ($querys->result() as $row1) {
$items[$j++] = $row1->days;
}
$Date = $dob;
$stamp = strtotime($Date);
$d = array();
$i = 0;
foreach ($items as $day) {
$newstamp = $stamp + ($day * 24 * 60 * 60);
$d[$i++] = date("m/d/Y", $newstamp);
echo "<br>";
}
$day = implode(',', $d);
$this->register_model->edit_patientdetails($id, $hospitalid, $hospitalname, $doctorname, $babyname, $sex, $weight, $parentname, $dob, $address, $email, $phone, $username, $day, $pass);
$this->session->set_flashdata('msg', 'succesfully updated');
redirect('patient_register/patient_detail');
} else {
$items = array();
$j = 0;
foreach ($querys->result() as $row1) {
$items[$j++] = $row1->days;
}
$Date = $dob;
$stamp = strtotime($Date);
$d = array();
$i = 0;
foreach ($items as $day) {
$newstamp = $stamp + ($day * 24 * 60 * 60);
$d[$i++] = date("m/d/Y", $newstamp);
echo "<br>";
}
$day = implode(',', $d);
$this->register_model->edit_patientdetail($id, $hospitalid, $hospitalname, $doctorname, $babyname, $sex, $weight, $parentname, $dob, $address, $email, $phone, $username, $day);
echo $this->sendregistermsg($phone, $username);
echo $this->mail($email, $phone, $username);
$this->session->set_flashdata('msg', 'succesfully updated');
redirect('patient_register/patient_detail');
}
} else {
$querys = $this->db->query("SELECT days FROM vaccine_details WHERE hospitalid='admin'");
if (strcmp($pass , $phone)== 0) {
$items = array();
$j = 0;
foreach ($querys->result() as $row1) {
$items[$j++] = $row1->days;
}
$Date = $dob;
$stamp = strtotime($Date);
$d = array();
$i = 0;
foreach ($items as $day) {
$newstamp = $stamp + ($day * 24 * 60 * 60);
$d[$i++] = date("m/d/Y", $newstamp);
echo "<br>";
}
$day = implode(',', $d);
$this->register_model->edit_patientdetails($id, $hospitalid, $hospitalname, $doctorname, $babyname, $sex, $weight, $parentname, $dob, $address, $email, $phone, $username, $day, $pass);
echo $this->sendregistermsg($phone, $username);
echo $this->mail($email, $phone, $username);
$this->session->set_flashdata('msg', 'succesfully updated');
redirect('patient_register/patient_detail');
} else {
$items = array();
$j = 0;
foreach ($querys->result() as $row1) {
$items[$j++] = $row1->days;
}
$Date = $dob;
$stamp = strtotime($Date);
$d = array();
$i = 0;
foreach ($items as $day) {
$newstamp = $stamp + ($day * 24 * 60 * 60);
$d[$i++] = date("m/d/Y", $newstamp);
echo "<br>";
}
$day = implode(',', $d);
$this->register_model->edit_patientdetail($id, $hospitalid, $hospitalname, $doctorname, $babyname, $sex, $weight, $parentname, $dob, $address, $email, $phone, $username, $day);
$this->session->set_flashdata('msg', 'succesfully updated');
redirect('patient_register/patient_detail');
}
}
}
} else {
$this->session->set_userdata('pid', $id);
$id = $this->session->userdata('pid');
$this->session->set_flashdata('msg', 'Invalid Entry');
$sess_id = $this->session->userdata('id');
$result['query'] = $this->panel_model->hospitaldetails($sess_id);
$result['query1'] = $this->register_model->edit_patient($id);
$this->load->view('innerheader', $result);
$this->load->view('edit_patient', $result);
$this->load->view('footer', $result);
}
}
感謝您發佈此 – 2014-02-25 09:09:09