marcosgdf-bug-1796

Conflicts:
	ChangeLog
This commit is contained in:
Laurent Destailleur 2015-01-18 15:08:49 +01:00
commit 7c5927ef93
9 changed files with 173 additions and 116 deletions

View File

@ -13,6 +13,7 @@ English Dolibarr ChangeLog
- Fix: [ bug #1804 ] SQL error when sending email without addresee - Fix: [ bug #1804 ] SQL error when sending email without addresee
- Fix: [ bug #1803 ] AJAX company contact input is not aligned - Fix: [ bug #1803 ] AJAX company contact input is not aligned
- Fix: [ bug #1787 ] Incorrect behaviour of doActions hook - Fix: [ bug #1787 ] Incorrect behaviour of doActions hook
- Fix: [ bug #1796 ] Unable to use numeration modules from an external module
***** ChangeLog for 3.6.2 compared to 3.6.1 ***** ***** ChangeLog for 3.6.2 compared to 3.6.1 *****
- Fix: fix ErrorBadValueForParamNotAString error message in price customer multiprice. - Fix: fix ErrorBadValueForParamNotAString error message in price customer multiprice.

View File

@ -2564,11 +2564,14 @@ class Propal extends CommonObject
$classname = $conf->global->PROPALE_ADDON; $classname = $conf->global->PROPALE_ADDON;
// Include file with class // Include file with class
foreach ($conf->file->dol_document_root as $dirroot) $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
{
$dir = $dirroot."/core/modules/propale/"; foreach ($dirmodels as $reldir) {
// Load file with numbering class (if found)
$mybool|=@include_once $dir.$file; $dir = dol_buildpath($reldir."core/modules/propale/");
// Load file with numbering class (if found)
$mybool|=@include_once $dir.$file;
} }
if (! $mybool) if (! $mybool)

View File

@ -137,17 +137,20 @@ class Commande extends CommonOrder
$classname = $conf->global->COMMANDE_ADDON; $classname = $conf->global->COMMANDE_ADDON;
// Include file with class // Include file with class
foreach ($conf->file->dol_document_root as $dirroot) $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
{
$dir = $dirroot."/core/modules/commande/"; foreach ($dirmodels as $reldir) {
// Load file with numbering class (if found)
$mybool|=@include_once $dir.$file; $dir = dol_buildpath($reldir."core/modules/commande/");
// Load file with numbering class (if found)
$mybool|=@include_once $dir.$file;
} }
if (! $mybool) if (! $mybool)
{ {
dol_print_error('',"Failed to include file ".$file); dol_print_error('',"Failed to include file ".$file);
return ''; return '';
} }
$obj = new $classname(); $obj = new $classname();

View File

@ -2504,52 +2504,64 @@ class Facture extends CommonInvoice
else if ($conf->global->FACTURE_ADDON=='terre') $conf->global->FACTURE_ADDON='mod_facture_terre'; else if ($conf->global->FACTURE_ADDON=='terre') $conf->global->FACTURE_ADDON='mod_facture_terre';
else if ($conf->global->FACTURE_ADDON=='mercure') $conf->global->FACTURE_ADDON='mod_facture_mercure'; else if ($conf->global->FACTURE_ADDON=='mercure') $conf->global->FACTURE_ADDON='mod_facture_mercure';
$mybool=false; if (! empty($conf->global->FACTURE_ADDON))
$file = $conf->global->FACTURE_ADDON.".php";
$classname = $conf->global->FACTURE_ADDON;
// Include file with class
foreach ($conf->file->dol_document_root as $dirroot)
{ {
$dir = $dirroot."/core/modules/facture/"; $mybool=false;
// Load file with numbering class (if found)
$mybool|=@include_once $dir.$file; $file = $conf->global->FACTURE_ADDON.".php";
} $classname = $conf->global->FACTURE_ADDON;
// For compatibility
if (! $mybool)
{
$file = $conf->global->FACTURE_ADDON."/".$conf->global->FACTURE_ADDON.".modules.php";
$classname = "mod_facture_".$conf->global->FACTURE_ADDON;
$classname = preg_replace('/\-.*$/','',$classname);
// Include file with class // Include file with class
foreach ($conf->file->dol_document_root as $dirroot) $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
{
$dir = $dirroot."/core/modules/facture/"; foreach ($dirmodels as $reldir) {
$dir = dol_buildpath($reldir."core/modules/facture/");
// Load file with numbering class (if found) // Load file with numbering class (if found)
$mybool|=@include_once $dir.$file; $mybool|=@include_once $dir.$file;
} }
}
//print "xx".$mybool.$dir.$file."-".$classname;
if (! $mybool) // For compatibility
{ if (! $mybool)
dol_print_error('',"Failed to include file ".$file); {
return ''; $file = $conf->global->FACTURE_ADDON."/".$conf->global->FACTURE_ADDON.".modules.php";
} $classname = "mod_facture_".$conf->global->FACTURE_ADDON;
$classname = preg_replace('/\-.*$/','',$classname);
// Include file with class
foreach ($conf->file->dol_document_root as $dirroot)
{
$dir = $dirroot."/core/modules/facture/";
// Load file with numbering class (if found)
$mybool|=@include_once $dir.$file;
}
}
$obj = new $classname(); if (! $mybool)
$numref = ""; {
$numref = $obj->getNumRef($soc,$this,$mode); dol_print_error('',"Failed to include file ".$file);
return '';
}
if ($numref != "") $obj = new $classname();
{ $numref = "";
return $numref; $numref = $obj->getNextValue($soc,$this,$mode);
if ($numref != "")
{
return $numref;
}
else
{
dol_print_error($db,"Facture::getNextNumRef ".$obj->error);
return "";
}
} }
else else
{ {
//dol_print_error($db,get_class($this)."::getNextNumRef ".$obj->error); $langs->load("errors");
return false; print $langs->trans("Error")." ".$langs->trans("ErrorModuleSetupNotComplete");
return "";
} }
} }

View File

@ -92,23 +92,31 @@ class Contrat extends CommonObject
global $db, $langs, $conf; global $db, $langs, $conf;
$langs->load("contracts"); $langs->load("contracts");
$dir = DOL_DOCUMENT_ROOT . "/core/modules/contract"; if (!empty($conf->global->CONTRACT_ADDON))
if (empty($conf->global->CONTRACT_ADDON))
{ {
$conf->global->CONTRACT_ADDON='mod_contract_serpis'; $mybool = false;
}
$file = $conf->global->CONTRACT_ADDON.".php"; $file = $conf->global->CONTRACT_ADDON.".php";
$classname = $conf->global->CONTRACT_ADDON;
// Chargement de la classe de numerotation // Include file with class
$classname = $conf->global->CONTRACT_ADDON; $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
foreach ($dirmodels as $reldir) {
$dir = dol_buildpath($reldir."core/modules/contract/");
// Load file with numbering class (if found)
$mybool|=@include_once $dir.$file;
}
if (! $mybool)
{
dol_print_error('',"Failed to include file ".$file);
return '';
}
$result=include_once $dir.'/'.$file;
if ($result)
{
$obj = new $classname(); $obj = new $classname();
$numref = ""; $numref = "";
$numref = $obj->getNextValue($soc,$this); $numref = $obj->getNextValue($soc,$this);
@ -118,15 +126,17 @@ class Contrat extends CommonObject
} }
else else
{ {
$this->error = $obj->error;
dol_print_error($db,get_class($this)."::getNextValue ".$obj->error); dol_print_error($db,get_class($this)."::getNextValue ".$obj->error);
return ""; return "";
} }
} }
else else
{ {
print $langs->trans("Error")." ".$langs->trans("Error_CONTRACT_ADDON_NotDefined"); $langs->load("errors");
print $langs->trans("Error")." ".$langs->trans("ErrorModuleSetupNotComplete");
return ""; return "";
} }
} }
/** /**

View File

@ -119,21 +119,30 @@ class Expedition extends CommonObject
global $db, $langs, $conf; global $db, $langs, $conf;
$langs->load("sendings"); $langs->load("sendings");
$dir = DOL_DOCUMENT_ROOT . "/core/modules/expedition"; if (!empty($conf->global->EXPEDITION_ADDON_NUMBER))
if (empty($conf->global->EXPEDITION_ADDON_NUMBER))
{ {
$conf->global->EXPEDITION_ADDON_NUMBER='mod_expedition_safor'; $mybool = false;
}
$file = $conf->global->EXPEDITION_ADDON_NUMBER.".php"; $file = $conf->global->EXPEDITION_ADDON_NUMBER.".php";
$classname = $conf->global->EXPEDITION_ADDON_NUMBER;
// Chargement de la classe de numerotation // Include file with class
$classname = $conf->global->EXPEDITION_ADDON_NUMBER; $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
foreach ($dirmodels as $reldir) {
$dir = dol_buildpath($reldir."core/modules/expedition/");
// Load file with numbering class (if found)
$mybool|=@include_once $dir.$file;
}
if (! $mybool)
{
dol_print_error('',"Failed to include file ".$file);
return '';
}
$result=include_once $dir.'/'.$file;
if ($result)
{
$obj = new $classname(); $obj = new $classname();
$numref = ""; $numref = "";
$numref = $obj->getNextValue($soc,$this); $numref = $obj->getNextValue($soc,$this);
@ -147,12 +156,12 @@ class Expedition extends CommonObject
dol_print_error($db,get_class($this)."::getNextNumRef ".$obj->error); dol_print_error($db,get_class($this)."::getNextNumRef ".$obj->error);
return ""; return "";
} }
} }
else else
{ {
print $langs->trans("Error")." ".$langs->trans("Error_EXPEDITION_ADDON_NUMBER_NotDefined"); print $langs->trans("Error")." ".$langs->trans("Error_EXPEDITION_ADDON_NUMBER_NotDefined");
return ""; return "";
} }
} }
/** /**

View File

@ -599,25 +599,33 @@ class Fichinter extends CommonObject
global $conf, $db, $langs; global $conf, $db, $langs;
$langs->load("interventions"); $langs->load("interventions");
$dir = DOL_DOCUMENT_ROOT . "/core/modules/fichinter/";
if (! empty($conf->global->FICHEINTER_ADDON)) if (! empty($conf->global->FICHEINTER_ADDON))
{ {
$file = $conf->global->FICHEINTER_ADDON.".php"; $mybool = false;
$classname = $conf->global->FICHEINTER_ADDON;
if (! file_exists($dir.$file)) $file = "mod_".$conf->global->FICHEINTER_ADDON.".php";
{ $classname = "mod_".$conf->global->FICHEINTER_ADDON;
$file='mod_'.$file;
$classname='mod_'.$classname; // Include file with class
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
foreach ($dirmodels as $reldir) {
$dir = dol_buildpath($reldir."core/modules/fichinter/");
// Load file with numbering class (if found)
$mybool|=@include_once $dir.$file;
} }
// Chargement de la classe de numerotation if (! $mybool)
require_once $dir.$file; {
dol_print_error('',"Failed to include file ".$file);
return '';
}
$obj = new $classname(); $obj = new $classname();
$numref = ""; $numref = "";
$numref = $obj->getNumRef($soc,$this); $numref = $obj->getNextValue($soc,$this);
if ( $numref != "") if ( $numref != "")
{ {
@ -631,6 +639,7 @@ class Fichinter extends CommonObject
} }
else else
{ {
$langs->load("errors");
print $langs->trans("Error")." ".$langs->trans("Error_FICHEINTER_ADDON_NotDefined"); print $langs->trans("Error")." ".$langs->trans("Error_FICHEINTER_ADDON_NotDefined");
return ""; return "";
} }

View File

@ -551,44 +551,50 @@ class CommandeFournisseur extends CommonOrder
global $db, $langs, $conf; global $db, $langs, $conf;
$langs->load("orders"); $langs->load("orders");
$dir = DOL_DOCUMENT_ROOT .'/core/modules/supplier_order/';
if (! empty($conf->global->COMMANDE_SUPPLIER_ADDON_NUMBER)) if (! empty($conf->global->COMMANDE_SUPPLIER_ADDON_NUMBER))
{ {
$mybool = false;
$file = $conf->global->COMMANDE_SUPPLIER_ADDON_NUMBER.'.php'; $file = $conf->global->COMMANDE_SUPPLIER_ADDON_NUMBER.'.php';
$classname=$conf->global->COMMANDE_SUPPLIER_ADDON_NUMBER;
if (is_readable($dir.'/'.$file)) // Include file with class
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
foreach ($dirmodels as $reldir) {
$dir = dol_buildpath($reldir."core/modules/supplier_order/");
// Load file with numbering class (if found)
$mybool|=@include_once $dir.$file;
}
if (! $mybool)
{ {
// Definition du nom de modele de numerotation de commande fournisseur dol_print_error('',"Failed to include file ".$file);
$modName=$conf->global->COMMANDE_SUPPLIER_ADDON_NUMBER; return '';
require_once $dir.'/'.$file; }
// Recuperation de la nouvelle reference $obj = new $classname();
$objMod = new $modName($this->db); $numref = "";
$numref = $obj->getNextValue($soc,$this);
$numref = ""; if ( $numref != "")
$numref = $objMod->commande_get_num($soc,$this); {
return $numref;
if ( $numref != "")
{
return $numref;
}
else
{
dol_print_error($db, get_class($this)."::getNextNumRef ".$obj->error);
return -1;
}
} }
else else
{ {
print $langs->trans("Error")." ".$langs->trans("Error_FailedToLoad_COMMANDE_SUPPLIER_ADDON_File",$conf->global->COMMANDE_SUPPLIER_ADDON_NUMBER); $this->error = $obj->error;
return -2; dol_print_error($db, get_class($this)."::getNextNumRef ".$obj->error);
return "";
} }
} }
else else
{ {
print $langs->trans("Error")." ".$langs->trans("Error_COMMANDE_SUPPLIER_ADDON_NotDefined"); $langs->load("errors");
return -3; print $langs->trans("Error")." ".$langs->trans("ErrorModuleSetupNotComplete");
return "";
} }
} }

View File

@ -1497,10 +1497,14 @@ class FactureFournisseur extends CommonInvoice
$file = $conf->global->INVOICE_SUPPLIER_ADDON_NUMBER.".php"; $file = $conf->global->INVOICE_SUPPLIER_ADDON_NUMBER.".php";
$classname = $conf->global->INVOICE_SUPPLIER_ADDON_NUMBER; $classname = $conf->global->INVOICE_SUPPLIER_ADDON_NUMBER;
// Include file with class // Include file with class
foreach ($conf->file->dol_document_root as $dirroot) $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
{
$dir = $dirroot."/core/modules/supplier_invoice/"; foreach ($dirmodels as $reldir) {
$dir = dol_buildpath($reldir."core/modules/supplier_invoice/");
// Load file with numbering class (if found) // Load file with numbering class (if found)
$mybool|=@include_once $dir.$file; $mybool|=@include_once $dir.$file;
} }