';
- $numprojet=$html->select_projects($soc->id,$projetid,'projetidp');
+ $numprojet=select_projects($soc->id,$projetid,'projetidp');
if ($numprojet==0)
{
print ' '.$langs->trans("AddProject").'';
diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php
index aa098e81b01..58156370e5f 100644
--- a/htdocs/commande/fiche.php
+++ b/htdocs/commande/fiche.php
@@ -35,6 +35,7 @@ require_once(DOL_DOCUMENT_ROOT.'/commande/commande.class.php');
require_once(DOL_DOCUMENT_ROOT.'/actioncomm.class.php');
require_once(DOL_DOCUMENT_ROOT."/lib/order.lib.php");
if ($conf->projet->enabled) require_once(DOL_DOCUMENT_ROOT.'/project.class.php');
+if ($conf->projet->enabled) require_once(DOL_DOCUMENT_ROOT.'/lib/project.lib.php');
if ($conf->propal->enabled) require_once(DOL_DOCUMENT_ROOT.'/propal.class.php');
$langs->load('orders');
@@ -836,7 +837,7 @@ if ($_GET['action'] == 'create' && $user->rights->commande->creer)
if ($conf->projet->enabled)
{
print '
'.$langs->trans('Project').'
';
- $numprojet=$html->select_projects($soc->id,$projetid,'projetid');
+ $numprojet=select_projects($soc->id,$projetid,'projetid');
if ($numprojet==0)
{
print ' id.'&action=create>'.$langs->trans("AddProject").'';
diff --git a/htdocs/compta/dons/fiche.php b/htdocs/compta/dons/fiche.php
index c452daf5643..d0827097338 100644
--- a/htdocs/compta/dons/fiche.php
+++ b/htdocs/compta/dons/fiche.php
@@ -1,6 +1,6 @@
- * Copyright (C) 2004-2006 Laurent Destailleur
+ * Copyright (C) 2004-2008 Laurent Destailleur
*
* 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
@@ -17,7 +17,6 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Id$
- * $Source$
*/
/**
@@ -30,6 +29,7 @@
require_once("./pre.inc.php");
require_once(DOL_DOCUMENT_ROOT."/don.class.php");
require_once(DOL_DOCUMENT_ROOT."/paiement.class.php");
+if ($conf->projet->enabled) require_once(DOL_DOCUMENT_ROOT.'/lib/project.lib.php');
$langs->load("companies");
$langs->load("donations");
@@ -207,7 +207,7 @@ if ($_GET["action"] == 'create')
{
// Si module projet actif
print "
';
- }
- }
- return 1;
- }
-
- /**
+ /**
* \brief Retourne la liste des modèles d'export
* \param selected Id modèle pré-sélectionné
* \param htmlname Nom de la zone select
@@ -3313,56 +3084,56 @@ class Form
}
- /**
- * \brief Retourne la liste des ecotaxes avec tooltip sur le libelle
- * \param selected code ecotaxes pre-selectionne
- * \param htmlname nom de la liste deroulante
- */
- function select_ecotaxes($selected='',$htmlname='ecotaxe_id')
- {
- global $langs;
-
- $sql = "SELECT e.rowid, e.code, e.libelle, e.price, e.organization,";
- $sql.= " p.libelle as pays";
- $sql.= " FROM ".MAIN_DB_PREFIX."c_ecotaxe as e,".MAIN_DB_PREFIX."c_pays as p";
- $sql.= " WHERE e.active = 1 AND e.fk_pays = p.rowid";
- $sql.= " ORDER BY pays, e.organization ASC, e.code ASC";
-
- if ($this->db->query($sql))
- {
- print '';
- return 0;
- }
- else
- {
- dolibarr_print_error($this->db);
- return 1;
- }
- }
+ /**
+ * \brief Retourne la liste des ecotaxes avec tooltip sur le libelle
+ * \param selected code ecotaxes pre-selectionne
+ * \param htmlname nom de la liste deroulante
+ */
+ function select_ecotaxes($selected='',$htmlname='ecotaxe_id')
+ {
+ global $langs;
+
+ $sql = "SELECT e.rowid, e.code, e.libelle, e.price, e.organization,";
+ $sql.= " p.libelle as pays";
+ $sql.= " FROM ".MAIN_DB_PREFIX."c_ecotaxe as e,".MAIN_DB_PREFIX."c_pays as p";
+ $sql.= " WHERE e.active = 1 AND e.fk_pays = p.rowid";
+ $sql.= " ORDER BY pays, e.organization ASC, e.code ASC";
+
+ if ($this->db->query($sql))
+ {
+ print '';
+ return 0;
+ }
+ else
+ {
+ dolibarr_print_error($this->db);
+ return 1;
+ }
+ }
}
diff --git a/htdocs/html.formadmin.class.php b/htdocs/html.formadmin.class.php
new file mode 100644
index 00000000000..78396dcd591
--- /dev/null
+++ b/htdocs/html.formadmin.class.php
@@ -0,0 +1,161 @@
+
+ * Copyright (C) 2007 Patrick Raguin
+ *
+ * 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.
+ *
+ * $Id$
+ */
+
+/**
+ \file htdocs/html.formadmin.class.php
+ \brief Fichier de la classe des fonctions prédéfinie de composants html pour les pages admin
+*/
+
+
+/**
+ \class FormAdmin
+ \brief Classe permettant la génération de composants html pour les pages admin
+*/
+
+class FormAdmin
+{
+ var $db;
+ var $error;
+
+
+ /**
+ \brief Constructeur
+ \param DB handler d'accès base de donnée
+ */
+ function FormAdmin($DB)
+ {
+ $this->db = $DB;
+
+ return 1;
+ }
+
+ /**
+ * \brief Retourne la liste déroulante des menus disponibles (eldy_backoffice, ...)
+ * \param selected Menu pré-sélectionnée
+ * \param htmlname Nom de la zone select
+ * \param dirmenu Repértoire à scanner
+ */
+ function select_menu($selected='',$htmlname,$dirmenu)
+ {
+ global $langs,$conf;
+
+ if ($selected == 'eldy.php') $selected='eldy_backoffice.php'; // Pour compatibilité
+
+ $menuarray=array();
+ $handle=opendir($dirmenu);
+ while (($file = readdir($handle))!==false)
+ {
+ if (is_file($dirmenu."/".$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')
+ {
+ $filelib=eregi_replace('\.php$','',$file);
+ $prefix='';
+ if (eregi('^eldy',$file)) $prefix='0'; // Recommanded
+ else if (eregi('^auguria',$file)) $prefix='2'; // Other
+ else if (eregi('^default',$file)) $prefix='2'; // Other
+ else if (eregi('^rodolphe',$file)) $prefix='2'; // Other
+ else if (eregi('^empty',$file)) $prefix='2'; // Other
+ else $prefix='1'; // Experimental
+
+ if ($file == $selected)
+ {
+ $menuarray[$prefix.'_'.$file]='';
+ }
+ else
+ {
+ $menuarray[$prefix.'_'.$file]='';
+ }
+ }
+ }
+ ksort($menuarray);
+
+ // Affichage liste deroulante des menus
+ print '';
+ }
+
+ /**
+ * \brief Retourne la liste déroulante des menus disponibles (eldy)
+ * \param selected Menu pré-sélectionnée
+ * \param htmlname Nom de la zone select
+ * \param dirmenu Repertoire à scanner
+ */
+ function select_menu_families($selected='',$htmlname,$dirmenu)
+ {
+ global $langs,$conf;
+
+ $menuarray=array();
+ $handle=opendir($dirmenu);
+ while (($file = readdir($handle))!==false)
+ {
+ if (is_file($dirmenu."/".$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')
+ {
+ $filelib=eregi_replace('(_backoffice|_frontoffice)?\.php$','',$file);
+ if (eregi('^default',$filelib)) continue;
+ if (eregi('^empty',$filelib)) continue;
+
+ $menuarray[$filelib]=1;
+ }
+ $menuarray['all']=1;
+ }
+ ksort($menuarray);
+
+ // Affichage liste deroulante des menus
+ print '';
+ }
+
+}
+
+?>
diff --git a/htdocs/lib/company.lib.php b/htdocs/lib/company.lib.php
index 8da29f782ff..ba8a7f82c59 100644
--- a/htdocs/lib/company.lib.php
+++ b/htdocs/lib/company.lib.php
@@ -128,6 +128,43 @@ function societe_prepare_head($objsoc)
return $head;
}
+
+/**
+* \brief Retourne le nom traduit ou code+nom d'un pays
+* \param id id du pays
+* \param withcode 1=affiche code + nom
+* \return string Nom traduit du pays
+*/
+function getCountryLabel($id,$withcode=0)
+{
+ global $db,$langs;
+
+ $sql = "SELECT rowid, code, libelle FROM ".MAIN_DB_PREFIX."c_pays";
+ $sql.= " WHERE rowid=".$id;
+
+ dolibarr_syslog("company.lib.php sql=".$sql);
+ $resql=$db->query($sql);
+ if ($resql)
+ {
+ $obj = $db->fetch_object($resql);
+ if ($obj)
+ {
+ $label=$obj->code && $langs->trans("Country".$obj->code)!="Country".$obj->code?$langs->trans("Country".$obj->code):($obj->libelle!='-'?$obj->libelle:'');
+ if ($withcode) return $label==$obj->code?"$obj->code":"$obj->code - $label";
+ else return $label;
+ }
+ else
+ {
+ return $langs->trans("NotDefined");
+ }
+ $db->free($resql);
+ }
+}
+
+
+/**
+* \brief Show html area with actions to do
+*/
function show_actions_todo($conf,$langs,$db,$objsoc)
{
global $bc;
@@ -255,6 +292,9 @@ function show_actions_todo($conf,$langs,$db,$objsoc)
}
}
+/**
+* \brief Show html area with actions done
+*/
function show_actions_done($conf,$langs,$db,$objsoc)
{
global $bc;
diff --git a/htdocs/lib/ldap.class.php b/htdocs/lib/ldap.class.php
index 00b0236cc70..1f21c488dee 100644
--- a/htdocs/lib/ldap.class.php
+++ b/htdocs/lib/ldap.class.php
@@ -268,8 +268,17 @@ class Ldap
if (! $connected) $this->close();
}
- $return=($connected ? $connected : -1);
- dolibarr_syslog("Ldap::connect_bind return=".$return,LOG_DEBUG);
+ if ($connected)
+ {
+ $return=$connected;
+ dolibarr_syslog("Ldap::connect_bind return=".$return, LOG_DEBUG);
+ }
+ else
+ {
+ $this->error='Failed to connect to LDAP';
+ $return=-1;
+ dolibarr_syslog("Ldap::connect_bind return=".$return, LOG_WARN);
+ }
return $return;
}
diff --git a/htdocs/lib/ldap.lib.php b/htdocs/lib/ldap.lib.php
index 7b6e2677003..17bd45412b4 100644
--- a/htdocs/lib/ldap.lib.php
+++ b/htdocs/lib/ldap.lib.php
@@ -78,4 +78,47 @@ function ldap_prepare_head()
return $head;
}
+
+function show_ldap_content($result,$level,$count,$var,$hide=0)
+{
+ global $bc, $conf;
+
+ $count++;
+ if ($count > 1000) return -1; // To avoid infinite loop
+ if (! is_array($result)) return -1;
+
+ foreach($result as $key => $val)
+ {
+ if ("$key" == "objectclass") continue;
+ if ("$key" == "count") continue;
+ if ("$key" == "dn") continue;
+
+ if ("$val" == "objectclass") continue;
+ if ("$val" == $lastkey[$level]) continue;
+
+ $lastkey[$level]=$key;
+
+ if (is_array($val))
+ {
+ $hide=0;
+ if (! is_numeric($key))
+ {
+ $var=!$var;
+ print '
';
+ }
+ }
+ return 1;
+}
+
?>
\ No newline at end of file
diff --git a/htdocs/lib/project.lib.php b/htdocs/lib/project.lib.php
index 147cd191481..c8bcd6c1318 100644
--- a/htdocs/lib/project.lib.php
+++ b/htdocs/lib/project.lib.php
@@ -1,5 +1,5 @@
+/* Copyright (C) 2006-2008 Laurent Destailleur
*
* 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
@@ -17,7 +17,6 @@
* or see http://www.gnu.org/
*
* $Id$
- * $Source$
*/
/**
@@ -25,8 +24,6 @@
\brief Ensemble de fonctions de base pour le module projet
\ingroup societe
\version $Revision$
-
- Ensemble de fonctions de base de dolibarr sous forme d'include
*/
function project_prepare_head($objsoc)
@@ -75,4 +72,57 @@ function project_prepare_head($objsoc)
return $head;
}
+
+/**
+ \brief Affiche la liste déroulante des projets d'une société donnée
+ \param socid Id société
+ \param selected Id projet pré-sélectionné
+ \param htmlname Nom de la zone html
+ \return int Nbre de projet si ok, <0 si ko
+*/
+function select_projects($socid, $selected='', $htmlname='projectid')
+{
+ global $db;
+
+ // On recherche les projets
+ $sql = 'SELECT p.rowid, p.title FROM ';
+ $sql.= MAIN_DB_PREFIX .'projet as p';
+ $sql.= " WHERE fk_soc='".$socid."'";
+ $sql.= " ORDER BY p.title ASC";
+
+ dolibarr_syslog("project.lib::select_projects sql=".$sql);
+ $resql=$db->query($sql);
+ if ($resql)
+ {
+ print '';
+ $db->free($resql);
+ return $num;
+ }
+ else
+ {
+ dolibarr_print_error($this->db);
+ return -1;
+ }
+}
+
?>
\ No newline at end of file
diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php
index 4b1f91461f6..0a4be51d0d5 100644
--- a/htdocs/main.inc.php
+++ b/htdocs/main.inc.php
@@ -85,12 +85,12 @@ foreach ($_POST as $key => $val)
require_once("master.inc.php");
-//stopwithmem();
// Chargement des includes complementaire de presentation
-if (! defined('NOREQUIREMENU')) require_once(DOL_DOCUMENT_ROOT ."/menu.class.php");
-if (! defined('NOREQUIREHTML')) require_once(DOL_DOCUMENT_ROOT ."/html.form.class.php");
-if (! defined('NOREQUIREAJAX') && $conf->use_javascript_ajax) require_once(DOL_DOCUMENT_ROOT.'/lib/ajax.lib.php');
+if (! defined('NOREQUIREMENU')) require_once(DOL_DOCUMENT_ROOT ."/menu.class.php"); // Need 11ko memory
+if (! defined('NOREQUIREHTML')) require_once(DOL_DOCUMENT_ROOT ."/html.form.class.php"); // Need 800ko memory
+if (! defined('NOREQUIREAJAX') && $conf->use_javascript_ajax) require_once(DOL_DOCUMENT_ROOT.'/lib/ajax.lib.php'); // Need 20ko memory
+//stopwithmem();
// Init session
$sessionname="DOLSESSID_".$dolibarr_main_db_name;
@@ -284,7 +284,6 @@ if ($user->admin)
$user->rights->user->self->password=1;
}
-
/**
* Overwrite configs global par configs perso
* ------------------------------------------
diff --git a/htdocs/user/group/ldap.php b/htdocs/user/group/ldap.php
index e3f3a18923f..116df0c7517 100644
--- a/htdocs/user/group/ldap.php
+++ b/htdocs/user/group/ldap.php
@@ -17,7 +17,6 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Id$
- * $Source$
*/
/**
@@ -136,8 +135,7 @@ if ($result > 0)
}
else
{
- $html=new Form($db);
- $result=$html->show_ldap_content($records,0,0,true);
+ $result=show_ldap_content($records,0,0,true);
}
}
else
diff --git a/htdocs/user/ldap.php b/htdocs/user/ldap.php
index f0293acb9f0..c08d256091e 100644
--- a/htdocs/user/ldap.php
+++ b/htdocs/user/ldap.php
@@ -17,7 +17,6 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Id$
- * $Source$
*/
/**
@@ -216,8 +215,7 @@ if ($result > 0)
}
else
{
- $html=new Form($db);
- $result=$html->show_ldap_content($records,0,0,true);
+ $result=show_ldap_content($records,0,0,true);
}
}
else