2
0
forked from Wavyzz/dolibarr

Merge branch '19.0' of git@github.com:Dolibarr/dolibarr.git into 20.0

This commit is contained in:
Laurent Destailleur
2024-10-07 15:20:16 +02:00
4 changed files with 20 additions and 9 deletions

View File

@@ -278,8 +278,8 @@ class Categories extends DolibarrApi
throw new RestException(403, 'Access not allowed for login '.DolibarrApiAccess::$user->login); throw new RestException(403, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
} }
if (!$this->category->delete(DolibarrApiAccess::$user)) { if ($this->category->delete(DolibarrApiAccess::$user) <= 0) {
throw new RestException(500, 'error when delete category'); throw new RestException(500, 'Error when delete category : ' . $this->category->error);
} }
return array( return array(

View File

@@ -3514,7 +3514,7 @@ class Form
if (isModEnabled('stock') && isset($objp->stock) && ($objp->fk_product_type == Product::TYPE_PRODUCT || getDolGlobalString('STOCK_SUPPORTS_SERVICES'))) { if (isModEnabled('stock') && isset($objp->stock) && ($objp->fk_product_type == Product::TYPE_PRODUCT || getDolGlobalString('STOCK_SUPPORTS_SERVICES'))) {
if ($user->hasRight('stock', 'lire')) { if ($user->hasRight('stock', 'lire')) {
$opt .= ' - ' . $langs->trans("Stock") . ': ' . price(price2num($objp->stock, 'MS')); $opt .= ' - ' . $langs->trans("Stock") . ': ' . price(price2num($objp->stock, 'MS'), 0, $langs, 0, 0);
if ($objp->stock > 0) { if ($objp->stock > 0) {
$outval .= ' - <span class="product_line_stock_ok">'; $outval .= ' - <span class="product_line_stock_ok">';

View File

@@ -6612,10 +6612,11 @@ function price($amount, $form = 0, $outlangs = '', $trunc = 1, $rounding = -1, $
if (dol_strlen($decpart) > $nbdecimal) { if (dol_strlen($decpart) > $nbdecimal) {
$nbdecimal = dol_strlen($decpart); $nbdecimal = dol_strlen($decpart);
} }
// Si on depasse max
$max_nbdecimal = (int) str_replace('...', '', getDolGlobalString('MAIN_MAX_DECIMALS_SHOWN')); // If nbdecimal is higher than max to show
if ($trunc && $nbdecimal > $max_nbdecimal) { $nbdecimalmaxshown = (int) str_replace('...', '', getDolGlobalString('MAIN_MAX_DECIMALS_SHOWN'));
$nbdecimal = $max_nbdecimal; if ($trunc && $nbdecimal > $nbdecimalmaxshown) {
$nbdecimal = $nbdecimalmaxshown;
if (preg_match('/\.\.\./i', getDolGlobalString('MAIN_MAX_DECIMALS_SHOWN'))) { if (preg_match('/\.\.\./i', getDolGlobalString('MAIN_MAX_DECIMALS_SHOWN'))) {
// If output is truncated, we show ... // If output is truncated, we show ...
$end = '...'; $end = '...';

View File

@@ -369,7 +369,7 @@ class Contacts extends DolibarrApi
* Delete contact * Delete contact
* *
* @param int $id Contact ID * @param int $id Contact ID
* @return integer * @return array[]
*/ */
public function delete($id) public function delete($id)
{ {
@@ -385,7 +385,17 @@ class Contacts extends DolibarrApi
throw new RestException(403, 'Access not allowed for login '.DolibarrApiAccess::$user->login); throw new RestException(403, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
} }
$this->contact->oldcopy = clone $this->contact; $this->contact->oldcopy = clone $this->contact;
return $this->contact->delete(DolibarrApiAccess::$user);
if ($this->contact->delete(DolibarrApiAccess::$user) <= 0) {
throw new RestException(500, 'Error when delete contact ' . $this->contact->error);
}
return array(
'success' => array(
'code' => 200,
'message' => 'Contact deleted'
)
);
} }
/** /**