Exemple #1
0
 public function save_edit()
 {
     if ($_POST) {
         $post = $this->input->post();
         $department_id = $post['hd_department_id'];
         $institution_id = $post['input_institution_id'];
         $department_name = $post['input_department_name'];
         $department_desc = $post['input_department_desc'];
         $where = array('DID' => $department_id);
         $data = array('D_INSID' => $institution_id, 'DName' => $department_name, 'DDesc' => $department_desc);
         $this->department->update($data, $where);
         log_admin('insert', $department_id, 'department', 'edit department [name] ' . $department_name, $this->user_id);
         echo swalc('บันทึกเรียบร้อยแล้ว', '', 'success', 'window.location.href = "' . site_url('admin/Department/') . '"');
     }
 }
Exemple #2
0
 private function _save($type_save = "")
 {
     $post = $this->input->post(null, true);
     if ($type_save === "userinfo") {
         $new_password = $post['input_new_password'];
         $data = array('Password' => $new_password);
         $where = array('UserID' => $this->user_id);
         $this->user->edit($data, $where);
         echo swalc('บันทึกข้อมูลเรียบร้อยแล้ว', '', 'success', 'window.location.href = "' . site_url('Userprofile/userinfo') . '"');
     } elseif ($type_save === "profileinfo") {
         # ให้ HR เป็นคนแก้
     } elseif ($type_save === "addressinfo") {
     } elseif ($type_save === "othercontactinfo") {
     }
     return false;
 }
Exemple #3
0
 public function signin()
 {
     if ($_POST) {
         $this->redirect_url = $this->input->post("hd_redirect_url");
         if ($this->_check_login()) {
             if (!empty($this->redirect_url)) {
                 redirect(site_url($this->redirect_url));
                 exit;
             } else {
                 redirect("home");
                 exit;
             }
         } else {
             echo swalc($this->lang->line("error"), $this->lang->line("alert_cant_login"), "error");
         }
     }
     //set data
     $data = array();
     $data["title"] = $this->lang->line("title_login_page");
     $data["redirect_url"] = $this->redirect_url;
     //load view
     $this->load->view("login", $data);
 }
Exemple #4
0
 public function detail()
 {
     //form validation
     $rules = array(array("field" => "inputName", "label" => "ชื่อบริษัท", "rules" => "trim|required"));
     $this->form_validation->set_rules($rules);
     if ($this->form_validation->run() === true) {
         $this->_edit();
         echo swalc("บันทึกเรียบร้อยแล้ว", "", "success", "window.location.href = '" . site_url($this->redirectUrl) . "'");
         //redirect($this->redirectUrl);
         exit;
     } else {
         $query = $this->company->getDetail();
         $query = $query->row_array();
         $data = array();
         $data["query"] = $query;
         $data["queryProvince"] = $this->province->getListForDropDown();
         $data["queryAmphur"] = $this->amphur->getListForDropDown($query["C_ProvinceID"]);
         $data["queryDistrict"] = $this->district->getListForDropDown($query["C_ProvinceID"], $query["C_AmphurID"]);
         $data["queryZipcode"] = $this->zipcode->getListForDropDown($query["C_ProvinceID"], $query["C_AmphurID"], $query["C_DistrictID"]);
         parent::setHeaderAdmin("ข้อมูลบริษัท");
         $this->load->view("admin/company/company_add", $data);
         parent::setFooterAdmin();
     }
 }
Exemple #5
0
 public function save_edit_ot_condition()
 {
     if ($_POST) {
         $post = $this->input->post();
         $ot_condition_id = $post['hd_ot_condition_id'];
         //for update and get old data for log
         $ot_hour = $post['input_ot_hour'];
         $money = $post['input_money'];
         $leave = $post['input_leave'];
         //old data for insert log
         $old_data = $this->otconditions->get_detail_by_id($ot_condition_id);
         $old_data = $old_data->row_array();
         //old data detail
         $old_ot_hour = $old_data['wotcond_ot_hour'];
         $old_money = $old_data['wotcond_money'];
         $old_leave = $old_data['wotcond_leave'];
         $data = array();
         $data['wotcond_ot_hour'] = $ot_hour;
         $data['wotcond_money'] = $money;
         $data['wotcond_leave'] = $leave;
         $data['wotcond_update_by'] = $this->user_id;
         $data['wotcond_update_date'] = getDateTimeNow();
         $where = array('wotcond_id' => $ot_condition_id);
         $new_id = $this->otconditions->update($data, $where);
         //insert log ot about update
         insert_log_ot_conditions($ot_condition_id, 'update ot condition', 'HR แก้ไขเงื่อนไขการแลกค่าทำงาน OT จาก OT ' . $old_ot_hour . ' ชั่วโมง แลกเป็นเงินได้ ' . $old_money . ' บาท หรือ แลกเป็นวันหยุดได้ ' . $old_leave . ' วัน ' . 'เป็น OT ' . $ot_hour . ' ชั่วโมง แลกเป็นเงินได้ ' . $money . ' บาท หรือ แลกเป็นวันหยุดได้ ' . $leave . ' วัน', $this->user_id);
         echo swalc('บันทึกเรียบร้อยแล้ว', '', 'success', 'window.location.href = "' . site_url('admin/Worktime') . '"');
     }
 }
