<div style="height:40px;">
	Part Number : <input id="part_number_inv_coo" type="text" />
	<?php if($this->session->userdata('DX_username') == 'admin' || $this->session->userdata('DX_username') == 'yayan' || $this->session->userdata('DX_username') == 'ojah'){ ?>
		<button id="btnupdateinvpartnumbercoo">Update Part</button>
	<?php }; ?>
</div>
<table id="tblinv_coo_bc23_draft_dtl"></table> <div id="ptblinv_coo_bc23_draft_dtl"></div>
<div id="div_cek_part_nocoo_detil_null" style="color:red"><?php echo $test_null_inv; ?></div>
<script type="text/javascript">
    
    $(document).ready(function(){
		
		$("#btnupdateinvpartnumbercoo").click(function(){
			var id = jQuery("#tblinv_coo_bc23_draft_dtl").jqGrid('getGridParam','selrow');
			if (id) { 
				var ret = jQuery("#tblinv_coo_bc23_draft_dtl").jqGrid('getRowData',id);
				
			} else {
				alert("Please Select Row");
				return false;
			};	
			
			var form_data = {
				
				inv_hdr_idxxx:ret.id_coo_data,
				part_number_invxxx:$("#part_number_inv_coo").val(),
				inv_dtlxxx:ret.id_coo
			
			};
						
			$("#update_partinv_bc23_coo_manual").dialog( "destroy" );
			$(".update_partinv_bc23_coo_manualcl").remove();
			$(".update_partinv_bc23_coo_manualcl").html('');
			$("body").append('<div id="update_partinv_bc23_coo_manual" title="Warning" class="update_partinv_bc23_coo_manualcl"><p>PAK YAYAN/PAK NUR Apakah anda akan Memproses Data ini?</p><br />Harap Periksa Baik2 karena perubahan hanya satu kali</div>');
			$("#update_partinv_bc23_coo_manual").dialog({
				height: 200,
				width: 350,
				modal: true,
				hide: 'Slide',
				autoOpen: 'false',
				buttons: {
					"CONFIRM": function() {
					$.ajax({
						url :"<?php echo base_url().'exim/ct_inv_detil_draft/update_part_inv_coo'; ?>",
						type : 'POST',
						dataType: 'json',
						data : form_data,
						success: function(msg){
							if (msg.sts == '00'){
								alert(msg.desc);
								$("#update_partinv_bc23_coo_manual").dialog("close");
								$('#update_partinv_bc23_coo_manual').dialog("destroy"); 
								$(".update_partinv_bc23_coo_manualcl").remove(); 
								$(".update_partinv_bc23_coo_manualcl").html('');
								$('#tblinv_coo_bc23_draft_dtl').trigger('reloadGrid');
								
							} else { 
								alert(msg.sts+msg.desc);
								$("#update_partinv_bc23_coo_manual").dialog("close");
								$('#update_partinv_bc23_coo_manual').dialog("destroy"); 
								$(".update_partinv_bc23_coo_manualcl").remove(); 		

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

					}
				},
				close : function(){
					$('#update_partinv_bc23_coo_manual').dialog("destroy"); 
					$(".update_partinv_bc23_coo_manualcl").remove(); 
					$("body").append('<div id="update_partinv_bc23_coo_manual" title="Warning" class="update_partinv_bc23_coo_manualcl"><p>Apakah anda akan Memproses Data ini Menjadi Data BC23?</p></div>');     
					$(".update_partinv_bc23_coo_manualcl").html('');
				},
				open: function(){
					$("body").unblock();
					
				}
			});	
		
		});
		
		
		jQuery("#tblinv_coo_bc23_draft_dtl").jqGrid({
			url:'<?php echo base_url().'exim/ct_inv_draft/v_coo_data'; ?>',
			mtype : "post",
			postData:{'q':'1', 'id_coo_data1':function(){ return <?php echo $id_coo_data; ?>} },
			datatype: "json",
			colNames:[
			'ID','ID Hdr' ,
			 'Part Number', 'Description','UOM' ,
			 'Qty','PRICE' ,'KDVAL', 'NET WEIGHT','NEG. ASAL' ,'ORDER NO','TOTAL AMOUNT' ,'Box', 'Pack','CONTAINER'
			 ,'SUP NEG'
			 
			],
			colModel:[
				{name:'id_coo',index:'id_coo', width:60, hidden:true},
				{name:'id_coo_data',index:'id_coo_data', width:60, hidden:true},
				{name:'ITEM_NUMBER',index:'ITEM_NUMBER', width:119, hidden:false},
				{name:'DESCRIPTION',index:'DESCRIPTION', width:184, hidden:false},
				{name:'UOM',index:'UOM', width:50, hidden:false},
				{name:'ARRIV_PLAN_NUMBER',index:'ARRIV_PLAN_NUMBER', width:80, hidden:false,  align:'right', formatter:'number', formatoptions: { decimalPlaces: 4 }},
				{name:'PRICE',index:'PRICE', width:80, hidden:false,  align:'right', formatter:'number', formatoptions: { decimalPlaces: 4 }},
				{name:'CURRENT_MONEY',index:'CURRENT_MONEY', width:50, hidden:false},
				{name:'NET_WEIGHT',index:'NET_WEIGHT', width:90, hidden:false,  align:'right'},
				{name:'kd_neg',index:'kd_neg', width:70, hidden:false},
				{name:'ORDER_NO',index:'ORDER_NO', width:90, hidden:false},
				{name:'amount',index:'amount', width:90, hidden:false,  align:'right', formatter:'number', formatoptions: { decimalPlaces: 4 }},
				{name:'CTN_QUANTITY',index:'CTN_QUANTITY', width:50, hidden:false, align:'right'},
				{name:'PACKING_QTY',index:'PACKING_QTY', width:50, hidden:false, align:'right'},
				{name:'CONTIANER_NO',index:'CONTIANER_NO', width:50, hidden:false},
				{name:'supplier_country',index:'supplier_country', width:50, hidden:false},
			],
			rowNum:15,
			rowList:[15,30,40],
			pager: '#ptblinv_coo_bc23_draft_dtl',
			sortname: 'id_coo',
			viewrecords: true,
			sortorder: "asc",
			width: 1030,
			height:250,
			jsonReader: { repeatitems : false },
			caption:"INVOICE ITEMS DATA",
			rownumbers: true,
			shrinkToFit: false,
			afterInsertRow: function(){
				
				
			},
			onSelectRow: function(ids) { 
				var ret = jQuery("#tblinv_coo_bc23_draft_dtl").jqGrid('getRowData',ids);
				$("#part_number_inv_coo").val(ret.ITEM_NUMBER);	
					
			}
		}); 
			
                        
		jQuery("#tblinv_coo_bc23_draft_dtl").jqGrid('navGrid','#ptblinv_coo_bc23_draft_dtl',{edit:false,add:false,del:false,view:true, search:true}, {height:175, width:250});
		jQuery("#tblinv_coo_bc23_draft_dtl").jqGrid('filterToolbar',{stringResult: true,searchOnEnter : true, defaultSearch: 'cn', ignoreCase: true});
	

	});
		  	
</script>


	
	