eOSP2/app/Http/Controllers/documentApplicationController.php

75 lines
3.2 KiB
PHP
Raw Normal View History

2020-03-25 00:20:45 +01:00
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class documentApplicationController extends Controller
{
2020-07-11 20:56:21 +02:00
public function createWniosekNadanieForm(){
2020-03-25 00:20:45 +01:00
if(auth()->user() != null && auth()->user()->fireStationID != null ){
$fireFighters = DB::table('users')->where("fireStationID", "=", auth()->user()->fireStationID )->get();
2020-06-13 00:02:05 +02:00
$decoration = DB::table('decorations')->pluck('decorationName', 'id');
2020-07-11 20:56:21 +02:00
return view("wniosekNadanieForm")
2020-06-13 00:02:05 +02:00
->with(compact('decoration'))
->with(compact('fireFighters'));
2020-03-25 00:20:45 +01:00
} else{
return view('home');
}
}
2020-07-11 20:56:21 +02:00
public function createKartaEwidencyjnaForm(){
if(auth()->user() != null && auth()->user()->fireStationID != null ){
$fireFighters = DB::table('users')->where("fireStationID", "=", auth()->user()->fireStationID )->get();
$decoration = DB::table('decorations')->pluck('decorationName', 'id');
return view("kartaEwidencyjnaForm")
->with(compact('fireFighters'));
}else{
return view('home');
}
}
public function printWniosekNadaniePDF(){
2020-03-25 00:20:45 +01:00
if(auth()->user() != null && auth()->user()->fireStationID != null ) {
$request = request();
$test = new documentOverlayController();
2020-06-13 00:02:05 +02:00
$userData = DB::table('users')->where("users.id", '=', $request->fireFighterID)
->leftJoin('ranks', 'users.degreeID', '=', 'ranks.id')
->leftJoin('unitFunctions', 'users.functionID', '=', 'unitFunctions.id')
->select('users.id','users.name', 'users.surname', 'users.PESEL', 'users.fireStationID','users.phoneNumber', 'users.email', 'ranks.rank', 'unitFunctions.unitFunction', 'users.number')
->first();
2020-07-12 16:11:49 +02:00
$fireStation = DB::table('fireStations')->where("id", '=', $userData->fireStationID)->first();
2020-06-13 00:02:05 +02:00
2020-07-11 20:56:21 +02:00
$test->wniosekNadaniePDF($userData, $request->decoration, $fireStation);
}
}
public function printKartaEwidencyjnaPDF(){
if(auth()->user() != null && auth()->user()->fireStationID != null ) {
$request = request();
$test = new documentOverlayController();
$userData = DB::table('users')->where("users.id", '=', $request->fireFighterID)
->leftJoin('ranks', 'users.degreeID', '=', 'ranks.id')
->leftJoin('unitFunctions', 'users.functionID', '=', 'unitFunctions.id')
->select('users.id','users.name', 'users.surname', 'users.PESEL', 'users.fireStationID','users.phoneNumber', 'users.email', 'ranks.rank', 'unitFunctions.unitFunction', 'users.number')
->first();
2020-07-12 16:11:49 +02:00
$userTrainings = DB::table('trainingsFirefighters')->where("trainingsFirefighters.firefighterID", '=', $request->fireFighterID)
->leftJoin('trainings', 'trainingsFirefighters.trainingID', '=', 'trainings.id')
2020-07-11 20:56:21 +02:00
->get();
2020-07-12 16:11:49 +02:00
$fireStation = DB::table('fireStations')->where("id", '=', $userData->fireStationID)->first();
2020-07-11 20:56:21 +02:00
$test->kartaEwidencyjnaPDF($userData, $fireStation, $userTrainings);
2020-03-25 00:20:45 +01:00
}
}
}