<div style="height:40px"></div>

<div style="height:200px;position:absolute;left:670px;top:40px" >
  <div>
     <table width="320" border="0">
      <tr>
        <td width="167">PART NO </td>
        <td width="8"><div align="center">:</div></td>
        <td width="204"><input type="text" name="txtpartno" id="txtpartno"  value="<?php echo $part_number; ?>" style="width:160px"/></td>
      </tr>
      <tr>
        <td>PART NAME </td>
        <td><div align="center">:</div></td>
        <td><input type="text" name="txtpartname" id="txtpartname" value="<?php echo $part_name; ?>" style="width:160px"/></td>
      </tr>
      <tr>
        <td>PART NAME CUSTOMS </td>
        <td><div align="center">:</div></td>
        <td><input type="text" name="txtpartnamecustoms" id="txtpartnamecustoms" value="<?php echo $part_name_customs; ?>" style="width:160px"/></td>
      </tr>
      <tr>
        <td>HS CODE </td>
        <td><div align="center">:</div></td>
        <td><input type="text" name="txthscode" id="txthscode" value="<?php echo $hs_code; ?>" style="width:160px"/></td>
      </tr>
      <tr>
        <td>BM</td>
        <td><div align="center">:</div></td>
        <td><input type="text" name="txtbm" id="txtbm" value="<?php echo $bm; ?>" style="width:160px" class='numeric'/></td>
      </tr>
      <tr>
        <td>CEK PRICE </td>
        <td><div align="center">:</div></td>
        <td><input type="text" name="txtcekprice" id="txtcekprice" value="<?php echo $cek_price; ?>" style="width:160px" class='numeric'/></td>
      </tr>
      <tr>
        <td>PART NO 2 </td>
        <td><div align="center">:</div></td>
        <td><input type="text" name="txtpartno2" id="txtpartno2" value="<?php echo $part_number2; ?>" style="width:160px"/></td>
      </tr>
      </table>
  </div>
  <br />
  <br />
  <div style="padding-left:130px">
	<button id="btnupdateparths" >UPDATE</button>
	<button id="btninsertparths" >INSERT</button>


  </div>
</div>
<div style="position:absolute;left:10px;top:40px" >
	<table id="tbldataparthsbc23"></table> <div id="ptbldataparthsbc23"></div>
</div>

<div style="height:40px;">
	
