From 93b28f2799e32842fd68278cb6e45de64fe9555c Mon Sep 17 00:00:00 2001 From: Dasc3er Date: Thu, 2 Sep 2021 16:27:38 +0200 Subject: [PATCH] Miglioramento gestione foto articoli in Stampa Preventivo --- modules/contratti/bulk.php | 2 +- templates/preventivi/body.php | 46 ++++++++++++++++++++--------------- 2 files changed, 28 insertions(+), 20 deletions(-) diff --git a/modules/contratti/bulk.php b/modules/contratti/bulk.php index cd3c5c290..2e2c5884a 100755 --- a/modules/contratti/bulk.php +++ b/modules/contratti/bulk.php @@ -104,7 +104,7 @@ switch (post('op')) { if ($copia->isArticolo()) { $copia->serials = $riga->serials; } - + $copia->save(); } } diff --git a/templates/preventivi/body.php b/templates/preventivi/body.php index 95a809470..db7f1f0f2 100755 --- a/templates/preventivi/body.php +++ b/templates/preventivi/body.php @@ -22,17 +22,6 @@ use Modules\Anagrafiche\Anagrafica; include_once __DIR__.'/../../core.php'; -$has_images = null; - -// Righe documento -$righe = $documento->getRighe(); - -foreach ($righe as $riga) { - if ($riga->articolo->immagine) { - $has_images = 1; - } -} - $anagrafica = Anagrafica::find($documento['idanagrafica']); $pagamento = $dbo->fetchOne('SELECT * FROM co_pagamenti WHERE id = '.prepare($documento['idpagamento'])); @@ -44,8 +33,22 @@ if (!empty($anagrafica->idbanca_vendite)) { $banca = $dbo->fetchOne('SELECT co_banche.nome, co_banche.iban, co_banche.bic FROM co_banche INNER JOIN co_pianodeiconti3 ON co_banche.id_pianodeiconti3 = co_pianodeiconti3.id WHERE co_pianodeiconti3.id = '.prepare($pagamento['idconto_vendite']).' AND co_banche.deleted_at IS NULL'); } +// Righe documento +$righe = $documento->getRighe(); + +$has_image = $righe->search(function ($item) { + return !empty($item->articolo->immagine); +}) !== false; + +$columns = 6; +if ($has_image) { + ++$columns; +} + +$columns = $options['pricing'] ? $columns : 3; + // Creazione righe fantasma -$autofill = new \Util\Autofill($options['pricing'] ? (($has_images) ? 7 : 6) : 3); +$autofill = new \Util\Autofill($columns); $autofill->setRows(20, 10); echo ' @@ -138,7 +141,7 @@ echo " #"; -if ($has_images) { +if ($has_image) { echo " Foto"; } @@ -173,13 +176,18 @@ foreach ($righe as $riga) { '.$num.' '; - if ($has_images) { - echo ''; - if (!empty($riga->articolo->immagine)) { - echo ''; - } + if ($has_image) { + if ($riga->isArticolo() && !empty($riga->articolo->image)) { + echo ' + + + '; - echo ''; + $autofill->set(5); + } else { + echo ' + '; + } } echo '