Foros del Web » Programando para Internet » PHP » Symfony »

[SOLUCIONADO] Reportes en Symfony

Estas en el tema de Reportes en Symfony en el foro de Symfony en Foros del Web. Saludos necesito ayuda por favoshe intentado realizar reportes en symfony utilizando el siguiente Bundle, https://github.com/psliwa/PdfBundle pero al momento de invocar al reporte no se me ...
  #1 (permalink)  
Antiguo 26/08/2014, 10:55
 
Fecha de Ingreso: julio-2014
Mensajes: 6
Antigüedad: 9 años, 9 meses
Puntos: 1
Pregunta Reportes en Symfony

Saludos necesito ayuda por favoshe intentado realizar reportes en symfony utilizando el siguiente Bundle,

https://github.com/psliwa/PdfBundle

pero al momento de invocar al reporte no se me genera el PDF, lo que se obtiene como resultado es lo siguiente



el codigo que tengo es el siguiente

CONTROLLER

Código:
 /**
    * @Pdf()
    */
    public function portadareporteAction() {
        $periodo='';
        
        $em = $this->getDoctrine()->getEntityManager();

       
        $listamaterias = $em->getRepository('administrativoBundle:Materia')->findAll();
        
        $listacursos = $em->getRepository('administrativoBundle:Curso')->findAll();
        
        $listaparalelos = $em->getRepository('administrativoBundle:Paralelo')->findAll();        
      
        $listahoras = $em->getRepository('administrativoBundle:Hora')->findAll();        
        
        $format = $this->get('request')->get('_format');
        
        $content = $this->render(sprintf('administrativoBundle:Default:portada_admin.%s.twig', $format),array(
            'periodo'=>$periodo,
            'listacursos'=>$listacursos,
            'listaparalelos'=>$listaparalelos,   
            'listameses'=>$listameses,
            'listahoras'=>$listahoras,        
        ));
        
         $contentType = 'pdf' == $format ? 'application/pdf' : 'text/html';

           $response = new Response($content, 200, array('content-type' => $contentType));

            return $response;
    }

en la vista tengo lo siguiente:

VIEW

Código:
{% extends '::frontend.html.twig'%}

{% block title %} Perfil de docente {% endblock%}
{% block id 'portada' %}

{% block article%}
<pdf>
    <dynamic-page>
<strong>    
    <h2>Materias</h2>
    <br>
</strong>
<div id="materias">
    <div id="materias_table">
        <table class="display" id="m_table">
            <thead>
                <tr>
                    <th>{{'Nombre' }}</th>
                    <th>{{'Area' }}</th>
                    <th>{{'Numero Horas'}}</th> 
                    <th>{{'Descripcion'}}</th> 
                    <th>{{'Estado'}}</th>                                         
                </tr>
            </thead>

            <tbody>{% for mat in listamaterias %}
                <tr>
                    <td ALIGN="CENTER" style="vertical-align:middle">{{mat.nombre}}</td>
                    <td ALIGN="CENTER" style="vertical-align:middle">{{mat.area}}</td>                        
                    <td ALIGN="CENTER" style="vertical-align:middle">{{mat.numerocreditos}}</td>
                    <td ALIGN="CENTER" style="vertical-align:middle">{{mat.descripcion}}</td>                        
                    <td ALIGN="CENTER" style="vertical-align:middle">{% if (mat.estado) ==1 %}
                        <strong>Activo</strong>
        {% endif %}
        {% if (mat.estado) ==0 %}
                        <strong>No activo</strong>
        {% endif %}</td>
                </tr>{% endfor%}
            </tbody>    
        </table>
        
    </div>


</div>

<hr>    
<div align="center" class="contenido">
    <div class="columna-izquierda">
        <strong>    
            <h2>Niveles</h2>
            <br>
        </strong>
        <table class="display" id="c_table">
            <thead>
                <tr >
                    <th>{{'Nombre' }}</th> 
                </tr>
            </thead>

            <tbody>{% for cur in listacursos %}
                <tr>
                    <td ALIGN="CENTER" style="vertical-align:middle">{{cur.nombre}}</td>
                </tr>{% endfor%}
            </tbody>


        </table> 
       
    </div>

    <div class="columna-derecha">
        <strong>    
            <h2> Paralelos</h2>
            <br>
        </strong>    
        <table class="display" id="p_table">
            <thead>
                <tr >
                    <th>{{'Nombre' }}</th> 
                </tr>
            </thead>

            <tbody>{% for par in listaparalelos %}
                <tr>
                    <td ALIGN="CENTER" style="vertical-align:middle">{{par.nombre}}</td>
                </tr>{% endfor%}
            </tbody>
        </table> 
        
    </div>

