|
|
@@ -36,6 +36,13 @@ class GenerateDocumentsService
|
|
|
public function generateInstallationPack(Order $order, int $userId): string
|
|
|
{
|
|
|
$techDocsPath = base_path('/tech-docs/');
|
|
|
+ $order = Order::query()
|
|
|
+ ->withoutGlobalScopes()
|
|
|
+ ->whereKey($order->id)
|
|
|
+ ->where('year', $order->year)
|
|
|
+ ->with('documents')
|
|
|
+ ->firstOrFail();
|
|
|
+
|
|
|
$products_sku = $order->products_sku()
|
|
|
->withoutGlobalScopes()
|
|
|
->where('year', $order->year)
|
|
|
@@ -57,6 +64,14 @@ class GenerateDocumentsService
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ $orderDocumentsDir = 'orders/' . $order->id . '/tmp/Документы площадки';
|
|
|
+ foreach ($order->documents as $document) {
|
|
|
+ if ($this->shouldSkipArchiveDocument($document)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ $this->copyFileToDir($document->path, $orderDocumentsDir, $document->original_name);
|
|
|
+ }
|
|
|
+
|
|
|
// generate xlsx order file
|
|
|
$this->generateOrderForMount($order);
|
|
|
|
|
|
@@ -100,6 +115,11 @@ class GenerateDocumentsService
|
|
|
$str = Str::replace('<div>', '', $order->products_with_count);
|
|
|
$str = Str::replace('</div>', "\n", $str);
|
|
|
|
|
|
+ // дата монтажа
|
|
|
+ $installationDate = ($order->installation_date) ? DateHelper::getHumanDate($order->installation_date, true) : '';
|
|
|
+ $sheet->setCellValue('L15', $installationDate);
|
|
|
+
|
|
|
+
|
|
|
// мафы
|
|
|
$sheet->setCellValue('G33', Str::trim($str));
|
|
|
|
|
|
@@ -607,16 +627,39 @@ class GenerateDocumentsService
|
|
|
}
|
|
|
|
|
|
private function shouldSkipDocumentForPaymentPack($file): bool
|
|
|
+ {
|
|
|
+ return $this->shouldSkipArchiveDocument($file);
|
|
|
+ }
|
|
|
+
|
|
|
+ private function shouldSkipArchiveDocument($file): bool
|
|
|
{
|
|
|
if (!$file) {
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
- if ($file->mime_type === 'application/zip') {
|
|
|
+ $fileName = Str::lower((string)$file->original_name);
|
|
|
+ $mimeType = Str::lower((string)$file->mime_type);
|
|
|
+
|
|
|
+ $archiveSuffixes = [
|
|
|
+ '.zip',
|
|
|
+ '.rar',
|
|
|
+ '.7z',
|
|
|
+ '.tar',
|
|
|
+ '.tar.gz',
|
|
|
+ '.tgz',
|
|
|
+ '.tar.bz2',
|
|
|
+ '.tbz2',
|
|
|
+ '.bz2',
|
|
|
+ '.tar.xz',
|
|
|
+ '.txz',
|
|
|
+ '.xz',
|
|
|
+ ];
|
|
|
+
|
|
|
+ if (Str::endsWith($fileName, $archiveSuffixes)) {
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
- if (Str::endsWith((string)$file->original_name, '.zip')) {
|
|
|
+ if (str_contains($mimeType, 'zip') || str_contains($mimeType, 'compressed') || str_contains($mimeType, '7z') || str_contains($mimeType, 'rar')) {
|
|
|
return true;
|
|
|
}
|
|
|
|