<?php
	require_once("../../includes/bootstrap.php");
	require_once("../../includes/phpExcel/PHPExcel.php");
	$sesion=new sesion();
	$academia=bootstrap::initBd($sesion->get('anio'));
	$tipo_usuario=$sesion->getVar('ac_tipo_user');
	cache();
?>
<script type="text/javascript">
$(function(){
	var tbNewDts=$("#dtSo");
	
	 var toolbar = [
	 	{  
			text:'Add',  
			iconCls:'icon-add',  
			handler:function(){
				var dtsSel=$("#tbCamposCons").datagrid('getSelections');
				for(x in dtsSel){
					tbNewDts.append('<tr id="'+dtsSel[x].id+'"><td>'+dtsSel[x].desc+'</td></tr>');
				}
				tbNewDts.tableDnD();
			}  
		},'-'
	]; 
	$("#tbCamposCons").datagrid({
		toolbar:toolbar
	});
	$(".easyui-linkbutton").linkbutton().click(function(){
		dts=tbNewDts.tableDnDSerialize();
		alert(dts);
		$("#objDescargas").attr("src","mod_reportes/reporte_estud_automata/gen_xsl_rep_automata.php?"+dts);
	});
	$("#panelDtsSel").panel()
})
</script>
<table border="0" cellspacing="0" cellpadding="5">
	<tr>
		<td><table id="tbCamposCons" class="easyui-datagrid"
			data-options="rownumbers:true,checkOnSelect:true,selectOnCheck:true" style="width:260px;height:250px">
			<thead>
				<tr>
					<th data-options="field:'ck',checkbox:true"></th>
					<th data-options="field:'id',width:80,hidden:true">Item ID</th>
					<th data-options="field:'desc',width:200">Descripción</th>
				</tr>
			</thead>
			<tbody>
				<?php
		$sql="SELECT nom_campo_tb, des_campo FROM conf_capos_cons_estudiantes";
		$academia->instruccion($sql);
		while($reg=$academia->extraer_registro()){
			echo "<tr><td></td><td>".$reg['nom_campo_tb']."</td><td>".$reg['des_campo']."</td></tr>";
		}
	?>
			</tbody>
		</table></td>
		<td valign="top">
			<div id="panelDtsSel" class="easyui-panel" title="Orden de los campos"style="width:500px;height:250px;padding:10px;background:#fafafa;"> 
			<table border="0" cellspacing="0" cellpadding="0" id="dtSo" class="table table-bordered table-condensed table-striped">
			
			</table>
		</div>
		</td>
	</tr>
	<tr>
		<td colspan="2"><a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-excel'">Generar reporte</a></td>
	</tr>
</table>
