<?
////////////////////////////////////////////////////
// Conciliación: gestión de conciliación de activos
// Version: 1.0
//
// Copyright (C) 2014  Eustotem Multimedia, S.L.
//
// License: MIT, see LICENSE
////////////////////////////////////////////////////


if(!isset($_REQUEST['anno'])){
	$_REQUEST['anno']=date("Y");
	$_GET['anno']=date("Y");
}
include("../conf/preferences.php");
session_name(SYS_APP_SESSNAME);
session_start();
include("../conf/langs/".$langs[$_SESSION['userlang']][0]."/MAIN.php");
include("../conf/connections.php");
include("../phplib/auth.php");
require_once("../phplib/utils.php");
require_once("../core/plugins.php");

function getHeaders($conf){
	global $permissions;
	$cadena="";
	if(((string)$conf->layout->col_check=="true" && $permissions[3]==1) || $_SESSION[session_id()]['level']==1){
		$cadena.='<td width="16"  class="header_columns ui-widget-header"><input class="checks" name="checkAll" type="checkbox" id="checkAll" onclick="toggleAllChecked()" /></td>';
	}
	if(isset($conf->data->field_sort)) $cadena.="<td width='12' class='header_columns ui-widget-header'><img src='../resources/themes/default/icon_move.gif' alt='".TABLE_REORDER_ICON."' /></td>";
	foreach($conf->column_model->column as $columna){
		if((string)$columna['exclude_from_simple']=="true") continue;								
		$field=(string)$columna['boundTo'];															
		$orderby=isset($_GET['orderby']) ? $_GET['orderby'] : (string)$conf->data->orderby;			
		$sortby=isset($_GET['sortby']) ? $_GET['sortby'] : (string)$conf->data->sortby;				
		$urlparams=$_GET;
		if($field==$orderby){
			$sort=$sortby=="DESC" ? "" : "DESC";
		}else{
			$sort='';
		}
		$temp=array('orderby'=>$field,'sortby'=>$sort);
		$enlace='template_master_1.php?'.changeUrlParams($urlparams,$temp);
		$cadena.='<td class="header_columns ui-widget-header">';
		if(isset($columna['icon'])){
			$poner="<img border='0' src='" . $columna['icon'] . "' alt='".$columna['label']."' />";
		}else{
			$poner='<strong>'.$columna['label'].'</strong>';
		}
		$cadena.='<a href="'.$enlace.'" title="'.$columna['label'].'">' . $poner . '</a>';
		if($field==$orderby){
			$cadena.='&nbsp;<img class="arrow" src="../resources/themes/default/' . ($sortby=="DESC" ? "a_dn.gif" : "a_up.gif") . '" />';
		}
		$cadena.='</td>';
	}
	$extracol=false;
	if(((string)$conf->layout->col_edit=="true" && $permissions[2]==1) || $_SESSION[session_id()]['level']==1){
		$extracol=true;
	}
	if(((string)$conf->layout->col_details=="true" && $permissions[4]==1) || $_SESSION[session_id()]['level']==1){
		$extracol=true;
	}
	if($extracol==true) $cadena.='<td width="16"  class="header_columns ui-widget-header">&nbsp;</td>';
	return $cadena;
}

