<div style="" >
  <div>
       <table width="320" border="0">
      <tr>
        <td width="167">ITEM CODE</td>
        <td width="8"><div align="center">:</div></td>
        <td width="204"><input type="text" name="txtkodebarang" id="txtscrapcodeupdateitemcode" value="<?php echo $kd_brg; ?>"   style="width:160px"/></td>
      </tr>
      <tr>
        <td>SCRAP NAME </td>
        <td><div align="center">:</div></td>
        <td><input type="text" name="txtnamabarang" id="txtscrapcodeupdatemachinename" value="<?php echo $nama_barang; ?>" style="width:160px"/></td>
      </tr>
      <tr>
        <td>UNIT </td>
        <td><div align="center">:</div></td>
        <td><input type="text" name="txtsatuan" id="txtscrapcodeupdateunit" value="<?php echo $satuan; ?>"  style="width:160px"/></td>
      </tr>
      </table>

  </div>
 </div>
 <input type="hidden" id="idscrapcode" value="<?php echo $idx; ?>" />
 <input type="hidden" id="txtnamabarang_old" value="<?php echo $nama_barang;; ?>" />
 <br />
 <span style="padding-left:245px" /><button id="btnscrapcodeupdateparths" >Update</button>
<script type="text/javascript">
    
    $(document).ready(function(){
		$("input.numeric").numeric();
		$("#txtscrapcodeupdateitemcode").focusout(function(){
			var value = $("#txtscrapcodeupdateitemcode").val(); 
			value = value.replace(/\s/g, '');
			$("#txtscrapcodeupdateitemcode2").val(value);
		});
		$("#btnscrapcodeupdateparths").button().click(function(){
		
			$("#dlgscrapupdateparths").dialog( "destroy" );
			$(".dlgscrapupdateparths_cl").remove();
			$("body").append('<div id="dlgscrapupdateparths" title="Warning" class="dlgscrapupdateparths_cl"><p>Are you sure want to change this scrap code ?</p><br /></div>');
			var form_data = {
				kodebarang:$("#txtscrapcodeupdateitemcode").val(),
				namabarang:$("#txtscrapcodeupdatemachinename").val(),
				namabarang_old:$("#txtnamabarang_old").val(),
				satuan:$("#txtscrapcodeupdateunit").val(),
				id:$("#idscrapcode").val(),
			};
				
			$("#dlgscrapupdateparths").dialog({
				height: 160,
				width: 250,
				modal: true,
				hide: 'Slide',
				autoOpen: 'false',
				buttons: {
					"CONFIRM": function() {
					$.ajax({
						url : "<?php echo base_url().'pasi_settings/ct_scrapcode/updatekodebarang'; ?>",
						type : 'POST',
						dataType: 'json',
						data : form_data,
						success: function(msg){
							if (msg.sts == '00'){
								alert(msg.desc);
								$("#dlgscrapupdateparths").dialog("close");
								$('#dlgscrapupdateparths').dialog("destroy"); 
								$(".dlgscrapupdateparths_cl").remove(); 
								$('#tbl_scrapcode').trigger('reloadGrid');

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

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

					}
				},
				close : function(){
					$('#dlgscrapupdateparths').dialog("destroy"); 
					$(".dlgscrapupdateparths_cl").remove(); 
					$("body").append('<div id="dlgscrapupdateparths" title="Warning" class="dlgscrapupdateparths_cl"><p>Are you sure want to change this scrap code ?</p><br /></div>');     
					
				},
				open: function(){
					$("body").unblock();
					
				}
			});
		
		});

	});
		  	
</script>



	
	