dowload wip
This commit is contained in:
1 parent
b004542988
commit
8971b8b948
41 files changed
+2103
-243
No files matched your search
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions\Download;
|
||||
|
||||
use App\Actions\Generate\GenerateExcel;
|
||||
use App\Models\Projekt;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use Illuminate\Support\Facades\Response;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class DownloadExcel
|
||||
{
|
||||
public function download($projekts_id, $mode)
|
||||
{
|
||||
if ($mode == 'new') {
|
||||
Projekt::where('id', $projekts_id)->update(['excel_nutzwerte' => '', 'excel_nutzwerte_ok' => '0']);
|
||||
}
|
||||
|
||||
$projekt = Projekt::where('id', $projekts_id)->first()->toArray();
|
||||
$filepath = Storage::disk('public')->path("/download/$projekts_id/excel/");
|
||||
|
||||
if ($projekt['excel_nutzwerte_ok'] == 0) {
|
||||
|
||||
$filename = preg_replace("'[^0-9a-zA-Z]'", '', $projekt['intname']).'.xlsx';
|
||||
|
||||
if (! File::isDirectory($filepath)) {
|
||||
File::makeDirectory($filepath, 0777, true, true);
|
||||
}
|
||||
$file = $filepath.$filename;
|
||||
|
||||
GenerateExcel::generate($file, $projekts_id);
|
||||
|
||||
Projekt::where('id', $projekts_id)->update(['excel_nutzwerte' => $filename, 'excel_nutzwerte_ok' => '1']);
|
||||
|
||||
} else {
|
||||
|
||||
$filename = $projekt['excel_nutzwerte'];
|
||||
$file = $filepath.$filename;
|
||||
}
|
||||
|
||||
$headers = [
|
||||
'Content-Type: application/vnd.ms-excel',
|
||||
'Content-Disposition: attachment;filename="'.$filename.'"',
|
||||
'Cache-Control: max-age=0',
|
||||
'Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT',
|
||||
'Cache-Control: cache, must-revalidate',
|
||||
'Pragma: public',
|
||||
];
|
||||
|
||||
return Response::download($file, $projekt['name'], $headers);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions\Download;
|
||||
|
||||
use App\Actions\Generate\GenerateNutzwerte;
|
||||
use App\Models\Projekt;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use Illuminate\Support\Facades\Response;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class DownloadNutzwerte
|
||||
{
|
||||
public function download($projekts_id, $mode)
|
||||
{
|
||||
|
||||
if ($mode == 'new') {
|
||||
Projekt::where('id', $projekts_id)->update(['pdf_nutzwerte' => '', 'pdf_nutzwerte_ok' => '0']);
|
||||
}
|
||||
|
||||
$headers = [
|
||||
'Content-Type: application/pdf',
|
||||
'Cache-Control: max-age=0',
|
||||
'Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT',
|
||||
'Cache-Control: cache, must-revalidate',
|
||||
];
|
||||
|
||||
$projekt = Projekt::where('id', $projekts_id)->first()->toArray();
|
||||
|
||||
$filepath = Storage::disk('public')->path("/download/$projekts_id/nutzwerte/");
|
||||
|
||||
if ($projekt['pdf_nutzwerte_ok'] == 0) {
|
||||
|
||||
$filename = preg_replace("'[^0-9a-zA-Z]'", '', $projekt['intname']).'.pdf';
|
||||
|
||||
if (! File::isDirectory($filepath)) {
|
||||
File::makeDirectory($filepath, 0777, true, true);
|
||||
}
|
||||
$file = $filepath.$filename;
|
||||
|
||||
GenerateNutzwerte::generate($file, $projekts_id);
|
||||
|
||||
Projekt::where('id', $projekts_id)->update(['pdf_nutzwerte' => $filename, 'pdf_nutzwerte_ok' => '1']);
|
||||
|
||||
return Response::download($file, $projekt['name'], $headers);
|
||||
|
||||
} else {
|
||||
|
||||
$filename = $projekt['pdf_nutzwerte'];
|
||||
|
||||
$file = $filepath.$filename;
|
||||
|
||||
return Response::download($file, $projekt['name'], $headers);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions\Download;
|
||||
|
||||
use App\Actions\Generate\GenerateStandardTexte;
|
||||
use App\Models\Projekt;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use Illuminate\Support\Facades\Response;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class DownloadStandardTexte
|
||||
{
|
||||
public function download($projekts_id, $mode)
|
||||
{
|
||||
|
||||
if ($mode == 'new') {
|
||||
Projekt::where('id', $projekts_id)->update(['pdf_standardtexte' => '', 'pdf_standardtexte_ok' => '0']);
|
||||
}
|
||||
|
||||
$headers = [
|
||||
'Content-Type: application/pdf',
|
||||
'Cache-Control: max-age=0',
|
||||
'Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT',
|
||||
'Cache-Control: cache, must-revalidate',
|
||||
];
|
||||
|
||||
$projekt = Projekt::where('id', $projekts_id)->first()->toArray();
|
||||
|
||||
$filepath = Storage::disk('public')->path("/download/$projekts_id/standards/");
|
||||
|
||||
if ($projekt['pdf_standardtexte_ok'] == 0) {
|
||||
|
||||
$filename = preg_replace("'[^0-9a-zA-Z]'", '', $projekt['intname']).'.pdf';
|
||||
|
||||
if (! File::isDirectory($filepath)) {
|
||||
File::makeDirectory($filepath, 0777, true, true);
|
||||
}
|
||||
$file = $filepath.$filename;
|
||||
|
||||
GenerateStandardTexte::generate($file, $projekts_id);
|
||||
|
||||
Projekt::where('id', $projekts_id)->update(['pdf_standardtexte' => $filename, 'pdf_standardtexte_ok' => 1]);
|
||||
|
||||
return Response::download($file, $projekt['name'], $headers);
|
||||
} else {
|
||||
|
||||
$filename = $projekt['pdf_standardtexte'];
|
||||
|
||||
$file = $filepath.$filename;
|
||||
|
||||
return Response::download($file, $projekt['name'], $headers);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user