db->query("SELECT * FROM inv_jenis_barang ORDER BY id_jenis_barang LIMIT $num OFFSET $offset"); return $query; } function get_jenis_barang($id){ $query = $this->db->query("SELECT nama_jenis FROM inv_jenis_barang WHERE id_jenis_barang = '$id' "); foreach ($query->result() as $row){ $nama_jenis_barang = $row->nama_jenis; return $nama_jenis_barang; } } function save_jenis_barang($data){ $this->db->insert('inv_jenis_barang', $data); } function update_jenis_barang($id, $data){ $this->db->where('id_jenis_barang', $id); $this->db->update('inv_jenis_barang', $data); } function delete_jenis_barang($id){ $this->db->where('id_jenis_barang',$id); $this->db->delete('inv_jenis_barang'); } /* Unit Kerja */ function list_unit_kerja($num, $offset){ $query = $this->db->query("SELECT * FROM inv_unit_kerja ORDER BY id_unit_kerja LIMIT $num OFFSET $offset"); return $query; } function get_unit_kerja($id){ $query = $this->db->query("SELECT nama_unit FROM inv_unit_kerja WHERE id_unit_kerja = '$id' "); foreach ($query->result() as $row){ $nama_unit_kerja = $row->nama_unit; return $nama_unit_kerja; } } function save_unit_kerja($data){ $this->db->insert('inv_unit_kerja', $data); } function update_unit_kerja($id, $data){ $this->db->where('id_unit_kerja', $id); $this->db->update('inv_unit_kerja', $data); } function delete_unit_kerja($id){ $this->db->where('id_unit_kerja',$id); $this->db->delete('inv_unit_kerja'); } /* Daftar Inventaris */ function list_daftar($num, $offset){ $query = $this->db->query(" SELECT *, uk.nama_unit, jb.nama_jenis, s.nama_satuan FROM inv_barang as i JOIN inv_unit_kerja as uk ON uk.id_unit_kerja = i.id_unit_kerja JOIN inv_jenis_barang as jb ON jb.id_jenis_barang = i.id_jenis_barang JOIN inv_satuan as s ON s.id_satuan = i.id_satuan ORDER BY id_inv_barang LIMIT $num OFFSET $offset"); return $query; } function filter_daftar($unit, $jenis, $num, $offset){ $query = $this->db->query(" SELECT *, uk.nama_unit, jb.nama_jenis, s.nama_satuan FROM inv_barang as i JOIN inv_unit_kerja as uk ON uk.id_unit_kerja = i.id_unit_kerja JOIN inv_jenis_barang as jb ON jb.id_jenis_barang = i.id_jenis_barang JOIN inv_satuan as s ON s.id_satuan = i.id_satuan WHERE i.id_unit_kerja = '$unit' AND i.id_jenis_barang = '$jenis' ORDER BY id_inv_barang LIMIT $num OFFSET $offset"); return $query; } function filter_daftar_unit($unit, $num, $offset){ $query = $this->db->query(" SELECT *, uk.nama_unit, jb.nama_jenis, s.nama_satuan FROM inv_barang as i JOIN inv_unit_kerja as uk ON uk.id_unit_kerja = i.id_unit_kerja JOIN inv_jenis_barang as jb ON jb.id_jenis_barang = i.id_jenis_barang JOIN inv_satuan as s ON s.id_satuan = i.id_satuan WHERE i.id_unit_kerja = '$unit' ORDER BY i.id_jenis_barang LIMIT $num OFFSET $offset"); return $query; } function filter_daftar_jenis($jenis, $num, $offset){ $query = $this->db->query(" SELECT *, uk.nama_unit, jb.nama_jenis, s.nama_satuan FROM inv_barang as i JOIN inv_unit_kerja as uk ON uk.id_unit_kerja = i.id_unit_kerja JOIN inv_jenis_barang as jb ON jb.id_jenis_barang = i.id_jenis_barang JOIN inv_satuan as s ON s.id_satuan = i.id_satuan WHERE i.id_jenis_barang = '$jenis' ORDER BY i.id_unit_kerja LIMIT $num OFFSET $offset"); return $query; } function get_daftar_detail($id){ $query = $this->db->query("SELECT * FROM inv_barang WHERE id_inv_barang = '$id' "); return $query; } function get_drop_unit(){ $query = $this->db->query('SELECT id_unit_kerja, nama_unit FROM inv_unit_kerja ORDER BY id_unit_kerja asc')->result(); return $query; } function get_drop_jenis(){ $query = $this->db->query('SELECT id_jenis_barang, nama_jenis FROM inv_jenis_barang ORDER BY id_jenis_barang asc')->result(); return $query; } function get_drop_satuan(){ $query = $this->db->query('SELECT id_satuan, nama_satuan FROM inv_satuan ORDER BY id_satuan asc')->result(); return $query; } function count_filter($unit, $jenis){ $query = $this->db->query("SELECT COUNT(id_inv_barang) as jml_filter FROM inv_barang WHERE id_unit_kerja = '$unit' AND id_jenis_barang = '$jenis'"); foreach ($query->result() as $row){ $cf = $row->jml_filter; return $cf; } } function count_filter_unit($unit){ $query = $this->db->query("SELECT COUNT(id_inv_barang) as jml_filter FROM inv_barang WHERE id_unit_kerja = '$unit'"); foreach ($query->result() as $row){ $cf = $row->jml_filter; return $cf; } } function count_filter_jenis($jenis){ $query = $this->db->query("SELECT COUNT(id_inv_barang) as jml_filter FROM inv_barang WHERE id_jenis_barang = '$jenis'"); foreach ($query->result() as $row){ $cf = $row->jml_filter; return $cf; } } function cari_daftar($kunci, $kunci2){ $query = $this->db->query(" SELECT *, uk.nama_unit, jb.nama_jenis, s.nama_satuan FROM inv_barang as i JOIN inv_unit_kerja as uk ON uk.id_unit_kerja = i.id_unit_kerja JOIN inv_jenis_barang as jb ON jb.id_jenis_barang = i.id_jenis_barang JOIN inv_satuan as s ON s.id_satuan = i.id_satuan WHERE i.nama_barang LIKE '%".$kunci."%' OR i.nama_barang LIKE '%".$kunci2."%' ORDER BY i.id_unit_kerja, i.id_jenis_barang"); return $query; } function count_cari($kunci, $kunci2){ $query = $this->db->query("SELECT COUNT(id_inv_barang) as jml_cari FROM inv_barang WHERE nama_barang LIKE '%".$kunci."%' OR nama_barang LIKE '%".$kunci2."%'"); foreach ($query->result() as $row){ $jc = $row->jml_cari; return $jc; } } function save_daftar($data){ $this->db->insert('inv_barang', $data); } function update_daftar($id, $data){ $this->db->where('id_inv_barang', $id); $this->db->update('inv_barang', $data); } function delete_daftar($id){ $this->db->where('id_inv_barang',$id); $this->db->delete('inv_barang'); } }