Esempio n. 1
0
 public function saveReply()
 {
     $messageID = 0;
     if ($_POST) {
         $messageID = $this->input->post("hdMID");
         $content = $this->input->post("txtContent");
         $data = array();
         $data["MContent"] = $content;
         $data["M_UserID"] = $this->user_id;
         $data["MReplyToID"] = $messageID;
         $data["MCreatedDate"] = getDateTimeNow();
         $data["MLatestUpdate"] = getDateTimeNow();
         $this->message->insert($data);
     }
     redirect(site_url("Message/detail/" . $messageID));
 }
Esempio n. 2
0
 public function saveApprove()
 {
     //value status
     // 1 = request
     // 2 = approve
     // 3 = disapprove
     if ($_POST) {
         $post = $this->input->post();
         $status = $post["status"] == "approve" ? 2 : 3;
         //approve / disapprove
         $amount = $post["inputApproveAmount"] == "" ? 0 : $post["inputApproveAmount"];
         $remark = $post["inputApproveRemark"];
         $reqID = $post["id"];
         $data = array();
         $data["RE_StatusID"] = $status;
         $data["REApproveAmount"] = $amount;
         $data["RERemark"] = $remark;
         $data["RELatestUpdate"] = getDateTimeNow();
         $data["RELatestUpdateBy"] = $this->userID;
         $where = array();
         $where["REID"] = $reqID;
         $this->requestemp->update($data, $where);
     }
 }
Esempio n. 3
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') . '"');
     }
 }
Esempio n. 4
0
 private function _save_special_money()
 {
     $this->load->model("Specialmoneyofmonth_model");
     $post = $this->input->post(NULL, TRUE);
     $data = array();
     $data["SMMUserID"] = $post["hd_user_id"];
     $data["SMMYear"] = $post["ddlYear"];
     $data["SMMMonth"] = $post["ddlMonth"];
     $data["SMMTopic"] = $post["inputTopic"];
     $data["SMMDesc"] = $post["inputDesc"];
     $data["SMMMoney"] = $post["inputType"] . $post["inputMoney"];
     $data["SMMCreatedDate"] = getDateTimeNow();
     $data["SMMCreatedByUserID"] = $this->session->userid;
     $data["SMMLatestUpdate"] = getDateTimeNow();
     $data["SMMLatestUpdateByUserID"] = $this->session->userid;
     $this->Specialmoneyofmonth_model->insert($data);
     return TRUE;
 }
Esempio n. 5
0
 public function deleteNews($newsID)
 {
     $data = array();
     $data["NS_StatusID"] = 0;
     $data["NSLatestUpdate"] = getDateTimeNow();
     $where = array();
     $where["NSID"] = $newsID;
     $this->news->update($data, $where);
     redirect(site_url("hr/News"));
 }
Esempio n. 6
0
 private function _saveSpecialMoney($empId)
 {
     $empData = getEmployeeDetail($empId);
     $post = $this->input->post(NULL, TRUE);
     $data = array();
     $data["SMMUserID"] = $empData["UserID"];
     $data["SMMYear"] = $post["ddlYear"];
     $data["SMMMonth"] = $post["ddlMonth"];
     $data["SMMTopic"] = $post["inputTopic"];
     $data["SMMDesc"] = $post["inputDesc"];
     $data["SMMMoney"] = $post["inputType"] . $post["inputMoney"];
     $data["SMMCreatedDate"] = getDateTimeNow();
     $data["SMMCreatedByUserID"] = $this->user_id;
     $data["SMMLatestUpdate"] = getDateTimeNow();
     $data["SMMLatestUpdateByUserID"] = $this->user_id;
     $this->specialmoney->insert($data);
     return TRUE;
 }
Esempio n. 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') . '"');
     }
 }
