1
0
forked from s421507/eOSP2

Stan sprzetu pdf

This commit is contained in:
czup 2020-01-05 10:42:59 +01:00
parent e21a6ebb54
commit 0eee1dc4d9
3 changed files with 52 additions and 7 deletions

View File

@ -2,14 +2,51 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use Codedge\Fpdf\Fpdf\Fpdf; use Codedge\Fpdf\Fpdf\Fpdf;
use DB;
class pdfController extends Controller class pdfController extends Controller
{ {
public function createView(){ public function textConvert($text){
return iconv('utf-8','iso-8859-2',$text);
}
public function createViewEquipment(){
if(auth()->user() != null && auth()->user()->fireStationID != null ){
$equipment = DB::table('equipment')->where("fireStationID", '=', auth()->user()->fireStationID)
->whereNull('deleted_at')->get();
}
$pdf = new FPDF(); $pdf = new FPDF();
$pdf->AddPage(); $pdf->AddPage();
$pdf->SetFont('Arial','B',16); $pdf->AddFont('arialpl', '', 'arialpl.php');
$pdf->Cell(40,10,'Hello World!'); $pdf->AddFont('arialpl', 'B', 'arialplb.php');
$pdf->SetFont('arialpl','B',16);
$pdf->Cell(40,10, $this->textConvert("5. Sprzęt na wyposażeniu jednostki:"));
$pdf->Ln();
$pdf->SetFillColor(152,152,152);
$pdf->Cell(165,10, $this->textConvert("Nazwa sprzętu"), 1, 0, 'C', true);
$pdf->Cell(25,10, $this->textConvert("Ilość"), 1, 0, 'C', true);
$pdf->Ln();
$pdf->SetFont('arialpl','',14);
$fill = false;
$pdf->SetFillColor(224,224,224);
foreach( $equipment as $item){
$text = $item->name." ".$item->parameter;
$pdf->Cell(165,10,$this->textConvert($text), 1, 0, '', $fill);
$pdf->Cell(25,10,$this->textConvert($item->amount), 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(); $pdf->Output();
exit; exit;
} }

View File

@ -12,6 +12,12 @@
@section('center-area') @section('center-area')
@parent @parent
@include('inc.loginXX') @if( auth()->check())
@if( auth()->user()->fireStationID != NULL)
<form action="/pdf/sprzet" method="post">
{{ csrf_field() }}
<button class="btn btn-info" type="submit">Stan sprzętu</button>
</form>
@endif
@endif
@stop @stop

View File

@ -21,6 +21,8 @@ Route::get('/dokumentacja', function(){
return view('documents'); return view('documents');
}); });
Route::resource('pdfController', 'pdfController');
Route::get('/straznica', function(){ Route::get('/straznica', function(){
return view('depot'); return view('depot');
}); });
@ -107,4 +109,4 @@ Route::get('register/verify/{confirmationCode}', [
// //
//Route::get('/home', 'HomeController@index')->name('home'); //Route::get('/home', 'HomeController@index')->name('home');
Route::get('/pdf', 'pdfController@createView'); Route::post('/pdf/sprzet', 'pdfController@createViewEquipment');