public function clientesmasactivospublicarepoAction() { $from = $this->_getParam('from'); $to = $this->_getParam('to'); $idUsuario = Zend_Registry::get('id_usuario'); $modelUser = new Application_Model_DbTable_Usuarios(); $datosAdmin = $modelUser->traerdatosclienteID($idUsuario); foreach ($datosAdmin as $admin) { $nombreAdmin = $admin->nombre; $apellidoAdmin = $admin->apellido; } $model = new Application_Model_DbTable_Comentarios(); $posts = $model->reporte_cliente_mas_activo_publica($from, $to); $this->getHelper('layout')->disableLayout(); $this->getHelper('ViewRenderer')->setNoRender(); $tipo_reporte = 'Reporte Clientes Mas Activos (Comentarios)'; $content = '<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Reportes - Capicua Restobar.</title> </head> <body>' . '<img width=100% height=50px src="images/top_footer.jpg"/> <br/><br/> <h3><center>' . $tipo_reporte . '</center></h3>' . '<br/> <strong><u>Administrador : </u></strong>' . ' ' . $nombreAdmin . ' ' . $apellidoAdmin . '<br/> <strong><u>Fecha : </u></strong>' . ' ' . date("d/m/Y H:i") . '<br/>'; if ($from || $to) { $content = $content . ' <hr> <li> <p>Desde: ' . $from . '</p> </li> <li> <p>Hasta: ' . $to . '</p> </li>'; } else { $content = $content . ' <h3> Reporte Historico</h3>'; } $content = $content . ' <div> <table cellspacing="10%" cellpadding="10%" width=100%> <tr align = center BGCOLOR="ccff66"> <td width="2%"><font><u>Nombre</u></font></td> <td width="2%"><font><u>Usuario</u></font></td> <td width="2%"><font><u>Email</u></font></td> <td width="2%"><font><u>Total de Comentarios</u></font></td> </tr>'; if (count($posts)) { foreach ($posts as $tipo) { $content = $content . '<tr align="center" bgcolor="ffff99">'; if ($tipo) { $content = $content . '<td>' . $tipo->nombre . ' ' . $tipo->apellido . '</td>'; if ($tipo->tipo_usuario == 1) { $content = $content . '<td>' . 'Adminsitrador' . '</td>'; } else { $content = $content . '<td>' . 'Cliente ' . '</td>'; } $content = $content . '<td>' . $tipo->email . '</td>'; $content = $content . '<td>' . $tipo->num . '</td>'; $content = $content . '</tr>'; } } } else { $content = $content . ' <tr> <td colspan="3">No hay datos</td> </tr>'; } $content = $content . '</table><div></body></html>'; if ($content != '') { //Añadimos la extensión del archivo. Si está vacío el nombre lo creamos $path = 'Reporte publicaciones mas activos-ventas' . date("d/m/Y H:i") . '.pdf'; //Las opciones del papel del PDF. Si no existen se asignan las siguientes:[*] $paper_1 = 'a4'; $paper_2 = 'portrait'; $dompdf = new DOMPDF(); $dompdf->set_paper($paper_1, $paper_2); $dompdf->load_html(utf8_encode($content)); //ini_set("memory_limit","32M"); //opcional $dompdf->render(); $mode = false; //Creamos el pdf if ($mode == false) { $dompdf->stream($path); } //Lo guardamos en un directorio y lo mostramos if ($mode == true) { if (file_put_contents($path, $dompdf->output())) { header('Location: ' . $path); } } } }