<div style="height:40px;">
	NO INVOICE : <input type="text" id="nomor_invoice_bc40" value="<?php echo $no_invoice_bc40_update; ?>" /> TANGGAL INVOICE  <input type="text" id="tgl_invoice_bc40" value="<?php echo $tgl_invoice_bc40_update; ?>" /> 
	<button id="btnupdateinvoicebc40" >UPDATE</button>
	<input type="hidden" id="hdn_nomor_invoice_bc40" value="<?php echo $no_invoice_bc40_update; ?>" /><input type="hidden" id="hdn_tgl_invoice_bc40" value="<?php echo $tgl_invoice_bc40_update; ?>" /> 
</div>

<script type="text/javascript">
    
    $(document).ready(function(){
		var currentDate = new Date(); 
		var datesetopt = {
			showOn: "button",
			buttonImageOnly: true,
			buttonImage: "<?php echo base_url()."assets/images/icons/16x16/timespan.png"  ?>",
			buttonText: "Tanggalan",
			dateFormat: 'yy-mm-dd'
		};
		
		$("#tgl_invoice_bc40").datepicker(datesetopt); 	
		
		$("#btnupdateinvoicebc40").button().click(function(){
			var id = jQuery("#tblbc40dok").jqGrid('getGridParam','selrow');
			if (id) { 
				var ret = jQuery("#tblbc40dok").jqGrid('getRowData',id);
				
			} else {
				alert("Please Select Row");
				return false;
			};
			
			if(ret.DokKd != '380'){
				alert("Pilih No Invoice");
				return false;
			}
			var form_data ={
				idhdrbc40:ret.id_bc_in_hdr,
				id_bc_in_dok:ret.id_bc_in_dok,
				nomor_invoice_bc40:$("#nomor_invoice_bc40").val(),
				tgl_invoice_bc40:$("#tgl_invoice_bc40").val(),
				hdn_nomor_invoice_bc40:$("#hdn_nomor_invoice_bc40").val(),
				hdn_tgl_invoice_bc40:$("#hdn_tgl_invoice_bc40").val()
			};		
			
			$("#update_no_invoicebc40_dlg").dialog( "destroy" );
			$(".update_no_invoicebc40_dlgcl").remove();
			$(".update_no_invoicebc40_dlgcl").html('');
			$("body").append('<div id="update_no_invoicebc40_dlg" title="Warning" class="update_no_invoicebc40_dlgcl"><p>Apakah anda akan data ini?!?</p><br /> No Doc dari INVOICE = '+ $("#hdn_nomor_invoice_bc40").val() +'</div>');
			$("#update_no_invoicebc40_dlg").dialog({
				height: 200,
				width: 250,
				modal: true,
				hide: 'Slide',
				autoOpen: 'false',
				buttons: {
					"CONFIRM": function() {
					$.ajax({
						url : "<?php echo base_url().'exim/ct_bc40/update_no_invoicebc40'; ?>",
						type : 'POST',
						dataType: 'json',
						data : form_data,
						success: function(msg){
							if (msg.sts == '00'){
								alert(msg.desc);
								$("#update_no_invoicebc40_dlg").dialog("close");
								$('#update_no_invoicebc40_dlg').dialog("destroy"); 
								$(".update_no_invoicebc40_dlgcl").remove(); 
								jQuery("#tblbc40dok").trigger('reloadGrid');
								
							} else { 
								alert(msg.sts+' '+msg.desc); 
								jQuery("#tblbc40dok").trigger('reloadGrid');
								$("#update_no_invoicebc40_dlg").dialog("close");
								$('#update_no_invoicebc40_dlg').dialog("destroy"); 
								$(".update_no_invoicebc40_dlgcl").remove(); 
								
							}
						}
					});
				},
					"CANCEL": function() {
						$( "#update_no_invoicebc40_dlg" ).dialog( "close" );

					}
				},
				close : function(){
					$('#update_no_invoicebc40_dlg').dialog("destroy"); 
					$(".update_no_invoicebc40_dlgcl").remove(); 
					$("body").append('<div id="update_no_invoicebc40_dlg" title="Warning" class="update_no_invoicebc40_dlgcl"><p>Apakah anda akan memproses file ini?!?</p></div>');     
					
				},
				open: function(){
					$("body").unblock();
					
				}
			});	
			
		
		});
		
		


	});
		  	
</script>



	
	