diff --git a/htdocs/compta/facture/card-rec.php b/htdocs/compta/facture/card-rec.php index 284ec8111d5..a11f0f7c800 100644 --- a/htdocs/compta/facture/card-rec.php +++ b/htdocs/compta/facture/card-rec.php @@ -1617,13 +1617,12 @@ if ($action == 'create') // Show object lines if (!empty($object->lines)) { - //$disableedit=1; - //$disablemove=1; + $canchangeproduct = 1; $ret = $object->printObjectLines($action, $mysoc, $object->thirdparty, $lineid, 0); // No date selector for template invoice } // Form to add new line - if ($object->statut == 0 && $user->rights->facture->creer && $action != 'valid' && $action != 'editline') + if ($object->statut == $object::STATUS_DRAFT && $user->rights->facture->creer && $action != 'valid' && $action != 'editline') { if ($action != 'editline') { diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index fadf0831ada..adb117b7b8f 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -665,6 +665,7 @@ if (empty($reshook)) $fk_unit = GETPOST('unit', 'alpha'); + $objectline->fk_product = GETPOST('idprod', 'int'); $objectline->description = GETPOST('product_desc', 'restricthtml'); $objectline->price_ht = GETPOST('elprice'); $objectline->subprice = GETPOST('elprice'); @@ -1436,8 +1437,6 @@ if ($action == 'create') $usemargins = 0; if (!empty($conf->margin->enabled) && !empty($object->element) && in_array($object->element, array('facture', 'propal', 'commande'))) $usemargins = 1; - $var = false; - // Title line for service $cursorline = 1; print '
'; @@ -1448,7 +1447,6 @@ if ($action == 'create') print ''; print ''; print ''; - print ''; print ''; // Area with common detail of line @@ -1632,17 +1630,29 @@ if ($action == 'create') // Ligne carac print ''; print ''; - if ($objp->fk_product) + if ($objp->fk_product > 0) { - $productstatic->id = $objp->fk_product; - $productstatic->type = $objp->ptype; - $productstatic->ref = $objp->pref; - $productstatic->entity = $objp->pentity; - print $productstatic->getNomUrl(1, '', 32); - print $objp->label ? ' - '.dol_trunc($objp->label, 32) : ''; + $canchangeproduct = 1; + if (empty($canchangeproduct)) { + $productstatic->id = $objp->fk_product; + $productstatic->type = $objp->ptype; + $productstatic->ref = $objp->pref; + $productstatic->entity = $objp->pentity; + print $productstatic->getNomUrl(1, '', 32); + print $objp->label ? ' - '.dol_trunc($objp->label, 32) : ''; + print ''; + } else { + $senderissupplier = 0; + if (empty($senderissupplier)) { + print $form->select_produits((!empty($object->lines[$cursorline - 1]->fk_product) ? $object->lines[$cursorline - 1]->fk_product : 0), 'idprod'); + } else { + print $form->select_produits_fournisseurs((!empty($object->lines[$cursorline - 1]->fk_product) ? $object->lines[$cursorline - 1]->fk_product : 0), 'idprod'); + } + } print '
'; } else { print $objp->label ? $objp->label.'
' : ''; + print ''; } // editeur wysiwyg diff --git a/htdocs/core/tpl/objectline_edit.tpl.php b/htdocs/core/tpl/objectline_edit.tpl.php index 86cb472da43..6ced56b5e03 100644 --- a/htdocs/core/tpl/objectline_edit.tpl.php +++ b/htdocs/core/tpl/objectline_edit.tpl.php @@ -1,6 +1,6 @@ - * Copyright (C) 2010-2012 Laurent Destailleur + * Copyright (C) 2010-2020 Laurent Destailleur * Copyright (C) 2012 Christophe Battarel * Copyright (C) 2012 Cédric Salvador * Copyright (C) 2012-2014 Raphaël Doursenaud @@ -29,6 +29,7 @@ * $forceall (0 by default, 1 for supplier invoices/orders) * $senderissupplier (0 by default, 1 for supplier invoices/orders) * $inputalsopricewithtax (0 by default, 1 to also show column with unit price including tax) + * $canchangeproduct (0 by default, 1 to allow to change the product if it is a predefined product) */ // Protection to avoid direct call of template @@ -42,12 +43,12 @@ if (empty($object) || !is_object($object)) $usemargins = 0; if (!empty($conf->margin->enabled) && !empty($object->element) && in_array($object->element, array('facture', 'facturerec', 'propal', 'commande'))) $usemargins = 1; -global $forceall, $senderissupplier, $inputalsopricewithtax; +global $forceall, $senderissupplier, $inputalsopricewithtax, $canchangeproduct; if (empty($dateSelector)) $dateSelector = 0; if (empty($forceall)) $forceall = 0; if (empty($senderissupplier)) $senderissupplier = 0; if (empty($inputalsopricewithtax)) $inputalsopricewithtax = 0; - +if (empty($canchangeproduct)) $canchangeproduct = 0; // Define colspan for the button 'Add' $colspan = 3; // Col total ht + col edit + col delete @@ -71,27 +72,33 @@ $coldisplay++; - fk_product > 0) { ?> fk_parent_line > 0) echo img_picto('', 'rightarrow'); + if (empty($canchangeproduct)) { + if ($line->fk_parent_line > 0) echo img_picto('', 'rightarrow'); + ?> + + product_type == 1) echo img_object($langs->trans('ShowService'), 'service'); + else print img_object($langs->trans('ShowProduct'), 'product'); + echo ' '.$line->ref; + ?> + + product_label); + print ''; + } else { + if ($senderissupplier) { + print $form->select_produits_fournisseurs(!empty($line->fk_product) ? $line->fk_product : 0, 'productid'); + } else { + print $form->select_produits(!empty($line->fk_product) ? $line->fk_product : 0, 'productid'); + } + } ?> - - product_type == 1) echo img_object($langs->trans('ShowService'), 'service'); - else print img_object($langs->trans('ShowProduct'), 'product'); - echo ' '.$line->ref; - ?> - - product_label); - ?> -

-