fix pdf download

parent 786bc219
<?php <?php
use Illuminate\Support\Facades\Route; use Illuminate\Support\Facades\Route;
use Portal\Mileage\Http\Controllers\ApplyformController;
use Portal\Mileage\Http\Controllers\ApplicationsController;
use Portal\Mileage\Http\Controllers\PMController; use Portal\Mileage\Http\Controllers\PMController;
use Portal\Mileage\Http\Controllers\ProjectDirectorController;
use Portal\Mileage\Http\Controllers\HODController; use Portal\Mileage\Http\Controllers\HODController;
use Portal\Mileage\Http\Controllers\BODController; use Portal\Mileage\Http\Controllers\BODController;
use Portal\Mileage\Http\Controllers\HRController; use Portal\Mileage\Http\Controllers\HRController;
...@@ -19,23 +16,6 @@ ...@@ -19,23 +16,6 @@
'middleware' => ['web', 'auth'], 'middleware' => ['web', 'auth'],
], ],
function () { function () {
// Applyform
Route::prefix('applyform')->name('applyform')->group(function () {
Route::get('/', [ApplyformController::class, 'index'])->name('.index');
Route::get('/noproject', [ApplyformController::class, 'noproject'])->name('.noproject');
Route::get('/applyform/getDates', [ApplyformController::class, 'getDates'])->name('.getDates');
});
// Route::resource('applyform', ApplyformController::class);
// Applications
Route::get('applications/senarai', [ApplicationsController::class, 'senarai'])->name('applications.senarai');
Route::resource('applications', ApplicationsController::class);
Route::put('applications/{id}/updateStatus', [ApplicationsController::class, 'updateStatus'])
->name('applications.updateStatus');
Route::get('applications/view/claim/{id}', [ApplicationsController::class, 'viewEach'])->name('applications.viewEach');
Route::put('applications/{id}', [ApplicationsController::class, 'update'])
->name('applications.update');
/// PM /// PM
Route::prefix('PM')->name('PM')->group(function () { Route::prefix('PM')->name('PM')->group(function () {
Route::get('/dashboard', [PMController::class, 'index'])->name('.index'); Route::get('/dashboard', [PMController::class, 'index'])->name('.index');
...@@ -45,16 +25,6 @@ function () { ...@@ -45,16 +25,6 @@ function () {
Route::post('/{id}/submitTindakan', [PMController::class, 'submitTindakan'])->name('.submitTindakan'); Route::post('/{id}/submitTindakan', [PMController::class, 'submitTindakan'])->name('.submitTindakan');
}); });
// Project Director
Route::prefix('projectDirector')->name('projectDirector')->group(function () {
Route::get('/dashboard', [ProjectDirectorController::class, 'index'])->name('.index');
Route::get('/show/{projectId}/{userId}', [ProjectDirectorController::class, 'show'])->name('.show');
Route::post('/approve-month', [ProjectDirectorController::class, 'approveMonth'])->name('.approveMonth');
Route::post('/reject-month', [ProjectDirectorController::class, 'rejectMonth'])->name('.rejectMonth');
Route::post('/claim/{id}/approve', [ProjectDirectorController::class, 'approveClaim'])->name('.approveClaim');
Route::post('/claim/{id}/reject', [ProjectDirectorController::class, 'rejectClaim'])->name('.rejectClaim');
});
// Finance // Finance
Route::prefix('finance')->name('finance')->group(function () { Route::prefix('finance')->name('finance')->group(function () {
Route::get('/dashboard', [FinanceController::class, 'index'])->name('.index'); Route::get('/dashboard', [FinanceController::class, 'index'])->name('.index');
...@@ -117,10 +87,12 @@ function () { ...@@ -117,10 +87,12 @@ function () {
Route::get('department/{id}/edit', [DepartmentController::class, 'edit'])->name('department.edit'); Route::get('department/{id}/edit', [DepartmentController::class, 'edit'])->name('department.edit');
Route::put('department/{id}', [DepartmentController::class, 'update'])->name('department.update'); Route::put('department/{id}', [DepartmentController::class, 'update'])->name('department.update');
Route::delete('department/{id}', [DepartmentController::class, 'destroy'])->name('department.destroy'); Route::delete('department/{id}', [DepartmentController::class, 'destroy'])->name('department.destroy');
}
Route::get('claim/{id}/pdf', ['uses' => 'MileageController@downloadPdf', 'as' => 'mileage.claim.downloadPdf']); Route::get('claim/{id}/pdf', ['uses' => 'MileageController@downloadPdf', 'as' => 'mileage.claim.downloadPdf']);
} }
); );
// Guest group (currently unused) // Guest group (currently unused)
......
...@@ -189,6 +189,7 @@ public function downloadPdf(Request $request, $id) ...@@ -189,6 +189,7 @@ public function downloadPdf(Request $request, $id)
'attachments', 'attachments',
'faCategory', 'faCategory',
'financeDetail', 'financeDetail',
'financeDetail.processedBy',
])->findOrFail($id); ])->findOrFail($id);
if (!in_array($claim->status, [11, 12])) { if (!in_array($claim->status, [11, 12])) {
...@@ -205,7 +206,7 @@ public function downloadPdf(Request $request, $id) ...@@ -205,7 +206,7 @@ public function downloadPdf(Request $request, $id)
} }
$html = view('mileage::mileage.pdf', compact('claim'))->render(); $html = view('mileage::mileage.pdf', compact('claim'))->render();
$pdf = \Barryvdh\DomPDF\Facade\Pdf::loadHTML($html)->setPaper('A4', 'portrait'); $pdf = \Barryvdh\DomPDF\Facade\Pdf::loadHTML($html)->setPaper('A4', 'landscape');
return $pdf->download('Tuntutan_Mileage_' . $claim->mm_apply_no . '.pdf'); return $pdf->download('Tuntutan_Mileage_' . $claim->mm_apply_no . '.pdf');
......
...@@ -49,7 +49,7 @@ protected static function boot() ...@@ -49,7 +49,7 @@ protected static function boot()
public static function generateApplyNo(): string public static function generateApplyNo(): string
{ {
$year = now()->format('Y'); $year = now()->format('Y');
$prefix = "MC-{$year}-"; $prefix = "TC-{$year}-";
$last = static::where('mm_apply_no', 'like', "{$prefix}%") $last = static::where('mm_apply_no', 'like', "{$prefix}%")
->orderByDesc('mm_apply_no') ->orderByDesc('mm_apply_no')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment