<div style="height:10px;">
	
</div>
<b>NOMOR INVOICE: <?php echo $no_invoice; ?></b>
<table>
	<tr>
		<td>Cek Car yang ada di modul</td><td>:</td><td><input type="text" id="txttarikdariinvoice" value="<?php echo $no_invoice; ?>"/></td><td><button id="btntarikdariinvoice" >Cek Car</button></td>
	</tr>
</table>
<table>
	<tr>
		<td>CAR CC </td><td><input type="text" id="txtinvoicecarcc" style="width:200px"></td>
	</tr>
	<tr>
		<td>MODUL BC23</td><td><input type="text" id="txtinvoicecarmodul" style="width:200px"></td>
	</tr>
</table>
<br />
<br />
<br />
Gunakan menu ini untuk update invoice:
<br />
<table>
	<tr>
		<td>Ganti Nomor Invoice baru yang akan diupdate</td><td>:</td><td><input type="text" id="txtnomorinvoicebaru" value="<?php echo $no_invoice; ?>"/></td><td><button id="btnupdateinvoice" >Update</button></td>
	</tr>
</table>

<script type="text/javascript">
    
    $(document).ready(function(){
		var noinvoicelama='<?php echo $no_invoice; ?>';
		var inv_hdr_id = '<?php echo $inv_hdr_id; ?>';
		$("#btnupdateinvoice").button().click(function(){
			var form_data={
				noinvoicelama:noinvoicelama, inv_hdr_id:inv_hdr_id, noinvoicebaru:$("#txtnomorinvoicebaru").val()
			};
			
			$("#dlgrevicei").dialog( "destroy" );
			$(".dlgreviceicl").remove();
			$(".dlgreviceicl").html('');
			$("body").append('<div id="dlgrevicei" title="Warning" class="dlgreviceicl"><p>Apakah anda akan Melakukan update</p><br /> No Invoice Lama  = '+ noinvoicelama +' menjadi '+ $("#txtnomorinvoicebaru").val() +'</div>');
			$("#dlgrevicei").dialog({
				height: 200,
				width: 250,
				modal: true,
				hide: 'Slide',
				autoOpen: 'false',
				buttons: {
					"CONFIRM": function() {
					$.ajax({
						url : "<?php echo base_url().'exim/ct_inv_draft/updatenoinvoice'; ?>",
						type : 'POST',
						dataType: 'json',
						data : form_data,
						success: function(msg){
							if (msg.sts == '00'){
								alert(msg.desc);
								$("#dlgrevicei").dialog("close");
								$('#dlgrevicei').dialog("destroy"); 
								$(".dlgreviceicl").remove(); 
								$('#tblbc23hdr_draft').trigger('reloadGrid');
							} else { 
								alert(msg.sts+msg.desc); 
								$("#dlgrevicei").dialog("close");
								$('#dlgrevicei').dialog("destroy"); 
								$(".dlgreviceicl").remove(); 

							}
						}
					});
				},
					"CANCEL": function() {
						$( "#dlgrevicei" ).dialog( "close" );
								
					}
				},
				close : function(){
					$('#dlgrevicei').dialog("destroy"); 
					$(".dlgreviceicl").remove(); 
					$("body").append('<div id="dlgrevicei" title="Warning" class="dlgreviceicl"><p>Apakah anda akan Melakukan update<</p></div>');     
					
				},
				open: function(){
					$("body").unblock();
					
				}
			});
			
		
		});
		
		$("#btntarikdariinvoice").button().click(function(){
			var form_data={
				noinvoicelama:noinvoicelama
			};	
			$.ajax({
				url : "<?php echo base_url().'exim/ct_inv_draft/cekinvoicemodul'; ?>",
				type : 'POST',
				dataType: 'json',
				data : form_data,
				success: function(msg){
					if (msg.sts == '00'){
						
						$("#txtinvoicecarcc").val(msg.carcc);
						$("#txtinvoicecarmodul").val(msg.carmodul);
						
					} else { 
						alert(msg.desc);
			
					}
				}
			});
		});
		

	});
		  	
</script>



	
	