dolibarr/htdocs/main.inc.php3

435 lines
10 KiB
PHP
Raw Normal View History

2002-04-30 12:56:25 +02:00
<?PHP
2003-02-12 01:03:31 +01:00
/* Copyright (C) 2002-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
2002-04-30 12:56:25 +02:00
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
2002-06-26 02:03:47 +02:00
* $Id$
* $Source$
*
2002-04-30 12:56:25 +02:00
*/
2003-08-04 16:48:30 +02:00
define('DOL_VERSION','0.4.1');
2003-06-18 15:56:26 +02:00
if (! include ("conf/conf.php"))
{
2003-06-18 15:59:34 +02:00
print "Votre syst<73>me n'est pas configur<75>, rendez-vous <20> l'url <a href=\"install.php\">install.php</a>";
2003-06-18 15:56:26 +02:00
exit ;
}
2003-04-13 15:09:07 +02:00
2003-06-18 15:56:26 +02:00
define('DOL_DOCUMENT_ROOT', $dolibarr_main_document_root);
if (strtolower(substr($dolibarr_main_url_root, 0, 7)) == 'http://')
{
$uri = substr($dolibarr_main_url_root, 7);
}
if (strtolower(substr($dolibarr_main_url_root, 0, 7)) == 'https:/')
{
$uri = substr($dolibarr_main_url_root, 8);
}
2003-06-18 18:32:23 +02:00
$pos = strstr ($uri, '/');
if ($pos == '/')
{
$pos = '';
}
define('DOL_URL_ROOT', $pos);
//define('DOL_URL_ROOT', $dolibarr_main_url_root);
2003-06-18 15:56:26 +02:00
require (DOL_DOCUMENT_ROOT."/conf/conf.class.php");
2003-06-18 15:56:26 +02:00
/*
* Doit figurer apr<EFBFBD>s l'inclusion de conf.class.php3 pour overider certaines variables, <20> terme conf.class.php3 devra etre un fichier qui ne sera pas modifi<66> par l'utilisateur
*/
2002-04-30 12:56:25 +02:00
$conf = new Conf();
2003-06-18 15:56:26 +02:00
$conf->db->host = $dolibarr_main_db_host;
$conf->db->name = $dolibarr_main_db_name;
$conf->db->user = $dolibarr_main_db_user;
$conf->db->pass = $dolibarr_main_db_pass;
require (DOL_DOCUMENT_ROOT ."/lib/mysql.lib.php3");
require (DOL_DOCUMENT_ROOT ."/lib/functions.inc.php3");
require (DOL_DOCUMENT_ROOT ."/product.class.php3");
require (DOL_DOCUMENT_ROOT ."/user.class.php3");
require (DOL_DOCUMENT_ROOT ."/menu.class.php3");
require (DOL_DOCUMENT_ROOT ."/societe.class.php3");
require (DOL_DOCUMENT_ROOT ."/html.form.class.php");
require (DOL_DOCUMENT_ROOT ."/translate.class.php");
require (DOL_DOCUMENT_ROOT ."/boxes.php");
require (DOL_DOCUMENT_ROOT ."/address.class.php");
require (DOL_DOCUMENT_ROOT ."/notify.class.php");
2003-06-18 15:56:26 +02:00
require (DOL_DOCUMENT_ROOT ."/includes/fpdf/fpdf.php");
define('FPDF_FONTPATH',DOL_DOCUMENT_ROOT .'/includes/fpdf/font/');
2002-04-30 12:56:25 +02:00
$db = new Db();
2002-07-29 12:26:12 +02:00
2002-04-30 12:56:25 +02:00
$user = new User($db);
2002-07-29 12:26:12 +02:00
2002-04-30 12:56:25 +02:00
$user->fetch($GLOBALS["REMOTE_USER"]);
2002-07-29 12:26:12 +02:00
/*
2003-02-27 18:09:50 +01:00
* Definition de toutes les Constantes globales d'envirronement
*
*/
$sql = "SELECT name, value FROM llx_const";
$result = $db->query($sql);
if ($result)
{
2003-03-18 16:11:57 +01:00
$numr = $db->num_rows();
$i = 0;
2003-03-18 16:11:57 +01:00
while ($i < $numr)
{
$objp = $db->fetch_object( $i);
define ("$objp->name", $objp->value);
$i++;
}
}
/*
*
*
*/
2003-03-11 17:25:07 +01:00
2002-05-09 16:57:48 +02:00
$db->close();
2003-02-27 18:09:50 +01:00
2003-03-11 17:25:07 +01:00
/*
* Inclusion de librairies d<EFBFBD>pendantes de param<EFBFBD>tres de conf
*/
if (defined("MAIN_MODULE_FACTURE") && MAIN_MODULE_FACTURE)
2003-03-11 17:25:07 +01:00
{
require (DOL_DOCUMENT_ROOT ."/includes/modules/facture/modules_facture.php");
if (defined("FACTURE_ADDON"))
{
require(DOL_DOCUMENT_ROOT ."/includes/modules/facture/".FACTURE_ADDON."/".FACTURE_ADDON.".modules.php");
}
if (defined("FACTURE_ADDON_PDF"))
{
require(DOL_DOCUMENT_ROOT ."/includes/modules/facture/pdf_".FACTURE_ADDON_PDF.".modules.php");
}
2003-03-11 17:25:07 +01:00
}
if (defined("MAIN_MODULE_PROPALE") && MAIN_MODULE_PROPALE)
{
require (DOL_DOCUMENT_ROOT ."/includes/modules/propale/modules_propale.php");
if (defined("PROPALE_ADDON"))
{
require(DOL_DOCUMENT_ROOT ."/includes/modules/propale/".PROPALE_ADDON."/".PROPALE_ADDON.".modules.php");
}
if (! defined("PROPALE_OUTPUTDIR"))
{
define('PROPALE_OUTPUTDIR', DOL_DOCUMENT_ROOT . "/document/propale/");
}
if (! defined("PROPALE_OUTPUT_URL"))
{
define('PROPALE_OUTPUT_URL', "/document/propale");
}
}
2003-03-11 17:25:07 +01:00
2003-02-27 18:09:50 +01:00
// Modification de quelques variable de conf en fonction des Constantes
/*
* SIZE_LISTE_LIMIT : constante de taille maximale des listes
*/
if (defined("SIZE_LISTE_LIMIT"))
{
$conf->liste_limit=SIZE_LISTE_LIMIT;
}
2003-06-24 17:21:05 +02:00
else
{
$conf->liste_limit=20;
}
2003-07-10 15:00:16 +02:00
if ($user->limite_liste > 0)
2003-06-24 17:21:05 +02:00
{
$conf->liste_limit = $user->limite_liste;
}
2003-02-27 18:09:50 +01:00
if (defined("MAIN_THEME"))
{
$conf->theme=MAIN_THEME;
$conf->css = "theme/".$conf->theme."/".$conf->theme.".css";
}
if (defined("MAIN_MAIL_RESIL"))
{
$conf->adherent->email_resil=MAIN_MAIL_RESIL;
}
if (defined("MAIN_MAIL_RESIL_SUBJECT"))
{
$conf->adherent->email_resil_subject=MAIN_MAIL_RESIL_SUBJECT;
}
if (defined("MAIN_MAIL_VALID"))
{
$conf->adherent->email_valid=MAIN_MAIL_VALID;
}
if (defined("MAIN_MAIL_VALID_SUBJECT"))
{
$conf->adherent->email_valid_subject=MAIN_MAIL_VALID_SUBJECT;
}
if (defined("MAIN_MAIL_EDIT"))
{
$conf->adherent->email_edit=MAIN_MAIL_EDIT;
}
if (defined("MAIN_MAIL_EDIT_SUBJECT"))
{
$conf->adherent->email_edit_subject=MAIN_MAIL_EDIT_SUBJECT;
}
if (defined("MAIN_MAIL_NEW"))
{
$conf->adherent->email_new=MAIN_MAIL_NEW;
}
if (defined("MAIN_MAIL_NEW_SUBJECT"))
{
$conf->adherent->email_new_subject=MAIN_MAIL_NEW_SUBJECT;
}
2003-03-11 17:25:07 +01:00
if (defined("MAIN_MODULE_COMMANDE"))
{
$conf->commande->enabled=MAIN_MODULE_COMMANDE;
}
2003-06-11 15:31:39 +02:00
if (defined("MAIN_MODULE_SOCIETE") && MAIN_MODULE_SOCIETE)
2003-06-10 14:25:52 +02:00
{
$conf->societe = 1 ;
}
2003-03-13 19:27:26 +01:00
if (defined("MAIN_MODULE_COMMERCIAL"))
{
$conf->commercial->enabled=MAIN_MODULE_COMMERCIAL;
}
if (defined("MAIN_MODULE_COMPTABILITE"))
{
$conf->compta->enabled=MAIN_MODULE_COMPTABILITE;
}
if (defined("MAIN_MODULE_DON"))
{
$conf->don->enabled=MAIN_MODULE_DON;
}
if (defined("MAIN_MODULE_FOURNISSEUR"))
{
$conf->fournisseur->enabled=MAIN_MODULE_FOURNISSEUR;
}
2003-06-11 15:31:39 +02:00
if (defined("MAIN_MODULE_FICHEINTER") && MAIN_MODULE_FICHEINTER)
{
2003-06-18 15:56:26 +02:00
require (DOL_DOCUMENT_ROOT ."/includes/modules/fichinter/modules_fichinter.php");
2003-06-11 15:31:39 +02:00
$conf->fichinter->enabled=MAIN_MODULE_FICHEINTER;
}
if (defined("MAIN_MODULE_ADHERENT"))
{
$conf->adherent->enabled=MAIN_MODULE_ADHERENT;
}
2003-03-13 19:27:26 +01:00
if (defined("MAIN_MODULE_PRODUIT"))
{
$conf->produit->enabled=MAIN_MODULE_PRODUIT;
}
if (defined("MAIN_MODULE_BOUTIQUE"))
{
$conf->boutique->enabled=MAIN_MODULE_BOUTIQUE;
}
2003-03-11 23:48:46 +01:00
if (defined("BOUTIQUE_LIVRE"))
{
$conf->boutique->livre->enabled=BOUTIQUE_LIVRE;
}
if (defined("BOUTIQUE_ALBUM"))
{
$conf->boutique->album->enabled=BOUTIQUE_ALBUM;
}
2002-07-29 12:26:12 +02:00
/*
*/
if(!isset($application_lang))
{
2002-07-29 12:26:12 +02:00
$application_lang = "fr";
}
2003-06-18 15:56:26 +02:00
$rtplang = new rtplang(DOL_DOCUMENT_ROOT ."/langs", "en", "en", $application_lang);
2002-07-29 12:26:12 +02:00
$rtplang->debug=1;
/*
*/
2002-05-06 21:10:48 +02:00
$bc[0]="class=\"impair\"";
$bc[1]="class=\"pair\"";
2003-02-12 01:03:31 +01:00
setlocale(LC_TIME, "fr_FR");
2002-04-30 12:56:25 +02:00
2002-12-31 15:10:59 +01:00
/*
* Barre de menu sup<EFBFBD>rieure
*
*
*/
function top_menu($head)
{
2002-07-29 12:26:12 +02:00
global $user, $conf, $rtplang;
print $rtplang->lang_header();
2002-05-04 01:01:45 +02:00
2003-02-27 18:09:50 +01:00
// print "<HTML><HEAD>";
2002-05-04 01:01:45 +02:00
print $head;
2003-02-27 18:09:50 +01:00
// print '<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">';
// print '<BASE href="'.DOL_URL_ROOT.'/">';
2003-06-18 18:28:05 +02:00
print '<LINK REL="stylesheet" TYPE="text/css" HREF="'.DOL_URL_ROOT.'/'.$conf->css.'">';
2002-07-29 12:26:12 +02:00
print "\n";
2003-06-18 16:06:35 +02:00
if (defined("MAIN_TITLE"))
{
print "<title>".MAIN_TITLE."</title>";
}
else
{
print '<title>Dolibarr</title>';
}
2002-07-29 12:26:12 +02:00
print "\n";
2002-05-04 01:01:45 +02:00
print "</HEAD>\n";
2002-05-09 16:57:48 +02:00
print '<BODY TOPMARGIN="0" BOTTOMMARGIN="0" LEFTMARGIN="0" RIGHTMARGIN="0" MARGINHEIGHT="0" MARGINWIDTH="0">';
2003-02-27 18:09:50 +01:00
2002-05-06 21:10:48 +02:00
/*
* Barre superieure
*
*/
2002-05-04 01:01:45 +02:00
2002-12-30 23:50:00 +01:00
print '<TABLE class="topbarre" width="100%">';
2002-05-04 01:01:45 +02:00
2002-12-31 15:10:59 +01:00
print "<tr>";
2003-06-18 16:10:23 +02:00
print '<td width="15%" class="menu" align="center"><A class="menu" href="'.DOL_URL_ROOT.'/">Accueil</A></TD>';
2002-05-04 01:01:45 +02:00
if (!defined(MAIN_MENU_BARRETOP))
{
define("MAIN_MENU_BARRETOP","default.php");
}
2002-05-04 01:01:45 +02:00
2003-06-18 15:56:26 +02:00
require(DOL_DOCUMENT_ROOT ."/includes/menus/barre_top/".MAIN_MENU_BARRETOP);
2002-05-04 01:01:45 +02:00
2002-07-03 14:46:00 +02:00
print '<TD width="15%" class="menu" align="center">'.strftime(" %d %B - %H:%M",time()).'</TD>';
2002-05-06 21:10:48 +02:00
2002-12-31 15:10:59 +01:00
print '<td width="10%" class="menu" align="center">'.$user->login.'</td>';
print '</tr>';
// print '</table>';
2002-05-06 21:10:48 +02:00
/*
* Table principale
*
*/
2002-12-31 15:10:59 +01:00
// print '<TABLE border="0" width="100%" cellspacing="0" cellpadding="3">';
print '<tr><td valign="top" align="right">';
2002-05-09 16:57:48 +02:00
}
/*
* Barre de menu gauche
*
*
*
*
*/
Function left_menu($menu)
{
global $user, $conf, $rtplang;
2002-05-09 16:57:48 +02:00
/*
* Colonne de gauche
*
*/
2002-12-31 15:10:59 +01:00
print '<table class="leftmenu" border="0" width="100%" cellspacing="1" cellpadding="4">';
2002-05-09 16:57:48 +02:00
2002-12-12 17:42:08 +01:00
for ($i = 0 ; $i < sizeof($menu) ; $i++)
{
2002-05-09 16:57:48 +02:00
2002-12-31 15:10:59 +01:00
print '<tr><td class="barre" valign="top">';
2002-12-30 21:35:06 +01:00
print '<A class="leftmenu" href="'.$menu[$i][0].'">'.$menu[$i][1].'</a>';
2002-05-09 16:57:48 +02:00
2002-12-12 17:42:08 +01:00
for ($j = 2 ; $j < sizeof($menu[$i]) - 1 ; $j = $j +2)
{
print '<br>&nbsp;-&nbsp;<a class="submenu" href="'.$menu[$i][$j].'">'.$menu[$i][$j+1].'</A>';
}
print '</td></tr>';
2002-05-09 16:57:48 +02:00
}
if ((defined("MAIN_SEARCHFORM_SOCIETE") && MAIN_SEARCHFORM_SOCIETE > 0)|| (defined("MAIN_SEARCHFORM_CONTACT") && MAIN_SEARCHFORM_CONTACT > 0))
{
print '<tr><td class="barre" valign="top" align="right">';
if (defined("MAIN_SEARCHFORM_SOCIETE") && MAIN_SEARCHFORM_SOCIETE > 0)
{
// print constant("MAIN_SEARCHFORM_SOCIETE");
// echo MAIN_SEARCHFORM_SOCIETE."==MAIN_SEARCHFORM_SOCIETE; le type est " . gettype( MAIN_SEARCHFORM_SOCIETE ) . "<br>\n";
print '<A class="menu" href="/comm/clients.php3">Societes</A>';
print '<form action="/comm/clients.php3">';
print '<input type="hidden" name="mode" value="search">';
print '<input type="hidden" name="mode-search" value="soc">';
print '<input type="text" name="socname" class="flat" size="10">&nbsp;';
print '<input type="submit" class="flat" value="go">';
print '</form>';
}
if (defined("MAIN_SEARCHFORM_CONTACT") && MAIN_SEARCHFORM_CONTACT > 0)
{
print '<A class="menu" href="/comm/contact.php3">Contacts</A>';
print '<form action="/comm/contact.php3">';
print '<input type="hidden" name="mode" value="search">';
print '<input type="hidden" name="mode-search" value="contact">';
print '<input type="text" class="flat" name="contactname" size="10">&nbsp;';
print '<input type="submit" class="flat" value="go">';
print '</form>';
}
print '</td></tr>';
}
2002-12-30 21:35:06 +01:00
print '</table>';
2002-05-09 16:57:48 +02:00
/*
*
*
*/
2002-12-31 15:10:59 +01:00
print '</td><td valign="top" width="85%" colspan="6">';
2002-05-04 01:01:45 +02:00
}
2002-12-31 15:10:59 +01:00
/*
* Impression du pied de page
*
*
*
*/
2002-12-12 17:42:08 +01:00
function llxFooter($foot='')
{
2003-07-24 15:10:49 +02:00
print "</td></tr>";
2002-05-09 16:57:48 +02:00
/*
*
*/
2003-07-24 15:10:49 +02:00
print "</table>\n";
print '<p id="powered-by-dolibarr">';
print '<a href="http://savannah.gnu.org/bugs/?group_id=1915">Bug report</a>&nbsp;';
print '<a href="http://savannah.gnu.org/projects/dolibarr/">Source Code</a>&nbsp;'.$foot.'</p>';
print "</body></html>";
2002-05-09 16:57:48 +02:00
}
2002-04-30 12:56:25 +02:00
?>