Quantcast
Channel: Active questions tagged html - Stack Overflow
Viewing all articles
Browse latest Browse all 73935

Redirect page after opening pdf file in another tab

$
0
0

hope you can help me, I am using barryvdh / laravel-dompdf to be able to create the pdf that the reporting system needs, now I need to redirect the page where the button is pressed to create it, the methods that have been used only the pdf in another tag, but does not redirect or redirect but does not generate the pdf. Attached part of the code.

I would appreciate all the help you can provide to solve this dilemma. If you need more reelevance information, please let me know.

//============================ imprimir factura ============================
public function imprimir_factura(Request $request)
{
    if($request->person_id != null){
        if($request->factura != null){

            $billing = billing::find($request->factura);
            $billing->person_id = $request->person_id;
            $billing->type_payment_id = $request->tipo_pago;
            $billing->type_currency = $request->tipo_moneda;
            $billing->save();
            $fecha = Carbon::now()->format('Y-m-d');

            $todos = Billing::with('person','employe.person','employe.doctor', 'patient', 'procedure','typepayment' , 'typecurrency')->where('id',$billing->id)->first();
            $total = 0;
            foreach($todos->procedure as $proce) { 
                $total += $proce->price;
            }

            $cirugia = Itinerary::with('person','employe.person','surgery.typesurgeries')->where('patient_id', $todos->patient_id )->where('employe_id',$todos->employe_id)->first();

            if($cirugia->surgery != null){
                $total_cancelar = $cirugia->surgery->typesurgeries->cost + $todos->employe->doctor->price + $total;
            }else{
                $total_cancelar = $todos->employe->doctor->price + $total;
            }

            $pdf = PDF::loadView('dashboard.checkout.print', compact('todos','cirugia','total_cancelar','fecha'));

            return $pdf->stream('factura.pdf');
        }else{
            Alert::error('No puede procesar la factura');
            return redirect()->back();
        }
    }else{
        Alert::error('No puede procesar la factura');
        return redirect()->back();
    }
}

<form action="{{ route('checkout.imprimir_factura') }}" method="POST" target="_blank">
    @csrf 
    <div class="section-body py-3 row">
        <div class="section-body py-3 col-10 ml-5 ">
            <div class="container">
                <div class="tab-content">
                    <!-----------------------Campos ocultoss---------------------->
                    <input id="person_id" type="hidden" name="person_id" value="">
                    <input type="hidden" name="factura" value="{{ $crear_factura->id }}">
                    <!-------------------- fin de Campos ocultoss------------------>
                    <div class="tab-pane fade active show" id="Invoice-detail" role="tabpanel">
                        <div class="row clearfix">
                            <div class="col-md-12 col-lg-12 col-sm-12">
                                <div class="card">
                                    <div class="card-body row my-8  pl-4">
                                        <div class="col-lg-4 col-md-4 col-sm-12"><h2>Factura</h2> </div>
                                        <div class="col-lg-8 col-md-8 col-sm-12 d-flex justify-content-end pr-3 pt-10" style="color:#000">
                                            <span class="h6 h66 pt-0 pr-10">Fecha:</span><span class="text col-lg-4 col-md-7 col-sm-12" style="margin-bottom:50px"><i class="fa fa-calendar pl-20"></i> {{ $fecha }}</span><br>
                                        </div>                             
                                    </div>
                                    <div class="card-body mt-0 " style="top:-50px">
                                    <!--Paciente-->
                                        <div class="row">
                                            <div class="col-lg-3 col-md-12 col-sm-12 mb-2">
                                                <span class="h6 h66"><i class="fa fa-user mr-2" style="font-size:18px"></i>Paciente:</span>
                                            </div>
                                            <input type="hidden" id="paciente_id" name="paciente_id" value="{{ $itinerary->person->id }}">
                                            <div class="col-lg-3 col-md-4 col-sm-12 pr-10 mb-2">
                                                <span id="dni" class="text form-control p-1 mt-0 text-left"><i class="fa fa-address-card"></i>&nbsp;&nbsp;{{ $itinerary->person->dni }}</span>
                                            </div>
                                            <div class="col-lg-3 col-md-4 col-sm-12 mb-2">
                                                <span id="name" class="text form-control p-1 text-left"><i class="fa fa-user"></i>&nbsp;&nbsp;{{ $itinerary->person->name }} {{ $itinerary->person->lastname }}</span>
                                            </div>
                                            <div class="col-lg-3 col-md-4 col-sm-12 mb-2">
                                                <span id="phone" class="text form-control p-1 text-left"><i class="fa fa-phone"></i>&nbsp;&nbsp;{{ $itinerary->person->phone }}</span><br>
                                            </div>
                                        </div>

                                    <!--Medico tratante-->
                                        <div class="row">
                                            <div class="col-lg-3 col-md-12 col-sm-12 mb-2">
                                                <span class="h6 h66"><i class="fa fa-user-md mr-2" style="font-size:18px"></i>Medico tratante:</span>
                                            </div>
                                            <div class="col-lg-3 col-md-4 col-sm-12 pr-10 mb-2">
                                                <span class="text form-control p-1 text-left"><i class="fa fa-address-card"></i>&nbsp;&nbsp;{{ $itinerary->employe->person->dni }}</span>
                                            </div>
                                            <div class="col-lg-3 col-md-4 col-sm-12 pr-10 mb-2">
                                                <span class="text form-control p-1 text-left"><i class="fa fa-user-md"></i>&nbsp;&nbsp;{{ $itinerary->employe->person->name }} {{ $itinerary->employe->person->lastname }}</span>
                                            </div>
                                            <div class="col-lg-3 col-md-4 col-sm-12 pr-10 mb-2">
                                                <span class="text form-control p-1 text-left"><i class="fa fa-phone"></i>&nbsp;&nbsp;{{ $itinerary->employe->person->phone }}</span><br>
                                            </div>
                                        </div><br>
                                        <div class="row">
                                            <div class="col-12 mt-2 d-flex justify-content-center">
                                                    <span class="h6 h66">Seleccione persona a pagar</span>
                                            </div>
                                        </div>
                                        <div class="row">
                                            <div class="col-12 mt-2 d-flex justify-content-center">
                                                <div class="col-6 d-flex justify-content-end">
                                                        <a class="btn btn-boo " title="Paciente" style="color:#fff" id="paciente" name="paciente"> 
                                                            <i class="fa fa-user mr-2"></i> Paciente
                                                        </a>
                                                    </div>
                                                    <div class="col-6">
                                                            <a  class="btn btn-boo " title="Agregar cliente" style="color:#fff" data-toggle="modal" data-target="#otro"> 
                                                            <i class="fa fa-user-plus"></i> Otro cliente
                                                        </a>
                                                    </div>
                                            </div>
                                        </div><br>
                                        <!--Persona a cancelar-->
                                        <div class="row">
                                            <div class="col-lg-3 col-md-12 col-sm-12 mb-2 mt-2">
                                                <span class="h6 h66"><i class="fa fa-shopping-cart mr-1" style="font-size:18px"></i> Pagado por:</span>
                                            </div>
                                            <div class="col-lg-3 col-md-4 col-sm-12 mb-2 mt-2">
                                                <span class="text form-control p-1"><i class="fa fa-address-card pl-1"></i>&nbsp;<span id="dni_c" class="text text-left"></span></span>
                                            </div>
                                            <div class="col-lg-3 col-md-4 col-sm-12 mb-2 mt-2">
                                                <span class="text form-control p-1"><i class="fa fa-user pl-1"></i>&nbsp;<span id="name_c" class="text text-left"></span><span id="lastname_c" class="text text-left"></span></span>
                                            </div>
                                            <div class="col-lg-3 col-md-4 col-sm-12 mb-2 mt-2">
                                                <span class="text form-control p-1"><i class="fa fa-phone pl-1"></i>&nbsp;<span id="phone_c" class="text text-left"></span></span>
                                            </div>
                                        </div>

                                        <!--tipo de moneda-->
                                        <div class="row mt-4">
                                            <div class="col-lg-6 col-md-6">
                                                <span class="h6 h66">Tipo de moneda:</span>
                                                <div class="form-group multiselect_div mt-2">
                                                    <select id="single-selection" name="tipo_moneda" class="multiselect multiselect-custom" style="display: none;">
                                                        @foreach ($tipo_moneda as $moneda)
                                                        <option value="{{ $moneda->id }}">{{ $moneda->name }}</option>
                                                        @endforeach
                                                    </select>
                                                </div>
                                            </div>
                                            <!--tipo de pago-->
                                            <div class="col-lg-6 col-md-6">
                                                <span class="h6 h66">Tipo de pago:</span>
                                                <div class="form-group multiselect_div mt-2">
                                                    <select id="single-selection2" name="tipo_pago" class="multiselect multiselect-custom" style="display: none;">
                                                        @foreach ($tipo_pago as $pago)
                                                        <option value="{{ $pago->id }}">{{ $pago->name }}</option>
                                                        @endforeach
                                                    </select>
                                                </div>
                                            </div>
                                        </div>

                                        <!--Modal-->
                                        <div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
                                            <div class="modal-dialog" role="document">
                                                <div class="modal-content">
                                                    <div class="modal-header">
                                                    <h5 class="modal-title" id="exampleModalLabel">Modal title</h5>
                                                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                                        <span aria-hidden="true">&times;</span>
                                                    </button>
                                                    </div>
                                                    <div class="modal-body">
                                                    ...
                                                    </div>
                                                    <div class="modal-footer">
                                                    <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
                                                    <button type="button" class="btn btn-primary">Save changes</button>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>

                                        <div class="table-responsive push">
                                            <table class="table table-bordered table-hover mt-5">
                                                <tbody style="border-bottom: 1px solid #000">
                                                    <td colspan="5" class="text-left pl-4" style="font-weight:bold; ">DESCRIPCION</td>
                                                    <td class="text-right" style="width: 4%; font-weight:bold">COSTO</td>
                                                </tbody>
                                                @if($itinerary->employe->doctor != null)
                                                    <tbody style="border-bottom: 1px solid #000">
                                                        <td colspan="5" class="text-left pl-4">Consulta Médica</td>
                                                        <td class="text-right" style="width: 1%">{{ $itinerary->employe->doctor->price }}</td>
                                                    </tbody>
                                                @endif
                                                @if($procedure != 0)
                                                <tbody>
                                                    @foreach ($procedure as $item)
                                                    <tr>
                                                        <td colspan="5" class="text-left pl-4">
                                                            <div class="text-muted">Procedimiento {{ $item->name }}</div>
                                                        </td>

                                                        <td class="text-right" style="width: 1%">{{ $item->price }}</td>
                                                    </tr>
                                                    @endforeach
                                                </tbody> 
                                                @endif
                                                @if($itinerary->surgery != null)
                                                <tbody>
                                                    <tr>
                                                        <td colspan="5" class="text-left pl-4">
                                                            <div class="text-muted">Cirugía {{ $itinerary->surgery->typesurgeries->name }}</div>
                                                        </td>
                                                        <td class="text-right" style="width: 1%">{{ $itinerary->surgery->typesurgeries->cost }}</td>
                                                    </tr>
                                                </tbody> 
                                                @endif
                                                <tr>
                                                    <td colspan="5" class="font600 text-right">Subtotal</td>
                                                    <td class="text-right" id="subtotal">{{ $total }}</td> 
                                                </tr>
                                                <tr class="bg-boo text-light">
                                                    <td colspan="5" class="font700 text-right ">Total a cancelar</td>
                                                    <td class="font700 text-right" id="costo_total">{{ $total }}</td>
                                                </tr>
                                            </table>
                                        </div><br>
                                        <div class="row d-flex justify-content-end">
                                            <button type="submit" class="btn btn-boo pr-5 pl-5 mr-3" onclick="redirect()"> <i class="fa fa-print"> </i> Imprimir</button>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>

                    </div>
                </div>                
            </div>
        </div>
    </div>
</form>

Viewing all articles
Browse latest Browse all 73935

Trending Articles