Good afternoon I have a small problem and it is the following I have my route for the pdf which is as follows:
Route::resource('cuadre','CuadreController');
Route::get('vista-html-pdf',array(
'as'=>'vistaHTMLPDF',
'uses'=>'CuadreController@vistaHTMLPDF'
));
and this one from my controller:
public function vistaHTMLPDF(Request $request) {
$fecha1;
$fecha2;
$zona;
//trayendo objeto de cuadre con todos los atributos guardados en store
$guia =Cuadre::orderBy('idcuadre','ASC')->paginate(5);
foreach($guia as $guias) {
$id = $guias->idcuadre;
$zona = $guias->idzona;
$fecha1 = $guias->fechainicial;
$fecha2 = $guias->fechafinal;
}
/*consulta para borrar los registros a la hora de darle al boton cerrar */
// $fechacierre =DB::delete('delete from asignacion where idzona='.$zona.
// ' and ts between '.$fecha1.' and '.$fecha2);
/*Consulta de zona pereira*/
$cua = DB::select('select forma_pago ,sum(valor_neto) as s
FROM asignacion as a,
guia_manual as b where b.idguia_manual = a.idguia and
idzona='.$zona.' GROUP by forma_pago');
//consulta para traerme el resumen de los pagos y el total de guias creadas en pereira
$resumen = DB::select('select remision,forma_pago,valor_neto
FROM guia_manual g,
asignacion a WHERE a.idguia = g.idguia_manual and idzona='.$zona);
/*Consulta de zona bogota*/
$bog2 = DB::select('select forma_pago,sum(valor_neto) as s
FROM asignacion as a,
guia_manual as b
where b.idguia_manual = a.idguia and
idzona='.$zona.'
GROUP by forma_pago');
if($request->has('descargar')){
$pdf = PDF::loadView('vista-html-pdf');
return $pdf->download('reporte');
}
if($zona=='12'){
return view('vista-html-pdf')->with('cua',$cua)->with('resumen', $resumen)->with('zona',$zona);
} elseif ($zona=='13') {
return view('vista-html-pdf')->with('bog2',$bog2)->with('resumen', $resumen)->with('zona',$zona);
}
and this is my view for the pdf:
<div class="botones">
<div class="form-group">
<a href="{{route('vistaHTMLPDF',['descargar'=>'pdf'])}}" class="btn btn-warning">Ver Pdf </a>
</div>
</div>
<?php if ($zona =="12"): ?>
<table style="width: 18%" class="table table-striped">
@foreach($cua as $cuas)
<tr>
<th>total {{$cuas->forma_pago}}: </th>
<td>{{$cuas->s}}</td>
</tr>
@endforeach
</table>
<table style="width: 30%" class="table table-striped">
<th>Guias</th>
<th>Forma pago</th>
<th>Valor</th>
@foreach($resumen as $remisiones)
<tr>
<td>{{$remisiones->remision}}</td>
<td>{{$remisiones->forma_pago}}</td>
<td>{{$remisiones->valor_neto}}</td>
</tr>
@endforeach
</table>
<tbody>
</tbody>
<?php endif ?>
<?php if ($zona=='13'): ?>
<table style="width: 18%" class="table table-striped">
@foreach($bog2 as $bogs2)
<tr>
<th>total {{$bogs2->forma_pago}}: </th>
<td>{{$bogs2->s}}</td>
</tr>
@endforeach
</table>
<table style="width: 30%" class="table table-striped">
<th>Guias</th>
<th>Forma pago</th>
<th>Valor</th>
@foreach($resumen as $remisiones)
<tr>
<td>{{$remisiones->remision}}</td>
<td>{{$remisiones->forma_pago}}</td>
<td>{{$remisiones->valor_neto}}</td>
</tr>
@endforeach
</table>
<tbody>
</tbody>
<?php endif ?>
but when pressing the button see pdf I get that the variables that I am sent to the view are not defined but I do not know why.