USe fk_product is better than ref

This commit is contained in:
Laurent Destailleur 2018-02-14 21:14:24 +01:00
parent f3ffc7ce8a
commit 78697c1735
2 changed files with 15 additions and 13 deletions

View File

@ -104,8 +104,11 @@ if ($id > 0 || ! empty($ref)) {
$ret = $object->fetch($id, $ref); $ret = $object->fetch($id, $ref);
if ($ret > 0) if ($ret > 0)
$ret = $object->fetch_thirdparty(); $ret = $object->fetch_thirdparty();
if ($ret < 0) if ($ret <= 0)
dol_print_error('', $object->error); {
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 // 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 '</table>'; print '</table>';
} }
} else { } elseif ($object->id > 0) {
/* /*
* Show object in view mode * Show object in view mode
*/ */
@ -1818,7 +1821,6 @@ if ($action == 'create')
$linkback = '<a href="' . DOL_URL_ROOT . '/comm/propal/list.php?restore_lastsearch_values=1' . (! empty($socid) ? '&socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>'; $linkback = '<a href="' . DOL_URL_ROOT . '/comm/propal/list.php?restore_lastsearch_values=1' . (! empty($socid) ? '&socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>';
$morehtmlref='<div class="refidno">'; $morehtmlref='<div class="refidno">';
// Ref customer // Ref customer
$morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, $user->rights->propal->creer, 'string', '', 0, 1); $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, $user->rights->propal->creer, 'string', '', 0, 1);

View File

@ -425,7 +425,7 @@ abstract class CommonDocGenerator
{ {
$object->fetch_projet(); $object->fetch_projet();
} }
$resarray[$array_key.'_project_ref'] = $object->project->ref; $resarray[$array_key.'_project_ref'] = $object->project->ref;
$resarray[$array_key.'_project_title'] = $object->project->title; $resarray[$array_key.'_project_title'] = $object->project->title;
$resarray[$array_key.'_project_description'] = $object->project->description; $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_tva_locale' => price($line->multicurrency_total_tva, 0, $outputlangs),
'line_multicurrency_total_ttc_locale' => price($line->multicurrency_total_ttc, 0, $outputlangs), 'line_multicurrency_total_ttc_locale' => price($line->multicurrency_total_ttc, 0, $outputlangs),
); );
// Units // Units
if ($conf->global->PRODUCT_USE_UNITS) if ($conf->global->PRODUCT_USE_UNITS)
{ {
@ -527,16 +527,16 @@ abstract class CommonDocGenerator
$line->fetch_optionals($line->rowid,$extralabels); $line->fetch_optionals($line->rowid,$extralabels);
$resarray = $this->fill_substitutionarray_with_extrafields($line,$resarray,$extrafields,$array_key=$array_key,$outputlangs); $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}" // 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); $tmpproduct = new Product($this->db);
$result = $product->fetch(null, $line->product_ref); $result = $tmpproduct->fetch($line->fk_product);
foreach($product->array_options as $key=>$label) foreach($tmpproduct->array_options as $key=>$label)
$resarray["line_".$key] = $label; $resarray["line_".$key] = $label;
} }
return $resarray; return $resarray;
} }