2002-04-30 12:44:42 +02:00
|
|
|
|
<?PHP
|
2005-01-14 11:18:29 +01:00
|
|
|
|
/* Copyright (C) 2000-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
2004-02-02 21:52:56 +01:00
|
|
|
|
* Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org>
|
2005-01-02 14:57:45 +01:00
|
|
|
|
* Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net>
|
2004-09-02 23:14:20 +02:00
|
|
|
|
* Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
|
2004-10-31 14:34:08 +01:00
|
|
|
|
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
|
2004-09-23 20:51:34 +02:00
|
|
|
|
* Copyright (C) 2004 Christophe Combelles <ccomb@free.fr>
|
2002-04-30 12:44:42 +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.
|
|
|
|
|
|
* or see http://www.gnu.org/
|
2002-05-29 17:28:31 +02:00
|
|
|
|
*
|
2002-04-30 12:44:42 +02:00
|
|
|
|
* $Id$
|
|
|
|
|
|
* $Source$
|
|
|
|
|
|
*/
|
2002-12-17 21:57:07 +01:00
|
|
|
|
|
2005-03-20 03:26:59 +01:00
|
|
|
|
/**
|
|
|
|
|
|
\file htdocs/lib/functions.inc.php
|
2004-12-04 17:33:12 +01:00
|
|
|
|
\brief Ensemble de fonctions de base de dolibarr sous forme d'include
|
|
|
|
|
|
\author Rodolphe Quiedeville
|
|
|
|
|
|
\author Jean-Louis Bergamo
|
|
|
|
|
|
\author Laurent Destailleur
|
|
|
|
|
|
\author Sebastien Di Cintio
|
|
|
|
|
|
\author Benoit Mortier
|
|
|
|
|
|
\version $Revision$
|
2004-07-16 00:17:39 +02:00
|
|
|
|
|
|
|
|
|
|
Ensemble de fonctions de base de dolibarr sous forme d'include
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
2004-10-07 17:22:17 +02:00
|
|
|
|
|
2004-12-28 16:36:40 +01:00
|
|
|
|
/**
|
|
|
|
|
|
\brief Renvoi vrai si l'email est syntaxiquement valide
|
|
|
|
|
|
\param address adresse email (Ex: "toto@titi.com", "John Do <johndo@titi.com>")
|
|
|
|
|
|
\return boolean true si email valide, false sinon
|
2004-10-07 17:22:17 +02:00
|
|
|
|
*/
|
|
|
|
|
|
function ValidEmail($address)
|
|
|
|
|
|
{
|
2004-10-23 02:47:51 +02:00
|
|
|
|
if (ereg( ".*<(.+)>", $address, $regs)) {
|
2004-10-07 17:22:17 +02:00
|
|
|
|
$address = $regs[1];
|
|
|
|
|
|
}
|
2004-10-23 02:47:51 +02:00
|
|
|
|
if (ereg( "^[^@ ]+@([a-zA-Z0-9\-]+\.)+([a-zA-Z0-9\-]{2}|net|com|gov|mil|org|edu|int)\$",$address))
|
2004-10-07 17:22:17 +02:00
|
|
|
|
{
|
2004-10-23 02:47:51 +02:00
|
|
|
|
return true;
|
2004-10-07 17:22:17 +02:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2004-10-23 02:47:51 +02:00
|
|
|
|
return false;
|
2004-10-07 17:22:17 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2004-12-28 16:36:40 +01:00
|
|
|
|
/**
|
|
|
|
|
|
\brief Renvoi vrai si l'email a un nom de domaine qui r<EFBFBD>soud via dns
|
|
|
|
|
|
\param mail adresse email (Ex: "toto@titi.com", "John Do <johndo@titi.com>")
|
|
|
|
|
|
\return boolean true si email valide, false sinon
|
|
|
|
|
|
*/
|
2004-10-07 17:22:17 +02:00
|
|
|
|
function check_mail ($mail)
|
|
|
|
|
|
{
|
|
|
|
|
|
list($user, $domain) = split("@", $mail, 2);
|
|
|
|
|
|
if (checkdnsrr($domain, "MX"))
|
|
|
|
|
|
{
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2005-07-03 18:16:44 +02:00
|
|
|
|
/**
|
|
|
|
|
|
\brief Nettoie chaine de caract<EFBFBD>re des accents
|
|
|
|
|
|
\param str Chaine a nettoyer
|
|
|
|
|
|
\return string Chaine nettoy<EFBFBD>
|
|
|
|
|
|
*/
|
2005-05-24 13:44:07 +02:00
|
|
|
|
function unaccent($str)
|
|
|
|
|
|
{
|
2005-05-24 15:47:50 +02:00
|
|
|
|
$acc = array("<EFBFBD>","<EFBFBD>","<EFBFBD>","<EFBFBD>","<EFBFBD>","<EFBFBD>","<EFBFBD>","<EFBFBD>","<EFBFBD>","<EFBFBD>","<EFBFBD>","'");
|
|
|
|
|
|
$uac = array("a","a","e","e","e","i","i","o","o","u","u","");
|
2005-05-24 13:44:07 +02:00
|
|
|
|
|
|
|
|
|
|
return str_replace($acc, $uac, $str);
|
|
|
|
|
|
}
|
2004-10-07 17:22:17 +02:00
|
|
|
|
|
2005-07-03 18:16:44 +02:00
|
|
|
|
/**
|
|
|
|
|
|
\brief Nettoie chaine de caract<EFBFBD>re de caract<EFBFBD>res sp<EFBFBD>ciaux
|
|
|
|
|
|
\param str Chaine a nettoyer
|
|
|
|
|
|
\return string Chaine nettoy<EFBFBD>
|
|
|
|
|
|
*/
|
|
|
|
|
|
function sanitize_string($str)
|
|
|
|
|
|
{
|
2005-07-16 02:50:06 +02:00
|
|
|
|
$forbidden_chars=array(" ","'","/","\\",":","*","?","\"","<",">","|","[","]",",",";","=");
|
2005-07-03 18:16:44 +02:00
|
|
|
|
return str_replace($forbidden_chars,"_",$str);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2004-12-28 16:36:40 +01:00
|
|
|
|
/**
|
2005-04-21 19:55:23 +02:00
|
|
|
|
\brief Envoi des messages dolibarr dans syslog ou dans un fichier
|
2005-06-11 13:38:19 +02:00
|
|
|
|
Pour syslog: facility d<EFBFBD>fini par SYSLOG_FACILITY
|
2005-04-30 16:36:13 +02:00
|
|
|
|
Pour fichier: fichier d<EFBFBD>fini par SYSLOG_FILE
|
2005-06-11 13:38:19 +02:00
|
|
|
|
\param message Message a envoyer a syslog
|
|
|
|
|
|
\param level Niveau de l'erreur
|
2005-08-11 21:13:08 +02:00
|
|
|
|
\remarks Cette fonction n'a un effet que si le module syslog est activ<EFBFBD>.
|
2005-04-28 02:01:43 +02:00
|
|
|
|
Warning, les fonctions syslog sont buggu<EFBFBD>s sous Windows et g<EFBFBD>n<EFBFBD>rent des
|
|
|
|
|
|
fautes de protection m<EFBFBD>moire. Pour r<EFBFBD>soudre, utiliser le loggage fichier,
|
2005-08-11 21:13:08 +02:00
|
|
|
|
au lieu du loggage syslog (configuration du module).
|
2004-07-16 00:17:39 +02:00
|
|
|
|
*/
|
2004-09-30 14:44:36 +02:00
|
|
|
|
function dolibarr_syslog($message, $level=LOG_ERR)
|
2004-02-10 20:23:08 +01:00
|
|
|
|
{
|
2005-08-11 21:13:08 +02:00
|
|
|
|
global $conf,$user;
|
2005-07-10 01:50:51 +02:00
|
|
|
|
|
|
|
|
|
|
if ($conf->syslog->enabled)
|
2005-04-07 15:14:28 +02:00
|
|
|
|
{
|
2005-08-11 21:13:08 +02:00
|
|
|
|
// Ajout user a la log
|
|
|
|
|
|
$message=sprintf("%-8s",($user->id?$user->login:'???')).' '.$message;
|
|
|
|
|
|
|
2005-04-30 16:36:13 +02:00
|
|
|
|
if (defined("SYSLOG_FILE") && SYSLOG_FILE)
|
2005-04-21 19:55:23 +02:00
|
|
|
|
{
|
2005-04-30 16:36:13 +02:00
|
|
|
|
$file=fopen(SYSLOG_FILE,"a+");
|
|
|
|
|
|
if ($file) {
|
2005-07-10 01:50:51 +02:00
|
|
|
|
fwrite($file,strftime("%Y-%m-%d %H:%M:%S",time())." ".$level." ".$message."\n");
|
2005-04-30 16:36:13 +02:00
|
|
|
|
fclose($file);
|
|
|
|
|
|
}
|
|
|
|
|
|
else {
|
2005-06-11 13:38:19 +02:00
|
|
|
|
print $langs->trans("ErrorFailedToOpenFile",SYSLOG_FILE);
|
2005-04-30 16:36:13 +02:00
|
|
|
|
}
|
2005-04-21 19:55:23 +02:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2005-08-11 21:13:08 +02:00
|
|
|
|
//define_syslog_variables(); d<>j<EFBFBD> d<>finit dans master.inc.php
|
2005-04-21 19:55:23 +02:00
|
|
|
|
|
|
|
|
|
|
if (defined("MAIN_SYSLOG_FACILITY") && MAIN_SYSLOG_FACILITY)
|
|
|
|
|
|
{
|
|
|
|
|
|
$facility = MAIN_SYSLOG_FACILITY;
|
|
|
|
|
|
}
|
2005-06-11 13:38:19 +02:00
|
|
|
|
elseif (defined("SYSLOG_FACILITY") && SYSLOG_FACILITY && defined(SYSLOG_FACILITY))
|
|
|
|
|
|
{
|
|
|
|
|
|
// Exemple: SYSLOG_FACILITY vaut LOG_USER qui vaut 8. On a besoin de 8 dans $facility.
|
|
|
|
|
|
$facility = constant(SYSLOG_FACILITY);
|
|
|
|
|
|
}
|
2005-04-21 19:55:23 +02:00
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
$facility = LOG_USER;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
openlog("dolibarr", LOG_PID | LOG_PERROR, $facility);
|
|
|
|
|
|
|
|
|
|
|
|
if (! $level)
|
|
|
|
|
|
{
|
|
|
|
|
|
syslog(LOG_ERR, $message);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
syslog($level, $message);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
closelog();
|
|
|
|
|
|
}
|
2005-03-20 01:38:03 +01:00
|
|
|
|
}
|
2004-02-10 20:23:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2004-10-23 02:47:51 +02:00
|
|
|
|
|
2004-12-28 16:36:40 +01:00
|
|
|
|
/**
|
2004-08-07 16:41:29 +02:00
|
|
|
|
\brief Affiche le header d'une fiche
|
|
|
|
|
|
\param links liens
|
|
|
|
|
|
\param active 0 par d<EFBFBD>faut
|
2004-08-07 19:14:42 +02:00
|
|
|
|
\param title titre ("" par defaut)
|
2004-07-16 00:17:39 +02:00
|
|
|
|
*/
|
2004-07-19 11:22:17 +02:00
|
|
|
|
function dolibarr_fiche_head($links, $active=0, $title='')
|
2004-02-08 12:56:38 +01:00
|
|
|
|
{
|
2004-02-14 15:14:38 +01:00
|
|
|
|
print "<!-- fiche --><div class=\"tabs\">\n";
|
2004-02-08 12:56:38 +01:00
|
|
|
|
|
2004-07-19 11:22:17 +02:00
|
|
|
|
if (strlen($title))
|
|
|
|
|
|
{
|
2004-12-22 22:38:30 +01:00
|
|
|
|
$limittitle=30;
|
|
|
|
|
|
if (strlen($title) > $limittitle) print '<a class="tabTitle">'.substr($title,0,$limittitle).'...</a>';
|
|
|
|
|
|
else print '<a class="tabTitle">'.$title.'</a>';
|
2004-07-19 11:22:17 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
2004-02-08 12:56:38 +01:00
|
|
|
|
for ($i = 0 ; $i < sizeof($links) ; $i++)
|
|
|
|
|
|
{
|
2004-07-12 16:02:23 +02:00
|
|
|
|
if ($links[$i][2] == 'image')
|
2004-02-08 12:56:38 +01:00
|
|
|
|
{
|
2004-07-12 16:02:23 +02:00
|
|
|
|
print '<a class="tabimage" href="'.$links[$i][0].'">'.$links[$i][1].'</a>'."\n";
|
2004-02-08 12:56:38 +01:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2004-07-12 16:02:23 +02:00
|
|
|
|
if ($i == $active)
|
|
|
|
|
|
{
|
|
|
|
|
|
print '<a id="active" class="tab" href="'.$links[$i][0].'">'.$links[$i][1].'</a>'."\n";
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
print '<a class="tab" href="'.$links[$i][0].'">'.$links[$i][1].'</a>'."\n";
|
|
|
|
|
|
}
|
2004-02-08 12:56:38 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2004-02-14 15:14:38 +01:00
|
|
|
|
print "</div>\n";
|
|
|
|
|
|
print "<div class=\"tabBar\">\n<br>\n";
|
2004-02-08 12:56:38 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2005-06-11 13:38:19 +02:00
|
|
|
|
/**
|
|
|
|
|
|
\brief R<EFBFBD>cup<EFBFBD>re une constante depuis la base de donn<EFBFBD>es.
|
2005-08-20 16:36:32 +02:00
|
|
|
|
\see dolibarr_del_const, dolibarr_set_const
|
2005-06-11 13:38:19 +02:00
|
|
|
|
\param db Handler d'acc<EFBFBD>s base
|
|
|
|
|
|
\param name Nom de la constante
|
|
|
|
|
|
\return string Valeur de la constante
|
|
|
|
|
|
*/
|
|
|
|
|
|
function dolibarr_get_const($db, $name)
|
|
|
|
|
|
{
|
|
|
|
|
|
$value='';
|
|
|
|
|
|
|
|
|
|
|
|
$sql ="SELECT value";
|
|
|
|
|
|
$sql.=" FROM llx_const";
|
|
|
|
|
|
$sql.=" WHERE name = '$name';";
|
|
|
|
|
|
$resql=$db->query($sql);
|
|
|
|
|
|
if ($resql)
|
|
|
|
|
|
{
|
|
|
|
|
|
$obj=$db->fetch_object($resql);
|
|
|
|
|
|
$value=$obj->value;
|
|
|
|
|
|
}
|
|
|
|
|
|
return $value;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2005-08-11 22:23:34 +02:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
\brief Positionne environnement PHP en fonction du langage
|
|
|
|
|
|
\param code_lang Code langue concern<EFBFBD> (fr_FR, en_US, ...)
|
|
|
|
|
|
\return string Code langue valid<EFBFBD>
|
|
|
|
|
|
*/
|
|
|
|
|
|
function dolibarr_set_php_lang($code_lang)
|
|
|
|
|
|
{
|
|
|
|
|
|
$code_lang_tiret=ereg_replace('_','-',$code_lang);
|
2005-08-12 02:25:06 +02:00
|
|
|
|
|
2005-08-13 21:18:01 +02:00
|
|
|
|
//dolibarr_syslog("dolibarr_set_php_lang: code_lang=$code_lang code_lang_tirer=$code_lang_tiret");
|
2005-08-12 02:25:06 +02:00
|
|
|
|
|
2005-08-11 22:23:34 +02:00
|
|
|
|
setlocale(LC_ALL, $code_lang); // Compenser pb de locale avec windows
|
2005-08-12 02:25:06 +02:00
|
|
|
|
setlocale(LC_ALL, $code_lang_tiret);
|
2005-08-11 22:23:34 +02:00
|
|
|
|
if (defined("MAIN_FORCE_SETLOCALE_LC_ALL") && MAIN_FORCE_SETLOCALE_LC_ALL) setlocale(LC_ALL, MAIN_FORCE_SETLOCALE_LC_ALL);
|
|
|
|
|
|
if (defined("MAIN_FORCE_SETLOCALE_LC_TIME") && MAIN_FORCE_SETLOCALE_LC_TIME) setlocale(LC_TIME, MAIN_FORCE_SETLOCALE_LC_TIME);
|
|
|
|
|
|
if (defined("MAIN_FORCE_SETLOCALE_LC_NUMERIC") && MAIN_FORCE_SETLOCALE_LC_NUMERIC) setlocale(LC_NUMERIC, MAIN_FORCE_SETLOCALE_LC_NUMERIC);
|
|
|
|
|
|
if (defined("MAIN_FORCE_SETLOCALE_LC_MONETARY") && MAIN_FORCE_SETLOCALE_LC_MONETARY) setlocale(LC_MONETARY, MAIN_FORCE_SETLOCALE_LC_MONETARY);
|
|
|
|
|
|
|
|
|
|
|
|
// On corrige $code_lang si il ne vaut pas le code long: fr -> fr_FR par exemple
|
|
|
|
|
|
if (strlen($code_lang) <= 3)
|
|
|
|
|
|
{
|
|
|
|
|
|
$code_lang = strtolower($code_lang)."_".strtoupper($code_lang);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return $code_lang;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2004-12-28 16:36:40 +01:00
|
|
|
|
/**
|
2004-08-07 16:41:29 +02:00
|
|
|
|
\brief Insertion d'une constante dans la base de donn<EFBFBD>es.
|
2005-08-20 16:36:32 +02:00
|
|
|
|
\see dolibarr_del_const, dolibarr_get_const
|
|
|
|
|
|
\param db Handler d'acc<EFBFBD>s base
|
|
|
|
|
|
\param name Nom de la constante
|
|
|
|
|
|
\param value Valeur de la constante
|
|
|
|
|
|
\param type Type de constante (chaine par d<EFBFBD>faut)
|
|
|
|
|
|
\param visible La constante est elle visible (0 par d<EFBFBD>faut)
|
|
|
|
|
|
\param note Explication de la constante
|
|
|
|
|
|
\return int <0 si ko, >0 si ok
|
2004-07-16 00:17:39 +02:00
|
|
|
|
*/
|
|
|
|
|
|
function dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $note='')
|
2004-02-05 19:39:38 +01:00
|
|
|
|
{
|
2005-08-20 16:36:32 +02:00
|
|
|
|
global $conf;
|
|
|
|
|
|
|
2005-04-11 19:21:24 +02:00
|
|
|
|
$db->begin();
|
|
|
|
|
|
|
|
|
|
|
|
$sql = "DELETE FROM llx_const WHERE name = '$name';";
|
|
|
|
|
|
$resql=$db->query($sql);
|
|
|
|
|
|
|
|
|
|
|
|
$sql = "INSERT INTO llx_const(name,value,type,visible,note)";
|
2005-04-22 01:10:09 +02:00
|
|
|
|
$sql.= " VALUES ('$name','".addslashes($value)."','$type',$visible,'$note');";
|
2005-04-11 19:21:24 +02:00
|
|
|
|
$resql=$db->query($sql);
|
|
|
|
|
|
|
|
|
|
|
|
if ($resql)
|
|
|
|
|
|
{
|
|
|
|
|
|
$db->commit();
|
2005-08-20 16:36:32 +02:00
|
|
|
|
$conf->global->$name=$value;
|
2005-04-11 19:21:24 +02:00
|
|
|
|
return 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
$db->rollback();
|
2005-08-20 16:36:32 +02:00
|
|
|
|
return -1;
|
2005-04-11 19:21:24 +02:00
|
|
|
|
}
|
2004-02-21 00:41:53 +01:00
|
|
|
|
}
|
2004-02-05 19:39:38 +01:00
|
|
|
|
|
2004-12-28 16:36:40 +01:00
|
|
|
|
/**
|
2004-08-07 16:41:29 +02:00
|
|
|
|
\brief Effacement d'une constante dans la base de donn<EFBFBD>es
|
2005-06-11 13:38:19 +02:00
|
|
|
|
\see dolibarr_get_const, dolibarr_sel_const
|
2004-08-07 16:41:29 +02:00
|
|
|
|
\param db handler d'acc<EFBFBD>s base
|
|
|
|
|
|
\param name nom ou rowid de la constante
|
2005-04-11 19:21:24 +02:00
|
|
|
|
\return int 0 si KO, 1 si OK
|
2004-07-16 00:17:39 +02:00
|
|
|
|
*/
|
|
|
|
|
|
function dolibarr_del_const($db, $name)
|
2004-02-21 00:41:53 +01:00
|
|
|
|
{
|
2005-04-11 19:21:24 +02:00
|
|
|
|
$sql = "DELETE FROM llx_const WHERE name='$name' or rowid='$name'";
|
|
|
|
|
|
$resql=$db->query($sql);
|
2004-07-16 00:17:39 +02:00
|
|
|
|
|
2005-04-11 19:21:24 +02:00
|
|
|
|
if ($resql)
|
2004-02-21 00:41:53 +01:00
|
|
|
|
{
|
2005-04-11 19:21:24 +02:00
|
|
|
|
return 1;
|
2004-02-21 00:41:53 +01:00
|
|
|
|
}
|
2005-04-11 19:21:24 +02:00
|
|
|
|
else
|
2004-02-21 00:41:53 +01:00
|
|
|
|
{
|
2005-04-11 19:21:24 +02:00
|
|
|
|
return 0;
|
2004-02-21 00:41:53 +01:00
|
|
|
|
}
|
2004-02-05 19:39:38 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2004-12-28 16:36:40 +01:00
|
|
|
|
/**
|
2004-08-07 16:41:29 +02:00
|
|
|
|
\brief Formattage des nombres
|
2004-07-16 00:17:39 +02:00
|
|
|
|
\param ca valeur a formater
|
2004-08-07 16:41:29 +02:00
|
|
|
|
\return int valeur format<EFBFBD>e
|
2004-07-16 00:17:39 +02:00
|
|
|
|
*/
|
|
|
|
|
|
function dolibarr_print_ca($ca)
|
2004-02-18 16:20:12 +01:00
|
|
|
|
{
|
2005-07-10 17:46:19 +02:00
|
|
|
|
global $langs,$conf;
|
|
|
|
|
|
|
2004-05-01 02:32:11 +02:00
|
|
|
|
if ($ca > 1000)
|
2004-02-18 16:20:12 +01:00
|
|
|
|
{
|
|
|
|
|
|
$cat = round(($ca / 1000),2);
|
2005-07-10 17:46:19 +02:00
|
|
|
|
$cat = "$cat K".$langs->trans("Currency".$conf->monnaie);
|
2004-02-18 16:20:12 +01:00
|
|
|
|
}
|
2004-05-01 02:32:11 +02:00
|
|
|
|
else
|
2004-02-18 16:20:12 +01:00
|
|
|
|
{
|
|
|
|
|
|
$cat = round($ca,2);
|
2005-07-10 17:46:19 +02:00
|
|
|
|
$cat = "$cat ".$langs->trans("Currency".$conf->monnaie);
|
2004-02-18 16:20:12 +01:00
|
|
|
|
}
|
2004-07-16 00:17:39 +02:00
|
|
|
|
|
2004-05-01 02:32:11 +02:00
|
|
|
|
if ($ca > 1000000)
|
2004-02-18 16:20:12 +01:00
|
|
|
|
{
|
|
|
|
|
|
$cat = round(($ca / 1000000),2);
|
2005-07-10 17:46:19 +02:00
|
|
|
|
$cat = "$cat M".$langs->trans("Currency".$conf->monnaie);
|
2004-02-18 16:20:12 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2004-05-01 02:32:11 +02:00
|
|
|
|
return $cat;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2005-06-11 13:38:19 +02:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
\brief Effectue un d<EFBFBD>calage de date par rapport <EFBFBD> une dur<EFBFBD>e
|
|
|
|
|
|
\param time Date timestamp ou au format YYYY-MM-DD
|
|
|
|
|
|
\param duration_value Valeur de la dur<EFBFBD>e <EFBFBD> ajouter
|
|
|
|
|
|
\param duration_unit Unit<EFBFBD> de la dur<EFBFBD>e <EFBFBD> ajouter (d, m, y)
|
|
|
|
|
|
\return int Nouveau timestamp
|
|
|
|
|
|
*/
|
|
|
|
|
|
function dolibarr_time_plus_duree($time,$duration_value,$duration_unit)
|
|
|
|
|
|
{
|
|
|
|
|
|
$deltastring="+$duration_value";
|
|
|
|
|
|
if ($duration_unit == 'd') { $deltastring.=" day"; }
|
|
|
|
|
|
if ($duration_unit == 'm') { $deltastring.=" month"; }
|
|
|
|
|
|
if ($duration_unit == 'y') { $deltastring.=" year"; }
|
|
|
|
|
|
return strtotime($deltastring,$time);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2004-12-28 16:36:40 +01:00
|
|
|
|
/**
|
2005-07-02 15:19:18 +02:00
|
|
|
|
\brief Formattage de la date en fonction de la langue $conf->langage
|
2005-08-15 23:36:13 +02:00
|
|
|
|
\param time Date 'timestamp' ou format 'YYYY-MM-DD' ou 'YYYY-MM-DD HH:MM:SS'
|
|
|
|
|
|
\param format Format d'affichage de la date "%d %b %Y"
|
|
|
|
|
|
\return string Date format<EFBFBD>e ou "?" si time nul
|
2004-07-16 00:17:39 +02:00
|
|
|
|
*/
|
|
|
|
|
|
function dolibarr_print_date($time,$format="%d %b %Y")
|
2004-05-01 02:32:11 +02:00
|
|
|
|
{
|
2005-08-15 23:36:13 +02:00
|
|
|
|
// Si date non d<>fini, on renvoie vide
|
|
|
|
|
|
if (! $time) return "?";
|
|
|
|
|
|
|
2005-07-02 15:19:18 +02:00
|
|
|
|
// Analyse de la date
|
|
|
|
|
|
if (eregi('^([0-9]+)\-([0-9]+)\-([0-9]+)\s?([0-9]+)?:?([0-9]+)?',$time,$reg)) {
|
|
|
|
|
|
// Date au format 'YYYY-MM-DD' ou 'YYYY-MM-DD HH:MM:SS'
|
|
|
|
|
|
$syear = $reg[1];
|
|
|
|
|
|
$smonth = $reg[2];
|
|
|
|
|
|
$sday = $reg[3];
|
|
|
|
|
|
$shour = $reg[4];
|
|
|
|
|
|
$smin = $reg[5];
|
|
|
|
|
|
if ($syear < 1970 && $_SERVER["WINDIR"])
|
|
|
|
|
|
{
|
|
|
|
|
|
// Le formatage ne peut etre appliqu<71> car windows ne supporte pas la fonction
|
|
|
|
|
|
// mktime si l'ann<6E>e est inf<6E>rieur <20> 1970. On retourne un format fixe
|
|
|
|
|
|
return "$syear-$smonth-$sday";
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
return strftime($format,mktime($shour,$smin,0,$smonth,$sday,$syear));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else {
|
|
|
|
|
|
// Date est un timestamps
|
|
|
|
|
|
return strftime($format,$time);
|
|
|
|
|
|
}
|
2004-05-01 02:32:11 +02:00
|
|
|
|
}
|
2004-02-18 16:20:12 +01:00
|
|
|
|
|
2004-07-16 00:17:39 +02:00
|
|
|
|
|
2004-12-28 16:36:40 +01:00
|
|
|
|
/**
|
2004-08-07 16:41:29 +02:00
|
|
|
|
\brief Affiche les informations d'un objet
|
2004-07-16 00:17:39 +02:00
|
|
|
|
\param object objet a afficher
|
|
|
|
|
|
*/
|
|
|
|
|
|
function dolibarr_print_object_info($object)
|
2004-05-01 02:32:11 +02:00
|
|
|
|
{
|
2004-09-18 14:45:37 +02:00
|
|
|
|
global $langs;
|
2005-07-10 16:39:35 +02:00
|
|
|
|
|
2005-07-03 15:05:13 +02:00
|
|
|
|
if (isset($object->user_creation) && $object->user_creation->fullname)
|
2004-09-18 14:45:37 +02:00
|
|
|
|
print $langs->trans("CreatedBy")." : " . $object->user_creation->fullname . '<br>';
|
|
|
|
|
|
|
|
|
|
|
|
if (isset($object->date_creation))
|
|
|
|
|
|
print $langs->trans("DateCreation")." : " . dolibarr_print_date($object->date_creation,"%A %d %B %Y %H:%M:%S") . '<br>';
|
|
|
|
|
|
|
2005-07-03 15:05:13 +02:00
|
|
|
|
if (isset($object->user_modification) && $object->user_modification->fullname)
|
2004-09-18 14:45:37 +02:00
|
|
|
|
print $langs->trans("ModifiedBy")." : " . $object->user_modification->fullname . '<br>';
|
|
|
|
|
|
|
|
|
|
|
|
if (isset($object->date_modification))
|
2005-07-03 15:05:13 +02:00
|
|
|
|
print $langs->trans("DateLastModification")." : " . dolibarr_print_date($object->date_modification,"%A %d %B %Y %H:%M:%S") . '<br>';
|
2004-09-18 14:45:37 +02:00
|
|
|
|
|
2005-07-03 15:05:13 +02:00
|
|
|
|
if (isset($object->user_validation) && $object->user_validation->fullname)
|
2004-09-18 14:45:37 +02:00
|
|
|
|
print $langs->trans("ValidatedBy")." : " . $object->user_validation->fullname . '<br>';
|
|
|
|
|
|
|
|
|
|
|
|
if (isset($object->date_validation))
|
2005-07-10 16:39:35 +02:00
|
|
|
|
print $langs->trans("DateValidation")." : " . dolibarr_print_date($object->date_validation,"%A %d %B %Y %H:%M:%S") . '<br>';
|
2004-09-18 14:45:37 +02:00
|
|
|
|
|
2005-07-03 15:05:13 +02:00
|
|
|
|
if (isset($object->user_cloture) && $object->user_cloture->fullname )
|
2004-09-18 14:45:37 +02:00
|
|
|
|
print $langs->trans("ClosedBy")." : " . $object->user_cloture->fullname . '<br>';
|
|
|
|
|
|
|
|
|
|
|
|
if (isset($object->date_cloture))
|
2005-07-03 15:05:13 +02:00
|
|
|
|
print $langs->trans("DateClosing")." : " . dolibarr_print_date($object->date_cloture,"%A %d %B %Y %H:%M:%S") . '<br>';
|
2004-02-18 16:20:12 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2004-12-28 16:36:40 +01:00
|
|
|
|
/**
|
2005-04-08 23:31:03 +02:00
|
|
|
|
\brief Formatage des num<EFBFBD>ros de telephone en fonction du format d'un pays
|
|
|
|
|
|
\param phone Num<EFBFBD>ro de telephone <EFBFBD> formater
|
|
|
|
|
|
\param country Pays selon lequel formatter
|
|
|
|
|
|
\return string Num<EFBFBD>ro de t<EFBFBD>l<EFBFBD>phone format<EFBFBD>
|
2004-07-16 00:17:39 +02:00
|
|
|
|
*/
|
2005-01-30 20:42:33 +01:00
|
|
|
|
function dolibarr_print_phone($phone,$country="FR")
|
2004-05-01 02:32:11 +02:00
|
|
|
|
{
|
2005-01-30 20:42:33 +01:00
|
|
|
|
$phone=trim($phone);
|
2004-09-25 02:12:49 +02:00
|
|
|
|
if (strstr($phone, ' ')) { return $phone; }
|
2005-01-30 20:42:33 +01:00
|
|
|
|
if (strtoupper($country) == "FR") {
|
|
|
|
|
|
// France
|
|
|
|
|
|
if (strlen($phone) == 10) {
|
|
|
|
|
|
return substr($phone,0,2)." ".substr($phone,2,2)." ".substr($phone,4,2)." ".substr($phone,6,2)." ".substr($phone,8,2);
|
|
|
|
|
|
}
|
|
|
|
|
|
elseif (strlen($phone) == 7)
|
|
|
|
|
|
{
|
|
|
|
|
|
return substr($phone,0,3)." ".substr($phone,3,2)." ".substr($phone,5,2);
|
|
|
|
|
|
}
|
|
|
|
|
|
elseif (strlen($phone) == 9)
|
|
|
|
|
|
{
|
|
|
|
|
|
return substr($phone,0,2)." ".substr($phone,2,3)." ".substr($phone,5,2)." ".substr($phone,7,2);
|
|
|
|
|
|
}
|
|
|
|
|
|
elseif (strlen($phone) == 11)
|
|
|
|
|
|
{
|
|
|
|
|
|
return substr($phone,0,3)." ".substr($phone,3,2)." ".substr($phone,5,2)." ".substr($phone,7,2)." ".substr($phone,9,2);
|
|
|
|
|
|
}
|
|
|
|
|
|
elseif (strlen($phone) == 12)
|
|
|
|
|
|
{
|
|
|
|
|
|
return substr($phone,0,4)." ".substr($phone,4,2)." ".substr($phone,6,2)." ".substr($phone,8,2)." ".substr($phone,10,2);
|
|
|
|
|
|
}
|
2004-09-25 02:12:49 +02:00
|
|
|
|
}
|
|
|
|
|
|
return $phone;
|
2004-05-01 02:32:11 +02:00
|
|
|
|
}
|
2004-02-18 16:20:12 +01:00
|
|
|
|
|
2005-04-08 23:31:03 +02:00
|
|
|
|
/**
|
|
|
|
|
|
\brief Tronque une chaine <EFBFBD> une taille donn<EFBFBD>e en ajoutant les points de suspension si cela d<EFBFBD>passe
|
2005-07-03 15:05:13 +02:00
|
|
|
|
\param string Chaine <EFBFBD> tronquer
|
|
|
|
|
|
\param size Longueur max de la chaine
|
|
|
|
|
|
\return string Chaine tronqu<EFBFBD>e
|
2005-04-08 23:31:03 +02:00
|
|
|
|
*/
|
|
|
|
|
|
function dolibarr_trunc($string,$size=40)
|
|
|
|
|
|
{
|
2005-05-14 16:57:52 +02:00
|
|
|
|
if (strlen($string) > $size) return substr($string,0,$size).'...';
|
2005-04-08 23:31:03 +02:00
|
|
|
|
else return $string;
|
|
|
|
|
|
}
|
2004-09-23 20:51:34 +02:00
|
|
|
|
|
2004-12-28 16:36:40 +01:00
|
|
|
|
/**
|
2005-07-09 12:55:21 +02:00
|
|
|
|
\brief Affiche picto propre <EFBFBD> une notion/module (fonction g<EFBFBD>n<EFBFBD>rique)
|
2005-07-03 15:05:13 +02:00
|
|
|
|
\param alt Texte sur le alt de l'image
|
|
|
|
|
|
\param object Objet pour lequel il faut afficher le logo (exemple: user, group, action, bill, contract, propal, product, ...)
|
2005-07-10 21:54:48 +02:00
|
|
|
|
\return string Retourne tag img
|
2004-08-07 01:39:54 +02:00
|
|
|
|
*/
|
2005-01-30 20:42:33 +01:00
|
|
|
|
function img_object($alt, $object)
|
2004-08-07 01:39:54 +02:00
|
|
|
|
{
|
2005-01-18 22:09:16 +01:00
|
|
|
|
global $conf,$langs;
|
2005-01-30 20:42:33 +01:00
|
|
|
|
return '<img src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/object_'.$object.'.png" border="0" alt="'.$alt.'" title="'.$alt.'">';
|
2004-08-07 01:39:54 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
2005-07-09 12:55:21 +02:00
|
|
|
|
/**
|
|
|
|
|
|
\brief Affiche picto (fonction g<EFBFBD>n<EFBFBD>rique)
|
|
|
|
|
|
\param alt Texte sur le alt de l'image
|
|
|
|
|
|
\param picto Nom de l'image a afficher
|
2005-07-10 21:54:48 +02:00
|
|
|
|
\return string Retourne tag img
|
2005-07-09 12:55:21 +02:00
|
|
|
|
*/
|
|
|
|
|
|
function img_picto($alt, $picto)
|
|
|
|
|
|
{
|
|
|
|
|
|
global $conf,$langs;
|
|
|
|
|
|
return '<img src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/'.$picto.'.png" border="0" alt="'.$alt.'" title="'.$alt.'">';
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2005-04-08 21:51:34 +02:00
|
|
|
|
/**
|
2005-07-03 15:05:13 +02:00
|
|
|
|
\brief Affiche logo action
|
|
|
|
|
|
\param alt Texte sur le alt de l'image
|
|
|
|
|
|
\param numaction Determine image action
|
2005-07-10 21:54:48 +02:00
|
|
|
|
\return string Retourne tag img
|
2005-04-08 21:51:34 +02:00
|
|
|
|
*/
|
|
|
|
|
|
function img_action($alt = "default", $numaction)
|
|
|
|
|
|
{
|
|
|
|
|
|
global $conf,$langs;
|
|
|
|
|
|
if ($alt=="default") {
|
|
|
|
|
|
if ($numaction == -1) $alt=$langs->trans("ChangeDoNotContact");
|
|
|
|
|
|
if ($numaction == 0) $alt=$langs->trans("ChangeNeverContacted");
|
|
|
|
|
|
if ($numaction == 1) $alt=$langs->trans("ChangeToContact");
|
2005-04-09 01:16:23 +02:00
|
|
|
|
if ($numaction == 2) $alt=$langs->trans("ChangeContactInProcess");
|
|
|
|
|
|
if ($numaction == 3) $alt=$langs->trans("ChangeContactDone");
|
2005-04-08 21:51:34 +02:00
|
|
|
|
}
|
2005-04-09 01:16:23 +02:00
|
|
|
|
return '<img align="absmiddle" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/stcomm'.$numaction.'.png" border="0" alt="'.$alt.'" title="'.$alt.'">';
|
2005-04-08 21:51:34 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
2004-12-28 16:36:40 +01:00
|
|
|
|
/**
|
2005-07-03 15:05:13 +02:00
|
|
|
|
\brief Affiche logo statut
|
|
|
|
|
|
\param num Num<EFBFBD>ro statut
|
2005-07-10 22:22:49 +02:00
|
|
|
|
\param alt Texte a afficher sur alt
|
2005-07-10 21:54:48 +02:00
|
|
|
|
\return string Retourne tag img
|
2005-07-03 15:05:13 +02:00
|
|
|
|
*/
|
|
|
|
|
|
function img_statut($num,$alt = "default")
|
|
|
|
|
|
{
|
|
|
|
|
|
global $conf,$langs;
|
|
|
|
|
|
if ($alt=="default") {
|
|
|
|
|
|
if ($num == 0) $alt=$langs->trans("Draft");
|
|
|
|
|
|
if ($num == 1) $alt=$langs->trans("Late");
|
|
|
|
|
|
if ($num == 4) $alt=$langs->trans("Running");
|
|
|
|
|
|
if ($num == 5) $alt=$langs->trans("Closed");
|
|
|
|
|
|
}
|
|
|
|
|
|
return '<img src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/statut'.$num.'.png" border="0" alt="'.$alt.'" title="'.$alt.'">';
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
\brief Affiche logo fichier
|
|
|
|
|
|
\param alt Texte sur le alt de l'image
|
2005-07-10 21:54:48 +02:00
|
|
|
|
\return string Retourne tag img
|
2004-07-31 14:52:37 +02:00
|
|
|
|
*/
|
2004-07-25 19:43:23 +02:00
|
|
|
|
function img_file($alt = "default")
|
2003-10-28 15:13:01 +01:00
|
|
|
|
{
|
2005-01-18 22:09:16 +01:00
|
|
|
|
global $conf,$langs;
|
|
|
|
|
|
if ($alt=="default") $alt=$langs->trans("Show");
|
|
|
|
|
|
return '<img src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/file.png" border="0" alt="'.$alt.'" title="'.$alt.'">';
|
2003-10-28 15:13:01 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2004-12-28 16:36:40 +01:00
|
|
|
|
/**
|
2005-07-03 15:05:13 +02:00
|
|
|
|
\brief Affiche logo dossier
|
|
|
|
|
|
\param alt Texte sur le alt de l'image
|
2005-07-10 21:54:48 +02:00
|
|
|
|
\return string Retourne tag img
|
2004-12-09 10:36:32 +01:00
|
|
|
|
*/
|
|
|
|
|
|
function img_folder($alt = "default")
|
|
|
|
|
|
{
|
2005-01-18 22:09:16 +01:00
|
|
|
|
global $conf,$langs;
|
|
|
|
|
|
if ($alt=="default") $alt=$langs->trans("Dossier");
|
|
|
|
|
|
return '<img src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/folder.png" border="0" alt="'.$alt.'" title="'.$alt.'">';
|
2004-12-09 10:36:32 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2004-12-28 16:36:40 +01:00
|
|
|
|
/**
|
2005-07-03 15:05:13 +02:00
|
|
|
|
\brief Affiche logo nouveau fichier
|
|
|
|
|
|
\param alt Texte sur le alt de l'image
|
2005-07-10 21:54:48 +02:00
|
|
|
|
\return string Retourne tag img
|
2004-07-31 14:52:37 +02:00
|
|
|
|
*/
|
2004-07-25 19:43:23 +02:00
|
|
|
|
function img_file_new($alt = "default")
|
2004-02-18 16:20:12 +01:00
|
|
|
|
{
|
2005-01-18 22:09:16 +01:00
|
|
|
|
global $conf,$langs;
|
|
|
|
|
|
if ($alt=="default") $alt=$langs->trans("Show");
|
|
|
|
|
|
return '<img src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/filenew.png" border="0" alt="'.$alt.'" title="'.$alt.'">';
|
2004-02-18 16:20:12 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2004-12-28 16:36:40 +01:00
|
|
|
|
/**
|
2005-07-03 15:05:13 +02:00
|
|
|
|
\brief Affiche logo pdf
|
|
|
|
|
|
\param alt Texte sur le alt de l'image
|
2005-07-10 21:54:48 +02:00
|
|
|
|
\return string Retourne tag img
|
2004-07-31 14:52:37 +02:00
|
|
|
|
*/
|
2004-07-25 19:43:23 +02:00
|
|
|
|
function img_pdf($alt = "default")
|
2004-02-16 19:09:12 +01:00
|
|
|
|
{
|
2005-01-18 22:09:16 +01:00
|
|
|
|
global $conf,$langs;
|
|
|
|
|
|
if ($alt=="default") $alt=$langs->trans("Show");
|
|
|
|
|
|
return '<img src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/pdf.png" border="0" alt="'.$alt.'" title="'.$alt.'">';
|
2004-02-16 19:09:12 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2004-12-28 16:36:40 +01:00
|
|
|
|
/**
|
2005-07-03 15:05:13 +02:00
|
|
|
|
\brief Affiche logo +
|
|
|
|
|
|
\param alt Texte sur le alt de l'image
|
2005-07-10 21:54:48 +02:00
|
|
|
|
\return string Retourne tag img
|
2004-07-31 14:52:37 +02:00
|
|
|
|
*/
|
|
|
|
|
|
function img_edit_add($alt = "default")
|
|
|
|
|
|
{
|
2005-01-18 22:09:16 +01:00
|
|
|
|
global $conf,$langs;
|
|
|
|
|
|
if ($alt=="default") $alt=$langs->trans("Add");
|
|
|
|
|
|
return '<img src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/edit_add.png" border="0" alt="'.$alt.'" title="'.$alt.'">';
|
2004-07-31 14:52:37 +02:00
|
|
|
|
}
|
2004-12-28 16:36:40 +01:00
|
|
|
|
/**
|
2005-07-03 15:05:13 +02:00
|
|
|
|
\brief Affiche logo -
|
|
|
|
|
|
\param alt Texte sur le alt de l'image
|
2005-07-10 21:54:48 +02:00
|
|
|
|
\return string Retourne tag img
|
2004-07-31 14:52:37 +02:00
|
|
|
|
*/
|
2004-07-31 17:27:37 +02:00
|
|
|
|
function img_edit_remove($alt = "default")
|
2004-07-31 14:52:37 +02:00
|
|
|
|
{
|
2005-01-18 22:09:16 +01:00
|
|
|
|
global $conf,$langs;
|
|
|
|
|
|
if ($alt=="default") $alt=$langs->trans("Remove");
|
|
|
|
|
|
return '<img src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/edit_remove.png" border="0" alt="'.$alt.'" title="'.$alt.'">';
|
2004-07-31 14:52:37 +02:00
|
|
|
|
}
|
2004-07-17 14:52:41 +02:00
|
|
|
|
|
2004-12-28 16:36:40 +01:00
|
|
|
|
/**
|
2005-07-03 15:05:13 +02:00
|
|
|
|
\brief Affiche logo editer/modifier fiche
|
|
|
|
|
|
\param alt Texte sur le alt de l'image
|
2005-07-10 21:54:48 +02:00
|
|
|
|
\return string Retourne tag img
|
2004-07-31 14:52:37 +02:00
|
|
|
|
*/
|
2004-07-25 19:43:23 +02:00
|
|
|
|
function img_edit($alt = "default")
|
2004-06-30 16:59:08 +02:00
|
|
|
|
{
|
2005-01-18 22:09:16 +01:00
|
|
|
|
global $conf,$langs;
|
|
|
|
|
|
if ($alt=="default") $alt=$langs->trans("Modify");
|
|
|
|
|
|
return '<img src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/edit.png" border="0" alt="'.$alt.'" title="'.$alt.'">';
|
2004-06-30 16:59:08 +02:00
|
|
|
|
}
|
2004-02-16 19:09:12 +01:00
|
|
|
|
|
2004-12-28 16:36:40 +01:00
|
|
|
|
/**
|
2005-07-03 15:05:13 +02:00
|
|
|
|
\brief Affiche logo effacer
|
|
|
|
|
|
\param alt Texte sur le alt de l'image
|
2005-07-10 21:54:48 +02:00
|
|
|
|
\return string Retourne tag img
|
2004-07-31 14:52:37 +02:00
|
|
|
|
*/
|
2004-07-25 19:43:23 +02:00
|
|
|
|
function img_delete($alt = "default")
|
2003-11-08 17:49:52 +01:00
|
|
|
|
{
|
2005-01-18 22:09:16 +01:00
|
|
|
|
global $conf,$langs;
|
|
|
|
|
|
if ($alt=="default") $alt=$langs->trans("Delete");
|
|
|
|
|
|
return '<img src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/delete.png" border="0" alt="'.$alt.'" title="'.$alt.'">';
|
2003-11-08 17:49:52 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2004-12-28 16:36:40 +01:00
|
|
|
|
/**
|
2005-07-03 15:05:13 +02:00
|
|
|
|
\brief Affiche logo d<EFBFBD>sactiver
|
|
|
|
|
|
\param alt Texte sur le alt de l'image
|
2005-07-10 21:54:48 +02:00
|
|
|
|
\return string Retourne tag img
|
2004-07-31 14:52:37 +02:00
|
|
|
|
*/
|
2004-07-25 19:43:23 +02:00
|
|
|
|
function img_disable($alt = "default")
|
2004-02-14 15:14:38 +01:00
|
|
|
|
{
|
2005-01-18 22:09:16 +01:00
|
|
|
|
global $conf,$langs;
|
|
|
|
|
|
if ($alt=="default") $alt=$langs->trans("Disable");
|
|
|
|
|
|
return '<img src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/disable.png" border="0" alt="'.$alt.'" title="'.$alt.'">';
|
2004-02-14 15:14:38 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2004-12-28 16:36:40 +01:00
|
|
|
|
/**
|
2005-07-03 15:05:13 +02:00
|
|
|
|
\brief Affiche logo info
|
|
|
|
|
|
\param alt Texte sur le alt de l'image
|
2005-07-10 21:54:48 +02:00
|
|
|
|
\return string Retourne tag img
|
2004-07-31 14:52:37 +02:00
|
|
|
|
*/
|
2004-10-23 01:16:32 +02:00
|
|
|
|
function img_info($alt = "default")
|
2004-07-31 14:52:37 +02:00
|
|
|
|
{
|
2005-01-18 22:09:16 +01:00
|
|
|
|
global $conf,$langs;
|
|
|
|
|
|
if ($alt=="default") $alt=$langs->trans("Informations");
|
|
|
|
|
|
return '<img src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/info.png" border="0" alt="'.$alt.'" title="'.$alt.'">';
|
2004-07-31 14:52:37 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
2004-12-28 16:36:40 +01:00
|
|
|
|
/**
|
2005-07-03 15:05:13 +02:00
|
|
|
|
\brief Affiche logo warning
|
|
|
|
|
|
\param alt Texte sur le alt de l'image
|
2005-07-10 21:54:48 +02:00
|
|
|
|
\return string Retourne tag img
|
2004-07-31 14:52:37 +02:00
|
|
|
|
*/
|
2004-07-25 19:43:23 +02:00
|
|
|
|
function img_warning($alt = "default")
|
2004-07-17 14:52:41 +02:00
|
|
|
|
{
|
2005-01-18 22:09:16 +01:00
|
|
|
|
global $conf,$langs;
|
2005-04-30 19:27:06 +02:00
|
|
|
|
if ($alt=="default") $alt=$langs->trans("Warning");
|
2005-01-18 22:09:16 +01:00
|
|
|
|
return '<img src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/warning.png" border="0" alt="'.$alt.'" title="'.$alt.'">';
|
2004-07-17 14:52:41 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
2005-04-30 19:27:06 +02:00
|
|
|
|
/**
|
2005-07-03 15:05:13 +02:00
|
|
|
|
\brief Affiche logo warning
|
|
|
|
|
|
\param alt Texte sur le alt de l'image
|
2005-07-10 21:54:48 +02:00
|
|
|
|
\return string Retourne tag img
|
2005-04-30 19:27:06 +02:00
|
|
|
|
*/
|
|
|
|
|
|
function img_error($alt = "default")
|
|
|
|
|
|
{
|
|
|
|
|
|
global $conf,$langs;
|
|
|
|
|
|
if ($alt=="default") $alt=$langs->trans("Error");
|
|
|
|
|
|
return '<img src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/error.png" border="0" alt="'.$alt.'" title="'.$alt.'">';
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2004-12-28 16:36:40 +01:00
|
|
|
|
/**
|
2005-07-03 15:05:13 +02:00
|
|
|
|
\brief Affiche logo alerte
|
|
|
|
|
|
\param alt Texte sur le alt de l'image
|
2005-07-10 21:54:48 +02:00
|
|
|
|
\return string Retourne tag img
|
2004-07-31 14:52:37 +02:00
|
|
|
|
*/
|
2004-07-25 19:43:23 +02:00
|
|
|
|
function img_alerte($alt = "default")
|
2004-07-17 14:52:41 +02:00
|
|
|
|
{
|
2005-01-18 22:09:16 +01:00
|
|
|
|
global $conf,$langs;
|
|
|
|
|
|
if ($alt=="default") $alt=$langs->trans("Alert");
|
|
|
|
|
|
return '<img src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/alerte.png" border="0" alt="'.$alt.'" title="'.$alt.'">';
|
2004-07-17 14:52:41 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
2004-12-28 16:36:40 +01:00
|
|
|
|
/**
|
2005-07-03 15:05:13 +02:00
|
|
|
|
\brief Affiche logo t<EFBFBD>l<EFBFBD>phone in
|
|
|
|
|
|
\param alt Texte sur le alt de l'image
|
2005-07-10 21:54:48 +02:00
|
|
|
|
\return string Retourne tag img
|
2004-07-31 14:52:37 +02:00
|
|
|
|
*/
|
2004-07-25 19:43:23 +02:00
|
|
|
|
function img_phone_in($alt = "default")
|
2004-05-25 16:31:18 +02:00
|
|
|
|
{
|
2005-01-18 22:09:16 +01:00
|
|
|
|
global $conf,$langs;
|
|
|
|
|
|
if ($alt=="default") $alt=$langs->trans("Modify");
|
|
|
|
|
|
return '<img src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/call.png" border="0" alt="'.$alt.'" title="'.$alt.'">';
|
2004-05-25 16:31:18 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
2004-12-28 16:36:40 +01:00
|
|
|
|
/**
|
2005-07-03 15:05:13 +02:00
|
|
|
|
\brief Affiche logo t<EFBFBD>l<EFBFBD>phone out
|
|
|
|
|
|
\param alt Texte sur le alt de l'image
|
2005-07-10 21:54:48 +02:00
|
|
|
|
\return string Retourne tag img
|
2004-07-31 14:52:37 +02:00
|
|
|
|
*/
|
2004-07-25 19:43:23 +02:00
|
|
|
|
function img_phone_out($alt = "default")
|
2004-05-25 16:31:18 +02:00
|
|
|
|
{
|
2005-01-18 22:09:16 +01:00
|
|
|
|
global $conf,$langs;
|
|
|
|
|
|
if ($alt=="default") $alt=$langs->trans("Modify");
|
|
|
|
|
|
return '<img src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/call.png" border="0" alt="'.$alt.'" title="'.$alt.'">';
|
2004-05-25 16:31:18 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
2004-12-28 16:36:40 +01:00
|
|
|
|
/**
|
2005-07-03 15:05:13 +02:00
|
|
|
|
\brief Affiche logo suivant
|
|
|
|
|
|
\param alt Texte sur le alt de l'image
|
2005-07-10 21:54:48 +02:00
|
|
|
|
\return string Retourne tag img
|
2004-07-31 14:52:37 +02:00
|
|
|
|
*/
|
2004-07-25 19:43:23 +02:00
|
|
|
|
function img_next($alt = "default")
|
2004-04-02 11:40:17 +02:00
|
|
|
|
{
|
2005-01-18 22:09:16 +01:00
|
|
|
|
global $conf,$langs;
|
2004-10-23 01:16:32 +02:00
|
|
|
|
if ($alt=="default") {
|
2004-07-25 19:43:23 +02:00
|
|
|
|
$alt=$langs->trans("Next");
|
|
|
|
|
|
}
|
2005-01-18 22:09:16 +01:00
|
|
|
|
return '<img src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/next.png" border="0" alt="'.$alt.'" title="'.$alt.'">';
|
2004-04-02 11:40:17 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
2004-12-28 16:36:40 +01:00
|
|
|
|
/**
|
2005-07-03 15:05:13 +02:00
|
|
|
|
\brief Affiche logo pr<EFBFBD>c<EFBFBD>dent
|
|
|
|
|
|
\param alt Texte sur le alt de l'image
|
2005-07-10 21:54:48 +02:00
|
|
|
|
\return string Retourne tag img
|
2004-07-31 14:52:37 +02:00
|
|
|
|
*/
|
2004-07-25 19:43:23 +02:00
|
|
|
|
function img_previous($alt = "default")
|
2004-04-02 11:40:17 +02:00
|
|
|
|
{
|
2005-01-18 22:09:16 +01:00
|
|
|
|
global $conf,$langs;
|
|
|
|
|
|
if ($alt=="default") $alt=$langs->trans("Previous");
|
|
|
|
|
|
return '<img src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/previous.png" border="0" alt="'.$alt.'" title="'.$alt.'">';
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2005-07-03 15:05:13 +02:00
|
|
|
|
\brief Affiche logo bas
|
|
|
|
|
|
\param alt Texte sur le alt de l'image
|
|
|
|
|
|
\param selected Affiche version "selected" du logo
|
2005-07-10 21:54:48 +02:00
|
|
|
|
\return string Retourne tag img
|
2005-01-18 22:09:16 +01:00
|
|
|
|
*/
|
2005-06-11 13:38:19 +02:00
|
|
|
|
function img_down($alt = "default", $selected=1)
|
2005-01-18 22:09:16 +01:00
|
|
|
|
{
|
2005-06-11 13:38:19 +02:00
|
|
|
|
global $conf,$langs;
|
|
|
|
|
|
if ($alt=="default") $alt=$langs->trans("Down");
|
|
|
|
|
|
if ($selected) return '<img src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/1downarrow.png" border="0" alt="'.$alt.'" title="'.$alt.'">';
|
|
|
|
|
|
else return '<img src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/1downarrow_notselected.png" border="0" alt="'.$alt.'" title="'.$alt.'">';
|
2005-01-18 22:09:16 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2005-07-03 15:05:13 +02:00
|
|
|
|
\brief Affiche logo haut
|
|
|
|
|
|
\param alt Texte sur le alt de l'image
|
|
|
|
|
|
\param selected Affiche version "selected" du logo
|
2005-07-10 21:54:48 +02:00
|
|
|
|
\return string Retourne tag img
|
2005-01-18 22:09:16 +01:00
|
|
|
|
*/
|
2005-06-11 13:38:19 +02:00
|
|
|
|
function img_up($alt = "default", $selected=1)
|
2005-01-18 22:09:16 +01:00
|
|
|
|
{
|
2005-06-11 13:38:19 +02:00
|
|
|
|
global $conf,$langs;
|
|
|
|
|
|
if ($alt=="default") $alt=$langs->trans("Up");
|
|
|
|
|
|
if ($selected) return '<img src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/1uparrow.png" border="0" alt="'.$alt.'" title="'.$alt.'">';
|
|
|
|
|
|
else return '<img src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/1uparrow_notselected.png" border="0" alt="'.$alt.'" title="'.$alt.'">';
|
2004-04-02 11:40:17 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
2005-03-06 16:39:32 +01:00
|
|
|
|
|
|
|
|
|
|
/**
|
2005-07-03 15:05:13 +02:00
|
|
|
|
\brief Affiche logo tick
|
|
|
|
|
|
\param alt Texte sur le alt de l'image
|
2005-07-10 21:54:48 +02:00
|
|
|
|
\return string Retourne tag img
|
2005-03-06 16:39:32 +01:00
|
|
|
|
*/
|
|
|
|
|
|
function img_tick($alt = "default")
|
|
|
|
|
|
{
|
|
|
|
|
|
global $conf,$langs;
|
|
|
|
|
|
if ($alt=="default") $alt=$langs->trans("Active");
|
|
|
|
|
|
return '<img src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/tick.png" border="0" alt="'.$alt.'" title="'.$alt.'">';
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2005-07-03 15:05:13 +02:00
|
|
|
|
|
2004-12-28 16:36:40 +01:00
|
|
|
|
/**
|
2005-07-02 14:16:33 +02:00
|
|
|
|
\brief Affiche formulaire de login
|
|
|
|
|
|
\remarks il faut changer le code html dans cette fonction pour changer le design
|
2004-07-16 00:17:39 +02:00
|
|
|
|
*/
|
|
|
|
|
|
function loginfunction()
|
2003-08-30 12:48:01 +02:00
|
|
|
|
{
|
2005-07-02 14:16:33 +02:00
|
|
|
|
global $langs,$conf;
|
2005-08-11 21:13:08 +02:00
|
|
|
|
$langs->load("main");
|
2005-04-15 20:28:11 +02:00
|
|
|
|
|
2003-10-03 21:37:38 +02:00
|
|
|
|
print '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">';
|
2005-07-02 14:16:33 +02:00
|
|
|
|
print "\n<html><head><title>Dolibarr Authentification</title>\n";
|
|
|
|
|
|
print '<link rel="stylesheet" type="text/css" href="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/'.$conf->theme.'.css">';
|
2005-08-01 11:47:32 +02:00
|
|
|
|
|
|
|
|
|
|
|
2005-07-02 14:16:33 +02:00
|
|
|
|
|
2005-07-02 14:22:24 +02:00
|
|
|
|
print '<style type="text/css">';
|
|
|
|
|
|
print '<!--';
|
|
|
|
|
|
print '#login {';
|
|
|
|
|
|
print ' margin-top: 70px;';
|
|
|
|
|
|
print ' margin-bottom: 50px;';
|
|
|
|
|
|
print ' text-align: center;';
|
|
|
|
|
|
print ' font: 12px arial,helvetica;';
|
|
|
|
|
|
print '}';
|
|
|
|
|
|
print '#login table {';
|
|
|
|
|
|
print ' border: 1px solid #C0C0C0;';
|
|
|
|
|
|
if (file_exists(DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/login_background.png'))
|
|
|
|
|
|
{
|
|
|
|
|
|
print 'background: #F0F0F0 url('.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/login_background.png) repeat-x;';
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
print 'background: #F0F0F0 url('.DOL_URL_ROOT.'/theme/login_background.png) repeat-x;';
|
|
|
|
|
|
}
|
|
|
|
|
|
print 'font-size: 12px;';
|
|
|
|
|
|
print '}';
|
|
|
|
|
|
print '-->';
|
|
|
|
|
|
print '</style>';
|
2005-08-01 11:47:32 +02:00
|
|
|
|
print '<script type="text/javascript">';
|
|
|
|
|
|
print "function donnefocus() {\n";
|
|
|
|
|
|
print "document.getElementsByTagName('INPUT')[0].focus();";
|
|
|
|
|
|
print "}\n";
|
|
|
|
|
|
print '</script>';
|
|
|
|
|
|
print '</head>';
|
|
|
|
|
|
print '<body onload="donnefocus();">';
|
2005-07-02 14:22:24 +02:00
|
|
|
|
|
2005-07-02 14:16:33 +02:00
|
|
|
|
print '<form id="login" method="post" action="' . $_SERVER['PHP_SELF'] . '" name="identification">';
|
|
|
|
|
|
|
|
|
|
|
|
print '
|
|
|
|
|
|
<table cellpadding="0" cellspacing="0" border="0" align="center" width="350">
|
|
|
|
|
|
<tr class="vmenu"><td>Dolibarr '.DOL_VERSION.'</td></tr>
|
|
|
|
|
|
</table>
|
|
|
|
|
|
|
|
|
|
|
|
<br>
|
|
|
|
|
|
|
|
|
|
|
|
<table cellpadding="2" align="center" width="350">
|
|
|
|
|
|
|
|
|
|
|
|
<tr><td colspan="3"> </td></tr>
|
|
|
|
|
|
|
|
|
|
|
|
<tr><td align="left"> <b>'.$langs->trans("Login").'</b> </td>
|
|
|
|
|
|
<td><input name="username" class="flat" size="15" maxlength="25" value="" tabindex="1" /></td>
|
|
|
|
|
|
';
|
|
|
|
|
|
|
|
|
|
|
|
if (file_exists(DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/login_logo.png'))
|
|
|
|
|
|
{
|
|
|
|
|
|
print '<td rowspan="2"><img src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/login_logo.png"></td>';
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
print '<td rowspan="2"><img src="'.DOL_URL_ROOT.'/theme/login_logo.png"></td>';
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
print '
|
|
|
|
|
|
</tr>
|
|
|
|
|
|
|
|
|
|
|
|
<tr><td align="left"> <b>'.$langs->trans("Password").'</b> </a></td>
|
|
|
|
|
|
<td><input name="password" class="flat" type="password" size="15" maxlength="30" tabindex="2" />
|
|
|
|
|
|
</td></tr>
|
|
|
|
|
|
|
|
|
|
|
|
<tr><td colspan="3" style="text-align:center;"><br>
|
2005-08-11 21:13:08 +02:00
|
|
|
|
<input type="submit" class="button" value=" '.$langs->trans("Connection").' " tabindex="4" />
|
2005-07-02 14:16:33 +02:00
|
|
|
|
</td></tr>
|
|
|
|
|
|
|
|
|
|
|
|
</table>
|
2005-08-11 21:13:08 +02:00
|
|
|
|
<input type="hidden" name="loginfunction" value="loginfunction" />
|
|
|
|
|
|
|
2005-07-02 14:16:33 +02:00
|
|
|
|
';
|
|
|
|
|
|
|
2005-04-15 20:28:11 +02:00
|
|
|
|
print '</form>';
|
2003-08-30 12:48:01 +02:00
|
|
|
|
}
|
2004-07-16 00:17:39 +02:00
|
|
|
|
|
2005-01-02 14:57:45 +01:00
|
|
|
|
|
2004-12-28 16:36:40 +01:00
|
|
|
|
/**
|
2004-08-07 16:41:29 +02:00
|
|
|
|
\brief Affiche message erreur de type acces interdit et arrete le programme
|
2005-01-02 14:57:45 +01:00
|
|
|
|
\remarks L'appel a cette fonction termine le code.
|
2004-07-16 00:17:39 +02:00
|
|
|
|
*/
|
2003-03-23 16:22:32 +01:00
|
|
|
|
function accessforbidden()
|
|
|
|
|
|
{
|
2005-01-02 14:57:45 +01:00
|
|
|
|
global $user, $langs;
|
|
|
|
|
|
$langs->load("other");
|
2004-07-25 19:43:23 +02:00
|
|
|
|
|
2003-03-23 16:22:32 +01:00
|
|
|
|
llxHeader();
|
2005-01-02 14:57:45 +01:00
|
|
|
|
print '<div class="error">'.$langs->trans("ErrorForbidden").'</div>';
|
|
|
|
|
|
print '<br>';
|
2005-03-26 14:40:07 +01:00
|
|
|
|
if ($user->login)
|
|
|
|
|
|
{
|
|
|
|
|
|
print $langs->trans("CurrentLogin").': <font class="error">'.$user->login.'</font><br>';
|
2005-01-02 14:57:45 +01:00
|
|
|
|
print $langs->trans("ErrorForbidden2",$langs->trans("Home"),$langs->trans("Users"));
|
|
|
|
|
|
}
|
2005-03-26 14:40:07 +01:00
|
|
|
|
elseif (! empty($_SERVER["REMOTE_USER"]))
|
|
|
|
|
|
{
|
|
|
|
|
|
print $langs->trans("CurrentLogin").': <font class="error">'.$_SERVER["REMOTE_USER"]."</font><br>";
|
|
|
|
|
|
print $langs->trans("ErrorForbidden2",$langs->trans("Home"),$langs->trans("Users"));
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2005-01-02 14:57:45 +01:00
|
|
|
|
print $langs->trans("ErrorForbidden3");
|
|
|
|
|
|
}
|
2003-03-23 16:22:32 +01:00
|
|
|
|
llxFooter();
|
|
|
|
|
|
exit(0);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2005-01-02 14:57:45 +01:00
|
|
|
|
|
2004-12-28 16:36:40 +01:00
|
|
|
|
/**
|
2005-08-16 15:14:13 +02:00
|
|
|
|
\brief Affiche message erreur system avec toutes les informations pour faciliter le diagnostic et la remont<EFBFBD>e des bugs.
|
2005-01-02 14:57:45 +01:00
|
|
|
|
On doit appeler cette fonction quand une erreur technique bloquante est rencontr<EFBFBD>e.
|
2005-08-16 15:14:13 +02:00
|
|
|
|
Toutefois, il faut essayer de ne l'appeler qu'au sein de pages php, les classes devant
|
2005-01-02 14:57:45 +01:00
|
|
|
|
renvoyer leur erreur par l'interm<EFBFBD>diaire de leur propri<EFBFBD>t<EFBFBD> "error".
|
|
|
|
|
|
\param db Handler de base utilis<EFBFBD>
|
|
|
|
|
|
\param msg Message compl<EFBFBD>mentaire <EFBFBD> afficher
|
2004-07-24 21:11:01 +02:00
|
|
|
|
*/
|
|
|
|
|
|
function dolibarr_print_error($db='',$msg='')
|
|
|
|
|
|
{
|
2005-04-30 03:47:42 +02:00
|
|
|
|
global $langs;
|
|
|
|
|
|
$syslog = '';
|
|
|
|
|
|
|
2005-08-11 21:13:08 +02:00
|
|
|
|
// Si erreur intervenue avant chargement langue
|
2005-04-30 03:47:42 +02:00
|
|
|
|
if (! $langs) {
|
|
|
|
|
|
require_once(DOL_DOCUMENT_ROOT ."/translate.class.php");
|
|
|
|
|
|
$langs = new Translate(DOL_DOCUMENT_ROOT ."/langs", "en_US");
|
|
|
|
|
|
$langs->load("main");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ($_SERVER['DOCUMENT_ROOT']) // Mode web
|
|
|
|
|
|
{
|
|
|
|
|
|
print $langs->trans("DolibarrHasDetectedError").".<br>\n";
|
|
|
|
|
|
print $langs->trans("InformationToHelpDiagnose").":<br><br>\n";
|
|
|
|
|
|
|
2005-01-02 14:57:45 +01:00
|
|
|
|
print "<b>".$langs->trans("Server").":</b> ".$_SERVER["SERVER_SOFTWARE"]."<br>\n";;
|
2005-04-30 03:47:42 +02:00
|
|
|
|
print "<b>".$langs->trans("RequestedUrl").":</b> ".$_SERVER["REQUEST_URI"]."<br>\n";;
|
2004-09-22 21:20:19 +02:00
|
|
|
|
print "<b>QUERY_STRING:</b> ".$_SERVER["QUERY_STRING"]."<br>\n";;
|
2005-04-30 03:47:42 +02:00
|
|
|
|
print "<b>".$langs->trans("Referer").":</b> ".$_SERVER["HTTP_REFERER"]."<br>\n";;
|
2004-09-22 21:20:19 +02:00
|
|
|
|
$syslog.="url=".$_SERVER["REQUEST_URI"];
|
|
|
|
|
|
$syslog.=", query_string=".$_SERVER["QUERY_STRING"];
|
|
|
|
|
|
}
|
2005-04-30 03:47:42 +02:00
|
|
|
|
else // Mode CLI
|
2005-01-02 14:57:45 +01:00
|
|
|
|
{
|
2005-04-30 03:47:42 +02:00
|
|
|
|
|
2005-08-11 21:13:08 +02:00
|
|
|
|
print $langs->trans("ErrorInternalErrorDetected")."\n";
|
2005-04-30 03:47:42 +02:00
|
|
|
|
$syslog.="pid=".getmypid();
|
2004-09-22 21:20:19 +02:00
|
|
|
|
}
|
2005-04-30 03:47:42 +02:00
|
|
|
|
|
2005-08-11 21:13:08 +02:00
|
|
|
|
if ($db)
|
|
|
|
|
|
{
|
2005-04-30 03:47:42 +02:00
|
|
|
|
if ($_SERVER['DOCUMENT_ROOT']) // Mode web
|
|
|
|
|
|
{
|
|
|
|
|
|
print "<br>\n";
|
|
|
|
|
|
print "<b>".$langs->trans("DatabaseTypeManager").":</b> ".$db->type."<br>\n";
|
|
|
|
|
|
print "<b>".$langs->trans("RequestLastAccess").":</b> ".($db->lastquery()?$db->lastquery():$langs->trans("ErrorNoRequestRan"))."<br>\n";
|
|
|
|
|
|
print "<b>".$langs->trans("ReturnCodeLastAccess").":</b> ".$db->errno()."<br>\n";
|
|
|
|
|
|
print "<b>".$langs->trans("InformationLastAccess").":</b> ".$db->error()."<br>\n";
|
|
|
|
|
|
}
|
|
|
|
|
|
else // Mode CLI
|
|
|
|
|
|
{
|
|
|
|
|
|
print $langs->trans("DatabaseTypeManager").":\n".$db->type."\n";
|
|
|
|
|
|
print $langs->trans("RequestLastAccess").":\n".($db->lastquery()?$db->lastquery():$langs->trans("ErrorNoRequestRan"))."\n";
|
|
|
|
|
|
print $langs->trans("ReturnCodeLastAccess").":\n".$db->errno()."\n";
|
|
|
|
|
|
print $langs->trans("InformationLastAccess").":\n".$db->error()."\n";
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
$syslog.=", sql=".$db->lastquery();
|
|
|
|
|
|
$syslog.=", db_error=".$db->error();
|
2005-01-02 14:57:45 +01:00
|
|
|
|
}
|
2005-04-30 03:47:42 +02:00
|
|
|
|
|
|
|
|
|
|
if ($msg) {
|
|
|
|
|
|
if ($_SERVER['DOCUMENT_ROOT']) // Mode web
|
|
|
|
|
|
{
|
|
|
|
|
|
print "<b>".$langs->trans("Message").":</b> ".$msg."<br>\n" ;
|
|
|
|
|
|
}
|
|
|
|
|
|
else // Mode CLI
|
|
|
|
|
|
{
|
|
|
|
|
|
print $langs->trans("Message").":\n".$msg."\n" ;
|
|
|
|
|
|
}
|
|
|
|
|
|
$syslog.=", msg=".$msg;
|
2004-09-22 21:20:19 +02:00
|
|
|
|
}
|
2005-04-30 03:47:42 +02:00
|
|
|
|
|
|
|
|
|
|
dolibarr_syslog("Error $syslog");
|
2004-07-24 21:11:01 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
2004-12-04 17:33:12 +01:00
|
|
|
|
|
2004-12-28 16:36:40 +01:00
|
|
|
|
/**
|
2004-08-07 16:41:29 +02:00
|
|
|
|
\brief Deplacer les fichiers telecharg<EFBFBD>s
|
2004-07-16 00:17:39 +02:00
|
|
|
|
\param src_file fichier source
|
|
|
|
|
|
\param dest_file fichier de destination
|
2004-08-07 16:41:29 +02:00
|
|
|
|
\return int le resultat du move_uploaded_file
|
2004-07-16 00:17:39 +02:00
|
|
|
|
*/
|
2003-09-12 18:45:27 +02:00
|
|
|
|
function doliMoveFileUpload($src_file, $dest_file)
|
|
|
|
|
|
{
|
|
|
|
|
|
$file_name = $dest_file;
|
|
|
|
|
|
|
|
|
|
|
|
if (substr($file_name, strlen($file_name) -3 , 3) == 'php')
|
|
|
|
|
|
{
|
|
|
|
|
|
$file_name = $dest_file . ".txt";
|
|
|
|
|
|
}
|
2004-07-16 00:17:39 +02:00
|
|
|
|
|
2003-09-12 18:45:27 +02:00
|
|
|
|
return move_uploaded_file($src_file, $file_name);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2004-07-16 00:17:39 +02:00
|
|
|
|
|
2004-12-28 16:36:40 +01:00
|
|
|
|
/**
|
2005-08-11 21:13:08 +02:00
|
|
|
|
\brief Sauvegarde parametrage personnel
|
|
|
|
|
|
\param db Handler d'acc<EFBFBD>s base
|
|
|
|
|
|
\param user Objet utilisateur
|
|
|
|
|
|
\param url Si defini, on sauve parametre du tableau tab dont cl<EFBFBD> = sortfield, sortorder, begin et page
|
|
|
|
|
|
Si non defini on sauve tous parametres du tableau tab
|
|
|
|
|
|
\param tab Tableau (cl<EFBFBD>=>valeur) des param<EFBFBD>tres <EFBFBD> sauvegarder
|
2004-08-07 16:41:29 +02:00
|
|
|
|
*/
|
2005-08-11 21:13:08 +02:00
|
|
|
|
function dolibarr_set_user_page_param($db, &$user, $url='', $tab)
|
2004-02-27 15:24:42 +01:00
|
|
|
|
{
|
2005-08-11 21:13:08 +02:00
|
|
|
|
$db->begin();
|
|
|
|
|
|
|
|
|
|
|
|
// On efface param<61>tres anciens
|
|
|
|
|
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."user_param";
|
|
|
|
|
|
$sql.= " WHERE fk_user = ".$user->id;
|
|
|
|
|
|
if ($url) $sql.=" AND page='".$url."'";
|
|
|
|
|
|
else $sql.=" AND page=''";
|
|
|
|
|
|
$sql.=";";
|
|
|
|
|
|
$resql=$db->query($sql);
|
|
|
|
|
|
if (! $resql)
|
2004-07-16 00:17:39 +02:00
|
|
|
|
{
|
2005-08-11 21:13:08 +02:00
|
|
|
|
dolibarr_print_error($db);
|
|
|
|
|
|
}
|
|
|
|
|
|
dolibarr_syslog("functions.inc.php::dolibarr_set_user_page_param $sql");
|
2003-09-12 18:45:27 +02:00
|
|
|
|
|
2005-08-11 21:13:08 +02:00
|
|
|
|
foreach ($tab as $key=>$value)
|
|
|
|
|
|
{
|
|
|
|
|
|
// On positionne nouveaux param<61>tres
|
|
|
|
|
|
if ($value && (! $url || in_array($key,array('sortfield','sortorder','begin','page'))))
|
|
|
|
|
|
{
|
|
|
|
|
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX."user_param(fk_user,page,param,value)";
|
|
|
|
|
|
$sql.= " VALUES (".$user->id.",";
|
|
|
|
|
|
if ($url) $sql.= " '".urlencode($url)."',";
|
|
|
|
|
|
else $sql.= " '',";
|
|
|
|
|
|
$sql.= " '".$key."','".addslashes($value)."');";
|
|
|
|
|
|
dolibarr_syslog("functions.inc.php::dolibarr_set_user_page_param $sql");
|
|
|
|
|
|
$db->query($sql);
|
|
|
|
|
|
|
|
|
|
|
|
$user->page_param[$key] = $value;
|
|
|
|
|
|
}
|
2004-02-27 15:24:42 +01:00
|
|
|
|
}
|
2005-08-11 21:13:08 +02:00
|
|
|
|
|
|
|
|
|
|
$db->commit();
|
2004-02-27 15:24:42 +01:00
|
|
|
|
}
|
2003-09-12 18:45:27 +02:00
|
|
|
|
|
2004-12-28 16:36:40 +01:00
|
|
|
|
/**
|
2004-08-07 16:41:29 +02:00
|
|
|
|
\brief Transcodage de francs en euros
|
2004-07-16 00:17:39 +02:00
|
|
|
|
\param zonein zone de depart
|
|
|
|
|
|
\param devise type de devise
|
2004-08-07 16:41:29 +02:00
|
|
|
|
\return r resultat transcod<EFBFBD>
|
2004-07-16 00:17:39 +02:00
|
|
|
|
*/
|
2002-12-17 21:57:07 +01:00
|
|
|
|
function transcoS2L($zonein,$devise)
|
2004-07-16 00:17:39 +02:00
|
|
|
|
{
|
2002-12-17 21:57:07 +01:00
|
|
|
|
// Open source offert par <A HREF="mailto:alainfloch@free.fr?subject=chif2let">alainfloch@free.fr</A> 28/10/2001, sans garantie.
|
|
|
|
|
|
// d<>but de la fonction de transcodification de somme en toutes lettres
|
|
|
|
|
|
|
2004-07-16 00:17:39 +02:00
|
|
|
|
/* $zonein = "123,56";
|
2002-12-17 21:57:07 +01:00
|
|
|
|
* $devise = "E"; // pr<70>ciser F si francs , sinon ce sera de l'euro
|
|
|
|
|
|
* $r = transcoS2L($zonein,$devise); // appeler la fonction
|
|
|
|
|
|
* echo "r<EFBFBD>sultat vaut $r<br>";
|
|
|
|
|
|
* $zonelettresM = strtoupper($r); // si vous voulez la m<>me zone mais tout en majuscules
|
|
|
|
|
|
* echo "r<EFBFBD>sultat en Majuscules vaut $zonelettresM<br>";
|
|
|
|
|
|
* $zonein = "1,01";
|
|
|
|
|
|
* $r = transcoS2L($zonein,$devise);
|
|
|
|
|
|
* echo "r<EFBFBD>sultat vaut $r<br>";
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($devise == "F")
|
2002-12-17 21:57:32 +01:00
|
|
|
|
{
|
|
|
|
|
|
$unite_singulier = " franc ";
|
|
|
|
|
|
$unite_pluriel = " francs ";
|
|
|
|
|
|
$cent_singulier = " centime";
|
|
|
|
|
|
}
|
2002-12-17 21:57:07 +01:00
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
$unite_singulier = " euro ";
|
|
|
|
|
|
$unite_pluriel = " euros ";
|
|
|
|
|
|
$cent_singulier = " centime";
|
|
|
|
|
|
}
|
2004-07-16 00:17:39 +02:00
|
|
|
|
|
2002-12-17 21:57:07 +01:00
|
|
|
|
$arr1_99 = array("z<EFBFBD>ro","un","deux","trois",
|
|
|
|
|
|
"quatre","cinq","six","sept",
|
|
|
|
|
|
"huit","neuf","dix","onze","douze",
|
|
|
|
|
|
"treize","quatorze","quinze","seize",
|
|
|
|
|
|
"dix-sept","dix-huit","dix-neuf","vingt ");
|
|
|
|
|
|
|
|
|
|
|
|
$arr1_99[30] = "trente ";
|
|
|
|
|
|
$arr1_99[40] = "quarante ";
|
|
|
|
|
|
$arr1_99[50] = "cinquante ";
|
|
|
|
|
|
$arr1_99[60] = "soixante ";
|
|
|
|
|
|
$arr1_99[70] = "soixante-dix ";
|
|
|
|
|
|
$arr1_99[71] = "soixante et onze";
|
|
|
|
|
|
$arr1_99[80] = "quatre-vingts ";
|
|
|
|
|
|
$i = 22;
|
|
|
|
|
|
while ($i < 63) {// initialise la table
|
|
|
|
|
|
$arr1_99[$i - 1] = $arr1_99[$i - 2]." et un";
|
|
|
|
|
|
$j = 0;
|
|
|
|
|
|
while ($j < 8) {
|
|
|
|
|
|
$k = $i + $j;
|
|
|
|
|
|
$arr1_99[$k] = $arr1_99[$i - 2].$arr1_99[$j + 2];
|
|
|
|
|
|
$j++;
|
|
|
|
|
|
}
|
|
|
|
|
|
$i = $i + 10;
|
|
|
|
|
|
} // fin initialise la table
|
|
|
|
|
|
|
|
|
|
|
|
$i = 12;
|
|
|
|
|
|
while ($i < 20) {// initialise la table (suite)
|
|
|
|
|
|
$j = 60 + $i;
|
|
|
|
|
|
$arr1_99[$j] = "soixante-".$arr1_99[$i];
|
|
|
|
|
|
$i++;
|
|
|
|
|
|
} // fin initialise la table (suite)
|
|
|
|
|
|
|
|
|
|
|
|
$i = 1;
|
|
|
|
|
|
while ($i < 20) {// initialise la table (fin)
|
|
|
|
|
|
$j = 80 + $i;
|
|
|
|
|
|
$arr1_99[$j] = "quatre-vingt-".$arr1_99[$i];
|
|
|
|
|
|
$i++;
|
|
|
|
|
|
} // fin initialise la table (fin)
|
2003-02-10 18:25:06 +01:00
|
|
|
|
// echo "Pour une valeur en entr<74>e = $zonein<br>"; //pour ceux qui ne croient que ce qu'ils voient !
|
2002-12-17 21:57:07 +01:00
|
|
|
|
// quelques petits controles s'imposent !!
|
|
|
|
|
|
$valid = "[a-zA-Z\&\<EFBFBD>\"\'\(\-\<EFBFBD>\_\<EFBFBD>\<EFBFBD>\)\=\;\:\!\*\$\^\<\>]";
|
|
|
|
|
|
if (ereg($valid,$zonein))
|
|
|
|
|
|
{
|
|
|
|
|
|
$r = "<b>la cha<68>ne ".$zonein." n'est pas valide</b>";
|
|
|
|
|
|
return($r);
|
|
|
|
|
|
}
|
|
|
|
|
|
$zone = explode(" ",$zonein); // supprimer les blancs s<>parateurs
|
|
|
|
|
|
$zonein = implode("",$zone); // reconcat<61>ne la zone input
|
|
|
|
|
|
$zone = explode(".",$zonein); // supprimer les points s<>parateurs
|
|
|
|
|
|
$zonein = implode("",$zone); // reconcat<61>ne la zone input, <20>a c'est fort ! merci PHP
|
|
|
|
|
|
$virg = strpos($zonein,",",1); // <20> la poursuite de la virgule
|
|
|
|
|
|
$i = strlen($zonein); // et de la longueur de la zone input
|
|
|
|
|
|
if ($virg == 0) { // ya pas de virgule
|
|
|
|
|
|
if ($i > 7)
|
|
|
|
|
|
{
|
|
|
|
|
|
$r = "<b>la cha<68>ne ".$zonein." est trop longue (maxi = 9 millions)</b>";
|
|
|
|
|
|
return($r);
|
|
|
|
|
|
}
|
|
|
|
|
|
$deb = 7 - $i;
|
|
|
|
|
|
$zoneanaly = substr($zonechiffres,0,$deb).$zonein.",00";
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{ //ya une virgule
|
|
|
|
|
|
$ti = explode(",",$zonein); // mettre de c<>t<EFBFBD> ce qu'il y a devant la virgule
|
|
|
|
|
|
$i = strlen($ti[0]); // en controler la longueur
|
|
|
|
|
|
$zonechiffres = "0000000,00";
|
|
|
|
|
|
if ($i > 7)
|
|
|
|
|
|
{
|
|
|
|
|
|
$r = "<b>la cha<68>ne ".$zonein." est trop longue (maxi = 9 millions,00)</b>";
|
|
|
|
|
|
return($r);
|
|
|
|
|
|
}
|
|
|
|
|
|
$deb = 7 - $i;
|
|
|
|
|
|
$zoneanaly = substr($zonechiffres,0,$deb).$zonein;
|
|
|
|
|
|
}
|
|
|
|
|
|
$M= substr($zoneanaly,0,1);
|
|
|
|
|
|
if ($M != 0)
|
|
|
|
|
|
{ // qui veut gagner des millions
|
|
|
|
|
|
$r = $arr1_99[$M]." million";
|
|
|
|
|
|
if ($M ==1) $r = $r." ";
|
|
|
|
|
|
else $r = $r."s ";
|
|
|
|
|
|
if (substr($zoneanaly,1,6)==0)
|
|
|
|
|
|
{
|
|
|
|
|
|
if ($devise == 'F') $r = $r." de ";
|
|
|
|
|
|
else $r = $r."d'";
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
$CM= substr($zoneanaly,1,1);
|
|
|
|
|
|
if ($CM == 1)
|
|
|
|
|
|
{ // qui veut gagner des centaines de mille
|
|
|
|
|
|
$r = $r." cent ";
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{ // ya des centaines de mille
|
|
|
|
|
|
if ($CM > 1)
|
|
|
|
|
|
{
|
|
|
|
|
|
$r = $r. $arr1_99[$CM]." cent ";
|
|
|
|
|
|
}
|
|
|
|
|
|
} // fin du else ya des centaines de mille
|
|
|
|
|
|
$MM= substr($zoneanaly,2,2);
|
|
|
|
|
|
if (substr($zoneanaly,2,1)==0){ $MM = substr($zoneanaly,3,1);} // enlever le z<>ro des milliers cause indexation
|
|
|
|
|
|
if ($MM ==0 && $CM > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
$r = $r."mille ";
|
|
|
|
|
|
}
|
|
|
|
|
|
if ($MM != 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
if ($MM == 80)
|
|
|
|
|
|
{
|
|
|
|
|
|
$r = $r."quatre-vingt mille ";
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
if ($MM > 1 )
|
|
|
|
|
|
{
|
|
|
|
|
|
$r = $r.$arr1_99[$MM]." mille ";
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
if ($CM == 0) $r = $r." mille ";
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
$r = $r.$arr1_99[$MM]." mille ";
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
$C2= substr($zoneanaly,5,2);
|
|
|
|
|
|
if (substr($zoneanaly,5,1)==0){ $C2 = substr($zoneanaly,6,1);} // enlever le z<>ro des centaines cause indexation
|
|
|
|
|
|
$C1= substr($zoneanaly,4,1);
|
|
|
|
|
|
if ($C2 ==0 && $C1 > 1)
|
|
|
|
|
|
{
|
|
|
|
|
|
$r = $r.$arr1_99[$C1]." cents ";
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
if ($C1 == 1) $r = $r." cent ";
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
if ($C1 > 1) $r = $r.$arr1_99[$C1]." cent ";
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2004-07-16 00:17:39 +02:00
|
|
|
|
if ($C2 != 0)
|
2002-12-17 21:57:07 +01:00
|
|
|
|
{
|
|
|
|
|
|
$r = $r.$arr1_99[$C2];
|
|
|
|
|
|
}
|
|
|
|
|
|
if ($virg !=0)
|
|
|
|
|
|
{
|
|
|
|
|
|
if ($ti[0] > 1) $r = $r. $unite_pluriel; else $r = "un ".$unite_singulier;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
if ($zonein > 1) $r = $r.$unite_pluriel; else $r = "un ".$unite_singulier;
|
|
|
|
|
|
}
|
|
|
|
|
|
$UN= substr($zoneanaly,8,2);
|
|
|
|
|
|
if ($UN != "00")
|
|
|
|
|
|
{
|
|
|
|
|
|
$cts = $UN;
|
|
|
|
|
|
if (substr($UN,0,1)==0){ $cts = substr($UN,1,1);} // enlever le z<>ro des centimes cause indexation
|
|
|
|
|
|
$r = $r." et ". $arr1_99[$cts].$cent_singulier;
|
|
|
|
|
|
if ($UN > 1) $r =$r."s"; // accorde au pluriel
|
|
|
|
|
|
}
|
|
|
|
|
|
$r1 = ltrim($r); // enleve quelques blancs possibles en d<>but de zone
|
|
|
|
|
|
$r = ucfirst($r1); // met le 1er caract<63>re en Majuscule, c'est + zoli
|
|
|
|
|
|
return($r); // retourne le r<>sultat
|
|
|
|
|
|
} // fin fonction transcoS2L
|
|
|
|
|
|
|
2004-07-25 19:43:23 +02:00
|
|
|
|
|
2004-12-28 16:36:40 +01:00
|
|
|
|
/**
|
|
|
|
|
|
\brief Affichage de la ligne de titre d'un tabelau
|
2005-06-11 13:38:19 +02:00
|
|
|
|
\param name libelle champ
|
|
|
|
|
|
\param file url pour clic sur tri
|
|
|
|
|
|
\param field champ de tri
|
2004-12-28 16:36:40 +01:00
|
|
|
|
\param begin ("" par defaut)
|
|
|
|
|
|
\param options ("" par defaut)
|
2005-06-11 13:38:19 +02:00
|
|
|
|
\param td options de l'attribut td ("" par defaut)
|
2004-12-28 16:36:40 +01:00
|
|
|
|
\param sortfield nom du champ sur lequel est effectu<EFBFBD> le tri du tableau
|
2005-06-11 13:38:19 +02:00
|
|
|
|
\param sortorder ordre du tri
|
2004-07-16 00:17:39 +02:00
|
|
|
|
*/
|
2005-06-11 13:38:19 +02:00
|
|
|
|
function print_liste_field_titre($name, $file, $field, $begin="", $options="", $td="", $sortfield="", $sortorder="")
|
2004-10-31 14:34:08 +01:00
|
|
|
|
{
|
|
|
|
|
|
global $conf;
|
2005-01-08 23:44:50 +01:00
|
|
|
|
// Le champ de tri est mis en <20>vidence.
|
|
|
|
|
|
// Exemple si (sortfield,field)=("nom","xxx.nom") ou (sortfield,field)=("nom","nom")
|
|
|
|
|
|
if ($sortfield == $field || $sortfield == ereg_replace("^[^\.]+\.","",$field))
|
2003-06-21 16:56:42 +02:00
|
|
|
|
{
|
2005-05-07 16:59:43 +02:00
|
|
|
|
print '<td class="liste_titre_sel" '. $td.'>';
|
2003-06-21 16:56:42 +02:00
|
|
|
|
}
|
2004-10-31 14:34:08 +01:00
|
|
|
|
else
|
2003-06-21 16:56:42 +02:00
|
|
|
|
{
|
2005-05-07 16:59:43 +02:00
|
|
|
|
print '<td class="liste_titre" '. $td.'>';
|
2003-06-21 16:56:42 +02:00
|
|
|
|
}
|
2004-10-31 14:34:08 +01:00
|
|
|
|
print $name." ";
|
2005-06-11 13:38:19 +02:00
|
|
|
|
if (! $sortorder)
|
|
|
|
|
|
{
|
|
|
|
|
|
print '<a href="'.$file.'?sortfield='.$field.'&sortorder=asc&begin='.$begin.$options.'">'.img_down("A-Z",1).'</a>';
|
|
|
|
|
|
print '<a href="'.$file.'?sortfield='.$field.'&sortorder=desc&begin='.$begin.$options.'">'.img_up("Z-A",1).'</a>';
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
if ($field != $sortfield) {
|
|
|
|
|
|
print '<a href="'.$file.'?sortfield='.$field.'&sortorder=asc&begin='.$begin.$options.'">'.img_down("A-Z",1).'</a>';
|
|
|
|
|
|
print '<a href="'.$file.'?sortfield='.$field.'&sortorder=desc&begin='.$begin.$options.'">'.img_up("Z-A",1).'</a>';
|
|
|
|
|
|
}
|
|
|
|
|
|
else {
|
|
|
|
|
|
if ($sortorder == 'DESC' ) {
|
|
|
|
|
|
print '<a href="'.$file.'?sortfield='.$field.'&sortorder=asc&begin='.$begin.$options.'">'.img_down("A-Z",1).'</a>';
|
|
|
|
|
|
print '<a href="'.$file.'?sortfield='.$field.'&sortorder=desc&begin='.$begin.$options.'">'.img_up("Z-A",0).'</a>';
|
|
|
|
|
|
}
|
|
|
|
|
|
if ($sortorder == 'ASC' ) {
|
|
|
|
|
|
print '<a href="'.$file.'?sortfield='.$field.'&sortorder=asc&begin='.$begin.$options.'">'.img_down("A-Z",0).'</a>';
|
|
|
|
|
|
print '<a href="'.$file.'?sortfield='.$field.'&sortorder=desc&begin='.$begin.$options.'">'.img_up("Z-A",1).'</a>';
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2004-10-31 14:34:08 +01:00
|
|
|
|
print "</td>";
|
2003-06-21 16:56:42 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
2004-12-28 16:36:40 +01:00
|
|
|
|
/**
|
2004-08-07 16:41:29 +02:00
|
|
|
|
\brief Affichage d'un titre
|
2005-01-18 22:09:16 +01:00
|
|
|
|
\param titre Le titre a afficher
|
2004-07-16 00:17:39 +02:00
|
|
|
|
*/
|
2002-12-23 15:10:24 +01:00
|
|
|
|
function print_titre($titre)
|
2003-04-26 16:25:47 +02:00
|
|
|
|
{
|
2005-08-11 21:13:08 +02:00
|
|
|
|
print '<div class="titre">'.$titre.'</div>';
|
2002-05-06 21:10:48 +02:00
|
|
|
|
}
|
2004-07-16 00:17:39 +02:00
|
|
|
|
|
2004-12-28 16:36:40 +01:00
|
|
|
|
/**
|
2004-08-07 16:41:29 +02:00
|
|
|
|
\brief Affichage d'un titre d'une fiche, align<EFBFBD> a gauche
|
2005-01-18 22:09:16 +01:00
|
|
|
|
\param titre Le titre a afficher
|
|
|
|
|
|
\param mesg Message supl<EFBFBD>mentaire <EFBFBD> afficher <EFBFBD> droite
|
2004-07-16 00:17:39 +02:00
|
|
|
|
*/
|
2003-06-28 16:05:03 +02:00
|
|
|
|
function print_fiche_titre($titre, $mesg='')
|
|
|
|
|
|
{
|
2005-08-11 21:13:08 +02:00
|
|
|
|
print "\n";
|
|
|
|
|
|
print '<table width="100%" border="0" class="notopnoleftnoright">';
|
|
|
|
|
|
print '<tr><td class="notopnoleftnoright"><div class="titre">'.$titre.'</div></td>';
|
|
|
|
|
|
if (strlen($mesg))
|
2003-06-28 16:05:03 +02:00
|
|
|
|
{
|
2005-08-11 21:13:08 +02:00
|
|
|
|
print '<td align="right" valign="middle"><b>'.$mesg.'</b></td>';
|
2003-06-28 16:05:03 +02:00
|
|
|
|
}
|
2005-08-11 21:13:08 +02:00
|
|
|
|
print '</tr></table>'."\n";
|
2003-06-28 16:05:03 +02:00
|
|
|
|
}
|
2004-06-08 13:14:42 +02:00
|
|
|
|
|
2004-12-28 16:36:40 +01:00
|
|
|
|
/**
|
2004-08-07 16:41:29 +02:00
|
|
|
|
\brief Effacement d'un fichier
|
2004-07-16 00:17:39 +02:00
|
|
|
|
\param file fichier a effacer
|
|
|
|
|
|
*/
|
2003-06-17 16:36:13 +02:00
|
|
|
|
function dol_delete_file($file)
|
|
|
|
|
|
{
|
|
|
|
|
|
return unlink($file);
|
|
|
|
|
|
}
|
2004-06-08 13:14:42 +02:00
|
|
|
|
|
2003-04-26 16:25:47 +02:00
|
|
|
|
|
2004-12-28 16:36:40 +01:00
|
|
|
|
/**
|
2004-08-07 16:41:29 +02:00
|
|
|
|
\brief Fonction print_barre_liste
|
2004-07-28 00:50:27 +02:00
|
|
|
|
\param titre titre de la page
|
|
|
|
|
|
\param page num<EFBFBD>ro de la page
|
|
|
|
|
|
\param file lien
|
2005-08-11 21:13:08 +02:00
|
|
|
|
\param options options cellule td ('' par defaut)
|
|
|
|
|
|
\param sortfield champ de tri ('' par defaut)
|
|
|
|
|
|
\param sortorder ordre de tri ('' par defaut)
|
|
|
|
|
|
\param center chaine du centre ('' par defaut)
|
2004-08-07 16:41:29 +02:00
|
|
|
|
\param num nombre d'<EFBFBD>l<EFBFBD>ment total
|
2004-07-28 00:50:27 +02:00
|
|
|
|
*/
|
2005-08-11 21:13:08 +02:00
|
|
|
|
function print_barre_liste($titre, $page, $file, $options='', $sortfield='', $sortorder='', $center='', $num=-1)
|
2005-06-11 13:38:19 +02:00
|
|
|
|
{
|
|
|
|
|
|
global $conf;
|
2003-07-10 15:07:56 +02:00
|
|
|
|
|
2005-06-11 13:38:19 +02:00
|
|
|
|
if ($num > $conf->liste_limit or $num == -1)
|
2003-07-10 15:07:56 +02:00
|
|
|
|
{
|
2005-06-11 13:38:19 +02:00
|
|
|
|
$nextpage = 1;
|
2003-07-10 15:07:56 +02:00
|
|
|
|
}
|
2005-06-11 13:38:19 +02:00
|
|
|
|
else
|
2003-07-10 15:07:56 +02:00
|
|
|
|
{
|
2005-06-11 13:38:19 +02:00
|
|
|
|
$nextpage = 0;
|
2003-07-10 15:07:56 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
2005-08-11 21:13:08 +02:00
|
|
|
|
print '<table width="100%" border="0" class="notopnoleftnoright">';
|
2003-03-27 23:13:57 +01:00
|
|
|
|
|
2005-06-11 13:38:19 +02:00
|
|
|
|
if ($page > 0 || $num > $conf->liste_limit)
|
2003-03-25 22:46:18 +01:00
|
|
|
|
{
|
2005-06-11 13:38:19 +02:00
|
|
|
|
print '<tr><td><div class="titre">'.$titre.' - page '.($page+1);
|
|
|
|
|
|
print '</div></td>';
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
print '<tr><td><div class="titre">'.$titre.'</div></td>';
|
2003-03-25 22:46:18 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2005-08-11 21:13:08 +02:00
|
|
|
|
if ($center)
|
2003-03-25 22:46:18 +01:00
|
|
|
|
{
|
2005-08-11 21:13:08 +02:00
|
|
|
|
print '<td align="left">'.$center.'</td>';
|
2003-03-25 22:46:18 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2005-06-11 13:38:19 +02:00
|
|
|
|
print '<td align="right">';
|
|
|
|
|
|
|
|
|
|
|
|
if ($sortfield) $options .= "&sortfield=$sortfield";
|
|
|
|
|
|
if ($sortorder) $options .= "&sortorder=$sortorder";
|
2003-07-10 15:07:56 +02:00
|
|
|
|
|
2005-06-11 13:38:19 +02:00
|
|
|
|
// Affichage des fleches de navigation
|
|
|
|
|
|
print_fleche_navigation($page,$file,$options,$nextpage);
|
2003-07-10 15:07:56 +02:00
|
|
|
|
|
2005-08-11 21:13:08 +02:00
|
|
|
|
print '</td></tr></table>';
|
2002-05-06 21:10:48 +02:00
|
|
|
|
}
|
2003-05-05 13:14:48 +02:00
|
|
|
|
|
2004-12-28 16:36:40 +01:00
|
|
|
|
/**
|
2004-08-07 16:41:29 +02:00
|
|
|
|
\brief Fonction servant a afficher les fleches de navigation dans les pages de listes
|
2004-07-16 00:17:39 +02:00
|
|
|
|
\param page num<EFBFBD>ro de la page
|
|
|
|
|
|
\param file lien
|
2004-08-07 16:41:29 +02:00
|
|
|
|
\param options autres parametres d'url a propager dans les liens ("" par defaut)
|
2005-01-18 22:09:16 +01:00
|
|
|
|
\param nextpage faut-il une page suivante
|
2004-07-16 00:17:39 +02:00
|
|
|
|
*/
|
2005-01-18 22:09:16 +01:00
|
|
|
|
function print_fleche_navigation($page,$file,$options='',$nextpage)
|
2003-05-05 13:14:48 +02:00
|
|
|
|
{
|
2004-07-25 20:45:03 +02:00
|
|
|
|
global $conf, $langs;
|
2004-07-16 00:17:39 +02:00
|
|
|
|
if ($page > 0)
|
2003-05-05 13:14:48 +02:00
|
|
|
|
{
|
2005-01-18 22:09:16 +01:00
|
|
|
|
print '<a href="'.$file.'?page='.($page-1).$options.'">'.img_previous($langs->trans("Previous")).'</a>';
|
2003-05-05 13:14:48 +02:00
|
|
|
|
}
|
2003-07-10 15:07:56 +02:00
|
|
|
|
|
2004-07-16 00:17:39 +02:00
|
|
|
|
if ($nextpage > 0)
|
2003-07-10 15:07:56 +02:00
|
|
|
|
{
|
2005-01-18 22:09:16 +01:00
|
|
|
|
print '<a href="'.$file.'?page='.($page+1).$options.'">'.img_next($langs->trans("Next")).'</a>';
|
2003-07-10 15:07:56 +02:00
|
|
|
|
}
|
2003-05-05 13:14:48 +02:00
|
|
|
|
}
|
2004-07-16 00:17:39 +02:00
|
|
|
|
|
2004-07-17 14:52:41 +02:00
|
|
|
|
|
2004-12-28 16:36:40 +01:00
|
|
|
|
/**
|
2004-08-07 16:41:29 +02:00
|
|
|
|
\brief Fonction servant a afficher les heures/minutes dans un liste d<EFBFBD>roulante
|
2004-07-16 00:17:39 +02:00
|
|
|
|
\param prefix
|
2004-08-07 16:41:29 +02:00
|
|
|
|
\param begin (1 par defaut)
|
|
|
|
|
|
\param end (23 par defaut)
|
2004-07-16 00:17:39 +02:00
|
|
|
|
*/
|
2002-05-09 16:57:48 +02:00
|
|
|
|
function print_heure_select($prefix,$begin=1,$end=23) {
|
|
|
|
|
|
|
|
|
|
|
|
print '<select name="'.$prefix.'hour">';
|
|
|
|
|
|
for ($hour = $begin ; $hour <= $end ; $hour++) {
|
|
|
|
|
|
print "<option value=\"$hour\">$hour";
|
|
|
|
|
|
}
|
|
|
|
|
|
print "</select> H ";
|
|
|
|
|
|
print '<select name="'.$prefix.'min">';
|
|
|
|
|
|
for ($min = 0 ; $min < 60 ; $min=$min+5) {
|
|
|
|
|
|
if ($min < 10) {
|
|
|
|
|
|
$min = "0" . $min;
|
|
|
|
|
|
}
|
|
|
|
|
|
print "<option value=\"$min\">$min";
|
|
|
|
|
|
}
|
|
|
|
|
|
print "</select>\n";
|
|
|
|
|
|
}
|
2004-07-16 00:17:39 +02:00
|
|
|
|
|
2004-12-28 16:36:40 +01:00
|
|
|
|
/**
|
2004-08-07 16:41:29 +02:00
|
|
|
|
\brief Fonction servant a afficher une dur<EFBFBD>e dans une liste d<EFBFBD>roulante
|
2004-08-07 19:14:42 +02:00
|
|
|
|
\param prefix prefix
|
2004-07-16 00:17:39 +02:00
|
|
|
|
*/
|
2002-12-23 15:10:24 +01:00
|
|
|
|
function print_duree_select($prefix)
|
2003-08-12 15:39:54 +02:00
|
|
|
|
{
|
2002-05-09 16:57:48 +02:00
|
|
|
|
print '<select name="'.$prefix.'hour">';
|
|
|
|
|
|
print "<option value=\"0\">0";
|
2004-07-25 19:43:23 +02:00
|
|
|
|
print "<option value=\"1\" selected>1";
|
2002-05-09 16:57:48 +02:00
|
|
|
|
|
2002-12-23 15:10:24 +01:00
|
|
|
|
for ($hour = 2 ; $hour < 13 ; $hour++)
|
|
|
|
|
|
{
|
|
|
|
|
|
print "<option value=\"$hour\">$hour";
|
|
|
|
|
|
}
|
2002-05-09 16:57:48 +02:00
|
|
|
|
print "</select> H ";
|
|
|
|
|
|
print '<select name="'.$prefix.'min">';
|
2002-12-23 15:10:24 +01:00
|
|
|
|
for ($min = 0 ; $min < 55 ; $min=$min+5)
|
|
|
|
|
|
{
|
|
|
|
|
|
print "<option value=\"$min\">$min";
|
|
|
|
|
|
}
|
2002-05-09 16:57:48 +02:00
|
|
|
|
print "</select>\n";
|
|
|
|
|
|
}
|
2002-05-04 23:28:42 +02:00
|
|
|
|
|
2004-07-17 14:52:41 +02:00
|
|
|
|
|
2004-12-28 16:36:40 +01:00
|
|
|
|
/**
|
2004-08-07 16:41:29 +02:00
|
|
|
|
\brief Fonction qui retourne un montant mon<EFBFBD>taire format<EFBFBD>
|
2004-07-16 00:17:39 +02:00
|
|
|
|
\param amount montant a formater
|
2004-08-07 16:41:29 +02:00
|
|
|
|
\param html formatage html ou pas (0 par defaut)
|
|
|
|
|
|
\remarks fonction utilis<EFBFBD>e dans les pdf et les pages html
|
2004-07-16 00:17:39 +02:00
|
|
|
|
|
|
|
|
|
|
*/
|
2004-04-07 14:57:52 +02:00
|
|
|
|
function price($amount, $html=0)
|
2002-12-23 15:10:24 +01:00
|
|
|
|
{
|
2004-04-07 14:57:52 +02:00
|
|
|
|
if ($html)
|
|
|
|
|
|
{
|
|
|
|
|
|
|
2004-07-16 00:17:39 +02:00
|
|
|
|
$dec='.'; $thousand=' ';
|
2004-04-07 14:57:52 +02:00
|
|
|
|
return ereg_replace(' ',' ',number_format($amount, 2, $dec, $thousand));
|
2004-07-16 00:17:39 +02:00
|
|
|
|
|
2004-04-07 14:57:52 +02:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
return number_format($amount, 2, '.', ' ');
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2002-04-30 12:44:42 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
2004-12-28 16:36:40 +01:00
|
|
|
|
/**
|
2004-08-07 16:41:29 +02:00
|
|
|
|
\brief Fonction qui convertit des euros en francs
|
2004-08-07 19:14:42 +02:00
|
|
|
|
\param euros somme en euro <EFBFBD> convertir
|
|
|
|
|
|
\return price prix converti et format<EFBFBD>
|
2004-07-16 00:17:39 +02:00
|
|
|
|
*/
|
2002-12-23 15:10:24 +01:00
|
|
|
|
function francs($euros)
|
|
|
|
|
|
{
|
2002-04-30 12:44:42 +02:00
|
|
|
|
return price($euros * 6.55957);
|
|
|
|
|
|
}
|
2003-03-12 19:05:40 +01:00
|
|
|
|
|
2004-12-28 16:36:40 +01:00
|
|
|
|
/**
|
2004-08-07 16:41:29 +02:00
|
|
|
|
\brief Fonction qui calcule la tva
|
2004-07-16 00:17:39 +02:00
|
|
|
|
\param euros somme en euro
|
|
|
|
|
|
\param taux taux de tva
|
|
|
|
|
|
*/
|
2003-03-12 19:05:40 +01:00
|
|
|
|
function tva($euros, $taux=19.6)
|
2002-12-23 15:10:24 +01:00
|
|
|
|
{
|
2003-03-12 19:05:40 +01:00
|
|
|
|
$taux = $taux / 100 ;
|
|
|
|
|
|
|
2002-12-23 15:10:24 +01:00
|
|
|
|
return sprintf("%01.2f",($euros * $taux));
|
2002-04-30 12:44:42 +02:00
|
|
|
|
}
|
2004-07-16 00:17:39 +02:00
|
|
|
|
|
2004-12-28 16:36:40 +01:00
|
|
|
|
/**
|
2004-08-07 16:41:29 +02:00
|
|
|
|
\brief Fonction qui calcule le montant tva incluse
|
2004-07-16 00:17:39 +02:00
|
|
|
|
\param euros somme en euro
|
|
|
|
|
|
\param taux taux de tva
|
|
|
|
|
|
*/
|
2002-12-23 15:10:24 +01:00
|
|
|
|
function inctva($euros, $taux=1.196)
|
|
|
|
|
|
{
|
|
|
|
|
|
return sprintf("%01.2f",($euros * $taux));
|
2002-04-30 12:44:42 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
2004-12-28 16:36:40 +01:00
|
|
|
|
/**
|
2004-08-07 16:41:29 +02:00
|
|
|
|
\brief Renvoie oui ou non dans la langue choisie
|
2004-07-31 17:27:37 +02:00
|
|
|
|
\param yesno variable pour test si oui ou non
|
|
|
|
|
|
\param case Oui/Non ou oui/non
|
|
|
|
|
|
*/
|
|
|
|
|
|
function yn($yesno, $case=1) {
|
|
|
|
|
|
global $langs;
|
|
|
|
|
|
if ($yesno == 0 || $yesno == 'no' || $yesno == 'false')
|
|
|
|
|
|
return $case?$langs->trans("No"):$langs->trans("no");
|
|
|
|
|
|
if ($yesno == 1 || $yesno == 'yes' || $yesno == 'true')
|
|
|
|
|
|
return $case?$langs->trans("Yes"):$langs->trans("yes");
|
|
|
|
|
|
return "unknown";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2002-04-30 12:44:42 +02:00
|
|
|
|
|
2004-12-28 16:36:40 +01:00
|
|
|
|
/**
|
2004-08-07 16:41:29 +02:00
|
|
|
|
\brief Fonction pour cr<EFBFBD>er un mot de passe al<EFBFBD>atoire
|
2004-12-04 17:33:12 +01:00
|
|
|
|
\param longueur longueur du mot de passe (8 par defaut)
|
|
|
|
|
|
\param sel donn<EFBFBD>e al<EFBFBD>atoire
|
2004-08-07 16:41:29 +02:00
|
|
|
|
\remarks la fonction a <EFBFBD>t<EFBFBD> prise sur http://www.uzine.net/spip
|
2004-07-16 00:17:39 +02:00
|
|
|
|
*/
|
2003-03-07 19:53:17 +01:00
|
|
|
|
function creer_pass_aleatoire($longueur = 8, $sel = "") {
|
|
|
|
|
|
$seed = (double) (microtime() + 1) * time();
|
|
|
|
|
|
srand($seed);
|
2004-07-16 00:17:39 +02:00
|
|
|
|
|
2003-03-07 19:53:17 +01:00
|
|
|
|
for ($i = 0; $i < $longueur; $i++) {
|
|
|
|
|
|
if (!$s) {
|
|
|
|
|
|
if (!$s) $s = rand();
|
|
|
|
|
|
$s = substr(md5(uniqid($s).$sel), 0, 16);
|
|
|
|
|
|
}
|
|
|
|
|
|
$r = unpack("Cr", pack("H2", $s.$s));
|
|
|
|
|
|
$x = $r['r'] & 63;
|
|
|
|
|
|
if ($x < 10) $x = chr($x + 48);
|
|
|
|
|
|
else if ($x < 36) $x = chr($x + 55);
|
|
|
|
|
|
else if ($x < 62) $x = chr($x + 61);
|
|
|
|
|
|
else if ($x == 63) $x = '/';
|
|
|
|
|
|
else $x = '.';
|
|
|
|
|
|
$pass .= $x;
|
|
|
|
|
|
$s = substr($s, 2);
|
|
|
|
|
|
}
|
|
|
|
|
|
return $pass;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2004-12-28 16:36:40 +01:00
|
|
|
|
/**
|
2004-08-07 16:41:29 +02:00
|
|
|
|
\brief Fonction pour initialiser sel
|
|
|
|
|
|
\remarks la fonction a <EFBFBD>t<EFBFBD> prise sur http://www.uzine.net/spip
|
2004-07-16 00:17:39 +02:00
|
|
|
|
*/
|
2003-03-07 19:53:17 +01:00
|
|
|
|
function initialiser_sel() {
|
|
|
|
|
|
global $htsalt;
|
2004-07-16 00:17:39 +02:00
|
|
|
|
|
2003-03-07 19:53:17 +01:00
|
|
|
|
$htsalt = '$1$'.creer_pass_aleatoire();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2004-12-28 16:36:40 +01:00
|
|
|
|
/**
|
2004-08-07 16:41:29 +02:00
|
|
|
|
\brief Fonction pour qui retourne le rowid d'un departement par son code
|
|
|
|
|
|
\param db handler d'acc<EFBFBD>s base
|
|
|
|
|
|
\param code Code r<EFBFBD>gion
|
|
|
|
|
|
\param pays_id Id du pays
|
2004-07-28 10:58:25 +02:00
|
|
|
|
*/
|
|
|
|
|
|
function departement_rowid($db,$code, $pays_id)
|
2004-07-21 11:05:53 +02:00
|
|
|
|
{
|
|
|
|
|
|
$sql = "SELECT c.rowid FROM ".MAIN_DB_PREFIX."c_departements as c,".MAIN_DB_PREFIX."c_regions as r";
|
|
|
|
|
|
$sql .= " WHERE c.code_departement=". $code;
|
|
|
|
|
|
$sql .= " AND c.fk_region = r.code_region";
|
|
|
|
|
|
$sql .= " AND r.fk_pays =".$pays_id;
|
2004-07-21 16:44:30 +02:00
|
|
|
|
|
2004-07-21 11:05:53 +02:00
|
|
|
|
if ($db->query($sql))
|
|
|
|
|
|
{
|
|
|
|
|
|
$num = $db->num_rows();
|
|
|
|
|
|
if ($num)
|
|
|
|
|
|
{
|
2004-10-23 19:27:57 +02:00
|
|
|
|
$obj = $db->fetch_object();
|
2004-07-21 11:05:53 +02:00
|
|
|
|
return $obj->rowid;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
$db->free();
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2005-04-02 15:44:44 +02:00
|
|
|
|
/**
|
|
|
|
|
|
* \brief Renvoi un chemin de classement r<EFBFBD>pertoire en fonction d'un id
|
|
|
|
|
|
* Examples: 1->"0/0/1/", 15->"0/1/5/"
|
|
|
|
|
|
* \param $num id <EFBFBD> d<EFBFBD>composer
|
|
|
|
|
|
*/
|
2005-02-18 16:11:11 +01:00
|
|
|
|
function get_exdir($num)
|
|
|
|
|
|
{
|
2005-04-02 15:44:44 +02:00
|
|
|
|
$num = substr("000".$num, -3);
|
|
|
|
|
|
return substr($num, 0,1).'/'.substr($num, 1,1).'/'.substr($num, 2,1).'/';
|
2005-02-18 16:11:11 +01:00
|
|
|
|
}
|
2004-07-21 11:05:53 +02:00
|
|
|
|
|
2005-04-02 15:44:44 +02:00
|
|
|
|
/**
|
|
|
|
|
|
* \brief Cr<EFBFBD>ation de r<EFBFBD>pertoire recursive
|
|
|
|
|
|
* \param $dir R<EFBFBD>pertoire <EFBFBD> cr<EFBFBD>er
|
|
|
|
|
|
* \return int < 0 si erreur, >= 0 si succ<EFBFBD>s
|
2005-03-03 17:52:26 +01:00
|
|
|
|
*/
|
|
|
|
|
|
function create_exdir($dir)
|
|
|
|
|
|
{
|
2005-04-02 15:44:44 +02:00
|
|
|
|
$nberr=0;
|
|
|
|
|
|
$nbcreated=0;
|
2005-03-03 17:52:26 +01:00
|
|
|
|
|
2005-04-02 15:44:44 +02:00
|
|
|
|
$ccdir = '';
|
|
|
|
|
|
$cdir = explode("/",$dir);
|
|
|
|
|
|
for ($i = 0 ; $i < sizeof($cdir) ; $i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
if ($i > 0) $ccdir .= '/'.$cdir[$i];
|
|
|
|
|
|
else $ccdir = $cdir[$i];
|
|
|
|
|
|
if (eregi("^.:$",$ccdir,$regs)) continue; // Si chemin Windows incomplet, on poursuit par rep suivant
|
2005-03-03 17:52:26 +01:00
|
|
|
|
|
2005-04-02 15:44:44 +02:00
|
|
|
|
//print "${ccdir}<br>\n";
|
|
|
|
|
|
if ($ccdir && ! file_exists($ccdir))
|
|
|
|
|
|
{
|
|
|
|
|
|
umask(0);
|
|
|
|
|
|
if (! @mkdir($ccdir, 0755))
|
|
|
|
|
|
{
|
|
|
|
|
|
dolibarr_syslog("functions.inc.php::create_exdir Erreur: Le r<>pertoire '$ccdir' n'existe pas et Dolibarr n'a pu le cr<63>er.");
|
|
|
|
|
|
$nberr++;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
dolibarr_syslog("functions.inc.php::create_exdir R<>pertoire '$ccdir' created");
|
|
|
|
|
|
$nbcreated++;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return ($nberr ? -$nberr : $nbcreated);
|
2005-03-03 17:52:26 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2002-04-30 12:44:42 +02:00
|
|
|
|
?>
|