Qual: Better management of select type of lines

This commit is contained in:
Ferran Marcet 2018-12-13 10:36:30 +01:00
parent 911f343c97
commit 555698a3af
3 changed files with 7 additions and 13 deletions

View File

@ -2063,10 +2063,6 @@ else
print '<div class="div-table-responsive-no-min">';
print '<table id="tablelines" class="noborder noshadow" width="100%">'; // Array with (n*2)+1 lines
// Trick to not show product entries
$savproductenabled=$conf->product->enabled;
if (empty($conf->global->CONTRACT_SUPPORT_PRODUCTS)) $conf->product->enabled = 0;
// Form to add new line
if ($action != 'editline')
{
@ -2079,9 +2075,6 @@ else
$reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
}
// Restore correct setup
$conf->product->enabled = $savproductenabled;
print '</table>';
print '</div>';
print '</form>';

View File

@ -878,7 +878,7 @@ class Form
* @param string $htmlname Name of field in html form
* @param int $showempty Add an empty field
* @param int $hidetext Do not show label 'Type' before combo box (used only if there is at least 2 choices to select)
* @param integer $forceall 1=Force to show products and services in combo list, whatever are activated modules, 0=No force, -1=Force none (and set hidden field to 'service')
* @param integer $forceall 1=Force to show products and services in combo list, whatever are activated modules, 0=No force, 2=Force to show only Products, 3=Force to show only services, -1=Force none (and set hidden field to 'service')
* @return void
*/
function select_type_of_lines($selected='',$htmlname='type',$showempty=0,$hidetext=0,$forceall=0)
@ -887,7 +887,7 @@ class Form
global $db,$langs,$user,$conf;
// If product & services are enabled or both disabled.
if ($forceall > 0 || (empty($forceall) && ! empty($conf->product->enabled) && ! empty($conf->service->enabled))
if ($forceall == 1 || (empty($forceall) && ! empty($conf->product->enabled) && ! empty($conf->service->enabled))
|| (empty($forceall) && empty($conf->product->enabled) && empty($conf->service->enabled)) )
{
if (empty($hidetext)) print $langs->trans("Type").': ';
@ -910,12 +910,12 @@ class Form
print '</select>';
//if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1);
}
if (empty($forceall) && empty($conf->product->enabled) && ! empty($conf->service->enabled))
if ((empty($forceall) && empty($conf->product->enabled) && ! empty($conf->service->enabled)) || $forceall == 3)
{
print $langs->trans("Service");
print '<input type="hidden" name="'.$htmlname.'" value="1">';
}
if (empty($forceall) && ! empty($conf->product->enabled) && empty($conf->service->enabled))
if ((empty($forceall) && ! empty($conf->product->enabled) && empty($conf->service->enabled)) || $forceall == 2)
{
print $langs->trans("Product");
print '<input type="hidden" name="'.$htmlname.'" value="0">';

View File

@ -7,6 +7,7 @@
* Copyright (C) 2014 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
* Copyright (C) 2015-2016 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2018 Ferran Marcet <fmarcet@2byte.es>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -184,7 +185,7 @@ else {
if ($object->element == 'contrat')
{
if (empty($conf->product->enabled) && empty($conf->service->enabled) && empty($conf->global->CONTRACT_SUPPORT_PRODUCTS)) $forceall=-1; // With contract, by default, no choice at all, except if CONTRACT_SUPPORT_PRODUCTS is set
else $forceall=0;
else if (empty($conf->global->CONTRACT_SUPPORT_PRODUCTS)) $forceall=3;
}
// Free line
@ -229,7 +230,7 @@ else {
if (empty($senderissupplier))
{
if (! empty($conf->product->enabled) && empty($conf->service->enabled)) echo $langs->trans('PredefinedProductsToSell');
else if (empty($conf->product->enabled) && ! empty($conf->service->enabled)) echo $langs->trans('PredefinedServicesToSell');
else if ((empty($conf->product->enabled) && ! empty($conf->service->enabled)) || ($object->element == 'contrat' && empty($conf->global->CONTRACT_SUPPORT_PRODUCTS))) echo $langs->trans('PredefinedServicesToSell');
else echo $langs->trans('PredefinedProductsAndServicesToSell');
}
else