80 lines
3.9 KiB
PHP
Executable File

<?php
if (!defined('BASEPATH'))
exit('No direct script access allowed');
class Addcaregiver extends MX_Controller {
function __construct() {
parent::__construct();
$this->load->model('caregivers/Caregiver_model');
$this->load->model('Addcaregiver_model');
}
public function register() {
// _die($_POST);
$id = $this->input->post('id');
//print_r($id);die;
$form_status = $this->input->post('form_status');
$form_mode = $this->input->post('form_mode');
$fname = $this->input->post('fname');
$lname = $this->input->post('lname');
$email = $this->input->post('email');
$phone = $this->input->post('phone');
$password = $this->input->post('password');
$qualification_type = $this->input->post('qualification_type');
$hire_type = "New Hire";
$data = array();
if(empty($id)){
if ($this->ion_auth->email_check($email)) {
$this->session->set_flashdata('feedback_error', 'This Email Address Is Already Registered');
redirect('caregivers/addNewCaregiver');
}else{
if($hire_type=='Re-Hire' && $date_of_re_hire==''){
$this->session->set_flashdata('feedback_error', 'Enter re-hire daate.');
redirect('caregivers/addNewCaregiver');
}else{
$username = $this->input->post('fname');
$dfg = 6;
$this->ion_auth->register($username, $password, $email,$dfg);
$ion_user_id = $this->db->get_where('users', array('email' => $email))->row()->id;
}
}
$application_date=date ('Y-m-d', now());
if(isset($_POST['fname'])){ $data['fname'] = $fname; }
if(isset($_POST['mid_name'])){ $data['mid_name'] = $_POST['mid_name']; }
if(isset($_POST['lname'])){ $data['lname'] = $lname; }
if(isset($_POST['email'])){ $data['email'] = $email;}
//if(isset($_POST['dependents'])){ $data['dependents'] = $dependents; }
if(isset($_POST['qualification_type'])){ $data['qualification_type'] = $_POST['qualification_type']; }
if(isset($_POST['hire_type'])){ $data['hire_type'] = $hire_type; }
if(isset($_POST['date_of_re_hire'])){ $data['date_of_re_hire'] = $date_of_re_hire; }
if(isset($_POST['phone'])){ $data['phone'] = $phone; }
$data['caregiver_id']=''.str_pad($ion_user_id, 6, "0", STR_PAD_LEFT);
$data['ion_user_id'] = $ion_user_id;
$data['application_date'] = $application_date;
$data['created_by'] = '';
$data['form_status'] = 1;
$data['status'] = 1;
$pctg = array();
$pctg['form1']=0;$pctg['form2']=0;$pctg['form3']=0;$pctg['form4']=0;$pctg['form5']=0;$pctg['form6']=0;$pctg['form7']=0;$pctg['form8']=0;$pctg['form9']=0;$pctg['form10']=0;$pctg['form11']=0;
$data['from_tab_status_pctg'] = json_encode($pctg);
// _die($data);
$cargiverId=$this->Caregiver_model->insertNurse($data);
$this->session->set_flashdata('caregiver_created', 'Caregiver created successfully.');
// send_email($from,$to,$subject,$message)
$from = 'noreply@admin.com';
$to = $email;
$subject = 'WECURO Caregiver Registration';
$message = 'Thank tou for registering with us';
send_email($from,$to,$subject,$message);
redirect('/');
}
}
}
/* End of file appointment.php */
/* Location: ./application/modules/appointment/controllers/appointment.php */