diff --git a/htdocs/compta/facture/card-rec.php b/htdocs/compta/facture/card-rec.php index 6d7f7f6010e..ca61eafcc3b 100644 --- a/htdocs/compta/facture/card-rec.php +++ b/htdocs/compta/facture/card-rec.php @@ -641,7 +641,7 @@ if (empty($reshook)) { setEventMessages($mesg, null, 'errors'); } else { // Insert line - $result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $price_base_type, $info_bits, '', $pu_ttc, $type, - 1, $special_code, $label, $fk_unit, 0, $date_start_fill, $date_end_fill, $fournprice, $buyingprice); + $result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $price_base_type, $info_bits, '', $pu_ttc, $type, -1, $special_code, $label, $fk_unit, 0, $date_start_fill, $date_end_fill, $fournprice, $buyingprice); if ($result > 0) { // Define output language and generate document @@ -1605,19 +1605,19 @@ if ($action == 'create') { // Lines - print '
- - - - - '; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; if (!empty($conf->use_javascript_ajax) && $object->statut == 0) { include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php'; } print '
'; - print ''; + print '
'; // Show object lines if (!empty($object->lines)) { $canchangeproduct = 1; diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index 91d0fd0f20a..7058364d1f1 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -945,6 +945,13 @@ class FactureRec extends CommonInvoice $product_type = $product->type; } + // Rank to use + $ranktouse = $rang; + if ($ranktouse == -1) { + $rangmax = $this->line_max(0); + $ranktouse = $rangmax + 1; + } + $sql = "INSERT INTO ".MAIN_DB_PREFIX."facturedet_rec ("; $sql .= "fk_facture"; $sql .= ", label"; @@ -1003,7 +1010,7 @@ class FactureRec extends CommonInvoice $sql .= ", ".($fk_fournprice > 0 ? $fk_fournprice : 'null'); $sql .= ", ".($pa_ht ? price2num($pa_ht) : 0); $sql .= ", ".((int) $info_bits); - $sql .= ", ".((int) $rang); + $sql .= ", ".((int) $ranktouse); $sql .= ", ".((int) $special_code); $sql .= ", ".($fk_unit ? ((int) $fk_unit) : "null"); $sql .= ", ".(int) $this->fk_multicurrency;