Buenas tardes, gente vengo con un problema muy especifico, no se si es común o si el problema es como lo estoy haciendo, el punto es que estoy generando un reporte pdf con mpdf, el reporte tiene una tabla, la misma tiene un rowspan, la tabla se alimenta de la informacion de la aplicacion, el problema viene cuando por ejemplo la cantidad de data requiere que la tabla se muestre en mas de una pagina. todo se descuadra. entiendo que no genera la columna con el colspan sino solo hasta la ultima pagina de dicha tabla. entonces las primeras no aparecen. a continuacion lo que tengo.
en "tblEventoreporte/1" una vista donde tomo los parametros para los reportes tengo un boton
[code
<?php
echo CHtml::button('Generar Resumen de Eventos PDF',
array('class'=>'btn-primary',
'id'=>'boton',
'onclick' => 'js:document.location.href="GenerarEventoreporte?estructuraid='.$model->id.'"'
));
?>
[/code]
la funcion para generar el PDF
public function actionGenerarEventoreporte() {
$eventoreportedatos = $_GET['estructuraid'];
$datos = Yii::app()->db->createCommand("SELECT * FROM tbl_eventoreporte WHERE id = ".$eventoreportedatos)->queryRow();
$criteria= new CDbCriteria;
$variablefecha1 = $datos['fechainicio'];
$fechainicio = str_replace('/', '-', $variablefecha1);
$variablefecha2 = $datos['fechafin'];
$fechafin = str_replace('/', '-', $variablefecha2);
if ($datos['idestructura'] == '9991' || $datos['idestructura'] == '9992') $varestructura = "";
else $varestructura = "AND id IN (SELECT idevento FROM tbl_asistencia WHERE idestructura = ".$datos['idestructura'].")";
if ($datos['idexpositor'] == '9993' || $datos['idexpositor'] == '9994') $varexpositor = "";
else $varexpositor = "AND idexpositor = ".$datos['idexpositor'];
if ($datos['iddescripcionevento'] == '9995' || $datos['iddescripcionevento'] == '9996') $vardescrip = "";
else $vardescrip = "AND iddescripcionevento = ".$datos['iddescripcionevento'];
$dataProvider = new CActiveDataProvider('TblEvento', array('pagination'=>false));
$criteria->condition = "(fechainicio, fechafin) OVERLAPS ('".date('Y-m-d', strtotime($fechainicio))."'::DATE, '".date('Y-m-d', strtotime($fechafin))."'::DATE)".
$vardescrip." ".
$varestructura." ".
$varexpositor."
order by fechafin ASC";
$dataProvider->setCriteria($criteria);
# SELECT * FROM tbl_evento WHERE (fechainicio, fechafin) OVELARPS ('01-01-2015'::DATE, '30-04-2015'::DATE)
# AND id IN (SELECT id FROM tbl_asistencia WHERE idestructura = 43
$this->layout = "/layouts/stylepdf.css";
$mPDF1 = Yii::app()->ePdf->mpdf('utf-8', 'A4-L');
//$mPDF1->mPDF('utf-8', 'A4-L');
//$mPDF1->use_kwt = true;
//$mPDF1->shrink_tables_to_fit=1;
$mPDF1->AddPage('P'); // Cambiar la orientacion de la vista
$mPDF1->WriteHTML('<img align="center" src="images/banneroficio1.jpg"> <br/><br/>');
$mPDF1->WriteHTML(nl2br($datos['descripcion'])."<br /><br />");
echo nl2br($oficio['encabezado']).'<br /><br />';
$mPDF1->WriteHTML('<table width="100%" border="1" style="overflow: hidden; border-collapse: collapse;">'); #<table repeat_header="1" style="page-break-inside: avoid;">
$mPDF1->WriteHTML('<thead>');
$mPDF1->WriteHTML('<tr>');
$mPDF1->WriteHTML('<th>Mes</th>');
$mPDF1->WriteHTML('<th>Fecha</th>');
if ($datos['idestructura'] <> '9992' ) {
$mPDF1->WriteHTML('<th>Organismo u Ente participante</th>');
}
if ($datos['iddescripcionevento'] <> '9996' ) {
$mPDF1->WriteHTML('<th>Curso</th>');
}
if ($datos['idexpositor'] <> '9994' ) {
$mPDF1->WriteHTML('<th>Expositor</th>');
}
$mPDF1->WriteHTML('<th>Asistentes</th>');
$mPDF1->WriteHTML('<th>Total Asistentes</th>');
$mPDF1->WriteHTML('</tr>');
$mPDF1->WriteHTML('</thead>');
$mPDF1->WriteHTML( $this->render('EventoReportes/redireccion',array('dataProvider' => $dataProvider),true));
$mPDF1->Output ('Certificados',EYiiPdf::OUTPUT_TO_BROWSER);
}
La redireccion
<tbody>
<?php
$this->widget('zii.widgets.CListView', array(
'dataProvider'=>$dataProvider,
'itemView'=>'EventoReportes/estructura1',
'enablePagination'=>false,
'template'=>"{items}\n{pager}",
)); ?>
</tbody>
</table>
y la estructura html/php que genera la data de la informacion
<style>
html *
{
font-size: 1em !important;
color: #000 !important;
font-family: Arial !important;
}
td
{
text-align: center;
}
</style>
<div>
<?php
$eventoreportedatos = $_GET['estructuraid'];
$eventoreporte = Yii::app()->db->createCommand("SELECT idestructura, idexpositor, iddescripcionevento, fechainicio, fechafin FROM tbl_eventoreporte WHERE id = ".$eventoreportedatos)->queryRow(); //queryRow para poder tomar los valores por separado como un array
$fechainicioEventoReporte = $eventoreporte['fechainicio'];
$fechainicioEventoReporte = str_replace('/', '-', $fechainicioEventoReporte);
$fechafinEventoReporte = $eventoreporte['fechafin'];
$fechafinEventoReporte = str_replace('/', '-', $fechafinEventoReporte);
if ($eventoreporte['idestructura'] == '9991' || $eventoreporte['idestructura'] == '9992')
{
$varestructura = " ";
$varestructura2 = " ";
$varestructura3 = " ";
}
else {
$varestructura = " AND id IN (SELECT idevento FROM tbl_asistencia WHERE idestructura = ".$eventoreporte['idestructura'].") ";
$varestructura2 = " AND idestructura = ".$eventoreporte['idestructura'];
}
if ($eventoreporte['idexpositor'] == '9993' || $eventoreporte['idexpositor'] == '9994') $varexpositor = " ";
else $varexpositor = "AND idexpositor = ".$eventoreporte['idexpositor']." ";
if ($eventoreporte['iddescripcionevento'] == '9995' || $eventoreporte['iddescripcionevento'] == '9996') $vardescrip = " ";
else $vardescrip = "AND iddescripcionevento = ".$eventoreporte['iddescripcionevento']." ";
$fecha = Yii::app()->db->createCommand("SELECT EXTRACT (MONTH FROM fechainicio) AS mes, EXTRACT(YEAR FROM fechainicio) AS anio FROM tbl_evento WHERE id =".$data->id)->queryRow();
//TOTAL DE ASISTENCIA POR EVENTO
$cantasistmensuales = Yii::app()->db->createCommand("SELECT count(*) FROM tbl_asistencia WHERE idevento =".$data->id." ".$varestructura2." ")->queryScalar();
//TOTAL DE ASISTENCIA POR MES
$totalasistenciames = Yii::app()->db->createCommand("SELECT count(*) FROM tbl_asistencia AS A , (SELECT id FROM tbl_evento WHERE EXTRACT(MONTH FROM fechainicio) = ".$fecha['mes']." AND EXTRACT(YEAR FROM fechainicio) = ".$fecha['anio']."
AND (fechainicio, fechafin) OVERLAPS ('".date('Y-m-d', strtotime($fechainicioEventoReporte))."'::DATE, '".date('Y-m-d', strtotime($fechafinEventoReporte))."'::DATE) ".$varestructura.$varexpositor.$vardescrip.") AS B
WHERE A.idevento = B.id".$varestructura2)->queryScalar();
//DETERMINAR SI SE AGREGA UN TD PARA EL TOTAL MENSUAL DE HABER MAS DE UN CURSO EN EL MISMO MES, NO SE AGREGA
$IDmeslimit = Yii::app()->db->createCommand("SELECT id FROM tbl_evento WHERE EXTRACT(MONTH FROM fechainicio) = ".$fecha['mes']." AND EXTRACT(YEAR FROM fechainicio) = ".$fecha['anio']."
AND (fechainicio, fechafin) OVERLAPS ('".date('Y-m-d', strtotime($fechainicioEventoReporte))."'::DATE, '".date('Y-m-d', strtotime($fechafinEventoReporte))."'::DATE)
".$varestructura.$varexpositor.$vardescrip." order by fechainicio ASC LIMIT 1")->queryScalar(); // creo que falta otro order by id ASC
//DETERMINAR EL ROWSPAN DEL TD QUE SI SE AGREGA EN FUNCION A LA CANTIDAD DE EVENTOS POR MES QUE EXISTEN
$rowspan= Yii::app()->db->createCommand("SELECT count(*) FROM tbl_evento WHERE EXTRACT(MONTH FROM fechainicio) =".$fecha['mes'].$varestructura.$varexpositor.$vardescrip." ;")->queryScalar();
$cantcursosmensuales = Yii::app()->db->createCommand("SELECT count(*) FROM tbl_evento group by EXTRACT(MONTH FROM fechainicio);")->queryScalar();
?>
<tr>
<?php
if ($data->id == $IDmeslimit) {
echo '<td id='.CHtml::encode($index).' rowspan="'.$rowspan.'" align="center" style="page-break-inside: avoid">'; # style="page-break-inside: avoid">';
if ($fecha['mes']==1) echo 'Enero <br>';#.$fecha['anio'];
if ($fecha['mes']==2) echo 'Febrero <br>';#.$fecha['anio'];
if ($fecha['mes']==3) echo 'Marzo <br>';#.$fecha['anio'];
if ($fecha['mes']==4) echo 'Abril <br>';#.$fecha['anio'];
if ($fecha['mes']==5) echo 'Mayo <br>';#.$fecha['anio'];
if ($fecha['mes']==6) echo 'Junio <br>';#.$fecha['anio'];
if ($fecha['mes']==7) echo 'Julio <br>';#.$fecha['anio'];
if ($fecha['mes']==<img src='http://www.yiiframework.com/forum/public/style_emoticons/default/cool.gif' class='bbc_emoticon' alt='8)' /> echo 'Agosto <br>';#.$fecha['anio'];
if ($fecha['mes']==9) echo 'Septiembre <br>';#.$fecha['anio'];
if ($fecha['mes']==10) echo 'Octube <br>';#.$fecha['anio'];
if ($fecha['mes']==11) echo 'Noviembre <br>';#.$fecha['anio'];
if ($fecha['mes']==12) echo 'Diciembre <br>';#.$fecha['anio'];
}
echo "</td>";
#echo "<td>".$IDmeslimit." ".$data->id."</td>";
?>
<?php echo "<td>".str_replace('/', '-', $data->fechainicio)." ".str_replace('/', '-', $data->fechafin)."</td>"; ?>
<?php
if (($eventoreporte['idestructura']) <> '9992')
{
$results=TblEstructura::model()->findAllBySql("SELECT denominacion FROM tbl_estructura as O, (SELECT idestructura FROM tbl_asistencia WHERE idevento =".$data->id." ".$varestructura2." GROUP BY idestructura) as A
WHERE O.id = A.idestructura;");
echo "<td>";
foreach($results AS $result)
{
echo ucwords(mb_strtolower($result->denominacion, 'UTF-8')).".<br><br> ";
}
echo "</td>";
}
?>
<?php
if ($eventoreporte['iddescripcionevento'] <> '9996' ) {
echo "<td>".$data->iddescripcionevento0->nombre."</td>";
}
?>
<?php
if ($eventoreporte['idexpositor'] <> '9994' ) {
echo "<td>".ucwords(mb_strtolower($data->idexpositor0->idpersona0->nombre,'UTF-8'))." ".ucwords(mb_strtolower($data->idexpositor0->idpersona0->apellido,'UTF-8'))."</td>";
}
?>
<?php echo "<td>".$cantasistmensuales."</td>"; ?>
<?php
if ($data->id == $IDmeslimit) {
echo "<td rowspan='".$rowspan."' align='center'>".$totalasistenciames."</td>";
}
#echo "<td align='center'>".$totalasistenciames."</td>";
?>
</tr>
</div>
Cualquier ayuda es bienvenida. la verdad busque bastante en la web y no consigo nada para solucionar el problema, gracias