Esempio n. 8
0
 public function saveSalary()
 {
     if ($_POST) {
         $post = $this->input->post();
         $emp_id = $post['hd_emp_id'];
         //data salary
         $salary = $post['txt_salary'];
         //now salary
         $increase = $post['txt_salary_increase'];
         //increase
         $net = $post['txt_salary_net'];
         //total salary
         $remark = $post['txt_remark'];
         //prepare data for update employee
         $emp = array('EmpSalary' => $net);
         $where_emp = array('EmpID' => $emp_id);
         //update employee
         $this->load->model('Employees_model', 'employee');
         $this->employee->edit($emp, $where_emp);
         //prepare data for insert salary log
         $log = array();
         $log['sal_user_id'] = getUserIDByEmpID($emp_id);
         $log['sal_salary_from'] = $salary;
         $log['sal_salary_increase'] = $increase;
         $log['sal_salary_to'] = $net;
         $log['sal_change_date'] = getDateTimeNow();
         $log['sal_change_by'] = $this->user_id;
         $log['sal_remark'] = $remark;
         //insert salary log
         $this->load->model('salary_log_model', 'salarylog');
         $this->salarylog->insert($log);
         echo swalc('สำเร็จ', 'บันทึกการปรับเงินเดือนเรียบร้อยแล้ว', 'success', 'window.location.href = "' . site_url('hr/Employee') . '"');
     }
 }
Esempio n. 9
0
 private function _saveGroup($type = "add")
 {
     $post = $this->input->post(NULL, TRUE);
     if ($type === "add") {
         $data = array();
         $data["cg_cuid"] = $post["inputParent"];
         $data["cgname"] = $post["inputName"];
         $data["cgdesc"] = $post["inputDesc"];
         $data["cgstatus"] = 1;
         $data["cgcreateddate"] = getDateTimeNow();
         $data["cgcreatedbyuserid"] = $this->user_id;
         $data["cglatestupdate"] = getDateTimeNow();
         $data["cglatestupdatebyuserid"] = $this->user_id;
         $newId = $this->group->insert($data);
     } else {
         if ($type === "edit") {
             $data = array();
             $data["cg_cuid"] = $post["inputParent"];
             $data["cgname"] = $post["inputName"];
             $data["cgdesc"] = $post["inputDesc"];
             $data["cglatestupdate"] = getDateTimeNow();
             $data["cglatestupdatebyuserid"] = $this->user_id;
             $where = array();
             $where["cgid"] = $post["hdId"];
             $this->group->update($data, $where);
         }
     }
 }
Esempio n. 10
0
 public function disApprove()
 {
     if ($_POST) {
         $post = $this->input->post();
         $where = array();
         $where["LID"] = $post["id"];
         $data = array();
         $data["L_WFID"] = 3;
         $this->leave->update($data, $where);
         $data = array();
         $data["LL_LID"] = $post["id"];
         $data["LLDetail"] = "ไม่อนุมัติใบลาโดย HR";
         $data["LLDate"] = getDateTimeNow();
         $data["LLBy"] = $this->userID;
         $this->leavelog->insert($data);
     }
 }
Esempio n. 11
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'));
         }
     }
 }
Esempio n. 12
0
 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/"));
     }
 }
Esempio n. 13
0
 public function delete()
 {
     if ($_POST) {
         $bank_id = $this->input->post('id');
         $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['B_StatusID'] = '-999';
             $data['BLatestUpdate'] = getDateTimeNow();
             $where = array('BID' => $bank_id);
             $this->bank->update($data, $where);
             log_admin('insert', $bank_id, 'bank', 'delete bank name ' . $old_bank_name, $this->user_id);
         }
     }
 }