Exemple #6
0
 public function save_user_permissions()
 {
     if ($_POST) {
         $this->load->model('User_permissions_model', 'userpermissions');
         $post = $this->input->post();
         $user_id = $post['hd_user_id'];
         foreach ($post as $k => $perm_value) {
             if (substr($k, 0, 5) == "perm_") {
                 $perm_id = str_replace("perm_", "", $k);
                 if ($perm_value == 'x') {
                     $this->userpermissions->delete_from_permission($perm_id, $user_id);
                 } else {
                     $this->userpermissions->replace_into_permission($perm_id, $perm_value, $user_id);
                 }
             }
         }
         echo swalc('บันทึกเรียบร้อย', '', 'success', 'window.location.href = "' . site_url('hr/Employees/userroles/' . $user_id) . '"');
     }
 }
Exemple #7
0
 public function save_exchange_ot()
 {
     if ($_POST) {
         $this->load->model('Worktime_ot_model', 'ot');
         $this->load->model('Worktime_ot_exchange_model', 'otexchange');
         $this->load->model('Worktime_ot_exchange_detail_model', 'otexchangedetail');
         $post = $this->input->post();
         $input_ot = $post['input_ot'];
         //array
         $exchange_type = $post['input_exchange_type'];
         //money or leave
         $exchange_type_thai = '';
         $exchange_value = 0;
         $exchange_value_type = '';
         $exchange_date = '';
         $money = 0;
         $leave = 0;
         $cond_id = '';
         $new_otx_id = 0;
         //sum ot hour
         $sum_ot_hour = 0;
         foreach ($input_ot as $id) {
             $query = $this->ot->get_detail_by_id($id);
             if ($query->num_rows() > 0) {
                 $query = $query->row_array();
                 $sum_ot_hour = $sum_ot_hour + intval($query['wot_request_hour']);
                 $exchange_date .= dateThaiFormatFromDB($query['wot_date']) . ' , ';
             }
         }
         $exchange_date = substr($exchange_date, 0, -1);
         //remove last character
         //use sum ot hour for can use?
         $spliter = $this->calculate_exchange_ot_condition($sum_ot_hour, false);
         $spliter = explode('//--//', $spliter);
         if ($exchange_type === 'money') {
             $money = $spliter[0];
             $exchange_type_thai = 'เงิน';
             $exchange_value = $money;
             $exchange_value_type = 'บาท';
         } else {
             if ($exchange_type === 'leave') {
                 $leave = $spliter[1];
                 $exchange_type_thai = 'วันหยุด';
                 $exchange_value = $leave;
                 $exchange_value_type = 'วัน';
             }
         }
         $cond_id = substr($spliter[2], 0, -1);
         //in last character have comma(,) remove it.
         $cond_id = explode(',', $cond_id);
         //split to array
         //insert to t_worktime_ot_exchange
         $data = array();
         $data['otx_hour'] = $sum_ot_hour;
         $data['otx_type'] = $exchange_type;
         $data['otx_money'] = $money;
         $data['otx_leave'] = $leave;
         $data['otx_by'] = $this->user_id;
         $data['otx_date'] = getDateTimeNow();
         $new_otx_id = $this->otexchange->insert($data);
         //update id to t_worktime_ot
         foreach ($input_ot as $id) {
             $data = array();
             $data['wot_otx_id'] = $new_otx_id;
             $where = array('wot_id' => $id);
             $this->ot->update($data, $where);
         }
         //insert detail to t_worktime_ot_exchange_detail
         foreach ($cond_id as $id) {
             $query = $this->otconditions->get_detail_by_id($id);
             if ($query->num_rows() > 0) {
                 $query = $query->row_array();
                 $cond_hour = $query['wotcond_ot_hour'];
                 $cond_money = $query['wotcond_money'];
                 $cond_leave = $query['wotcond_leave'];
                 $data = array();
                 $data['otxd_otx_id'] = $new_otx_id;
                 $data['otxd_cond_id'] = $id;
                 $data['otxd_money'] = $cond_money;
                 $data['otxd_leave'] = $cond_leave;
                 $this->otexchangedetail->insert($data);
             }
         }
         //insert log about ot exchange process
         $log_type = 'user exchange ot for ' . $exchange_type;
         $log_detail = $this->emp_id . ' ทำการขอแลกจำนวนชั่วโมงทำ OT จำนวน ' . $sum_ot_hour . ' ชั่วโมง เป็น ' . $exchange_type_thai . ' จำนวน ' . $exchange_value . ' ' . $exchange_value_type . ' โดยใช้วันทำ OT วันที่ ' . $exchange_date;
         insert_log_ot_exchange($new_otx_id, $log_type, $log_detail, $this->user_id);
         echo swalc('บันทึกเรียบร้อยแล้ว', '', 'success', 'window.location.href = "' . site_url('Overtime') . '"');
     }
 }