function getTableRow($f,$fila,$conf){
	global $permissions; global $page; global $pagesize;
	$userprocess=new UserProcessing();
	$process=new Process();
	$field_key=(string)$conf->data->field_key;
	
	if(isset($conf->column_model['rowProcess'])){
		$rowPrArr=explode("/",$conf->column_model['rowProcess']);
		include_once("../".$rowPrArr[0]."/".$rowPrArr[1]);
		$rp=new $rowPrArr[2];
		$rp->recordset=$f;
		$estilofila=$rp->$rowPrArr[3]();
	}
	
	$cadena='';
	$cadena.="<tr id='row_{$fila}' {$estilofila}>";
	if(((string)$conf->layout->col_check=="true" && $permissions[3]==1) || $_SESSION[session_id()]['level']==1){
		$cadena.='<td class="cell_main_mini" >';
		if(isset($conf->data->field_lock_del) && $f[(string)$conf->data->field_lock_del]==1){
			$cadena.='<img src="../resources/themes/default/forbidden.png" alt="'.TABLE_DEL_FORBIDDEN.'" />';
		}else{
			$cadena.='<input class="checks" type="checkbox" name="checkRow[' . $f[$field_key] . ']" id="checkRow[' . $f[$field_key] . ']" value="' . $f[$field_key] . '" />';
		}
		$cadena.='</td>';
	}
	if(isset($conf->data->field_sort)) $cadena.="<td width='12' id='hsorter_{$f[$field_key]}' class='sorter cell_main'><input type='hidden' name='sorter_{$f[$field_key]}' id='sorter_{$f[$field_key]}' value='".$f[(string)$conf->data->field_sort]."' /></td>";
	foreach($conf->column_model->column as $columna){
		if((string)$columna['exclude_from_simple']=="true") continue;									
		$valor=$f[(string)$columna['boundTo']];
		$cellid='cell_'.$columna['boundTo'].'_'.$fila;							
		if(isset($columna['lang']) && $columna['lang']!='') $valor=Content::extractLang($valor, $columna['lang']);
		if(isset($columna->process)){
			$metodo=(string)$columna->process["method"];
			$valor=$process->$metodo($valor,$columna->process)->content;
		}
		if(isset($columna['postprocess'])){
			$metodo=(string)$columna["postprocess"];
			$formato=$userprocess->$metodo($valor,(string)$columna['postprocess']);
			$cellstyle=' style="'.$formato->cell.'" ';
			$valor=$formato->content;
		}else{
			$inv_dates=array('0000-00-00', '0000-00-00 00:00:00', '00:00:00', '', NULL);
			if($columna['type']=='date' || $columna['type']=='datetime' || $columna['type']=='time'){
				if(in_array($valor,$inv_dates)){
					$valor='';
				}else{
					$formats=array("date"=>CAL_DATE_FORMAT, "datetime"=>CAL_DATETIME_FORMAT, "time"=>CAL_TIME_FORMAT);
					$date=new DateTime($valor);
					$valor=$date->format($formats[(string)$columna['type']]);
				}
			}
			$cellstyle=isset($columna['cellstyle']) ? ' style="'.$columna['cellstyle'].'"' : '';
			$valor=isset($columna['style']) ? ' <span style="'.$columna['style'].'">'.$valor.'</span>' : $valor;
		}
		if($columna->wrapper!='') $valor=replaceSpecialParams(str_replace(STR_SEPARATOR,$valor,(string)$columna->wrapper),$f);		
		$valor=Content::parse($valor);
		$cadena.='<td class="cell_main" id="'.$cellid.'" '.$cellstyle.'>'.$valor.'</td>';
	}
	$extracol=false; $cadena2="";
	if((string)$conf->layout->col_edit=="true"){
		$accion=$permissions[2]==1 || $_SESSION[session_id()]['level']==1 ? 'edit' : 'view';
		$extracol=true;
		$cadena2.='<a href="template_detail_1.php?_action=' . $accion . '&amp;resId=' . $_GET['resId'] . '&amp;id=' . $f[$field_key] . '&amp;mymasterpage=' . urlencode($_SERVER['REQUEST_URI']) . '" title="'.TABLE_TEXT_EDIT.'" class="button icon_button"><img class="icon_edit" src="../resources/themes/default/edit_icon.gif" alt="'. TABLE_TEXT_EDIT .'" style="border:0;" /></a>';
	}
	if((string)$conf->layout->col_details=="true"){
		$extracol=true;
		$pos=$fila+($page*$pagesize);	
		$url=changeUrlParam('pos',$pos).'&amp;id='.$f[$field_key].'&amp;mymasterpage='.urlencode($_SERVER['REQUEST_URI']);
		$cadena2.='<a href="template_detail_9.php?'.$url.'" title="'.TABLE_TEXT_EDIT.'" class="button icon_button"><img class="icon_edit" src="../resources/themes/default/view_icon.png" alt="'. TABLE_TEXT_EDIT .'" style="border:0;" /></a>';
	}
	if($extracol==true) $cadena.='<td class="cell_main_mini" width="16" style="white-space:nowrap" >'.$cadena2.'</td>';
	$cadena.='</tr>';
	return $cadena;
}