</div>
<input type="hidden" id="hdnidxpartnumberhs" value="<?php echo $idx; ?>" />
<script type="text/javascript">
    
    $(document).ready(function(){
		$("input.numeric").numeric();
		$("#btnupdateparths").button().click(function(){
			$("#dlgupdateparths").dialog( "destroy" );
			$(".dlgupdateparths_cl").remove();
			$(".dlgupdateparths_cl").html();
			$("body").append('<div id="dlgupdateparths" title="Warning" class="dlgupdateparths_cl"><p>Apakah anda akan melakukan update part hs ini?!?</p><br /></div>');
			var form_data = {
				part_no:$("#txtpartno").val(),
				partname:$("#txtpartname").val(),
				partnamecustoms:$("#txtpartnamecustoms").val(),
				bm:$("#txtbm").val(),
				cekprice:$("#txtcekprice").val(),
				part_no2:$("#txtpartno2").val(),
				hscode:$("#txthscode").val(),
				id:$("#hdnidxpartnumberhs").val(),
			};
			
			
			$("#dlgupdateparths").dialog({
				height: 200,
				width: 250,
				modal: true,
				hide: 'Slide',
				autoOpen: 'false',
				buttons: {
					"CONFIRM": function() {
					$.ajax({
						url : "<?php echo base_url().'exim/ct_bc23_view_dtl/updateparths'; ?>",
						type : 'POST',
						dataType: 'json',
						data : form_data,
						success: function(msg){
							if (msg.sts == '00'){
								alert(msg.desc);
								$("#dlgupdateparths").dialog("close");
								$('#dlgupdateparths').dialog("destroy"); 
								$(".dlgupdateparths_cl").remove(); 

							} else { 
								alert(msg.sts+msg.desc); 
								$("#dlgupdateparths").dialog("close");
								$('#dlgupdateparths').dialog("destroy"); 
								$(".dlgupdateparths_cl").remove(); 

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

					}
				},
				close : function(){
					$('#dlgupdateparths').dialog("destroy"); 
					$(".dlgupdateparths_cl").remove(); 
					$("body").append('<div id="dlgupdateparths" title="Warning" class="dlgupdateparths_cl"><p>Apakah anda akan melakukan update part hs ini?!?</p><br /></div>');     
					
				},
				open: function(){
					$("body").unblock();
					
				}
			});
		});
		
		$("#btninsertparths").button().click(function(){
			var form_data = {
				part_no:$("#txtpartno").val(),
				partname:$("#txtpartname").val(),
				partnamecustoms:$("#txtpartnamecustoms").val(),
				bm:$("#txtbm").val(),
				cekprice:$("#txtcekprice").val(),
				part_no2:$("#txtpartno2").val(),
				hscode:$("#txthscode").val(),
			};
			
			$("#dlginsertparths").dialog( "destroy" );
			$(".dlginsertparths_cl").remove();
			$(".dlginsertparths_cl").html('');
			$("body").append('<div id="dlginsertparths" title="Warning" class="dlginsertparths_cl"><p>Apakah anda akan melakukan insert part hs ini?!?</p><br /></div>');
			$("#dlginsertparths").dialog({
				height: 200,
				width: 250,
				modal: true,
				hide: 'Slide',
				autoOpen: 'false',
				buttons: {
					"CONFIRM": function() {
					$.ajax({
						url : "<?php echo base_url().'exim/ct_bc23_view_dtl/insertparths'; ?>",
						type : 'POST',
						dataType: 'json',
						data : form_data,
						success: function(msg){
							if (msg.sts == '00'){
								alert(msg.desc);
								$("#dlginsertparths").dialog("close");
								$('#dlginsertparths').dialog("destroy"); 
								$(".dlginsertparths_cl").remove(); 
								

							} else { 
								alert(msg.sts+msg.desc); 
								$("#dlginsertparths").dialog("close");
								$('#dlginsertparths').dialog("destroy"); 
								$(".dlginsertparths_cl").remove(); 

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

					}
				},
				close : function(){
					$('#dlginsertparths').dialog("destroy"); 
					$(".dlginsertparths_cl").remove(); 
					$("body").append('<div id="dlginsertparths" title="Warning" class="dlginsertparths_cl"><p>Apakah anda akan melakukan update part hs ini?!?</p><br /></div>');     
					
				},
				open: function(){
					$("body").unblock();
					
				}
			});
		});
		
		jQuery("#tbldataparthsbc23").jqGrid({
			url:'<?php echo base_url().'exim/ct_bc23_view_dtl/datapartnumberhs'; ?>',
			mtype : "post",
			postData:{'q':'1'},
			datatype: "json",
			colNames:['id','part no','part name' , 'part name customs', 'hs code','bm' ,'cek price','part no2'],
			colModel:[
				{name:'id',index:'id', width:60, hidden:true},
				{name:'part_no',index:'part_no', width:116, hidden:false},
				{name:'part_name',index:'part_name', width:129, hidden:false},
				{name:'part_name_customs',index:'part_name_customs', width:124, hidden:false},
				{name:'hs_code',index:'hs_code', width:106, hidden:false},
				{name:'bm',index:'bm', width:82, hidden:false,  align:'right'},
				{name:'cek_price',index:'cek_price', width:80, hidden:false,  align:'right', formatter:'number'},
				{name:'part_no2',index:'part_no2', width:110, hidden:false},
				
			],
			rowNum:10,
			rowList:[10,30,40],
			pager: '#ptbldataparthsbc23',
			sortname: 'id',
			viewrecords: true,
			sortorder: "asc",
			width: 650,
			height:250,
			jsonReader: { repeatitems : false },
			caption:"DATA PART HS",
			rownumbers: true,
			shrinkToFit: false,
			afterInsertRow: function(){
				
				
			}
		}); 
			
                        
		jQuery("#tbldataparthsbc23").jqGrid('navGrid','#ptbldataparthsbc23',{edit:false,add:false,del:false,view:true, search:true}, {height:175, width:250});
		jQuery("#tbldataparthsbc23").jqGrid('filterToolbar',{stringResult: true,searchOnEnter : false, defaultSearch: 'cn', ignoreCase: true});
	

	});
		  	
</script>



	
	