<div style="" >
  <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="txt_bp_partno_out" id="txt_bp_partno_out"  value="<?php echo $part_no; ?>" style="width:160px;text-transform: uppercase" readonly="readonly"/></td>
      </tr>
      <tr>
        <td>PART NAME </td>
        <td><div align="center">:</div></td>
        <td><input type="text" name="txt_bp_partname_out" id="txt_bp_partname_out" value="<?php echo $part_name; ?>" style="width:160px;text-transform: uppercase" readonly="readonly"/></td>
      </tr>
      <tr>
        <td>QTY </td>
        <td><div align="center">:</div></td>
        <td><input type="text" name="txt_bp_update_qty_out" id="txt_bp_update_qty_out" value="<?php echo $qty; ?>" style="width:160px;text-transform: uppercase"/></td>
      </tr>
      <tr>
        <td>STATUS </td>
        <td><div align="center">:</div></td>
        <td>
			<select name="txt_bp_update_status_out" id="txt_bp_update_status_out" style="width:160px">
			  <option value="APPROVED">APPROVED</option>
			  <option value="CANCEL">CANCEL</option>
			</select>
		</td>
      </tr>
      </table>
  </div>
 </div>
 <input type="hidden" id="hdn_bp_id_bp_out_dtl" value="<?php echo $id_bp_out_dtl; ?>" />
 <br />
 
 <span style="padding-left:130px" /><button id="btn_bp_out_update" >Update</button><span style="padding-left:10px" /><button id="btn_bp_out_insert" >Insert</button>
