1
0
forked from s421507/eOSP2

Wniosek o nadanie odznaczenia - lista odznaczen

This commit is contained in:
s421507 2020-07-15 05:34:02 +02:00
parent a6ce63a6d3
commit ff6c53703c
4 changed files with 153 additions and 9 deletions

View File

@ -2,15 +2,10 @@
<project version="4">
<component name="ChangeListManager">
<list default="true" id="adc1032e-2c5f-4e68-bc22-d140f965f9d5" name="Default Changelist" comment="">
<change afterPath="$PROJECT_DIR$/app/Common/PDF.php" afterDir="false" />
<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$/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" />
@ -267,7 +262,7 @@
<workItem from="1592243087933" duration="42000" />
<workItem from="1592276510207" duration="28000" />
<workItem from="1592478779386" duration="40397000" />
<workItem from="1593829053562" duration="14354000" />
<workItem from="1593829053562" duration="24071000" />
</task>
<servers />
</component>
@ -279,6 +274,10 @@
<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="1592276535446" />
<state x="559" y="267" key="NewPhpClassDialog" timestamp="1594782484572">
<screen x="0" y="0" width="1536" height="824" />
</state>
<state x="559" y="267" key="NewPhpClassDialog/0.0.1536.824@0.0.1536.824" timestamp="1594782484572" />
<state x="519" y="347" key="NewPhpFileDialog" timestamp="1593832676565">
<screen x="0" y="0" width="1536" height="824" />
</state>

132
app/Common/PDF.php Normal file
View File

@ -0,0 +1,132 @@
<?php
namespace App\Common;
class PDF extends FPDF
{
function MultiCell($w, $h, $txt, $border=0, $align='J', $fill=false, $maxline=0){
//Output text with automatic or explicit line breaks, at most $maxline lines
$cw=&$this->CurrentFont['cw'];
if($w==0)
$w=$this->w-$this->rMargin-$this->x;
$wmax=($w-2*$this->cMargin)*1000/$this->FontSize;
$s=str_replace("\r",'',$txt);
$nb=strlen($s);
if($nb>0 && $s[$nb-1]=="\n")
$nb--;
$b=0;
if($border)
{
if($border==1)
{
$border='LTRB';
$b='LRT';
$b2='LR';
}
else
{
$b2='';
if(is_int(strpos($border,'L')))
$b2.='L';
if(is_int(strpos($border,'R')))
$b2.='R';
$b=is_int(strpos($border,'T')) ? $b2.'T' : $b2;
}
}
$sep=-1;
$i=0;
$j=0;
$l=0;
$ns=0;
$nl=1;
while($i<$nb)
{
//Get next character
$c=$s[$i];
if($c=="\n")
{
//Explicit line break
if($this->ws>0)
{
$this->ws=0;
$this->_out('0 Tw');
}
$this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill);
$i++;
$sep=-1;
$j=$i;
$l=0;
$ns=0;
$nl++;
if($border && $nl==2)
$b=$b2;
if($maxline && $nl>$maxline)
return substr($s,$i);
continue;
}
if($c==' ')
{
$sep=$i;
$ls=$l;
$ns++;
}
$l+=$cw[$c];
if($l>$wmax)
{
//Automatic line break
if($sep==-1)
{
if($i==$j)
$i++;
if($this->ws>0)
{
$this->ws=0;
$this->_out('0 Tw');
}
$this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill);
}
else
{
if($align=='J')
{
$this->ws=($ns>1) ? ($wmax-$ls)/1000*$this->FontSize/($ns-1) : 0;
$this->_out(sprintf('%.3F Tw',$this->ws*$this->k));
}
$this->Cell($w,$h,substr($s,$j,$sep-$j),$b,2,$align,$fill);
$i=$sep+1;
}
$sep=-1;
$j=$i;
$l=0;
$ns=0;
$nl++;
if($border && $nl==2)
$b=$b2;
if($maxline && $nl>$maxline)
{
if($this->ws>0)
{
$this->ws=0;
$this->_out('0 Tw');
}
return substr($s,$i);
}
}
else
$i++;
}
//Last chunk
if($this->ws>0)
{
$this->ws=0;
$this->_out('0 Tw');
}
if($border && is_int(strpos($border,'B')))
$b.='B';
$this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill);
$this->x=$this->lMargin;
return '';
}
}

View File

@ -44,9 +44,15 @@ class documentApplicationController extends Controller
->select('users.id','users.name', 'users.surname', 'users.PESEL', 'users.fireStationID','users.phoneNumber', 'users.email', 'ranks.rank', 'unitFunctions.unitFunction', 'users.number')
->first();
$awardedDecorations = DB::table('decorationsFirefighters')->where("decorationsFirefighters.firefighterID", '=', $request->fireFighterID)
->whereNull('decorationsFirefighters.deleted_at')
->leftJoin('decorations', 'decorationsFirefighters.decorationID', '=', 'decorations.id')
->select('decorationName', 'dateOfAward', 'firefighterID', 'decorations.id AS decorationsId', 'decorationsFirefighters.id AS decorationsFirefightersID')
->get();
$fireStation = DB::table('fireStations')->where("id", '=', $userData->fireStationID)->first();
$test->wniosekNadaniePDF($userData, $request->decoration, $fireStation);
$test->wniosekNadaniePDF($userData, $request->decoration, $fireStation, $awardedDecorations);
}
}

View File

@ -10,7 +10,7 @@ use App\Common\Helpers;
class documentOverlayController extends Controller
{
public function wniosekNadaniePDF($userData, $decoration, $fireStation){
public function wniosekNadaniePDF($userData, $decoration, $fireStation, $awardedDecorations){
// initiate FPDI
$pdf = new Fpdi();
// set the source file
@ -71,6 +71,13 @@ class documentOverlayController extends Controller
#Funkcja
$pdf->SetXY(35, 113);
$pdf->Cell(20,10, $fireStation->postOffice, 0, 0, 'C');
$txt = "";
foreach($awardedDecorations as $awardedDecoration){
$txt = $txt." ".$awardedDecoration->decorationName."\n";
}
$pdf->SetXY(18, 132);
$pdf->MultiCell(86,4, $txt, 1, 'l', 0);
}
}