Fix: Type of line (product/service) could not be edited on supplier

order/invoice.
This commit is contained in:
Laurent Destailleur 2014-07-20 02:36:03 +02:00
parent a9779ca1ff
commit 8137fd7fe4
3 changed files with 14 additions and 12 deletions

View File

@ -544,7 +544,7 @@ class Form
* @param string $htmlname Name of field in html form * @param string $htmlname Name of field in html form
* @param int $showempty Add an empty field * @param int $showempty Add an empty field
* @param int $hidetext Do not show label before combo box * @param int $hidetext Do not show label before combo box
* @param string $forceall Force to show products and services in combo list, whatever are activated modules * @param string $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')
* @return void * @return void
*/ */
function select_type_of_lines($selected='',$htmlname='type',$showempty=0,$hidetext=0,$forceall=0) function select_type_of_lines($selected='',$htmlname='type',$showempty=0,$hidetext=0,$forceall=0)
@ -552,8 +552,8 @@ class Form
global $db,$langs,$user,$conf; global $db,$langs,$user,$conf;
// If product & services are enabled or both disabled. // If product & services are enabled or both disabled.
if ($forceall || (! empty($conf->product->enabled) && ! empty($conf->service->enabled)) if ($forceall > 0 || (empty($forceall) && ! empty($conf->product->enabled) && ! empty($conf->service->enabled))
|| (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").': '; if (empty($hidetext)) print $langs->trans("Type").': ';
print '<select class="flat" id="select_'.$htmlname.'" name="'.$htmlname.'">'; print '<select class="flat" id="select_'.$htmlname.'" name="'.$htmlname.'">';

View File

@ -1698,7 +1698,7 @@ elseif (! empty($object->id))
print "</tr>"; print "</tr>";
} }
// Ligne en mode update // Edit line
if ($action == 'edit_line' && $user->rights->fournisseur->commande->creer && ($_GET["rowid"] == $line->id)) if ($action == 'edit_line' && $user->rights->fournisseur->commande->creer && ($_GET["rowid"] == $line->id))
{ {
print "\n"; print "\n";
@ -1723,8 +1723,10 @@ elseif (! empty($object->id))
} }
else else
{ {
print $form->select_type_of_lines($line->product_type,'type',1); $forceall=1; // For suppliers, we always show all types
if (! empty($conf->product->enabled) && ! empty($conf->service->enabled)) print '<br>'; print $form->select_type_of_lines($line->product_type,'type',1,0,$forceall);
if ($forceall || (! empty($conf->product->enabled) && ! empty($conf->service->enabled))
|| (empty($conf->product->enabled) && empty($conf->service->enabled))) print '<br>';
} }
if (is_object($hookmanager)) if (is_object($hookmanager))

View File

@ -1953,7 +1953,7 @@ else
print '<input type="hidden" name="lineid" value="'.$object->lines[$i]->rowid.'">'; print '<input type="hidden" name="lineid" value="'.$object->lines[$i]->rowid.'">';
if ((! empty($conf->product->enabled) || ! empty($conf->service->enabled)) && $object->lines[$i]->fk_product) if ((! empty($conf->product->enabled) || ! empty($conf->service->enabled)) && $object->lines[$i]->fk_product > 0)
{ {
print '<input type="hidden" name="idprod" value="'.$object->lines[$i]->fk_product.'">'; print '<input type="hidden" name="idprod" value="'.$object->lines[$i]->fk_product.'">';
$product_static=new ProductFournisseur($db); $product_static=new ProductFournisseur($db);
@ -1964,9 +1964,9 @@ else
print '<br>'; print '<br>';
} }
else else
{ {
$forceall=1; // For suppliers, we always show all types $forceall=1; // For suppliers, we always show all types
print $form->select_type_of_lines($object->lines[$i]->product_type,'type',1); print $form->select_type_of_lines($object->lines[$i]->product_type,'type',1,0,$forceall);
if ($forceall || (! empty($conf->product->enabled) && ! empty($conf->service->enabled)) if ($forceall || (! empty($conf->product->enabled) && ! empty($conf->service->enabled))
|| (empty($conf->product->enabled) && empty($conf->service->enabled))) print '<br>'; || (empty($conf->product->enabled) && empty($conf->service->enabled))) print '<br>';
} }