Exemple #8
0
 /**
  * [instant_hr_approve_disapprove_from_email description] รวมจาก approve_from_email , disapprove_from_email
  * @param  string $type [approve/disapprove]
  * @param  int $hr_userid encrypt hr user id
  * @param  int $headman_userid encrypt headman user id
  * @param  int $leave_id encrypt leave id
  */
 public function instant_hr_approve_disapprove_from_email($type, $hr_userid, $headman_userid, $leave_id)
 {
     $hr_userid = floatval(encrypt_decrypt('decrypt', $hr_userid));
     $headman_userid = floatval(encrypt_decrypt('decrypt', $headman_userid));
     $leave_id = encrypt_decrypt('decrypt', $leave_id);
     $workflow_id = 0;
     $log_type = '';
     $log_detail = '';
     $alert_success = '';
     if ($type == 'approve') {
         $log_type = 'hr_approve_from_email';
         $log_detail = 'อนุมัติใบลาโดย HR ผ่านอีเมล์';
         $workflow_id = 4;
         $alert_success = 'อนุมัติใบลาเรียบร้อยแล้ว';
     } else {
         if ($type == 'disapprove') {
             $log_type = 'hr_disapprove_from_email';
             $log_detail = 'ไม่อนุมัติใบลาโดย HR ผ่านอีเมล์';
             $workflow_id = 5;
             $alert_success = 'ไม่อนุมัติใบลาเรียบร้อยแล้ว';
         }
     }
     if ($headman_userid > 0) {
         $query = $this->leave->getDetailForVerify($leave_id, $headman_id);
         if ($query->num_rows() > 0) {
             $query = $query->result_array();
             $query = $query[0];
             if ($query["L_WFID"] > 3) {
                 echo swalc("ไม่สามารถทำคำสั่งได้", "เนื่องจากมีการอนุมัติ/ไม่อนุมัติไปแล้ว", "error");
             } else {
                 $where = array();
                 $where["LID"] = $leave_id;
                 $data = array();
                 $data["L_WFID"] = $workflow_id;
                 $this->leave->update($data, $where);
                 log_leave($log_type, $leave_id, $log_detail, $hr_userid);
                 echo swalc("สำเร็จ", $alert_success, "success");
             }
         }
     } else {
         echo swalc("ผิดพลาด", "ไม่สามารถทำรายการใบลาได้", "error");
     }
 }
Exemple #9
0
 public function save_edit()
 {
     if ($_POST) {
         $post = $this->input->post();
         $position_id = $post['hd_position_id'];
         $department_id = $post['select_department_id'];
         $position_name = $post['input_position_name'];
         $position_desc = $post['input_position_desc'];
         $headman_position_id = $post['select_headman_position_id'];
         $query = $this->position->get_detail_by_id($position_id);
         if ($query->num_rows() > 0) {
             $query = $query->row_array();
             $old_position_name = $query['PName'];
             $where = array('PID' => $position_id);
             $data = array();
             $data['P_DID'] = $department_id;
             $data['PName'] = $position_name;
             $data['PDesc'] = $position_desc;
             $data['Headman_PID'] = $headman_position_id;
             $data['PLatestUpdate'] = getDateTimeNow();
             $this->position->update($data, $where);
             log_admin('insert', $position_id, 'position', 'edit position name ' . $old_position_name, $this->user_id);
             echo swalc('บันทึกเรียบร้อย', '', 'success', 'window.location.href = "' . site_url('admin/Position') . '"');
         } else {
             redirect(site_url('admin/Position'));
         }
     }
 }
