'; // 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 '
';
print '
';
print '';
diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php
index 8ba38b81edb..030f04a5ae3 100644
--- a/htdocs/core/class/html.form.class.php
+++ b/htdocs/core/class/html.form.class.php
@@ -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 '';
//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 '';
}
- 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 '';
diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php
index 2489a40c5d7..d412c611a9d 100644
--- a/htdocs/core/tpl/objectline_create.tpl.php
+++ b/htdocs/core/tpl/objectline_create.tpl.php
@@ -7,6 +7,7 @@
* Copyright (C) 2014 Raphaël Doursenaud
* Copyright (C) 2015-2016 Marcos García
* Copyright (C) 2018 Frédéric France
+ * Copyright (C) 2018 Ferran Marcet
*
* 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