->error rather than dol_print_error into product

This commit is contained in:
florian HENRY 2020-07-31 16:09:38 +02:00
parent f5d7e94d7e
commit e44a1fd33f
6 changed files with 38 additions and 17 deletions

View File

@ -890,7 +890,10 @@ if ($rowid > 0) {
if (empty($conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS) || $conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS != 'defaultforfoundationcountry') print '. <span class="opacitymedium">'.$langs->trans("NoVatOnSubscription", 0).'</span>'; if (empty($conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS) || $conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS != 'defaultforfoundationcountry') print '. <span class="opacitymedium">'.$langs->trans("NoVatOnSubscription", 0).'</span>';
if (!empty($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS) && (!empty($conf->product->enabled) || !empty($conf->service->enabled))) { if (!empty($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS) && (!empty($conf->product->enabled) || !empty($conf->service->enabled))) {
$prodtmp = new Product($db); $prodtmp = new Product($db);
$prodtmp->fetch($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS); $result = $prodtmp->fetch($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS);
if ($result < 0) {
setEventMessage($prodtmp->error, 'errors');
}
print '. '.$langs->transnoentitiesnoconv("ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS", $prodtmp->getNomUrl(1)); // must use noentitiesnoconv to avoid to encode html into getNomUrl of product print '. '.$langs->transnoentitiesnoconv("ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS", $prodtmp->getNomUrl(1)); // must use noentitiesnoconv to avoid to encode html into getNomUrl of product
} }
print '<br>'; print '<br>';
@ -912,7 +915,10 @@ if ($rowid > 0) {
if (empty($conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS) || $conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS != 'defaultforfoundationcountry') print '. <span class="opacitymedium">'.$langs->trans("NoVatOnSubscription", 0).'</span>'; if (empty($conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS) || $conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS != 'defaultforfoundationcountry') print '. <span class="opacitymedium">'.$langs->trans("NoVatOnSubscription", 0).'</span>';
if (!empty($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS) && (!empty($conf->product->enabled) || !empty($conf->service->enabled))) { if (!empty($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS) && (!empty($conf->product->enabled) || !empty($conf->service->enabled))) {
$prodtmp = new Product($db); $prodtmp = new Product($db);
$prodtmp->fetch($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS); $result = $prodtmp->fetch($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS);
if ($result < 0) {
setEventMessage($prodtmp->error, 'errors');
}
print '. '.$langs->transnoentitiesnoconv("ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS", $prodtmp->getNomUrl(1)); // must use noentitiesnoconv to avoid to encode html into getNomUrl of product print '. '.$langs->transnoentitiesnoconv("ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS", $prodtmp->getNomUrl(1)); // must use noentitiesnoconv to avoid to encode html into getNomUrl of product
} }
print '<br>'; print '<br>';

View File

@ -419,8 +419,10 @@ class Documents extends DolibarrApi
$object = new Product($this->db); $object = new Product($this->db);
$result = $object->fetch($id, $ref); $result = $object->fetch($id, $ref);
if (!$result) { if ($result==0) {
throw new RestException(404, 'Product not found'); throw new RestException(404, 'Product not found');
} elseif ($result<0) {
throw new RestException(500, 'Error while fetching object: '.$object->error);
} }
$upload_dir = $conf->product->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 0, $object, 'product').dol_sanitizeFileName($object->ref); $upload_dir = $conf->product->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 0, $object, 'product').dol_sanitizeFileName($object->ref);
@ -630,7 +632,7 @@ class Documents extends DolibarrApi
} }
elseif ($result < 0) elseif ($result < 0)
{ {
throw new RestException(500, 'Error while fetching object.'); throw new RestException(500, 'Error while fetching object: '.$object->error);
} }
} }

View File

