Qual: Rorganisation un peu plus logique de certaines fonctions. Rduction de la taille du fichier html.form.class.php qui est charg a chaque fois et qui consomme a lui seul 1Mo

This commit is contained in:
Laurent Destailleur 2008-01-11 10:25:26 +00:00
parent d2dfe7376f
commit 5d37bfa7a9
21 changed files with 466 additions and 390 deletions

View File

@ -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 '<tr><td>'.$langs->trans("Zip").' / '.$langs->trans("Town").'</td><td class="valeur">'.$adh->cp.' '.$adh->ville.'&nbsp;</td></tr>';
// Pays
print '<tr><td>'.$langs->trans("Country").'</td><td class="valeur">'.$html->pays_name($adh->pays_id).'</td></tr>';
print '<tr><td>'.$langs->trans("Country").'</td><td class="valeur">'.getCountryLabel($adh->pays_id).'</td></tr>';
// Tel pro.
print '<tr><td>'.$langs->trans("PhonePro").'</td><td class="valeur">'.$adh->phone.'</td></tr>';

View File

@ -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

View File

@ -492,7 +492,7 @@ else
$var=!$var;
print '<tr '.$bc[$var].'><td>'.$langs->trans("CompanyCountry").'</td><td>';
print $form->pays_name($conf->global->MAIN_INFO_SOCIETE_PAYS,1);
print getCountryLabel($conf->global->MAIN_INFO_SOCIETE_PAYS,1);
print '</td></tr>';
$var=!$var;

View File

@ -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 '<tr '.$bc[$var].'><td>'.$langs->trans("DefaultMenuTopManager").'</td>';
print '<td>';
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 '</td>';
print '<td>';
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 '</td>';
print '</tr>';
@ -134,10 +137,10 @@ if (isset($_GET["action"]) && $_GET["action"] == 'edit')
$var=!$var;
print '<tr '.$bc[$var].'><td>'.$langs->trans("DefaultMenuLeftManager").'</td>';
print '<td>';
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 '</td>';
print '<td>';
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 '</td>';
print '</tr>';

View File

@ -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 '<tr><td><b>'.$langs->trans('MenuHandler').'</b></td>';
print '<td>';
print $html->select_menu_families($menu_handler,'menu_handler',$dirleft);
print $htmladmin->select_menu_families($menu_handler,'menu_handler',$dirleft);
//print '<input type="text" size="30" name="handler" value="'.$menu_handler.'">';
print '</td>';
print '<td>'.$langs->trans('DetailMenuHandler').'</td></tr>';

View File

@ -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 '<form name="newmenu" class="nocellnopadding" action="'.$_SERVER["PHP_SELF"].'">';
print '<input type="hidden" action="change_menu_handler">';
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 ' &nbsp; <input type="submit" class="button" value="'.$langs->trans("Refresh").'">';
print '</form>';

View File

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2006 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2007 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
*
@ -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 '<tr>';
print '<td valign="top">'.$langs->trans("Project").'</td><td colspan="2">';
$numprojet=$html->select_projects($soc->id,$projetid,'projetidp');
$numprojet=select_projects($soc->id,$projetid,'projetidp');
if ($numprojet==0)
{
print ' &nbsp; <a href="../projet/fiche.php?socid='.$soc->id.'&action=create">'.$langs->trans("AddProject").'</a>';

View File

@ -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 '<tr><td>'.$langs->trans('Project').'</td><td colspan="2">';
$numprojet=$html->select_projects($soc->id,$projetid,'projetid');
$numprojet=select_projects($soc->id,$projetid,'projetid');
if ($numprojet==0)
{
print ' &nbsp; <a href=../projet/fiche.php?socid='.$soc->id.'&action=create>'.$langs->trans("AddProject").'</a>';

View File

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2001-2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2006 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
*
* 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 "<tr><td>".$langs->trans("Project")."</td><td>";
$html->select_projects('','','',"projetid");
select_projects('','','',"projetid");
print "</td></tr>\n";
}

View File

@ -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 '<tr><td>'.$langs->trans('Project').'</td><td colspan="2">';
$html->select_projects($soc->id, $projetid, 'projetid');
select_projects($soc->id, $projetid, 'projetid');
print '</td></tr>';
}

View File

@ -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

View File