Esempio n. 14
0
 public function ajaxGetDetailLeave($type = 'add')
 {
     $this->load->model("Employees_Model", "employees");
     $this->load->model("LeaveCondition_Model", "leavecon");
     //เมื่อโหลดเข้ามาหน้านี้ให้ทำการ Gen Quota ของปีนั้นๆ หากไม่มีข้อมูล เพื่อใช้แสดงผล/เช็คว่ามีวันเหลือกี่วัน
     //T_LeaveQuota ใช้ร่วมกับ T_Employees , T_LeaveCondition
     if ($_POST) {
         $returner = "";
         $pData = $this->input->post();
         $leaveTypeID = $pData["id"];
         $query = $this->leavetype->getDetailByID($leaveTypeID);
         if ($query->num_rows() > 0) {
             $query = $query->result_array();
             $returner = $query[0]["LTDesc"];
             //รายละเอียดการลาป่วย
         }
         //get quota
         $userID = $this->user_id;
         $empID = $this->emp_id;
         $this->load->model("LeaveQuota_Model", "leavequota");
         if ($this->leavequota->checkExists($userID, $leaveTypeID) == false) {
             /*	ถ้าไม่มีข้อมูลเกี่ยวกับโควต้าอยู่ให้ทำการ Gen Quota ให้ โดย คิดจากต้นปี ของปีนี้ - วันที่เริ่มงาน
              *		1. ต้องรับวันที่เริ่มทำงานของพนักงานมาก่อนที่ T_Employees
              *		2. เอามาคำนวณวันที่ทำงานโดยตั้งด้วย ปีปัจจุบัน-01-01 แล้วลบด้วยวันที่เริ่มทำงาน
              *		3. ได้จำนวนปีแล้วเอาไปเช็คกับเงื่อนไขใน T_LeaveCondition ว่าได้สิทธิ์เท่าไหร่
              *		4. Insert จำนวนสิทธิ์เข้าไปที่ T_LeaveQuota
              */
             $workAgeYear = $this->employees->getWorkAgeForQuota($empID);
             $canLeave = $this->leavecon->getCanLeave($leaveTypeID, $workAgeYear);
             $data = array();
             $data["LQ_UserID"] = $userID;
             $data["LQ_LTID"] = $leaveTypeID;
             $data["LQQuota"] = $canLeave;
             $data["LQUsedDay"] = 0;
             $data["LQUsedHour"] = 0;
             $data["LQRemainDay"] = $canLeave;
             $data["LQYear"] = date("Y");
             $data["LQCreatedDate"] = getDateTimeNow();
             $data["LQLatestUpdate"] = getDateTimeNow();
             $this->leavequota->insertNew($data);
         }
         $query = $this->leavequota->getQuota($userID, $leaveTypeID);
         if ($query->num_rows() > 0) {
             $query = $query->result_array();
             $query = $query[0];
             $quota = intval($query["LQQuota"]);
             $used_day = intval($query["LQUsedDay"]);
             $used_hour = intval($query["LQUsedHour"]);
             $returner .= "<p>คุณมีสิทธิ์ในการลาได้ทั้งหมด " . $quota . " วัน";
             $returner .= "<br/>คุณใช้สิทธิ์ในการลาไปแล้ว " . $used_day . " วัน " . $used_hour . " ชั่วโมง</p>";
             $returner .= "<!--CAN_LEAVE-->";
             if ($used_day >= $quota) {
                 $returner .= "FALSE";
             } else {
                 $returner .= "TRUE";
             }
             $returner .= "<!--CAN_LEAVE-->";
         }
         if ($type = 'add') {
             echo $returner;
         } else {
             return $returner;
         }
     }
 }
Esempio n. 15
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"));
     }
 }
Esempio n. 16
0
 public function insert($postData)
 {
     $data = array();
     $data["L_LTID"] = $postData["ddlLeaveType"];
     $data["L_UserID"] = $postData["hdUserID"];
     $data["LBecause"] = $postData["txtBecause"];
     $data["LStartDate"] = $postData["txtStartDate"];
     $data["L_StartPeriodID"] = $postData["rdoStartPeriod"];
     $data["LEndDate"] = $postData["txtEndDate"];
     $data["L_EndPeriodID"] = $postData["rdoEndPeriod"];
     $data["L_WFID"] = "1";
     $data["LCreatedDate"] = getDateTimeNow();
     $data["LLatestUpdate"] = getDateTimeNow();
     $this->db->insert($this->table, $data);
     return $this->db->insert_id();
 }