</div>

<hr>

    <strong>    
        <h2>Horas</h2>
        <br>
    </strong>
    <div id="horas">
        <div id="horas_table">
            <table class="display" id="h_table">
                <thead>
                    <tr>
                        <th>{{'Hora inicio -- Hora fin' }}</th>                                           
                        <th>{{'Descripcion'}}</th>                                       
                    </tr>
                </thead>

                <tbody>{% for hor in listahoras %}
                    <tr>
                        <td  ALIGN="CENTER" style="vertical-align:middle">{{hor}}</td> 
                        <td  ALIGN="CENTER" style="vertical-align:middle">{{hor.descripcion}}</td>                                             
                    </tr>{% endfor%}
                </tbody>    
            </table>
        </div>


    </div>

    <hr>
</dynamic-page>
</pdf>
{% endblock%}



{% block stylesheets %}
{{ parent() }}

{% include 'academicoBundle:Default:tablecss.html.twig'%}
    <style>
            .columna-izquierda{
                text-align:left;
                margin-right:5px;
                padding-left: 80px;
                float:left;
                width:245px;
            }
            .columna-derecha{
                float:right;
                width:245px;
                padding-right: 80px;
            }   
            .contenido{height:auto;overflow:auto}
            
            p.big {
            line-height: 200%;
            }
        </style>
   {% endblock %}
y en el ROUTING tengo lo siguiente,

Código:
portada_reporte:
    pattern:  /admin/reportegeneral
    defaults: { _controller: administrativoBundle:Default:portadareporteciudad, _format: pdf}    
    requirements:
        _format: pdf
  #2 (permalink)  
Antiguo 26/08/2014, 13:26
Avatar de hhs
hhs
Colaborador
 
Fecha de Ingreso: junio-2013
Ubicación: México
Mensajes: 2.995
Antigüedad: 10 años, 9 meses
Puntos: 379
Respuesta: Reportes en Symfony

suponiendo que todo esta bien, lo único que encaja es la ruta:
Código PHP:
Ver original
  1. portada_reporte:
  2.     pattern:  /admin/reportegeneral
  3.     defaults: { _controller: administrativoBundle:Default:portadareporteciudad, _format: pdf}    
  4.     requirements:
  5.         _format: pdf
Estas buscando un metodo llamado portadareporteciudad y en tu código dice que el método es: portadareporte. Creo que no estas solicitando el método correcto de tu controlador.
__________________
Saludos
About me
Laraveles
A class should have only one reason to change.
  #3 (permalink)  
Antiguo 26/08/2014, 21:06
 
Fecha de Ingreso: julio-2014
Mensajes: 6
Antigüedad: 9 años, 9 meses
Puntos: 1
Respuesta: Reportes en Symfony

Gracias por tu respuesta, al colocar el nombre adecuado en la ruta el error anterior ya no aparece, pero ahora aparece una excepcion,

Código:
Xml parsing error "Document is empty
" in file "file:///C:/xampp/htdocs/academicov2l/web/" on line 1 on column 1 

 500 Internal Server Error - ParseException
Stack Trace

    in C:\xampp\htdocs\academicov2l\vendor\psliwa\php-pdf\lib\PHPPdf\Parser\XmlParser.php at line 121  -
                if($error)
                {
                    libxml_clear_errors();
                    throw new Exceptions\ParseException(sprintf('Xml parsing error "%s" in file "%s" on line %s on column %s', $error->message, $error->file, $error->line, $error->column));
                }
                return $status;
  #4 (permalink)  
Antiguo 27/08/2014, 10:40
Avatar de hhs
hhs
Colaborador
 
Fecha de Ingreso: junio-2013
Ubicación: México
Mensajes: 2.995
Antigüedad: 10 años, 9 meses
Puntos: 379
Respuesta: Reportes en Symfony

supongo que no puede parsear el archivo que estas usando como plantilla o algo así. Lo recomendable es que busques mas información en los foros del bundle ya que esto es algo especifico.
__________________
Saludos
About me
Laraveles
A class should have only one reason to change.
  #5 (permalink)  
Antiguo 27/08/2014, 16:23
 
Fecha de Ingreso: julio-2014
Mensajes: 6
Antigüedad: 9 años, 9 meses
Puntos: 1
Respuesta: Reportes en Symfony

Solucionado. EL problema fue que algunas de las etiquetas en el archivo a renderizar no son soportadas. La lista de etiquetas soportadas por el Bundle son las siguientes:

Código:
 div, p, table, tr, td, b, strong, span, a, h1, h2, h3, h4, h5, img, br, ul, li

Etiquetas: php, reportes, symfony2
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 19:46.