
<div id="divbc271loaddatapasi" >
	<div style="height:40px;">
		<button id="btnloadbc27pasi" >Load BC27 PASI</button>
		<button id="btnloadbc27pasi_dtl" >View detil BC27 PASI</button>
		<button id="btnloadbc27pasi_proses" >Proses BC27 PASI</button>
	</div>
	<table id="tblbc271loaddata"></table> <div id="ptblbc271loaddata"></div>
</div>
<div id="divbc271loaddatapasi_dtl" >
	<button id="btnloadbc27pasi_back" >BACK</button>
	<br />
	<br />
	<table id="tblbc271loaddata_dtl"></table> <div id="ptblbc271loaddata_dtl"></div>
</div>

<script type="text/javascript">
    
    $(document).ready(function(){
		$("#divbc271loaddatapasi_dtl").hide();
		
		$("#btnloadbc27pasi_dtl").button().click(function(){
			
			var id = jQuery("#tblbc271loaddata").jqGrid('getGridParam','selrow');
			if (id) { 
				var ret = jQuery("#tblbc271loaddata").jqGrid('getRowData',id);
				
			} else {
				alert("Please Select Row");
				return false;
			};	
			
			$("#divbc271loaddatapasi_dtl").fadeIn();
			$("#divbc271loaddatapasi_dtl").show();
			$("#divbc271loaddatapasi").fadeOut();
			$("#divbc271loaddatapasi").hide();
			
			var form_data = { 'id_bc271_hdr':ret.id_bc271_hdr};
			$("#tblbc271loaddata_dtl").jqGrid('setGridParam', { postData: form_data });
			jQuery("#tblbc271loaddata_dtl").trigger('reloadGrid');
		
		});
		$("#btnloadbc27pasi_back").button().click(function(){
			$("#divbc271loaddatapasi").fadeIn();
			$("#divbc271loaddatapasi").show();
			$("#divbc271loaddatapasi_dtl").fadeOut();
			$("#divbc271loaddatapasi_dtl").hide();
		
		});
		$("#btnloadbc27pasi").button().click(function(){
			
			$.ajax({
				url : "<?php echo base_url().'exim/ct_bc271/execdatabc27pasi'; ?>",
				type : 'POST',
				dataType: 'json',
				data : {test:'aaa'},
				success: function(msg){
					
					if (msg.sts == '00'){
						
						alert(msg.desc);
						$('#tblbc271loaddata').trigger('reloadGrid');
						
					} else { alert(msg.sts+msg.desc);  }
				}
			});
			
		
		
		});
		
		$("#btnloadbc27pasi_proses").button().click(function(){
		
			var id = jQuery("#tblbc271loaddata").jqGrid('getGridParam','selrow');
			if (id) { 
				var ret = jQuery("#tblbc271loaddata").jqGrid('getRowData',id);
				
			} else {
				alert("Please Select Row");
				return false;
			};	
			var form_data;
			form_data={
				'id_bc271_hdr':ret.id_bc271_hdr
			
			};
			
			$("#dlg_movebc271proses").dialog( "destroy" );
			$(".dlg_movebc271proses_cl").remove();
			$(".dlg_movebc271proses_cl").html('');
			$("body").append('<div id="dlg_movebc271proses" title="Warning" class="dlg_movebc271proses_cl"><p>Apakah anda yakin akan mengirim data bc271 ini menjadi data inventory incoming dengan nomor bc271 '+ ret.CAR +'..?</p><br />Mohon diperiksa kembali datanya.</div>');
			$("#dlg_movebc271proses").dialog({
				height: 200,
				width: 250,
				modal: true,
				hide: 'Slide',
				autoOpen: 'false',
				buttons: {
					"CONFIRM": function() {
					$.ajax({
						url : "<?php echo base_url().'exim/ct_bc271/prosesdatabc27pasi'; ?>",
						type : 'POST',
						dataType: 'json',
						data : form_data,
						success: function(msg){
							if (msg.sts == '00'){
								alert(msg.desc);
								$("#dlg_movebc271proses").dialog("close");
								$('#dlg_movebc271proses').dialog("destroy"); 
								$(".dlg_movebc271proses_cl").remove(); 
								$(".dlg_movebc271proses_cl").html('');
								$("body").append('<div id="dlg_movebc271proses" title="Warning" class="dlg_movebc271proses_cl"></div>');
								jQuery("#tblbc271loaddata").trigger('reloadGrid');
							} else { 
								alert(msg.sts+msg.desc); 
								$("#dlg_movebc271proses").dialog("close");
								$('#dlg_movebc271proses').dialog("destroy"); 
								$(".dlg_movebc271proses_cl").remove(); 
								$(".dlg_movebc271proses_cl").html('');
								
							}
						}
					});
				},
					"CANCEL": function() {
						$( "#dlg_movebc271proses" ).dialog( "close" );

					}
				},
				close : function(){
					$('#dlg_movebc271proses').dialog("destroy"); 
					$(".dlg_movebc271proses_cl").remove(); 
					$("body").append('<div id="dlg_movebc271proses" title="Warning" class="dlg_movebc271proses_cl"><p>Apakah anda yakin akan mengirim data bc271 ini menjadi data inventory incoming  nomor bc271 ..?</p><br />Mohon diperiksa kembali datanya.</div>');     
					
				},
				open: function(){
					$("body").unblock();
					
				}
			});	
		
		})
		
		jQuery("#tblbc271loaddata").jqGrid({
			url:'<?php echo base_url().'exim/ct_bc271/loaddatabc27pasi'; ?>',
			mtype : "post",
			postData:{'q':'1'},
			datatype: "json",
			colNames:[
			'id_bc271_hdr'
		  ,'CAR'
		  ,'KdKpbc'
		  ,'KdKpbcBongkar'
		  ,'KdKpbcAwas'
		  ,'PasokNama'
		  ,'PasokAlmt1'
		  ,'Moda'
		  ,'KdVal'
		  ,'Cif'
		  ,'Bruto'
		  ,'Netto'
		  ,'NilSerah'
		  ,'Nodaf'
		  ,'Tgldaf'
		  ,'UsahaNama'
		  ,'UsahaNPWP'
		  ,'UsahaAlamat1'
		  ,'UsahaAlamat2'
		  ,'UsahaSkep'
		  ,'PasokAlmt2'
		  ,'PasokSkep'
		  ,'PasokNPWP'
		  ,'NoInvoice'
		  ,'TgInvoice'
		  ,'NoPackinglist'
		  ,'TgPackinglist'
		  ,'NoKontrak'
		  ,'TgKontrak'
		  ,'SuratJalan'
		  ,'TgSuratjalan'
		  ,'SuratKep'
		  ,'TgSuratKep'
		  ,'SuratLain'
		  ,'TgSuratLain'
		  ,'NoBc27Asal'
		  ,'TgBc27Asal'
		  ,'Nopol'
		  ,'MrkNoKms'
		  ,'JmlJnsKms'
		  ,'NoSeg'
		  ,'CtBcTuj1'
		  ,'CtBcTuj2'
		  ,'Volume'
		  ,'Tgl_Keluar'
		  ,'No_Keluar'
		  ,'create_date'
		  ,'create_by'
		  ,'update_date'
		  ,'update_by'
		  ,'status'
		  ,'id_bc271_hdr_pasi'],
			colModel:[
			  {name:'id_bc271_hdr',index:'id_bc271_hdr', width:60, hidden:true},
			  {name:'CAR',index:'CAR', width:149, hidden:false},
			  {name:'KdKpbc',index:'KdKpbc', width:149, hidden:false},
			  {name:'KdKpbcBongkar',index:'KdKpbcBongkar', width:69, hidden:false},
			  {name:'KdKpbcAwas',index:'KdKpbcAwas', width:69, hidden:false},
			  {name:'PasokNama',index:'PasokNama', width:200, hidden:false},
			  {name:'PasokAlmt1',index:'PasokAlmt1', width:280, hidden:false},
			  {name:'Moda',index:'Moda', width:50, hidden:false},
			  {name:'KdVal',index:'KdVal', width:50, hidden:false},
			  {name:'Cif',index:'Cif', width:150, hidden:false},
			  {name:'Bruto',index:'Bruto', width:150, hidden:false, align:'right'},
			  {name:'Netto',index:'Netto', width:150, hidden:false, align:'right'},
			  {name:'NilSerah',index:'NilSerah', width:150, hidden:false, align:'right'},
			  {name:'Nodaf',index:'Nodaf', width:150, hidden:false},
			  {name:'Tgldaf',index:'Tgldaf', width:150, hidden:false},
			  {name:'UsahaNama',index:'UsahaNama', width:200, hidden:false},
			  {name:'UsahaNPWP',index:'UsahaNPWP', width:200, hidden:false},
			  {name:'UsahaAlamat1',index:'UsahaAlamat1', width:200, hidden:false},
			  {name:'UsahaAlamat2',index:'UsahaAlamat2', width:200, hidden:false},
			  {name:'UsahaSkep',index:'UsahaSkep', width:200, hidden:false},
			  {name:'PasokAlmt2',index:'PasokAlmt2', width:200, hidden:false},
			  {name:'PasokSkep',index:'PasokSkep', width:200, hidden:false},
			  {name:'PasokNPWP',index:'PasokNPWP', width:200, hidden:false},
			  {name:'NoInvoice',index:'NoInvoice', width:200, hidden:false},
			  {name:'TgInvoice',index:'TgInvoice', width:200, hidden:false},
			  {name:'NoPackinglist',index:'NoPackinglist', width:200, hidden:false},
			  {name:'TgPackinglist',index:'TgPackinglist', width:200, hidden:false},
			  {name:'NoKontrak',index:'NoKontrak', width:200, hidden:false},
			  {name:'TgKontrak',index:'TgKontrak', width:200, hidden:false},
			  {name:'SuratJalan',index:'SuratJalan', width:200, hidden:false},
			  {name:'TgSuratjalan',index:'TgSuratjalan', width:200, hidden:false},
			  {name:'SuratKep',index:'SuratKep', width:200, hidden:false},
			  {name:'TgSuratKep',index:'TgSuratKep', width:200, hidden:false},
			  {name:'SuratLain',index:'SuratLain', width:200, hidden:false},
			  {name:'TgSuratLain',index:'TgSuratLain', width:200, hidden:false},
			  {name:'NoBc27Asal',index:'NoBc27Asal', width:200, hidden:false},
			  {name:'TgBc27Asal',index:'TgBc27Asal', width:200, hidden:false},
			  {name:'Nopol',index:'Nopol', width:200, hidden:false},
			  {name:'MrkNoKms',index:'MrkNoKms', width:200, hidden:false},
			  {name:'JmlJnsKms',index:'JmlJnsKms', width:200, hidden:false},
			  {name:'NoSeg',index:'NoSeg', width:200, hidden:false},
			  {name:'CtBcTuj1',index:'CtBcTuj1', width:200, hidden:false},
			  {name:'CtBcTuj2',index:'CtBcTuj2', width:200, hidden:false},
			  {name:'Volume',index:'Volume', width:200, hidden:false},
			  {name:'Tgl_Keluar',index:'Tgl_Keluar', width:200, hidden:false},
			  {name:'No_Keluar',index:'No_Keluar', width:200, hidden:false},
			  {name:'create_date',index:'create_date', width:200, hidden:false},
			  {name:'create_by',index:'create_by', width:200, hidden:false},
			  {name:'update_date',index:'update_date', width:200, hidden:false},
			  {name:'update_by',index:'update_by', width:200, hidden:false},
			  {name:'status',index:'status', width:200, hidden:false},
			  {name:'id_bc271_hdr_pasi',index:'id_bc271_hdr_pasi', width:200, hidden:false}
			],
			rowNum:10,
			rowList:[10,20,30],
			pager: '#ptblbc271loaddata',
			sortname: 'id_bc271_hdr',
			viewrecords: true,
			sortorder: "desc",
			width: 960,
			height:300,
			jsonReader: { repeatitems : false },
			caption:"List of BC271 Data Pasi",
			rownumbers: true,
			shrinkToFit: false,
			afterInsertRow: function(rowid, aData){
				/*switch (aData.statusdok) {
					case 'DATA SENT':
						jQuery("#tblbc271loaddata").jqGrid('setCell',rowid,'statusdok','',{color:'green'});
					break;
					case '2':
						jQuery("#tblbc271loaddata").jqGrid('setCell',rowid,'statusdok','',{color:'red'});
					break;
					case '1':
						jQuery("#tblbc271loaddata").jqGrid('setCell',rowid,'statusdok','',{color:'blue'});
					break;
					
				} */
			},
			gridComplete: function(){
				
			},
		}); 
			
                        
		jQuery("#tblbc271loaddata").jqGrid('navGrid','#ptblbc271loaddata',{del:false,add:false,edit:false},{},{},{},{multipleSearch:false});
		jQuery("#tblbc271loaddata").jqGrid('filterToolbar',{stringResult: true,searchOnEnter : true, defaultSearch: 'cn', ignoreCase: true});

		jQuery("#tblbc271loaddata_dtl").jqGrid({
			url:'<?php echo base_url().'exim/ct_bc271/loaddatabc27pasi_dtl'; ?>',
			mtype : "post",
			postData:{'q':'1'},
			datatype: "json",
			colNames:[
			 'id_bc271_detail'
			  ,'id_bc271_hdr'
			  ,'CAR'
			  ,'NoHS'
			  ,'BrgUrai'
			  ,'Merk'
			  ,'Tipe'
			  ,'SpfLain'
			  ,'KdBrg'
			  ,'KdSat'
			  ,'JmlSat'
			  ,'NettoDtl'
			  ,'DSerah'
			  ,'DVol'
			  ,'NoUrut'
			  ,'create_date'
			  ,'create_by'
			  ,'update_date'
			  ,'update_by'
			  ,'Status'],
			colModel:[
			  {name:'id_bc271_detail',index:'id_bc271_detail', width:200, hidden:true},
			  {name:'id_bc271_hdr',index:'id_bc271_hdr', width:200, hidden:true},
			  {name:'CAR',index:'CAR', width:200, hidden:false},
			  {name:'NoHS',index:'NoHS', width:200, hidden:false},
			  {name:'BrgUrai',index:'BrgUrai', width:200, hidden:false},
			  {name:'Merk',index:'Merk', width:200, hidden:false},
			  {name:'Tipe',index:'Tipe', width:200, hidden:false},
			  {name:'SpfLain',index:'SpfLain', width:200, hidden:false},
			  {name:'KdBrg',index:'KdBrg', width:200, hidden:false},
			  {name:'KdSat',index:'KdSat', width:200, hidden:false},
			  {name:'JmlSat',index:'JmlSat', width:200, hidden:false},
			  {name:'NettoDtl',index:'NettoDtl', width:200, hidden:false},
			  {name:'DSerah',index:'DSerah', width:200, hidden:false},
			  {name:'DVol',index:'DVol', width:200, hidden:false},
			  {name:'NoUrut',index:'NoUrut', width:200, hidden:false},
			  {name:'create_date',index:'create_date', width:200, hidden:false},
			  {name:'create_by',index:'create_by', width:200, hidden:false},
			  {name:'update_date',index:'update_date', width:200, hidden:false},
			  {name:'update_by',index:'update_by', width:200, hidden:false},
			  {name:'Status',index:'Status', width:200, hidden:false}
			],
			rowNum:10,
			rowList:[10,20,30],
			pager: '#ptblbc271loaddata_dtl',
			sortname: 'id_bc271_detail',
			viewrecords: true,
			sortorder: "desc",
			width: 960,
			height:300,
			jsonReader: { repeatitems : false },
			caption:"List of BC271 Data Pasi Detil",
			rownumbers: true,
			shrinkToFit: false,
			afterInsertRow: function(rowid, aData){
				/*switch (aData.statusdok) {
					case 'DATA SENT':
						jQuery("#tblbc271loaddata_dtl").jqGrid('setCell',rowid,'statusdok','',{color:'green'});
					break;
					case '2':
						jQuery("#tblbc271loaddata_dtl").jqGrid('setCell',rowid,'statusdok','',{color:'red'});
					break;
					case '1':
						jQuery("#tblbc271loaddata_dtl").jqGrid('setCell',rowid,'statusdok','',{color:'blue'});
					break;
					
				} */
			},
			gridComplete: function(){
				
			},
		}); 
			
                        
		jQuery("#tblbc271loaddata_dtl").jqGrid('navGrid','#ptblbc271loaddata_dtl',{del:false,add:false,edit:false},{},{},{},{multipleSearch:false});
		jQuery("#tblbc271loaddata_dtl").jqGrid('filterToolbar',{stringResult: true,searchOnEnter : false, defaultSearch: 'cn', ignoreCase: true});
		
	});
		  	
</script>



	
	