Untitled
unknown
plain_text
a year ago
12 kB
2
Indexable
Never
// PEMINJAMAN function peminjaman() { //cek_session_akses('pembelian',$this->session->id_session); cek_session_karyawan(); $this->session->unset_userdata('idp', 'kd'); //$data['record'] = $this->model_app->view_join_one('rb_pembelian','rb_supplier','id_supplier','id_pembelian','DESC'); $data['record'] = $this->model_app->view_ordering('mst_peminjaman', 'id_peminjaman', 'DESC'); $this->template->load('karyawan/template', 'karyawan/additional/mod_peminjaman/view_peminjaman', $data); } function detail_peminjaman() { cek_session_karyawan(); $id = $this->uri->segment(3); //Print($id);die; //cek_session_akses('pembelian',$this->session->id_session); $data['rows'] = $this->model_app->view_pj_header($id)->row_array(); //$data['rows'] = $this->model_app->view_where('mst_pembelian',array('id_pembelian'=>$id))->row_array(); $data['record'] = $this->model_app->view_join_where('mst_peminjaman_dtl', 'mst_item', 'kode_item', array('id_peminjaman' => $id), 'id_dpeminjaman', 'DESC'); $this->template->load('karyawan/template', 'karyawan/additional/mod_peminjaman/view_peminjaman_detail', $data); } function tambah_peminjaman() { //cek_session_akses('pembelian',$this->session->id_session); cek_session_karyawan(); if (isset($_POST['submit1'])) { $latest_ticket = $this->model_app->get_latest_ticket_pj(); $cekskrng = date('Ymd'); $cekdata_akhir = substr($latest_ticket, 3, -3); if (empty($latest_ticket) || $cekskrng != $cekdata_akhir) { $new_number = 1; } else { $last_number = number_format(substr($latest_ticket, -3)); $new_number = $last_number + 1; } $new_number_str = str_pad($new_number, 3, '0', STR_PAD_LEFT); $kd_pinjam = "PJ-" . date('Ymd') . $new_number_str; if ($this->session->idp == '') { $data = array( 'kd_pinjam' => $kd_pinjam, 'tgl_pinjam' => date('Y-m-d'), 'jam_pinjam' => date('H:i:s'), 'user_create' => $this->session->nik, // 'kategori_pr'=>$this->input->post('b'), // 'type_pr'=>$this->input->post('c'), 'no_projek' => $this->input->post('d'), 'lokasi' => $this->input->post('e'), // 'tgl_kebutuhan'=>$this->input->post('f'), // 'no_job'=>$this->input->post('h'), // 'keterangan_pr'=>$this->input->post('g'), 'status_pinjam' => "Draft" ); $this->model_app->insert('mst_peminjaman', $data); $idp = $this->db->insert_id(); $this->session->set_userdata(array('idp' => $idp, 'kd' => $kd_pinjam)); } else { $data = array( 'no_projek' => $this->input->post('d'), 'lokasi' => $this->input->post('e'), 'status_pinjam' => "Draft" ); $where = array('id_peminjaman' => $this->session->idp); $this->model_app->update('mst_peminjaman', $data, $where); } redirect('karyawan/tambah_peminjaman'); } elseif (isset($_POST['submit'])) { if ($this->input->post('idpd') == '') { $data = array( 'id_peminjaman' => $this->session->idp, 'kd_pinjam' => $this->session->kd, 'kode_item' => $this->input->post('aa'), 'keterangan_item' => $this->input->post('bb'), 'jumlah_pinjam' => $this->input->post('dd'), 'satuan_pinjam' => $this->input->post('ee'), 'status_item' => "Draft" ); $this->model_app->insert('mst_peminjaman_dtl', $data); } else { $data = array( 'id_peminjaman' => $this->session->idp, 'kd_pinjam' => $this->session->kd, 'kode_item' => $this->input->post('aa'), 'keterangan_item' => $this->input->post('bb'), 'jumlah_pinjam' => $this->input->post('dd'), 'satuan_pinjam' => $this->input->post('ee'), 'status_item' => "Draft" ); $where = array('id_dpeminjaman' => $this->input->post('idpd')); $this->model_app->update('mst_peminjaman_dtl', $data, $where); } redirect('karyawan/tambah_peminjaman'); } else { $data['rows'] = $this->model_app->view_where('mst_peminjaman', array('id_peminjaman' => $this->session->idp))->row_array(); //$data['rows'] = $this->model_reseller->view_join_rows('rb_pembelian','rb_supplier','id_supplier',array('id_pembelian'=>$this->session->idp),'id_pembelian','DESC')->row_array(); $data['record'] = $this->model_app->view_join_where('mst_peminjaman_dtl', 'mst_item', 'kode_item', array('id_peminjaman' => $this->session->idp), 'id_dpeminjaman', 'DESC'); // $data['kategori'] = $this->model_app->view_where_ordering('uti_setting',array('sub_modul'=>'kategori_pr'),'id_uti','ASC'); // $data['type'] = $this->model_app->view_where_ordering('uti_setting',array('sub_modul'=>'type_pr'),'id_uti','ASC'); $data['lokasi'] = $this->model_app->view_where_ordering('uti_setting', array('sub_modul' => 'lokasi'), 'id_uti', 'ASC'); $data['item'] = $this->model_app->view_where_ordering('mst_item', array('mstatus_item' => '1'), 'id_item', 'ASC'); if ($this->uri->segment(3) != '') { $data['row'] = $this->model_app->view_where('mst_peminjaman_dtl', array('id_dpeminjaman' => $this->uri->segment(3)))->row_array(); } $this->template->load('karyawan/template', 'karyawan/additional/mod_peminjaman/view_peminjaman_tambah', $data); } } function edit_peminjaman() { cek_session_karyawan(); $idp = $this->uri->segment(3); // Print($idp);die; if (isset($_POST['submit1'])) { $data = array( 'tgl_pinjam' => date('Y-m-d'), 'jam_pinjam' => date('H:i:s'), 'user_create' => $this->session->nik, 'no_projek' => $this->input->post('d'), 'lokasi' => $this->input->post('e'), 'status_pinjam' => "Draft" ); $where = array('id_peminjaman' => $idp); //Print($id);die; $this->model_app->update('mst_peminjaman', $data, $where); redirect('karyawan/peminjaman/' . $idp); //Print($id);die; } elseif (isset($_POST['submit'])) { if ($this->input->post('idpd') == '') { $data = array( 'id_peminjaman' => $this->input->post('idp'), 'kd_pinjam' => $this->input->post('kd'), 'kode_item' => $this->input->post('aa'), 'keterangan_item' => $this->input->post('bb'), 'jumlah_pinjam' => $this->input->post('dd'), 'satuan_pinjam' => $this->input->post('ee'), 'status_item' => "Draft" ); $this->model_app->insert('mst_peminjaman_dtl', $data); } else { $data = array( 'id_peminjaman' => $this->input->post('idp'), 'kd_pinjam' => $this->input->post('kd'), 'kode_item' => $this->input->post('aa'), 'keterangan_item' => $this->input->post('bb'), 'jumlah_pinjam' => $this->input->post('dd'), 'satuan_pinjam' => $this->input->post('ee'), 'status_item' => "Draft" ); $where = array('id_dpeminjaman' => $this->input->post('idpd')); $this->model_app->update('mst_peminjaman_dtl', $data, $where); } redirect('karyawan/edit_peminjaman/' . $this->input->post('idp')); } else { $data['rows'] = $this->model_app->view_where('mst_peminjaman', array('id_peminjaman' => $this->uri->segment(3)))->row_array(); //$data['rows'] = $this->model_reseller->view_join_rows('rb_pembelian','rb_supplier','id_supplier',array('id_pembelian'=>$this->session->idp),'id_pembelian','DESC')->row_array(); $data['record'] = $this->model_app->view_join_where('mst_peminjaman_dtl', 'mst_item', 'kode_item', array('id_peminjaman' => $this->uri->segment(3)), 'id_dpeminjaman', 'DESC'); // $data['kategori'] = $this->model_app->view_where_ordering('uti_setting',array('sub_modul'=>'kategori_pr'),'id_uti','ASC'); // $data['type'] = $this->model_app->view_where_ordering('uti_setting',array('sub_modul'=>'type_pr'),'id_uti','ASC'); $data['lokasi'] = $this->model_app->view_where_ordering('uti_setting', array('sub_modul' => 'lokasi'), 'id_uti', 'ASC'); $data['item'] = $this->model_app->view_where_ordering('mst_item', array('mstatus_item' => '1'), 'id_item', 'ASC'); if ($this->uri->segment(4) != '') { $data['row'] = $this->model_app->view_where('mst_peminjaman_dtl', array('id_dpeminjaman' => $this->uri->segment(4)))->row_array(); } $this->template->load('karyawan/template', 'karyawan/additional/mod_peminjaman/view_peminjaman_edit', $data); } } function peminjaman_submit() { $id = $this->uri->segment(3); $cari = $this->model_app->view_where('mst_peminjaman', array('id_peminjaman' => $id))->row_array(); $data = array('status_pinjam' => "Submit"); $where = array('id_peminjaman' => $id); $this->model_app->update('mst_peminjaman', $data, $where); $data1 = array('status_item' => "PJ"); $where1 = array('id_peminjaman' => $id); $this->model_app->update('mst_peminjaman_dtl', $data1, $where1); redirect('karyawan/peminjaman'); } function peminjaman_cetak() { $id = $this->uri->segment(3); // Ambil data dengan 'status_item' yang 'Approve' $data['rows'] = $this->model_app->view_pj_header($id)->row_array(); // Ambil data 'mst_peminjaman_dtl' dengan 'status_item' yang 'Approve' $data['record'] = $this->model_app->view_join_where( 'mst_peminjaman_dtl', 'mst_item', 'kode_item', array('id_peminjaman' => $id, 'status_item' => 'Approve'), // Filter status_item 'id_dpeminjaman', 'DESC' ); $this->template->load('karyawan/template', 'karyawan/additional/mod_peminjaman/print_pj', $data); } function delete_peminjaman() { //cek_session_akses('pembelian',$this->session->id_session); cek_session_karyawan(); $id = array('id_peminjaman' => $this->uri->segment(3)); $this->model_app->delete('mst_peminjaman', $id); $this->model_app->delete('mst_peminjaman_dtl', $id); redirect('karyawan/peminjaman'); } function delete_peminjaman_detail() { //cek_session_akses('pembelian',$this->session->id_session); cek_session_karyawan(); $id = array('id_dpeminjaman' => $this->uri->segment(4)); $this->model_app->delete('mst_peminjaman_dtl', $id); redirect('karyawan/edit_peminjaman/' . $this->uri->segment(3)); } function delete_peminjaman_tambah_detail() { //cek_session_akses('pembelian',$this->session->id_session); cek_session_karyawan(); $id = array('id_dpeminjaman' => $this->uri->segment(3)); $this->model_app->delete('mst_peminjaman_dtl', $id); redirect('karyawan/tambah_peminjaman'); }