<?php 

class Stok_opname extends CI_Controller{

	function __construct(){
		parent::__construct();
	 	$this->load->model('m_kontak');/* sesuaikan dengan nama file pada model */
		$this->load->model('m_login'); 
		$this->load->model('m_admin'); 
		$this->load->model('m_kasir');
		$this->load->model('m_metode');
		$this->load->model('m_member');
		$this->load->model('m_kantor');
		$this->load->model('m_supliyer'); 
		$this->load->model('m_stok_opname'); 
		$this->load->library('session');
		$this->load->library('upload');
		 
		$this->load->helper(array('form', 'url','tanggal'));
		if($this->session->userdata('status') != "loginbro"  and empty($this->session->userdata('email')) ){
			$this->session->set_flashdata('msg','<div class="alert alert-danger alert-dismissible">
						<a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
						<strong> Admin Bukan Admin </strong>Ulangi Kembali
						</div> ');

			redirect(base_url("")); 
			
		}
	 
	 
	}

	 
	function index(){		
		$username = $this->session->userdata("username");  
		$this->db->where('username',$username);
		$query = $this->db->get('tb_admin');
		$row = $query->row();
		$data['id_admin']= $row->id;
		$data['nama_admin']= $row->nama_admin;
		$data['id_kantor']= $row->id_kantor;
		$id_admin = $row->id;
		$id_kantor = $row->id_kantor;



		$this->db->where('id_kantor',$id_kantor);
		$query = $this->db->get('tb_kantor');
		$row = $query->row();
		$data['nama_kantor']= $row->nama_kantor;

		$data['barang'] = $this->m_kantor->kantor_stok_in($id_kantor); 
		$data['title1'] = 'Pelayanan Kasir'; 	
		$data['title2'] = 'Ubah Data'; 	
		$data['title3'] = 'Tambah Data';
		$data['title4'] = 'Kasir';
		$data['kontak'] = $this->m_kontak->kontak();
		$data['kantor'] = $this->m_kantor->kantor();
		$data['metode'] = $this->m_metode->metode();
		$data['admin'] = $this->m_admin->data_admin(); 
		$data['member'] = $this->m_member->member(); 
		$data['admin_login'] = $this->m_admin->data_admin_login();  
		$data['supliyer'] = $this->m_supliyer->supliyer();
		$data['keranjang'] = $this->m_stok_opname->keranjang($id_admin,$id_kantor);
		$data['sub_total'] = $this->m_kasir->sub_total_pembelian($id_admin,$id_kantor);
		$data['jumlah_pembelian'] = $this->m_kasir->jum_pembelian($id_admin,$id_kantor);


		$this->load->view('master/stok_opname/index',$data); 
		 
		
		 
		  
	}
	function fetch()
	{
		$output = '';
		$query = '';

		if($this->input->post('query'))
		{
			$query = $this->input->post('query');
		}
		$data = $this->m_kasir->fetch_data($query);
		$output .= '
		<div class="table-responsive">
		<table class="table table-bordered table-striped">
		<tr>
		<th>Barcode id</th>
		<th>Nama Barang</th>
		<th>Harga Jual</th>
		<th>Stok</th>
	 
		</tr>
		';
		if($data->num_rows() > 0)
		{
			foreach($data->result() as $row)
			{
				$username = $this->session->userdata("username");  
				$this->db->where('username',$username);
				$query3 = $this->db->get('tb_admin');
				$row2 = $query3->row(); 
				$id_kantor = $row2->id_kantor;

				$id_barang= $row->id;
				
				$sql_menuu = "SELECT stok_aplikasi FROM tb_stok WHERE  id_barang = '$id_barang' and id_kantor = '$id_kantor' ";
				$main_menuu = $this->db->query($sql_menuu)->result();
				foreach ($main_menuu as $mainkk) {
					$stok_aplikasi= $mainkk->stok_aplikasi;
				}
				$output .= '
				<tr  class=pilih data-id_barang='.$row->id.' data-nama_barang='.$row->nama_barang.' data-harga_jual_ecer='.$row->harga_jual_ecer.' data-barcode='.$row->barcode_ecer.'>
					<td><a onClick=masuk(this,'.$row->id.') href="#">'.$row->barcode_ecer.'</a></td>
					<td><a onClick=masuk(this,'.$row->id.') href="#">'.$row->nama_barang.'</a></td>
					<td>'.$row->harga_jual_ecer.'</td>
					<td>'.$stok_aplikasi.'</td>
					 
				</tr>
				';
			}
		}
		else
		{
			$output .= '<tr>
			<td colspan="5">No Data Found</td>
			</tr>';
		}
		$output .= '</table>';
		echo $output;
	}
	function history_kasir(){		
		$username = $this->session->userdata("username");  
		$this->db->where('username',$username);
		$query = $this->db->get('tb_admin');
		$row = $query->row();
		$data['id_admin']= $row->id;
		$data['nama_admin']= $row->nama_admin;
		$data['id_kantor']= $row->id_kantor;

		$id_admin = $row->id;
		$level = $row->level;
		$id_kantor = $row->id_kantor;

		$data['admin_login'] = $this->m_admin->data_admin_login();  
 

			if($level =='manager'){
				$this->db->order_by('date', 'desc');
				$query = $this->db->count_all('tb_kasir');

			}else{
				$this->db->order_by('date', 'desc');
				$this->db->where('id_admin',$id_admin);
				$this->db->where('id_kantor',$id_kantor);
				$query = $this->db->count_all('tb_kasir');
			}

		$config['base_url'] = base_url('kasir/history_kasir');
		 
        $config['total_rows'] = $query; //total row
        $config['per_page'] = 20;  //show record per halaman
        $config["uri_segment"] = 3;  // uri parameter
        $choice = $config["total_rows"] / $config["per_page"];
        $config["num_links"] = floor($choice);

        // Membuat Style pagination untuk BootStrap v4
      	$config['first_link']       = 'First';
        $config['last_link']        = 'Last';
        $config['next_link']        = 'Next';
        $config['prev_link']        = 'Prev';
        $config['full_tag_open']    = '<div class="pagging text-center"><nav><ul class="pagination justify-content-center">';
        $config['full_tag_close']   = '</ul></nav></div>';
        $config['num_tag_open']     = '<li class="page-item"><span class="page-link">';
        $config['num_tag_close']    = '</span></li>';
        $config['cur_tag_open']     = '<li class="page-item active"><span class="page-link">';
        $config['cur_tag_close']    = '<span class="sr-only">(current)</span></span></li>';
        $config['next_tag_open']    = '<li class="page-item"><span class="page-link">';
        $config['next_tagl_close']  = '<span aria-hidden="true">&raquo;</span></span></li>';
        $config['prev_tag_open']    = '<li class="page-item"><span class="page-link">';
        $config['prev_tagl_close']  = '</span>Next</li>';
        $config['first_tag_open']   = '<li class="page-item"><span class="page-link">';
        $config['first_tagl_close'] = '</span></li>';
        $config['last_tag_open']    = '<li class="page-item"><span class="page-link">';
        $config['last_tagl_close']  = '</span></li>';

        $this->pagination->initialize($config);
        $data['page'] = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0;

        //panggil function data_barangq yang ada pada mmodel m_barang.
        $data['data'] = $this->m_kasir->kasir_moneycash($config["per_page"], $data['page']);

        $data['pagination'] = $this->pagination->create_links();


 
		$this->load->view('master/header',$data); 
		$this->load->view('master/kasir/v_kasir_moneycash');
		$this->load->view('master/footer',$data); 
		
		 
		  
	}
	function log_in(){		
		$username = $this->session->userdata("username");  
		$this->db->where('username',$username);
		$query = $this->db->get('tb_admin');
		$row = $query->row();
		$data['id_admin']= $row->id;
		$data['nama_admin']= $row->nama_admin;
		$data['id_kantor']= $row->id_kantor;
		$id_admin = $row->id;
		$id_kantor = $row->id_kantor;



		$this->db->where('id_kantor',$id_kantor);
		$query = $this->db->get('tb_kantor');
		$row = $query->row();
		$data['nama_kantor']= $row->nama_kantor;

		$data['barang'] = $this->m_kantor->kantor_stok_in($id_kantor); 
		$data['title1'] = 'Pelayanan Kasir'; 	
		$data['title2'] = 'Ubah Data'; 	
		$data['title3'] = 'Tambah Data';
		$data['title4'] = 'Kasir';
		$data['kontak'] = $this->m_kontak->kontak();
		$data['kantor'] = $this->m_kantor->kantor();
		$data['metode'] = $this->m_metode->metode();
		$data['admin'] = $this->m_admin->data_admin(); 
		$data['member'] = $this->m_member->member(); 
		$data['admin_login'] = $this->m_admin->data_admin_login();  
		$data['supliyer'] = $this->m_supliyer->supliyer();
		$data['keranjang'] = $this->m_kasir->keranjang($id_admin,$id_kantor);
		$data['sub_total'] = $this->m_kasir->sub_total_pembelian($id_admin,$id_kantor);
		$data['jumlah_pembelian'] = $this->m_kasir->jum_pembelian($id_admin,$id_kantor);


		$this->load->view('master/kasir/index',$data); 
		 
		 
		 
		  
	}
	function get_autocomplete(){
		if (isset($_GET['term'])) {
		  	$result = $this->m_kasir->search_blog($_GET['term']);
		   	if (count($result) > 0) {
		    foreach ($result as $row)
		     	$arr_result[] = array(
					'label'			=> $row->blog_title,
					'description'	=> $row->blog_description,
				);
		     	echo json_encode($arr_result);
		   	}
		}
	}
	function get_autocomplete_barang(){
		if (isset($_GET['term'])) {
		  	$result = $this->m_kasir->pencarian($_GET['term']);
		   	if (count($result) > 0) {
		    foreach ($result as $row)
		     	$arr_result[] = array(
					'label'			=> $row->nama_barang,
					'description'	=> $row->id,
					'namabarang'	=> $row->id,
				);
		     	echo json_encode($arr_result);
		   	}
		}
	}
	function logout(){		
		$username = $this->session->userdata("username");  
		$this->db->where('username',$username);
		$query = $this->db->get('tb_admin');
		$row = $query->row();
		$data['id_admin']= $row->id;
		$data['nama_admin']= $row->nama_admin;
		$data['id_kantor']= $row->id_kantor;

		$id_kantor = $row->id_kantor;



		$this->db->where('id_kantor',$id_kantor);
		$query = $this->db->get('tb_kantor');
		$row = $query->row();
		$data['nama_kantor']= $row->nama_kantor;

		$data['barang'] = $this->m_kantor->kantor_stok_in($id_kantor); 
		$data['title1'] = 'Data Katagori Supliyer'; 	
		$data['title2'] = 'Ubah Data'; 	
		$data['title3'] = 'Tambah Data';
		$data['title4'] = 'Supliyer';
		$data['kontak'] = $this->m_kontak->kontak();
		$data['kantor'] = $this->m_kantor->kantor();
		$data['admin'] = $this->m_admin->data_admin(); 
		$data['admin_login'] = $this->m_admin->data_admin_login();  
		$data['supliyer'] = $this->m_supliyer->supliyer(); 

		 
		$this->load->view('master/header',$data); 
		$this->load->view('master/kasir/v_kasir2',$data); 
		$this->load->view('master/footer',$data);


		 
		  
	}
	 
 
	 
	public function hapus_keranjang($id){
		 
		 
	    $this->db->delete('tb_stok_opname_detail_keranjang', array('id' => $id)); 
	    
	    redirect('stok_opname/index');
		
	} 
    public function code_simpan_keranjang()
	{	 
		

		$id_barang= $this->input->post('id_barang');
		$id_admin= $this->input->post('id_admin');
		$id_kantor= $this->input->post('id_kantor');
		$jum_masuk= $this->input->post('jumlah');

		 	

		//cek   barang sudah dientri di tb_stok_opname_detail_keranjang
		$this->db->where('id_barang',$id_barang);
		$this->db->where('id_kantor',$id_kantor);
		$this->db->where('id_admin',$id_admin);
		$query = $this->db->get('tb_stok_opname_detail_keranjang');
		$kasir = $query->row();
		$cek_id_barang = $kasir->id_barang;
		$cek_jum_jual = $kasir->jumlah;

		$new_jumlah = $cek_jum_jual + $jum_masuk;


 		//cek barang apakah barang sudah masuk keranjang admin
		if($cek_id_barang == $id_barang ){
		 
			$data=array(
				 
				 
				'jumlah'=> $new_jumlah,
			 
				 
			);
			//update keranjang
			$this->db->where('id_barang',$id_barang);
			$this->db->where('id_admin',$id_admin);
			$this->db->where('id_kantor',$id_kantor);
			$this->db->update('tb_stok_opname_detail_keranjang',$data);

			redirect('stok_opname/index');

		}else{
			//barang belum entri keranjang
			 
			$data=array(
				'id'=>  null,
				'id_barang'=> $id_barang,
				'id_admin'=> $id_admin,
				'id_kantor'=> $id_kantor,
			 
				'jumlah'=> $new_jumlah,
			 
			);
			$this->db->insert('tb_stok_opname_detail_keranjang',$data);
			redirect('stok_opname/index');
		}	
  
 
        
        
    } 
     public function ubah_code_keranjang()
	{	 
		

		$id_barang= $this->input->post('id_barang');
		$id_admin= $this->input->post('id_admin');
		$id_kantor= $this->input->post('id_kantor');
		$jum_masuk= $this->input->post('jumlah_ubah');
 
 
		//cek   barang sudah dientri di tb_stok_opname_detail_keranjang
		$this->db->where('id_barang',$id_barang);
		$this->db->where('id_kantor',$id_kantor);
		$this->db->where('id_admin',$id_admin);
		$query = $this->db->get('tb_stok_opname_detail_keranjang');
		$kasir = $query->row();
		$cek_id_barang = $kasir->id_barang;
		$cek_jum_jual = $kasir->jumlah;

		$new_jumlah = $cek_jum_jual + $jum_masuk;


		//cek barang apakah barang sudah masuk keranjang admin
		if($cek_id_barang == $id_barang ){
		 
			$data=array(
				 
			 
				'jumlah'=> $jum_masuk,
			 
				 
			);
			//update keranjang
			$this->db->where('id_barang',$id_barang);
			$this->db->where('id_admin',$id_admin);
			$this->db->where('id_kantor',$id_kantor);
			$this->db->update('tb_stok_opname_detail_keranjang',$data);

			redirect('stok_opname/index');

		}else{
			//barang belum entri keranjang
			 
			$data=array(
				'id'=>  null,
				'id_barang'=> $id_barang,
				'id_admin'=> $id_admin,
				'id_kantor'=> $id_kantor,
			 
				'jumlah'=> $new_jumlah,
			 
			);
			$this->db->insert('tb_stok_opname_detail_keranjang',$data);
			redirect('stok_opname/index');
		}	
 
		 
        
        
    } 
 

 
	public function code_ubah() {
      
        
    	$data=array(
    	 
    		'nama_supliyer'=> $this->input->post('nama_supliyer'),
			'url_supliyer'=> url_title($this->input->post('nama_supliyer')),
			'nama_petugas'=> $this->input->post('nama_petugas'),
			'alamat'=> $this->input->post('alamat'),
			'no_hp'=> $this->input->post('no_hp'),


    	);

    	$this->db->where('id_supliyer',$this->input->post('id'));
        $this->db->update('tb_supliyer',$data);
        $this->session->set_flashdata('msg','success-edit');
    	redirect('supliyer');
	 
	} 
	 
	function get_barang(){
        $kode=$this->input->post('kode');
        $data=$this->m_kasir->get_data_barang_bykode($kode);
        echo json_encode($data);
    }
    public function code_simpan_pembelian() {
    	$id_member= $this->input->post('id_member');
     	$id_admin= $this->input->post('id_admin');
		$id_kantor= $this->input->post('id_kantor');
		$keterangan= $this->input->post('keterangan');

	 
		//kodetransaksi
		$date = date("dmY");
		$query = $this->db->query("SELECT max(id_stokopname) as max_id FROM tb_stok_opname WHERE id_stokopname LIKE '$date%' "); 
		$row = $query->row_array();
		$max_id = $row['max_id']; 
		$max_id1 =(int) substr($max_id,8,3);
		$kode_tr = $max_id1 +1;
		$newkode = $date.sprintf("%03s",$kode_tr);

		
 

		$sql = "SELECT * FROM tb_stok_opname_detail_keranjang  where id_admin='$id_admin' and id_kantor='$id_kantor' ";
		$cari = $this->db->query($sql)->result();
		foreach ($cari as $data) {
		        	//input data barmasuk
		        	$id_barang = $data->id_barang;
		        	$querybarang = $this->db->where('id',$id_barang);
		        	$querybarang = $this->db->get('tb_barang');
		        	$rowbarang = $querybarang->row();
		        	$harga_beli_ecer= $rowbarang->harga_beli_ecer;


		        	//cek stok

		        	$jumlah_toko = $data->jumlah;

		        	$query1	 = $this->db->where('id_barang',$id_barang);
		        	$query1	 = $this->db->where('id_kantor',$id_kantor);
		        	$query1	 = $this->db->get('tb_stok');
		        	$row1 	 = $query1->row();
		        	$jumlah_aplikasi	 = $row1->stok_aplikasi;


		        	$selisih_stok = $jumlah_toko  -  $jumlah_aplikasi  ;
		        	$new_stok = $jumlah_toko ;

		        	$total = $harga_beli_ecer * $selisih_stok ;

		        	if($selisih_stok == 0){
		        		$informasi = 'SESUAI';
		        	}else if($selisih_stok < 0){
		        		$informasi = 'RUGI';
		        	}else if($selisih_stok > 0){
		        		$informasi = 'PENAMBAHAN STOK';
		        	}

					$data1=array(

						'id'=>null,

						'id_barang'			=>  $data->id_barang, 
						'id_kantor'			=>  $data->id_kantor,
						'id_admin'			=>  $data->id_admin,
					 	'harga_beli'		=>  $harga_beli_ecer,
						'jumlah_toko'		=>  $data->jumlah,
						'jumlah_aplikasi'	=>  $jumlah_aplikasi,
						'selisih'			=>  $selisih_stok,
						'informasi'			=>  $informasi,
						'total'				=>  $total,
						'id_admin'			=>  $data->id_admin, 	
						 
						'id_stokopname'=>  $newkode
					);

					$this->db->insert('tb_stok_opname_detail',$data1);


		        //input data history
					$data2=array(

						'id_barang'			=>  $data->id_barang, 
						'id_kantor'			=>  $data->id_kantor,
						'jumlah'			=>  $data->jumlah,
						'id_admin'			=>  $data->id_admin,
						'date'				=>  $data->date,
						'keterangan'=>  'stok opname',
						
						'id_transaksi'=>  $newkode, 

					);

					$this->db->insert('tb_history_barang_in_out',$data2);


					 
					//update stok gudang
					$datax=array(

						'stok_aplikasi'=>  $data->jumlah,

					);
					$this->db->where('id_barang',$id_barang);
					$this->db->where('id_kantor',$id_kantor);
					$this->db->update('tb_stok',$datax);

		}
	  	// simpan stok opname
		$data4=array(
			
			'id_stokopname'=>  $newkode, 
			 
			'id_kantor'=>  $this->input->post('id_kantor'), 
		 
			'id_admin'=>  $this->input->post('id_admin'), 
			
			'keterangan'=>  $this->input->post('keterangan')  
			
		);
		$this->db->insert('tb_stok_opname',$data4); 

	 

		//hapus barjual kasir
		$hapus = "DELETE FROM tb_stok_opname_detail_keranjang where id_admin='$id_admin' and id_kantor='$id_kantor'    ";
		$data = $this->db->query($hapus);
		

		$this->session->set_flashdata('msg','success-opname');
		redirect('stok_opname/index');	

				 
			 

	 
       
	 
	} 
	 public function simpan_stok_opname_rak() {
	 		//kodetransaksi
		$date = date("dmY");
		$query = $this->db->query("SELECT max(id_stokopname) as max_id FROM tb_stok_opname WHERE id_stokopname LIKE '$date%' "); 
		$row = $query->row_array();
		$max_id = $row['max_id']; 
		$max_id1 =(int) substr($max_id,8,3);
		$kode_tr = $max_id1 +1;
		$newkode = $date.sprintf("%03s",$kode_tr);

	 	$nm = $this->input->post('id');
    $result = array();
    foreach($nm AS $key => $val){
    	 $harga_beli_ecer= $_POST['harga_beli'][$key];
    	 $selisih_stok = ($_POST['jumlah_toko'][$key]) - ($_POST['jumlah_aplikasi'][$key]) ;
    	 $total = $harga_beli_ecer * $selisih_stok ;
    	 //SELEKSI INFORMASI
    	 		if($selisih_stok == 0){
		    		$informasi = 'SESUAI';
		    	}else if($selisih_stok < 0){
		    		$informasi = 'RUGI';
		    	}else if($selisih_stok > 0){
		    		$informasi = 'PENAMBAHAN STOK';
		    	}
     $result[] = array(
	     	"id"=>null,
	     	"id_barang"  => $_POST['id_barang'][$key],
	     	"id_kantor"  => $_POST['id_kantor'][$key],
	     	"id_admin"  =>  $_POST['id_admin'][$key],
	     	"harga_beli"  => $_POST['harga_beli'][$key],
	     	"jumlah_toko"  => $_POST['jumlah_toko'][$key],
	     	"jumlah_aplikasi"  => $_POST['jumlah_aplikasi'][$key],
	     	"selisih"  => 	$selisih_stok ,
	     	"informasi"  => $informasi,
	     	"total"  => $total,
	     	"id_stokopname"  =>$newkode
     );
    }            
    
    $test= $this->db->insert_batch('tb_stok_opname_detail', $result); 


     $id_kantorq= $this->input->post('id_kantorq');
    $id_adminq= $this->input->post('id_adminq');
		$data4=array(
	
			'id_stokopname'=>  $newkode, 
			 
			'id_kantor'=>  $id_kantorq, 
		 
			'id_admin'=>  $id_adminq, 
			
			'keterangan'=> '-'
			
		);
		$this->db->insert('tb_stok_opname',$data4); 



		$nm = $this->input->post('id');
    $result = array();
    foreach($nm AS $key => $val){
   
     $result[] = array(
	     	"id_history"=>null,
	     	"id_barang"  => $_POST['id_barang'][$key],
	     	"id_kantor"  => $_POST['id_kantor'][$key],
	     	"id_admin"  =>  $_POST['id_admin'][$key],
	     	 	
	     	"jumlah"  => $_POST['jumlah_toko'][$key],
	     	"keterangan"  =>'stok opname',
	     	 
	     	"id_transaksi"  =>$newkode
     );
    }            
    
    $history= $this->db->insert_batch('tb_history_barang_in_out', $result); 
 

    $ID_att = $this->input->post('id_stok');
			$result = array();
			foreach($ID_att AS $key => $val){
			 $result[] = array(
			  "id_stok" => $ID_att[$key],
			
	     	"stok_aplikasi"  => $_POST['jumlah_toko'][$key],
	      
			 );
			}
			$this->db->update_batch('tb_stok', $result, 'id_stok');

	
	
	 //  $id = $this->input->post('id');
  //   $result = array();
  //   foreach($id AS $key => $val){
  //   	 // $harga_beli_ecer= $_POST['harga_beli'][$key];
  //   	 // $selisih_stok = ($_POST['jumlah_toko'][$key]) - ($_POST['jumlah_aplikasi'][$key]) ;
  //   	 // $total = $harga_beli_ecer * $selisih_stok ;
  //   	 // //SELEKSI INFORMASI
  //   	 // 		if($selisih_stok == 0){
		//     // 		$informasi = 'SESUAI';
		//     // 	}else if($selisih_stok < 0){
		//     // 		$informasi = 'RUGI';
		//     // 	}else if($selisih_stok > 0){
		//     // 		$informasi = 'PENAMBAHAN STOK';
		//     // 	}


	 //     $result[] = array(
	 //     	"id"=>null,
	 //     	"id_barang"  => $_POST['id_barang'][$key],
	 //     	"id_kantor"  => $_POST['id_kantor'][$key],
	 //     	"id_admin"  =>  $_POST['id_admin'][$key],
	 //     	"harga_beli"  => $_POST['harga_beli'][$key],
	 //     	"jumlah_toko"  => $_POST['jumlah_toko'][$key],
	 //     	"jumlah_aplikasi"  => $_POST['jumlah_aplikasi'][$key],
	 //     	// "selisih"  => 	$selisih_stok ,
	 //     	// "informasi"  => $informasi,
	 //     	// "total"  => $total,
	 //     	// "id_stokopname"  =>$newkode
	 //     );
  //   }            
    
  //   $this->db->insert('tb_stok_opname_detail', $result);  

 		

 	// 	//update stok
 	// // 	$id = $this->input->post('id');
 	// // 	$stok_update = array();
  // //   foreach($id AS $key => $val){
     
	 // //     $result[] = array(
	      
	 // //     	'stok_aplikasi'  => $_POST['jumlah_toko'][$key],
	      
	 // //     );
  // //   }            
  // //   $this->db->where_batch('id_barang', $_POST['id_barang'][$key] );
		// // $this->db->where_batch('id_kantor',$_POST['id_kantor'][$key]);
  // //   $this->db->update_batch('tb_stok', $stok_update);  

  //    //input data history
 

 


	  


		$this->session->set_flashdata('msg','success-opname');
		redirect('home');	

				 
			 

	 
       
	 
	} 



}