From 77a65abdb50c58cb7537e1385d3e2df554a14d30 Mon Sep 17 00:00:00 2001 From: Sendi Pebriyan Date: Tue, 2 Jun 2026 08:07:14 +0700 Subject: [PATCH] Active Menu Attendance Monthly Penambahan Modal rekapitulasi kehadiran perbulan --- application/controllers/Attendancemonthly.php | 103 +++++ application/controllers/Jurnal.php | 14 +- .../views/employees/attendance_monthly.php | 390 ++++++++++++++++++ application/views/jurnal/layout.php | 10 + application/views/partials/header.php | 13 +- 5 files changed, 520 insertions(+), 10 deletions(-) create mode 100644 application/controllers/Attendancemonthly.php create mode 100644 application/views/employees/attendance_monthly.php diff --git a/application/controllers/Attendancemonthly.php b/application/controllers/Attendancemonthly.php new file mode 100644 index 0000000..9da4956 --- /dev/null +++ b/application/controllers/Attendancemonthly.php @@ -0,0 +1,103 @@ +load->database(); + } + + public function index() + { + $data = [ + "active_menu" => "attendance_monthly" + ]; + + $this->load->view('partials/header', $data); + $this->load->view('employees/attendance_monthly'); + $this->load->view('partials/footer'); + } + + public function get_data() + { + $date = $this->input->get('date') . '-01'; + + if(!$date){ + $date = date('Y-m-d'); + } + + $data = $this->db->query(" + SELECT + a.*, + e.employee_code, + e.full_name + FROM k_attendance_monthly a + LEFT JOIN k_employees e ON e.id = a.employee_id + WHERE a.month = '$date' + ORDER BY a.updated_at DESC + ")->result(); + + $rows = []; + $no = 1; + + foreach($data as $row){ + + $rows[] = [ + $no++, + $row->employee_code, + $row->full_name, + tanggal_indo($row->month,'F Y'), + $row->status, + ' + + ' + ]; + } + + echo json_encode([ + 'data' => $rows + ]); + } + + // public function detail($id) + // { + // echo json_encode( + // $this->db->get_where('k_attendance_monthly',['id'=>$id])->row() + // ); + // } + + public function detail($id, $month) + { + $header = $this->db + ->select('a.*, e.full_name, e.employee_code') + ->from('k_attendance_monthly a') + ->join('k_employees e','e.id = a.employee_id', 'left') + ->where('a.id',$id) + ->where('a.month',$month) + ->get() + ->row(); + + $startDate = $month; + $endDate = substr($month, 0, 7) . date('-t'); + + $detail = $this->db + ->select('a.attendance_date, a.attendance_status, b.shift_name') + ->from('k_attendances a') + ->join('k_shifts b', 'b.id = a.shift_id', 'left') + ->where('a.employee_id', $header->employee_id) + ->where('a.attendance_date >=', $startDate) + ->where('a.attendance_date <=', $endDate) + ->get() + ->result(); + + echo json_encode([ + 'header'=>$header, + 'detail'=>$detail + ]); + } + +} \ No newline at end of file diff --git a/application/controllers/Jurnal.php b/application/controllers/Jurnal.php index 198639d..681d921 100644 --- a/application/controllers/Jurnal.php +++ b/application/controllers/Jurnal.php @@ -141,13 +141,13 @@ class Jurnal extends CI_Controller { $debit = $this->input->post('debit'); $kredit = $this->input->post('kredit'); - if (array_sum($debit) != array_sum($kredit)) { - echo json_encode([ - 'status'=>false, - 'message'=>'Debit & Kredit tidak balance!' - ]); - return; - } + if (array_sum($debit) != array_sum($kredit)) { + echo json_encode([ + 'status'=>false, + 'message'=>'Debit & Kredit tidak balance!' + ]); + return; + } $this->db->trans_start(); diff --git a/application/views/employees/attendance_monthly.php b/application/views/employees/attendance_monthly.php new file mode 100644 index 0000000..04c976c --- /dev/null +++ b/application/views/employees/attendance_monthly.php @@ -0,0 +1,390 @@ + + +
+ +
+ +
+ +
+ Tanggal +
+ +
+ + +
+ Monitoring Absensi Bulanan +
+ + + +
+ +
+ + + + + + + + + + + + + + +
NoKodeNamaPeriodeStatusAksi
+ +
+ +
+ +
+ +
+ + + + + + \ No newline at end of file diff --git a/application/views/jurnal/layout.php b/application/views/jurnal/layout.php index 91879cb..6d7faf3 100644 --- a/application/views/jurnal/layout.php +++ b/application/views/jurnal/layout.php @@ -402,6 +402,16 @@ $('#btnSimpan').click(function(){ Swal.fire('Warning','Harap Isi Semua Kolom!','warning'); // ✅ FIX add all collumn must be filled return; } + + if($('#keterangan').val().trim() === ''){ + Swal.fire('Warning','Keterangan tidak boleh kosong!','warning'); + return; + } + + if(!$('#tanggal').val()){ + Swal.fire('Warning','Tanggal tidak boleh kosong!','warning'); + return; + } // lanjut simpan $.post("", { diff --git a/application/views/partials/header.php b/application/views/partials/header.php index 5be8ece..23b5171 100644 --- a/application/views/partials/header.php +++ b/application/views/partials/header.php @@ -258,17 +258,24 @@
  • - Monitoring Absensi - -
  • +
  • + + + + Absensi Bulanan + +
  • + +