fix for the supplier code
This commit is contained in:
parent
c8440a6283
commit
a3628954b2
@ -255,6 +255,7 @@ if (empty($reshook) && $action == 'add') {
|
|||||||
// Getting the thirdparty or creating it
|
// Getting the thirdparty or creating it
|
||||||
$thirdparty = new Societe($db);
|
$thirdparty = new Societe($db);
|
||||||
$resultfetchthirdparty = $thirdparty->fetch('', $societe);
|
$resultfetchthirdparty = $thirdparty->fetch('', $societe);
|
||||||
|
|
||||||
if ($resultfetchthirdparty<=0) {
|
if ($resultfetchthirdparty<=0) {
|
||||||
// Need to create a new one (not found or multiple with the same name)
|
// Need to create a new one (not found or multiple with the same name)
|
||||||
$thirdparty->name = $societe;
|
$thirdparty->name = $societe;
|
||||||
@ -331,37 +332,41 @@ if (empty($reshook) && $action == 'add') {
|
|||||||
$resultcategory = $category->fetch($conf->global->EVENTORGANIZATION_CATEG_THIRDPARTY_BOOTH);
|
$resultcategory = $category->fetch($conf->global->EVENTORGANIZATION_CATEG_THIRDPARTY_BOOTH);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($resultcategory<0) {
|
if ($resultcategory<=0) {
|
||||||
$error++;
|
$error++;
|
||||||
$errmsg .= $category->error;
|
$errmsg .= $category->error;
|
||||||
} else {
|
} else {
|
||||||
$resultsetcategory = $thirdparty->setCategoriesCommon(array($category->id), CATEGORIE::TYPE_CUSTOMER, false);
|
$resultsetcategory = $thirdparty->setCategoriesCommon(array($category->id), CATEGORIE::TYPE_CUSTOMER, false);
|
||||||
if ($resultsetcategory <=0) {
|
if ($resultsetcategory < 0) {
|
||||||
$error++;
|
$error++;
|
||||||
$errmsg .= $thirdparty->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
|
$res = $thirdparty->update(0, $user, 1, 1, 1);
|
||||||
$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') {
|
if ($res <= 0) {
|
||||||
$module = substr($module, 0, dol_strlen($module) - 4);
|
$error++;
|
||||||
}
|
|
||||||
$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, 0);
|
|
||||||
}
|
|
||||||
$thirdparty->code_fournisseur = $tmpcode;
|
|
||||||
|
|
||||||
$res = $thirdparty->update(0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -2468,6 +2468,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
|
|||||||
if ($tmpcheck != 0 && $tmpcheck != -5) {
|
if ($tmpcheck != 0 && $tmpcheck != -5) {
|
||||||
print ' <font class="error">('.$langs->trans("WrongSupplierCode").')</font>';
|
print ' <font class="error">('.$langs->trans("WrongSupplierCode").')</font>';
|
||||||
}
|
}
|
||||||
|
var_dump($tmpcheck);
|
||||||
print '</td>';
|
print '</td>';
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user