@ -57,9 +57,11 @@ $thirdpartytmp = new Societe($db);
if (GETPOST('submitproduct') && GETPOST('submitproduct')) if (GETPOST('submitproduct') && GETPOST('submitproduct'))
{ {
$action = ''; // We reset because we don't want to build doc $action = ''; // We reset because we don't want to build doc
if (GETPOST('productid') > 0) if (GETPOST('productid') > 0) {
{ $result = $producttmp->fetch(GETPOST('productid'));
$producttmp->fetch(GETPOST('productid')); if ($result < 0) {
setEventMessage($producttmp->error, 'errors');
}
$forbarcode = $producttmp->barcode; $forbarcode = $producttmp->barcode;
$fk_barcode_type = $producttmp->barcode_type; $fk_barcode_type = $producttmp->barcode_type;

View File

@ -1004,7 +1004,11 @@ class BOM extends CommonObject
foreach ($this->lines as &$line) { foreach ($this->lines as &$line) {
$tmpproduct = new Product($this->db); $tmpproduct = new Product($this->db);
$tmpproduct->fetch($line->fk_product); $result= $tmpproduct->fetch($line->fk_product);
if ($result < 0) {
$this->error=$tmpproduct->error;
return -1;
}
$line->unit_cost = price2num((!empty($tmpproduct->cost_price)) ? $tmpproduct->cost_price : $tmpproduct->pmp); $line->unit_cost = price2num((!empty($tmpproduct->cost_price)) ? $tmpproduct->cost_price : $tmpproduct->pmp);
if (empty($line->unit_cost)) { if (empty($line->unit_cost)) {
if ($productFournisseur->find_min_price_product_fournisseur($line->fk_product) > 0) if ($productFournisseur->find_min_price_product_fournisseur($line->fk_product) > 0)

View File

@ -52,8 +52,15 @@ foreach ($linkedObjectBlock as $key => $objectlink)
} }
echo '</td>'; echo '</td>';
echo '<td class="linkedcol-name nowraponall" >'.$objectlink->getNomUrl(1).'</td>'; echo '<td class="linkedcol-name nowraponall" >'.$objectlink->getNomUrl(1).'</td>';
$product_static->fetch($objectlink->fk_product);
echo '<td class="linkedcol-ref" align="center">'.$product_static->getNomUrl(1).'</td>'; echo '<td class="linkedcol-ref" align="center">';
$result=$product_static->fetch($objectlink->fk_product);
if ($result<0) {
setEventMessage($product_static->error, 'errors');
} elseif ($result>0) {
$product_static->getNomUrl(1);
}
print '</td>';
echo '<td class="linkedcol-date" align="center">'.dol_print_date($objectlink->date_creation, 'day').'</td>'; echo '<td class="linkedcol-date" align="center">'.dol_print_date($objectlink->date_creation, 'day').'</td>';
echo '<td class="linkedcol-amount right">'; echo '<td class="linkedcol-amount right">';
if ($user->rights->commande->lire) { if ($user->rights->commande->lire) {

View File

@ -2209,7 +2209,7 @@ class Product extends CommonObject
} }
}*/ }*/
} else { } else {
dol_print_error($this->db); $this->error=$this->db->lasterror;
return -1; return -1;
} }
} }
@ -2254,12 +2254,12 @@ class Product extends CommonObject
} }
$this->prices_by_qty_list[0] = $resultat; $this->prices_by_qty_list[0] = $resultat;
} else { } else {
dol_print_error($this->db); $this->error=$this->db->lasterror;
return -1; return -1;
} }
} }
} else { } else {
dol_print_error($this->db); $this->error=$this->db->lasterror;
return -1; return -1;
} }
} elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES) && empty($ignore_price_load)) // prices per customer and quantity } elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES) && empty($ignore_price_load)) // prices per customer and quantity
@ -2313,12 +2313,12 @@ class Product extends CommonObject
} }
$this->prices_by_qty_list[$i] = $resultat; $this->prices_by_qty_list[$i] = $resultat;
} else { } else {
dol_print_error($this->db); $this->error=$this->db->lasterror;
return -1; return -1;
} }
} }
} else { } else {
dol_print_error($this->db); $this->error=$this->db->lasterror;
return -1; return -1;
} }
} }
@ -2345,7 +2345,7 @@ class Product extends CommonObject
return 0; return 0;
} }
} else { } else {
dol_print_error($this->db); $this->error=$this->db->lasterror;
return -1; return -1;
} }
} }