From 07b42f2bd5dc24f4bd7f34943ecabb490c55de66 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Tue, 22 Dec 2015 07:31:59 +0100 Subject: [PATCH] Fix bug with empty code - return -1 --- htdocs/product/card.php | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 7b2d71a4c27..29ab2c0018c 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -157,6 +157,7 @@ if (empty($reshook)) } } + /* if ($action == 'setaccountancy_code_buy') { $result = $object->setAccountancyCode('buy', GETPOST('accountancy_code_buy')); @@ -170,6 +171,7 @@ if (empty($reshook)) if ($result < 0) setEventMessages(join(',',$object->errors), null, 'errors'); $action=""; } + */ // Add a product or service if ($action == 'add' && ($user->rights->produit->creer || $user->rights->service->creer)) @@ -262,10 +264,11 @@ if (empty($reshook)) $object->finished = GETPOST('finished'); $object->fk_unit = GETPOST('units'); - if (GETPOST('accountancy_code_sell') <= 0) { $accountancy_code_sell = ''; } else { $accountancy_code_sell = GETPOST('accountancy_code_sell'); } - if (GETPOST('accountancy_code_buy') <= 0) { $accountancy_code_buy = ''; } else { $accountancy_code_buy = GETPOST('accountancy_code_buy'); } - $object->accountancy_code_sell = $accountancy_code_sell; - $object->accountancy_code_buy = $accountancy_code_buy; + $accountancy_code_sell = GETPOST('accountancy_code_sell'); + $accountancy_code_buy = GETPOST('accountancy_code_buy'); + + if ($accountancy_code_sell <= 0) { $object->accountancy_code_sell = ''; } else { $object->accountancy_code_sell = $accountancy_code_sell; } + if ($accountancy_code_buy <= 0) { $object->accountancy_code_buy = ''; } else { $object->accountancy_code_buy = $accountancy_code_buy; } // MultiPrix if (! empty($conf->global->PRODUIT_MULTIPRICES)) @@ -374,10 +377,11 @@ if (empty($reshook)) $object->barcode_type_coder = $stdobject->barcode_type_coder; $object->barcode_type_label = $stdobject->barcode_type_label; - if (GETPOST('accountancy_code_sell') <= 0) { $accountancy_code_sell = ''; } else { $accountancy_code_sell = GETPOST('accountancy_code_sell'); } - if (GETPOST('accountancy_code_buy') <= 0) { $accountancy_code_buy = ''; } else { $accountancy_code_buy = GETPOST('accountancy_code_buy'); } - $object->accountancy_code_sell = GETPOST('accountancy_code_sell'); - $object->accountancy_code_buy = GETPOST('accountancy_code_buy'); + $accountancy_code_sell = GETPOST('accountancy_code_sell'); + $accountancy_code_buy = GETPOST('accountancy_code_buy'); + + if ($accountancy_code_sell <= 0) { $object->accountancy_code_sell = ''; } else { $object->accountancy_code_sell = $accountancy_code_sell; } + if ($accountancy_code_buy <= 0) { $object->accountancy_code_buy = ''; } else { $object->accountancy_code_buy = $accountancy_code_buy; } // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost($extralabels,$object);