function getTotalsRow($conf){
	global $permissions;
	global $tabla;			
	$process=new Process();
	$va=true;
	foreach($conf->column_model->column as $columna){
		if((string)$columna['autosum']=="true") $va=false;
	}
	if($va==true) return '';
	
	$cadena='<tr class="barra_totales" >';
	if(((string)$conf->layout->col_check=="true" && $permissions[3]==1) || $_SESSION[session_id()]['level']==1){ $cadena.='<td >Sum:</td>'; }
	if(isset($conf->data->field_sort)) $cadena.="<td width='12'></td>";
	foreach($conf->column_model->column as $columna){
		if((string)$columna['exclude_from_simple']=="true") continue;									
		$cellstyle=isset($columna['cellstyle']) ? ' style="'.$columna['cellstyle'].'"' : '';
		$cadena.='<td '.$cellstyle.' >';
		if((string)$columna['autosum']=="true"){
			$value=0;
			for($i=0;$i<count($tabla);$i++){
				$value+=$tabla[$i][(string)$columna['boundTo']];
			}
			if(isset($columna->process)){
				$metodo=(string)$columna->process["method"];
				$value=$process->$metodo($value,$columna->process)->content;
			}
			$cadena.=$value;
		}
		$cadena.='</td>';
	}
	$extracol=false;
	if((string)$conf->layout->col_edit=="true" || $_SESSION[session_id()]['level']==1){ $extracol=true; }
	if((string)$conf->layout->col_details=="true" || $_SESSION[session_id()]['level']==1){ $extracol=true; }
	if($extracol==true) $cadena.='<td width="20">&nbsp;</td>';
	$cadena.='</tr>';
	return $cadena;
}
function getAvgsRow($conf){
	global $permissions;
	global $tabla;			
	$process=new Process();
	$va=true;
	foreach($conf->column_model->column as $columna){
		if((string)$columna['autoavg']=="true") $va=false;
	}
	if($va==true) return '';
	
	$cadena='<tr class="barra_totales" >';
	if(((string)$conf->layout->col_check=="true" && $permissions[3]==1) || $_SESSION[session_id()]['level']==1){ $cadena.='<td >Avg:</td>'; }
	if(isset($conf->data->field_sort)) $cadena.="<td width='12'></td>";
	foreach($conf->column_model->column as $columna){
		if((string)$columna['exclude_from_simple']=="true") continue;									
		$cadena.='<td >';
		if((string)$columna['autoavg']=="true"){
			$value=0;
			for($i=0;$i<count($tabla);$i++){
				$value+=$tabla[$i][(string)$columna['boundTo']];
			}
			if(isset($columna->process)){
				$metodo=(string)$columna->process["method"];
				$value=$process->$metodo($value,$columna->process)->content;
			}
			$cadena.=number_format($value/count($tabla),2,SYS_DECIMALS_SEP,SYS_THOUSANDS_SEP);
		}
		$cadena.='</td>';
	}
	$extracol=false;
	if((string)$conf->layout->col_edit=="true" || $_SESSION[session_id()]['level']==1){ $extracol=true; }
	if((string)$conf->layout->col_details=="true" || $_SESSION[session_id()]['level']==1){ $extracol=true; }
	if($extracol==true) $cadena.='<td width="20" >&nbsp;</td>';
	$cadena.='</tr>';
	return $cadena;
}