Esempio n. 17
0
 private function log_all_data()
 {
     /********* 
      * หลังจากได้ค่าทุกอย่างแล้ว ตอนนี้เราจะเริ่มทำการ Insert ลง DB
      *********/
     $this->load->model('Salary_pay_log_detail_model');
     $this->Salary_pay_log_detail_model->set_value('user_id', $this->user_id);
     $i = 0;
     # use for index log
     //table: salary_pay_log
     $pay_log = array("sapay_user_id" => $this->emp_user_id, "sapay_year" => $this->year, "sapay_month" => $this->month, "sapay_salary" => $this->my_salary, "sapay_ot" => $this->my_ot, "sapay_specialmoney_plus" => $this->my_specialmoney_plus, "sapay_specialmoney_minus" => $this->my_specialmoney_minus, "sapay_deduction" => $this->my_deduction, "sapay_tax" => $this->my_tax, "sapay_tax_ratepercent" => $this->my_tax_ratepercent, "sapay_bonus" => $this->my_bonus, "sapay_providentfund" => $this->my_provident_fund, "sapay_net" => $this->salary_pay_net, "sapay_total_income" => $this->total_income, "sapay_created_date" => getDateTimeNow());
     $this->db->insert("salary_pay_log", $pay_log);
     $sapay_id = $this->db->insert_id();
     $log = array();
     $i = 0;
     //salary_pay_log_detail_deduct
     foreach ($this->my_deduction_data as $mydata) {
         $log[$i] = array('spldd_sapay_id' => $sapay_id, 'spldd_deduc_id' => $mydata['deduc_id'], 'spldd_deduc_name' => $mydata['deduc_name'], 'spldd_deduc_baht' => $mydata['real_deduc_baht']);
         $i++;
     }
     $this->Salary_pay_log_detail_model->set_value("data_deduct", $log);
     $log = array();
     $i = 0;
     //salary_pay_log_detail_tax น่าจะยังไม่ต้องเก็บภาษีนะ ไม่มีรายละเอียดอะไร
     //salary_pay_log_detail_ot
     //wot_id,wot_date,wot_time_from,wot_time_to,wot_request_hour,
     //real_wot_time_from,real_wot_time_to,real_wot_request_hour
     foreach ($this->my_ot_data as $mydata) {
         $log[$i] = array('spldot_sapay_id' => $sapay_id, 'spldot_wot_id' => $mydata['wot_id'], 'spldot_wot_date' => $mydata['wot_date'], 'spldot_wot_time_from' => $mydata['wot_time_from'], 'spldot_wot_time_to' => $mydata['wot_time_to'], 'spldot_wot_request_hour' => $mydata['wot_request_hour'], 'spldot_real_wot_time_from' => $mydata['real_wot_time_from'], 'spldot_real_wot_time_to' => $mydata['real_wot_time_to'], 'spldot_real_wot_request_hour' => $mydata['real_wot_request_hour'], 'spldot_multiplier' => $mydata['ot_pay_multiplier'], 'spldot_money' => $mydata['real_ot_money']);
         $i++;
     }
     $this->Salary_pay_log_detail_model->set_value("data_ot", $log);
     $log = array();
     $i = 0;
     //salary_pay_log_detail_provident_fund
     //sapay_id,pvdid,pvdcode,pvdname,pvdratepercent
     foreach ($this->my_provident_fund_data as $mydata) {
         $log[$i] = array('spldpf_sapay_id' => $sapay_id, 'spldpf_pvdid' => $mydata['pvdid'], 'spldpf_pvdcode' => $mydata['pvdcode'], 'spldpf_pvdname' => $mydata['pvdname'], 'spldpf_pvdratepercent' => $mydata['pvdratepercent']);
         $i++;
     }
     $this->Salary_pay_log_detail_model->set_value("data_provident_fund", $log);
     $log = array();
     $i = 0;
     //salary_pay_log_detail_bonus
     foreach ($this->my_bonus_data as $mydata) {
         $log[$i] = array('spldbo_sapay_id' => $sapay_id, 'spldbo_bonus_id' => $mydata['bonus_id'], 'spldbo_bonus_money' => $mydata['bonus_money'], 'spldbo_bonus_period_id' => $mydata['bp_id'], 'spldbo_bonus_period' => $mydata['bp_period'], 'spldbo_bonus_pay' => $mydata['bp_money']);
         $i++;
     }
     $this->Salary_pay_log_detail_model->set_value("data_bonus", $log);
     $log = array();
     $i = 0;
     //salary_pay_log_detail_specialmoney
     foreach ($this->my_specialmoney_data as $mydata) {
         $log[$i] = array('spldsm_sapay_id' => $sapay_id, 'spldsm_smm_id' => $mydata['SMMID'], 'spldsm_smm_topic' => $mydata['SMMTopic'], 'spldsm_smm_money' => $mydata['SMMMoney']);
         $i++;
     }
     $this->Salary_pay_log_detail_model->set_value("data_specialmoney", $log);
     $log = array();
     $i = 0;
     # after set all data then insert all.
     $this->Salary_pay_log_detail_model->insert_all_detail();
     $data = "\n\t\t\t<h2>" . $this->emp_data['EmpFullnameThai'] . "</h2>\n\t\t\t<p>เงินเดือน: " . $this->my_salary . "</p>\n\t\t\t<p>OT: " . $this->my_ot . "\n\t\t\t\t<ul>";
     foreach ($this->my_ot_data as $ot_data) {
         $data .= "\n\t\t\t\t\t<li>วันที่ทำ: " . $ot_data['wot_date'] . "\n\t\t\t\t\t\t<br>เวลาที่ขอทำ: " . $ot_data['wot_time_from'] . " - " . $ot_data['wot_time_to'] . "\n\t\t\t\t\t\tจำนวนชั่วโมงที่ขอทำ: " . $ot_data['wot_request_hour'] . "\n\t\t\t\t\t\t<br>เวลาที่ทำจริง: " . $ot_data['real_wot_time_from'] . " - " . $ot_data['real_wot_time_to'] . "\n\t\t\t\t\t\tจำนวนชั่วโมงที่ทำจริง: " . $ot_data['real_wot_request_hour'] . "\n\t\t\t\t\t</li>";
     }
     $data .= "\n\t\t\t\t</ul>\n\t\t\t</p>\n\t\t\t<p>รายได้พิเศษ: " . $this->my_specialmoney_plus . "</p>\n\t\t\t<ul>";
     foreach ($this->my_specialmoney_data as $my_data) {
         if (intval($my_data['SMMMoney']) > 0) {
             $data .= "\n\t\t\t\t\t\t<li>\n\t\t\t\t\t\t" . $my_data['SMMTopic'] . ": " . $my_data['SMMMoney'] . "\n\t\t\t\t\t\t</li>\n\t\t\t\t\t\t";
         }
     }
     $data .= "</ul><p>รายหักพิเศษ: " . $this->my_specialmoney_minus . "</p>\n\t\t\t<ul>";
     foreach ($this->my_specialmoney_data as $my_data) {
         if (intval($my_data['SMMMoney']) < 0) {
             $data .= "\n\t\t\t\t\t<li>\n\t\t\t\t\t" . $my_data['SMMTopic'] . ": " . $my_data['SMMMoney'] . "\n\t\t\t\t\t</li>\n\t\t\t\t\t";
         }
     }
     $data .= "</ul>\n\t\t\t<p>ประกันสังคม: " . $this->my_deduction . "</p>\n\t\t\t<p>โบนัส: " . $this->my_bonus . "</p>\n\t\t\t<p>กองทุนสำรองเลี้ยงชีพ: " . $this->my_provident_fund . "</p>\n\t\t\t<p>ภาษี: " . $this->my_tax . "</p>\n\t\t\t<p>สรุปรายได้คือ: " . $this->salary_pay_net . "</p>\n\t\t\t<br><br>\n\t\t\t";
     echo $data;
 }
