1
0
forked from s421507/eOSP2

Karta ewidencyjna

This commit is contained in:
s421507 2020-07-11 20:56:21 +02:00
parent a7ea8d2509
commit aa5a8df45f
10 changed files with 253 additions and 89 deletions

View File

@ -3,9 +3,14 @@
<component name="ChangeListManager">
<list default="true" id="adc1032e-2c5f-4e68-bc22-d140f965f9d5" name="Default Changelist" comment="">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/Common/Helpers.php" beforeDir="false" afterPath="$PROJECT_DIR$/app/Common/Helpers.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/Http/Controllers/a.pdf" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/app/Http/Controllers/documentApplicationController.php" beforeDir="false" afterPath="$PROJECT_DIR$/app/Http/Controllers/documentApplicationController.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/Http/Controllers/documentOverlayController.php" beforeDir="false" afterPath="$PROJECT_DIR$/app/Http/Controllers/documentOverlayController.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/resources/views/documentApplicationForm.blade.php" beforeDir="false" afterPath="$PROJECT_DIR$/resources/views/documentApplicationForm.blade.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/Http/Controllers/wniosek_o_nadanie_odznaczenia.pdf" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/resources/views/documents.blade.php" beforeDir="false" afterPath="$PROJECT_DIR$/resources/views/documents.blade.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/resources/views/kartaEwidencyjnaForm.blade.php" beforeDir="false" afterPath="$PROJECT_DIR$/resources/views/kartaEwidencyjnaForm.blade.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/routes/web.php" beforeDir="false" afterPath="$PROJECT_DIR$/routes/web.php" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -166,7 +171,7 @@
<property name="WebServerToolWindowFactoryState" value="false" />
<property name="js.buildTools.grunt.grunt-cli.package" value="" />
<property name="js.buildTools.gulp.gulp_package_dir" value="" />
<property name="last_opened_file_path" value="$PROJECT_DIR$/public/img/left_menu_icon" />
<property name="last_opened_file_path" value="$PROJECT_DIR$" />
<property name="nodejs.jest.jest_package" value="" />
<property name="nodejs.mocha.mocha_node_package_dir" value="" />
<property name="nodejs_interpreter_path.stuck_in_default_project" value="undefined stuck path" />
@ -175,10 +180,6 @@
<property name="settings.editor.selected.configurable" value="database.main" />
</component>
<component name="RecentsManager">
<key name="MoveFile.RECENT_KEYS">
<recent name="C:\Users\czup\PhpstormProjects\eOSP2\resources\views" />
<recent name="$PROJECT_DIR$/database/migrations" />
</key>
<key name="CopyFile.RECENT_KEYS">
<recent name="C:\Users\czup\PhpstormProjects\eOSP2\public\img\left_menu_icon" />
<recent name="C:\Users\czup\PhpstormProjects\eOSP2\app\Http\Controllers" />
@ -186,6 +187,10 @@
<recent name="C:\Users\czup\PhpstormProjects\eOSP2\vendor" />
<recent name="$PROJECT_DIR$/database/migrations/x" />
</key>
<key name="MoveFile.RECENT_KEYS">
<recent name="C:\Users\czup\PhpstormProjects\eOSP2\resources\views" />
<recent name="$PROJECT_DIR$/database/migrations" />
</key>
</component>
<component name="RunManager">
<configuration name="Unnamed" type="docker-deploy" factoryName="docker-compose.yml" server-name="Docker">
@ -257,7 +262,12 @@
<workItem from="1586389118250" duration="3243000" />
<workItem from="1587752993410" duration="614000" />
<workItem from="1591804585624" duration="4930000" />
<workItem from="1591847981434" duration="9628000" />
<workItem from="1591847981434" duration="11876000" />
<workItem from="1592234696135" duration="608000" />
<workItem from="1592243087933" duration="42000" />
<workItem from="1592276510207" duration="28000" />
<workItem from="1592478779386" duration="40397000" />
<workItem from="1593829053562" duration="14354000" />
</task>
<servers />
</component>
@ -265,49 +275,25 @@
<option name="version" value="1" />
</component>
<component name="WindowStateProjectService">
<state x="348" y="67" key="#CLI_Interpreters" timestamp="1583241317032">
<state x="912" y="146" width="424" height="484" key="FileChooserDialogImpl" timestamp="1592276535446">
<screen x="0" y="0" width="1536" height="824" />
</state>
<state x="348" y="67" key="#CLI_Interpreters/0.0.1536.824@0.0.1536.824" timestamp="1583241317032" />
<state x="360" y="70" key="#Docker" timestamp="1583254845348">
<state x="912" y="146" key="FileChooserDialogImpl/0.0.1536.824@0.0.1536.824" timestamp="1592276535446" />
<state x="519" y="347" key="NewPhpFileDialog" timestamp="1593832676565">
<screen x="0" y="0" width="1536" height="824" />
</state>
<state x="360" y="70" key="#Docker/0.0.1536.824@0.0.1536.824" timestamp="1583254845348" />
<state x="468" y="42" key="#com.intellij.execution.impl.EditConfigurationsDialog" timestamp="1583262355627">
<state x="519" y="347" key="NewPhpFileDialog/0.0.1536.824@0.0.1536.824" timestamp="1593832676565" />
<state x="482" y="276" key="com.intellij.ide.util.TipDialog" timestamp="1592243093163">
<screen x="0" y="0" width="1536" height="824" />
</state>
<state x="468" y="42" key="#com.intellij.execution.impl.EditConfigurationsDialog/0.0.1536.824@0.0.1536.824" timestamp="1583262355627" />
<state x="527" y="258" width="559" height="390" key="#com.intellij.fileTypes.FileTypeChooser" timestamp="1583256847898">
<state x="482" y="276" key="com.intellij.ide.util.TipDialog/0.0.1536.824@0.0.1536.824" timestamp="1592243093163" />
<state x="342" y="189" key="run.anything.popup" timestamp="1592234653450">
<screen x="0" y="0" width="1536" height="824" />
</state>
<state x="527" y="258" key="#com.intellij.fileTypes.FileTypeChooser/0.0.1536.824@0.0.1536.824" timestamp="1583256847898" />
<state x="546" y="221" width="524" height="484" key="#com.jetbrains.php.actions.copyPaste.importReferences.PhpImportReferencesDialog" timestamp="1583817494217">
<state x="342" y="189" key="run.anything.popup/0.0.1536.824@0.0.1536.824" timestamp="1592234653450" />
<state x="431" y="145" width="672" height="678" key="search.everywhere.popup" timestamp="1593834623262">
<screen x="0" y="0" width="1536" height="824" />
</state>
<state x="546" y="221" key="#com.jetbrains.php.actions.copyPaste.importReferences.PhpImportReferencesDialog/0.0.1536.824@0.0.1536.824" timestamp="1583817494217" />
<state x="607" y="301" key="DockerComposeFileDialog" timestamp="1583254880063">
<screen x="0" y="0" width="1536" height="824" />
</state>
<state x="607" y="301" key="DockerComposeFileDialog/0.0.1536.824@0.0.1536.824" timestamp="1583254880063" />
<state x="912" y="146" width="424" height="484" key="FileChooserDialogImpl" timestamp="1583254878286">
<screen x="0" y="0" width="1536" height="824" />
</state>
<state x="912" y="146" key="FileChooserDialogImpl/0.0.1536.824@0.0.1536.824" timestamp="1583254878286" />
<state x="604" y="336" key="NewPhpFileDialog" timestamp="1583816251531">
<screen x="0" y="0" width="1536" height="824" />
</state>
<state x="604" y="336" key="NewPhpFileDialog/0.0.1536.824@0.0.1536.824" timestamp="1583816251531" />
<state x="277" y="55" key="SettingsEditor" timestamp="1583262148541">
<screen x="0" y="0" width="1536" height="824" />
</state>
<state x="277" y="55" key="SettingsEditor/0.0.1536.824@0.0.1536.824" timestamp="1583262148541" />
<state x="482" y="276" key="com.intellij.ide.util.TipDialog" timestamp="1591848060220">
<screen x="0" y="0" width="1536" height="824" />
</state>
<state x="482" y="276" key="com.intellij.ide.util.TipDialog/0.0.1536.824@0.0.1536.824" timestamp="1591848060220" />
<state x="431" y="145" width="672" height="678" key="search.everywhere.popup" timestamp="1586390166241">
<screen x="0" y="0" width="1536" height="824" />
</state>
<state x="431" y="145" width="672" height="678" key="search.everywhere.popup/0.0.1536.824@0.0.1536.824" timestamp="1586390166241" />
<state x="431" y="145" width="672" height="678" key="search.everywhere.popup/0.0.1536.824@0.0.1536.824" timestamp="1593834623262" />
</component>
</project>

