Fix: Usage of alternate document root works with invoice numbering modules.

This commit is contained in:
Laurent Destailleur 2009-11-06 18:38:35 +00:00
parent a873104877
commit 40b38892b5
3 changed files with 302 additions and 279 deletions

View File

@ -248,14 +248,22 @@ print '</tr>'."\n";
clearstatcache(); clearstatcache();
$handle=opendir($dir);
$var=true; $var=true;
foreach ($conf->file->dol_document_root as $dirroot)
{
$dir = $dirroot . "/includes/modules/facture/";
if (is_dir($dir))
{
$handle = opendir($dir);
if ($handle)
{
while (($file = readdir($handle))!==false) while (($file = readdir($handle))!==false)
{ {
if (is_dir($dir.$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS') if (is_dir($dir.$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')
{ {
$filebis = $file."/".$file.".modules.php"; $filebis = $file."/".$file.".modules.php";
if (is_readable($dir.$filebis)) if (is_readable($dir.$filebis))
{ {
// Chargement de la classe de num<75>rotation // Chargement de la classe de num<75>rotation
@ -338,6 +346,9 @@ while (($file = readdir($handle))!==false)
} }
} }
closedir($handle); closedir($handle);
}
}
}
print '</table>'; print '</table>';

View File

@ -186,7 +186,6 @@ if ($_GET["action"] == 'setmod')
llxHeader('',$langs->trans("PropalSetup")); llxHeader('',$langs->trans("PropalSetup"));
$dir = "../includes/modules/propale/";
$html=new Form($db); $html=new Form($db);
@ -210,17 +209,23 @@ print '</tr>'."\n";
clearstatcache(); clearstatcache();
$var=true;
foreach ($conf->file->dol_document_root as $dirroot)
{
$dir = $dirroot . "/includes/modules/propale/";
if (is_dir($dir))
{
$handle = opendir($dir); $handle = opendir($dir);
if ($handle) if ($handle)
{ {
$var=true;
while (($file = readdir($handle))!==false) while (($file = readdir($handle))!==false)
{ {
if (substr($file, 0, 12) == 'mod_propale_' && substr($file, strlen($file)-3, 3) == 'php') if (substr($file, 0, 12) == 'mod_propale_' && substr($file, strlen($file)-3, 3) == 'php')
{ {
$file = substr($file, 0, strlen($file)-4); $file = substr($file, 0, strlen($file)-4);
require_once(DOL_DOCUMENT_ROOT ."/includes/modules/propale/".$file.".php"); require_once($dir.$file.".php");
$module = new $file; $module = new $file;
@ -280,6 +285,8 @@ if ($handle)
} }
closedir($handle); closedir($handle);
} }
}
}
print "</table><br>\n"; print "</table><br>\n";

View File

@ -2166,18 +2166,23 @@ class Facture extends CommonObject
*/ */
function getNextNumRef($soc) function getNextNumRef($soc)
{ {
global $db, $langs; global $conf, $db, $langs;
$langs->load("bills"); $langs->load("bills");
$dir = DOL_DOCUMENT_ROOT . "/includes/modules/facture/";
if (defined("FACTURE_ADDON") && FACTURE_ADDON) if (defined("FACTURE_ADDON") && FACTURE_ADDON)
{ {
$file = FACTURE_ADDON."/".FACTURE_ADDON.".modules.php"; $file = FACTURE_ADDON."/".FACTURE_ADDON.".modules.php";
// Chargement de la classe de numerotation
$classname = "mod_facture_".FACTURE_ADDON; $classname = "mod_facture_".FACTURE_ADDON;
require_once($dir.$file);
// Include file with class
$mybool=false;
foreach ($conf->file->dol_document_root as $dirroot)
{
$dir = $dirroot."/includes/modules/facture/";
// Load file with numbering class (if found)
$mybool|=@include_once($dir.$file);
}
if (! $mybool) dol_print_error('',"Failed to include file ".$file);
$obj = new $classname(); $obj = new $classname();