From: Vincent Vanwaelscappel Date: Wed, 7 May 2025 16:30:01 +0000 (+0200) Subject: wait #7513 @1.5 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=162ca6ca2dd73b99b3365f6aab226dbd34c40136;p=fluidbook-toolbox.git wait #7513 @1.5 --- diff --git a/app/Http/Controllers/Admin/Operations/FluidbookPublication/Services/PumaOperation.php b/app/Http/Controllers/Admin/Operations/FluidbookPublication/Services/PumaOperation.php index 0874df498..dda9e9015 100644 --- a/app/Http/Controllers/Admin/Operations/FluidbookPublication/Services/PumaOperation.php +++ b/app/Http/Controllers/Admin/Operations/FluidbookPublication/Services/PumaOperation.php @@ -32,6 +32,9 @@ trait PumaOperation $cl->execute(); return response()->download($tmp, $filename . '.pdf')->deleteFileAfterSend(true); } + + $bottomStrings = ['shorts', 'pants']; + $references = explode(',', $references); /** @var FluidbookPublication $book */ $book = FluidbookPublication::withoutGlobalScopes()->where('id', $id)->where('cid', $cid)->firstOrFail(); @@ -42,14 +45,23 @@ trait PumaOperation if (!in_array($reference, $references)) { continue; } + $r[$reference] = $data; $title = trim(trim($data['Catégorie'] ?? '') . ' ' . trim($data['RBU'] ?? '')); $subtitle = trim(trim($data['Age Group'] ?? '') . ' - ' . $data['Gender'] . ' - ' . trim($data['Product Line'] ?? ''), '- '); $key = md5($title . $subtitle); if (!isset($planches[$key])) { - $planches[$key] = ['class' => $data['Catégorie'], 'title' => $title, 'subtitle' => $subtitle, 'products' => []]; + $planches[$key] = ['class' => $data['Catégorie'], 'title' => $title, 'subtitle' => $subtitle, 'groups' => ['top' => [], 'bottom' => []]]; } - $planches[$key]['products'][$reference] = $data; + $group = 'top'; + foreach ($bottomStrings as $str) { + if (stristr($data['Article Type'], $str)) { + $group = 'bottom'; + break; + } + } + + $planches[$key]['groups'][$group][$reference] = $data; } $html = ''; @@ -61,37 +73,52 @@ trait PumaOperation $html .= ''; $html .= ''; foreach ($planches as $data) { - $max = $data['class'] === 'Footwear' ? 20 : 18; + $cols = $data['class'] === 'Footwear' ? 5 : 6; + $rows = $data['class'] === 'Footwear' ? 4 : 3; - $subs = array_chunk($data['products'], $max, true); + $lines = []; + foreach ($data['groups'] as $group => $products) { + if (!count($products)) { + continue; + } + $lines= array_merge($lines, array_chunk($products, $cols, true));;; + } + + $subs = array_chunk($lines, $rows, true); $csubs = count($subs); - foreach ($subs as $i => $sub) { + foreach ($subs as $i => $lines) { $pos = $csubs == 1 ? '' : ' (' . ($i + 1) . '/' . $csubs . ')'; $html .= '
'; $html .= '

' . $data['title'] . '

'; $html .= '

' . $data['subtitle'] . $pos . '

'; $html .= '
'; - foreach ($sub as $reference => $product) { - if (isset($product['zoom_image'])) { - $f = protected_path('fluidbookpublication/cache/zoomarea/zoomarea/books/' . $id . '/' . $product['zoom_image']); - $img = Files::asDataURI($f); - $img_attr = ''; - } else { - $img = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+P+/HgAFhAJ/wlseKgAAAABJRU5ErkJggg=='; - $img_attr = ' width="40" height="40"'; - } + foreach ($lines as $line) { + foreach ($line as $reference => $product) { + if (isset($product['zoom_image'])) { + $f = protected_path('fluidbookpublication/cache/zoomarea/zoomarea/books/' . $id . '/' . $product['zoom_image']); + $img = Files::asDataURI($f); + $img_attr = ''; + } else { + $img = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+P+/HgAFhAJ/wlseKgAAAABJRU5ErkJggg=='; + $img_attr = ' width="40" height="40"'; + } - $html .= '
'; - $html .= ''; - $html .= '
'; - $html .= '

' . $reference . '

'; - $html .= '
' . $product['Désignation'] ?? '' . '
'; - $html .= '
' . $product['Color Name'] ?? '' . '
'; - $html .= '
PA : ' . number_format(floatval($product['Tarif'] ?? 0), 2, ',', ' ') . ' € / PVP : ' . number_format(floatval($product['PVC'] ?? 0), 2, ',', ' ') . ' €
'; - $html .= '
'; - $html .= '
'; + $html .= '
'; + $html .= ''; + $html .= '
'; + $html .= '

' . $reference . '

'; + $html .= '
' . $product['Désignation'] ?? '' . '
'; + $html .= '
' . $product['Color Name'] ?? '' . '
'; + $html .= '
PA : ' . number_format(floatval($product['Tarif'] ?? 0), 2, ',', ' ') . ' € / PVP : ' . number_format(floatval($product['PVC'] ?? 0), 2, ',', ' ') . ' €
'; + $html .= '
'; + $html .= '
'; + } + for ($i = count($line); $i < $cols; $i++) { + $html .= '
'; + } } + $html .= '
'; $html .= '
'; }