Example #1
0
 function get_ot_value($emp_id, $period_id, $monthly_income_id)
 {
     $is_management = getValue('job_level', 'kg_view_overtime', array('id_employee' => 'where/' . $emp_id));
     $filter_period = array('id' => 'where/' . $period_id);
     $month = getValue('month', 'payroll_period', $filter_period);
     $year = getValue('year', 'payroll_period', $filter_period);
     $date_end = $year . '-' . $month . '-' . '15';
     $date_start = date("Y-m-d", strtotime(date($date_end, strtotime(date("Y-m-d"))) . "-1 month"));
     $date_start = date("Y-m-d", strtotime(date($date_start, strtotime(date("Y-m-d"))) . "+1 day"));
     //Acc Ovt
     $acc = 0;
     $q = GetAll("kg_view_overtime", array("id_employee" => "where/" . $emp_id, "date_full >=" => "where/" . $date_start, "date_full <=" => "where/" . $date_end, "date_temp" => "where/0000-00-00"));
     foreach ($q->result_array() as $s) {
         if ($s['job_level'] != "nonmanagement") {
             if ($s['ovt_hour_sum'] >= 2) {
                 $acc += $s['ovt_hour_sum'];
             }
         } else {
             $acc += $s['ovt_hour_cal'];
         }
     }
     //print_mz($acc);
     $q = GetAll("kg_view_overtime", array("id_employee" => "where/" . $emp_id, "date_temp >=" => "where/" . $date_start, "date_temp <=" => "where/" . $date_end));
     foreach ($q->result_array() as $s) {
         if ($s['job_level'] != "nonmanagement") {
             if ($s['ovt_hour_sum'] >= 2) {
                 $acc += $s['ovt_hour_sum'];
             }
         } else {
             $acc += $s['ovt_hour_cal'];
         }
     }
     if ($is_management != "nonmanagement") {
         $upah = $acc * GetConfigDirect('rest_time');
         $component_id = 82;
         $num_rows = GetAllSelect('payroll_monthly_income_component', 'payroll_component_id', array('payroll_monthly_income_id' => 'where/' . $monthly_income_id, 'payroll_component_id' => 'where/' . $component_id))->num_rows();
         $data = array('payroll_monthly_income_id' => $monthly_income_id, 'payroll_component_id' => $component_id, 'value' => $upah);
         if ($num_rows > 0) {
             $this->db->where('payroll_monthly_income_id', $monthly_income_id)->where('payroll_component_id', $component_id)->update('payroll_monthly_income_component', $data);
         } else {
             $this->db->insert('payroll_monthly_income_component', $data);
         }
     } else {
         $upah = $acc * (GetGapok($emp_id, $date_start) + GetHA($emp_id, $date_start)) / GetConfigDirect('total_hour_ovt');
         $component_id = 82;
         $num_rows = GetAllSelect('payroll_monthly_income_component', 'payroll_component_id', array('payroll_monthly_income_id' => 'where/' . $monthly_income_id, 'payroll_component_id' => 'where/' . $component_id))->num_rows();
         $data = array('payroll_monthly_income_id' => $monthly_income_id, 'payroll_component_id' => $component_id, 'value' => $upah);
         if ($num_rows > 0) {
             $this->db->where('payroll_monthly_income_id', $monthly_income_id)->where('payroll_component_id', $component_id)->update('payroll_monthly_income_component', $data);
         } else {
             $this->db->insert('payroll_monthly_income_component', $data);
         }
     }
     $ot_rasio = GetOTRasio($emp_id, $date_end);
     //$upah / (GetGapok($emp_id, $exp[0]) + GetHA($emp_id, $exp[0]) + $upah) * 100;
     return $upah;
     //$data[] = array($no, $r->ext_id, $r->person_nm, GetMonth(intval(substr($tgl,16,2))).' '.substr($tgl,11,4), $r->ovt_hour_sum, $acc, Decimal($ot_rasio)."%", Rupiah($upah), $edit);
 }