View File

@ -1 +1,62 @@
<?php
namespace App\Common;
class Helpers
{
public static function peselBirthdayDate($pesel){
$pesel = (String) $pesel;
$output = $pesel[2];
$output = (int)$output;
if( $output == 0 || $output == 1){
$year = '19'."".(String)$pesel[0]."".(String)$pesel[1];
}elseif( $output == 2 || $output == 3){
$year = '20'."".(String)$pesel[0]."".(String)$pesel[1];
}elseif( $output == 4 || $output == 5){
$year = '21'."".(String)$pesel[0]."".(String)$pesel[1];
}elseif( $output == 6 || $output == 7){
$year = '22'."".(String)$pesel[0]."".(String)$pesel[1];
}elseif( $output == 8 || $output == 9){
$year = '18'."".(String)$pesel[0]."".(String)$pesel[1];
}
if($output % 2 == 0 ){
$month = '0'."".(String)$pesel[3];
}else{
$month = '1'."".(String)$pesel[3];
}
$day = (String)$pesel[4]."".(String)$pesel[5];
return $day.".".$month.".".$year;
}
public static function peselBirthdayDateARRAY($pesel){
$pesel = (String) $pesel;
$output = $pesel[2];
$output = (int)$output;
if( $output == 0 || $output == 1){
$year = '19'."".(String)$pesel[0]."".(String)$pesel[1];
}elseif( $output == 2 || $output == 3){
$year = '20'."".(String)$pesel[0]."".(String)$pesel[1];
}elseif( $output == 4 || $output == 5){
$year = '21'."".(String)$pesel[0]."".(String)$pesel[1];
}elseif( $output == 6 || $output == 7){
$year = '22'."".(String)$pesel[0]."".(String)$pesel[1];
}elseif( $output == 8 || $output == 9){
$year = '18'."".(String)$pesel[0]."".(String)$pesel[1];
}
if($output % 2 == 0 ){
$month = '0'."".(String)$pesel[3];
}else{
$month = '1'."".(String)$pesel[3];
}
$day = (String)$pesel[4]."".(String)$pesel[5];
return array($day, $month, $year);
}
}

