From d428f79d46157ca3e474e860f4e262902339d109 Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio Date: Wed, 15 May 2019 12:26:39 +0200 Subject: [PATCH 1/2] NEW: new line template: hidden conf to fill service dates from the last service line --- htdocs/core/tpl/objectline_create.tpl.php | 47 +++++++++++++++++++++++ htdocs/langs/en_US/products.lang | 1 + 2 files changed, 48 insertions(+) diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index 4a4febe65d3..b76a2f55219 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -464,6 +464,27 @@ if ((! empty($conf->service->enabled) || ($object->element == 'contrat')) && $da global->MAIN_FILL_SERVICE_DATES_FROM_LAST_SERVICE_LINE) && ! empty($object->lines)) + { + for($i = count($object->lines) - 1; $i >= 0; $i--) + { + $lastline = $object->lines[$i]; + + if($lastline->product_type == Product::TYPE_SERVICE && (! empty($lastline->date_start) || ! empty($lastline->date_end))) + { + $date_start_prefill = $lastline->date_start; + $date_end_prefill = $lastline->date_end; + + $prefillDates = true; + break; + } + } + } + + if (! empty($object->element) && $object->element == 'contrat') { print $langs->trans("DateStartPlanned").' '; @@ -478,7 +499,33 @@ if ((! empty($conf->service->enabled) || ($object->element == 'contrat')) && $da echo ' '.$langs->trans('to').' '; print $form->selectDate($date_end, 'date_end', empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE)?0:1, empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE)?0:1, 1, "addproduct", 1, 0); }; + + if($prefillDates) + { + echo ' ' . $langs->trans('FillWithLastServiceDates') . ''; + } + print '