if(!isset($_GET['resId'])) header("Location:error.php");
$resId=$_GET['resId'];
if(isset($_GET['parentId'])) $parentId=$_GET['parentId'];
$conf=simplexml_load_file("../conf/resources/".$langs[$_SESSION['userlang']][0]."/".$_SESSION['conf'][$resId]->masterview);
$titulogeneral=$conf->title!=NULL ? $conf->title : $_SESSION['conf'][$resId]->title;


$table=array();										
unset($_SESSION['uploads'][$resId]);				
$errores=array();									
$cols=0;											
$_SESSION['current_master_page']=$_SERVER['REQUEST_URI'];
$page=isset($_GET['page']) ? $_GET['page'] : 0;										
$pagesize=(isset($_GET['pagesize']) && $_GET['pagesize']!="0") ? $_GET['pagesize'] : $conf->data->pagesize;		
$orderby=isset($_GET['orderby']) ? $_GET['orderby'] : $conf->data->orderby;			
$sortby=isset($_GET['sortby']) ? $_GET['sortby'] : $conf->data->sortby;				

$consulta=(string)$conf->data->sql;
$filtros=isset($conf->filters) ? FilterProcess::getQuery($consulta,$conf->filters) : '';	
$consulta=str_replace("{@filters}",$filtros,$consulta);
$consulta=Content::parse($consulta);														
$consulta=exclContent($consulta);															

if(isset($conf->data->orderby))$consulta.=" ORDER BY " . $orderby;
$q=mysql_query($consulta) or die(mysql_error()."<br>" . $consulta);
$totalrows=mysql_num_rows($q);
$pages=ceil($totalrows/($pagesize>0 ? $pagesize : 1));
if((int)$page>=$pages-1 || (string)$page=='last') $page=$pages-1;
if((int)$page<0 || (string)$page=='first') $page=0;
if(isset($conf->data->pagesize)){
	$qlimit=((int)$pagesize>0) ? " LIMIT " . ($pagesize*$page) . "," . $pagesize : "";
	if(isset($conf->data->orderby)) $consultab=$consulta;
	$q=mysql_query($consultab . $qlimit) or die(mysql_error()."<br>" . $consultab . $qlimit);
}
$currows=mysql_num_rows($q);		

