<input type="hidden" id="no_packinglistbc262" value="<?php echo $no_packinglist ?>" />
<input type="hidden" id="tgl_packinglistbc262" value="<?php echo $tgl_packinglist ?>" />
<div id="divbc262_packinglist_dtl" >
	<div style="height:40px;">
		<button id="btnbc262_packinglist_add" >ADD NO KONTRAK/SURAT JALAN/KURS</button>
	</div>
	<table id="tblbc262_packinglist_dtl"></table> <div id="ptblbc262_packinglist_dtl"></div>
</div>


<script type="text/javascript">
    
    $(document).ready(function(){
		var datePick = function (el) {
			$(el).datepicker({
				changeYear: true,
				changeMonth: true,
				showButtonPanel: true,
				onSelect: function () {
					
					if (this.id.substr(0, 3) === "gs_") {
                // in case of searching toolbar
					setTimeout(function(){
					jQuery("#tbluploadparths").jqGrid()[0].triggerToolbar();
						}, 50);
					} else {
						// refresh the filter in case of
						// searching dialog
						$(this).trigger('change');
					}
				}    
			});
		};
		jQuery("#tblbc262_packinglist_dtl").jqGrid({
			url:'<?php echo base_url().'exim/ct_bc262/data_packinglist_bc262'; ?>',
			mtype : "post",
			postData:{'q':'1','BB':'XXXX', 'no_packinglistbc262':function () { return $("#no_packinglistbc262").val(); }, 'tgl_packinglistbc262':function () { return $("#tgl_packinglistbc262").val(); }},
			datatype: "json",
			colNames:['id_packinglist','No PackingList','Tgl', 'No Kontrak', 'Tgl Kontrak', 'No Srt Jln', 'Tgl Srt Jln', 'Assy No', 'QTY', 'QTY Box', 'Price', 'Aamount', 'Kurs', 'Unit','Status','id_bc_hdr','id_bc261'],
			colModel:[
				{name:'id_packinglist',id_packinglist:'status', width:99, hidden:true},
				{name:'no_packinglist',index:'no_packinglist', width:110},
				{name:'tgl_packinglist',index:'tgl_packinglist', width:99,stype:"text",searchoptions:{dataInit:datePick, att:{title:'Select Date'}}},
				{name:'no_kontrak',index:'no_kontrak', width:170},
				{name:'tgl_kontrak',index:'tgl_kontrak', width:99,stype:"text",searchoptions:{dataInit:datePick, att:{title:'Select Date'}}},
				{name:'no_surat_jalan',index:'no_surat_jalan', width:160},
				{name:'tgl_surat_jalan',index:'tgl_surat_jalan', width:99,stype:"text",searchoptions:{dataInit:datePick, att:{title:'Select Date'}}},
				{name:'assy_no',index:'assy_no', width:180},
				{name:'qty',index:'qty', width:100, align:'right', formatter:'number',formatoptions: { decimalPlaces: 2 }},
				{name:'qty_box',index:'qty_box', width:100, align:'right', formatter:'number',formatoptions: { decimalPlaces: 2 }},
				{name:'price',index:'price', width:100, align:'right', formatter:'number',formatoptions: { decimalPlaces: 2 }},
				{name:'amount',index:'amount', width:100, align:'right', formatter:'number',formatoptions: { decimalPlaces: 2 }},
				{name:'kurs',index:'kurs', width:100, align:'right', formatter:'number',formatoptions: { decimalPlaces: 2 }},
				{name:'unit',index:'unit', width:60},
				{name:'status',index:'status', width:99},
				{name:'id_bc_hdr',index:'id_bc_hdr', width:99, hidden:true},
				{name:'id_bc261',index:'id_bc261', width:99, hidden:true}
			
				],
			rowNum:10,
			rowList:[10,20,30],
			pager: '#ptblbc262_packinglist_dtl',
			sortname: 'tgl_packinglist',
			viewrecords: true,
			sortorder: "desc",
			height:270,
			width:910,
			jsonReader: { repeatitems : false },
			caption:"DATA PACKING LIST DTL",
			rownumbers: true,
			shrinkToFit: false,
			afterInsertRow: function(){
				
				
			},			
			gridComplete: function(){
				var rowIDs = jQuery("#tblbc262_packinglist_dtl").getDataIDs(); 
				var rowData = $("#tblbc262_packinglist_dtl").getRowData();
			
				for (var i = 0; i < rowData.length; i++) 
				{
				   var trElement = jQuery("#"+ rowIDs[i],jQuery('#tblbc262_packinglist_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;
						
						
					}
				}
			}
		}); 
		
		jQuery("#tblbc262_packinglist_dtl").jqGrid('navGrid','#ptblbc262_packinglist_dtl',{del:false,add:false,edit:false},{},{},{},{multipleSearch:false});
		jQuery("#tblbc262_packinglist_dtl").jqGrid('filterToolbar',{stringResult: true,searchOnEnter : false, defaultSearch: 'cn', ignoreCase: true});
		
		$("#btnbc262_packinglist_add").button().click(function(){
			var form_data = {
				'no_packinglistbc262':function () { return $("#no_packinglistbc262").val(); }, 'tgl_packinglistbc262':function () { return $("#tgl_packinglistbc262").val(); }
			};
			
			$("#frmbc262_view_invoice_dtl_form").load('<?php echo base_url().'exim/ct_bc262/view_bc262_invoice_form'; ?>', form_data, function() {
				$("#frmbc262_view_invoice_dtl_form").dialog({
					modal:true,
					width : 550,
					height : 330,
					buttons: {
                        "Close": function() {  
							$(".ui-dialog-titlebar-close").trigger('click');  
							
						}
                    },
					close : function(){
						$('#frmbc262_view_invoice_dtl_form').dialog("destroy"); 
					    $(".frmbc262_view_invoice_dtl_form_cl").remove(); 
					    $("body").append('<div id="frmbc262_view_invoice_dtl_form" title="FORM UPDATE" class="frmbc262_view_invoice_dtl_form_cl"></div>'); 
						$('#tblbc262_packinglist_dtl').trigger('reloadGrid');
	
					},
					open: function(){
						$("body").unblock();
						
					}
				});
			});
		
		});
		
	});
		  	
</script>
<div id="frmbc262_view_invoice_dtl_form" title="FORM UPDATE" class="frmbc262_view_invoice_dtl_form_cl"></div>

	
	