load->model('m_inventaris');
if ($this->session->userdata("logged_in") == FALSE){
redirect("user/login", "location");
}
}
/**************************/
/*** Jenis Barang ***/
/**************************/
public function jenis_barang(){
$data['base_url'] = base_url().'inventaris/jenis_barang';
$data['total_rows'] = $this->db->count_all('inv_jenis_barang');
$data['per_page'] = '10';
$data['uri_segment']= '3';
$data['first_link'] = 'Pertama';
$data['last_link'] = 'Terakhir';
$data['next_link'] = '>';
$data['prev_link'] = '<';
$this->pagination->initialize($data);
$offset = $this->uri->segment(3);
if ($offset == '') { $offset = 0; }
$paging = $data['per_page'];
// Otoritas //
$id_menu = '7';
$menu["id_menu"] = $id_menu;
$data['title'] = 'UNLASYS - Jenis Barang Inventaris';
$data["query"] = $this->m_inventaris->list_jenis_barang($paging, $offset);
$this->load->view('v_header.php',$data);
$this->load->view('v_menu.php',$menu);
$this->load->view('inventaris/v_jenis_barang.php');
$this->load->view('v_footer.php');
}
public function tambah_jenis_barang(){
$this->_validation_jenis_barang();
if($this->form_validation->run()==false){
$data["title"] = "UNLASYS - Tambah Jenis Barang";
$data["judul_form"] = "Tambah";
$data["nama_jenis_barang"] = "";
$data["action_form"]= base_url().'inventaris/tambah_jenis_barang';
// Otoritas //
$id_menu = '7';
$menu["id_menu"] = $id_menu;
$this->load->view('v_header.php',$data);
$this->load->view('v_menu.php',$menu);
$this->load->view('inventaris/v_jenis_barang_form.php');
$this->load->view('v_footer.php');
}else{
$data = array('nama_jenis' => $this->input->post('nama_jenis_barang'));
$this->m_inventaris->save_jenis_barang($data);
$this->session->set_flashdata('success', 'Data Jenis Barang berhasil ditambah');
redirect('inventaris/jenis_barang');
}
}
public function ubah_jenis_barang($id_jenis_barang){
$this->_validation_jenis_barang();
if($this->form_validation->run()==false){
$data["title"] = "UNLASYS - Ubah Jenis Barang";
$data["judul_form"] = "Ubah";
$data["action_form"]= base_url().'inventaris/ubah_jenis_barang/'.$id_jenis_barang;
$data["nama_jenis_barang"] = $this->m_inventaris->get_jenis_barang($id_jenis_barang);
// Otoritas //
$id_menu = '7';
$menu["id_menu"] = $id_menu;
$this->load->view('v_header.php',$data);
$this->load->view('v_menu.php',$menu);
$this->load->view('inventaris/v_jenis_barang_form.php');
$this->load->view('v_footer.php');
}else{
$data = array('nama_jenis' => $this->input->post('nama_jenis_barang'));
$this->m_inventaris->update_jenis_barang($id_jenis_barang, $data);
$this->session->set_flashdata('success', 'Data Kategori Materi berhasil diubah');
redirect('inventaris/jenis_barang');
}
}
public function hapus_jenis_barang($id_jenis_barang){
$this->m_inventaris->delete_jenis_barang($id_jenis_barang);
$this->session->set_flashdata('success', 'Data Jenis Barang berhasil dihapus');
redirect('inventaris/jenis_barang');
}
function _validation_jenis_barang(){
$this->form_validation->set_rules("nama_jenis_barang", "Nama Jenis Barang", "required|max_length[30]");
$this->form_validation->set_message("required","%s tidak boleh kosong");
$this->form_validation->set_message("max_length", "%s tidak boleh lebih dari %s karakter");
$this->form_validation->set_error_delimiters("
", "
");
}
/**********************/
/*** Unit Kerja ***/
/**********************/
public function unit_kerja(){
$data['base_url'] = base_url().'inventaris/unit_kerja';
$data['total_rows'] = $this->db->count_all('inv_unit_kerja');
$data['per_page'] = '10';
$data['uri_segment']= '3';
$data['first_link'] = 'Pertama';
$data['last_link'] = 'Terakhir';
$data['next_link'] = '>';
$data['prev_link'] = '<';
$this->pagination->initialize($data);
$offset = $this->uri->segment(3);
if ($offset == '') { $offset = 0; }
$paging = $data['per_page'];
$data['title'] = 'UNLASYS - Unit Kerja Inventaris';
$data["query"] = $this->m_inventaris->list_unit_kerja($paging, $offset);
$this->load->view('v_header.php',$data);
$this->load->view('v_menu.php');
$this->load->view('inventaris/v_unit_kerja.php');
$this->load->view('v_footer.php');
}
public function tambah_unit_kerja(){
$this->_validation_unit_kerja();
if($this->form_validation->run()==false){
$data["title"] = "UNLASYS - Tambah Unit Kerja";
$data["judul_form"] = "Tambah";
$data["nama_unit_kerja"] = "";
$data["action_form"]= base_url().'inventaris/tambah_unit_kerja';
$this->load->view('v_header.php',$data);
$this->load->view('v_menu.php');
$this->load->view('inventaris/v_unit_kerja_form.php');
$this->load->view('v_footer.php');
}else{
$data = array('nama_unit' => $this->input->post('nama_unit_kerja'));
$this->m_inventaris->save_unit_kerja($data);
$this->session->set_flashdata('success', 'Data Unit Kerja berhasil ditambah');
redirect('inventaris/unit_kerja');
}
}
public function ubah_unit_kerja($id_unit_kerja){
$this->_validation_unit_kerja();
if($this->form_validation->run()==false){
$data["title"] = "UNLASYS - Ubah Unit Kerja";
$data["judul_form"] = "Ubah";
$data["action_form"]= base_url().'inventaris/ubah_unit_kerja/'.$id_unit_kerja;
$data["nama_unit_kerja"] = $this->m_inventaris->get_unit_kerja($id_unit_kerja);
$this->load->view('v_header.php',$data);
$this->load->view('v_menu.php');
$this->load->view('inventaris/v_unit_kerja_form.php');
$this->load->view('v_footer.php');
}else{
$data = array('nama_unit' => $this->input->post('nama_unit_kerja'));
$this->m_inventaris->update_unit_kerja($id_unit_kerja, $data);
$this->session->set_flashdata('success', 'Data Unit Kerja berhasil diubah');
redirect('inventaris/unit_kerja');
}
}
public function hapus_unit_kerja($id_unit_kerja){
$this->m_inventaris->delete_unit_kerja($id_unit_kerja);
$this->session->set_flashdata('success', 'Data Unit Kerja berhasil dihapus');
redirect('inventaris/unit_kerja');
}
function _validation_unit_kerja(){
$this->form_validation->set_rules("nama_unit_kerja", "Nama Unit Kerja", "required|max_length[50]");
$this->form_validation->set_message("required","%s tidak boleh kosong");
$this->form_validation->set_message("max_length", "%s tidak boleh lebih dari %s karakter");
$this->form_validation->set_error_delimiters("", "
");
}
/******************/
/*** Daftar ***/
/******************/
public function daftar(){
$data['base_url'] = base_url().'inventaris/daftar';
$data['total_rows'] = $this->db->count_all('inv_barang');
$data['per_page'] = '10';
$data['uri_segment']= '3';
$data['first_link'] = 'Pertama';
$data['last_link'] = 'Terakhir';
$data['next_link'] = '>';
$data['prev_link'] = '<';
$this->pagination->initialize($data);
$offset = $this->uri->segment(3);
if ($offset == '') { $offset = 0; }
$paging = $data['per_page'];
// Otoritas //
$id_menu = '8';
$menu["id_menu"] = $id_menu;
$data["id_unit_kerja"] = "";
$data["id_jenis_barang"] = "";
$data["drop_unit_kerja"] = $this->m_inventaris->get_drop_unit();
$data["drop_jenis_barang"] = $this->m_inventaris->get_drop_jenis();
$data["nama_unit_kerja"] = "Keseluruhan";
$data["nama_jenis_barang"] = "";
$data["jml_cari"] = "";
$data["title"] = "UNLASYS - Daftar Inventaris'";
$data["query"] = $this->m_inventaris->list_daftar($paging, $offset);
$this->load->view('v_header.php',$data);
$this->load->view('v_menu.php',$menu);
$this->load->view('inventaris/v_daftar.php');
$this->load->view('v_footer.php');
}
public function daftar_filter(){
$unit_kerja = $this->input->post('id_unit_kerja');
$jenis_barang = $this->input->post('id_jenis_barang');
$offset = $this->uri->segment(3);
if ($offset == '') { $offset = 0; }
$paging = '10';
if($unit_kerja == NULL){
if($jenis_barang == NULL){
redirect('inventaris/daftar');
}else{
$data["query"] = $this->m_inventaris->filter_daftar_jenis($jenis_barang, $paging, $offset);
$count_filter = $this->m_inventaris->count_filter_jenis($jenis_barang);
$nama_jenis = $this->m_inventaris->get_jenis_barang($jenis_barang);
}
}else{
if($jenis_barang == NULL){
$data["query"] = $this->m_inventaris->filter_daftar_unit($unit_kerja, $paging, $offset);
$count_filter = $this->m_inventaris->count_filter_unit($unit_kerja);
$nama_jenis = 'Keseluruhan';
}else{
$data["query"] = $this->m_inventaris->filter_daftar($unit_kerja, $jenis_barang, $paging, $offset);
$count_filter = $this->m_inventaris->count_filter($unit_kerja, $jenis_barang);
$nama_jenis = $this->m_inventaris->get_jenis_barang($jenis_barang);
}
}
$data['base_url'] = base_url().'inventaris/daftar_filter';
$data['total_rows'] = $count_filter;
$data['per_page'] = '10';
$data['uri_segment']= '3';
$data['first_link'] = 'Pertama';
$data['last_link'] = 'Terakhir';
$data['next_link'] = '>';
$data['prev_link'] = '<';
$this->pagination->initialize($data);
// Otoritas //
$id_menu = '8';
$menu["id_menu"] = $id_menu;
$data["id_unit_kerja"] = $unit_kerja;
$data["id_jenis_barang"] = $jenis_barang;
$data["drop_unit_kerja"] = $this->m_inventaris->get_drop_unit();
$data["drop_jenis_barang"] = $this->m_inventaris->get_drop_jenis();
$data["nama_unit_kerja"] = $this->m_inventaris->get_unit_kerja($unit_kerja);
$data["jml_cari"] = "";
$reset = anchor('inventaris/daftar','',array('class'=>'btn btn-danger btn-circle'));
$data["nama_jenis_barang"] = " - Jenis Barang ".$nama_jenis." ".$reset;
$data["title"] = "UNLASYS - Daftar Filter Inventaris'";
$this->load->view('v_header.php',$data);
$this->load->view('v_menu.php',$menu);
$this->load->view('inventaris/v_daftar.php');
$this->load->view('v_footer.php');
}
public function daftar_cari(){
$kunci = $this->input->post("cari");
if($kunci <> ''){
$kunci2 = strtoupper($kunci);
$data['query'] = $this->m_inventaris->cari_daftar($kunci, $kunci2);
//$data['kunci'] = $kunci;
if ($data['query']->result() == null ){
$this->session->set_flashdata('error', 'Tidak ditemukan Data Inventaris dengan kata kunci = "'.$kunci.'"');
redirect ('inventaris/daftar','refresh');
}else{
// Otoritas //
$id_menu = '8';
$menu["id_menu"] = $id_menu;
$data["jml_cari"] = "Data Ditemukan : ".$this->m_inventaris->count_cari($kunci, $kunci2)."
";
$data["id_unit_kerja"] = "";
$data["id_jenis_barang"] = "";
$data["drop_unit_kerja"] = $this->m_inventaris->get_drop_unit();
$data["drop_jenis_barang"] = $this->m_inventaris->get_drop_jenis();
$data["nama_unit_kerja"] = "Cari";
$reset = anchor('inventaris/daftar','',array('class'=>'btn btn-danger btn-circle'));
$data["nama_jenis_barang"] = '- Kata Kunci : "'.$kunci.'" '.$reset;
$data["title"] = "UNLASYS - Daftar Cari Inventaris'";
$this->load->view('v_header.php',$data);
$this->load->view('v_menu.php',$menu);
$this->load->view('inventaris/v_daftar.php');
$this->load->view('v_footer.php');
}
}else{
$this->session->set_flashdata('error', 'Kolom Nama Barang kosong');
redirect('inventaris/daftar', 'refresh');
}
}
public function tambah_daftar(){
$this->_validation_daftar();
if($this->form_validation->run()==false){
$data["title"] = "UNLASYS - Tambah Inventaris";
$data["judul_form"] = "Tambah";
$data["id_unit_kerja"] = "";
$data["id_jenis_barang"]= "";
$data["id_satuan"] = "";
$data["nama_barang"] = "";
$data["jml_barang"] = "";
$data["sangat_baik"] = "";
$data["baik"] = "";
$data["sedikit_rusak"] = "";
$data["rusak"] = "";
$data["keterangan"] = "";
$data["action_form"] = base_url().'inventaris/tambah_daftar';
$data["drop_unit_kerja"] = $this->m_inventaris->get_drop_unit();
$data["drop_jenis_barang"] = $this->m_inventaris->get_drop_jenis();
$data["drop_satuan"] = $this->m_inventaris->get_drop_satuan();
// Otoritas //
$id_menu = '8';
$menu["id_menu"] = $id_menu;
$this->load->view('v_header.php',$data);
$this->load->view('v_menu.php',$menu);
$this->load->view('inventaris/v_daftar_form.php');
$this->load->view('v_footer.php');
}else{
$id_unit_kerja = $this->input->post('id_unit_kerja');
$id_jenis_barang= $this->input->post('id_jenis_barang');
$nama_barang = $this->input->post('nama_barang');
$id_satuan = $this->input->post('id_satuan');
$keterangan = $this->input->post('keterangan');
$jml_barang = $this->input->post('jml_barang');
$sangat_baik = $this->input->post('sangat_baik');
$baik = $this->input->post('baik');
$sedikit_rusak = $this->input->post('sedikit_rusak');
$rusak = $this->input->post('rusak');
$kondisi = $sangat_baik + $baik + $sedikit_rusak + $rusak;
if($jml_barang == $kondisi){
$data = array(
'id_unit_kerja' => $id_unit_kerja,
'id_jenis_barang' => $id_jenis_barang,
'nama_barang' => $nama_barang,
'jml_barang' => $jml_barang,
'id_satuan' => $id_satuan,
'sangat_baik' => $sangat_baik,
'baik' => $baik,
'sedikit_rusak' => $sedikit_rusak,
'rusak' => $rusak,
'keterangan' => $keterangan
);
$this->m_inventaris->save_daftar($data);
$this->session->set_flashdata('success', 'Data Inventaris berhasil ditambah');
redirect('inventaris/daftar');
}else{
$this->session->set_flashdata('errorform', 'Total Jumlah Kondisi harus sama dengan Jumlah Barang');
$data["title"] = "UNLASYS - Tambah Inventaris";
$data["judul_form"] = "Tambah";
$data["id_unit_kerja"] = "";
$data["id_jenis_barang"]= "";
$data["id_satuan"] = "";
$data["nama_barang"] = "";
$data["jml_barang"] = "";
$data["sangat_baik"] = "";
$data["baik"] = "";
$data["sedikit_rusak"] = "";
$data["rusak"] = "";
$data["keterangan"] = "";
$data["action_form"] = base_url().'inventaris/tambah_daftar';
$data["drop_unit_kerja"] = $this->m_inventaris->get_drop_unit();
$data["drop_jenis_barang"] = $this->m_inventaris->get_drop_jenis();
$data["drop_satuan"] = $this->m_inventaris->get_drop_satuan();
// Otoritas //
$id_menu = '8';
$menu["id_menu"] = $id_menu;
$this->load->view('v_header.php',$data);
$this->load->view('v_menu.php',$menu);
$this->load->view('inventaris/v_daftar_form.php');
$this->load->view('v_footer.php');
}
}
}
public function ubah_daftar($id_inv_barang){
$this->_validation_daftar();
if($this->form_validation->run()==false){
$data["title"] = "UNLASYS - Ubah Inventaris";
$data["judul_form"] = "Ubah";
$daftar_detail = $this->m_inventaris->get_daftar_detail($id_inv_barang);
foreach($daftar_detail->result() as $row_daftar) {
$data["id_unit_kerja"] = $row_daftar->id_unit_kerja;
$data["id_jenis_barang"]= $row_daftar->id_jenis_barang;
$data["id_satuan"] = $row_daftar->id_satuan;
$data["nama_barang"] = $row_daftar->nama_barang;
$data["jml_barang"] = $row_daftar->jml_barang;
$data["sangat_baik"] = $row_daftar->sangat_baik;
$data["baik"] = $row_daftar->baik;
$data["sedikit_rusak"] = $row_daftar->sedikit_rusak;
$data["rusak"] = $row_daftar->rusak;
$data["keterangan"] = $row_daftar->keterangan;
}
$data["action_form"]= base_url().'inventaris/ubah_daftar/'.$id_inv_barang;
$data["drop_unit_kerja"] = $this->m_inventaris->get_drop_unit();
$data["drop_jenis_barang"] = $this->m_inventaris->get_drop_jenis();
$data["drop_satuan"] = $this->m_inventaris->get_drop_satuan();
// Otoritas //
$id_menu = '8';
$menu["id_menu"] = $id_menu;
$this->load->view('v_header.php',$data);
$this->load->view('v_menu.php',$menu);
$this->load->view('inventaris/v_daftar_form.php');
$this->load->view('v_footer.php');
}else{
$id_unit_kerja = $this->input->post('id_unit_kerja');
$id_jenis_barang= $this->input->post('id_jenis_barang');
$nama_barang = $this->input->post('nama_barang');
$id_satuan = $this->input->post('id_satuan');
$keterangan = $this->input->post('keterangan');
$jml_barang = $this->input->post('jml_barang');
$sangat_baik = $this->input->post('sangat_baik');
$baik = $this->input->post('baik');
$sedikit_rusak = $this->input->post('sedikit_rusak');
$rusak = $this->input->post('rusak');
$kondisi = $sangat_baik + $baik + $sedikit_rusak + $rusak;
if($jml_barang == $kondisi){
$data = array(
'id_unit_kerja' => $id_unit_kerja,
'id_jenis_barang' => $id_jenis_barang,
'nama_barang' => $nama_barang,
'jml_barang' => $jml_barang,
'id_satuan' => $id_satuan,
'sangat_baik' => $sangat_baik,
'baik' => $baik,
'sedikit_rusak' => $sedikit_rusak,
'rusak' => $rusak,
'keterangan' => $keterangan
);
$this->m_inventaris->update_daftar($id_inv_barang, $data);
$this->session->set_flashdata('success', 'Data Inventaris berhasil diubah');
redirect('inventaris/daftar');
}else{
$this->session->set_flashdata('errorform', 'Total Jumlah Kondisi harus sama dengan Jumlah Barang');
$data["title"] = "UNLASYS - Ubah Inventaris";
$data["judul_form"] = "Ubah";
$daftar_detail = $this->m_inventaris->get_daftar_detail($id_inv_barang);
foreach($daftar_detail->result() as $row_daftar) {
$data["id_unit_kerja"] = $row_daftar->id_unit_kerja;
$data["id_jenis_barang"]= $row_daftar->id_jenis_barang;
$data["id_satuan"] = $row_daftar->id_satuan;
$data["nama_barang"] = $row_daftar->nama_barang;
$data["jml_barang"] = $row_daftar->jml_barang;
$data["sangat_baik"] = $row_daftar->sangat_baik;
$data["baik"] = $row_daftar->baik;
$data["sedikit_rusak"] = $row_daftar->sedikit_rusak;
$data["rusak"] = $row_daftar->rusak;
$data["keterangan"] = $row_daftar->keterangan;
}
// Otoritas //
$id_menu = '8';
$menu["id_menu"] = $id_menu;
$data["action_form"]= base_url().'inventaris/ubah_daftar/'.$id_inv_barang;
$data["drop_unit_kerja"] = $this->m_inventaris->get_drop_unit();
$data["drop_jenis_barang"] = $this->m_inventaris->get_drop_jenis();
$data["drop_satuan"] = $this->m_inventaris->get_drop_satuan();
$this->load->view('v_header.php',$data);
$this->load->view('v_menu.php',$menu);
$this->load->view('inventaris/v_daftar_form.php');
$this->load->view('v_footer.php');
}
}
}
public function hapus_daftar($id_inv_barang){
$this->m_inventaris->delete_daftar($id_inv_barang);
$this->session->set_flashdata('success', 'Data Inventaris berhasil dihapus');
redirect('inventaris/daftar');
}
function _validation_daftar(){
$this->form_validation->set_rules("id_unit_kerja", "Nama Unit Kerja", "required");
$this->form_validation->set_rules("id_jenis_barang", "Nama Jenis Barang", "required");
$this->form_validation->set_rules("nama_barang", "Nama Barang", "required|max_length[50]");
$this->form_validation->set_rules("jml_barang", "Jumlah Barang", "required|max_length[5]");
$this->form_validation->set_rules("id_satuan", "Satuan", "required");
$this->form_validation->set_rules("sangat_baik", "Sangat Baik", "max_length[5]");
$this->form_validation->set_rules("baik", "baik", "max_length[5]");
$this->form_validation->set_rules("sedikit_rusak", "Sedikit Rusak", "max_length[5]");
$this->form_validation->set_rules("rusak", "Rusak", "max_length[5]");
$this->form_validation->set_rules("keterangan", "Keterangan", "max_length[500]");
$this->form_validation->set_message("required","%s tidak boleh kosong");
$this->form_validation->set_message("max_length", "%s tidak boleh lebih dari %s karakter");
$this->form_validation->set_error_delimiters("", "
");
}
/******************/
/*** laporan ***/
/******************/
public function laporan(){
$data['title'] = 'UNLASYS - Laporan Inventaris';
$this->load->view('v_header.php',$data);
$this->load->view('v_menu.php');
$this->load->view('inventaris/v_laporan.php');
$this->load->view('v_footer.php');
}
}