Binary file not shown.

View File

@ -7,12 +7,12 @@ use Illuminate\Support\Facades\DB;
class documentApplicationController extends Controller
{
public function create(){
public function createWniosekNadanieForm(){
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("documentApplicationForm")
return view("wniosekNadanieForm")
->with(compact('decoration'))
->with(compact('fireFighters'));
@ -22,7 +22,18 @@ class documentApplicationController extends Controller
}
public function printPDF(){
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(){
if(auth()->user() != null && auth()->user()->fireStationID != null ) {
$request = request();
$test = new documentOverlayController();
@ -35,7 +46,29 @@ class documentApplicationController extends Controller
$fireStation = DB::table('firestations')->where("id", '=', $userData->fireStationID)->first();
$test->testPdf($userData, $request->decoration, $fireStation);
$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();
$userTrainings = DB::table('trainingsfirefighters')->where("trainingsfirefighters.firefighterID", '=', $request->fireFighterID)
->leftJoin('trainings', 'trainingsfirefighters.trainingID', '=', 'trainings.id')
->get();
$fireStation = DB::table('firestations')->where("id", '=', $userData->fireStationID)->first();
$test->kartaEwidencyjnaPDF($userData, $fireStation, $userTrainings);
}
}
}

View File

@ -6,41 +6,11 @@ use Codedge\Fpdf\Fpdf\Fpdf;
use Illuminate\Http\Request;
use setasign\Fpdi\Fpdi;
use App\Common\Helpers;
class documentOverlayController extends Controller
{
//
public function peselBirthDay($pesel){
$pesel = (String) $pesel;
$output = $pesel[2];
$output = (int)$output;
if( $output == 0 || $output == 1){
$year = '19'."".(String)$pesel[0]."".(String)$pesel[1];
}elseif( $output == 2 || $output == 3){
$year = '20'."".(String)$pesel[0]."".(String)$pesel[1];
}elseif( $output == 4 || $output == 5){
$year = '21'."".(String)$pesel[0]."".(String)$pesel[1];
}elseif( $output == 6 || $output == 7){
$year = '22'."".(String)$pesel[0]."".(String)$pesel[1];
}elseif( $output == 8 || $output == 9){
$year = '18'."".(String)$pesel[0]."".(String)$pesel[1];
}
if($output % 2 == 0 ){
$month = '0'."".(String)$pesel[3];
}else{
$month = '1'."".(String)$pesel[3];
}
$day = (String)$pesel[4]."".(String)$pesel[5];
return $day.".".$month.".".$year;
}
public function testPdf($userData, $decoration, $fireStation){
public function wniosekNadaniePDF($userData, $decoration, $fireStation){
// initiate FPDI
$pdf = new Fpdi();
// set the source file
@ -76,30 +46,31 @@ class documentOverlayController extends Controller
#Nazwa odznaczenia
$pdf->SetXY(120, 50);
//$pdf->Write(0, $decoration);
$pdf->Cell(20,10, $decoration, 1, 0, 'C');
$pdf->Cell(20,10, $decoration, 0, 0, 'C');
#Imie
$pdf->SetXY(35, 74);
//$pdf->Write(0, $decoration);
$pdf->Cell(20,10, $userData->name, 1, 0, 'C');
$pdf->Cell(20,10, $userData->name, 0, 0, 'C');
#Nazwisko
$pdf->SetXY(95, 74);
//$pdf->Write(0, $decoration);
$pdf->Cell(20,10, $userData->surname, 1, 0, 'C');
$pdf->Cell(20,10, $userData->surname, 0, 0, 'C');
#Data Urodzenia
$pdf->SetXY(35, 93);
//$pdf->Write(0, $decoration);
$pdf->Cell(20,10, $this->peselBirthDay($userData->PESEL), 1, 0, 'C');
$pdf->Cell(20,10, Helpers::peselBirthdayDate($userData->PESEL), 0, 0, 'C');
#Funkcja
$pdf->SetXY(124, 113);
$pdf->Cell(20,10, $userData->unitFunction, 1, 0, 'C');
$pdf->Cell(20,10, $userData->unitFunction, 0, 0, 'C');
#Funkcja
$pdf->SetXY(35, 113);
$pdf->Cell(20,10, $fireStation->postOffice, 1, 0, 'C');
$pdf->Cell(20,10, $fireStation->postOffice, 0, 0, 'C');
}
}
@ -109,4 +80,77 @@ class documentOverlayController extends Controller
}
public function kartaEwidencyjnaPDF($userData, $fireStation, $userTrainings){
// initiate FPDI
$pdf = new Fpdi();
// set the source file
$pageCount = $pdf->setSourceFile("../app/Http/Controllers/documentTemplates/b.pdf");
// import page 1
for ($pageNo = 1; $pageNo <= $pageCount; $pageNo++) {
// import a page
$templateId = $pdf->importPage($pageNo);
// get the size of the imported page
$size = $pdf->getTemplateSize($templateId);
// create a page (landscape or portrait depending on the imported page size)
if ($size[0] > $size[1]) {
$pdf->AddPage('L', array($size[0], $size[1]));
} else {
$pdf->AddPage('P', array($size[0], $size[1]));
}
$pdf->useTemplate($templateId);
if($pageNo == 1) {
$pdf->SetFont('times');
$pdf->SetTextColor(128, 128, 128);
# Imie i nazwisko
$pdf->SetXY(84, 31.5);
$pdf->Cell(0, 10, $userData->surname . ' ' . $userData->name, 0, 0, 'l');
# PESEL
$peselArray = str_split($userData->PESEL);
$x = 116;
foreach ($peselArray as $char) {
$pdf->SetXY($x, 62.5);
$pdf->Cell(0, 10, $char, 0, 0, 'l');
$x = $x + 7.35;
}
# Numer Telefonu
$pdf->SetXY(102, 103);
$pdf->Cell(0, 10, $userData->phoneNumber, 0, 0, 'l');
# Data urodzenia
$birthdayArray = Helpers::peselBirthdayDateARRAY($userData->PESEL);
#Day
$pdf->SetXY(16, 62.5);
$pdf->Cell(0, 10, $birthdayArray[0], 0, 0, 'l');
#Month
$pdf->SetXY(26.5, 62.5);
$pdf->Cell(0, 10, $birthdayArray[1], 0, 0, 'l');
#Month
$pdf->SetXY(37.5, 62.5);
$pdf->Cell(0, 10, $birthdayArray[2], 0, 0, 'l');
$y = 182;
$lp = 1;
foreach($userTrainings as $userTraining){
$pdf->SetXY(20, $y);
$pdf->Cell(0, 10, $lp, 0, 0, 'l');
$pdf->SetXY(26, $y);
$pdf->Cell(0, 10, $userTraining->trainingName, 0, 0, 'l');
$pdf->SetXY(162, $y);
$pdf->Cell(0, 10, $userTraining->dateOfComplete, 0, 0, 'l');
$y = $y + 5.5;
$lp = $lp + 1;
}
}
}
$pdf->Output();
}
}

Binary file not shown.

View File

@ -24,10 +24,15 @@
<button class="btn btn-info" type="submit">Wykaz strażaków wraz z kontaktem</button>
</form>
<form action="/dokumentacja/wniosek" method="post">
<form action="/dokumentacja/wniosek_o_nadanie" method="post">
{{ csrf_field() }}
<button class="btn btn-info" type="submit">Wniosek o przyznanie odznaczenia</button>
</form>
<form action="/dokumentacja/karta_ewidencyjna" method="post">
{{ csrf_field() }}
<button class="btn btn-info" type="submit">Karta Ewidencyjna</button>
</form>
@endif
@endif
@stop

View File

@ -1 +1,34 @@
<?php
@extends('layout.app')
@section('center-area')
@parent
@if( auth()->check())
@if( auth()->user()->fireStationID == NULL)
Jednostka nie istnieje
@else
<form method="POST" action="/dokumentacja/karta_ewidencyjna/pdf">
{{ csrf_field() }}
<div class="form-group row">
<div class="col-auto">
<label for="location">Wnioskujacy:</label>
<select name="fireFighterID" class="form-control">
<option value="">--- Wybierz strażaka ---</option>
@foreach ($fireFighters as $fireFighter)
<option value="{{$fireFighter->id}}">{{ $fireFighter->name }} {{$fireFighter->surname }}</option>
@endforeach
</select>
</div>
</div>
<div class="form-group">
<button style="cursor:pointer" type="submit" class="btn btn-primary">Drukuj</button>
</div>
@include('inc.formerrors')
</form>
@endif
@else
Brak autoryzacji
@endif
@stop

View File

@ -133,6 +133,8 @@ Route::post('/pdf/strazacy', 'pdfController@createViewFireFighters');
Route::get('/forgottenPassword', 'resetPasswordController@create');
Route::post('/forgottenPassword', 'resetPasswordController@reset');
Route::get('/pdf/test', 'documentOverlayController@testPdf');
Route::post('/dokumentacja/wniosek', 'documentApplicationController@create');
Route::post('/dokumentacja/wniosek/pdf', 'documentApplicationController@printPDF');
Route::post('/dokumentacja/wniosek_o_nadanie', 'documentApplicationController@createWniosekNadanieForm');
Route::post('/dokumentacja/wniosek_o_nadanie/pdf', 'documentApplicationController@printWniosekNadaniePDF');
Route::post('/dokumentacja/karta_ewidencyjna', 'documentApplicationController@createKartaEwidencyjnaForm');
Route::post('/dokumentacja/karta_ewidencyjna/pdf', 'documentApplicationController@printKartaEwidencyjnaPDF');