<?php if($this->session->userdata('DX_username') == 'admin' || $this->session->userdata('DX_username') == 'yayan' || $this->session->userdata('DX_username') == 'nurhadi' || $this->session->userdata('DX_username') == 'ojah'){ ?>
	<span style="padding-left:10px" /><button id="btn_bp_out_delete" >Delete</button>
 <?php } ?>
 <script type="text/javascript">
    
    $(document).ready(function(){
		$("input.numeric").numeric();
		
		$("#txt_bp_update_status_out").val("<?php echo $status_data; ?>");
		
		$("#btn_bp_out_insert").button().click(function(){
			var form_data = {
				txt_bp_partno_out:$("#txt_bp_partno_out").val(),
				txt_bp_partname_out:$("#txt_bp_partname_out").val(),
				txt_bp_update_qty_out:$("#txt_bp_update_qty_out").val(),
				txt_bp_update_status_out:$("#txt_bp_update_status_out").val(),
				hdn_bp_id_bp_out_dtl:$("#hdn_bp_id_bp_out_dtl").val(),
				command:'INSERT'
			};
			
			$("#dlg_bp_insert_bp_out").dialog( "destroy" );
			$(".dlg_bp_insert_bp_out_cl").remove();
			$("body").append('<div id="dlg_bp_insert_bp_out" title="Warning" class="dlg_bp_insert_bp_out_cl"><p>Apakah anda akan melakukan insert data out ini?!?</p><br /></div>');
			$("#dlg_bp_insert_bp_out").dialog({
				height: 200,
				width: 250,
				modal: true,
				hide: 'Slide',
				autoOpen: 'false',
				buttons: {
					"CONFIRM": function() {
					$.ajax({
						url : "<?php echo base_url().'settings/ct_barangbahanpenolong/update_bahanpenolong_out'; ?>",
						type : 'POST',
						dataType: 'json',
						data : form_data,
						success: function(msg){
							if (msg.sts == '00'){
								alert(msg.desc);
								$("#dlg_bp_insert_bp_out").dialog("close");
								$('#dlg_bp_insert_bp_out').dialog("destroy"); 
								$(".dlg_bp_insert_bp_out_cl").remove(); 
								$('#tbl_data_bp_bc_out_prod').trigger('reloadGrid');
								$("body").append('<div id="dlg_bp_insert_bp_out" title="Warning" class="dlg_bp_insert_bp_out_cl"></div>');
			

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

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

					}
				},
				close : function(){
					$('#dlg_bp_insert_bp_out').dialog("destroy"); 
					$(".dlg_bp_insert_bp_out_cl").remove(); 
					$("body").append('<div id="dlg_bp_insert_bp_out" title="Warning" class="dlg_bp_insert_bp_out_cl"><p>Apakah anda akan melakukan insert part hs ini?!?</p><br /></div>');     
					
				},
				open: function(){
					$("body").unblock();
					
				}
			});
		
		});
		
		
		
		$("#btn_bp_out_update").button().click(function(){
		
			var form_data = {
				txt_bp_partno_out:$("#txt_bp_partno_out").val(),
				txt_bp_partname_out:$("#txt_bp_partname_out").val(),
				txt_bp_update_qty_out:$("#txt_bp_update_qty_out").val(),
				txt_bp_update_status_out:$("#txt_bp_update_status_out").val(),
				hdn_bp_id_bp_out_dtl:$("#hdn_bp_id_bp_out_dtl").val(),
				command:'UPDATE'
			};
			
			$("#dlg_bp_update_bp_out").dialog( "destroy" );
			$(".dlg_bp_update_bp_out_cl").remove();
			$("body").append('<div id="dlg_bp_update_bp_out" title="Warning" class="dlg_bp_update_bp_out_cl"><p>Apakah anda akan melakukan update part hs ini?!?</p><br /></div>');
			
			$("#dlg_bp_update_bp_out").dialog({
				height: 160,
				width: 250,
				modal: true,
				hide: 'Slide',
				autoOpen: 'false',
				buttons: {
					"CONFIRM": function() {
					$.ajax({
						url : "<?php echo base_url().'settings/ct_barangbahanpenolong/update_bahanpenolong_out'; ?>",
						type : 'POST',
						dataType: 'json',
						data : form_data,
						success: function(msg){
							if (msg.sts == '00'){
								alert(msg.desc);
								$("#dlg_bp_update_bp_out").dialog("close");
								$('#dlg_bp_update_bp_out').dialog("destroy"); 
								$(".dlg_bp_update_bp_out_cl").remove(); 
								$('#tbl_data_bp_bc_out_prod').trigger('reloadGrid');
								$('#tbl_data_bp_bc_out').trigger('reloadGrid');
							} else { 
								alert(msg.sts+msg.desc); 
								$("#dlg_bp_update_bp_out").dialog("close");
								$('#dlg_bp_update_bp_out').dialog("destroy"); 
								$(".dlg_bp_update_bp_out_cl").remove(); 

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

					}
				},
				close : function(){
					$('#dlg_bp_update_bp_out').dialog("destroy"); 
					$(".dlg_bp_update_bp_out_cl").remove(); 
					$("body").append('<div id="dlg_bp_update_bp_out" title="Warning" class="dlg_bp_update_bp_out_cl"><p>Apakah anda akan melakukan update part hs ini?!?</p><br /></div>');     
					
				},
				open: function(){
					$("body").unblock();
					
				}
			});
		
		});
		
		
		$("#btn_bp_out_delete").button().click(function(){
			
			var form_data = {
				txt_bp_partno_out:$("#txt_bp_partno_out").val(),
				txt_bp_partname_out:$("#txt_bp_partname_out").val(),
				txt_bp_update_qty_out:$("#txt_bp_update_qty_out").val(),
				txt_bp_update_status_out:$("#txt_bp_update_status_out").val(),
				hdn_bp_id_bp_out_dtl:$("#hdn_bp_id_bp_out_dtl").val(),
				command:'DELETE'
			};
				
			$("#dlg_bp_delete_bp_out").dialog( "destroy" );
			$(".dlg_bp_delete_bp_out_cl").remove();
			$(".dlg_bp_delete_bp_out_cl").html('');
			$("body").append('<div id="dlg_bp_delete_bp_out" title="Warning" class="dlg_bp_delete_bp_out_cl"><p>Apakah anda akan melakukan <b>DELETE</b> part hs ini?!?</p><br /></div>');
			
			
			$("#dlg_bp_delete_bp_out").dialog({
				height: 160,
				width: 250,
				modal: true,
				hide: 'Slide',
				autoOpen: 'false',
				buttons: {
					"CONFIRM": function() {
					$.ajax({
						url : "<?php echo base_url().'settings/ct_barangbahanpenolong/update_bahanpenolong_out'; ?>",
						type : 'POST',
						dataType: 'json',
						data : form_data,
						success: function(msg){
							if (msg.sts == '00'){
								alert(msg.desc);
								$("#dlg_bp_delete_bp_out").dialog("close");
								$('#dlg_bp_delete_bp_out').dialog("destroy"); 
								$(".dlg_bp_delete_bp_out_cl").remove(); 
								$(".dlg_bp_delete_bp_out_cl").html('');
								$('#tbl_data_bp_bc_out_prod').trigger('reloadGrid');
								$('#tbl_data_bp_bc_out').trigger('reloadGrid');
								
							} else { 
								alert(msg.sts+msg.desc); 
								$("#dlg_bp_delete_bp_out").dialog("close");
								$('#dlg_bp_delete_bp_out').dialog("destroy"); 
								$(".dlg_bp_delete_bp_out_cl").remove(); 

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

					}
				},
				close : function(){
					$('#dlg_bp_delete_bp_out').dialog("destroy"); 
					$(".dlg_bp_delete_bp_out_cl").remove(); 
					$("body").append('<div id="dlg_bp_delete_bp_out" title="Warning" class="dlg_bp_delete_bp_out_cl"><p>Apakah anda akan melakukan <b>DELETE</b> part hs ini?!?</p><br /></div>');     
					
				},
				open: function(){
					$("body").unblock();
					
				}
			});
		}); 
		

	});
		  	
</script>



	
	