From c887cb687fb8f612d1bfbbd596eaf9dc9d3c4167 Mon Sep 17 00:00:00 2001 From: MatteoPistorello Date: Thu, 8 Apr 2021 12:18:38 +0200 Subject: [PATCH] Aggiunta ora evasione negli ordini e in stampa --- include/common/riga.php | 73 +++++++++++++++++++++++------------ modules/ordini/actions.php | 27 ++++++++++++- modules/ordini/row-list.php | 8 +++- templates/ordini/body.php | 30 ++++++++------ templates/ordini/settings.php | 24 ++++++++++++ update/2_4_23.sql | 5 ++- 6 files changed, 127 insertions(+), 40 deletions(-) create mode 100644 templates/ordini/settings.php diff --git a/include/common/riga.php b/include/common/riga.php index 6bdc5d62a..911f44105 100755 --- a/include/common/riga.php +++ b/include/common/riga.php @@ -121,31 +121,54 @@ if (in_array($module['name'], ['Ordini cliente', 'Ordini fornitore'])) { $confermato = $result['confermato']; } echo ' -
-
-

'.tr('Informazioni aggiuntive').'

-
- +
+
+

'.tr('Informazioni aggiuntive').'

+
+ +
+
+ +
+
+
+ {[ "type": "date", "label": "'.tr('Data prevista evasione').'", "name": "data_evasione", "value": "'.$result['data_evasione'].'" ]} +
+
+ {[ "type": "time", "label": "'.tr('Ora prevista evasione').'", "name": "ora_evasione", "value": "'.$result['ora_evasione'].'", "disabled": 1 ]} +
+
+ {[ "type": "checkbox", "label": "'.tr('Cambia data a tutte le righe').'", "name": "data_evasione_all", "value": "" ]} +
+
+
+
+ +
+
+ {[ "type": "checkbox", "label": "'.tr('Articolo confermato').'", "name": "confermato", "value": "'.$confermato.'" ]} +
+
+ {[ "type": "checkbox", "label": "'.tr('Cambia stato a tutte le righe').'", "name": "confermato_all", "value": "" ]} +
+
-
-
-
- {[ "type": "date", "label": "'.tr('Data prevista evasione').'", "name": "data_evasione", "value": "'.$result['data_evasione'].'" ]} -
-
- {[ "type": "checkbox", "label": "'.tr('Cambia data a tutte le righe').'", "name": "data_evasione_all", "value": "" ]} -
-
-
-
- {[ "type": "checkbox", "label": "'.tr('Articolo confermato').'", "name": "confermato", "value": "'.$confermato.'" ]} -
-
- {[ "type": "checkbox", "label": "'.tr('Cambia stato a tutte le righe').'", "name": "confermato_all", "value": "" ]} -
-
-
-
'; -} + '; +} \ No newline at end of file diff --git a/modules/ordini/actions.php b/modules/ordini/actions.php index 6c5563cd8..20ebd6c79 100755 --- a/modules/ordini/actions.php +++ b/modules/ordini/actions.php @@ -180,6 +180,7 @@ switch (post('op')) { $articolo->costo_unitario = post('costo_unitario') ?: 0; $articolo->data_evasione = post('data_evasione') ?: null; + $articolo->ora_evasione = post('ora_evasione') ?: null; $articolo->confermato = post('confermato') ?: 0; $articolo->setPrezzoUnitario(post('prezzo_unitario'), post('idiva')); $articolo->setSconto(post('sconto'), post('tipo_sconto')); @@ -194,16 +195,17 @@ switch (post('op')) { // Impostare data evasione su tutte le righe if (post('data_evasione_all') == 1) { - $righe = $ordine->getRighe(); + $righe = $ordine->getRighe()->where('is_descrizione', '=', '0');; foreach ($righe as $riga) { $riga->data_evasione = post('data_evasione') ?: null; + $riga->ora_evasione = post('ora_evasione') ?: null; $riga->save(); } } // Impostare confermato su tutte le righe if (post('confermato_all') == 1) { - $righe = $ordine->getRighe(); + $righe = $ordine->getRighe()->where('is_descrizione', '=', '0');; foreach ($righe as $riga) { $riga->confermato = post('confermato') ?: 0; @@ -257,6 +259,7 @@ switch (post('op')) { $riga->costo_unitario = post('costo_unitario') ?: 0; $riga->data_evasione = post('data_evasione') ?: null; + $riga->ora_evasione = post('ora_evasione') ?: null; $riga->confermato = post('confermato') ?: 0; $riga->setPrezzoUnitario(post('prezzo_unitario'), post('idiva')); $riga->setSconto(post('sconto'), post('tipo_sconto')); @@ -265,6 +268,26 @@ switch (post('op')) { $riga->save(); + // Impostare data evasione su tutte le righe + if (post('data_evasione_all') == 1) { + $righe = $ordine->getRighe()->where('is_descrizione', '=', '0'); + + foreach ($righe as $riga) { + $riga->data_evasione = post('data_evasione') ?: null; + $riga->ora_evasione = post('ora_evasione') ?: null; + $riga->save(); + } + } + // Impostare confermato su tutte le righe + if (post('confermato_all') == 1) { + $righe = $ordine->getRighe()->where('is_descrizione', '=', '0'); + + foreach ($righe as $riga) { + $riga->confermato = post('confermato') ?: 0; + $riga->save(); + } + } + if (post('idriga') != null) { flash()->info(tr('Riga modificata!')); } else { diff --git a/modules/ordini/row-list.php b/modules/ordini/row-list.php index 2f0fd4aef..fb7e90a09 100755 --- a/modules/ordini/row-list.php +++ b/modules/ordini/row-list.php @@ -129,7 +129,13 @@ foreach ($righe as $riga) { ); } - $info_evasione = ' '.Translator::dateToLocale($riga->data_evasione).''; + if (!empty($riga->ora_evasione)) { + $ora_evasione = '
'.Translator::timeToLocale($riga->ora_evasione).''; + } else{ + $ora_evasione = ''; + } + + $info_evasione = ' '.Translator::dateToLocale($riga->data_evasione).$ora_evasione.''; } echo ' diff --git a/templates/ordini/body.php b/templates/ordini/body.php index a5b2eb491..a4834f988 100755 --- a/templates/ordini/body.php +++ b/templates/ordini/body.php @@ -22,7 +22,7 @@ include_once __DIR__.'/../../core.php'; // Righe documento $righe = $documento->getRighe(); -$columns = 6; +$columns = 7; //Immagine solo per documenti di vendita if ($documento->direzione == 'entrata') { @@ -76,11 +76,12 @@ if ($options['pricing']) { ".tr('IVA', [], ['upper' => true]).' (%)'; } - echo ' + echo " + ".tr('Data evasione', [], ['upper' => true])." - '; + "; $num = 0; foreach ($righe as $riga) { @@ -121,14 +122,16 @@ foreach ($righe as $riga) { '.nl2br($r['descrizione']); if ($riga->isArticolo()) { - // Codice articolo - $text = tr('COD. _COD_', [ - '_COD_' => $riga->codice, - ]); - echo ' -
'.$text.''; + if($documento->direzione == 'entrata'){ + // Codice articolo + $text = tr('COD. _COD_', [ + '_COD_' => $riga->codice, + ]); + echo ' +
'.$text.''; - $autofill->count($text, true); + $autofill->count($text, true); + } // Seriali $seriali = $riga->serials; @@ -188,6 +191,11 @@ foreach ($righe as $riga) { '.Translator::numberToLocale($riga->aliquota->percentuale, 0).' '; } + + echo ' + + '.Translator::dateToLocale($riga->data_evasione).($riga->ora_evasione ? '
'.Translator::timeToLocale($riga->ora_evasione).'' : '').'
+ '; } else { echo ' '; @@ -221,7 +229,7 @@ $netto_a_pagare = $documento->netto; $show_sconto = $sconto > 0; -$colspan = 4; +$colspan = 5; ($documento->direzione == 'uscita' ? $colspan++ : $colspan); ($has_image ? $colspan++ : $colspan); diff --git a/templates/ordini/settings.php b/templates/ordini/settings.php new file mode 100644 index 000000000..5af9d7a6a --- /dev/null +++ b/templates/ordini/settings.php @@ -0,0 +1,24 @@ +. + */ + +$settings = [ + 'font-size' => 9, +]; + +return $settings; diff --git a/update/2_4_23.sql b/update/2_4_23.sql index 506dd20f5..e50a20142 100644 --- a/update/2_4_23.sql +++ b/update/2_4_23.sql @@ -145,4 +145,7 @@ SELECT `zz_groups`.`id`, `zz_views`.`id` FROM `zz_groups`, `zz_views` INNER JOIN INSERT INTO `zz_group_view` (`id_gruppo`, `id_vista`) ( SELECT `zz_groups`.`id`, `zz_views`.`id` FROM `zz_groups`, `zz_views` INNER JOIN `zz_modules` ON `zz_views`.`id_module` = `zz_modules`.`id` WHERE `zz_modules`.`name`='Ordini cliente' AND (`zz_views`.`name` = 'icon_title_Prev. evasione' OR `zz_views`.`name` = 'icon_Prev. evasione') -); \ No newline at end of file +); + +-- Aggiunto campo ora evasione in ordini +ALTER TABLE `or_righe_ordini` ADD `ora_evasione` TIME NULL AFTER `data_evasione`; \ No newline at end of file