diff --git a/laravel/app/Http/Controllers/AnalyticController.php b/laravel/app/Http/Controllers/AnalyticController.php index fa0397f..4a3c2b1 100644 --- a/laravel/app/Http/Controllers/AnalyticController.php +++ b/laravel/app/Http/Controllers/AnalyticController.php @@ -71,7 +71,7 @@ class AnalyticController extends LocalController $exceldata = []; $exceldata[] = $fields; foreach($response->data->items as $item) { - $item = [$item->name,$item->email,$item->phone,isset($item->date_of_birth)?$item->date_of_birth:'-',isset($item->gender)?$item->gender:'-',$item->alternate_phone,$item->city,$item->state,$item->highlight_qualification,$item->specialization,$item->type_of_setup,$item->designation,$item->clinic_institute_name,isset($item->present) && $item->present == 'yes' ? 'Present':'Absent']; + $item = [$item->name ?? '',$item->email ?? '',$item->phone ?? '',$item->date_of_birth ?? '-',$item->gender ?? '-',$item->alternate_phone ?? '',$item->city ?? '',$item->state ?? '',$item->highlight_qualification ?? '',$item->specialization ?? '',is_array($item->type_of_setup ?? null) ? implode(', ', $item->type_of_setup) : ($item->type_of_setup ?? ''),$item->designation ?? '',$item->clinic_institute_name ?? '',isset($item->present) && $item->present == 'yes' ? 'Present':'Absent']; $exceldata[] = $item; } return Excel::download(new InvoicesExport($exceldata), 'report.xlsx'); diff --git a/laravel/app/Http/Controllers/SessionController.php b/laravel/app/Http/Controllers/SessionController.php index db39d10..d86b9d4 100644 --- a/laravel/app/Http/Controllers/SessionController.php +++ b/laravel/app/Http/Controllers/SessionController.php @@ -159,6 +159,24 @@ class SessionController extends LocalController return Response::download($folder.'/'.$filename, 'certificate.png',$headers); } + public function certificatepreview(Request $request) { + $type = $request->input('type', 'casper_plus'); + $session = (object) [ + 'type' => $type, + 'code' => 'preview', + 'start_date' => $request->input('date', date('Y-m-d')), + ]; + $doctor = (object) [ + 'name' => $request->input('name', 'Sample Doctor Name'), + 'id' => 'preview-' . time(), + ]; + $output = Creation::certificate($session, $doctor); + + return response()->file($output['folder'] . '/' . $output['filename'], [ + 'Content-Type' => 'image/png', + ]); + } + public function agenda(Request $request) { $id = $request->input('id', 0); if($id === 0) { diff --git a/laravel/app/Http/Requests/Creation.php b/laravel/app/Http/Requests/Creation.php index 6d180ad..fe6c2c1 100644 --- a/laravel/app/Http/Requests/Creation.php +++ b/laravel/app/Http/Requests/Creation.php @@ -39,9 +39,18 @@ class Creation } if($session->type == 'casper_plus'){ $font = storage_path('app').'/fonts/pala.ttf'; - $white = imagecolorallocate($outputImage, 0, 0, 0); - imagettftext($outputImage, 30, 0, 590, 514, $white, $font, $doctor->name ); - imagettftext($outputImage, 30, 0, 988, 684, $white, $font, date("d M Y", strtotime($session->start_date)) ); + $color = imagecolorallocate($outputImage, 0, 0, 0); + $nameSize = 30; + $dateSize = 30; + $nameX = 590; + $nameY = 514; + $dateX = 988; + $dateY = 684; + $certificateDate = !empty($session->start_date) + ? date('d M Y', strtotime($session->start_date)) + : date('d M Y'); + imagettftext($outputImage, $nameSize, 0, $nameX, $nameY, $color, $font, $doctor->name); + imagettftext($outputImage, $dateSize, 0, $dateX, $dateY, $color, $font, $certificateDate); } if($session->type == 'APFT'){ $font = storage_path('app').'/fonts/pala.ttf'; diff --git a/laravel/resources/views/session/attendance.blade.php b/laravel/resources/views/session/attendance.blade.php index 366c18a..057aa6b 100644 --- a/laravel/resources/views/session/attendance.blade.php +++ b/laravel/resources/views/session/attendance.blade.php @@ -60,19 +60,19 @@ @foreach($doctors as $item) - {{$item->name}} - {{$item->email}} - {{$item->phone}} - {{isset($item->date_of_birth)?$item->date_of_birth:''}} - {{isset($item->gender)?$item->gender:''}} - {{$item->alternate_phone}} - {{$item->city}} - {{$item->state}} - {{$item->highlight_qualification}} - {{$item->specialization}} - {{ is_array($item->type_of_setup) ? implode(', ', $item->type_of_setup) : $item->type_of_setup }} - {{$item->designation}} - {{$item->clinic_institute_name}} + {{ $item->name ?? '' }} + {{ $item->email ?? '' }} + {{ $item->phone ?? '' }} + {{ $item->date_of_birth ?? '' }} + {{ $item->gender ?? '' }} + {{ $item->alternate_phone ?? '' }} + {{ $item->city ?? '' }} + {{ $item->state ?? '' }} + {{ $item->highlight_qualification ?? '' }} + {{ $item->specialization ?? '' }} + {{ is_array($item->type_of_setup ?? null) ? implode(', ', $item->type_of_setup) : ($item->type_of_setup ?? '') }} + {{ $item->designation ?? '' }} + {{ $item->clinic_institute_name ?? '' }} {{isset($item->present) && $item->present == 'yes' ? 'Present':'Absent'}} {{isset($item->feedback) && $item->feedback == 'yes' ? 'Yes':'-'}} {!!isset($item->present) && $item->present == 'yes' && isset($item->feedback) && $item->feedback == 'yes' ? 'Download':''!!}