Exemple #10
0
 private function _instant_approve_disapprove_ot_by_headman($type, $headman_user_id, $ot_id, $remark = "")
 {
     $headman_level = 0;
     $checker = FALSE;
     list($checker, $headman_level) = is_your_ot_headman($headman_user_id, $ot_id);
     if ($checker === TRUE) {
         //check headman user id is sure for headman owner request ot
         //get ot request detail for get owner user id
         $query = $this->ot->get_detail_by_id($ot_id);
         if ($query->num_rows() > 0) {
             $query = $query->row_array();
             $user_id = $query["wot_request_by"];
             $workflow_id = $query["wot_workflow_id"];
             $query2 = $this->empheadman->get_list_by_user_id($user_id)->result_array();
             if (count($query2) > 0) {
                 foreach ($query2 as $qu) {
                     if (intval($qu["eh_headman_user_id"]) === intval($headman_user_id)) {
                         $headman_level = $qu["eh_headman_level"];
                         break;
                     }
                 }
                 $query2 = $this->workflow->get_detail($workflow_id);
                 $query2 = $query2->row_array();
                 if (count($query2) > 0) {
                     $workflow_name = $query2["WFName"];
                     if (strpos(strtolower($workflow_name), 'level ' . $headman_level) !== FALSE) {
                         $this->load->library("WorkflowSystem");
                         $this->workflowsystem->set_require_data($ot_id, "overtime", $type, $remark);
                         // leave_id,leave,approve/disapprove
                         $process = $this->workflowsystem->run();
                         //echo $this->workflowsystem->get_data("next_step_name");
                         echo swalc("สำเร็จ", "การอนุมัติใบลาเรียบร้อยแล้ว", "success");
                     } else {
                         echo swalc("ผิดพลาด", "ไม่สามารถทำการอนุมัติการทำงานล่วงเวลาได้", "error");
                     }
                 }
             }
         }
     }
 }
Exemple #11
0
 public function save_edit()
 {
     if ($_POST) {
         $post = $this->input->post();
         $bank_id = $post['hd_bank_id'];
         $bank_name = $post['input_bank_name'];
         $bank_desc = $post['input_bank_desc'];
         $query = $this->bank->get_detail_by_id($bank_id);
         if ($query->num_rows() > 0) {
             $query = $query->row_array();
             $old_bank_name = $query['BName'];
             $data = array();
             $data['BName'] = $bank_name;
             $data['BDesc'] = $bank_desc;
             $data['BLatestUpdate'] = getDateTimeNow();
             $where = array('BID' => $bank_id);
             $this->bank->update($data, $where);
             log_admin('insert', $bank_id, 'bank', 'edit bank name ' . $old_bank_name, $this->user_id);
             echo swalc('บันทึกเรียบร้อย', '', 'success', 'window.location.href = "' . site_url('admin/Bank/') . '" ');
         } else {
             redirect(site_url('admin/Bank/'));
         }
     }
 }
