From 5d37bfa7a9d5223cf6079aa00b05105282dc0722 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 11 Jan 2008 10:25:26 +0000 Subject: [PATCH] =?UTF-8?q?Qual:=20R=E9organisation=20un=20peu=20plus=20lo?= =?UTF-8?q?gique=20de=20certaines=20fonctions.=20R=E9duction=20de=20la=20t?= =?UTF-8?q?aille=20du=20fichier=20html.form.class.php=20qui=20est=20charg?= =?UTF-8?q?=E9=20a=20chaque=20fois=20et=20qui=20consomme=20a=20lui=20seul?= =?UTF-8?q?=201Mo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/adherents/fiche.php | 3 +- htdocs/adherents/ldap.php | 4 +- htdocs/admin/company.php | 2 +- htdocs/admin/menus.php | 11 +- htdocs/admin/menus/edit.php | 5 +- htdocs/admin/menus/index.php | 4 +- htdocs/comm/addpropal.php | 9 +- htdocs/commande/fiche.php | 3 +- htdocs/compta/dons/fiche.php | 6 +- htdocs/compta/facture.php | 3 +- htdocs/contact/ldap.php | 3 +- htdocs/fichinter/fiche.php | 22 +- htdocs/html.form.class.php | 449 ++++++++------------------------ htdocs/html.formadmin.class.php | 161 ++++++++++++ htdocs/lib/company.lib.php | 40 +++ htdocs/lib/ldap.class.php | 13 +- htdocs/lib/ldap.lib.php | 43 +++ htdocs/lib/project.lib.php | 58 ++++- htdocs/main.inc.php | 9 +- htdocs/user/group/ldap.php | 4 +- htdocs/user/ldap.php | 4 +- 21 files changed, 466 insertions(+), 390 deletions(-) create mode 100644 htdocs/html.formadmin.class.php diff --git a/htdocs/adherents/fiche.php b/htdocs/adherents/fiche.php index 71e09fda1c0..9f43417bfb7 100644 --- a/htdocs/adherents/fiche.php +++ b/htdocs/adherents/fiche.php @@ -29,6 +29,7 @@ require("./pre.inc.php"); require_once(DOL_DOCUMENT_ROOT."/lib/member.lib.php"); +require_once(DOL_DOCUMENT_ROOT."/lib/company.lib.php"); require_once(DOL_DOCUMENT_ROOT."/adherents/adherent.class.php"); require_once(DOL_DOCUMENT_ROOT."/adherents/adherent_type.class.php"); require_once(DOL_DOCUMENT_ROOT."/adherents/adherent_options.class.php"); @@ -911,7 +912,7 @@ if ($rowid && $action != 'edit') print ''.$langs->trans("Zip").' / '.$langs->trans("Town").''.$adh->cp.' '.$adh->ville.' '; // Pays - print ''.$langs->trans("Country").''.$html->pays_name($adh->pays_id).''; + print ''.$langs->trans("Country").''.getCountryLabel($adh->pays_id).''; // Tel pro. print ''.$langs->trans("PhonePro").''.$adh->phone.''; diff --git a/htdocs/adherents/ldap.php b/htdocs/adherents/ldap.php index c0b7aaa4773..b97bb73cc40 100644 --- a/htdocs/adherents/ldap.php +++ b/htdocs/adherents/ldap.php @@ -17,7 +17,6 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * $Id$ - * $Source$ */ /** @@ -181,8 +180,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/admin/company.php b/htdocs/admin/company.php index e09ae113364..b7927fe4652 100644 --- a/htdocs/admin/company.php +++ b/htdocs/admin/company.php @@ -492,7 +492,7 @@ else $var=!$var; print ''.$langs->trans("CompanyCountry").''; - print $form->pays_name($conf->global->MAIN_INFO_SOCIETE_PAYS,1); + print getCountryLabel($conf->global->MAIN_INFO_SOCIETE_PAYS,1); print ''; $var=!$var; diff --git a/htdocs/admin/menus.php b/htdocs/admin/menus.php index c3d47fa8d08..c135dce9ab8 100644 --- a/htdocs/admin/menus.php +++ b/htdocs/admin/menus.php @@ -26,6 +26,8 @@ */ require("./pre.inc.php"); +require_once(DOL_DOCUMENT_ROOT."/html.formadmin.class.php"); + $langs->load("companies"); $langs->load("products"); @@ -75,6 +77,7 @@ if (isset($_POST["action"]) && $_POST["action"] == 'update') */ $html=new Form($db); +$htmladmin=new FormAdmin($db); llxHeader(); @@ -123,10 +126,10 @@ if (isset($_GET["action"]) && $_GET["action"] == 'edit') $var=!$var; print ''.$langs->trans("DefaultMenuTopManager").''; print ''; - print $html->select_menu($conf->global->MAIN_MENU_BARRETOP,'main_menu_barretop',$dirtop); + print $htmladmin->select_menu($conf->global->MAIN_MENU_BARRETOP,'main_menu_barretop',$dirtop); print ''; print ''; - print $html->select_menu($conf->global->MAIN_MENUFRONT_BARRETOP,'main_menufront_barretop',$dirtop); + print $htmladmin->select_menu($conf->global->MAIN_MENUFRONT_BARRETOP,'main_menufront_barretop',$dirtop); print ''; print ''; @@ -134,10 +137,10 @@ if (isset($_GET["action"]) && $_GET["action"] == 'edit') $var=!$var; print ''.$langs->trans("DefaultMenuLeftManager").''; print ''; - print $html->select_menu($conf->global->MAIN_MENU_BARRELEFT,'main_menu_barreleft',$dirleft); + print $htmladmin->select_menu($conf->global->MAIN_MENU_BARRELEFT,'main_menu_barreleft',$dirleft); print ''; print ''; - print $html->select_menu($conf->global->MAIN_MENUFRONT_BARRELEFT,'main_menufront_barreleft',$dirleft); + print $htmladmin->select_menu($conf->global->MAIN_MENUFRONT_BARRELEFT,'main_menufront_barreleft',$dirleft); print ''; print ''; diff --git a/htdocs/admin/menus/edit.php b/htdocs/admin/menus/edit.php index 72a314f0b8e..1434565414b 100644 --- a/htdocs/admin/menus/edit.php +++ b/htdocs/admin/menus/edit.php @@ -26,6 +26,7 @@ */ require("./pre.inc.php"); +require_once(DOL_DOCUMENT_ROOT."/html.formadmin.class.php"); $langs->load("admin"); @@ -269,7 +270,9 @@ if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == 'yes') /* * Affichage page */ + $html=new Form($db); +$htmladmin=new FormAdmin($db); llxHeader(); @@ -313,7 +316,7 @@ if (isset($_GET["action"]) && $_GET["action"] == 'create') //Handler print ''.$langs->trans('MenuHandler').''; print ''; - print $html->select_menu_families($menu_handler,'menu_handler',$dirleft); + print $htmladmin->select_menu_families($menu_handler,'menu_handler',$dirleft); //print ''; print ''; print ''.$langs->trans('DetailMenuHandler').''; diff --git a/htdocs/admin/menus/index.php b/htdocs/admin/menus/index.php index 92612a72945..e179faf1b8d 100644 --- a/htdocs/admin/menus/index.php +++ b/htdocs/admin/menus/index.php @@ -26,6 +26,7 @@ */ require("./pre.inc.php"); +require_once(DOL_DOCUMENT_ROOT."/html.formadmin.class.php"); $langs->load("other"); $langs->load("admin"); @@ -187,6 +188,7 @@ if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == 'yes') * Affichage page */ $html=new Form($db); +$htmladmin=new FormAdmin($db); llxHeader(); @@ -231,7 +233,7 @@ if ($_GET["action"] == 'delete') print '
'; print ''; print $langs->trans("MenuHandler").': '; -print $html->select_menu_families($menu_handler,'menu_handler',$dirleft); +print $htmladmin->select_menu_families($menu_handler,'menu_handler',$dirleft); print '   '; print '
'; diff --git a/htdocs/comm/addpropal.php b/htdocs/comm/addpropal.php index 497c904cf93..80c7e09a2ef 100644 --- a/htdocs/comm/addpropal.php +++ b/htdocs/comm/addpropal.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2006 Laurent Destailleur + * Copyright (C) 2004-2008 Laurent Destailleur * Copyright (C) 2005-2007 Regis Houssin * Copyright (C) 2006 Andre Cianfarani * @@ -19,7 +19,6 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * $Id$ - * $Source$ */ /** @@ -30,12 +29,12 @@ */ require("./pre.inc.php"); - -include_once(DOL_DOCUMENT_ROOT.'/includes/modules/propale/modules_propale.php'); +require_once(DOL_DOCUMENT_ROOT.'/includes/modules/propale/modules_propale.php'); if (defined("PROPALE_ADDON") && is_readable(DOL_DOCUMENT_ROOT ."/includes/modules/propale/".PROPALE_ADDON.".php")) { require_once(DOL_DOCUMENT_ROOT ."/includes/modules/propale/".PROPALE_ADDON.".php"); } +if ($conf->projet->enabled) require_once(DOL_DOCUMENT_ROOT.'/lib/project.lib.php'); $langs->load("propal"); if ($conf->projet->enabled) $langs->load("projects"); @@ -202,7 +201,7 @@ if ($conf->expedition->enabled) print ''; print ''.$langs->trans("Project").''; - $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 "".$langs->trans("Project").""; - $html->select_projects('','','',"projetid"); + select_projects('','','',"projetid"); print "\n"; } diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 0a95e72b88c..7dada17a1ef 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -37,6 +37,7 @@ require_once(DOL_DOCUMENT_ROOT.'/discount.class.php'); require_once(DOL_DOCUMENT_ROOT.'/paiement.class.php'); require_once(DOL_DOCUMENT_ROOT.'/lib/invoice.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'); if ($conf->contrat->enabled) require_once(DOL_DOCUMENT_ROOT.'/contrat/contrat.class.php'); if ($conf->commande->enabled) require_once(DOL_DOCUMENT_ROOT.'/commande/commande.class.php'); @@ -1372,7 +1373,7 @@ if ($_GET['action'] == 'create') { $langs->load('projects'); print ''.$langs->trans('Project').''; - $html->select_projects($soc->id, $projetid, 'projetid'); + select_projects($soc->id, $projetid, 'projetid'); print ''; } diff --git a/htdocs/contact/ldap.php b/htdocs/contact/ldap.php index e6617da178f..90f1b60a754 100644 --- a/htdocs/contact/ldap.php +++ b/htdocs/contact/ldap.php @@ -174,8 +174,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/fichinter/fiche.php b/htdocs/fichinter/fiche.php index b9c1e9256af..c8256334294 100644 --- a/htdocs/fichinter/fiche.php +++ b/htdocs/fichinter/fiche.php @@ -406,8 +406,8 @@ if ($_GET["action"] == 'create') print ''.$langs->trans("Project").''; - if ($_GET["socid"]) $numprojet = $societe->has_projects(); - + if ($_GET["socid"]) $numprojet = $societe->has_projects(); + if (!$numprojet) { print ''; @@ -423,19 +423,19 @@ if ($_GET["action"] == 'create') } else { - $html->select_projects($societe->id,'','projetidp'); + select_projects($societe->id,'','projetidp'); } print ''; } - + // Model - print ''; - print ''; - print '"; + print ''; + print ''; + print '"; print ''; 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
'.$langs->trans("DefaultModel").''; - $model=new ModelePDFFicheinter(); - $liste=$model->liste_modeles($db); - $html->select_array('model',$liste,$conf->global->FICHEINTER_ADDON_PDF); - print "
'.$langs->trans("DefaultModel").''; + $model=new ModelePDFFicheinter(); + $liste=$model->liste_modeles($db); + $html->select_array('model',$liste,$conf->global->FICHEINTER_ADDON_PDF); + print "
'.$langs->trans("Description").'"; diff --git a/htdocs/html.form.class.php b/htdocs/html.form.class.php index 5eef1d5e934..c646f9980f3 100644 --- a/htdocs/html.form.class.php +++ b/htdocs/html.form.class.php @@ -36,6 +36,7 @@ /** \class Form \brief Classe permettant la génération de composants html + \remarks Only common components must be here. */ class Form @@ -48,7 +49,8 @@ class Form var $cache_conditions_paiements_code=array(); var $cache_conditions_paiements_libelle=array(); - var $tva_taux; + var $tva_taux_value; + var $tva_taux_libelle; /** \brief Constructeur @@ -507,170 +509,60 @@ class Form print ''; } - - /** - * \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 ''; - } - /** - * \brief Retourne la liste des types de comptes financiers - * \param selected Type pré-sélectionné - * \param htmlname Nom champ formulaire - */ - function select_type_comptes_financiers($selected=1,$htmlname='type') - { - global $langs; - $langs->load("banks"); - - $type_available=array(0,1,2); - - print ''; - } - - - /** - * \brief Retourne la liste des types de comptes financiers - * \param selected Type pré-sélectionné - * \param htmlname Nom champ formulaire - */ - function select_type_actions($selected='',$htmlname='actioncode') + * \brief Retourne la liste des types de comptes financiers + * \param selected Type pré-sélectionné + * \param htmlname Nom champ formulaire + */ + function select_type_comptes_financiers($selected=1,$htmlname='type') + { + global $langs; + $langs->load("banks"); + + $type_available=array(0,1,2); + + print ''; + } + + + /** + * \brief Retourne la liste des types de comptes financiers + * \param selected Type pré-sélectionné + * \param htmlname Nom champ formulaire + */ + function select_type_actions($selected='',$htmlname='actioncode') + { + global $langs,$user; + + require_once(DOL_DOCUMENT_ROOT."/cactioncomm.class.php"); + $caction=new CActionComm($this->db); + + $arraylist=$caction->liste_array(1,'code'); + $arraylist[0]=' '; + asort($arraylist); + + $this->select_array($htmlname, $arraylist, 0); + if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1); + } /** @@ -939,54 +831,6 @@ class Form } - /** - \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') - { - // 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"; - - $resql=$this->db->query($sql); - if ($resql) - { - print ''; - $this->db->free($resql); - return $num; - } - else - { - dolibarr_print_error($this->db); - return -1; - } - } /** \brief Retourne la liste des produits en Ajax si ajax activé ou renvoie à select_produits_do \param selected Produit pré-sélectionné @@ -1904,39 +1748,6 @@ class Form } - /** - * \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 pays_name($id,$withcode=0) - { - global $langs; - - $sql = "SELECT rowid, code, libelle FROM ".MAIN_DB_PREFIX."c_pays"; - $sql.= " WHERE rowid=$id;"; - - if ($this->db->query($sql)) - { - $num = $this->db->num_rows(); - - if ($num) - { - $obj = $this->db->fetch_object(); - $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"); - } - - } - } - - /** * \brief Affiche formulaire de demande de confirmation * \param page page @@ -2041,14 +1852,16 @@ class Form { global $langs; - $langs->load("project"); + require_once(DOL_DOCUMENT_ROOT."/lib/project.lib.php"); + + $langs->load("project"); if ($htmlname != "none") { print '
'; print ''; print ''; print ''; print ''; print '
'; - $this->select_projects($socid,$selected,$htmlname); + select_projects($socid,$selected,$htmlname); print '
'; @@ -2056,7 +1869,7 @@ class Form else { if ($selected) { - $projet = New Project($this->db); + $projet = new Project($this->db); $projet->fetch($selected); print ''.$projet->title.''; } else { @@ -2377,7 +2190,7 @@ class Form /** - * \brief Selection du taux de tva appliqué par vendeur + * \brief Selection du taux de tva à appliquer * \param name Nom champ html * \param defaulttx Forçage du taux tva pré-sélectionné. Mettre '' pour aucun forcage. * \param societe_vendeuse Objet société vendeuse @@ -3156,49 +2969,7 @@ class Form } - 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 '
'; - print $key; - print ''; - if (strtolower($key) == 'userpassword') $hide=1; - } - $this->show_ldap_content($val,$level+1,$count,$var,$hide); - } - else - { - if ($hide) print eregi_replace('.','*',utf8_decode("$val")); - else print utf8_decode($val); - print '
'; + print $key; + print ''; + if (strtolower($key) == 'userpassword') $hide=1; + } + show_ldap_content($val,$level+1,$count,$var,$hide); + } + else + { + if ($hide) print eregi_replace('.','*',utf8_decode("$val")); + else print utf8_decode($val); + print '