foreach($conf->column_model->column as $columna){ $cols++; }		
$cols+= (((string)$conf->layout->col_edit=="true") || ((string)$conf->layout->col_details=="true")) + ((string)$conf->layout->col_check=="true") + (isset($conf->data->field_sort));
while($f=mysql_fetch_assoc($q)){ $tabla[]=$f; Content::$data['main']=$f; }
if(isset($conf->data->aux_datasets)){
	foreach($conf->data->aux_datasets->dataset as $aux){
		$sql=Content::parse((string)$aux);
		$qq=mysql_query($sql) or print($sql);
		if(mysql_num_rows($qq)>1){
			Content::$data[(string)$aux['name']]=array();
			while($ff=mysql_fetch_assoc($qq)){
				Content::$data[(string)$aux['name']][]=$ff;
			}
		}else if(mysql_num_rows($qq)==1){
			$ff=mysql_fetch_assoc($qq);
			Content::$data[(string)$aux['name']]=$ff;
		}
	}
}

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title><? echo $_SESSION['application']['title'] ?></title>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<link href="../resources/themes/default/common.css" rel="stylesheet" type="text/css" media="screen" />
	<link href="../resources/themes/default/main.css" rel="stylesheet" type="text/css" media="screen" />
	<link href="../resources/themes/default/form_screen.css" rel="stylesheet" type="text/css" media="screen" />
	<?
	$styles=(string)$conf->layout->styles;
	if($styles!=NULL && $styles!='' && $styles!='main.css'){
	?>
	<link href="../resources/themes/default/<? echo $styles ?>" rel="stylesheet" type="text/css" media="screen" />
	<? } ?>
	<link type="text/css" href="../jslib/jq/ui/css/<? echo UI_THEME ?>/jquery-ui.custom.css" rel="stylesheet" />
	<link type="text/css" href="../jslib/jq/ui/css/<? echo UI_THEME ?>/jquery-ui.ekain.css" rel="stylesheet" />
	<script type="text/javascript" src = "../jslib/jq/jquery-1.7.2.min.js" ></script>
	<script type="text/javascript" src = "../jslib/jq/jquery.blockUI.js" ></script>
	<script type="text/javascript" src = "../jslib/jq/ui/js/jquery-ui-1.8.21.custom.min.js" ></script>
	<script type="text/javascript" src = "../jslib/jq/ui/jquery.ui.selectmenu.js" ></script>
	<link type="text/css" href="../jslib/jq/ui/css/<? echo UI_THEME ?>/jquery.ui.selectmenu.css" rel="stylesheet" />
	<script type="text/javascript" src = "../jslib/jq/ui/i18n/jquery.ui.datepicker-<? echo $langs[$_SESSION['userlang']][0] ?>.js" ></script>
	
	<script type="text/javascript" src="../jslib/utils.js"></script>
	<script src="../jslib/swfobject2.js" type="text/javascript"></script>
	<script type="text/javascript">
	
	var cal_date_format="<? echo CAL_DATE_FORMAT ?>";
	var cal_invalid_date="<? echo CAL_INVALID_DATE ?>";
	function toggleAllChecked(){
		var el=document.getElementById("checkAll");
		valor=el.checked;
		var frm=document.getElementById("dataform");
		for(i=0;i<frm.elements.length;i++){
			if(frm.elements[i].name.substr(0,8)=="checkRow"){
				frm.elements[i].checked=valor;
			}
		}
	}
	
	function submitTo(dir,targ){
		if(targ=='') targ="_self";
		var f=document.getElementById("dataform");
		var direccion=dir+"?resId=<? echo $_GET['resId'] ?>\&mymasterpage=<? echo urlencode($_SERVER['REQUEST_URI']) ?>";
		f.target=targ;
		f.action=direccion;
		f.submit();
	}
	
	<? if(isset($conf->inline_scripts)) echo $conf->inline_scripts;	?>
	$(document).ready(function(){
		initTableRows();				
		$("#table_body").sortable({		
			handle: '.sorter',
			axis: 'y',
			containment: 'parent',
			update: function(event, ui){
				var yuyu = $(".sorter[id]").map(function() { return this.id.split("hsorter_").join(""); }).get();
				$.blockUI({ message: null }); 
				$.post("XHR.master.php",{"action":"reorder", "resId":"<? echo $_GET['resId'] ?>", "items":yuyu.toString()},
					function(data){
						if(data.result=="KO"){
							alert("Error de base de datos. Por favor, inténtalo de nuevo más tarde.");
						}else{
						}
						$.unblockUI(); 
						initTableRows();
					},"json"
				);
			}
		});
	});
	function initTableRows(){
		$("#table_body > tr:odd").removeClass("row1 row2").addClass("row1");
		$("#table_body > tr:even").removeClass("row1 row2").addClass("row2");
		$("#table_body > tr").hover(
			function(){$(this).addClass("row_hover")}, 
			function(){$(this).removeClass("row_hover")}
		);
	}
	
	$(document).ready(function(){
		$('#tabla').tabs();
		$('select').selectmenu();
		$('button, input:submit, input:button, input:reset, .button, .link_button').button();
		$('.button-disabled').button({disabled: true});
	});
	
	<? if(isset($conf->data->field_sort)){ ?>
	<? } ?>
	</script>

	<? 
	if(isset($conf->client_code)) echo Content::parse($conf->client_code);
	?>
</head>

