Create new page when creating PDF file with dompdf in laravel 5.6

0

I'm using Laravel 5.6, and I want to create a new page to the PDF file, having loaded the first 25 records, using DOMPDF .

The controller I have it in the following way:

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use \PDF;
use Illuminate\Support\Facades\DB;
use Illuminate\Contracts\Auth\Guard;
use App\User;
use App\funcionario;

class PDFController extends Controller
{
//
protected $auth;
public function __construct(Guard $auth)
{
    $this->auth=$auth;
}
public function DetalleInventario($ubicacion,$valorada){
    $usuario=$this->auth->user()->id_funcionario;
    $almacen=$this->auth->user()->id_almacen;
    $encargado=funcionario::UsuarioOficina($usuario,$almacen);
    $inventario=DB::table('inventarios')
            ->join('tipo_materials', 'inventarios.id_tipo_material', '=', 'tipo_materials.id_tipo_material')
            ->join('almacens', 'inventarios.id_almacen', '=', 'almacens.id_almacen')
            ->select('id_item','tipo_materials.descripcion AS material','rango_inicial','rango_final','serie','cantidad','precio_unitario','observaciones','almacens.descripcion AS almacen')
            ->where('inventarios.id_almacen','=',$ubicacion)
            ->where('inventarios.id_tipo_material','=',$valorada)->get();
     $pdf=PDF::loadView('almacen.Inventariopdf',['inventario'=>$inventario,'encargado'=>$encargado])->setPaper('A4', 'landscape');

    return $pdf->download('InventarioAlmacen.pdf');

}
}

And the view like this:

<!DOCTYPE html>
<html lang="es">
<head>
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" href="css/estilo-pdf.css">
<title>Reporte Inventario</title>
</head>
<body>
<div class="cabecera">
        <div class="float-left">
            <img src="imagenes/aaaa.png" class="img-header">
        </div>
        <div class="float-left">
         <br>
         <p class="titulos">Almacen Central</p>
         <p class="titulos">Fiscalizacion y Control</p>
        </div>
</div>
  <div class="contenido">
    <h4 class="text-center">Inventario Material Valorado</h4>

 <div class="row" id="inventarioshow">
  <table class="table table-striped tabla-detalle table-sm">
     <tr class="table-secondary">
       <td>Nro</td>
       <td>Material</td>
       <td>Rango Inicial</td>
       <td>Rango Final</td>
       <td>Serie</td>
       <td>Cantidad</td>
       <td>Precio Unitario</td>
       <td>Observaciones</td>
       <td>Precio Total</td>
     </tr>
     <tbody id='DetalleInventario'>
        @if (count($inventario)<=0)
       <tr>
         <td colspan="9">No existen datos sobre esta compra </td>
       </tr>
        @else
        @php ($numero = 1)
        @php ($total = 0)

        @foreach($inventario as $invent)
        <tr>
          <td>{{ $numero }}</td>  
          <td>{{ $invent->material }}</td>
          <td>{{ $invent->rango_inicial }}</td>
          <td>{{ $invent->rango_final }}</td>
          <td>{{ $invent->serie }}</td>
          <td>{{ $invent->cantidad }}</td>
          <td>{{ $invent->precio_unitario }}</td>
          <td>{{ $invent->observaciones }}</td>
          <td>{{ ($invent->cantidad*$invent->precio_unitario) }}</td>
          @php ($numero++)
          @php ($total+=$invent->cantidad*$invent->precio_unitario) 
         </tr>
         @endforeach
          <tr class="table-info">
            <td colspan="8">Total</td>
            <td>{{ $total }}</td>
          </tr>

      @endif


     </tbody>
  </table>
</div>  
</div>
  <footer class="footer row">
    <table class="table table-sm tabla-datos">

    </table>
</footer>
</body>
</html>

Hoping for your collaboration I say goodbye very grateful in advance

    
asked by ALVARO ROBERTO BACARREZA ARZAB 22.06.2018 в 20:10
source

0 answers