Beispiel #1
0
  <td></td>
 </tr>
 <tr>
   <?php 
   $sds = 0;
   $sts = 0;
   $idt = 0;
   $ipc = 0;
   $ck = 0;
   $ct = 0;
   $cil = 0;
   $dns = 0;
   $alp = 0;
   for ($y = 1; $y <= $jml_hari; $y++) {
       if ($y <= $tanggal) {
           $day = Hari($y, $bln, $thn);
           if ($day != 6 && $day != 7) {
               // $arr = array_replace($employe[$list['userid']]['attendance'], $temp[$list['userid']]);
               $arr = array_replace($employe[$list['userid']]['attendance'], $temp);
               $keterangan = $arr[$y];
               $class = $keterangan === strtoupper('L') ? 'libur' : '';
               $att = substr($keterangan, 2, 1) == '_' ? substr($keterangan, 3, strlen($keterangan)) : $keterangan;
               if ($att == 'SDS') {
                   $sds++;
               } elseif ($att == 'STS') {
                   $sts++;
               } elseif ($att == 'IDT') {
                   $idt++;
               } elseif ($att == 'IPC') {
                   $ipc++;
               } elseif ($att == 'CK') {
Beispiel #2
0
 public function monthly($value = '')
 {
     $orgid = $this->input->get('orgid1');
     $depidi = $this->input->get('dp');
     $compid = $this->input->get('cid');
     $awal = $this->input->get('datestart');
     $userid = $this->input->get('userid');
     $excelid = $this->input->get('excelid');
     $statusid = $this->input->get('status');
     $statusid = $statusid == 'AB_A' ? 'absent' : $statusid;
     $areaid = $this->my_usession->userdata('user_area') != '' ? $this->device_model->areaonall(explode(',', $this->my_usession->userdata('user_area'))) : array();
     $user = array();
     $dept = array();
     $deptid = array();
     $s = array();
     if (!isset($depidi)) {
         $dp = '';
     } elseif ($depidi == 'undefined') {
         $dp = '';
     } elseif ($depidi == 0) {
         $dp = '';
     } elseif ($depidi == '01') {
         $dp = $depidi;
     } else {
         $dp = $depidi;
     }
     if ($awal == '') {
         redirect(base_url(), 'refresh');
     }
     //get parent or dept
     if ($compid != 'undefined') {
         if (isset($compid)) {
             $companyid = $compid;
             $arrtemp = $this->employe_model->company($companyid);
             $cid = array();
             foreach ($arrtemp->result() as $key) {
                 $cid[] = $key->deptid;
             }
         } else {
             $cid = "";
         }
         $asem = $this->employe_model->get_employee2($areaid, $orgid, $cid, $dp);
         foreach ($asem->result() as $us) {
             // $s[]="'".$us->userid."'";
             $deptid[] = "'" . $us->deptid . "'";
         }
         $uid = $this->employe_model->getEmpByDeptId($deptid, $dp, $statusid)->result_array();
         foreach ($uid as $key => $value) {
             $s[] = "'" . $value['userid'] . "'";
         }
         $s = array_unique($s, SORT_REGULAR);
     } else {
         $ck_parent = $this->employe_model->adachild($orgid);
         if ($orgid != '' && $userid == 'undefined') {
             if ($ck_parent == 1) {
                 $deptid = $this->employe_model->deptonall($orgid);
                 if (is_array($deptid)) {
                     $dept = array_filter($deptid);
                     foreach ($dept as $key => $value) {
                         $deptid[$key] = "'" . $value . "'";
                     }
                 }
             } elseif ($ck_parent != 1) {
                 $deptid = $orgid;
             }
             if (is_array($deptid)) {
                 $uid = $this->employe_model->getEmpByDeptId($deptid, $dp, $statusid)->result_array();
                 foreach ($uid as $key => $value) {
                     $s[] = "'" . $value['userid'] . "'";
                 }
                 $s = array_unique($s, SORT_REGULAR);
             } else {
                 $uid = $this->employe_model->getEmpByDeptId($deptid, $dp, $statusid)->result_array();
                 if (empty($uid) != 1) {
                     foreach ($uid as $key => $value) {
                         $s[] = "'" . $value['userid'] . "'";
                     }
                 } else {
                     return false;
                 }
             }
         } elseif ($orgid != '' && $userid != 'undefined') {
             if ($ck_parent == 1) {
                 $deptid = $this->employe_model->deptonall($orgid);
                 if (is_array($deptid)) {
                     $dept = array_filter($deptid);
                     foreach ($dept as $key => $value) {
                         $deptid[$key] = "'" . $value . "'";
                     }
                 }
             } elseif ($ck_parent != 1) {
                 $deptid = $orgid;
             }
             $userar = explode(',', $userid);
             if (is_array($userar)) {
                 $userar = array_filter($userar);
             }
             foreach ($userar as $key => $val) {
                 $s[] = "'" . $val . "'";
             }
         } elseif ($orgid == '' && $userid == '') {
             redirect(base_url(), 'refresh');
         }
     }
     $s = array_unique($s, SORT_REGULAR);
     if ($awal > 0 && $awal != '') {
         $thn = date('Y', strtotime($awal));
         $bln = date('m', strtotime($awal));
         $thbl = $thn . $bln;
         $periode = (int) substr($thbl, 0, 6);
     }
     $data['day'] = array($bln, $thn);
     $kalender = CAL_EASTER_DEFAULT;
     $jml_hari = cal_days_in_month($kalender, $bln, $thn);
     for ($i = 1; $i <= $jml_hari; $i++) {
         $tanggal[$i] = $i;
     }
     $userin = array();
     $lstuser = array();
     $daftar = array();
     $total_in = 0;
     $holidate = array();
     $holidate2 = array();
     $dat = array();
     $ctemp = array();
     $temp = array();
     $var = 0;
     $var2 = 0;
     $day_of_w = 0;
     $date = array();
     $holiday = $this->employe_model->getHoliday($periode);
     foreach ($holiday as $key => $value) {
         $holidate2 = $this->dateRange($value['startdate'], $value['enddate']);
         $holidate = array_merge($holidate, $holidate2);
     }
     for ($d = 1; $d <= $jml_hari; $d++) {
         $day = Hari($d, $bln, $thn);
         if ($day == 6 || $day == 7) {
             $day_of_w++;
             $date[] = $thn . '-' . $bln . '-' . $d;
         }
     }
     $tempdate = array_intersect($holidate, $date);
     $cw = $day_of_w - count($tempdate);
     if (!empty($s)) {
         $a = $this->employe_model->getEmp($s, $deptid, $periode, $areaid, $statusid)->result_array();
         //Get Data User
         $deptname = '';
         foreach ($a as $k => $row) {
             $tgl = toThbl($row['date_shift']);
             // $tanggal = (int) substr($tgl, 6,8);
             if ($dp == '0' || $dp == '') {
                 $deptname = 'ALL';
             } else {
                 $deptname = $row['deptname'];
             }
             if (!isset($daftar[$row['userid']])) {
                 $lstuser[] = array('userid' => $row['userid']);
                 $daftar[$row['userid']] = array('deptname' => $row['deptname'], 'name' => $row['name'], 'gol' => $row['gol'], 'pt' => $row['companyname'], 'userid' => $row['userid'], 'title' => $row['title'], 'workinholiday' => $row['workinholiday']);
                 $asd[] = array('name' => $row['name']);
             }
         }
         foreach ($tanggal as $key) {
             if ($key <= 31 && $key > 0) {
                 foreach ($a as $k => $row) {
                     if (!isset($userin[$row['userid']][$key])) {
                         // $wo = date('d', strtotime(12));
                         $userin[$row['userid']][$key] = '';
                         $daftar[$row['userid']]['checkin'][$key] = $userin[$row['userid']][$key];
                     }
                 }
             }
         }
         foreach ($a as $k => $row) {
             $tgl = toThbl($row['date_shift']);
             $wo = (int) substr($tgl, 6, 8);
             foreach ($holidate as $key => $value) {
                 if ($value = $row['date_shift']) {
                     $userin[$row['userid']][$wo] = '';
                 }
             }
             $userin[$row['userid']][$wo] = $row['check_in'];
             if ($row['attendance'] == 'NWK' || $row['attendance'] == 'NWDS') {
                 $userin[$row['userid']][$wo] = '';
             }
             foreach ($date as $key => $value) {
                 if ($value == $row['date_shift']) {
                     $userin[$row['userid']][$wo] = '';
                 }
             }
             $daftar[$row['userid']]['checkin'][$wo] = $userin[$row['userid']][$wo];
         }
         //Get Check Out User
         foreach ($tanggal as $key) {
             if ($key <= 31 && $key > 0) {
                 foreach ($a as $k => $row) {
                     if (!isset($userout[$row['userid']][$key])) {
                         $userout[$row['userid']][$key] = '';
                         $daftar[$row['userid']]['checkout'][$key] = $userout[$row['userid']][$key];
                     }
                 }
             }
         }
         foreach ($a as $k => $row) {
             $tgl = toThbl($row['date_shift']);
             $wo = (int) substr($tgl, 6, 8);
             foreach ($holidate as $key => $value) {
                 if ($value = $row['date_shift']) {
                     $userout[$row['userid']][$wo] = '';
                 }
             }
             $userout[$row['userid']][$wo] = $row['check_out'];
             if ($row['attendance'] == 'NWK' || $row['attendance'] == 'NWDS') {
                 $userout[$row['userid']][$wo] = '';
             }
             foreach ($date as $key => $value) {
                 if ($value == $row['date_shift']) {
                     $userout[$row['userid']][$wo] = '';
                 }
             }
             $daftar[$row['userid']]['checkout'][$wo] = $userout[$row['userid']][$wo];
         }
         //Get Attendance User
         foreach ($tanggal as $key) {
             if ($key <= 31 && $key > 0) {
                 foreach ($a as $k => $row) {
                     if (!isset($useratt[$row['userid']][$key])) {
                         $useratt[$row['userid']][$key] = '';
                         $daftar[$row['userid']]['attendance'][$key] = $useratt[$row['userid']][$key];
                     }
                 }
             }
         }
         foreach ($a as $k => $row) {
             $tgl = toThbl($row['date_shift']);
             $wo = (int) substr($tgl, 6, 8);
             $holidate;
             foreach ($holidate as $as => $v) {
                 if ($v == $row['date_shift']) {
                     $temp[$wo] = 'L';
                 }
             }
             $useratt[$row['userid']][$wo] = $row['attendance'];
             $daftar[$row['userid']]['attendance'][$wo] = $useratt[$row['userid']][$wo];
         }
         //Get Count Late User
         $arr_in = array();
         $arr_uinp = array();
         $cshiftin = $this->employe_model->getShiftIn($s, $periode);
         foreach ($tanggal as $k) {
             foreach ($cshiftin as $key => $value) {
                 if (!isset($arr_in[$value['userid']][$k])) {
                     $arr_in[$value['userid']][$k] = '';
                     $daftar[$value['userid']]['jam_masuk'][$k] = $arr_in[$value['userid']][$k];
                 }
             }
         }
         foreach ($cshiftin as $key => $value) {
             $tgl = toThbl($value['rosterdate']);
             $wo = (int) substr($tgl, 6, 8);
             $arr_in[$value['userid']][$wo] = $value['check_in'];
             $daftar[$value['userid']]['jam_masuk'][$wo] = $arr_in[$value['userid']][$wo];
         }
         foreach ($tanggal as $key) {
             if ($key <= 31 && $key > 0) {
                 foreach ($a as $k => $row) {
                     if (!isset($arr_in[$row['userid']][$key])) {
                         $arr_in[$row['userid']][$key] = '';
                         $daftar[$row['userid']]['jam_masuk'][$key] = $arr_in[$row['userid']][$key];
                     }
                 }
             }
         }
         $late = array();
         foreach ($tanggal as $k) {
             foreach ($a as $key => $value) {
                 if ($userin[$value['userid']][$k] > $arr_in[$value['userid']][$k]) {
                     $late[$value['userid']][$k] = $userin[$value['userid']][$k];
                 } else {
                     $late[$value['userid']][$k] = '';
                 }
             }
         }
         //Get Early User
         $cshiftout = $this->employe_model->getShiftOut($s, $periode);
         foreach ($tanggal as $k) {
             foreach ($cshiftout as $key => $value) {
                 if (!isset($arr_out[$value['userid']][$k])) {
                     $arr_out[$value['userid']][$k] = '';
                     $daftar[$value['userid']]['jam_keluar'][$k] = $arr_out[$value['userid']][$k];
                 }
             }
         }
         foreach ($cshiftout as $key => $value) {
             $tgl = toThbl($value['rosterdate']);
             $wo = (int) substr($tgl, 6, 8);
             $arr_out[$value['userid']][$wo] = $value['check_out'];
             $daftar[$value['userid']]['jam_keluar'][$wo] = $arr_out[$value['userid']][$wo];
         }
         foreach ($tanggal as $key) {
             if ($key <= 31 && $key > 0) {
                 foreach ($a as $k => $row) {
                     if (!isset($arr_out[$row['userid']][$key])) {
                         $arr_out[$row['userid']][$key] = '';
                         $daftar[$row['userid']]['jam_keluar'][$key] = $arr_out[$row['userid']][$key];
                     }
                 }
             }
         }
         $early = array();
         foreach ($tanggal as $k) {
             foreach ($a as $key => $value) {
                 if ($userout[$value['userid']][$k] < $arr_out[$value['userid']][$k]) {
                     $early[$value['userid']][$k] = $userout[$value['userid']][$k];
                 } else {
                     $early[$value['userid']][$k] = '';
                 }
             }
         }
         //Inisialiasi variable
         $data['jml_hari'] = $jml_hari;
         $data['holi'] = $holidate;
         $data['lstuser'] = array_unique($lstuser, SORT_REGULAR);
         $da = array_unique($lstuser, SORT_REGULAR);
         //Get Total Late
         foreach ($da as $list) {
             for ($counter = 1; $counter <= $jml_hari; $counter++) {
                 if ($counter <= $tanggal) {
                     $day = Hari($counter, $bln, $thn);
                     if ($day != 6 && $day != 7) {
                         $InLate = $late[$list['userid']];
                         $InEarly = $early[$list['userid']];
                     }
                 }
             }
             $clate = 0;
             $cearly = 0;
             for ($i = 1; $i <= count($InLate); $i++) {
                 if ($InLate[$i] != 0 || $InLate[$i] != '') {
                     $clate++;
                 }
             }
             for ($i = 1; $i <= count($InEarly); $i++) {
                 if ($InEarly[$i] != 0 || $InEarly[$i] != '') {
                     $cearly++;
                 }
             }
             $daftar[$list['userid']]['total_late'] = $clate;
             $daftar[$list['userid']]['total_early'] = $cearly;
         }
         if (is_null($a) == TRUE) {
             for ($counter = 1; $counter <= $jml_hari; $counter++) {
                 $day = Hari($counter, $bln, $thn);
                 if ($day != 6 && $day != 7) {
                     $ctemp[] = $counter;
                 }
             }
             $range = count($ctemp);
         } else {
             foreach ($da as $list) {
                 for ($counter = 1; $counter <= $jml_hari; $counter++) {
                     if ($counter <= $tanggal) {
                         $day = Hari($counter, $bln, $thn);
                         if ($day != 6 && $day != 7) {
                             $in2 = $daftar[$list['userid']]['checkin'];
                             $out2 = $daftar[$list['userid']]['checkout'];
                             $ctemp[] = $counter;
                         }
                     }
                 }
                 $cin = 0;
                 for ($i = 1; $i <= count($in2); $i++) {
                     if ($in2[$i] == 0) {
                         $cin++;
                     }
                 }
                 $cout = 0;
                 for ($i = 1; $i <= count($out2); $i++) {
                     if ($out2[$i] == 0) {
                         $cout++;
                     }
                 }
                 $daftar[$list['userid']]['total_in'] = $cin;
                 $daftar[$list['userid']]['total_out'] = $cout;
             }
         }
         $data['range'] = $jml_hari - $day_of_w;
         $data['day_of_w'] = $cw;
         $data['day_of_h'] = count($temp);
         $data['employe'] = $daftar;
         $data['title'] = 'Laporan Absensi Per Department';
         $data['department'] = $deptname;
         $data['tanggal'] = $tanggal;
         $data['temp'] = $temp;
         $month_year = date('F Y', strtotime($awal));
         $datestart = strtotime(date('Y-m-01', strtotime($awal)));
         $datestop = strtotime(date('Y-m-t', strtotime($awal)));
         $data['month_year'] = $month_year;
         $data['periode'] = thblToText($periode);
         $data['bulan'] = toBln($periode);
         if ($excelid == 1) {
             $datavw = '';
             $dataview = '';
             $dataview = $this->load->view('hpu/recapabsen', $data);
             $datavw = $datavw . $dataview;
             header("Content-type: application/x-msdownload");
             header("Content-Disposition: attachment; filename=monthlyabsence.xls");
             echo "{$datavw}";
         } else {
             $this->load->view("hpu/recapabsen", $data);
         }
     }
 }