From 78697c1735a0861c4136ddde0314433aed614bef Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 14 Feb 2018 21:14:24 +0100 Subject: [PATCH] USe fk_product is better than ref --- htdocs/comm/propal/card.php | 10 ++++++---- htdocs/core/class/commondocgenerator.class.php | 18 +++++++++--------- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 8bd9f7ffa98..54e3cf36c45 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -104,8 +104,11 @@ if ($id > 0 || ! empty($ref)) { $ret = $object->fetch($id, $ref); if ($ret > 0) $ret = $object->fetch_thirdparty(); - if ($ret < 0) - dol_print_error('', $object->error); + if ($ret <= 0) + { + setEventMessages($object->error, $object->errors, 'errors'); + $action = ''; + } } // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context @@ -1711,7 +1714,7 @@ if ($action == 'create') print ''; } -} else { +} elseif ($object->id > 0) { /* * Show object in view mode */ @@ -1818,7 +1821,6 @@ if ($action == 'create') $linkback = '' . $langs->trans("BackToList") . ''; - $morehtmlref='
'; // Ref customer $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, $user->rights->propal->creer, 'string', '', 0, 1); diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index 015173f1f05..aeca3d5a102 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -425,7 +425,7 @@ abstract class CommonDocGenerator { $object->fetch_projet(); } - + $resarray[$array_key.'_project_ref'] = $object->project->ref; $resarray[$array_key.'_project_title'] = $object->project->title; $resarray[$array_key.'_project_description'] = $object->project->description; @@ -510,7 +510,7 @@ abstract class CommonDocGenerator 'line_multicurrency_total_tva_locale' => price($line->multicurrency_total_tva, 0, $outputlangs), 'line_multicurrency_total_ttc_locale' => price($line->multicurrency_total_ttc, 0, $outputlangs), ); - + // Units if ($conf->global->PRODUCT_USE_UNITS) { @@ -527,16 +527,16 @@ abstract class CommonDocGenerator $line->fetch_optionals($line->rowid,$extralabels); $resarray = $this->fill_substitutionarray_with_extrafields($line,$resarray,$extrafields,$array_key=$array_key,$outputlangs); - + // Load product data optional fields to the line -> enables to use "line_options_{extrafield}" - if (isset($line->product_ref)) + if (isset($line->fk_product) && $line->fk_product > 0) { - $product = new Product($this->db); - $result = $product->fetch(null, $line->product_ref); - foreach($product->array_options as $key=>$label) + $tmpproduct = new Product($this->db); + $result = $tmpproduct->fetch($line->fk_product); + foreach($tmpproduct->array_options as $key=>$label) $resarray["line_".$key] = $label; - } - + } + return $resarray; }