Updates to 03-2025

This commit is contained in:
Kevin Adametz 2025-04-01 10:39:21 +02:00
parent 6167273a48
commit 9b54eb0512
348 changed files with 34535 additions and 5774 deletions

View file

@ -47,61 +47,89 @@ class FileController extends Controller
$this->isPermission($shopping_order->auth_user_id);
$filename = Invoice::getFilename($shopping_order);
$path = Invoice::getDownloadPath($shopping_order);
if (!Storage::disk('public')->exists($path)) {
return Response::make('File no found.', 404);
}
$file = Storage::disk('public')->get($path);
$type = Storage::disk('public')->mimeType($path);
if($do === 'download'){
return Response::make($file, 200)
->header("Content-Type", $type)
->header('Content-disposition', 'attachment; filename="'.$filename.'"');
/* $full_path = Invoice::getDownloadPath($shopping_order, true);
$he
if (file_exists($full_path)) {
return Response::download($full_path, $filename);
}*/
}
if($do === 'stream'){
return Response::make($file, 200)
->header("Content-Type", $type)
->header('Content-disposition','filename="'.$filename.'"');
}
}
if ($disk === 'delivery'){
$shopping_order = \App\Models\ShoppingOrder::findOrFail($id);
$this->isPermission($shopping_order->auth_user_id);
$filename = Invoice::getDeliveryFilename($shopping_order);
$path = Invoice::getDownloadPathDelivery($shopping_order);
}
if ($disk === 'invoice_delivery'){
$shopping_order = \App\Models\ShoppingOrder::findOrFail($id);
$this->isPermission($shopping_order->auth_user_id);
$ifilename = Invoice::getFilename($shopping_order);
$ipath = Invoice::getDownloadPath($shopping_order, true);
$dfilename = Invoice::getDeliveryFilename($shopping_order);
$dpath = Invoice::getDownloadPathDelivery($shopping_order, true);
$oMerger = new \App\Services\PDFMerger();
$oMerger->init();
$oMerger->addPDF($ipath);
$oMerger->addPDF($dpath);
$filename = str_replace('Rechnung-', 'Rechnung-Lieferschein-', $ifilename);
$oMerger->setFileName($filename);
$oMerger->merge();
$file = $oMerger->output();
return Response::make($file, 200)
->header("Content-Type", 'application/pdf')
->header('Content-disposition', 'attachment; filename="'.$filename.'"');
}
if ($disk === 'credit'){
$UserCredit = \App\Models\UserCredit::findOrFail($id);
$this->isPermission($UserCredit->auth_user_id);
$filename = Credit::getFilename($UserCredit);
$path = Credit::getDownloadPath($UserCredit);
if (!Storage::disk('public')->exists($path)) {
return Response::make('File no found.', 404);
}
$file = Storage::disk('public')->get($path);
$type = Storage::disk('public')->mimeType($path);
if($do === 'download'){
return Response::make($file, 200)
->header("Content-Type", $type)
->header('Content-disposition', 'attachment; filename="'.$filename.'"');
/* $full_path = Invoice::getDownloadPath($shopping_order, true);
$he
if (file_exists($full_path)) {
return Response::download($full_path, $filename);
}*/
}
if($do === 'stream'){
return Response::make($file, 200)
->header("Content-Type", $type)
->header('Content-disposition','filename="'.$filename.'"');
}
}
if (!Storage::disk('public')->exists($path)) {
return Response::make('File no found.', 404);
}
$file = Storage::disk('public')->get($path);
$mime = Storage::disk('public')->mimeType($path);
if($do === 'download'){
return Response::make($file, 200)
->header("Content-Type", $mime)
->header('Content-disposition', 'attachment; filename="'.$filename.'"');
/* $full_path = Invoice::getDownloadPath($shopping_order, true);
$he
if (file_exists($full_path)) {
return Response::download($full_path, $filename);
}*/
}
if($do === 'stream'){
return Response::make($file, 200)
->header("Content-Type", $mime)
->header('Content-disposition','filename="'.$filename.'"');
}
if($do === 'file'){
return Response::make($file, 200)
->header("Content-Type", $mime)
->header('Content-disposition', 'filename="'.$filename.'"');
}
if($do === 'image'){
return Response::make($file, 200)
->header("Content-Type", $mime);
}
if($do === 'pdf'){
$path = storage_path().'/app/public/' . $path;
$headers = array(
'Content-Type:'. $mime,
// 'Content-Length: ' . $file->size
// 'Content-Disposition: ' . $stream . '; filename=' . $file->original_name
);
return Response::download($path, $filename, $headers);
}
}
}