Fixed loading of external numeration modules in Contrat, Commande, Facture, Contrat, Expedition, Fichinter, CommandeFournisseur and uniformized code
This commit is contained in:
parent
ed839114ab
commit
41e01a22a3
@ -137,9 +137,12 @@ 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) {
|
||||||
|
|
||||||
|
$dir = dol_buildpath($reldir."core/modules/commande/");
|
||||||
|
|
||||||
// Load file with numbering class (if found)
|
// Load file with numbering class (if found)
|
||||||
$mybool|=@include_once $dir.$file;
|
$mybool|=@include_once $dir.$file;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2504,14 +2504,20 @@ 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';
|
||||||
|
|
||||||
|
if (! empty($conf->global->FACTURE_ADDON))
|
||||||
|
{
|
||||||
$mybool=false;
|
$mybool=false;
|
||||||
|
|
||||||
$file = $conf->global->FACTURE_ADDON.".php";
|
$file = $conf->global->FACTURE_ADDON.".php";
|
||||||
$classname = $conf->global->FACTURE_ADDON;
|
$classname = $conf->global->FACTURE_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/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;
|
||||||
}
|
}
|
||||||
@ -2530,7 +2536,6 @@ class Facture extends CommonInvoice
|
|||||||
$mybool|=@include_once $dir.$file;
|
$mybool|=@include_once $dir.$file;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//print "xx".$mybool.$dir.$file."-".$classname;
|
|
||||||
|
|
||||||
if (! $mybool)
|
if (! $mybool)
|
||||||
{
|
{
|
||||||
@ -2540,7 +2545,7 @@ class Facture extends CommonInvoice
|
|||||||
|
|
||||||
$obj = new $classname();
|
$obj = new $classname();
|
||||||
$numref = "";
|
$numref = "";
|
||||||
$numref = $obj->getNumRef($soc,$this,$mode);
|
$numref = $obj->getNextValue($soc,$this,$mode);
|
||||||
|
|
||||||
if ($numref != "")
|
if ($numref != "")
|
||||||
{
|
{
|
||||||
@ -2548,8 +2553,15 @@ class Facture extends CommonInvoice
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//dol_print_error($db,get_class($this)."::getNextNumRef ".$obj->error);
|
dol_print_error($db,"Facture::getNextNumRef ".$obj->error);
|
||||||
return false;
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$langs->load("errors");
|
||||||
|
print $langs->trans("Error")." ".$langs->trans("ErrorModuleSetupNotComplete");
|
||||||
|
return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -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";
|
||||||
|
|
||||||
// Chargement de la classe de numerotation
|
|
||||||
$classname = $conf->global->CONTRACT_ADDON;
|
$classname = $conf->global->CONTRACT_ADDON;
|
||||||
|
|
||||||
$result=include_once $dir.'/'.$file;
|
// Include file with class
|
||||||
if ($result)
|
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
|
||||||
{
|
|
||||||
$obj = new $classname();
|
|
||||||
|
|
||||||
|
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 '';
|
||||||
|
}
|
||||||
|
|
||||||
|
$obj = new $classname();
|
||||||
$numref = "";
|
$numref = "";
|
||||||
$numref = $obj->getNextValue($soc,$this);
|
$numref = $obj->getNextValue($soc,$this);
|
||||||
|
|
||||||
@ -118,13 +126,15 @@ 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 "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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";
|
||||||
|
|
||||||
// Chargement de la classe de numerotation
|
|
||||||
$classname = $conf->global->EXPEDITION_ADDON_NUMBER;
|
$classname = $conf->global->EXPEDITION_ADDON_NUMBER;
|
||||||
|
|
||||||
$result=include_once $dir.'/'.$file;
|
// Include file with class
|
||||||
if ($result)
|
$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 '';
|
||||||
|
}
|
||||||
|
|
||||||
$obj = new $classname();
|
$obj = new $classname();
|
||||||
$numref = "";
|
$numref = "";
|
||||||
$numref = $obj->getNextValue($soc,$this);
|
$numref = $obj->getNextValue($soc,$this);
|
||||||
|
|||||||
@ -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))
|
||||||
{
|
{
|
||||||
|
$mybool = false;
|
||||||
|
|
||||||
$file = $conf->global->FICHEINTER_ADDON.".php";
|
$file = $conf->global->FICHEINTER_ADDON.".php";
|
||||||
$classname = $conf->global->FICHEINTER_ADDON;
|
$classname = $conf->global->FICHEINTER_ADDON;
|
||||||
if (! file_exists($dir.$file))
|
|
||||||
{
|
// Include file with class
|
||||||
$file='mod_'.$file;
|
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
|
||||||
$classname='mod_'.$classname;
|
|
||||||
|
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 "";
|
||||||
}
|
}
|
||||||
|
|||||||
@ -551,23 +551,33 @@ 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
|
|
||||||
$objMod = new $modName($this->db);
|
|
||||||
|
|
||||||
|
$obj = new $classname();
|
||||||
$numref = "";
|
$numref = "";
|
||||||
$numref = $objMod->commande_get_num($soc,$this);
|
$numref = $obj->getNextValue($soc,$this);
|
||||||
|
|
||||||
if ( $numref != "")
|
if ( $numref != "")
|
||||||
{
|
{
|
||||||
@ -575,20 +585,16 @@ class CommandeFournisseur extends CommonOrder
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
$this->error = $obj->error;
|
||||||
dol_print_error($db, get_class($this)."::getNextNumRef ".$obj->error);
|
dol_print_error($db, get_class($this)."::getNextNumRef ".$obj->error);
|
||||||
return -1;
|
return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
print $langs->trans("Error")." ".$langs->trans("Error_FailedToLoad_COMMANDE_SUPPLIER_ADDON_File",$conf->global->COMMANDE_SUPPLIER_ADDON_NUMBER);
|
$langs->load("errors");
|
||||||
return -2;
|
print $langs->trans("Error")." ".$langs->trans("ErrorModuleSetupNotComplete");
|
||||||
}
|
return "";
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
print $langs->trans("Error")." ".$langs->trans("Error_COMMANDE_SUPPLIER_ADDON_NotDefined");
|
|
||||||
return -3;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user