@ -406,8 +406,8 @@ if ($_GET["action"] == 'create')
print '<tr><td valign="top">'.$langs->trans("Project").'</td><td>';
if ($_GET["socid"]) $numprojet = $societe->has_projects();
if ($_GET["socid"]) $numprojet = $societe->has_projects();
if (!$numprojet)
{
print '<table class="nobordernopadding" width="100%">';
@ -423,19 +423,19 @@ if ($_GET["action"] == 'create')
}
else
{
$html->select_projects($societe->id,'','projetidp');
select_projects($societe->id,'','projetidp');
}
print '</td></tr>';
}
// Model
print '<tr>';
print '<td>'.$langs->trans("DefaultModel").'</td>';
print '<td colspan="2">';
$model=new ModelePDFFicheinter();
$liste=$model->liste_modeles($db);
$html->select_array('model',$liste,$conf->global->FICHEINTER_ADDON_PDF);
print "</td></tr>";
print '<tr>';
print '<td>'.$langs->trans("DefaultModel").'</td>';
print '<td colspan="2">';
$model=new ModelePDFFicheinter();
$liste=$model->liste_modeles($db);
$html->select_array('model',$liste,$conf->global->FICHEINTER_ADDON_PDF);
print "</td></tr>";
print '<tr><td valign="top">'.$langs->trans("Description").'</td>';
print "<td>";

View File