Exemple #12
0
 /**
  * ส่งอีเมล์เพื่อให้พิจารณาอนุมัติ/ไม่อนุมัติใบลางาน
  * @param  [int] $leave_id 
  * @param  [int] $workflow_id  
  * @return [type]           [description]
  */
 public function send_mail_to_leave_headman($leave_id, $workflow_id = 1, $type = 'add', $leave_detail = array())
 {
     //load model needed
     $this->load->model('Leavetimedetail_model', 'leavetime');
     //get leave detail
     $query = $this->leave->getDetailByLeaveID($leave_id);
     $data = $query->row_array();
     $leave_type = $data['LTName'];
     $leave_because = $data['LBecause'];
     $leave_start_date = $data['LStartDate'] . ' ' . $data['LStartTime'];
     $leave_end_date = $data['LEndDate'] . ' ' . $data['LEndTime'];
     $leave_attach_file = $data['LAttachFile'];
     //get leave time detail
     $query_time = $this->leavetime->getDetailByLeaveID($leave_id);
     $query_time = $query_time->result_array();
     $leave_sum = sum_show_leave_time($query_time);
     //get owner leave detail
     $emp_detail = getEmployeeDetailByUserID($data["L_UserID"]);
     $owner_emp_id = $emp_detail['EmpID'];
     $owner_firstname = $emp_detail['EmpFirstnameThai'];
     $owner_fullname = $emp_detail["EmpNameTitleThai"] . $emp_detail["EmpFirstnameThai"] . " " . $emp_detail["EmpLastnameThai"];
     $owner_email = $emp_detail['EmpEmail'];
     //get headman detail
     $headman_user_id = $emp_detail["EmpHeadman_UserID"];
     $headman_detail = getEmployeeDetailByUserID($headman_user_id);
     $headman_email = $headman_detail['EmpEmail'];
     $headman_fullname = $headman_detail['EmpFullnameThai'];
     //get workflow process
     $query = $this->workflow->get_detail($workflow_id);
     $query = $query->row_array();
     $workflow_name = $query['WFName'];
     $subject = '';
     $template_email_path = '';
     switch ($workflow_id) {
         case '1':
             //ขออนุญาตลา
             //การส่งอนุมัติทันทีหรือไม่อนุมัติทันทีจะมีการแนบ UserID ของ headman คนนั้นไปด้วย แต่
             //เพื่อความปลอดภัยเลยเลือกใช้การ encode รหัสไว้ แล้วก็ ส่ง leave id ไป
             if ($type == 'add') {
                 $subject = 'ลูกทีม ' . $owner_firstname . ' ขออนุญาต ' . $leave_type;
                 $body = file_get_contents(APPPATH . 'views/Email/ask_approve_to_headman.html');
                 $search = array('{{headman_fullname}}', '{{leave_type}}', '{{owner_emp_id}}', '{{owner_fullname}}', '{{leave_because}}', '{{leave_start_date}}', '{{leave_end_date}}', '{{leave_sum}}', '{{siteurl}}', '{{headmanid}}', '{{leaveid}}');
                 $replace = array($headman_fullname, $leave_type, $owner_emp_id, $owner_fullname, $leave_because, $leave_start_date, $leave_end_date, $leave_sum, site_url(), encrypt_decrypt('encrypt', $headman_user_id), encrypt_decrypt('encrypt', $leave_id));
             } else {
                 if ($type == 'edit') {
                     $subject = '[มีการแก้ไขใบลา] ลูกทีม ' . $owner_firstname . ' ขออนุญาต ' . $leave_type;
                     $body = file_get_contents(APPPATH . 'views/Email/edit_ask_approve_to_headman.html');
                     $search = array('{{headman_fullname}}', '{{leave_type}}', '{{owner_emp_id}}', '{{owner_fullname}}', '{{leave_because}}', '{{leave_start_date}}', '{{leave_end_date}}', '{{leave_old_start_date}}', '{{leave_old_end_date}}', '{{leave_sum}}', '{{siteurl}}', '{{headmanid}}', '{{leaveid}}');
                     $replace = array($headman_fullname, $leave_type, $owner_emp_id, $owner_fullname, $leave_because, $leave_start_date, $leave_end_date, $leave_detail['LStartDate'] . ' ' . $leave_detail['LStartTime'], $leave_detail['LEndDate'] . ' ' . $leave_detail['LEndTime'], $leave_sum, site_url(), encrypt_decrypt('encrypt', $headman_user_id), encrypt_decrypt('encrypt', $leave_id));
                 }
             }
             $body = str_replace($search, $replace, $body);
             break;
         case '4':
             $subject = '[อนุมัติใบลา] ลูกทีม ' . $owner_firstname . ' โดยฝ่ายบุคคล';
             break;
         case '5':
             $subject = '[ไม่อนุมัติใบลา] ลูกทีม ' . $owner_firstname . ' โดยฝ่ายบุคคล';
             $body = file_get_contents(APPPATH . 'views/Email/result_leave_disapprove_from_hr_to_headman.html');
             $search = array('{{headman_fullname}}', '{{hr_result}}', '{{hr_remark}}', '{{leave_type}}', '{{owner_emp_id}}', '{{owner_fullname}}', '{{leave_because}}', '{{leave_start_date}}', '{{leave_end_date}}', '{{leave_sum}}', '{{siteurl}}', '{{leaveid}}');
             $replace = array($headman_fullname, $leave_detail['result'], $leave_detail['remark'], $leave_type, $owner_emp_id, $owner_fullname, $leave_because, $leave_start_date, $leave_end_date, $leave_sum, site_url(), $leave_id);
             $body = str_replace($search, $replace, $body);
             break;
     }
     //send mail library
     //non config because default set in phpmailer class
     $this->load->library('phpmailer');
     $this->phpmailer->ClearAllRecipients();
     $this->phpmailer->IsSMTP();
     $this->phpmailer->Subject = $subject;
     if ($leave_attach_file != "") {
         $this->phpmailer->AddAttachment($leave_attach_file);
     }
     $this->phpmailer->Body = $body;
     //ส่วนนี้รายละเอียดสามารถส่งเป็นรูปแบบ HTML ได้
     $this->phpmailer->AddAddress($headman_email, $headman_fullname);
     if (!$this->phpmailer->Send()) {
         //return $this->phpmailer->ErrorInfo;
         echo swalc('ผิดพลาด!!', 'ระบบบันทึกการลาของคุณแล้ว แต่ไม่สามารถส่งอีเมล์ถึงหัวหน้าของคุณได้<br/>' + $this->phpmailer->ErrorInfo, 'error', "window.location.href = '" . site_url("Leave") . "'");
     } else {
         return 'success';
         //echo swalc('สำเร็จ!!','บันทึกการลาของคุณพร้อมส่งอีเมล์ให้หัวหน้าเรียบร้อยแล้ว','success',"window.location.href = '".site_url("Leave")."'");
     }
 }
