<?php
//no esta siendo llamado
    $tabla="comunicacion";
    


   $id_gestion=isset($_REQUEST['gestion_id']) ? $_REQUEST['gestion_id'] : '-1';
 



     

    
    $where ="";
    if ($id_gestion<>'') {$where .= " and id_gestion=$id_gestion "; }   
    
    
    $page = isset($_POST['page']) ? intval($_POST['page']) : 1;
    $rows = isset($_POST['rows']) ? intval($_POST['rows']) : 10;
    $result = array();
    
    include '../rdb/conn.php';
    $sql= " select count(*) from $tabla where 1=1 ";
    $sql.=  $where;
    
    $rs = mysqli_query( $conn,$sql);
    $row = mysqli_fetch_row($rs);
    $result["total"] = $row[0];
    
    if ($result["total"] === 0) {exit;}  
    $sql = "select id, estado_id,";
    $sql.= "(select nombre from usuario where id=responsable_id) responsable,";
    $sql.= "(select nombre from rubros where id=rubro_id) tipo,";
    $sql.= "(select nombre from comunicacion_estado where id=estado_id) estado, ";
    $sql.= " fecha,vencimiento,(select nombre from consorcio where id=comunicacion.consorcio_id) consorcio,";
    $sql.= "unidad_id nombre, texto from $tabla ";
    $sql.=" where 1=1 ";
    $sql.= $where . " order by id  ";
    $rs = mysqli_query( $conn,$sql);
    


 

    $items = array();
    while($row = mysqli_fetch_object($rs)){
        array_push($items, $row);
    }
    $result["rows"] = $items;
    $result["sql"] = $sql;


    echo json_encode($result);
    
   
    
?>