<?
/*
Autor: Lic. Carlos Alberto Vaca Coronado
Version: 3.2.0
*/

session_name('portal_absa');
session_start();

require "../conexion/conectar.php";

$page = $_GET['page']; // get the requested page
$limit = $_GET['rows']; // get how many rows we want to have into the grid
$sidx = $_GET['sidx']; // get index row - i.e. user click to sort
$sord = $_GET['sord']; // get the direction
$id = $_GET['id'];
if(!$sidx) $sidx =1;
$queryC = str_replace("\\","",$_SESSION['queryC']);
$completaQuery =" and numeroevento='$id'";
$SQL_1="select COUNT(*) as count from (".$queryC.$completaQuery.") as temp";

//$SQL_1="select COUNT(*) as count from (select rfcemisor,tipodocto,serie,folio from doce) as temp";
conectar();
$result = mysql_query($SQL_1) or die(mysql_error());
desconectar();
$row = mysql_fetch_array($result,MYSQL_ASSOC);
$count = $row['count'];

if( $count >0 ) {
	$total_pages = ceil($count/$limit);
} else {
	$total_pages = 0;
}
if ($page > $total_pages) $page=$total_pages;
$start = $limit*$page - $limit;

$SQL = $_SESSION['queryC']." order by $sidx $sord LIMIT $start , $limit";
//$SQL = "select rfcemisor,tipodocto,serie,folio from doce order by $sidx $sord LIMIT $start , $limit";
conectar();
$result = mysql_query( $SQL ) or die(mysql_error());
desconectar();
$responce->page = $page;
$responce->total = $total_pages;
$responce->records = $count;
$i=0;

while($row = mysql_fetch_array($result,MYSQL_ASSOC)){

    //$responce->rows[$i]['id']=$row[$_GET['key']];
	$responce->rows[$i]['cell']=array("<textarea readOnly='true' cols='55' rows='4'>".$row['comentario']."</textarea>");
	$i++;
}
echo json_encode($responce);

?>