Esempio n. 1
0
 public function instant_approve_disapprove_ot_by_hr($type, $hr_user_id, $ot_id)
 {
     $hr_user_id = encrypt_decrypt('decrypt', $hr_user_id);
     $ot_id = encrypt_decrypt('decrypt', $ot_id);
     $workflow_id = 0;
     //check hr is in role hr
     $is_hr = is_hr($hr_user_id);
     if ($is_hr) {
         //get ot request detail for get owner user id
         $query = $this->ot->get_detail_by_id($ot_id);
         if ($query->num_rows() > 0) {
             $ot_detail = $query->row_array();
             if (intval($ot_detail['wot_workflow_id']) > 3) {
                 echo swalc('ผิดพลาด!!!', 'คุณไม่สามารถทำรายการใบคำขอทำงานล่วงเวลานี้ได้เพราะคำขอนี้มีการอนุมัติ/ไม่อนุมัติไปแล้ว', 'error');
             } else {
                 $owner_user_id = $ot_detail['wot_request_by'];
                 $owner_detail = getEmployeeDetailByUserID($owner_user_id);
                 $owner_headman_user_id = $owner_detail['EmpHeadman_UserID'];
                 $log_type = '';
                 $log_detail = '';
                 //set approve / disapprove
                 if ($type == 'approve') {
                     $workflow_id = 4;
                     $log_type = 'instant approve from email by hr';
                     $log_detail = 'HR ทำการอนุมัติใบคำขอทำงานล่วงเวลาทันทีผ่านอีเมล์';
                 } else {
                     if ($type == 'disapprove') {
                         $workflow_id = 5;
                         $log_type = 'instant disapprove from email by hr';
                         $log_detail = 'HR ไม่อนุมัติใบคำขอทำงานล่วงเวลาทันทีผ่านอีเมล์';
                         $send_to_headman = $this->send_email_ot_to_headman();
                     }
                 }
                 $data = array('wot_workflow_id' => $workflow_id);
                 $where = array('wot_id' => $ot_id);
                 //insert log
                 insert_log_ot($ot_id, $log_type, $log_detail, $hr_user_id);
                 //send email to owner request ot with log
                 $send = $this->send_email_result_ot_to_owner($ot_id);
                 if ($send == 'success') {
                     insert_log_ot($ot_id, 'send email result ot to owner', 'ส่งอีเมล์เพื่อแจ้งสถานะใบคำขอทำงานล่วงเวลาให้เจ้าของใบคำขอ', $hr_user_id);
                 } else {
                     insert_log_ot($ot_id, 'error send email result ot to owner', 'ไม่สามารถส่งอีเมล์เพื่อแจ้งสถานะใบคำขอทำงานล่วงเวลาให้เจ้าของใบคำขอได้', $hr_user_id);
                 }
                 //if disapprove send mail to headman
                 if ($type == 'disapprove') {
                     $send = $this->send_email_ot_to_headman('disapprove_by_hr', $ot_id);
                     if ($send == 'success') {
                         insert_log_ot($ot_id, 'send email disapprove ot to headman by hr', 'ส่งอีเมล์เพื่อแจ้งสถานะใบคำขอทำงานล่วงเวลาให้หัวหน้าเจ้าของคำขอ', $hr_user_id);
                     } else {
                         insert_log_ot($ot_id, 'error send email disapprove ot to headman by hr', 'ไม่สามารถส่งอีเมล์เพื่อแจ้งสถานะใบคำขอทำงานล่วงเวลาให้หัวหน้าเจ้าของใบคำขอได้ เพราะ ' . $send, $hr_user_id);
                     }
                 }
             }
         }
     } else {
         echo swalc('ผิดพลาด!!!', 'ไม่สามารถทำรายการได้', 'error');
     }
 }
Esempio n. 2
0
 public function disapprove_from_headman_level_3()
 {
     $ci =& get_instance();
     $ci->load->helper("log_helper");
     $process = $this->approve_disapprove_from_headman(3);
     if ($process === TRUE) {
         $log_type = 'headman_level_3_disapprove';
         $log_detail = $this->next_step_name;
         if ($this->remark !== "") {
             $log_detail .= " หมายเหตุเพิ่มเติม : " . $this->remark;
         }
         if ($this->type == "leave") {
             log_leave($log_type, $this->main_id, $log_detail, $this->headman_user_id);
         } else {
             if ($this->type == "overtime") {
                 insert_log_ot($this->main_id, $log_type, $log_detail, $this->headman_user_id);
             }
         }
     }
     return $process;
 }
Esempio n. 3
0
 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"));
     }
 }