// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         //
// GNU General Public License for more details:                          //
//                                                                       //
//          http://www.gnu.org/copyleft/gpl.html                         //
//                                                                       //
///////////////////////////////////////////////////////////////////////////
require '../../../functions/globales.php';
require '../include/rutas.php';
require '../functions/main.php';
require '../struct/login2.php';
require '../functions/doc_functions.php';
$titulo = "Informe de documentos";
if ($_POST['tipodoc'] != '') {
    $filtros = " and tipo = '" . $_POST['tipodoc'] . "'";
}
$documentos = documentos(BBDDUSUARIO, $_POST['orden'], '', $filtros);
if ($documentos) {
    if ($_POST['xls']) {
        //header("Pragma: ");
        header('Cache-control: ');
        header("Expires: -1000");
        //header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
        header("Cache-Control: no-store, no-cache, must-revalidate");
        header("Cache-Control: post-check=0, pre-check=0", false);
        header("Content-type: application/vnd.ms-excel");
        header("Content-disposition: attachment; filename=Informe_documentos.xls");
        header("Pragma: public");
        ?>
		<table><tr><td><?php 
        echo $titulo;
        ?>
 function ajax_grid_documentos()
 {
     if ($this->input->is_ajax_request()) {
         /**
          * Get the requested page.
          * @var int
          */
         $page = (int) $this->input->post('page', true);
         /**
          * Get how many rows we want to have into the grid
          * rowNum parameter in the grid.
          * @var int
          */
         $limit = (int) $this->input->post('rows', true);
         /**
          * Get index row - i.e. user click to sort
          * at first time sortname parameter - after that the index from colModel.
          * @var int
          */
         $sidx = 'fecha_creacion';
         /**
          * Sorting order - at first time sortorder
          * @var string
          */
         $sord = 'desc';
         /**
          * Inicializar variable $clause de busqueda
          */
         /*$modulo = array();
              		$documentos_id = array();
              		$tipo_archivo = $this->input->post('clause', true);
              		$moduloId = (int)$this->input->post('folder',true);
              		$documentos_id = empty($this->input->post('modulo_id', true))? array(): $this->input->post('modulo_id', true);
         
              		$subordinados = $this->seleccionar_subordinados();
         
              		$clause = filtro_documentos($tipo_archivo,$moduloId,$documentos_id,$subordinados);*/
         $tipo = (string) $this->input->post('clause', true);
         $modulo = (int) $this->input->post('folder', true);
         $uuid_documento = $this->input->post('uuid_documento', true);
         $usuarios = $this->andrea_ACL();
         $usuarios_propiedad = $this->andrea_ACL('propiedades');
         $clause = documentos($usuarios, $usuarios_propiedad, $tipo, $modulo, $uuid_documento);
         $paginador = (bool) $this->input->post('paginador', true);
         //$contarDocumentos = $this->documentos_model->contar_documentos($clause);
         /**
          * Total rows found in the query.
          * @var int
          */
         $listar = $this->documentos_model->listar_documentos($clause, $sidx, $sord, $limit, $page);
         $grid = Grid::documents_grid($listar, $paginador);
         echo $grid;
         exit;
     }
 }