diff --git a/application/controllers/Accounts.php b/application/controllers/Accounts.php index 2479bf4..1aeaacd 100644 --- a/application/controllers/Accounts.php +++ b/application/controllers/Accounts.php @@ -1,168 +1,171 @@ -load->model('DynamicModel', 'dm'); - - if (!$this->session->userdata('logged_in')) { - redirect('auth'); - } - } - - public function index() - { - - if($this->session->userdata('role') != 'Admin'){ - show_error('Akses ditolak', 403); - } - - $data = [ - "active_menu" => "accounts", - "parent_accounts" => $this->db->get('accounts')->result() - ]; - - $this->load->view('partials/header', $data); - $this->load->view('accounts/layout', $data); - $this->load->view('partials/footer'); - } - - public function get_data() - { - $this->dm->setTable('accounts') - ->setColumn( - [null,'kode_akun','nama_akun','tipe','posisi','kategori',null], - ['kode_akun','nama_akun','tipe'], - ['kode_akun'=>'ASC'] - ); - - $list = $this->dm->get_datatables(); - - $data = []; - $no = $_POST['start']; - - foreach ($list as $row) { - $no++; - - $data[] = [ - $no, - $row->kode_akun, - $row->nama_akun, - ucfirst($row->tipe), - ucfirst($row->posisi), - ucfirst($row->kategori), - ' - - - ' - ]; - } - - echo json_encode([ - "draw" => $_POST['draw'], - "recordsTotal" => $this->dm->count_all(), - "recordsFiltered" => $this->dm->count_filtered(), - "data" => $data - ]); - } - - // ================= SAVE - public function save() - { - $tipe = $this->input->post('tipe'); - - $data = [ - 'kode_akun' => $this->input->post('kode_akun'), - 'nama_akun' => $this->input->post('nama_akun'), - 'tipe' => $tipe, - 'posisi' => in_array($tipe, ['asset','expense']) ? 'debit' : 'kredit', - 'kategori' => in_array($tipe, ['asset','liability','equity']) ? 'neraca' : 'laba_rugi', - 'parent_id' => $this->input->post('parent_id') ?: NULL - ]; - - $insert = $this->dm->setTable('accounts')->insert($data); - - if($insert){ - log_activity( - 'Accounts', - 'create', - 'Menambah akun: '.$data['kode_akun'].' - '.$data['nama_akun'] - ); - } - - echo json_encode([ - 'status' => $insert ? true : false, - 'message' => $insert ? 'Data berhasil disimpan' : 'Gagal simpan' - ]); - } - - // ================= UPDATE - public function update() - { - $id = $this->input->post('id'); - $tipe = $this->input->post('tipe'); - - $data = [ - 'kode_akun' => $this->input->post('kode_akun'), - 'nama_akun' => $this->input->post('nama_akun'), - 'tipe' => $tipe, - 'posisi' => in_array($tipe, ['asset','expense']) ? 'debit' : 'kredit', - 'kategori' => in_array($tipe, ['asset','liability','equity']) ? 'neraca' : 'laba_rugi', - 'parent_id' => $this->input->post('parent_id') ?: NULL - ]; - - $update = $this->dm->setTable('accounts')->update($id, $data); - - if($update){ - log_activity( - 'Accounts', - 'update', - 'Update akun ID '.$id.' menjadi: '.$data['kode_akun'].' - '.$data['nama_akun'] - ); - } - - echo json_encode([ - 'status' => $update ? true : false, - 'message' => $update ? 'Data berhasil diupdate' : 'Gagal update' - ]); - } - - public function detail($id) - { - $data = $this->dm->setTable('accounts')->find($id); - echo json_encode($data); - } - - public function delete($id) - { - // cek apakah jadi parent - $child = $this->db->where('parent_id',$id)->count_all_results('accounts'); - - if($child > 0){ - echo json_encode([ - 'status'=>false, - 'message'=>'Tidak bisa hapus, akun punya child' - ]); - return; - } - - $delete = $this->dm->setTable('accounts')->delete($id); - - if($delete){ - log_activity( - 'Accounts', - 'delete', - 'Menghapus akun ID '.$id, - 'success' - ); - } - - echo json_encode([ - 'status' => $delete ? true : false, - 'message' => $delete ? 'Data berhasil dihapus' : 'Gagal hapus' - ]); - } +load->model('DynamicModel', 'dm'); + + if (!$this->session->userdata('logged_in')) { + redirect('auth'); + } + } + + public function index() + { + + if($this->session->userdata('role') != 'Admin'){ + show_error('Akses ditolak', 403); + } + + $data = [ + "active_menu" => "accounts", + "parent_accounts" => $this->db->get('accounts')->result() + ]; + + $this->load->view('partials/header', $data); + $this->load->view('accounts/layout', $data); + $this->load->view('partials/footer'); + } + + public function get_data() + { + $this->dm->setTable('accounts') + ->setColumn( + [null,'kode_akun','nama_akun','tipe','posisi','kategori',null], + ['kode_akun','nama_akun','tipe'], + ['kode_akun'=>'ASC'] + ); + + $list = $this->dm->get_datatables(); + + $data = []; + $no = $_POST['start']; + + foreach ($list as $row) { + $no++; + + $data[] = [ + $no, + $row->kode_akun, + $row->priority, + $row->nama_akun, + ucfirst($row->tipe), + ucfirst($row->posisi), + ucfirst($row->kategori), + ' + + + ' + ]; + } + + echo json_encode([ + "draw" => $_POST['draw'], + "recordsTotal" => $this->dm->count_all(), + "recordsFiltered" => $this->dm->count_filtered(), + "data" => $data + ]); + } + + // ================= SAVE + public function save() + { + $tipe = $this->input->post('tipe'); + + $data = [ + 'kode_akun' => $this->input->post('kode_akun'), + 'nama_akun' => $this->input->post('nama_akun'), + 'tipe' => $tipe, + 'posisi' => in_array($tipe, ['asset','expense']) ? 'debit' : 'kredit', + 'kategori' => in_array($tipe, ['asset','liability','equity']) ? 'neraca' : 'laba_rugi', + 'parent_id' => $this->input->post('parent_id') ?: NULL, + 'priority' => $this->input->post('priority') ?: NULL + ]; + + $insert = $this->dm->setTable('accounts')->insert($data); + + if($insert){ + log_activity( + 'Accounts', + 'create', + 'Menambah akun: '.$data['kode_akun'].' - '.$data['nama_akun'] + ); + } + + echo json_encode([ + 'status' => $insert ? true : false, + 'message' => $insert ? 'Data berhasil disimpan' : 'Gagal simpan' + ]); + } + + // ================= UPDATE + public function update() + { + $id = $this->input->post('id'); + $tipe = $this->input->post('tipe'); + + $data = [ + 'kode_akun' => $this->input->post('kode_akun'), + 'nama_akun' => $this->input->post('nama_akun'), + 'tipe' => $tipe, + 'posisi' => in_array($tipe, ['asset','expense']) ? 'debit' : 'kredit', + 'kategori' => in_array($tipe, ['asset','liability','equity']) ? 'neraca' : 'laba_rugi', + 'parent_id' => $this->input->post('parent_id') ?: NULL, + 'priority' => $this->input->post('priority') ?: NULL + ]; + + $update = $this->dm->setTable('accounts')->update($id, $data); + + if($update){ + log_activity( + 'Accounts', + 'update', + 'Update akun ID '.$id.' menjadi: '.$data['kode_akun'].' - '.$data['nama_akun'] + ); + } + + echo json_encode([ + 'status' => $update ? true : false, + 'message' => $update ? 'Data berhasil diupdate' : 'Gagal update' + ]); + } + + public function detail($id) + { + $data = $this->dm->setTable('accounts')->find($id); + echo json_encode($data); + } + + public function delete($id) + { + // cek apakah jadi parent + $child = $this->db->where('parent_id',$id)->count_all_results('accounts'); + + if($child > 0){ + echo json_encode([ + 'status'=>false, + 'message'=>'Tidak bisa hapus, akun punya child' + ]); + return; + } + + $delete = $this->dm->setTable('accounts')->delete($id); + + if($delete){ + log_activity( + 'Accounts', + 'delete', + 'Menghapus akun ID '.$id, + 'success' + ); + } + + echo json_encode([ + 'status' => $delete ? true : false, + 'message' => $delete ? 'Data berhasil dihapus' : 'Gagal hapus' + ]); + } } \ No newline at end of file diff --git a/application/controllers/Items.php b/application/controllers/Items.php index 51ca787..5bcd923 100644 --- a/application/controllers/Items.php +++ b/application/controllers/Items.php @@ -646,7 +646,7 @@ class Items extends CI_Controller { public function get_accounts() { $data = $this->db - ->where_in('kode_akun', [101,102,201]) + ->where_in('kode_akun', [101,102,201,122,125,105]) ->order_by('kode_akun','ASC') ->get('accounts') ->result(); diff --git a/application/controllers/Neraca.php b/application/controllers/Neraca.php index 837f189..8b8452b 100644 --- a/application/controllers/Neraca.php +++ b/application/controllers/Neraca.php @@ -101,7 +101,7 @@ class Neraca extends CI_Controller { } $this->db->group_by('a.id'); - $this->db->order_by('a.kode_akun','ASC'); + $this->db->order_by('a.priority','ASC'); $rows = $this->db->get()->result(); diff --git a/application/views/accounts/layout.php b/application/views/accounts/layout.php index b6c82de..454b16d 100644 --- a/application/views/accounts/layout.php +++ b/application/views/accounts/layout.php @@ -1,215 +1,223 @@ -
-
-
- -
-
Chart of Account (COA)
- -
- -
- - - - - - - - - - - - - -
NoKodeNamaTipePosisiKategoriAksi
-
- -
-
-
- - - - - \ No newline at end of file diff --git a/application/views/peralatan_teknisi/layout.php b/application/views/peralatan_teknisi/layout.php index 9d3bc00..a27f7c7 100644 --- a/application/views/peralatan_teknisi/layout.php +++ b/application/views/peralatan_teknisi/layout.php @@ -995,7 +995,7 @@ $(function(){ refreshTable(dtKembalikan, kembalikanData); $('#scanKembalikan').val('').focus(); - Swal.fire({icon:'success', text:'Barang ditambahkan ke daftar pengembalian', timer:1200, showConfirmButton:false}); + // Swal.fire({icon:'success', text:'Barang ditambahkan ke daftar pengembalian', timer:1200, showConfirmButton:false}); }, 'json'); } @@ -1059,7 +1059,7 @@ $(function(){ refreshTable(dtDibawa, dibawaData); $('#scanDibawa').val('').focus(); - Swal.fire({icon:'success', text:'Barang ditambahkan ke daftar bawaan', timer:1200, showConfirmButton:false}); + // Swal.fire({icon:'success', text:'Barang ditambahkan ke daftar bawaan', timer:1200, showConfirmButton:false}); }, 'json'); } diff --git a/uploads/karyawan/568032fce0712f5d4f41fc3f8129be6f.jpeg b/uploads/karyawan/568032fce0712f5d4f41fc3f8129be6f.jpeg deleted file mode 100644 index 14c683f..0000000 Binary files a/uploads/karyawan/568032fce0712f5d4f41fc3f8129be6f.jpeg and /dev/null differ diff --git a/uploads/karyawan/6fef16c815c572bb0a3fe6e4bed0844d.jpeg b/uploads/karyawan/6fef16c815c572bb0a3fe6e4bed0844d.jpeg deleted file mode 100644 index e704aa7..0000000 Binary files a/uploads/karyawan/6fef16c815c572bb0a3fe6e4bed0844d.jpeg and /dev/null differ diff --git a/uploads/karyawan/7087114e5e6957315f7398e070fcdef9.jpeg b/uploads/karyawan/7087114e5e6957315f7398e070fcdef9.jpeg deleted file mode 100644 index b2a57f7..0000000 Binary files a/uploads/karyawan/7087114e5e6957315f7398e070fcdef9.jpeg and /dev/null differ diff --git a/uploads/karyawan/b20b0041b8dedbc289730812365f92c7.jpeg b/uploads/karyawan/b20b0041b8dedbc289730812365f92c7.jpeg deleted file mode 100644 index 052ef35..0000000 Binary files a/uploads/karyawan/b20b0041b8dedbc289730812365f92c7.jpeg and /dev/null differ