Esempio n. 18
0
 private function _saveShiftwork($type = "add")
 {
     $post = $this->input->post(NULL, TRUE);
     if ($type === "add") {
         $this->db->trans_begin();
         //t_shiftwork
         $data = array();
         $data["swcode"] = $post["inputCode"];
         $data["swname"] = $post["inputName"];
         $data["swdesc"] = $post["inputDesc"];
         $data["swstatus"] = 1;
         $data["swcreateddate"] = getDateTimeNow();
         $data["swcreatedbyuserid"] = $this->user_id;
         $data["swlatestupdate"] = getDateTimeNow();
         $data["swlatestupdatebyuserid"] = $this->user_id;
         $newId = $this->shiftwork->insert($data);
         //insert t_shiftworkdetail
         $numDay = 7;
         for ($i = 0; $i < $numDay; $i++) {
             $data = array();
             $data["swd_swid"] = $newId;
             $data["swdday"] = $i;
             $data["swdiswork"] = $post["inputWorkDay" . $i];
             $data["swdtimestart1"] = $post["inputTimeStart1Day" . $i] == "" ? NULL : $post["inputTimeStart1Day" . $i];
             $data["swdtimeend1"] = $post["inputTimeEnd1Day" . $i] == "" ? NULL : $post["inputTimeEnd1Day" . $i];
             $data["swdtimestart2"] = $post["inputTimeStart2Day" . $i] == "" ? NULL : $post["inputTimeStart2Day" . $i];
             $data["swdtimeend2"] = $post["inputTimeEnd2Day" . $i] == "" ? NULL : $post["inputTimeEnd2Day" . $i];
             $data["swdtotaltime"] = $post["inputTotalTimeDay" . $i] == "" ? NULL : $post["inputTotalTimeDay" . $i];
             $data["swdnumscanfinger"] = 2;
             $this->shiftworkdetail->insert($data);
         }
         if ($this->db->trans_status() === FALSE) {
             $this->db->trans_rollback();
         } else {
             $this->db->trans_commit();
         }
     } else {
         if ($type === "edit") {
             $this->db->trans_begin();
             //t_shiftwork
             $data = array();
             $data["swcode"] = $post["inputCode"];
             $data["swname"] = $post["inputName"];
             $data["swdesc"] = $post["inputDesc"];
             $data["swlatestupdate"] = getDateTimeNow();
             $data["swlatestupdatebyuserid"] = $this->user_id;
             $where = array("swid" => $post["hdId"]);
             $this->shiftwork->update($data, $where);
             //insert t_shiftworkdetail
             $numDay = 7;
             $swdId = explode(",", $post["hdWorkDayId"]);
             for ($i = 0; $i < $numDay; $i++) {
                 $data = array();
                 $data["swdday"] = $i;
                 $data["swdiswork"] = $post["inputWorkDay" . $i];
                 $data["swdtimestart1"] = $post["inputTimeStart1Day" . $i] == "" ? NULL : $post["inputTimeStart1Day" . $i];
                 $data["swdtimeend1"] = $post["inputTimeEnd1Day" . $i] == "" ? NULL : $post["inputTimeEnd1Day" . $i];
                 $data["swdtimestart2"] = $post["inputTimeStart2Day" . $i] == "" ? NULL : $post["inputTimeStart2Day" . $i];
                 $data["swdtimeend2"] = $post["inputTimeEnd2Day" . $i] == "" ? NULL : $post["inputTimeEnd2Day" . $i];
                 $data["swdtotaltime"] = $post["inputTotalTimeDay" . $i] == "" ? NULL : $post["inputTotalTimeDay" . $i];
                 $data["swdnumscanfinger"] = 2;
                 $where = array("swdid" => $swdId[$i]);
                 $this->shiftworkdetail->update($data, $where);
             }
             if ($this->db->trans_status() === FALSE) {
                 $this->db->trans_rollback();
             } else {
                 $this->db->trans_commit();
             }
         }
     }
 }