From a3628954b21b82bfad96b69d4fa396322778d77e Mon Sep 17 00:00:00 2001 From: Dorian Vabre Date: Mon, 26 Apr 2021 17:46:30 +0200 Subject: [PATCH] fix for the supplier code --- htdocs/public/project/index.php | 47 ++++++++++++++++++--------------- htdocs/societe/card.php | 1 + 2 files changed, 27 insertions(+), 21 deletions(-) diff --git a/htdocs/public/project/index.php b/htdocs/public/project/index.php index 932a36dad92..d6614c8ed29 100644 --- a/htdocs/public/project/index.php +++ b/htdocs/public/project/index.php @@ -255,6 +255,7 @@ if (empty($reshook) && $action == 'add') { // Getting the thirdparty or creating it $thirdparty = new Societe($db); $resultfetchthirdparty = $thirdparty->fetch('', $societe); + if ($resultfetchthirdparty<=0) { // Need to create a new one (not found or multiple with the same name) $thirdparty->name = $societe; @@ -331,37 +332,41 @@ if (empty($reshook) && $action == 'add') { $resultcategory = $category->fetch($conf->global->EVENTORGANIZATION_CATEG_THIRDPARTY_BOOTH); } - if ($resultcategory<0) { + if ($resultcategory<=0) { $error++; $errmsg .= $category->error; } else { $resultsetcategory = $thirdparty->setCategoriesCommon(array($category->id), CATEGORIE::TYPE_CUSTOMER, false); - if ($resultsetcategory <=0) { + if ($resultsetcategory < 0) { $error++; $errmsg .= $thirdparty->error; - } + } else { + $thirdparty->fournisseur = 1; - $thirdparty->fournisseur = 1; + // Load object modCodeFournisseur + $module = (!empty($conf->global->SOCIETE_CODECLIENT_ADDON) ? $conf->global->SOCIETE_CODECLIENT_ADDON : 'mod_codeclient_leopard'); + if (substr($module, 0, 15) == 'mod_codeclient_' && substr($module, -3) == 'php') { + $module = substr($module, 0, dol_strlen($module) - 4); + } + $dirsociete = array_merge(array('/core/modules/societe/'), $conf->modules_parts['societe']); + foreach ($dirsociete as $dirroot) { + $res = dol_include_once($dirroot.$module.'.php'); + if ($res) { + break; + } + } + $modCodeFournisseur = new $module; + if (empty($tmpcode) && !empty($modCodeFournisseur->code_auto)) { + $tmpcode = $modCodeFournisseur->getNextValue($thirdparty, 1); + } + $thirdparty->code_fournisseur = $tmpcode; - // Load object modCodeFournisseur - $module = (!empty($conf->global->SOCIETE_CODECLIENT_ADDON) ? $conf->global->SOCIETE_CODECLIENT_ADDON : 'mod_codeclient_leopard'); - if (substr($module, 0, 15) == 'mod_codeclient_' && substr($module, -3) == 'php') { - $module = substr($module, 0, dol_strlen($module) - 4); - } - $dirsociete = array_merge(array('/core/modules/societe/'), $conf->modules_parts['societe']); - foreach ($dirsociete as $dirroot) { - $res = dol_include_once($dirroot.$module.'.php'); - if ($res) { - break; + $res = $thirdparty->update(0, $user, 1, 1, 1); + + if ($res <= 0) { + $error++; } } - $modCodeFournisseur = new $module; - if (empty($tmpcode) && !empty($modCodeFournisseur->code_auto)) { - $tmpcode = $modCodeFournisseur->getNextValue($thirdparty, 0); - } - $thirdparty->code_fournisseur = $tmpcode; - - $res = $thirdparty->update(0); } } diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 68efa8e694c..64a46f9d1a8 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -2468,6 +2468,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { if ($tmpcheck != 0 && $tmpcheck != -5) { print ' ('.$langs->trans("WrongSupplierCode").')'; } + var_dump($tmpcheck); print ''; print ''; }