function pr_user(){
$nik = $this->session->nik;
cek_session_akses('pr_user',$this->session->id_session);
if (isset($_POST['submit1'])){
if ($this->session->idp == ''){
$data = array('kd_pr'=>$this->input->post('a'),
'user_create'=>$this->input->post('user_create'),
'tgl_pr' => date('Y-m-d'),
'user_create' => $this->input->post('user_create'),
'kategori_pr' => $this->input->post('kategori_pr'),
'type_pr' => $this->db->escape_str($this->input->post('type_pr')),
'no_projek' => $this->db->escape_str($this->input->post('no_projek')),
'lokasi_projek' => $this->db->escape_str($this->input->post('lokasi_projek')),
'tgl_kebutuhan' => $this->db->escape_str($this->input->post('tgl_kebutuhan')),
'status_pr' => $this->db->escape_str($this->input->post('status_pr')),
'keterangan_pr' => $this->db->escape_str($this->input->post('keterangan_pr')));
$this->model_app->insert('mst_pembelian',$data);
$idp = $this->db->insert_id();
$this->session->set_userdata(array('idp'=>$idp));
}else{
$data = array('kd_pr'=>$this->input->post('a'),
'user_create'=>$this->input->post('user_create'),
'tgl_pr' => date('Y-m-d'),
'user_create' => $this->input->post('user_create'),
'kategori_pr' => $this->input->post('kategori_pr'),
'type_pr' => $this->db->escape_str($this->input->post('type_pr')),
'no_projek' => $this->db->escape_str($this->input->post('no_projek')),
'lokasi_projek' => $this->db->escape_str($this->input->post('lokasi_projek')),
'tgl_kebutuhan' => $this->db->escape_str($this->input->post('tgl_kebutuhan')),
'status_pr' => $this->db->escape_str($this->input->post('status_pr')),
'keterangan_pr' => $this->db->escape_str($this->input->post('keterangan_pr')));
$this->model_app->insert('mst_pembelian',$data);
$idp = $this->db->insert_id();
$this->session->set_userdata(array('idp'=>$idp));
$where = array('id_pembelian' => $this->session->idp);
$this->model_app->update('mst_pembelian', $data, $where);
}
// $this->session->set_flashdata('submitted_data', $data);
redirect('administrator/pr_user');
}elseif(isset($_POST['submit'])){
if ($this->input->post('idpd')==''){
$data = array('id_pembelian'=>$this->session->idp,
'item_barang'=>$this->input->post('item_barang '),
'deskripsi_item'=>$this->input->post('deskripsi_item'),
'dimension_item'=>$this->input->post('dimension_item'),
'jumlah_item'=>$this->input->post('jumlah_item'),
'satuan_item'=>$this->input->post('satuan_item'));
$this->model_app->insert('mst_pembelian_dtl',$data);
}else{
$data = array('id_pembelian'=>$this->session->idp,
'item_barang'=>$this->input->post('item_barang '),
'deskripsi_item'=>$this->input->post('deskripsi_item'),
'dimension_item'=>$this->input->post('dimension_item'),
'jumlah_item'=>$this->input->post('jumlah_item'),
'satuan_item'=>$this->input->post('satuan_item'));
$where = array('mst_pembelian_dtl' => $this->input->post('idpd'));
$this->model_app->update('mst_pembelian_dtl', $data, $where);
}
redirect('administrator/pr_user');
}else{
$data['rows'] = $this->model_app->view_ordering('mst_pembelian', 'id_pembelian', 'DESC');
$data['record'] = $this->model_app->view_join_where('mst_pembelian_dtl', 'mst_pembelian', 'id_pembelian', 'id_dpembelian', array('id_pembelian' => $this->session->idp), 'DESC');
// $data['barang'] = $this->model_app->view_where_ordering('rb_produk',array('id_reseller'=>'0'),'id_produk','ASC');
// $data['supplier'] = $this->model_app->view_ordering('rb_supplier','id_supplier','ASC');
if ($this->uri->segment(3)!=''){
$data['row'] = $this->model_app->view_where('mst_pembelian_dtl',array('mst_pembelian_dtl'=>$this->uri->segment(3)))->row_array();
}
$this->template->load('administrator/template','administrator/mod_pr/pr_user',$data);
}
}