Exemple #13
0
 private function _instant_headman_approve_disapprove($type, $headman_user_id, $leave_id)
 {
     $this->load->model("Emp_headman_model", "empheadman");
     $headman_level = 0;
     $remark = "ทำรายการผ่านหน้ารายการ";
     //check you is a headman this owner request
     list($checker, $headman_level) = is_your_leave_headman($headman_user_id, $leave_id);
     if ($checker === TRUE) {
         //เช็คว่าหัวหน้าที่จะทำการอนุมัตินี้ เป็นหัวหน้าระดับที่เท่าไหร่ แล้วตรงกันกับระดับของ Workflow มั้ย
         $query = $this->leave->getDetailByLeaveID($leave_id)->row_array();
         if (count($query) > 0) {
             $user_id = $query["L_UserID"];
             $workflow_id = $query["L_WFID"];
             $query2 = $this->empheadman->get_list_by_user_id($user_id)->result_array();
             if (count($query2) > 0) {
                 foreach ($query2 as $qu) {
                     if (intval($qu["eh_headman_user_id"]) === intval($headman_user_id)) {
                         $headman_level = $qu["eh_headman_level"];
                         break;
                     }
                 }
                 //หลังจากได้เลเวลของ headman ของตัวเองมาแล้วก็เอาไปเทียบกับ Workflow ตอนนี้
                 $query2 = $this->workflow->get_detail($workflow_id);
                 $query2 = $query2->row_array();
                 if (count($query2) > 0) {
                     $workflow_name = $query2["WFName"];
                     if (strpos(strtolower($workflow_name), 'level ' . $headman_level) !== FALSE) {
                         $this->load->library("WorkflowSystem");
                         $this->workflowsystem->set_require_data($leave_id, "leave", $type, $remark);
                         // leave_id,leave,approve/disapprove
                         $process = $this->workflowsystem->run();
                         echo $this->workflowsystem->get_data("next_step_name");
                     } else {
                         echo swalc("ผิดพลาด", "ไม่สามารถทำการอนุมัติใบลาได้", "error");
                     }
                 }
             }
         }
     }
 }
 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"));
     }
 }
Exemple #15
0
 public function assignment($id)
 {
     if (empty($id)) {
         redirect(site_url($this->urlList));
         exit;
     }
     if ($_POST) {
         $this->_saveAssignment();
         echo swalc("บันทึกเรียบร้อยแล้ว", "", "success");
         //exit();
     }
     $queryEmpShiftwork = $this->empshiftwork->getList($id);
     $queryEmp = $this->employees->getList();
     $data = array();
     $data["dataEmpList"] = $queryEmp->result_array();
     $data["dataEmpShiftworkList"] = $queryEmpShiftwork->result_array();
     $data["valueId"] = $id;
     parent::setHeaderAdmin("เวลาเข้า-ออก");
     $this->load->view("admin/Shiftwork/Shiftwork_assignment", $data);
     parent::setFooterAdmin();
 }