public function agregarcomentarioAction()
 {
     $this->_helper->layout()->disableLayout();
     $data = $this->_request->getPost();
     if (Zend_Registry::get('tipo_user')) {
         $tipo_user = Zend_Registry::get('tipo_user');
     } else {
         $tipo_user = NULL;
     }
     if ($data) {
         $postid = $data['postid'];
         $comment = $data['inputField'];
         $iduser = $data['iduser'];
         $fecha = new Zend_Db_Expr('NOW()');
         $modelcoment = new Application_Model_DbTable_Comentarios();
         $modelcoment->agregarcomentario($comment, $fecha, $postid, $iduser);
         $model = new Application_Model_DbTable_Usuarios();
         $user = $model->traerdatosclienteID($iduser);
         foreach ($user as $usser) {
             $nombre = $usser->nombre;
             $foto = $usser->foto_perfil;
         }
     }
     $this->view->tipo_user = $tipo_user;
     $this->view->postid = $postid;
     $this->view->comment = $comment;
     $this->view->nombre = $nombre;
     $this->view->foto = $foto;
 }
    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);
                }
            }
        }
    }