<style>
.tgl {
	width:70px;
}
table td {
    vertical-align: middle;
    padding:2px;
   
}
</style>
<label style="font-weight:bold;"><?php echo $command; ?> DATA</label>
<input id="id_coa_x" type="hidden" value="<?php echo $id_coa; ?>" />
<input id="command_x" type="hidden" value="<?php echo $command; ?>" />

<div class="ui-layout-content ui-widget-content-panel" >  
<table>
<tr>
<td>COA CODE</td><td>:</td><td><input id="txt_coa_sap" style="text-transform: uppercase;width:220px;" value="<?php echo $coa_sap; ?>" /></td>
</tr>
<tr>
<td>COA NAME</td><td>:</td><td><input id="txt_name_account" style="text-transform: uppercase;width:220px;" value="<?php echo $name_account; ?>" /></td>
</tr>

<tr>
<td>SECTION 1</td><td>:</td><td>
<select id="txt_section1" style="height:17px;width:220px;"  >
	<option value=""></option>
<?php 
	$qry = $this->db->query("
		select 
			[id]
		  ,[tag]
		  ,[kdtab]
		  ,[nama]
		  ,[keterangan]
		from [tbl_acc_table]	
		where [kdtab] = 'section1'
	
	");
	
	foreach($qry->result() as $r){
?> 
	<option value="<?php echo  $r->nama; ?>"><?php echo  $r->nama; ?></option>
<?php
	}
 ?>
</select>
</td>
</tr>


<tr>
<td>SECTION 2</td><td>:</td><td>
<select id="txt_section2" style="height:17px;width:220px;"  >
	<option value=""></option>
<?php 
	$qry = $this->db->query("
		select 
			[id]
		  ,[tag]
		  ,[kdtab]
		  ,[nama]
		  ,[keterangan]
		from [tbl_acc_table]	
		where [kdtab] = 'section2'
	
	");
	
	foreach($qry->result() as $r){
?> 
	<option value="<?php echo  $r->nama; ?>"><?php echo  $r->nama; ?></option>
<?php
	}
 ?>
</select>
</td>
</tr>


<tr>
<td>GROUP 1</td><td>:</td><td>
<select id="txt_target_group1" style="height:17px;width:220px;"  >
<?php 
	$qry = $this->db->query("
		select 
			[id]
			 ,[kdtab]
		  ,[tag]
		  ,[nama]
		  ,[keterangan]
		from [tbl_acc_table]	
		where [kdtab] = 'target_group1'
	
	");
	
	foreach($qry->result() as $r){
?> 
	<option value="<?php echo  $r->nama; ?>"><?php echo  $r->nama; ?></option>
<?php
	}
 ?>
</select>
</td>
</tr>
<tr>
<td>GROUP 2</td><td>:</td><td>
<select id="txt_target_group2" style="height:17px;width:220px;"  >
	<option value=""></option>
<?php 
	$qry = $this->db->query("
		select 
			[id]
			 ,[kdtab]
		  ,[tag]
		  ,[nama]
		  ,[keterangan]
		from [tbl_acc_table]	
		where [kdtab] = 'target_group2'
	
	");
	
	foreach($qry->result() as $r){
?> 
	<option value="<?php echo  $r->nama; ?>"><?php echo  $r->nama; ?></option>
<?php
	}
 ?>
</select>
</td>
</tr>

<tr>
<td>Target Report</td><td>:</td><td>
<select id="txt_target_report" style="height:17px;width:220px;"  >
<?php 
	$qry = $this->db->query("
		select 
			[id]
			 ,[kdtab]
		  ,[tag]
		  ,[nama]
		  ,[keterangan]
		from [tbl_acc_table]	
		where [kdtab] = 'target_report'
	
	");
	
	foreach($qry->result() as $r){
?> 
	<option value="<?php echo  $r->nama; ?>"><?php echo  $r->nama; ?></option>
<?php
	}
 ?>
</select>
</td>
</tr>

</table>	
</div>
<div class="pane-header ui-state-active">    
	<button id="save_coa" >SAVE</button> 
</div>

<script type="text/javascript">
    $(document).ready(function(){
		$("#txt_section1").val("<?php echo $section1; ?>");
		$("#txt_section2").val("<?php echo $section2; ?>");
		$("#txt_target_group1").val("<?php echo $target_group1; ?>");
		$("#txt_target_group2").val("<?php echo $target_group2; ?>");
		$("#txt_target_report").val("<?php echo $target_report; ?>");
		
		$("#save_coa").button().click(function(){
			var form_data = {
				txt_coa_sap : $("#txt_coa_sap").val()
				,txt_name_account: $("#txt_name_account").val()
				,txt_section1: $("#txt_section1").val()
				,txt_section2: $("#txt_section2").val()
				,txt_target_group1: $("#txt_target_group1").val()
				,txt_target_group2: $("#txt_target_group2").val()
				,txt_target_report	: $("#txt_target_report").val()
				,id_coa_x	: $("#id_coa_x").val()
				,command :$("#command_x").val()
			}
			
			$("#save_data_coa").dialog( "destroy" );
			$(".save_data_coacl").remove();
			$(".save_data_coacl").html('');
			$("body").append('<div id="save_data_coa" title="Warning" class="save_data_coacl"><p>Apakah anda akan melakukan ' + $("#command_x").val() + ' Data?</div>');
			$("#save_data_coa").dialog({
				height: 200,
				width: 350,
				modal: true,
				hide: 'Slide',
				autoOpen: 'false',
				buttons: {
					"CONFIRM": function() {
					$.ajax({
						url :"<?php echo base_url().'accounting_report/ct_accounting_report/save_data_coa'; ?>",
						type : 'POST',
						dataType: 'json',
						data : form_data,
						success: function(msg){
							if (msg.sts == '00'){
								alert(msg.desc);
								$("#save_data_coa").dialog("close");
								$('#save_data_coa').dialog("destroy"); 
								$(".save_data_coacl").remove(); 
								$(".save_data_coacl").html('');
								$('#tbl_acc_coa').trigger('reloadGrid');
							
							} else { 
								alert(msg.sts+msg.desc);
								$("#save_data_coa").dialog("close");
								$('#save_data_coa').dialog("destroy"); 
								$(".save_data_coacl").remove(); 		

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

					}
				},
				close : function(){
					$('#save_data_coa').dialog("destroy"); 
					$(".save_data_coacl").remove(); 
					$("body").append('<div id="save_data_coa" title="Warning" class="save_data_coacl"><p>Apakah anda akan melakukan Update Terhadap no BL ini?</p><br />Harap Periksa Baik2 karena perubahan hanya satu kali</div>');     
					$(".save_data_coacl").html('');
				},
				open: function(){
					$("body").unblock();
					
				}
			});		
			
			
		});
		
		
	});
		  	
</script>


	
	