public function eliminarcomentarioAction() { if (!$this->_hasParam('id')) { return $this->_redirect('/administrador/listarpublicaciones'); } $model = new Application_Model_DbTable_Comentarios(); $row = $model->obtenerRow($this->_getParam('id')); if ($row) { $row->delete(); } return $this->_redirect('/publicaciones'); }
public function publicacionesmascomentadasrepoAction() { $from = $this->_getParam('from'); $to = $this->_getParam('to'); $model = new Application_Model_DbTable_Comentarios(); $posts = $model->reporte_publicaciones_mas_comentadas($from, $to); $this->getHelper('layout')->disableLayout(); $this->getHelper('ViewRenderer')->setNoRender(); $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; } $tipo_reporte = 'Publicaciones Mas Comentadas'; $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>Titulo Publicacion</u></font></td> <td width="4%"><font><u>Contenido</u></font></td> <td width="2%"><font><u>Fecha Publicacion</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->titulo . '</td>'; $content = $content . '<td>' . $tipo->contenido . '</td>'; $content = $content . '<td>' . $tipo->fecha_publicacion . '</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 Comentadas.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); } } } }