<body id="cuerpo" <? echo isset($conf->layout->class)? 'class="'.$conf->layout->class.'"' : 'class="bkg-master-1"' ?>>
<div id="pageBar">
	<h1><? echo $titulogeneral ?></h1>
	<div style="position:absolute; right:5px; top:3px;">
	<? if($conf->layout->help_topic!="" && $conf->layout->help_topic!=NULL){ ?><a href="#" onclick="javascript:openPopupWindow('../help/loader.php?topic=<? echo $conf->layout->help_topic ?>','helpWindow',500,500,true,'scrollbars')"><img src="../resources/themes/default/icon_help.png" style="border:0" /></a><? } ?>
	<? include("../jslib/layoutBtns.htm") ?>
	</div>
</div>
<table cellpadding="0" cellspacing="0" style="width:100%" >
<tr>
<td id="panel_central" valign="top">
	<form name="dataform" id="dataform" method="post" enctype="application/x-www-form-urlencoded" action="<? echo $_SERVER['REQUEST_URI'] ?>">
	<? if(isset($conf->intro)) echo "<div class='introbox sombra roundcorners bkg_icon_info'>" . Content::parse($conf->intro) . "</div>" ?>
	<? $anchura=$conf->layout->width!=NULL ? (string)$conf->layout->width : "100%" ?>
	<table width="<? echo $anchura  ?>" border="0" align="center" cellspacing="0" cellpadding="0" id="tabla" class="sombra tablaformulario ui-corner-top">
		<thead>
		<tr>
			<td colspan="<? echo $cols ?>" class="header_caption header_caption_bkg ui-corner-top"><? echo getRecordCount($page,$pagesize,$totalrows,$currows); ?></td>
		</tr>
		<tr>
		<? echo getHeaders($conf); ?>
		</tr>
		</thead>
		<tbody id="table_body">
		<?
		for($i=0;$i<count($tabla);$i++){ echo getTableRow($tabla[$i],$i,$conf); }
		echo getTotalsRow($conf);
		echo getAvgsRow($conf);
		?>
		</tbody>
		<tfoot id="table_foot">
		<? if((string)$conf->layout->paginator=="true"){ ?>
		<tr>
			<td colspan="<? echo $cols ?>" class="ui-state-default footer"><? echo getPaginator($page,$pages,7) ?></td>
		</tr>
		</tfoot>
		<? } ?>
	</table>
	</form>
