diff --git a/app/Helpers/SVG.php b/app/Helpers/SVG.php index 53fec69be38f9d3a2f9b10137ff701dbd48b8d7c..65bb25982b42b19a7e6046ef3a9ec171222844de 100644 --- a/app/Helpers/SVG.php +++ b/app/Helpers/SVG.php @@ -7,7 +7,7 @@ class SVG private $score; private $maxScore; private $unit; - const UNITS = 414; + public const UNITS = 414; public function __construct($score, $maxScore) { @@ -31,7 +31,7 @@ private function oneHalf() return $this->maxScore / 2; } - private function calculateArray() : array + private function calculateArray(): array { $dashArray = [0, 0, 0, 0]; @@ -48,7 +48,7 @@ private function calculateArray() : array return $dashArray; } - private function calculateFirstQuarter() : array + private function calculateFirstQuarter(): array { return [ 0, @@ -58,7 +58,7 @@ private function calculateFirstQuarter() : array ]; } - private function calculateSecondQuarter() : array + private function calculateSecondQuarter(): array { return [ ($this->threeQuarters() * $this->unit) - $this->secondStroke(), @@ -68,7 +68,7 @@ private function calculateSecondQuarter() : array ]; } - private function calculateSecondHalf() : array + private function calculateSecondHalf(): array { return [ ($this->threeQuarters() * $this->unit) - $this->secondStroke(), @@ -83,7 +83,7 @@ private function secondStroke() return ($this->maxScore - $this->score) * $this->unit; } - public function dashArray() : string + public function dashArray(): string { $dashArray = $this->calculateArray(); diff --git a/app/Http/Controllers/PdfController.php b/app/Http/Controllers/PdfController.php index 4693fb6df1ff81eadf74fee84a1ca750d7c4b4c8..dc242f8886b13e1804c3ad628529a4923a1930f4 100644 --- a/app/Http/Controllers/PdfController.php +++ b/app/Http/Controllers/PdfController.php @@ -31,7 +31,7 @@ public function ActionPlanPdf() ->first(); $collectionAction = collect($evaluation->measureLevels)->filter(function (MeasureLevel $ml) { - return $ml->expected_level !== null; + return null !== $ml->expected_level; }); $actionSorted = $collectionAction->sortBy('end_date'); $actionSorted = $actionSorted->values()->all(); @@ -56,7 +56,7 @@ public function ActionPlanPdf() // // // dd($pdf->getDomPDF()); - //return $pdf->stream("Plan d'action - " . date('Y-m-d') . '.pdf'); + // return $pdf->stream("Plan d'action - " . date('Y-m-d') . '.pdf'); $pdf = App::make('snappy.pdf.wrapper'); $pdf->loadView('pdf.planAction', $data); $pdf->setOption('header-html', view('pdf.header', $data)); @@ -71,7 +71,7 @@ public function ActionPlanPdf() $pdf->setOption('margin-left', '0'); $pdf->setOption('xsl-style-sheet', view('pdf.toc', $data)); - $filename = "action_plan" . date('Y-m-d') . '.pdf'; + $filename = 'action_plan' . date('Y-m-d') . '.pdf'; if (file_exists(storage_path('app/action_plan/tmp.pdf'))) { unlink(storage_path('app/action_plan/tmp.pdf')); @@ -79,16 +79,15 @@ public function ActionPlanPdf() $pdf->save(storage_path('app/action_plan/tmp.pdf')); // Add measure documents to end of PDF file - $measureDocs = collect($actionSorted)->filter(function(MeasureLevel $ml) { - return $ml->measure->{'level'.$ml->expected_level.'_file'} !== null; - })->map(function(MeasureLevel $ml) { - $url = $ml->measure->{'level'.$ml->expected_level.'_file'}; + $measureDocs = collect($actionSorted)->filter(function (MeasureLevel $ml) { + return null !== $ml->measure->{'level' . $ml->expected_level . '_file'}; + })->map(function (MeasureLevel $ml) { + $url = $ml->measure->{'level' . $ml->expected_level . '_file'}; return str_replace('/storage/', storage_path('app/public/'), $url); })->join('" "'); - - exec('gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile="'.storage_path('app/action_plan/'.$filename).'" "'.storage_path('app/action_plan/tmp.pdf').'" "' . $measureDocs.'"'); + exec('gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile="' . storage_path('app/action_plan/' . $filename) . '" "' . storage_path('app/action_plan/tmp.pdf') . '" "' . $measureDocs . '"'); return Storage::download('action_plan/' . $filename, "Plan d'actions - " . date('Y-m-d') . '.pdf'); } diff --git a/config/snappy.php b/config/snappy.php index 46d12ec0ff1902bc2be07f0302104ec53b0a0cb4..28ce332257f08af36177a5b79651656c92e19398 100644 --- a/config/snappy.php +++ b/config/snappy.php @@ -1,7 +1,6 @@ <?php return [ - /* |-------------------------------------------------------------------------- | Snappy PDF / Image Configuration @@ -10,15 +9,15 @@ | This option contains settings for PDF generation. | | Enabled: - | + | | Whether to load PDF / Image generation. | | Binary: - | + | | The file path of the wkhtmltopdf / wkhtmltoimage executable. | | Timout: - | + | | The amount of time to wait (in seconds) before PDF / Image generation is stopped. | Setting this to false disables the timeout (unlimited processing time). | @@ -32,21 +31,20 @@ | The environment variables to set while running the wkhtmltopdf process. | */ - + 'pdf' => [ 'enabled' => true, - 'binary' => env('WKHTML_PDF_BINARY', '/usr/local/bin/wkhtmltopdf'), + 'binary' => env('WKHTML_PDF_BINARY', '/usr/local/bin/wkhtmltopdf'), 'timeout' => false, 'options' => [], - 'env' => [], + 'env' => [], ], - + 'image' => [ 'enabled' => true, - 'binary' => env('WKHTML_IMG_BINARY', '/usr/local/bin/wkhtmltoimage'), + 'binary' => env('WKHTML_IMG_BINARY', '/usr/local/bin/wkhtmltoimage'), 'timeout' => false, 'options' => [], - 'env' => [], + 'env' => [], ], - ];