From 78097207e2dc287f9c5d0789f839fe35a63c99ea Mon Sep 17 00:00:00 2001 From: czup Date: Sun, 5 Jan 2020 11:47:32 +0100 Subject: [PATCH] =?UTF-8?q?Wykaz=20stra=C5=BCak=C3=B3w?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/pdfController.php | 58 ++++++++++++++++++++++++++ routes/web.php | 2 + 2 files changed, 60 insertions(+) diff --git a/app/Http/Controllers/pdfController.php b/app/Http/Controllers/pdfController.php index c3ccc63..43aa5d5 100644 --- a/app/Http/Controllers/pdfController.php +++ b/app/Http/Controllers/pdfController.php @@ -3,6 +3,7 @@ namespace App\Http\Controllers; use Codedge\Fpdf\Fpdf\Fpdf; use DB; +use Carbon; class pdfController extends Controller { public function textConvert($text){ @@ -50,4 +51,61 @@ class pdfController extends Controller $pdf->Output(); exit; } + + public function createViewDecoration(){ + + $pdf = new FPDF(); + + $pdf->AddFont('arialpl', '', 'arialpl.php'); + $pdf->AddFont('arialpl', 'B', 'arialplb.php'); + $pdf->AddPage(); + $pdf->SetFont('arialpl','B',16); + $pdf->Cell(40,10, $this->textConvert("5. Sprzęt na wyposażeniu jednostki:")); + $pdf->Output(); + exit; + } + + public function createViewFireFighters(){ + if(auth()->user() != null && auth()->user()->fireStationID != null ){ + $users = DB::table('users')->where("fireStationID", '=', auth()->user()->fireStationID)->get(); + } + + $mytime = Carbon\Carbon::now()->toDateString('Y-m-d'); + + $pdf = new FPDF(); + $pdf->AddPage(); + $pdf->AddFont('arialpl', '', 'arialpl.php'); + $pdf->AddFont('arialpl', 'B', 'arialplb.php'); + $pdf->SetFont('arialpl','B',16); + $pdf->Cell(200,10, $this->textConvert("Wykaz strażaków na dzień: ".$mytime), 0, 0, 'C'); + $pdf->Ln(); + $pdf->SetFillColor(152,152,152); + $pdf->Cell(60,10, $this->textConvert("Imię i Nazwisko"), 1, 0, 'C', true); + $pdf->Cell(90,10, $this->textConvert("Email"), 1, 0, 'C', true); + $pdf->Cell(40,10, $this->textConvert("Telefon"), 1, 0, 'C', true); + $pdf->Ln(); + $pdf->SetFont('arialpl','',14); + + $fill = false; + $pdf->SetFillColor(224,224,224); + foreach( $users as $user){ + $text = $user->name." ".$user->surname; + $pdf->Cell(60,10,$this->textConvert($text), 1, 0, 'C', $fill); + $pdf->Cell(90,10,$this->textConvert($user->email), 1, 0, 'C', $fill); + $pdf->Cell(40,10,$this->textConvert($user->phoneNumber), 1, 0, 'C', $fill); + $pdf->Ln(); + + $fill = !$fill; + } + + $pdf->SetLeftMargin(140); + $pdf->Ln(); + $pdf->Ln(); + $pdf->Cell(40,5,"........................................."); + $pdf->SetFont('arialpl','',10); + $pdf->Ln(); + $pdf->Cell(60,5, "(podpis naczelnika OSP)", 0, 0, 'C'); + $pdf->Output(); + exit; + } } diff --git a/routes/web.php b/routes/web.php index 8cccb12..4445d3a 100644 --- a/routes/web.php +++ b/routes/web.php @@ -110,3 +110,5 @@ Route::get('register/verify/{confirmationCode}', [ //Route::get('/home', 'HomeController@index')->name('home'); Route::post('/pdf/sprzet', 'pdfController@createViewEquipment'); +Route::get('/pdf/wniosek', 'pdfController@createViewDecoration'); +Route::get('/pdf/strazacy', 'pdfController@createViewFireFighters');