update eprescription
This commit is contained in:
@@ -29,6 +29,8 @@ use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\Routing\Controller;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Dompdf\Dompdf;
|
||||
use Dompdf\Options;
|
||||
use DB;
|
||||
|
||||
class PrescriptionController extends Controller
|
||||
@@ -247,4 +249,58 @@ class PrescriptionController extends Controller
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
public function downloadPrescription($id){
|
||||
$pdf = new Dompdf();
|
||||
|
||||
$options = new Options();
|
||||
$options->set('isHtml5ParserEnabled', true);
|
||||
$options->set('isPhpEnabled', true);
|
||||
$options->set(['isRemoteEnabled' => true]);
|
||||
$pdf->setOptions($options);
|
||||
|
||||
$pdf->setPaper('A4', 'portrait');
|
||||
|
||||
|
||||
$livechat = Livechat::with('doctor.user', 'doctor.speciality', 'appointment.appointmentDetail', 'healthCare')
|
||||
->where('nIDAppointment', '!=', null)->where('nIDAppointment', '!=', '')
|
||||
->where('nID', $id)
|
||||
->first();
|
||||
|
||||
$prescription = Prescription::where('nIDLivechat', $id)->first();
|
||||
$valid_date = date('d-m-Y', strtotime($prescription->dTanggalResep . ' +3 days'));
|
||||
$prescriptionItem = PrescriptionItem::where('nIDPrescription', $prescription->nID)->get();
|
||||
|
||||
$user = User::where('nID', $livechat->nIDUser)->first();
|
||||
$doctor = Dokter::where('nIDUser', $livechat->nIDDokter)->first();
|
||||
|
||||
$patient = [
|
||||
'name' => $user->sFirstName. ' '. $user->sMiddleName. ' '. $user->sLastName,
|
||||
'tgl_lahir' => date('d-m-Y', strtotime($user->dTanggalLahir)),
|
||||
'kelamin' => $user->nIDJenisKelamin == 1 ? 'M' : 'F',
|
||||
'umur' => Helper::calculateAge($user->dTanggalLahir)
|
||||
];
|
||||
|
||||
// Memuat view pdf_view.php ke dalam variabel
|
||||
$data = [
|
||||
'doctor' => $doctor,
|
||||
'items' => $prescriptionItem,
|
||||
'tanggal_resep' => date('d-m-Y', strtotime($prescription->dTanggalResep)),
|
||||
'pasien' => $patient,
|
||||
'valid_date' => $valid_date,
|
||||
];
|
||||
// Halaman 1
|
||||
$html1 = view('pdf.prescription', $data);
|
||||
$htmlCombined = $html1 ;
|
||||
|
||||
$pdf->loadHtml($htmlCombined);
|
||||
$pdf->render();
|
||||
|
||||
$headers = [
|
||||
'Content-Type' => 'application/pdf',
|
||||
'Content-Disposition' => 'inline; filename="file.pdf"',
|
||||
];
|
||||
|
||||
return response($pdf->output(), 200, $headers);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user