function GetOTCal($id_emp, $date) { $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; $sum_hour = 0; $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']; $sum_hour += $ss['ovt_hour_sum']; } } else { $acc += $ss['ovt_hour_cal']; $sum_hour += $ss['ovt_hour_sum']; } } } $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']; $sum_hour += $ss['ovt_hour_sum']; } } else { $acc += $ss['ovt_hour_cal']; $sum_hour += $ss['ovt_hour_sum']; } } } return $sum_hour . "~" . $acc; }
function overtime() { $this->data['title'] = $this->title; $webmaster_id = permission(); $nik = $hadir = $off = $alpa = $where = $rasio = array(); $bawahan = CekBawahanByGrade($webmaster_id); //supaya User Login di Bar pertama $bawahan[] = array("grade" => 100, "id_emp" => "-1", "color" => "000000"); if (count($bawahan) == 1 && $webmaster_id != 1) { $this->data['flagz'] = 1; } else { $this->data['flagz'] = 0; } //die($data['flagz']."D"); rsort($bawahan); $q = GetAll("kg_ref_reason"); $title_reason = array(); foreach ($q->result_array() as $r) { $title_reason[$r['id_reason']] = $r['title']; } $avg_rasio = 0; $legend = array(); foreach ($bawahan as $val) { $b = $val['id_emp']; if ($b == "-1") { $b = $webmaster_id; } $ext_id = GetValue("ext_id", "hris_persons", array("person_id" => "where/" . $b)); $person_nm = GetValue("person_nm", "hris_persons", array("person_id" => "where/" . $b)); //$nik[] = "'".$ext_id."-".$person_nm."'"; //$nik[] = "'".$ext_id."'"; $new_nm = ""; $exp = explode(" ", $person_nm); foreach ($exp as $e) { if (strlen($new_nm . " " . $e) > 12) { break; } else { $new_nm .= $e . " "; } } $nik[] = "'" . $new_nm . "'"; $where[] = "'" . $b . "'"; $get_rasio = explode("%", GetOTRasio($b, "2015-12-15", 1)); $val_rasio = $get_rasio[0]; if ($val_rasio > 0) { $avg_rasio += $val_rasio; } //Reason $info = ""; $exp = explode("-", $get_rasio[1]); foreach ($exp as $alasan) { $exp2 = explode("~", $alasan); $info .= "<tr><td><small>" . $title_reason[$exp2[0]] . "</td><td>:</td><td>" . $exp2[1] . "</small></td></tr>"; } $rasio[$b] = "{info: '" . $info . "', titlez: '" . $person_nm . "', y: " . str_replace("%", "", GetOTRasio($b, "2015-12-15")) . ", id_emp: '" . $b . "', color: '#" . $val['color'] . "'}"; if ($val['grade'] != 100) { $legend[$val['grade']] = "<label class='legend_grafik' style='background:#" . $val['color'] . ";'> </label><label class='title_legend_grafik'>GRADE " . $val['grade'] . "</label>"; } } $this->data['avg_rasio'] = Decimal($avg_rasio / count($bawahan)); $this->data['limit_ot'] = GetConfigDirect("limit_ot_rasio_grafik"); if (count($legend) <= 2) { $this->data['width_legend'] = 35; } else { $this->data['width_legend'] = count($legend) * 10.5; } $legend['target'] = "<div class='clearfix'></div><label class='legend_grafik' style='width:30px;border-top:2px dashed #ff0000;height:3px;margin-top:8px;'> </label><label class='title_legend_grafik' style='width:100px;'>TARGET (" . $this->data['limit_ot'] . "%)</label>"; $legend['average'] = "<label class='legend_grafik' style='width:30px;border-top:2px dashed #008000;height:3px;margin-top:8px;'> </label><label class='title_legend_grafik' style='width:110px;'>AVERAGE (" . $this->data['avg_rasio'] . "%)</label>"; $this->data['legend'] = join('', $legend); //print_mz($nik); $wherez = join($where, ","); $q = $this->db->query("select person_nm,id_employee,ext_id,SUM(sakit) as sakit,SUM(cuti) as cuti,SUM(ijin) as ijin, SUM(alpa) as alpa,SUM(off) as off, SUM(jh) as jh\n from kg_view_attendance where id_employee in (" . $wherez . ") group by id_employee"); foreach ($q->result_array() as $r) { $id_emp = $r['id_employee']; if ($id_emp == $webmaster_id) { $id_emp = "-1"; } $hadir[$id_emp] = "{titlez: '" . $r['person_nm'] . "', y: " . $r['jh'] . ", id_emp: '" . $r['id_employee'] . "'}"; $off[$id_emp] = "{titlez: '" . $r['person_nm'] . "', y: " . $r['off'] . ", id_emp: '" . $r['id_employee'] . "'}"; $alpa[$id_emp] = "{titlez: '" . $r['person_nm'] . "', y: " . $r['alpa'] . ", id_emp: '" . $r['id_employee'] . "'}"; } ksort($hadir); ksort($off); ksort($alpa); $this->data['nik'] = join($nik, ','); $this->data['hadir'] = join($hadir, ','); $this->data['off'] = join($off, ','); $this->data['alpa'] = join($alpa, ','); $this->data['rasio'] = join($rasio, ','); $this->_render_page($this->filename . '/index_ot', $this->data); }
?> </div> </form> </div> </div> <script> var table; $(document).ready(function() { $('.tgl_limit').datepicker({ format: 'yyyy-mm-dd', autoclose: true, todayHighlight: true, startDate: "-<?php echo GetConfigDirect('limit_day_ovt'); ?> d", endDate: '0d' }); }); </script> <script src="<?php echo assets_url('modules/js/explode.js'); ?> "></script> <script src="<?php echo assets_url('modules/js/attendance_form.js'); ?> "></script>
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); }
function get_current_schedule($tgl) { $msg = "Actual In/Out not allowed empty, please contact your supervisor"; $err = ""; $webmaster_id = permission(); $exp = explode("-", $tgl); $cek_jadwal = GetValue("tgl_" . intval($exp[2]), "kg_jadwal_shift", array("id_employee" => "where/" . $webmaster_id, "bulan" => "where/" . $exp[1], "tahun" => "where/" . $exp[0])); if ($cek_jadwal == "reg") { echo GetConfigDirect('reguler_start') . "~" . GetConfigDirect('reguler_end'); } else { if ($cek_jadwal == "off") { echo "--:--~--:--"; } else { $time = GetConfigDirect('shift_' . $cek_jadwal); if ($cek_jadwal == 3) { $time .= "~" . GetConfigDirect('shift_1'); } else { $time .= "~" . GetConfigDirect('shift_' . ($cek_jadwal + 1)); } echo $time; } } //Scan in out $q = GetAll("kg_view_attendance", array("id_employee" => "where/" . $webmaster_id, "date_full" => "where/" . $tgl)); if ($q->num_rows() > 0) { foreach ($q->result_array() as $r) { if ($r['scan_masuk'] == "-") { $r['scan_masuk'] = "--:--"; $err = $msg; } if ($r['scan_pulang'] == "-") { $r['scan_pulang'] = "--:--"; $err = $msg; } echo "~" . $r['scan_masuk'] . "~" . $r['scan_pulang'] . "~" . $err; } } else { echo "~--:--~--:--~" . $msg; } }
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'); }