</td>
<td id="panel_lateral" valign="top">
	<? if(isset($conf->desc)){ ?>
	<div class="secc_container" >
		<div class="secc_title header_caption_bkg" onclick="toggleVis('secc1')">&nbsp;<? echo PANEL_SECC_1 ?></div>
		<div class="secc_content" id="secc1"><? echo $conf->desc ?></div>
	</div>
	<? } ?>
	<div class="secc_container" >
		<div class="secc_title header_caption_bkg" onclick="toggleVis('secc2')">&nbsp;<? echo PANEL_SECC_2 ?></div>
		<div class="secc_content" id="secc2">
		<?
		if($conf->layout->but_insert=="true" && $permissions[1]==1 && ($conf->data->maxrecords==0 || $totalrows<$conf->data->maxrecords)){
		?>
			<a href="template_detail_1.php?_action=insert&amp;resId=<? echo $_GET['resId'] ?>&amp;parentId=<? echo $_GET['parentId'] ?>&amp;mymasterpage=<? echo urlencode($_SERVER['REQUEST_URI']) ?>" class="link_button grad_blue"><? echo isset($conf->layout->but_insert['label']) ? $conf->layout->but_insert['label'] : PANEL_BTN_NEW ?></a>
		<?
		}
		if($conf->layout->but_delete=="true" && $permissions[3]==1){
		?>
			<a href="javascript:submitTo('template_delete.php','')" class="link_button grad_red"><? echo PANEL_BTN_DELETE ?></a>
		<?
		}
		if(count($conf->xpath("//client_config"))>0){
		?>
			<a href="template_master_9.php?<? echo $_SERVER['QUERY_STRING'] ?>" class="link_button grad_green">Listado editable</a>		
		<?
		}
		if($conf->layout->but_print=="true"){
		?>
			<a href="javascript:window.print()" class="link_button"><? echo PANEL_BTN_PRINT ?></a>
		<?
		}
		if($conf->layout->but_export_csv=="true"){
		?>
			<a href="../phplib/export_csv.php?<? echo $_SERVER['QUERY_STRING']."&amp;".http_build_query($_GET); ?>" class="link_button"><? echo PANEL_BTN_EXPORT_CSV ?></a>
		<?
		}
		if($conf->layout->but_export_pdf=="true"){
		?>
			<a href="../phplib/export_pdf.php?<? echo $_SERVER['QUERY_STRING']."&amp;".http_build_query($_GET); ?>" class="link_button" target="_blank"><? echo PANEL_BTN_EXPORT_PDF ?></a>
		<?
		}
		if(isset($conf->layout->but_special)) echo getSpecialButtons($conf->layout->but_special);
		?>
		</div>
	</div>
	<div class="secc_container" >
		<div class="secc_title header_caption_bkg" onclick="toggleVis('secc4')">&nbsp;<? echo PANEL_SECC_4 ?></div>
		<div class="secc_content" id="secc4" style="display:inherit">
			<form name="frmOpciones" id="frmOpciones" method="post" action="#" enctype="application/x-www-form-urlencoded" >
			<? echo PANEL_OPCS_ROWSPERPAGE ?><br />
			<select name="opsRegistros" id="opsRegistros" onchange="javascript:changeURL(this.options[this.selectedIndex].value)" class="select_large">
				<option value="<? echo changeUrlParam('pagesize','0') ?>"><? echo PANEL_OPCS_DEFAULT ?></option>
				<option value="<? echo changeUrlParam('pagesize','15') ?>" <? if($pagesize=="15") echo 'selected="selected"' ?>>15</option>
				<option value="<? echo changeUrlParam('pagesize','25') ?>" <? if($pagesize=="25") echo 'selected="selected"' ?>>25</option>
				<option value="<? echo changeUrlParam('pagesize','50') ?>" <? if($pagesize=="50") echo 'selected="selected"' ?>>50</option>
				<option value="<? echo changeUrlParam('pagesize','100') ?>" <? if($pagesize=="100") echo 'selected="selected"' ?>>100</option>
				<option value="<? echo changeUrlParam('pagesize','-1') ?>" <? if($pagesize=="-1") echo 'selected="selected"' ?>><? echo PANEL_OPCS_ALL ?></option>
			</select>
			</form>
			<?
			if(isset($conf->filters)){
				echo FilterProcess::getValidationScript($conf->filters);
				echo FilterProcess::getResetScript($conf->filters);
			?>
			<form name="frmFiltros" id="frmFiltros" method="GET" action="#" class="ui-form ">
				<strong><? echo $conf->filters['title'] ?></strong><br />
				<fieldset title="Año del informe">
					<legend >Año del informe</legend>
					<input type="text" name="anno" id="anno" class="txt_short" value="<? echo $_REQUEST['anno'] ?>" />
				</fieldset>
				<?
				foreach($conf->filters->filter as $filtro){
				?>
				<fieldset title="<? echo $filtro['title'] ?>">
					<legend ><? echo $filtro['title'] ?></legend>
					<? echo FilterProcess::getFilter($filtro); ?>
				</fieldset>
				<? } ?>
				<input type="submit" name="fil_btn_filter" class="but_default grad_orange" value="<? echo $conf->filters['btn_submit'] ?>" onclick="validaFiltros(); return false;" />
				<input type="button" name="fil_btn_reset" class="but_default grad_orange" value="<? echo $conf->filters['btn_reset'] ?>" onclick="javascript:resetFiltros()" />
			</form>
			<? } ?>			
		</div>
	</div>
</td>
</tr>
</table>
</body>
</html>
