<div style="height:2px;">
	
</div >
<table id="tbl_proses_inv_bc40_dtl"></table> <div id="ptbl_proses_inv_bc40_dtl"></div> 
<div style="position:absolute;top:380px;left:190px;">
	<!-- <button id="btnupdate_date_inv_bc40_dtl" >Update Selected Date Invoice</button> -->
</div>
<div style="position:relative;top:10px;left:1px;width:200px">
	
	<table>
		
		<tr>
			<td>NO BL</td><td>:</td><td><input type="text" id="txt_no_bl_bc40"/></td>
		</tr>
		<tr>
			<td>TGL BL</td><td>:</td><td><input type="text" id="txt_date_bl_bc40"/></td>
		</tr>
	</table>
	<span style="left:20px" /><button id="btnupdate_bc40_dtl" >Update Data BL</button>
	
</div>
<div style="position:absolute;top:369px;left:200px;width:200px">
	<?php 
		$data = json_decode($dataarray);
		$dataiv = '';
		if (!empty($data)){	
				
			foreach ($data as $r ){
				$dataiv .=  ' | ' . $r->invoice_no ;
			
			}
		}
		echo 'NO INVOICE: ' .  '<B>' . $dataiv . '</B>'; 
	?>
</div>
<script type="text/javascript">
    
    $(document).ready(function(){
		
		
		$("#txt_date_bl_bc40").datepicker({
			dateFormat:'yy-mm-dd',
		
		
		});
		
		var form_data = {
			where:'<?php echo $dataarray; ?>'
		};
		
		$('#txt_no_bl_bc40').keyup(function(){
			this.value = this.value.toUpperCase();
		});
		
		var jsondata;
		jsondata = 	'<?php echo $dataarray; ?>';
		
			
		jQuery("#tbl_proses_inv_bc40_dtl").jqGrid({
			url:'<?php echo base_url().'exim/ct_bc40/loaddata_proses_inv_bc40'; ?>',
			mtype : "post",
			postData:form_data,
			datatype: "json",
			colNames:['ID'
			   ,'invoice no'
			  ,'invoice date'
			  ,'nobl'
			  ,'tglbl'
			  ,'part name'
			  ,'part no'
			  ,'kode barang'
			  ,'kode supplier'
			  ,'maker'
			  ,'order qty'
			  ,'order no'
			  ,'order date'
			  ,'req eta date'
			  ,'shipping by'
			  ,'inv qty'
			  ,'inv unit'
			  ,'rec qty'
			  ,'rec date'
			  ,'status inv'
			  ,'amount'
			  ,'remark'
			  ,'nocar'
			  ,'tglaju'
			  ,'status data'
			  ,'create date'
			  ,'create by'
			  ,'update date'
			  ,'update by'],
			colModel:[
				{name:'id_invoice_bc40',index:'id_invoice_bc40', width:60, hidden:true},
				{name:'invoice_no',index:'invoice_no', width:160},
				{name:'invoice_date',index:'invoice_date', width:160,  
					editable:false, 
					edittype:'text', formatter:'date', 
					editoptions: { dataInit: 
						function(el){$(el).datepicker({
								changeYear: true,
								showButtonPanel: true,
								changeMonth: true, 
								dateFormat:'yy-mm-dd',
								onSelect: function () {
									
								
								}
							}); 
						} 
					} 
				},
				{name:'nobl',index:'nobl', width:160, 
				/*editable:true,*/ 
				},
				{name:'tglbl',index:'tglbl', width:160, 
					/*editable:true,*/ 
					edittype:'text', formatter:'date', 
					editoptions: { dataInit: 
						function(el){$(el).datepicker({
								changeYear: true,
								showButtonPanel: true,
								changeMonth: true, 
								dateFormat:'yy-mm-dd',
								onSelect: function () {
									
								
								}
							}); 
						} 
					}
				},
				{name:'part_name',index:'part_name', width:160},
				{name:'part_no',index:'part_no', width:160},
				{name:'kode_barang',index:'kode_barang', width:160},
				{name:'kode_supplier',index:'kode_supplier', width:160},
				{name:'maker',index:'maker', width:160},
				{name:'order_qty',index:'order_qty', width:160},
				{name:'order_no',index:'order_no', width:160},
				{name:'order_date',index:'order_date', width:160},
				{name:'req_eta_date',index:'req_eta_date', width:160},
				{name:'shipping_by',index:'shipping_by', width:160},
				{name:'inv_qty',index:'inv_qty', width:160},
				{name:'inv_unit',index:'inv_unit', width:160},
				{name:'rec_qty',index:'rec_qty', width:160},
				{name:'rec_date',index:'rec_date', width:160},
				{name:'status_inv',index:'status_inv', width:160},
				{name:'amount',index:'amount', width:160},
				{name:'remark',index:'remark', width:160},
				{name:'nocar',index:'nocar', width:160},
				{name:'tglaju',index:'tglaju', width:160},
				{name:'status_data',index:'status_data', width:160},
				{name:'create_date',index:'create_date', width:160},
				{name:'create_by',index:'create_by', width:160},
				{name:'update_date',index:'update_date', width:160},
				{name:'update_by',index:'update_by', width:160},
			],
			rowNum:10,
			rowList:[10,20,30],
			pager: '#ptbl_proses_inv_bc40_dtl',
			sortname: 'id_invoice_bc40',
			viewrecords: true,
			sortorder: "desc",
			width: 860,
			height:240,
			jsonReader: { repeatitems : false },
			caption:"Invoice Terproses",
			rownumbers: true,
			shrinkToFit: false,
			/* multiselect: true,   */
			loadOnce:true,
			cellEdit: true, 
			cellsubmit: 'clientArray',
			afterInsertRow: function(){
				
				
			},			
			gridComplete: function(){
				
				var rowIDs = jQuery("#tbl_proses_inv_bc40_dtl").getDataIDs(); 
				var rowData = $("#tbl_proses_inv_bc40_dtl").getRowData();
			
				for (var i = 0; i < rowData.length; i++) 
				{
				   var trElement = jQuery("#"+ rowIDs[i],jQuery('#tbl_proses_inv_bc40_dtl'));
				   
					switch (rowData[i].status_upload) {
						
						case 'cancel':
						   trElement.css({"color":"green"});
						break;
						case 'Deleted':
						   trElement.css({"color":"red", "text-decoration": "line-through"});
						break;
						case 'Data Processed':
						   trElement.css({"color":"blue"});
						break;
						
						
					}
				}
			},
			onSelectRow: function (rowid, status) {
				if(status == true){
					jQuery("#tbl_proses_inv_bc40_dtl").jqGrid('editRow',rowid);
				
				} else {
					jQuery("#tbl_proses_inv_bc40_dtl").jqGrid('restoreRow',rowid);
				
				}
				
			},
			loadComplete: function () {
			
			
			}
		}); 
		
		
		jQuery("#tbl_proses_inv_bc40_dtl").jqGrid('navGrid','#ptbl_proses_inv_bc40_dtl',{del:false,add:false,edit:false},{},{},{},{multipleSearch:false});
		jQuery("#tbl_proses_inv_bc40_dtl").jqGrid('filterToolbar',{stringResult: true,searchOnEnter : true, defaultSearch: 'cn', ignoreCase: true});
	
		/* $("#btnupdate_bc40_dtl").button().click(function(){
			var gridData = jQuery("#tbl_proses_inv_bc40_dtl").getRowData();
			var postData = JSON.stringify(gridData);
			var form_data;
			form_data = {
				postData:postData
			};
			$("#dlg_update_inv_bc40_dtl").dialog( "destroy" );
			$(".dlg_update_inv_bc40_dtl_cl").remove();
			$(".dlg_update_inv_bc40_dtl_cl").html('');
			$("body").append('<div id="dlg_update_inv_bc40_dtl" title="Warning" class="dlg_update_inv_bc40_dtl_cl"><p>Apakah anda yakin akan melakukan update data mesin sparepart  ..?</p><br />Mohon diperiksa kembali datanya.</div>');
			$("#dlg_update_inv_bc40_dtl").dialog({
				height: 200,
				width: 250,
				modal: true,
				hide: 'Slide',
				autoOpen: 'false',
				buttons: {
					"CONFIRM": function() {
					$.ajax({
						url : "<?php echo base_url().'exim/ct_bc40/proses_update_inv_bc40'; ?>",
						type : 'POST',
						dataType: 'json',
						data : form_data,
						success: function(msg){
							if (msg.sts == '00'){
								alert(msg.desc);
								$("#dlg_update_inv_bc40_dtl").dialog("close");
								$('#dlg_update_inv_bc40_dtl').dialog("destroy"); 
								$(".dlg_update_inv_bc40_dtl_cl").remove(); 
								$(".dlg_update_inv_bc40_dtl_cl").html('');
								jQuery("#tbl_proses_inv_bc40_hdr").trigger('reloadGrid');
								
							} else { 
								alert(msg.sts+msg.desc); 
								$("#dlg_update_inv_bc40_dtl").dialog("close");
								$('#dlg_update_inv_bc40_dtl').dialog("destroy"); 
								$(".dlg_update_inv_bc40_dtl_cl").remove(); 
								
							}
						}
					});
				},
					"CANCEL": function() {
						$( "#dlg_update_inv_bc40_dtl" ).dialog( "close" );

					}
				},
				close : function(){
					$('#dlg_update_inv_bc40_dtl').dialog("destroy"); 
					$(".dlg_update_inv_bc40_dtl_cl").remove(); 
					//$("body").append('<div id="dlg_update_inv_bc40_dtl" title="Warning" class="dlg_update_inv_bc40_dtl_cl"><p>Apakah anda yakin akan memproses data mesin sparepart  '+ ret.filename  +'..?</p><br />Mohon diperiksa kembali datanya.</div>.</div>');     
					
				},
				open: function(){
					$("body").unblock();
					
				}
			});
		
		}); */
		
		$("#btnupdate_bc40_dtl").button().click(function(){
			/* 	var ids = jQuery("#tbl_proses_inv_bc40_dtl").getGridParam('selarrrow');
			var count = ids.length;
			if (count>0) {
				var names = [];
				for (var i=0, il=ids.length; i < il; i++) {
					//var name = jQuery("#tbl_proses_inv_bc40_dtl").jqGrid('getCell', ids[i], 'invoice_no');
					var rowData = jQuery("#tbl_proses_inv_bc40_dtl").jqGrid('getRowData', ids[i]);
					//names.push(rowData.invoice_no);	
					names.push(rowData);
					alert(rowData.invoice_date + '------');
				}
			} else {
			
				return false;
			} */
			
			if (jsondata == '' || jsondata == 'undefined'){
				alert('Data tidak boleh kosong! Silakan Pilih Dahulu..');
				return false;
			}
			
			/* var gridData = jQuery("#tbl_proses_inv_bc40_dtl").getRowData();
			var postData = JSON.stringify(gridData); */
			var form_data;
			form_data = {
				no_bl_bc40:$("#txt_no_bl_bc40").val(),
				date_bl_bc40:$("#txt_date_bl_bc40").val(),
				postData:jsondata
			};
			$("#dlg_update_date_inv_bc40_dtl").dialog( "destroy" );
			$(".dlg_update_date_inv_bc40_dtl_cl").remove();
			$(".dlg_update_date_inv_bc40_dtl_cl").html('');
			$("body").append('<div id="dlg_update_date_inv_bc40_dtl" title="Warning" class="dlg_update_date_inv_bc40_dtl_cl"><p>Apakah anda yakin akan melakukan update data invoice bc40  ..?</p><br />Mohon diperiksa kembali datanya.</div>');
			$("#dlg_update_date_inv_bc40_dtl").dialog({
				height: 200,
				width: 250,
				modal: true,
				hide: 'Slide',
				autoOpen: 'false',
				buttons: {
					"CONFIRM": function() {
					$.ajax({
						url : "<?php echo base_url().'exim/ct_bc40/proses_update_bl_bc40'; ?>",
						type : 'POST',
						dataType: 'json',
						data : form_data,
						success: function(msg){
							if (msg.sts == '00'){
								alert(msg.desc);
								$("#dlg_update_date_inv_bc40_dtl").dialog("close");
								$('#dlg_update_date_inv_bc40_dtl').dialog("destroy"); 
								$(".dlg_update_date_inv_bc40_dtl_cl").remove(); 
								$(".dlg_update_date_inv_bc40_dtl_cl").html('');
								jQuery("#tbl_proses_inv_bc40_dtl").trigger('reloadGrid');
								
							} else { 
								alert(msg.sts+msg.desc); 
								$("#dlg_update_date_inv_bc40_dtl").dialog("close");
								$('#dlg_update_date_inv_bc40_dtl').dialog("destroy"); 
								$(".dlg_update_date_inv_bc40_dtl_cl").remove(); 
								
							}
						}
					});
				},
					"CANCEL": function() {
						$( "#dlg_update_date_inv_bc40_dtl" ).dialog( "close" );

					}
				},
				close : function(){
					$('#dlg_update_date_inv_bc40_dtl').dialog("destroy"); 
					$(".dlg_update_date_inv_bc40_dtl_cl").remove(); 
					//$("body").append('<div id="dlg_update_date_inv_bc40_dtl" title="Warning" class="dlg_update_date_inv_bc40_dtl_cl"><p>Apakah anda yakin akan memproses data mesin sparepart  '+ ret.filename  +'..?</p><br />Mohon diperiksa kembali datanya.</div>.</div>');     
					
				},
				open: function(){
					$("body").unblock();
					
				}
			});
		
		});
	});
		  	
</script>



	
	