public function EditEmployee() { if ($_POST) { $empData = $this->input->post(null, true); $empID = $empData["hdEmpID"]; if (isset($empData['txtPassword']) && $empData['txtPassword'] != '') { $data = array(); //เรื่องของรหัสผ่านแก้ที่ Table T_Users $data['Password'] = $empData['txtPassword']; $where['User_EmpID'] = $empID; $this->users->edit($data, $where); } $where = array(); $where['EmpID'] = $empID; $data = array(); $data['EmpNameTitleThai'] = $empData['ddlNameTitleThai']; $data['EmpFirstnameThai'] = $empData['txtFirstnameThai']; $data['EmpLastnameThai'] = $empData['txtLastnameThai']; $data['EmpNameTitleEnglish'] = $empData['ddlNameTitleEnglish']; $data['EmpFirstnameEnglish'] = $empData['txtFirstnameEnglish']; $data['EmpLastnameEnglish'] = $empData['txtLastnameEnglish']; $data['Emp_PositionID'] = $empData['ddlPosition']; $data['Emp_DepartmentID'] = $empData['ddlDepartment']; $data["Emp_SectionID"] = $empData["ddlSection"]; $data["Emp_UnitID"] = $empData["ddlUnit"]; $data["Emp_GroupID"] = $empData["ddlGroup"]; $data["EmpBirthDay"] = intval($empData["ddlBirthDayYear"]) > 0 ? intval($empData["ddlBirthDayYear"]) - 543 : 0 . "-" . $empData["ddlBirthDayMonth"] . "-" . $empData["ddlBirthDayDay"]; $data['EmpBirthPlace'] = $empData['txtBirthPlace']; $data['EmpIDCard'] = $empData['txtIDCard']; $data['EmpAddressNumber'] = $empData['txtAddressNumber']; $data['EmpAddressMoo'] = $empData['txtAddressMoo']; $data['EmpAddressRoad'] = $empData['txtAddressRoad']; $data['Emp_DistrictID'] = $empData['ddlAddressDistrict']; $data['Emp_AmphurID'] = $empData['ddlAddressAmphur']; $data['Emp_ProvinceID'] = $empData['ddlAddressProvince']; $data['Emp_ZipcodeID'] = $empData['ddlAddressZipcode']; //dbDateFormatFromThai is function from common_helper $data['EmpStartWorkDate'] = dbDateFormatFromThaiUn543($empData['txtStartWorkDate']); $data['EmpSuccessTrialWorkDate'] = dbDateFormatFromThaiUn543($empData['txtSuccessTrialWorkDate']); $data['EmpSalary'] = $empData['txtSalary']; $data['EmpCallname'] = $empData['txtCallName']; $data['EmpTelephone'] = $empData['txtTelePhone']; $data['EmpMobilePhone'] = $empData['txtMobilePhone']; $data['EmpEmail'] = $empData['txtEmail']; $data['EmpSex'] = !isset($empData['rdoSex']) ? 0 : $empData['rdoSex']; $data['EmpHeight'] = $empData['txtHeight']; $data['EmpWeight'] = $empData['txtWeight']; $data['EmpBlood'] = $empData['txtBlood']; $data['EmpNationality'] = $empData['txtNationality']; $data['EmpRace'] = $empData['txtRace']; $data['EmpReligion'] = $empData['txtReligion']; $data['Emp_MARSID'] = !isset($empData['rdoMartialStatus']) ? 0 : $empData['rdoMartialStatus']; $data['EmpMilitaryStatus'] = !isset($empData['rdoMilitaryStatus']) ? 0 : $empData['rdoMilitaryStatus']; $data['EmpMilitaryReason'] = $empData['txtMilitaryReason']; $data["EmpNumberOfChildren"] = $empData["txtNumberOfChildren"]; $data["EmpNumberOfBrother"] = $empData["txtNumberOfBrother"]; $data['Emp_BankID'] = $empData['ddlBank']; $data['EmpBankBranch'] = $empData['txtBankAccountBranch']; $data['EmpBankNumber'] = $empData['txtBankAccountNumber']; $data['Emp_BankTypeID'] = $empData['ddlBankAccountType']; $data['EmpFriendNameTitleThai'] = $empData['ddlNameTitleFriend']; $data['EmpFriendFirstnameThai'] = $empData['txtFirstnameFriend']; $data['EmpFriendLastnameThai'] = $empData['txtLastnameFriend']; $data['EmpFriendAddressNumber'] = $empData['txtAddressNumberFriend']; $data['EmpFriendAddressMoo'] = $empData['txtAddressMooFriend']; $data['EmpFriendAddressRoad'] = $empData['txtAddressRoadFriend']; $data['EmpFriend_DistrictID'] = $empData['ddlAddressDistrictFriend']; $data['EmpFriend_AmphurID'] = $empData['ddlAddressAmphurFriend']; $data['EmpFriend_ProvinceID'] = $empData['ddlAddressProvinceFriend']; $data['EmpFriend_ZipcodeID'] = $empData['ddlAddressZipcodeFriend']; $data["EmpFriendTelephone"] = $empData["txtTelePhoneFriend"]; $data["EmpFriendMobilePhone"] = $empData["txtMobilePhoneFriend"]; $data['EmpFatherNameTitleThai'] = $empData['ddlNameTitleFather']; $data['EmpFatherFirstnameThai'] = $empData['txtFirstnameFather']; $data['EmpFatherLastnameThai'] = $empData['txtLastnameFather']; $data['EmpFatherAddressNumber'] = $empData['txtAddressNumberFather']; $data['EmpFatherAddressMoo'] = $empData['txtAddressMooFather']; $data['EmpFatherAddressRoad'] = $empData['txtAddressRoadFather']; $data['EmpFather_DistrictID'] = $empData['ddlAddressDistrictFather']; $data['EmpFather_AmphurID'] = $empData['ddlAddressAmphurFather']; $data['EmpFather_ProvinceID'] = $empData['ddlAddressProvinceFather']; $data['EmpFather_ZipcodeID'] = $empData['ddlAddressZipcodeFather']; $data["EmpFatherTelephone"] = $empData["txtTelePhoneFather"]; $data["EmpFatherMobilePhone"] = $empData["txtMobilePhoneFather"]; $data['EmpMotherNameTitleThai'] = $empData['ddlNameTitleMother']; $data['EmpMotherFirstnameThai'] = $empData['txtFirstnameMother']; $data['EmpMotherLastnameThai'] = $empData['txtLastnameMother']; $data['EmpMotherAddressNumber'] = $empData['txtAddressNumberMother']; $data['EmpMotherAddressMoo'] = $empData['txtAddressMooMother']; $data['EmpMotherAddressRoad'] = $empData['txtAddressRoadMother']; $data['EmpMother_DistrictID'] = $empData['ddlAddressDistrictMother']; $data['EmpMother_AmphurID'] = $empData['ddlAddressAmphurMother']; $data['EmpMother_ProvinceID'] = $empData['ddlAddressProvinceMother']; $data['EmpMother_ZipcodeID'] = $empData['ddlAddressZipcodeMother']; $data["EmpMotherTelephone"] = $empData["txtTelePhoneMother"]; $data["EmpMotherMobilePhone"] = $empData["txtMobilePhoneMother"]; $data['EmpHouseRegAddressNumber'] = $empData['txtAddressNumberHouseReg']; $data['EmpHouseRegAddressMoo'] = $empData['txtAddressMooHouseReg']; $data['EmpHouseRegAddressRoad'] = $empData['txtAddressRoadHouseReg']; $data['EmpHouseReg_DistrictID'] = $empData['ddlAddressDistrictHouseReg']; $data['EmpHouseReg_AmphurID'] = $empData['ddlAddressAmphurHouseReg']; $data['EmpHouseReg_ProvinceID'] = $empData['ddlAddressProvinceHouseReg']; $data['EmpHouseReg_ZipcodeID'] = $empData['ddlAddressZipcodeHouseReg']; $data['EmpLatestUpdate'] = date('Y-m-d H:i:s'); $this->employees->edit($data, $where); $userID = floatval($this->users->getUserIDByEmpID($empID)); //upload edit $contFile = array("fuEmpPicture", "fuIDCard", "fuAddress", "fuDocRegisterJob", "fuBank"); foreach ($contFile as $file) { $nowPath = $this->uploadImg($file, $this->config->item('upload_employee') . intval($userID)); if ($nowPath != "") { $this->employees->updateImage($empID, $file, $nowPath); } } //insert emp headman level 1 - 3 [ddlHeadman_level_1,ddlHeadman_level_2,ddlHeadman_level_3] //if edit delete old data $this->empheadman->delete_from_user_id($userID); for ($i = 1; $i <= 3; $i++) { $headman_user_id = intval($empData['ddlHeadman_level_' . $i]); if ($headman_user_id > 0) { $this->empheadman->insert(array('eh_user_id' => $userID, 'eh_headman_user_id' => $headman_user_id, 'eh_headman_level' => $i)); } } //insert emp history work if have $ehw_company = $empData['history_work_company']; $ehw_position = $empData['history_work_position']; $ehw_district = $empData['history_work_district']; $ehw_desc = $empData['history_work_desc']; $ehw_date_from_day = $empData['history_work_date_from_day']; $ehw_date_from_month = $empData['history_work_date_from_month']; $ehw_date_from_year = $empData['history_work_date_from_year']; //year thai $ehw_date_to_day = $empData['history_work_date_to_day']; $ehw_date_to_month = $empData['history_work_date_to_month']; $ehw_date_to_year = $empData['history_work_date_to_year']; $this->hiswork->delete_from_user_id($userID); for ($i = 0; $i < count($ehw_company); $i++) { if ($ehw_company[$i] != "") { $this->hiswork->insert(array('ehw_user_id' => $userID, 'ehw_company' => $ehw_company[$i], 'ehw_position' => $ehw_position[$i], 'ehw_district' => $ehw_district[$i], 'ehw_desc' => $ehw_desc[$i], 'ehw_date_from' => dbDateFormatFromThai($ehw_date_from_day[$i] . '/' . $ehw_date_from_month[$i] . '/' . $ehw_date_from_year[$i]), 'ehw_date_to' => dbDateFormatFromThai($ehw_date_to_day[$i] . '/' . $ehw_date_to_month[$i] . '/' . $ehw_date_to_year[$i]))); } } //insert emp history study if have $ehs_academy = $empData['history_study_academy']; $ehs_education_level = $empData['history_study_education_level']; $ehs_bachelor = $empData['history_study_bachelor']; $ehs_major = $empData['history_study_major']; $ehs_desc = $empData['history_study_desc']; $ehs_year_start = $empData['history_study_year_start']; $ehs_year_end = $empData['history_study_year_end']; $ehs_grade_avg = $empData['history_study_grade_avg']; $ehs_degree = $empData['history_study_degree']; $this->hisstudy->delete_from_user_id($userID); for ($i = 0; $i < count($ehs_academy); $i++) { if ($ehs_academy[$i] != "") { $this->hisstudy->insert(array('ehs_user_id' => $userID, 'ehs_education_level_id' => $ehs_education_level[$i], 'ehs_academy' => $ehs_academy[$i], 'ehs_bachelor' => $ehs_bachelor[$i], 'ehs_major' => $ehs_major[$i], 'ehs_desc' => $ehs_desc[$i], 'ehs_year_start' => year_english_from_thai($ehs_year_start[$i]), 'ehs_year_end' => year_english_from_thai($ehs_year_end[$i]), 'ehs_grade_avg' => $ehs_grade_avg[$i], 'ehs_degree' => $ehs_degree[$i])); } } //insert shift work $this->empshiftwork->deleteByUserId($userID); if (isset($empData["hdShiftworkId"]) && count($empData["hdShiftworkId"] > 0)) { for ($i = 0; $i < count($empData["hdShiftworkId"]); $i++) { $dataSw = array(); $dataSw["esw_userid"] = $userID; $dataSw["esw_swid"] = $empData["hdShiftworkId"][$i]; $this->empshiftwork->insert($dataSw); } } swalc("บันทึกเรียบร้อยแล้ว", "", "success", "window.location.href = '" . site_url("hr/Employees/Detail/" . $empID) . "'"); } }
public function saveEdit() { if ($_POST) { $post = $this->input->post(); $data = array(); $data["ACTTopic"] = $post["txtTopic"]; $data["ACTContent"] = $post["txtContent"]; $data["ACTStartDate"] = dbDateFormatFromThai($post["txtStartDate"]); $data["ACTEndDate"] = dbDateFormatFromThai($post["txtEndDate"]); $data["ACTShowDateFrom"] = dbDateFormatFromThai($post["txtShowDateFrom"]); $data["ACTShowDateTo"] = dbDateFormatFromThai($post["txtShowDateTo"]); $data["ACTLatestUpdate"] = getDateTimeNow(); $data["ACTLatestUpdateBy"] = $this->userID; $where = array(); $where["ACTID"] = $post["hdACTID"]; $affRow = $this->activity->update($data, $where); redirect(site_url("hr/Activity/")); } }
public function EditEmployee() { if ($_POST) { $empData = $this->input->post(null, true); $empID = $empData["hdEmpID"]; if ($empData['txtPassword'] != '') { $data = array(); //เรื่องของรหัสผ่านแก้ที่ Table T_Users $data['Password'] = $empData['txtPassword']; $where['User_EmpID'] = $empID; $this->users->edit($data, $where); } $where = array(); $where['EmpID'] = $empID; $data = array(); $data['EmpNameTitleThai'] = $empData['ddlNameTitleThai']; $data['EmpFirstnameThai'] = $empData['txtFirstnameThai']; $data['EmpLastnameThai'] = $empData['txtLastnameThai']; $data['EmpNameTitleEnglish'] = $empData['ddlNameTitleEnglish']; $data['EmpFirstnameEnglish'] = $empData['txtFirstnameEnglish']; $data['EmpLastnameEnglish'] = $empData['txtLastnameEnglish']; $data['Emp_InstitutionID'] = $empData['ddlInstitution']; $data['Emp_PositionID'] = $empData['ddlPosition']; $data['Emp_DepartmentID'] = $empData['ddlDepartment']; $data["EmpBirthDay"] = $empData["ddlBirthDayYear"] . "-" . $empData["ddlBirthDayMonth"] . "-" . $empData["ddlBirthDayDay"]; $data['EmpBirthPlace'] = $empData['txtBirthPlace']; $data['EmpIDCard'] = $empData['txtIDCard']; $data['EmpAddressNumber'] = $empData['txtAddressNumber']; $data['EmpAddressMoo'] = $empData['txtAddressMoo']; $data['EmpAddressRoad'] = $empData['txtAddressRoad']; $data['Emp_DistrictID'] = $empData['ddlAddressDistrict']; $data['Emp_AmphurID'] = $empData['ddlAddressAmphur']; $data['Emp_ProvinceID'] = $empData['ddlAddressProvince']; $data['Emp_ZipcodeID'] = $empData['ddlAddressZipcode']; //dbDateFormatFromThai is function from common_helper $data['EmpStartWorkDate'] = dbDateFormatFromThai($empData['txtStartWorkDate']); $data['EmpPromiseStartWorkDate'] = dbDateFormatFromThai($empData['txtPromiseStartWorkDate']); $data['EmpSuccessTrialWorkDate'] = dbDateFormatFromThai($empData['txtSuccessTrialWorkDate']); $data['EmpSalary'] = $empData['txtSalary']; $data['EmpCallname'] = $empData['txtCallName']; $data['EmpTelephone'] = $empData['txtTelePhone']; $data['EmpMobilePhone'] = $empData['txtMobilePhone']; $data['EmpEmail'] = $empData['txtEmail']; $data['EmpSex'] = !isset($empData['rdoSex']) ? 0 : $empData['rdoSex']; $data['EmpHeight'] = $empData['txtHeight']; $data['EmpWeight'] = $empData['txtWeight']; $data['EmpBlood'] = $empData['txtBlood']; $data['EmpNationality'] = $empData['txtNationality']; $data['EmpRace'] = $empData['txtRace']; $data['EmpReligion'] = $empData['txtReligion']; $data['Emp_MARSID'] = !isset($empData['rdoMaritalStatus']) ? 0 : $empData['rdoMaritalStatus']; $data['EmpMilitaryStatus'] = !isset($empData['rdoMilitaryStatus']) ? 0 : $empData['rdoMilitaryStatus']; $data['EmpMilitaryReason'] = $empData['txtMilitaryReason']; $data['Emp_BankID'] = $empData['ddlBank']; $data['EmpBankBranch'] = $empData['txtBankAccountBranch']; $data['EmpBankNumber'] = $empData['txtBankAccountNumber']; $data['Emp_BankTypeID'] = $empData['ddlBankAccountType']; $data['EmpFriendNameTitleThai'] = $empData['ddlNameTitleFriend']; $data['EmpFriendFirstnameThai'] = $empData['txtFirstnameFriend']; $data['EmpFriendLastnameThai'] = $empData['txtLastnameFriend']; $data['EmpFriendAddressNumber'] = $empData['txtAddressNumberFriend']; $data['EmpFriendAddressMoo'] = $empData['txtAddressMooFriend']; $data['EmpFriendAddressRoad'] = $empData['txtAddressRoadFriend']; $data['EmpFriend_DistrictID'] = $empData['ddlAddressDistrictFriend']; $data['EmpFriend_AmphurID'] = $empData['ddlAddressAmphurFriend']; $data['EmpFriend_ProvinceID'] = $empData['ddlAddressProvinceFriend']; $data['EmpFriend_ZipcodeID'] = $empData['ddlAddressZipcodeFriend']; $data['EmpLatestUpdate'] = date('Y-m-d H:i:s'); $this->employees->edit($data, $where); $userID = floatval($this->users->getUserIDByEmpID($empID)); $contFile = array("fuEmpPicture", "fuIDCard", "fuAddress", "fuDocRegisterJob", "fuBank"); foreach ($contFile as $file) { $nowPath = $this->uploadImg($file, $this->config->item('upload_employee') . $userID); if ($nowPath != "") { $this->employees->updateImage($empID, $file, $nowPath); } } //insert emp headman level 1 - 3 [ddlHeadman_level_1,ddlHeadman_level_2,ddlHeadman_level_3] //if edit delete old data $this->empheadman->delete_from_user_id($userID); for ($i = 1; $i <= 3; $i++) { $headman_user_id = intval($empData['ddlHeadman_level_' . $i]); if ($headman_user_id > 0) { $this->empheadman->insert(array('eh_user_id' => $userID, 'eh_headman_user_id' => $headman_user_id, 'eh_headman_level' => $i)); } } //insert emp history work if have $ehw_company = $empData['history_work_company']; $ehw_position = $empData['history_work_position']; $ehw_district = $empData['history_work_district']; $ehw_desc = $empData['history_work_desc']; $ehw_date_from_day = $empData['history_work_date_from_day']; $ehw_date_from_month = $empData['history_work_date_from_month']; $ehw_date_from_year = $empData['history_work_date_from_year']; //year thai $ehw_date_to_day = $empData['history_work_date_to_day']; $ehw_date_to_month = $empData['history_work_date_to_month']; $ehw_date_to_year = $empData['history_work_date_to_year']; log_message("error", "company count " . count($ehw_company)); $this->hisstudy->delete_from_user_id($userID); for ($i = 0; $i < count($ehw_company); $i++) { if ($ehw_company[$i] != "") { $this->hiswork->insert(array('ehw_user_id' => $userID, 'ehw_company' => $ehw_company[$i], 'ehw_position' => $ehw_position[$i], 'ehw_district' => $ehw_district[$i], 'ehw_desc' => $ehw_desc[$i], 'ehw_date_from' => dbDateFormatFromThai($ehw_date_from_day[$i] . '/' . $ehw_date_from_month[$i] . '/' . $ehw_date_from_year[$i]), 'ehw_date_to' => dbDateFormatFromThai($ehw_date_to_day[$i] . '/' . $ehw_date_to_month[$i] . '/' . $ehw_date_to_year[$i]))); } } //insert emp history study if have $ehs_academy = $empData['history_study_academy']; $ehs_major = $empData['history_study_major']; $ehs_desc = $empData['history_study_desc']; $ehs_date_from_day = $empData['history_study_date_from_day']; $ehs_date_from_month = $empData['history_study_date_from_month']; $ehs_date_from_year = $empData['history_study_date_from_year']; $ehs_date_to_day = $empData['history_study_date_to_day']; $ehs_date_to_month = $empData['history_study_date_to_month']; $ehs_date_to_year = $empData['history_study_date_to_year']; $this->hisstudy->delete_from_user_id($userID); for ($i = 0; $i < count($ehs_academy); $i++) { if ($ehs_academy[$i] != "") { $this->hisstudy->insert(array('ehs_user_id' => $userID, 'ehs_academy' => $ehs_academy[$i], 'ehs_major' => $ehs_major[$i], 'ehs_desc' => $ehs_desc[$i], 'ehs_date_from' => dbDateFormatFromThai($ehs_date_from_day[$i] . '/' . $ehs_date_from_month[$i] . '/' . $ehs_date_from_year[$i]), 'ehs_date_to' => dbDateFormatFromThai($ehs_date_to_day[$i] . '/' . $ehs_date_to_month[$i] . '/' . $ehs_date_to_year[$i]))); } } parent::setHeader(); $this->load->view('success', array('url' => site_url('hr/Employee'))); parent::setFooter(); } }
public function save() { print_r($_POST); if ($_POST) { $post = $this->input->post(NULL, TRUE); $ot_request_by = $post['input_team']; $ot_date = $post['input_ot_date']; $ot_time_from = $post['input_ot_time_from']; $ot_time_to = $post['input_ot_time_to']; $ot_remark = $post['input_ot_remark']; $data = array(); $data['wot_date'] = dbDateFormatFromThai($ot_date); $data['wot_time_from'] = $ot_time_from; $data['wot_time_to'] = $ot_time_to; $data['wot_request_hour'] = timeDiff($ot_time_from, $ot_time_to); $data['wot_request_by'] = $ot_request_by; $data['wot_request_date'] = getDateTimeNow(); $data['wot_workflow_id'] = 10; $data['wot_status_id'] = 1; $data['wot_headman_user_id_send_instead'] = $this->user_id; $new_id = $this->ot->insert($data); insert_log_ot($new_id, 'headman send instead', 'หัวหน้าส่งใบคำขอทำงานล่วงเวลาแทน'); //send email to hr $send = $this->_send_email_ot_to_hr($new_id); // if($send == 'success') // { // insert_log_ot($new_id,$log_type_send_mail_headman_success,'ส่งอีเมล์ใบคำขอทำงานล่วงเวลาหาหัวหน้าสำเร็จ'); // } // else // { // insert_log_ot($new_id,$log_type_send_mail_headman_error,'ส่งอีเมล์ใบคำขอทำงานล่วงเวลาหาหัวหน้า ผิดพลาด '.$send); // } //alert after all process if ($new_id > 0 && $send == 'success') { echo swalc("ส่งใบขอทำงานล่วงเวลาเรียบร้อยแล้ว", '', 'success', 'window.location.href = "' . site_url('headman/Sendotinsteadteam') . '"'); } else { if ($new_id > 0 && $send != 'success') { echo swalc("ส่งใบขอทำงานล่วงเวลาเรียบร้อยแล้ว แต่ไม่สามารถส่งอีเมล์หา HR ได้", '', 'warning', 'window.location.href = "' . site_url('headman/Sendotinsteadteam') . '"'); } else { echo swalc("ผิดพลาด!! ไม่สามารถบันทึกใบคำขอทำงานล่วงเวลาได้ กรุณาลองใหม่ภายหลัง", '', 'error', 'window.location.href = "' . site_url('headman/Sendotinsteadteam') . '"'); } } } else { redirect(site_url("headman/Sendotinsteadteam")); } }