/** * Muestra las opciones para buscar */ public function actionListado() { $this->comprobarPermiso(); $model = new Objeto(); if (Yii::$app->request->post('consulta') != NULL) { $this->layout = 'printlayoutInventario'; $objetos = $model->getListado(Yii::$app->request->post('consulta')); $pdf = new mPDF('utf-8', 'A4-L', 0, '', 10, 10, 10, 10); $objPerPage = 30; //Dividimos el objeto en arrays del mismo tamaño $total = count($objetos); $misObjetos = array_chunk($objetos, $objPerPage, true); $numPages = count($misObjetos); foreach ($misObjetos as $key => $valor) { $ultimo = false; if ($key + 1 == $numPages) { $ultimo = true; } $content = $this->render('imprimir', ['model' => $model, 'objetos' => $valor, 'mPDF' => $pdf, 'ultimo' => $ultimo, 'total' => $total]); /* return $this->render('imprimir', [ 'model' => $model,'objetos'=>$objetos,'ultimo'=>false, ]);*/ //$pdf->SetHTMLHeader($this::$CABECERA,'',true); $pdf->SetFooter('Página {PAGENO} de ' . $numPages); $pdf->WriteHTML($content); if (!$ultimo) { $pdf->AddPage(); } } $pdf->Output(); exit; } /** Si no hay consulta entra en el renderizado normal */ return $this->render('listado', ['model' => $model, 'tipos' => $model->getTipos()]); }