Merge pull request #14461 from atm-john/NEW_fill_service_dates
NEW: new line template: hidden conf to fill service dates from the last service line
This commit is contained in:
commit
f0046672fc
@ -423,6 +423,27 @@ if ((!empty($conf->service->enabled) || ($object->element == 'contrat')) && $dat
|
|||||||
print '<td colspan="'.($coldisplay - (empty($conf->global->MAIN_VIEW_LINE_NUMBER) ? 0 : 1)).'">';
|
print '<td colspan="'.($coldisplay - (empty($conf->global->MAIN_VIEW_LINE_NUMBER) ? 0 : 1)).'">';
|
||||||
$date_start = dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), 0, GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear'));
|
$date_start = dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), 0, GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear'));
|
||||||
$date_end = dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), 0, GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear'));
|
$date_end = dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), 0, GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear'));
|
||||||
|
|
||||||
|
$prefillDates = false;
|
||||||
|
|
||||||
|
if(! empty($conf->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')
|
if (!empty($object->element) && $object->element == 'contrat')
|
||||||
{
|
{
|
||||||
print $langs->trans("DateStartPlanned").' ';
|
print $langs->trans("DateStartPlanned").' ';
|
||||||
@ -435,7 +456,33 @@ if ((!empty($conf->service->enabled) || ($object->element == 'contrat')) && $dat
|
|||||||
print ' '.$langs->trans('to').' ';
|
print ' '.$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);
|
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 ' <span class="small"><a href="#" id="prefill_service_dates">' . $langs->trans('FillWithLastServiceDates') . '</a></span>';
|
||||||
|
}
|
||||||
|
|
||||||
print '<script>';
|
print '<script>';
|
||||||
|
|
||||||
|
if($prefillDates)
|
||||||
|
{
|
||||||
|
?>
|
||||||
|
function prefill_service_dates()
|
||||||
|
{
|
||||||
|
$('#date_start').val("<?php echo dol_escape_js(dol_print_date($date_start_prefill, '%d/%m/%Y')); ?>").trigger('change');
|
||||||
|
$('#date_end').val("<?php echo dol_escape_js(dol_print_date($date_end_prefill, '%d/%m/%Y')); ?>").trigger('change');
|
||||||
|
|
||||||
|
return false; // Prevent default link behaviour (which is go to href URL)
|
||||||
|
}
|
||||||
|
|
||||||
|
$(document).ready(function()
|
||||||
|
{
|
||||||
|
$('#prefill_service_dates').click(prefill_service_dates);
|
||||||
|
});
|
||||||
|
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
|
||||||
if (!$date_start) {
|
if (!$date_start) {
|
||||||
if (isset($conf->global->MAIN_DEFAULT_DATE_START_HOUR)) {
|
if (isset($conf->global->MAIN_DEFAULT_DATE_START_HOUR)) {
|
||||||
print 'jQuery("#date_starthour").val("'.$conf->global->MAIN_DEFAULT_DATE_START_HOUR.'");';
|
print 'jQuery("#date_starthour").val("'.$conf->global->MAIN_DEFAULT_DATE_START_HOUR.'");';
|
||||||
|
|||||||
@ -104,6 +104,7 @@ SetDefaultBarcodeType=Set barcode type
|
|||||||
BarcodeValue=Barcode value
|
BarcodeValue=Barcode value
|
||||||
NoteNotVisibleOnBill=Note (not visible on invoices, proposals...)
|
NoteNotVisibleOnBill=Note (not visible on invoices, proposals...)
|
||||||
ServiceLimitedDuration=If product is a service with limited duration:
|
ServiceLimitedDuration=If product is a service with limited duration:
|
||||||
|
FillWithLastServiceDates=Fill with last service line dates
|
||||||
MultiPricesAbility=Multiple price segments per product/service (each customer is in one price segment)
|
MultiPricesAbility=Multiple price segments per product/service (each customer is in one price segment)
|
||||||
MultiPricesNumPrices=Number of prices
|
MultiPricesNumPrices=Number of prices
|
||||||
DefaultPriceType=Base of prices per default (with versus without tax) when adding new sale prices
|
DefaultPriceType=Base of prices per default (with versus without tax) when adding new sale prices
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user