EVOLUTION-NINJA
Edit File: 153423439310-7-18 jayblues_erp.php
//controller public function add_new_employees() { $employee_id = $this->input->post('employee_id'); $first_name = $this->input->post('first_name'); $last_name = $this->input->post('last_name'); $email_id = $this->input->post('email_id'); $nick_name = $this->input->post('nick_name'); $department_id = $this->input->post('department_id'); $designation_id = $this->input->post('designation_id'); $reporting_to = $this->input->post('reporting_to'); $source_of_hire = $this->input->post('source_of_hire'); $location = $this->input->post('location'); $title = $this->input->post('title'); $date_of_joining = $this->input->post('date_of_joining'); $seating_location = $this->input->post('seating_location'); $work_phone = $this->input->post('work_phone'); $extension = $this->input->post('extension'); $employee_status = $this->input->post('employee_status'); $employee_type = $this->input->post('employee_type'); $role_id = $this->input->post('role_id'); $pan_no = $this->input->post('pan_no'); $date_of_birth = $this->input->post('date_of_birth'); $address = $this->input->post('address'); $residential_address = $this->input->post('residential_address'); $marital_status = $this->input->post('marital_status'); $job_description = $this->input->post('job_description'); $about_me = $this->input->post('about_me'); $date_of_exit = $this->input->post('date_of_exit'); $gender = $this->input->post('gender'); $pre_com_name = $this->input->post('pre_com_name'); $pre_com_name1 = json_encode($pre_com_name); $job_title = $this->input->post('job_title'); $job_title1 = json_encode($job_title); $from_date = $this->input->post('from_date'); $from_date1 = json_encode($from_date); $to_date = $this->input->post('to_date'); $to_date1 = json_encode($to_date); $work_job_description = $this->input->post('work_job_description'); $work_job_description1 = json_encode($work_job_description); $school_name = $this->input->post('school_name'); $diplamo_degree = $this->input->post('diplamo_degree'); $field_of_study = $this->input->post('field_of_study'); $date_of_completion = $this->input->post('date_of_completion'); $additional_notes = $this->input->post('additional_notes'); $interests = $this->input->post('interests'); $dependent_name = $this->input->post('dependent_name'); $dependent_name1 = json_encode($dependent_name); $dependent_relationship = $this->input->post('dependent_relationship'); $dependent_relationship1 = json_encode($dependent_relationship); $dependent_dob = $this->input->post('dependent_dob'); $dependent_dob1 = json_encode($dependent_dob); $aggregate = $this->input->post('aggregate'); $aggregate1 = json_encode($aggregate); $this->load->library('upload'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d'); $employee_details = array( 'employee_id' => $employee_id, 'first_name' => $first_name, 'last_name' => $last_name, 'email_id' => $email_id, 'nick_name' => $nick_name, 'department_id' => $department_id, 'designation_id' => $designation_id, 'reporting_to' => $reporting_to, 'source_of_hire' => $source_of_hire, 'location' => $location, 'title' => $title, 'date_of_joining' => $date_of_joining, 'seating_location' => $seating_location, 'work_phone' => $work_phone, 'extension' => $extension, 'employee_status' => $employee_status, 'employee_type' => $employee_type, 'role_id' => $role_id, 'pan_no' => $pan_no, 'date_of_birth' => $date_of_birth, 'address' => $address, 'residential_address' => $residential_address, 'marital_status' => $marital_status, 'job_description' => $job_description, 'about_me' => $about_me, 'date_of_exit' => $date_of_exit, 'gender' => $gender, 'pre_company_name' => $pre_com_name1, 'job_title' => $job_title1, 'from_date' => $from_date1, 'to_date' => $to_date1, 'work_job_description' => $work_job_description1, 'dependent_name' => $dependent_name1, 'dependent_relationship' => $dependent_relationship1, 'dependent_dob' => $dependent_dob1, 'delete_status' => 'ACTIVE', 'created_at' => $created_at ); $result = $this->yaskawa_model->add_employee($employee_details); foreach($school_name as $key=>$d) { $education_details = array('employee_id'=>$employee_id, 'college_name'=>$school_name[$key], 'diplamo_degree'=>$diplamo_degree[$key], 'field_of_study'=>$field_of_study[$key], 'date_of_completion'=>$date_of_completion[$key], 'additional_notes'=>$additional_notes[$key], 'interests'=>$interests[$key], 'aggregate'=>$aggregate[$key], 'delete_status' => 'ACTIVE', 'created_at' => $created_at ); $cpt = count($_FILES['file_upload'.$key]['name']); $file_doc=""; unset($document); for($i=0; $i<$cpt; $i++) { if($_FILES['file_upload'.$key]['name']) { $path=$_FILES['file_upload'.$key]['name'][$i]; $target='files/'; $target.=time().$_FILES['file_upload'.$key]['name'][$i]; $document[]=time().$_FILES['file_upload'.$key]['name'][$i]; move_uploaded_file($_FILES['file_upload'.$key]['tmp_name'][$i],$target); $file_doc=$document; } else { $file_doc=""; } } $education_details['file']=json_encode($file_doc); $result_edu = $this->yaskawa_model->add_employee_education($education_details); } if($result) { echo json_encode(array('result'=>1,'message'=>"Employee added successfully")); } else { echo json_encode(array('result'=>0,'message'=>"Something went wrong.. try again")); } } public function single_employee_view() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $emp_id = $this->uri->segment(2); $data['employee_details'] = $this->yaskawa_model->single_employee_details($emp_id); $data['education_details'] = $this->yaskawa_model->employee_education_details($emp_id); if(!empty($data['employee_details'])){ if(($data['employee_details']->job_title)!=' '){ $data['job_details'] = json_decode($data['employee_details']->job_title); }else{ $data['job_details'] = ""; } if(($data['employee_details']->work_job_description)!=' '){ $data['work_details'] = json_decode($data['employee_details']->work_job_description); }else{ $data['work_details'] = ""; } if(($data['employee_details']->dependent_name)!=' '){ $data['dependent_name'] = json_decode($data['employee_details']->dependent_name); }else{ $data['dependent_name'] = ""; } if(($data['employee_details']->dependent_relationship)!=' '){ $data['dependent_relationship'] = json_decode($data['employee_details']->dependent_relationship); }else{ $data['dependent_relationship'] = ""; } }else{ $data['dependent_relationship'] =""; $data['job_details'] = ""; $data['dependent_name'] = ""; $data['interests'] = ""; $data['additional_notes'] = ""; $data['field_of_study'] = ""; $data['diplamo_degree'] = ""; $data['school_name'] = ""; $data['work_details'] = ""; } $data['get_all_roles'] = $this->yaskawa_model->get_all_roles_admin(); $data['get_all_departments'] = $this->yaskawa_model->get_all_departments(); $data['designation_list'] = $this->yaskawa_model->get_all_designation(); $data['company_details']=$this->yaskawa_model->fetch_company_details(); $this->load->view('admin/employee_info',$data); } else { redirect('/'); } } public function update_employee() { $employee_id = $this->input->post('employee_id'); $first_name = $this->input->post('first_name'); $last_name = $this->input->post('last_name'); $email_id = $this->input->post('email_id'); $nick_name = $this->input->post('nick_name'); $department_id = $this->input->post('department_id'); $designation_id = $this->input->post('designation_id'); $reporting_to = $this->input->post('reporting_to'); $source_of_hire = $this->input->post('source_of_hire'); $location = $this->input->post('location'); $title = $this->input->post('title'); $date_of_joining = $this->input->post('date_of_joining'); $seating_location = $this->input->post('seating_location'); $work_phone = $this->input->post('work_phone'); $extension = $this->input->post('extension'); $employee_status = $this->input->post('employee_status'); $employee_type = $this->input->post('employee_type'); $role_id = $this->input->post('role_id'); $pan_no = $this->input->post('pan_no'); $date_of_birth = $this->input->post('date_of_birth'); $address = $this->input->post('address'); $residential_address = $this->input->post('residential_address'); $marital_status = $this->input->post('marital_status'); $job_description = $this->input->post('job_description'); $about_me = $this->input->post('about_me'); $date_of_exit = $this->input->post('date_of_exit'); $gender = $this->input->post('gender'); $pre_com_name = $this->input->post('pre_com_name'); $pre_com_name1 = json_encode($pre_com_name); $job_title = $this->input->post('job_title'); $job_title1 = json_encode($job_title); $from_date = $this->input->post('from_date'); $from_date1 = json_encode($from_date); $to_date = $this->input->post('to_date'); $to_date1 = json_encode($to_date); $work_job_description = $this->input->post('work_job_description'); $work_job_description1 = json_encode($work_job_description); $school_name = $this->input->post('school_name'); $diplamo_degree = $this->input->post('diplamo_degree'); $field_of_study = $this->input->post('field_of_study'); $date_of_completion = $this->input->post('date_of_completion'); $additional_notes = $this->input->post('additional_notes'); $interests = $this->input->post('interests'); $dependent_name = $this->input->post('dependent_name'); $dependent_name1 = json_encode($dependent_name); $dependent_relationship = $this->input->post('dependent_relationship'); $dependent_relationship1 = json_encode($dependent_relationship); $dependent_dob = $this->input->post('dependent_dob'); $dependent_dob1 = json_encode($dependent_dob); $aggregate = $this->input->post('aggregate'); $aggregate1 = json_encode($aggregate); $this->load->library('upload'); //$myFile = $_FILES['file_upload']; // $file=$this->input->post('file_upload'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d'); $data = array( 'employee_id' => $employee_id, 'first_name' => $first_name, 'last_name' => $last_name, 'email_id' => $email_id, 'nick_name' => $nick_name, 'department_id' => $department_id, 'designation_id' => $designation_id, 'reporting_to' => $reporting_to, 'source_of_hire' => $source_of_hire, 'location' => $location, 'title' => $title, 'date_of_joining' => $date_of_joining, 'seating_location' => $seating_location, 'work_phone' => $work_phone, 'extension' => $extension, 'employee_status' => $employee_status, 'employee_type' => $employee_type, 'role_id' => $role_id, 'pan_no' => $pan_no, 'date_of_birth' => $date_of_birth, 'address' => $address, 'residential_address' => $residential_address, 'marital_status' => $marital_status, 'job_description' => $job_description, 'about_me' => $about_me, 'date_of_exit' => $date_of_exit, 'gender' => $gender, 'pre_company_name' => $pre_com_name1, 'job_title' => $job_title1, 'from_date' => $from_date1, 'to_date' => $to_date1, 'work_job_description' => $work_job_description1, 'dependent_name' => $dependent_name1, 'dependent_relationship' => $dependent_relationship1, 'dependent_dob' => $dependent_dob1, 'delete_status' => 'ACTIVE', 'created_at' => $created_at ); $where=array('employee_id'=>$employee_id,'delete_status'=>'ACTIVE'); $table_employee='employees'; $result = $this->yaskawa_model->update_employee_details($table_employee,$where,$data); $where_edu=array('employee_id'=>$employee_id,'delete_status'=>'ACTIVE'); $table_education='employee_education'; $get_data = $this->yaskawa_model->get_data($table_education,$where_edu); $edu_id=array(); foreach($get_data as $val) { array_push($edu_id,$val->id); } $count_id=count($edu_id); foreach($school_name as $key=>$d) { //print_r($file_doc.$key.[$key]); $education_details = array('employee_id'=>$employee_id, 'college_name'=>$school_name[$key], 'diplamo_degree'=>$diplamo_degree[$key], 'field_of_study'=>$field_of_study[$key], 'date_of_completion'=>$date_of_completion[$key], 'additional_notes'=>$additional_notes[$key], 'interests'=>$interests[$key], 'aggregate'=>$aggregate[$key], 'delete_status' => 'ACTIVE', 'created_at' => $created_at ); $cpt = count($_FILES['file_upload'.$key]['name']); $file_doc=""; $myFile = $_FILES['file_upload'.$key]; unset($document); for($i=0; $i<$cpt; $i++) { $file_name='file_upload'.$key; if($_FILES['file_upload'.$key]['name']) { $path=$_FILES['file_upload'.$key]['name'][$i]; $target='files/'; $target.=time().$_FILES['file_upload'.$key]['name'][$i]; $document[]=time().$_FILES['file_upload'.$key]['name'][$i]; move_uploaded_file($_FILES['file_upload'.$key]['tmp_name'][$i],$target); $file_doc=json_encode($document); } else { $file_doc=""; } } if($myFile['name'][0]!="") { $education_details['file']=$file_doc; } $table_education='employee_education'; if($count_id>1||$count_id>=1) { $where=array('id'=>$edu_id[$key],'delete_status'=>'ACTIVE'); $count_id=$count_id-1; $result = $this->yaskawa_model->update_employee_details($table_education,$where,$education_details); } else { $result = $this->yaskawa_model->add_employee_education($education_details); } } if($result) { echo json_encode(array('result'=>1,'message'=>"Employee added successfully")); } else { echo json_encode(array('result'=>0,'message'=>"Something went wrong.. try again")); } } //model public function add_employee_education($education_details) { return $this->db->insert('employee_education',$education_details); //return $this->db->insert(); } public function single_employee_details($emp_id) { $this->db->select('*,a.email_id as eid'); $this->db->from('employees a'); $this->db->join('department b','b.department_id = a.department_id'); $this->db->join('designation c','c.designation_id = a.designation_id'); $this->db->where('a.employee_id',$emp_id); $this->db->where('a.delete_status','ACTIVE'); $query=$this->db->get(); return $query->row(); } public function employee_education_details($emp_id) { $this->db->select('*'); $this->db->from('employee_education a'); $this->db->where('a.employee_id',$emp_id); $this->db->where('a.delete_status','ACTIVE'); $query=$this->db->get(); return $query->result(); } public function update_employee_details($table,$where,$data) { $this->db->where($where); $result=$this->db->update($table,$data); return $result; } public function get_data($table,$where) { $this->db->select('*'); $this->db->from($table); $this->db->where($where); $query=$this->db->get(); return $query->result(); } public function get_data_row($table,$where) { $this->db->select('*'); $this->db->from($table); $this->db->where($where); $query=$this->db->get(); return $query->row(); } public function edit_emp_details($emp_id) { $this->db->select('*'); $this->db->from('employees'); $this->db->where('employees.employee_id',$emp_id); $this->db->where('employees.delete_status','ACTIVE'); $query=$this->db->get(); return $query->row(); }