@ -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 '</select>';
}
/**
* \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]='<option value="'.$file.'" selected="true">'.$filelib.'</option>';
}
else
{
$menuarray[$prefix.'_'.$file]='<option value="'.$file.'">'.$filelib.'</option>';
}
}
}
ksort($menuarray);
// Affichage liste deroulante des menus
print '<select class="flat" name="'.$htmlname.'">';
$oldprefix='';
foreach ($menuarray as $key => $val)
{
$tab=split('_',$key);
$newprefix=$tab[0];
if ($conf->browser->firefox && $newprefix != $oldprefix)
{
// Affiche titre
print '<option value="-1" disabled="disabled">';
if ($newprefix=='0') print '-- '.$langs->trans("VersionRecommanded").' --';
if ($newprefix=='1') print '-- '.$langs->trans("VersionExperimental").' --';
if ($newprefix=='2') print '-- '.$langs->trans("Other").' --';
print '</option>';
$oldprefix=$newprefix;
}
print $val."\n";
}
print '</select>';
}
/**
* \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 '<select class="flat" name="'.$htmlname.'">';
$oldprefix='';
foreach ($menuarray as $key => $val)
{
$tab=split('_',$key);
$newprefix=$tab[0];
print '<option value="'.$key.'"';
if ($key == $selected)
{
print ' selected="true"';
}
//if ($key == 'rodolphe') print ' disabled="true"';
print '>';
if ($key == 'all') print $langs->trans("AllMenus");
else print $key;
//if ($key == 'rodolphe') print ' ('.$langs->trans("PersonalizedMenusNotSupported").')';
print '</option>'."\n";
}
print '</select>';
}
/**
* \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 '<select class="flat" name="'.$htmlname.'">';
$num = count($type_available);
$i = 0;
if ($num)
{
while ($i < $num)
{
if ($selected == $type_available[$i])
{
print '<option value="'.$type_available[$i].'" selected="true">'.$langs->trans("BankType".$type_available[$i]).'</option>';
}
else
{
print '<option value="'.$type_available[$i].'">'.$langs->trans("BankType".$type_available[$i]).'</option>';
}
$i++;
}
}
print '</select>';
}
/**
* \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 '<select class="flat" name="'.$htmlname.'">';
$num = count($type_available);
$i = 0;
if ($num)
{
global $langs,$user;
require_once(DOL_DOCUMENT_ROOT."/cactioncomm.class.php");
$caction=new CActionComm($this->db);
$arraylist=$caction->liste_array(1,'code');
$arraylist[0]='&nbsp;';
asort($arraylist);
$this->select_array($htmlname, $arraylist, 0);
if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1);
while ($i < $num)
{
if ($selected == $type_available[$i])
{
print '<option value="'.$type_available[$i].'" selected="true">'.$langs->trans("BankType".$type_available[$i]).'</option>';
}
else
{
print '<option value="'.$type_available[$i].'">'.$langs->trans("BankType".$type_available[$i]).'</option>';
}
$i++;
}
}
print '</select>';
}
/**
* \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]='&nbsp;';
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 '<select class="flat" name="'.$htmlname.'">';
print '<option value="0">&nbsp;</option>';
$num = $this->db->num_rows($resql);
$i = 0;
if ($num)
{
while ($i < $num)
{
$obj = $this->db->fetch_object($resql);
if (!empty($selected) && $selected == $obj->rowid)
{
print '<option value="'.$obj->rowid.'" selected="true">'.$obj->title.'</option>';
}
else
{
print '<option value="'.$obj->rowid.'">'.$obj->title.'</option>';
}
$i++;
}
}
print '</select>';
$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 '<form method="post" action="'.$page.'">';
print '<input type="hidden" name="action" value="classin">';
print '<table class="noborder" cellpadding="0" cellspacing="0">';
print '<tr><td>';
$this->select_projects($socid,$selected,$htmlname);
select_projects($socid,$selected,$htmlname);
print '</td>';
print '<td align="left"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>';
print '</tr></table></form>';
@ -2056,7 +1869,7 @@ class Form
else
{
if ($selected) {
$projet = New Project($this->db);
$projet = new Project($this->db);
$projet->fetch($selected);
print '<a href="'.DOL_URL_ROOT.'/projet/fiche.php?id='.$selected.'">'.$projet->title.'</a>';
} 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 '<tr '.$bc[$var].'><td>';
print $key;
print '</td><td>';
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 '</td></tr>';
}
}
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 '<select class="flat" name="'.$htmlname.'">';
$num = $this->db->num_rows();
$i = 0;
print '<option value="-1">&nbsp;</option>'."\n";
if ($num)
{
while ($i < $num)
{
$obj = $this->db->fetch_object();
if ($selected && $selected == $obj->rowid)
{
print '<option value="'.$obj->rowid.'" selected="true">';
}
else
{
print '<option value="'.$obj->rowid.'">';
//print '<option onmouseover="showtip(\''.$obj->libelle.'\')" onMouseout="hidetip()" value="'.$obj->rowid.'">';
}
$selectOptionValue = $obj->code.' : '.price($obj->price).' '.$langs->trans("HT").' ('.$obj->organization.')';
print $selectOptionValue;
print '</option>';
$i++;
}
}
print '</select>';
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 '<select class="flat" name="'.$htmlname.'">';
$num = $this->db->num_rows();
$i = 0;
print '<option value="-1">&nbsp;</option>'."\n";
if ($num)
{
while ($i < $num)
{
$obj = $this->db->fetch_object();
if ($selected && $selected == $obj->rowid)
{
print '<option value="'.$obj->rowid.'" selected="true">';
}
else
{
print '<option value="'.$obj->rowid.'">';
//print '<option onmouseover="showtip(\''.$obj->libelle.'\')" onMouseout="hidetip()" value="'.$obj->rowid.'">';
}
$selectOptionValue = $obj->code.' : '.price($obj->price).' '.$langs->trans("HT").' ('.$obj->organization.')';
print $selectOptionValue;
print '</option>';
$i++;
}
}
print '</select>';
return 0;
}
else
{
dolibarr_print_error($this->db);
return 1;
}
}
}

View File

@ -0,0 +1,161 @@
<?php
/* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2007 Patrick Raguin <patrick.raguin@gmail.com>
*
* 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]='<option value="'.$file.'" selected="true">'.$filelib.'</option>';
}
else
{
$menuarray[$prefix.'_'.$file]='<option value="'.$file.'">'.$filelib.'</option>';
}
}
}
ksort($menuarray);
// Affichage liste deroulante des menus
print '<select class="flat" name="'.$htmlname.'">';
$oldprefix='';
foreach ($menuarray as $key => $val)
{
$tab=split('_',$key);
$newprefix=$tab[0];
if ($conf->browser->firefox && $newprefix != $oldprefix)
{
// Affiche titre
print '<option value="-1" disabled="disabled">';
if ($newprefix=='0') print '-- '.$langs->trans("VersionRecommanded").' --';
if ($newprefix=='1') print '-- '.$langs->trans("VersionExperimental").' --';
if ($newprefix=='2') print '-- '.$langs->trans("Other").' --';
print '</option>';
$oldprefix=$newprefix;
}
print $val."\n";
}
print '</select>';
}
/**
* \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 '<select class="flat" name="'.$htmlname.'">';
$oldprefix='';
foreach ($menuarray as $key => $val)
{
$tab=split('_',$key);
$newprefix=$tab[0];
print '<option value="'.$key.'"';
if ($key == $selected)
{
print ' selected="true"';
}
//if ($key == 'rodolphe') print ' disabled="true"';
print '>';
if ($key == 'all') print $langs->trans("AllMenus");
else print $key;
//if ($key == 'rodolphe') print ' ('.$langs->trans("PersonalizedMenusNotSupported").')';
print '</option>'."\n";
}
print '</select>';
}
}
?>

View File

@ -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;

View File

@ -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;
}

View File

@ -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 '<tr '.$bc[$var].'><td>';
print $key;
print '</td><td>';
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 '</td></tr>';
}
}
return 1;
}
?>

View File

@ -1,5 +1,5 @@
<?php
/* Copyright (C) 2006 Laurent Destailleur <eldy@users.sourceforge.net>
/* Copyright (C) 2006-2008 Laurent Destailleur <eldy@users.sourceforge.net>
*
* 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 '<select class="flat" name="'.$htmlname.'">';
print '<option value="0">&nbsp;</option>';
$num = $db->num_rows($resql);
$i = 0;
if ($num)
{
while ($i < $num)
{
$obj = $db->fetch_object($resql);
if (!empty($selected) && $selected == $obj->rowid)
{
print '<option value="'.$obj->rowid.'" selected="true">'.$obj->title.'</option>';
}
else
{
print '<option value="'.$obj->rowid.'">'.$obj->title.'</option>';
}
$i++;
}
}
print '</select>';
$db->free($resql);
return $num;
}
else
{
dolibarr_print_error($this->db);
return -1;
}
}
?>

View File

@ -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
* ------------------------------------------

View File

@ -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

View File

@ -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