<input type="hidden" id="no_packinglistbc262_from" value="<?php echo $no_packinglist ?>" />
<input type="hidden" id="tgl_packinglistbc262_from" value="<?php echo $tgl_packinglist ?>" />
<div style="height:40px;">
	<button id="btnbc262_packinglist_save" >SAVE</button>
</div>
<div>
	<table>
		<tr>
			<td>NO. KONTRAK</td>
			<td>:</td>
			<td><input type="text" id="txt_nokontrak"  style="width:200px"/></td>
			<td>TGL. KONTRAK</td>
			<td>:</td>
			<td><input type="text" id="txt_tglkontrak" placeholder="yyyy-mm-dd"/></td>
		</tr>
		<tr>
			<td>No Srt Jln</td>
			<td>:</td>
			<td><input type="text" id="txtno_surat_jalan"  style="width:200px"/></td>
			<td>Tgl Srt Jln</td>
			<td>:</td>
			<td><input type="text" id="txttgl_surat_jalan" placeholder="yyyy-mm-dd" /></td>
		</tr>
		<tr>
			<td>Kurs</td>
			<td>:</td>
			<td><input type="number" id="txt_kurs"  min="0" style="text-align:right"/></td>
			<td></td>
			<td></td>
			<td></td>
		</tr>
		
	</table>
	*) No Kontrak Harus Sama Persis Dengan Saat Pengajuan BC261, Bisa Buka Di Menu BC261
	DI LEMBAR PERHITUNGAN EXIM BC261
</div>
<script type="text/javascript">
    
    $(document).ready(function(){
		var datesetopt = {
			showOn: "button",
			buttonImageOnly: true,
			buttonImage: "<?php echo base_url()."assets/images/icons/16x16/timespan.png"  ?>",
			buttonText: "Tanggalan",
			dateFormat: 'yy-mm-dd'
		};
		$("#txt_tglkontrak").datepicker(datesetopt);
		$("#txttgl_surat_jalan").datepicker(datesetopt);
		$("#btnbc262_packinglist_save").button().click(function(){
			if($.trim($("#txt_nokontrak").val()) == '' || $("#txt_nokontrak").val() == null){
				alert("nokontrak must be filled out");
				return false;
			} 	
			if($.trim($("#txt_tglkontrak").val()) == '' || $("#txt_tglkontrak").val() == null){
				alert("txt_tglkontrak must be filled out");
				return false;
			} 	
			if($.trim($("#txtno_surat_jalan").val()) == '' || $("#txtno_surat_jalan").val() == null){
				alert("txtno_surat_jalan must be filled out");
				return false;
			} 	
			if($.trim($("#txttgl_surat_jalan").val()) == '' || $("#txttgl_surat_jalan").val() == null){
				alert("txttgl_surat_jalan must be filled out");
				return false;
			} 	
			if($.trim($("#txt_kurs").val()) == '' || $("#txt_kurs").val() == null){
				alert("txtkurs must be filled out");
				return false;
			} 	
			
		
		
		var form_data = {
				no_packinglistbc262_from:function () { return $("#no_packinglistbc262_from").val(); },
				tgl_packinglistbc262_from:function () { return $("#tgl_packinglistbc262_from").val(); },
				txtnokontrak:function () { return $("#txt_nokontrak").val(); },
				txttglkontrak:function () { return $("#txt_tglkontrak").val(); },
				txtsuratjalan:function () { return $("#txtno_surat_jalan").val(); },
				txttanggalsuratjalan:function () { return $("#txttgl_surat_jalan").val(); },
				txtkurs:function () { return $("#txt_kurs").val(); }
		};
		$("#dlg_update_dtl_bc261").dialog( "destroy" );
			$(".dlg_update_dtl_bc261cl").remove();
			$(".dlg_update_dtl_bc261cl").html('');
			$("body").append('<div id="dlg_update_dtl_bc261" title="Warning" class="dlg_update_dtl_bc261cl"><p>Apakah anda akan melakukan Update?!?</p></div>');
			$("#dlg_update_dtl_bc261").dialog({
				height: 200,
				width: 250,
				modal: true,
				hide: 'Slide',
				autoOpen: 'false',
				buttons: {
					"CONFIRM": function() {
					$.ajax({
						url : "<?php echo base_url().'exim/ct_bc262/proses_update_dtl_bc262'; ?>",
						type : 'POST',
						dataType: 'json',
						data : form_data,
						success: function(msg){
							if (msg.sts == '00'){
								alert(msg.desc);
								$("#dlg_update_dtl_bc261").dialog("close");
								$('#dlg_update_dtl_bc261').dialog("destroy"); 
								$(".dlg_update_dtl_bc261cl").remove(); 
								$('#tblbc262_packinglist_dtl').trigger('reloadGrid');
								$('#tblbc262_packing_list262_hdr').trigger('reloadGrid');
								
							} else { 
								alert(msg.sts+' '+msg.desc); 
								$("#dlg_update_dtl_bc261").dialog("close");
								$('#dlg_update_dtl_bc261').dialog("destroy"); 
								$(".dlg_update_dtl_bc261cl").remove(); 

							}
						}
					});
				},
					"CANCEL": function() {
						$( "#dlg_update_dtl_bc261" ).dialog( "close" );

					}
				},
				close : function(){
					$('#dlg_update_dtl_bc261').dialog("destroy"); 
					$(".dlg_update_dtl_bc261cl").remove(); 
					$("body").append('<div id="dlg_update_dtl_bc261" title="Warning" class="dlg_update_dtl_bc261cl"><p>Apakah anda akan memproses file ini?!?</p></div>');     
					
				},
				open: function(){
					$("body").unblock();
					
				}
			});
		});
		
		$("#txt_nokontrak").autocomplete('<?php echo base_url().'exim/ct_bc262/autocompletenokontrak'; ?>', {
			dataType: 'json',
			max: 50,
			width:400,
			parse: function(data) {
				var rows = new Array();
				data = data;
				for(var i=0; i<data.length; i++){
					rows[i] = { data:data[i],
						value:data[i].NOKONTRAK,
						result:data[i].NOKONTRAK
					};
				}
				return rows;
			},
			formatItem: function(row, i, max) {
				return row.NOKONTRAK+ ', ' + row.TGLKONTRAK+ ', ' + row.kurs;
			},
			formatResult: function (row, i, max) {
				eval("row=" + row); 
				return row.no_register;
			},
			extraParams: {
				name_startsWith: function () { return $("#txt_nokontrak").val() }
			}
		});
		
		$("#txt_nokontrak").result(function(event, row, formatted) {
			$("#txt_nokontrak").val(row.NOKONTRAK);
			$("#txt_tglkontrak").val(row.TGLKONTRAK);
			$("#txt_kurs").val(row.kurs);
		});
		
	});
		  	
</script>



	
	