Example #2
0
 function GetOTRasio($id_emp, $date, $flag_reason = NULL)
 {
     $exp = explode("-", $date);
     $att_start_period = GetConfigDirect('att_start_period');
     if ($exp[2] < $att_start_period) {
         $awal = date("Y-m", mktime(0, 0, 0, $exp[1] - 1, $exp[2], $exp[0])) . "-" . $att_start_period;
     } else {
         $awal = $exp[0] . "-" . $exp[1] . "-" . $att_start_period;
     }
     $acc = 0;
     $upah = 0;
     $reason = array();
     $qq = GetAll("kg_view_overtime", array("id_employee" => "where/" . $id_emp, "ovt_status" => "where/Approve", "date_full >=" => "where/" . $awal, "date_full <=" => "where/" . $date, "date_temp" => "where/0000-00-00"));
     if ($qq->num_rows() > 0) {
         foreach ($qq->result_array() as $ss) {
             if ($ss['job_level'] != "nonmanagement") {
                 if ($ss['ovt_hour_sum'] >= 2) {
                     $acc += $ss['ovt_hour_sum'];
                 }
             } else {
                 $acc += $ss['ovt_hour_cal'];
             }
             //Hitung Jumlah Alasan
             if (!isset($reason[$ss['id_reason']])) {
                 $reason[$ss['id_reason']] = 0;
             }
             $reason[$ss['id_reason']]++;
         }
     }
     if (!isset($ss['job_level'])) {
         $ss['job_level'] = "";
     }
     $qq = GetAll("kg_view_overtime", array("id_employee" => "where/" . $id_emp, "ovt_status" => "where/Approve", "date_temp >=" => "where/" . $awal, "date_temp <=" => "where/" . $date));
     if ($qq->num_rows() > 0) {
         foreach ($qq->result_array() as $ss) {
             if ($ss['job_level'] != "nonmanagement") {
                 if ($ss['ovt_hour_sum'] >= 2) {
                     $acc += $ss['ovt_hour_sum'];
                 }
             } else {
                 $acc += $ss['ovt_hour_cal'];
             }
             //Hitung Jumlah Alasan
             if (!isset($reason[$ss['id_reason']])) {
                 $reason[$ss['id_reason']] = 0;
             }
             $reason[$ss['id_reason']]++;
         }
     }
     if (!isset($ss['job_level'])) {
         $ss['job_level'] = "";
     }
     if ($ss['job_level'] != "nonmanagement") {
         $upah = $acc * GetConfigDirect('rest_time');
     } else {
         $upah = $acc * (GetGapok($id_emp, $exp[0]) + GetHA($id_emp, $exp[0])) / GetConfigDirect('total_hour_ovt');
     }
     //Var Reason
     $alasan = "";
     arsort($reason);
     foreach ($reason as $key => $val) {
         $alasan .= $key . "~" . $val . "-";
     }
     $alasan = substr($alasan, 0, -1);
     $ot_rasio = $upah / (GetGapok($id_emp, $exp[0]) + GetHA($id_emp, $exp[0]) + $upah) * 100;
     if ($flag_reason) {
         return Decimal($ot_rasio) . "%" . $alasan;
     } else {
         return Decimal($ot_rasio) . "%";
     }
 }
Example #3
0
 function export_ovt_rekap($tgl = NULL, $regs = NULL, $div = NULL, $sec = NULL, $pos = NULL, $grade = NULL)
 {
     $this->load->model('overtime_model', 'ovt');
     $param = array("tgl" => $tgl, "rekap" => "rekap", "regs" => $regs, "divisi" => $div, "section" => $sec, "position" => $pos, "grade" => $grade);
     $exp = explode("~", $tgl);
     $list = $this->ovt->get_datatables($param);
     $dataz = array();
     $no = 0;
     //$_POST['start'];
     foreach ($list->result() as $r) {
         $no++;
         //Acc Ovt
         $acc = 0;
         $q = GetAll("kg_view_overtime", array("id_employee" => "where/" . $r->id_employee, "date_full >=" => "where/" . $exp[0], "date_full <=" => "where/" . $exp[1], "date_temp" => "where/0000-00-00"));
         foreach ($q->result_array() as $s) {
             if ($s['job_level'] != "nonmanagement") {
                 if ($s['ovt_hour_sum'] >= 2) {
                     $acc += $s['ovt_hour_sum'];
                 }
             } else {
                 $acc += $s['ovt_hour_cal'];
             }
         }
         $q = GetAll("kg_view_overtime", array("id_employee" => "where/" . $r->id_employee, "date_temp >=" => "where/" . $exp[0], "date_temp <=" => "where/" . $exp[1]));
         foreach ($q->result_array() as $s) {
             if ($s['job_level'] != "nonmanagement") {
                 if ($s['ovt_hour_sum'] >= 2) {
                     $acc += $s['ovt_hour_sum'];
                 }
             } else {
                 $acc += $s['ovt_hour_cal'];
             }
         }
         if ($r->job_level != "nonmanagement") {
             $upah = $acc * GetConfigDirect('rest_time');
         } else {
             $upah = $acc * (GetGapok($r->id_employee, $exp[0]) + GetHA($r->id_employee, $exp[0])) / GetConfigDirect('total_hour_ovt');
         }
         $ot_rasio = GetOTRasio($r->id_employee, $exp[1]);
         //$upah / (GetGapok($r->id_employee, $exp[0]) + GetHA($r->id_employee, $exp[0]) + $upah) * 100;
         //$edit = '<a class="btn btn-sm btn-primary" href="javascript:void(0);" onclick="detailOvertime('."'".$r->id_employee."'".')"><i class="glyphicon glyphicon-info-sign"></i> Detail</a>';
         $dataz[] = array($no, $r->ext_id, $r->person_nm, GetMonth(intval(substr($tgl, 16, 2))) . ' ' . substr($tgl, 11, 4), Decimal($r->ovt_hour_sum, 1), Decimal($acc), $ot_rasio, Number($upah));
     }
     $data['list'] = $dataz;
     //print_mz($data['list']);
     $html = $this->load->view('export_overtime_rekap', $data);
     to_excel($html, 'ReportOvertimeRekap');
 }