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

@ -37,7 +37,7 @@ $langs->load("bills");
$langs->load("other"); $langs->load("other");
if (!$user->admin) if (!$user->admin)
accessforbidden(); accessforbidden();
$typeconst=array('yesno','texte','chaine'); $typeconst=array('yesno','texte','chaine');
$dir = DOL_DOCUMENT_ROOT."/includes/modules/facture/"; $dir = DOL_DOCUMENT_ROOT."/includes/modules/facture/";
@ -94,108 +94,108 @@ if ($_GET["action"] == 'specimen')
if ($_GET["action"] == 'set') if ($_GET["action"] == 'set')
{ {
$type='invoice'; $type='invoice';
$sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES ('".$_GET["value"]."','".$type."',".$conf->entity.")"; $sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES ('".$_GET["value"]."','".$type."',".$conf->entity.")";
if ($db->query($sql)) if ($db->query($sql))
{ {
} }
} }
if ($_GET["action"] == 'del') if ($_GET["action"] == 'del')
{ {
$type='invoice'; $type='invoice';
$sql = "DELETE FROM ".MAIN_DB_PREFIX."document_model"; $sql = "DELETE FROM ".MAIN_DB_PREFIX."document_model";
$sql.= " WHERE nom = '".$_GET["value"]; $sql.= " WHERE nom = '".$_GET["value"];
$sql.= " AND type = '".$type."'"; $sql.= " AND type = '".$type."'";
$sql.= " AND entity = ".$conf->entity; $sql.= " AND entity = ".$conf->entity;
if ($db->query($sql)) if ($db->query($sql))
{ {
} }
} }
if ($_GET["action"] == 'setdoc') if ($_GET["action"] == 'setdoc')
{ {
$db->begin(); $db->begin();
if (dolibarr_set_const($db, "FACTURE_ADDON_PDF",$_GET["value"],'chaine',0,'',$conf->entity)) if (dolibarr_set_const($db, "FACTURE_ADDON_PDF",$_GET["value"],'chaine',0,'',$conf->entity))
{ {
$conf->global->FACTURE_ADDON_PDF = $_GET["value"]; $conf->global->FACTURE_ADDON_PDF = $_GET["value"];
} }
// On active le modele // On active le modele
$type='invoice'; $type='invoice';
$sql_del = "DELETE FROM ".MAIN_DB_PREFIX."document_model"; $sql_del = "DELETE FROM ".MAIN_DB_PREFIX."document_model";
$sql_del.= " WHERE nom = '".$_GET["value"]; $sql_del.= " WHERE nom = '".$_GET["value"];
$sql_del.= " AND type = '".$type."'"; $sql_del.= " AND type = '".$type."'";
$sql_del.= " AND entity = ".$conf->entity; $sql_del.= " AND entity = ".$conf->entity;
$result1=$db->query($sql_del); $result1=$db->query($sql_del);
$sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom,type,entity) VALUES ('".$_GET["value"]."','".$type."',".$conf->entity.")"; $sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom,type,entity) VALUES ('".$_GET["value"]."','".$type."',".$conf->entity.")";
$result2=$db->query($sql); $result2=$db->query($sql);
if ($result1 && $result2) if ($result1 && $result2)
{ {
$db->commit(); $db->commit();
} }
else else
{ {
$db->rollback(); $db->rollback();
} }
} }
if ($_GET["action"] == 'setmod') if ($_GET["action"] == 'setmod')
{ {
// TODO Verifier si module numerotation choisi peut etre active // TODO Verifier si module numerotation choisi peut etre active
// par appel methode canBeActivated // par appel methode canBeActivated
dolibarr_set_const($db, "FACTURE_ADDON",$_GET["value"],'chaine',0,'',$conf->entity); dolibarr_set_const($db, "FACTURE_ADDON",$_GET["value"],'chaine',0,'',$conf->entity);
} }
if ($_POST["action"] == 'setribchq') if ($_POST["action"] == 'setribchq')
{ {
dolibarr_set_const($db, "FACTURE_RIB_NUMBER",$_POST["rib"],'chaine',0,'',$conf->entity); dolibarr_set_const($db, "FACTURE_RIB_NUMBER",$_POST["rib"],'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "FACTURE_CHQ_NUMBER",$_POST["chq"],'chaine',0,'',$conf->entity); dolibarr_set_const($db, "FACTURE_CHQ_NUMBER",$_POST["chq"],'chaine',0,'',$conf->entity);
} }
if ($_POST["action"] == 'set_FACTURE_DRAFT_WATERMARK') if ($_POST["action"] == 'set_FACTURE_DRAFT_WATERMARK')
{ {
dolibarr_set_const($db, "FACTURE_DRAFT_WATERMARK",trim($_POST["FACTURE_DRAFT_WATERMARK"]),'chaine',0,'',$conf->entity); dolibarr_set_const($db, "FACTURE_DRAFT_WATERMARK",trim($_POST["FACTURE_DRAFT_WATERMARK"]),'chaine',0,'',$conf->entity);
} }
if ($_POST["action"] == 'set_FACTURE_FREE_TEXT') if ($_POST["action"] == 'set_FACTURE_FREE_TEXT')
{ {
dolibarr_set_const($db, "FACTURE_FREE_TEXT",$_POST["FACTURE_FREE_TEXT"],'chaine',0,'',$conf->entity); dolibarr_set_const($db, "FACTURE_FREE_TEXT",$_POST["FACTURE_FREE_TEXT"],'chaine',0,'',$conf->entity);
} }
if ($_POST["action"] == 'setforcedate') if ($_POST["action"] == 'setforcedate')
{ {
dolibarr_set_const($db, "FAC_FORCE_DATE_VALIDATION",$_POST["forcedate"],'chaine',0,'',$conf->entity); dolibarr_set_const($db, "FAC_FORCE_DATE_VALIDATION",$_POST["forcedate"],'chaine',0,'',$conf->entity);
} }
if ($_POST["action"] == 'set_enable_editdelete') if ($_POST["action"] == 'set_enable_editdelete')
{ {
dolibarr_set_const($db, "FACTURE_ENABLE_EDITDELETE",$_POST["enable_editdelete"],'chaine',0,'',$conf->entity); dolibarr_set_const($db, "FACTURE_ENABLE_EDITDELETE",$_POST["enable_editdelete"],'chaine',0,'',$conf->entity);
} }
if ($_POST["action"] == 'set_use_bill_contact_as_recipient') if ($_POST["action"] == 'set_use_bill_contact_as_recipient')
{ {
dolibarr_set_const($db, "FACTURE_USE_BILL_CONTACT_AS_RECIPIENT",$_POST["use_bill_contact_as_recipient"],'chaine',0,'',$conf->entity); dolibarr_set_const($db, "FACTURE_USE_BILL_CONTACT_AS_RECIPIENT",$_POST["use_bill_contact_as_recipient"],'chaine',0,'',$conf->entity);
} }
if ($_POST["action"] == 'update' || $_POST["action"] == 'add') if ($_POST["action"] == 'update' || $_POST["action"] == 'add')
{ {
if (! dolibarr_set_const($db, $_POST["constname"],$_POST["constvalue"],$typeconst[$_POST["consttype"]],0,isset($_POST["constnote"])?$_POST["constnote"]:'',$conf->entity)); if (! dolibarr_set_const($db, $_POST["constname"],$_POST["constvalue"],$typeconst[$_POST["consttype"]],0,isset($_POST["constnote"])?$_POST["constnote"]:'',$conf->entity));
{ {
dol_print_error($db); dol_print_error($db);
} }
} }
if ($_GET["action"] == 'delete') if ($_GET["action"] == 'delete')
{ {
if (! dolibarr_del_const($db, $_GET["rowid"],$conf->entity)); if (! dolibarr_del_const($db, $_GET["rowid"],$conf->entity));
{ {
dol_print_error($db); dol_print_error($db);
} }
} }
// defini les constantes du modele pluton // defini les constantes du modele pluton
@ -248,96 +248,107 @@ print '</tr>'."\n";
clearstatcache(); clearstatcache();
$handle=opendir($dir);
$var=true; $var=true;
while (($file = readdir($handle))!==false) foreach ($conf->file->dol_document_root as $dirroot)
{ {
if (is_dir($dir.$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS') $dir = $dirroot . "/includes/modules/facture/";
{
$filebis = $file."/".$file.".modules.php"; if (is_dir($dir))
if (is_readable($dir.$filebis)) {
$handle = opendir($dir);
if ($handle)
{ {
// Chargement de la classe de num<75>rotation while (($file = readdir($handle))!==false)
require_once($dir.$filebis); {
$classname = "mod_facture_".$file; if (is_dir($dir.$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')
$module = new $classname($db);
// Show modules according to features level
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue;
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue;
if ($module->isEnabled())
{
$var = !$var;
print '<tr '.$bc[$var].'><td width="100">';
echo "$file";
print "</td><td>\n";
print $module->info();
print '</td>';
// Affiche example
print '<td nowrap="nowrap">'.$module->getExample().'</td>';
print '<td align="center">';
if ($conf->global->FACTURE_ADDON == "$file")
{
print img_tick($langs->trans("Activated"));
}
else
{
print '<a href="'.$_SERVER["PHP_SELF"].'?action=setmod&amp;value='.$file.'" alt="'.$langs->trans("Default").'">'.$langs->trans("Default").'</a>';
}
print '</td>';
$facture=new Facture($db);
$facture->initAsSpecimen();
// Example for standard invoice
$htmltooltip='';
$htmltooltip.=''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
$facture->type=0;
$nextval=$module->getNextValue($mysoc,$facture);
if ("$nextval" != $langs->trans("NotAvailable")) // Keep " on nextval
{ {
$htmltooltip.=$langs->trans("NextValueForInvoices").': '; $filebis = $file."/".$file.".modules.php";
if ($nextval)
if (is_readable($dir.$filebis))
{ {
$htmltooltip.=$nextval.'<br>'; // Chargement de la classe de num<75>rotation
} require_once($dir.$filebis);
else $classname = "mod_facture_".$file;
{ $module = new $classname($db);
$htmltooltip.=$langs->trans($module->error).'<br>';
// Show modules according to features level
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue;
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue;
if ($module->isEnabled())
{
$var = !$var;
print '<tr '.$bc[$var].'><td width="100">';
echo "$file";
print "</td><td>\n";
print $module->info();
print '</td>';
// Affiche example
print '<td nowrap="nowrap">'.$module->getExample().'</td>';
print '<td align="center">';
if ($conf->global->FACTURE_ADDON == "$file")
{
print img_tick($langs->trans("Activated"));
}
else
{
print '<a href="'.$_SERVER["PHP_SELF"].'?action=setmod&amp;value='.$file.'" alt="'.$langs->trans("Default").'">'.$langs->trans("Default").'</a>';
}
print '</td>';
$facture=new Facture($db);
$facture->initAsSpecimen();
// Example for standard invoice
$htmltooltip='';
$htmltooltip.=''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
$facture->type=0;
$nextval=$module->getNextValue($mysoc,$facture);
if ("$nextval" != $langs->trans("NotAvailable")) // Keep " on nextval
{
$htmltooltip.=$langs->trans("NextValueForInvoices").': ';
if ($nextval)
{
$htmltooltip.=$nextval.'<br>';
}
else
{
$htmltooltip.=$langs->trans($module->error).'<br>';
}
}
// Example for credit invoice
$facture->type=2;
$nextval=$module->getNextValue($mysoc,$facture);
if ("$nextval" != $langs->trans("NotAvailable")) // Keep " on nextval
{
$htmltooltip.=$langs->trans("NextValueForCreditNotes").': ';
if ($nextval)
{
$htmltooltip.=$nextval;
}
else
{
$htmltooltip.=$langs->trans($module->error);
}
}
print '<td align="center">';
print $html->textwithpicto('',$htmltooltip,1,0);
print '</td>';
print "</tr>\n";
}
} }
} }
// Example for credit invoice }
$facture->type=2; closedir($handle);
$nextval=$module->getNextValue($mysoc,$facture);
if ("$nextval" != $langs->trans("NotAvailable")) // Keep " on nextval
{
$htmltooltip.=$langs->trans("NextValueForCreditNotes").': ';
if ($nextval)
{
$htmltooltip.=$nextval;
}
else
{
$htmltooltip.=$langs->trans($module->error);
}
}
print '<td align="center">';
print $html->textwithpicto('',$htmltooltip,1,0);
print '</td>';
print "</tr>\n";
}
} }
} }
} }
closedir($handle);
print '</table>'; print '</table>';
@ -387,20 +398,20 @@ $handle=opendir($dir);
$var=True; $var=True;
while (($file = readdir($handle))!==false) while (($file = readdir($handle))!==false)
{ {
if (preg_match('/\.modules\.php$/i',$file) && substr($file,0,4) == 'pdf_') if (preg_match('/\.modules\.php$/i',$file) && substr($file,0,4) == 'pdf_')
{ {
$var = !$var; $var = !$var;
$name = substr($file, 4, strlen($file) -16); $name = substr($file, 4, strlen($file) -16);
$classname = substr($file, 0, strlen($file) -12); $classname = substr($file, 0, strlen($file) -12);
print '<tr '.$bc[$var].'><td width="100">'; print '<tr '.$bc[$var].'><td width="100">';
echo "$name"; echo "$name";
print "</td><td>\n"; print "</td><td>\n";
require_once($dir.$file); require_once($dir.$file);
$module = new $classname($db); $module = new $classname($db);
print $module->description; print $module->description;
print '</td>'; print '</td>';
// Active // Active
if (in_array($name, $def)) if (in_array($name, $def))
@ -438,28 +449,28 @@ while (($file = readdir($handle))!==false)
print '</td>'; print '</td>';
// Info // Info
$htmltooltip = ''.$langs->trans("Name").': '.$module->name; $htmltooltip = ''.$langs->trans("Name").': '.$module->name;
$htmltooltip.='<br>'.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown")); $htmltooltip.='<br>'.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown"));
$htmltooltip.='<br>'.$langs->trans("Height").'/'.$langs->trans("Width").': '.$module->page_hauteur.'/'.$module->page_largeur; $htmltooltip.='<br>'.$langs->trans("Height").'/'.$langs->trans("Width").': '.$module->page_hauteur.'/'.$module->page_largeur;
$htmltooltip.='<br><br><u>'.$langs->trans("FeaturesSupported").':</u>'; $htmltooltip.='<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
$htmltooltip.='<br>'.$langs->trans("Logo").': '.yn($module->option_logo,1,1); $htmltooltip.='<br>'.$langs->trans("Logo").': '.yn($module->option_logo,1,1);
$htmltooltip.='<br>'.$langs->trans("PaymentMode").': '.yn($module->option_modereg,1,1); $htmltooltip.='<br>'.$langs->trans("PaymentMode").': '.yn($module->option_modereg,1,1);
$htmltooltip.='<br>'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg,1,1); $htmltooltip.='<br>'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg,1,1);
$htmltooltip.='<br>'.$langs->trans("Escompte").': '.yn($module->option_escompte,1,1); $htmltooltip.='<br>'.$langs->trans("Escompte").': '.yn($module->option_escompte,1,1);
$htmltooltip.='<br>'.$langs->trans("CreditNote").': '.yn($module->option_credit_note,1,1); $htmltooltip.='<br>'.$langs->trans("CreditNote").': '.yn($module->option_credit_note,1,1);
$htmltooltip.='<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang,1,1); $htmltooltip.='<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang,1,1);
$htmltooltip.='<br>'.$langs->trans("WatermarkOnDraftInvoices").': '.yn($module->option_draft_watermark,1,1); $htmltooltip.='<br>'.$langs->trans("WatermarkOnDraftInvoices").': '.yn($module->option_draft_watermark,1,1);
print '<td align="center">'; print '<td align="center">';
print $html->textwithpicto('',$htmltooltip,1,0); print $html->textwithpicto('',$htmltooltip,1,0);
print '</td>'; print '</td>';
print '<td align="center">'; print '<td align="center">';
print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"),'bill').'</a>'; print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"),'bill').'</a>';
print '</td>'; print '</td>';
print "</tr>\n"; print "</tr>\n";
} }
} }
closedir($handle); closedir($handle);
@ -490,39 +501,39 @@ print "<td>".$langs->trans("SuggestPaymentByRIBOnAccount")."</td>";
print "<td>"; print "<td>";
if ($conf->banque->enabled) if ($conf->banque->enabled)
{ {
$sql = "SELECT rowid, label"; $sql = "SELECT rowid, label";
$sql.= " FROM ".MAIN_DB_PREFIX."bank_account"; $sql.= " FROM ".MAIN_DB_PREFIX."bank_account";
$sql.= " WHERE clos = 0"; $sql.= " WHERE clos = 0";
$sql.= " AND courant = 1"; $sql.= " AND courant = 1";
$sql.= " AND entity = ".$conf->entity; $sql.= " AND entity = ".$conf->entity;
$resql=$db->query($sql); $resql=$db->query($sql);
if ($resql) if ($resql)
{ {
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
$i = 0; $i = 0;
if ($num > 0) { if ($num > 0) {
print "<select name=\"rib\">"; print "<select name=\"rib\">";
print '<option value="0">'.$langs->trans("DoNotSuggestPaymentMode").'</option>'; print '<option value="0">'.$langs->trans("DoNotSuggestPaymentMode").'</option>';
while ($i < $num) while ($i < $num)
{ {
$var=!$var; $var=!$var;
$row = $db->fetch_row($resql); $row = $db->fetch_row($resql);
print '<option value="'.$row[0].'"'; print '<option value="'.$row[0].'"';
print $conf->global->FACTURE_RIB_NUMBER == $row[0] ? ' selected="true"':''; print $conf->global->FACTURE_RIB_NUMBER == $row[0] ? ' selected="true"':'';
print '>'.$row[1].'</option>'; print '>'.$row[1].'</option>';
$i++; $i++;
} }
print "</select>"; print "</select>";
} else { } else {
print "<i>".$langs->trans("NoActiveBankAccountDefined")."</i>"; print "<i>".$langs->trans("NoActiveBankAccountDefined")."</i>";
} }
} }
} }
else else
{ {
print $langs->trans("BankModuleNotActive"); print $langs->trans("BankModuleNotActive");
} }
print "</td></tr>"; print "</td></tr>";
$var=!$var; $var=!$var;
@ -542,18 +553,18 @@ $var=True;
$resql=$db->query($sql); $resql=$db->query($sql);
if ($resql) if ($resql)
{ {
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
$i = 0; $i = 0;
while ($i < $num) while ($i < $num)
{ {
$var=!$var; $var=!$var;
$row = $db->fetch_row($resql); $row = $db->fetch_row($resql);
print '<option value="'.$row[0].'"'; print '<option value="'.$row[0].'"';
print $conf->global->FACTURE_CHQ_NUMBER == $row[0] ? ' selected="true"':''; print $conf->global->FACTURE_CHQ_NUMBER == $row[0] ? ' selected="true"':'';
print '>'.$langs->trans("OwnerOfBankAccount",$row[1]).'</option>'; print '>'.$langs->trans("OwnerOfBankAccount",$row[1]).'</option>';
$i++; $i++;
} }
} }
print "</select>"; print "</select>";
@ -602,19 +613,19 @@ print "</td></tr>\n";
print '</form>'; print '</form>';
/* /*
$var=! $var; $var=! $var;
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">'; print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="set_use_bill_contact_as_recipient">'; print '<input type="hidden" name="action" value="set_use_bill_contact_as_recipient">';
print '<tr '.$bc[$var].'><td>'; print '<tr '.$bc[$var].'><td>';
print $langs->trans("UsBillingContactAsIncoiveRecipientIfExist"); print $langs->trans("UsBillingContactAsIncoiveRecipientIfExist");
print '</td><td width="60" align="center">'; print '</td><td width="60" align="center">';
print $html->selectyesno("use_bill_contact_as_recipient",$conf->global->FACTURE_USE_BILL_CONTACT_AS_RECIPIENT,1); print $html->selectyesno("use_bill_contact_as_recipient",$conf->global->FACTURE_USE_BILL_CONTACT_AS_RECIPIENT,1);
print '</td><td align="right">'; print '</td><td align="right">';
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">'; print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
print "</td></tr>\n"; print "</td></tr>\n";
print '</form>'; print '</form>';
*/ */
$var=! $var; $var=! $var;
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">'; print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';

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,75 +209,83 @@ print '</tr>'."\n";
clearstatcache(); clearstatcache();
$handle = opendir($dir); $var=true;
if ($handle) foreach ($conf->file->dol_document_root as $dirroot)
{ {
$var=true; $dir = $dirroot . "/includes/modules/propale/";
while (($file = readdir($handle))!==false)
if (is_dir($dir))
{ {
if (substr($file, 0, 12) == 'mod_propale_' && substr($file, strlen($file)-3, 3) == 'php') $handle = opendir($dir);
if ($handle)
{ {
$file = substr($file, 0, strlen($file)-4); while (($file = readdir($handle))!==false)
require_once(DOL_DOCUMENT_ROOT ."/includes/modules/propale/".$file.".php");
$module = new $file;
// Show modules according to features level
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue;
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue;
if ($module->isEnabled())
{ {
$var=!$var; if (substr($file, 0, 12) == 'mod_propale_' && substr($file, strlen($file)-3, 3) == 'php')
print '<tr '.$bc[$var].'><td>'.$module->nom."</td><td>\n";
print $module->info();
print '</td>';
// Examples
print '<td nowrap="nowrap">'.$module->getExample()."</td>\n";
print '<td align="center">';
if ($conf->global->PROPALE_ADDON == "$file")
{ {
print img_tick($langs->trans("Activated")); $file = substr($file, 0, strlen($file)-4);
}
else
{
print '<a href="'.$_SERVER["PHP_SELF"].'?action=setmod&amp;value='.$file.'" alt="'.$langs->trans("Default").'">'.$langs->trans("Activate").'</a>';
}
print '</td>';
$propale=new Propal($db); require_once($dir.$file.".php");
$propale->initAsSpecimen();
// Info $module = new $file;
$htmltooltip='';
$htmltooltip.=''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>'; // Show modules according to features level
$facture->type=0; if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue;
$nextval=$module->getNextValue($mysoc,$propale); if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue;
if ("$nextval" != $langs->trans("NotAvailable")) // Keep " on nextval
{ if ($module->isEnabled())
$htmltooltip.=''.$langs->trans("NextValue").': ';
if ($nextval)
{ {
$htmltooltip.=$nextval.'<br>'; $var=!$var;
} print '<tr '.$bc[$var].'><td>'.$module->nom."</td><td>\n";
else print $module->info();
{ print '</td>';
$htmltooltip.=$langs->trans($module->error).'<br>';
// Examples
print '<td nowrap="nowrap">'.$module->getExample()."</td>\n";
print '<td align="center">';
if ($conf->global->PROPALE_ADDON == "$file")
{
print img_tick($langs->trans("Activated"));
}
else
{
print '<a href="'.$_SERVER["PHP_SELF"].'?action=setmod&amp;value='.$file.'" alt="'.$langs->trans("Default").'">'.$langs->trans("Activate").'</a>';
}
print '</td>';
$propale=new Propal($db);
$propale->initAsSpecimen();
// Info
$htmltooltip='';
$htmltooltip.=''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
$facture->type=0;
$nextval=$module->getNextValue($mysoc,$propale);
if ("$nextval" != $langs->trans("NotAvailable")) // Keep " on nextval
{
$htmltooltip.=''.$langs->trans("NextValue").': ';
if ($nextval)
{
$htmltooltip.=$nextval.'<br>';
}
else
{
$htmltooltip.=$langs->trans($module->error).'<br>';
}
}
print '<td align="center">';
print $html->textwithpicto('',$htmltooltip,1,0);
print '</td>';
print "</tr>\n";
} }
} }
print '<td align="center">';
print $html->textwithpicto('',$htmltooltip,1,0);
print '</td>';
print "</tr>\n";
} }
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();
@ -2185,14 +2190,14 @@ class Facture extends CommonObject
$numref = $obj->getNumRef($soc,$this); $numref = $obj->getNumRef($soc,$this);
if ( $numref != "") if ( $numref != "")
{ {
return $numref; return $numref;
} }
else else
{ {
dol_print_error($db,"Facture::getNextNumRef ".$obj->error); dol_print_error($db,"Facture::getNextNumRef ".$obj->error);
return ""; return "";
} }
} }
else else
{ {