2006-05-04 00:02:32 +02:00
< ? php
2007-01-05 10:55:48 +01:00
/* Copyright ( c ) 2002 - 2007 Rodolphe Quiedeville < rodolphe @ quiedeville . org >
2006-03-26 16:58:04 +02:00
* Copyright ( C ) 2004 - 2006 Laurent Destailleur < eldy @ users . sourceforge . net >
2006-02-09 18:36:09 +01:00
* Copyright ( C ) 2004 Benoit Mortier < benoit . mortier @ opensides . be >
* Copyright ( C ) 2004 Sebastien Di Cintio < sdicintio @ ressource - toi . org >
* Copyright ( C ) 2004 Eric Seigne < eric . seigne @ ryxeo . com >
2007-01-05 13:35:29 +01:00
* Copyright ( C ) 2005 - 2007 Regis Houssin < regis . houssin @ cap - networks . com >
2006-02-09 18:36:09 +01:00
* Copyright ( C ) 2006 Andre Cianfarani < acianfa @ free . fr >
2006-07-06 15:30:53 +02:00
* Copyright ( C ) 2006 Marc Barilley / Oc<EFBFBD> bo < marc @ ocebo . com >
2007-01-06 15:59:34 +01:00
* Copyright ( C ) 2007 Franky Van Liedekerke < franky . van . liedekerker @ telenet . be >
2007-04-30 12:53:58 +02:00
* Copyright ( C ) 2007 Patrick Raguin < patrick . raguin @ gmail . com >
2006-02-09 18:36:09 +01: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 .
*
* $Id $
* $Source $
*/
/**
\file htdocs / html . form . class . php
\brief Fichier de la classe des fonctions pr<EFBFBD> d<EFBFBD> finie de composants html
\version $Revision $
*/
/**
\class Form
\brief Classe permettant la g<EFBFBD> n<EFBFBD> ration de composants html
*/
class Form
{
2006-12-09 19:09:02 +01:00
var $db ;
var $error ;
2006-02-09 18:36:09 +01:00
2006-12-09 19:09:02 +01:00
var $cache_types_paiements_code = array ();
var $cache_types_paiements_libelle = array ();
var $cache_conditions_paiements_code = array ();
var $cache_conditions_paiements_libelle = array ();
2006-02-09 18:36:09 +01:00
2006-12-09 19:09:02 +01:00
var $tva_taux ;
2006-12-20 23:34:13 +01:00
2006-12-09 19:09:02 +01:00
/**
\brief Constructeur
\param DB handler d ' acc<EFBFBD> s base de donn<EFBFBD> e
*/
function Form ( $DB )
{
$this -> db = $DB ;
return 1 ;
}
2006-02-09 18:36:09 +01:00
2006-08-20 04:17:52 +02:00
2006-12-09 19:09:02 +01:00
/**
2007-05-21 20:21:43 +02:00
\brief Affiche un texte + picto avec tooltip sur texte ou sur picto
2007-07-30 21:03:25 +02:00
\param text Texte <EFBFBD> afficher
\param htmltext Contenu html du tooltip , cod<EFBFBD> en html
2007-08-03 13:57:52 +02:00
\param tooltipon 1 = tooltip sur texte , 2 = tooltip sur picto , 3 = tooltip sur les 2 , 4 = tooltip Ajax
2007-05-21 20:21:43 +02:00
\param direction - 1 = Le picto est avant , 0 = pas de picto , 1 = le picto est apr<EFBFBD> s
2007-07-30 21:03:25 +02:00
\param img Code img du picto
2006-12-16 14:45:59 +01:00
\return string Code html du texte , picto
2006-12-09 19:09:02 +01:00
*/
2007-07-30 21:03:25 +02:00
function textwithtooltip ( $text , $htmltext , $tooltipon = 1 , $direction = 0 , $img = '' , $i = 1 , $option = '' )
2007-07-30 11:01:27 +02:00
{
2007-08-03 14:05:06 +02:00
global $conf ;
2006-08-21 23:46:21 +02:00
2007-05-21 20:21:43 +02:00
if ( ! $htmltext ) return $text ;
2006-08-21 23:46:21 +02:00
2007-07-30 11:01:27 +02:00
$paramfortooltiptext = '' ;
$paramfortooltippicto = '' ;
// Sanitize tooltip
$htmltext = ereg_replace ( " ' " , " \ ' " , $htmltext );
$htmltext = ereg_replace ( " ' " , " \ ' " , $htmltext );
2007-07-30 21:05:52 +02:00
if ( $conf -> use_ajax && $tooltipon == 4 )
2007-07-30 11:01:27 +02:00
{
2007-08-03 13:57:52 +02:00
$s = '<div id="tip' . $i . '">' . " \n " ;
$s .= $text ;
$s .= '</div>' . " \n " ;
$s .= '<div id="tooltip_content" style="display:none">' . " \n " ;
$s .= $htmltext . " \n " ;
$s .= '</div>' . " \n " ;
$s .= '<script type=\'text/javascript\'>' . " \n " ;
2007-08-04 17:51:11 +02:00
$s .= 'TooltipManager.init("","",{width:500, shiftX:100});' . " \n " ;
2007-08-03 13:57:52 +02:00
$s .= 'TooltipManager.addHTML("tip' . $i . '", "tooltip_content");' . " \n " ;
$s .= '</script>' . " \n " ;
2007-07-30 11:01:27 +02:00
}
else
{
if ( $conf -> use_javascript )
{
if ( $tooltipon == 1 || $tooltipon == 3 )
{
2007-05-21 20:21:43 +02:00
$paramfortooltiptext .= ' onmouseover="showtip(\'' . $htmltext . '\')"' ;
$paramfortooltiptext .= ' onMouseout="hidetip()"' ;
}
if ( $tooltipon == 2 || $tooltipon == 3 )
{
$paramfortooltippicto .= ' onmouseover="showtip(\'' . $htmltext . '\')"' ;
$paramfortooltippicto .= ' onMouseout="hidetip()"' ;
}
2007-07-30 11:01:27 +02:00
}
2006-02-09 18:36:09 +01:00
2007-05-21 20:21:43 +02:00
$s = " " ;
2006-08-21 23:46:21 +02:00
$s .= '<table class="nobordernopadding"><tr>' ;
2006-08-20 04:17:52 +02:00
if ( $direction > 0 )
{
2007-05-21 20:21:43 +02:00
if ( $text )
{
$s .= '<td' . $paramfortooltiptext . '>' . $text ;
2007-05-21 20:24:44 +02:00
if ( $direction ) $s .= ' ' ;
2007-05-21 20:21:43 +02:00
$s .= '</td>' ;
}
if ( $direction ) $s .= '<td' . $paramfortooltippicto . ' valign="top" width="14">' . $img . '</td>' ;
2006-08-20 04:17:52 +02:00
}
else
{
2007-05-21 20:21:43 +02:00
if ( $direction ) $s .= '<td' . $paramfortooltippicto . ' valign="top" width="14">' . $img . '</td>' ;
if ( $text )
{
$s .= '<td' . $paramfortooltiptext . '>' ;
2007-05-21 20:24:44 +02:00
if ( $direction ) $s .= ' ' ;
2007-05-21 20:21:43 +02:00
$s .= $text . '</td>' ;
}
2006-08-20 04:17:52 +02:00
}
2006-08-21 23:46:21 +02:00
$s .= '</tr></table>' ;
2007-07-30 11:01:27 +02:00
}
return $s ;
}
2007-05-21 20:21:43 +02:00
/**
\brief Affiche un texte avec picto help qui affiche un tooltip
\param text Texte <EFBFBD> afficher
\param htmltooltip Contenu html du tooltip
\param direction 1 = Le picto est apr<EFBFBD> s , - 1 = le picto est avant
\param usehelpcursor 1 = Utilise curseur help , 0 = Curseur par defaut
\return string Code html du texte , picto
*/
function textwithhelp ( $text , $htmltext , $direction = 1 , $usehelpcursor = 1 )
{
return $this -> textwithtooltip ( $text , $htmltext , 2 , $direction , img_help ( $usehelpcursor , 0 ));
}
2006-08-20 04:17:52 +02:00
2007-04-26 12:47:31 +02:00
/**
2007-04-26 12:49:27 +02:00
\brief Affiche un texte avec picto warning qui affiche un tooltip
2007-04-26 12:47:31 +02:00
\param text Texte <EFBFBD> afficher
\param htmltooltip Contenu html du tooltip
\param direction 1 = Le picto est apr<EFBFBD> s , - 1 = le picto est avant
\return string Code html du texte , picto
2007-05-21 20:21:43 +02:00
*/
function textwithwarning ( $text , $htmltext , $direction = 1 )
2007-04-26 12:47:31 +02:00
{
2007-05-21 21:08:48 +02:00
return $this -> textwithtooltip ( $text , $htmltext , 2 , $direction , img_warning ( " " ));
2007-04-26 12:47:31 +02:00
}
2006-08-20 04:17:52 +02:00
2006-02-09 18:36:09 +01:00
/**
* \brief Retourne la liste d<EFBFBD> roulante des d<EFBFBD> partements / province / cantons tout pays confondu ou pour un pays donn<EFBFBD> .
* \remarks Dans le cas d 'une liste tout pays confondus, l' affichage fait une rupture sur le pays .
* \remarks La cle de la liste est le code ( il peut y avoir plusieurs entr<EFBFBD> e pour
* un code donn<EFBFBD> e mais dans ce cas , le champ pays diff<EFBFBD> re ) .
* Ainsi les liens avec les d<EFBFBD> partements se font sur un d<EFBFBD> partement ind<EFBFBD> pendemment de nom som .
* \param selected code forme juridique a pr<EFBFBD> s<EFBFBD> lectionn<EFBFBD>
* \param pays_code 0 = liste tous pays confondus , sinon code du pays <EFBFBD> afficher
*/
function select_departement ( $selected = '' , $pays_code = 0 )
{
2007-01-05 10:55:48 +01:00
dolibarr_syslog ( " Form::select_departement selected= $selected , pays_code= $pays_code " , LOG_DEBUG );
2006-04-21 01:33:40 +02:00
2007-01-05 10:55:48 +01:00
global $conf , $langs ;
$langs -> load ( " dict " );
$htmlname = 'departement_id' ;
// On recherche les d<> partements/cantons/province active d'une region et pays actif
$sql = " SELECT d.rowid, d.code_departement as code , d.nom, d.active, p.libelle as libelle_pays, p.code as code_pays FROM " ;
$sql .= " " . MAIN_DB_PREFIX . " c_departements as d, " . MAIN_DB_PREFIX . " c_regions as r, " . MAIN_DB_PREFIX . " c_pays as p " ;
$sql .= " WHERE d.fk_region=r.code_region and r.fk_pays=p.rowid " ;
$sql .= " AND d.active = 1 AND r.active = 1 AND p.active = 1 " ;
if ( $pays_code ) $sql .= " AND p.code = ' " . $pays_code . " ' " ;
$sql .= " ORDER BY p.code, d.code_departement " ;
$result = $this -> db -> query ( $sql );
if ( $result )
{
print '<select class="flat" name="' . $htmlname . '">' ;
if ( $pays_code ) print '<option value="0"> </option>' ;
$num = $this -> db -> num_rows ( $result );
$i = 0 ;
dolibarr_syslog ( " Form::select_departement num= $num " , LOG_DEBUG );
if ( $num )
2006-04-21 01:33:40 +02:00
{
$pays = '' ;
while ( $i < $num )
{
$obj = $this -> db -> fetch_object ( $result );
if ( $obj -> code == '0' ) // Le code peut etre une chaine
{
print '<option value="0"> </option>' ;
}
else {
if ( ! $pays || $pays != $obj -> libelle_pays )
{
// Affiche la rupture si on est en mode liste multipays
if ( ! $pays_code && $obj -> code_pays )
{
print '<option value="-1">----- ' . $obj -> libelle_pays . " -----</option> \n " ;
$pays = $obj -> libelle_pays ;
}
}
if ( $selected > 0 && $selected == $obj -> rowid )
{
print '<option value="' . $obj -> rowid . '" selected="true">' ;
}
else
{
print '<option value="' . $obj -> rowid . '">' ;
}
// Si traduction existe, on l'utilise, sinon on prend le libell<6C> par d<> faut
print $obj -> code . ' - ' . ( $langs -> trans ( $obj -> code ) != $obj -> code ? $langs -> trans ( $obj -> code ) : ( $obj -> nom != '-' ? $obj -> nom : '' ));
print '</option>' ;
}
$i ++ ;
}
}
print '</select>' ;
}
else {
dolibarr_print_error ( $this -> db );
}
}
2006-02-09 18:36:09 +01:00
/**
* \brief Retourne la liste d<EFBFBD> roulante des regions actives dont le pays est actif
* \remarks La cle de la liste est le code ( il peut y avoir plusieurs entr<EFBFBD> e pour
* un code donn<EFBFBD> e mais dans ce cas , le champ pays et lang diff<EFBFBD> re ) .
* Ainsi les liens avec les regions se font sur une region independemment
* de nom som .
*/
function select_region ( $selected = '' , $htmlname = 'region_id' )
{
global $conf , $langs ;
$langs -> load ( " dict " );
$sql = " SELECT r.rowid, r.code_region as code, r.nom as libelle, r.active, p.libelle as libelle_pays FROM " . MAIN_DB_PREFIX . " c_regions as r, " . MAIN_DB_PREFIX . " c_pays as p " ;
$sql .= " WHERE r.fk_pays=p.rowid AND r.active = 1 and p.active = 1 ORDER BY libelle_pays, libelle ASC " ;
if ( $this -> db -> query ( $sql ))
{
print '<select class="flat" name="' . $htmlname . '">' ;
$num = $this -> db -> num_rows ();
$i = 0 ;
if ( $num )
{
$pays = '' ;
while ( $i < $num )
{
$obj = $this -> db -> fetch_object ();
if ( $obj -> code == 0 ) {
print '<option value="0"> </option>' ;
}
else {
2007-05-27 05:56:18 +02:00
if ( $pays == '' || $pays != $obj -> libelle_pays )
{
2006-02-09 18:36:09 +01:00
// Affiche la rupture
2007-05-01 20:25:31 +02:00
print '<option value="-1" disabled="disabled">----- ' . $obj -> libelle_pays . " -----</option> \n " ;
2006-02-09 18:36:09 +01:00
$pays = $obj -> libelle_pays ;
}
if ( $selected > 0 && $selected == $obj -> code )
{
print '<option value="' . $obj -> code . '" selected="true">' . $obj -> libelle . '</option>' ;
}
else
{
print '<option value="' . $obj -> code . '">' . $obj -> libelle . '</option>' ;
}
}
$i ++ ;
}
}
print '</select>' ;
}
else {
dolibarr_print_error ( $this -> db );
}
}
2006-03-18 20:58:33 +01:00
/**
* \brief Renvoie la liste des sources de commandes
* \param selected Id de la source pr<EFBFBD> - s<EFBFBD> lectionn<EFBFBD> e
* \param htmlname Nom de la liste deroulante
* \param addempty 0 = liste sans valeur nulle , 1 = ajoute valeur inconnue
* \return array Tableau des sources de commandes
*/
function selectSourcesCommande ( $selected = '' , $htmlname = 'source_id' , $addempty = 0 )
{
global $conf , $langs ;
print '<select class="flat" name="' . $htmlname . '" ' . $htmloption . '>' ;
if ( $addempty ) print '<option value="-1" selected="true"> </option>' ;
print '<option value="0"' . ( $selected == '0' ? ' selected="true"' : '' ) . '>' . $langs -> trans ( 'OrderSource0' ) . '</option>' ;
print '<option value="1"' . ( $selected == '1' ? ' selected="true"' : '' ) . '>' . $langs -> trans ( 'OrderSource1' ) . '</option>' ;
print '<option value="2"' . ( $selected == '2' ? ' selected="true"' : '' ) . '>' . $langs -> trans ( 'OrderSource2' ) . '</option>' ;
print '<option value="3"' . ( $selected == '3' ? ' selected="true"' : '' ) . '>' . $langs -> trans ( 'OrderSource3' ) . '</option>' ;
print '<option value="4"' . ( $selected == '4' ? ' selected="true"' : '' ) . '>' . $langs -> trans ( 'OrderSource4' ) . '</option>' ;
print '<option value="5"' . ( $selected == '5' ? ' selected="true"' : '' ) . '>' . $langs -> trans ( 'OrderSource5' ) . '</option>' ;
2006-04-03 12:15:23 +02:00
print '<option value="6"' . ( $selected == '6' ? ' selected="true"' : '' ) . '>' . $langs -> trans ( 'OrderSource6' ) . '</option>' ;
2006-03-18 20:58:33 +01:00
print '</select>' ;
}
2006-05-06 18:32:47 +02:00
2006-03-18 20:58:33 +01:00
/**
2006-05-06 18:32:47 +02:00
*
*
*/
function select_methodes_commande ( $selected = '' , $htmlname = 'source_id' , $addempty = 0 )
{
global $conf , $langs ;
$listemethodes = array ();
$sql = " SELECT rowid, libelle " ;
$sql .= " FROM " . MAIN_DB_PREFIX . " c_methode_commande_fournisseur " ;
$sql .= " WHERE active = 1 " ;
$resql = $this -> db -> query ( $sql );
if ( $resql )
{
$i = 0 ;
2006-06-24 22:29:06 +02:00
$num = $this -> db -> num_rows ( $resql );
2006-05-06 18:32:47 +02:00
while ( $i < $num )
{
2006-06-24 22:29:06 +02:00
$obj = $this -> db -> fetch_object ( $resql );
$listemethodes [ $obj -> rowid ] = $obj -> libelle ;
2006-05-06 18:32:47 +02:00
$i ++ ;
}
}
else
{
dolibarr_print_error ( $this -> db );
return - 1 ;
}
print $this -> select_array ( $htmlname , $listemethodes , $selected , $addempty );
return 1 ;
}
/**
2006-03-18 20:58:33 +01:00
* \brief Retourne la liste d<EFBFBD> roulante des pays actifs , dans la langue de l ' utilisateur
2006-08-12 00:56:54 +02:00
* \param selected Id ou code pays pr<EFBFBD> - s<EFBFBD> lectionn<EFBFBD>
2006-03-18 20:58:33 +01:00
* \param htmlname Nom de la liste deroulante
* \param htmloption Options html sur le select
* \todo trier liste sur noms apr<EFBFBD> s traduction plutot que avant
*/
function select_pays ( $selected = '' , $htmlname = 'pays_id' , $htmloption = '' )
{
2006-08-12 00:56:54 +02:00
global $conf , $langs ;
$langs -> load ( " dict " );
$sql = " SELECT rowid, code, libelle, active " ;
$sql .= " FROM " . MAIN_DB_PREFIX . " c_pays " ;
$sql .= " WHERE active = 1 " ;
2007-04-24 23:03:12 +02:00
if ( $conf -> use_ajax && $conf -> global -> CODE_DE_TEST == 1 )
{
if ( is_numeric ( $selected ))
{
$sql .= " AND rowid = " . $selected ;
}
else
{
$sql .= " AND code = ' " . $selected . " ' " ;
}
}
2006-08-12 00:56:54 +02:00
$sql .= " ORDER BY code ASC; " ;
2007-04-24 23:03:12 +02:00
2006-11-26 08:00:14 +01:00
$resql = $this -> db -> query ( $sql );
if ( $resql )
2006-08-12 00:56:54 +02:00
{
2007-02-08 12:00:18 +01:00
if ( $conf -> use_ajax && $conf -> global -> CODE_DE_TEST == 1 )
2006-08-12 00:56:54 +02:00
{
2007-04-03 15:28:34 +02:00
$langs -> load ( " companies " );
2007-02-11 21:04:10 +01:00
$obj = $this -> db -> fetch_object ( $resql );
$pays_id = $obj -> rowid ? $obj -> rowid : '' ;
2007-02-12 13:27:48 +01:00
// On applique un delai d'execution pour le bon fonctionnement
2007-02-12 13:50:33 +01:00
$mode_create = substr ( $htmloption , - 9 , 6 );
$mode_edit = substr ( $htmloption , - 7 , 4 );
$mode_company = substr ( $htmloption , - 10 , 7 );
if ( $mode_create == 'create' )
2007-02-12 13:27:48 +01:00
{
$htmloption = 'onChange="ac_delay(\'autofilltownfromzip_save_refresh_create()\',\'500\')"' ;
}
2007-02-12 13:50:33 +01:00
else if ( $mode_edit == 'edit' )
2007-02-12 13:27:48 +01:00
{
$htmloption = 'onChange="ac_delay(\'autofilltownfromzip_save_refresh_edit()\',\'500\')"' ;
}
2007-02-12 13:50:33 +01:00
else if ( $mode_company == 'refresh' )
{
$htmloption = 'onChange="ac_delay(\'company_save_refresh()\',\'500\')"' ;
}
2007-06-23 09:03:20 +02:00
2007-02-08 12:00:18 +01:00
print '<div>' ;
2007-04-03 15:28:34 +02:00
if ( $obj -> rowid == 0 )
{
print '<input type="text" size="45" id="pays" name="pays" value="' . $langs -> trans ( " SelectCountry " ) . '" ' . $htmloption . ' />' ;
}
else
{
print '<input type="text" size="45" id="pays" name="pays" value="' . $obj -> libelle . '" ' . $htmloption . ' />' ;
}
2007-05-07 13:04:45 +02:00
2007-05-09 11:37:28 +02:00
print ajax_autocompleter ( $pays_id , 'pays' , '/societe/ajaxcountries.php' , 'working' );
2006-08-12 00:56:54 +02:00
}
2007-02-08 12:00:18 +01:00
else
{
print '<select class="flat" name="' . $htmlname . '" ' . $htmloption . '>' ;
$num = $this -> db -> num_rows ( $resql );
$i = 0 ;
if ( $num )
{
$foundselected = false ;
while ( $i < $num )
{
$obj = $this -> db -> fetch_object ( $resql );
if ( $selected && $selected != '-1' && ( $selected == $obj -> rowid || $selected == $obj -> code ))
{
$foundselected = true ;
print '<option value="' . $obj -> rowid . '" selected="true">' ;
}
else
{
print '<option value="' . $obj -> rowid . '">' ;
}
// Si traduction existe, on l'utilise, sinon on prend le libell<6C> par d<> faut
if ( $obj -> code ) { print $obj -> code . ' - ' ; }
print ( $obj -> code && $langs -> trans ( " Country " . $obj -> code ) != " Country " . $obj -> code ? $langs -> trans ( " Country " . $obj -> code ) : ( $obj -> libelle != '-' ? $obj -> libelle : ' ' ));
print '</option>' ;
$i ++ ;
}
}
print '</select>' ;
return 0 ;
}
}
else
{
dolibarr_print_error ( $this -> db );
2006-08-12 00:56:54 +02:00
return 1 ;
}
}
2006-02-09 18:36:09 +01:00
/**
* \brief Retourne la liste d<EFBFBD> roulante des langues disponibles
* \param selected Langue pr<EFBFBD> s<EFBFBD> lectionn<EFBFBD> e
* \param htmlname Nom de la zone select
* \param showauto Affiche choix auto
*/
function select_lang ( $selected = '' , $htmlname = 'lang_id' , $showauto = 0 )
{
global $langs ;
$langs_available = $langs -> get_available_languages ();
print '<select class="flat" name="' . $htmlname . '">' ;
if ( $showauto )
{
print '<option value="auto"' ;
if ( $selected == 'auto' ) print ' selected="true"' ;
print '>' . $langs -> trans ( " AutoDetectLang " ) . '</option>' ;
}
$num = count ( $langs_available );
$i = 0 ;
if ( $num )
{
while ( $i < $num )
{
if ( $selected == $langs_available [ $i ])
{
print '<option value="' . $langs_available [ $i ] . '" selected="true">' . $langs_available [ $i ] . '</option>' ;
}
else
{
print '<option value="' . $langs_available [ $i ] . '">' . $langs_available [ $i ] . '</option>' ;
}
$i ++ ;
}
}
print '</select>' ;
}
/**
2007-06-11 09:29:37 +02:00
* \brief Retourne la liste d<EFBFBD> roulante des menus disponibles ( eldy_backoffice , ... )
2006-02-09 18:36:09 +01:00
* \param selected Menu pr<EFBFBD> - s<EFBFBD> lectionn<EFBFBD> e
* \param htmlname Nom de la zone select
* \param dirmenu Rep<EFBFBD> rtoire <EFBFBD> scanner
*/
function select_menu ( $selected = '' , $htmlname , $dirmenu )
{
2007-05-27 05:55:11 +02:00
global $langs , $conf ;
2006-02-09 18:36:09 +01:00
if ( $selected == 'eldy.php' ) $selected = 'eldy_backoffice.php' ; // Pour compatibilit<69>
2007-05-27 05:55:11 +02:00
$menuarray = array ();
2006-02-09 18:36:09 +01:00
$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 );
2007-05-27 05:55:11 +02:00
$prefix = '' ;
if ( eregi ( '^eldy' , $file )) $prefix = '0' ; // Recommanded
else if ( eregi ( '^default' , $file )) $prefix = '2' ; // Other
else if ( eregi ( '^empty' , $file )) $prefix = '2' ; // Other
else $prefix = '1' ; // Experimental
2006-02-09 18:36:09 +01:00
if ( $file == $selected )
{
2007-05-27 05:55:11 +02:00
$menuarray [ $prefix . '_' . $file ] = '<option value="' . $file . '" selected="true">' . $filelib . '</option>' ;
2006-02-09 18:36:09 +01:00
}
else
{
2007-05-27 05:55:11 +02:00
$menuarray [ $prefix . '_' . $file ] = '<option value="' . $file . '">' . $filelib . '</option>' ;
2006-02-09 18:36:09 +01:00
}
}
}
2007-05-27 05:55:11 +02:00
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>' ;
2006-02-09 18:36:09 +01:00
}
2007-06-11 09:29:37 +02:00
/**
* \brief Retourne la liste d<EFBFBD> roulante des menus disponibles ( eldy )
* \param selected Menu pr<EFBFBD> - s<EFBFBD> lectionn<EFBFBD> e
* \param htmlname Nom de la zone select
* \param dirmenu Rep<EFBFBD> rtoire <EFBFBD> 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"' ;
}
print '>' . $key . '</option>' . " \n " ;
}
print '</select>' ;
}
/**
2006-02-09 18:36:09 +01:00
* \brief Retourne la liste des types de comptes financiers
* \param selected Type pr<EFBFBD> - s<EFBFBD> lectionn<EFBFBD>
* \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>' ;
}
2006-06-04 00:01:38 +02:00
/**
* \brief Retourne la liste d<EFBFBD> roulante des soci<EFBFBD> t<EFBFBD> s
* \param selected Societe pr<EFBFBD> s<EFBFBD> lectionn<EFBFBD> e
* \param htmlname Nom champ formulaire
* \param filter Criteres optionnels de filtre
*/
2006-11-11 02:42:50 +01:00
function select_societes ( $selected = '' , $htmlname = 'socid' , $filter = '' , $showempty = 0 )
2007-07-05 19:00:27 +02:00
{
global $conf ;
2006-02-09 18:36:09 +01:00
// On recherche les societes
2007-06-12 00:51:47 +02:00
$sql = " SELECT s.rowid, s.nom FROM " ;
2006-02-09 18:36:09 +01:00
$sql .= " " . MAIN_DB_PREFIX . " societe as s " ;
2007-07-05 19:00:27 +02:00
if ( $filter ) $sql .= " WHERE " . $filter ;
if ( $selected && $conf -> use_ajax && $conf -> global -> COMPANY_USE_SEARCH_TO_SELECT )
{
if ( $filter )
{
$sql .= " AND " ;
}
else
{
$sql .= " WHERE " ;
}
$sql .= " rowid = " . $selected ;
}
2006-02-09 18:36:09 +01:00
$sql .= " ORDER BY nom ASC " ;
$resql = $this -> db -> query ( $sql );
if ( $resql )
{
2007-07-05 19:00:27 +02:00
if ( $conf -> use_ajax && $conf -> global -> COMPANY_USE_SEARCH_TO_SELECT )
{
if ( $selected ) $obj = $this -> db -> fetch_object ( $resql );
$socid = $obj -> rowid ? $obj -> rowid : '' ;
print '<table class="nobordernopadding"><tr class="nocellnopadd">' ;
print '<td class="nobordernopadding">' ;
print '<div>' ;
if ( $obj -> rowid == 0 )
{
print '<input type="text" size="30" id="' . $htmlname . '" name="' . $htmlname . '" value=""/>' ;
}
else
{
print '<input type="text" size="30" id="' . $htmlname . '" name="' . $htmlname . '" value="' . $obj -> nom . '"/>' ;
}
print ajax_autocompleter ( $socid , $htmlname , '/societe/ajaxcompanies.php' , '' );
print '</td>' ;
print '<td class="nobordernopadding" align="left" width="16">' ;
print ajax_indicator ( $htmlname , 'working' );
print '</td></tr>' ;
print '</table>' ;
}
else
{
2006-02-09 18:36:09 +01:00
print '<select class="flat" name="' . $htmlname . '">' ;
2006-08-18 22:51:38 +02:00
if ( $showempty ) print '<option value="-1"> </option>' ;
2006-02-09 18:36:09 +01:00
$num = $this -> db -> num_rows ( $resql );
$i = 0 ;
if ( $num )
{
while ( $i < $num )
{
$obj = $this -> db -> fetch_object ( $resql );
2007-06-12 00:51:47 +02:00
if ( $selected > 0 && $selected == $obj -> rowid )
2006-02-09 18:36:09 +01:00
{
2007-06-12 00:51:47 +02:00
print '<option value="' . $obj -> rowid . '" selected="true">' . $obj -> nom . '</option>' ;
2006-02-09 18:36:09 +01:00
}
else
{
2007-06-12 00:51:47 +02:00
print '<option value="' . $obj -> rowid . '">' . $obj -> nom . '</option>' ;
2006-02-09 18:36:09 +01:00
}
$i ++ ;
}
}
print '</select>' ;
2007-07-05 19:00:27 +02:00
}
2006-02-09 18:36:09 +01:00
}
2007-07-05 19:00:27 +02:00
else
{
2006-02-09 18:36:09 +01:00
dolibarr_print_error ( $this -> db );
}
}
2006-06-04 00:01:38 +02:00
/**
* \brief Retourne la liste d<EFBFBD> roulante des remises fixes
* \param selected Id remise fixe pr<EFBFBD> s<EFBFBD> lectionn<EFBFBD> e
* \param htmlname Nom champ formulaire
* \param filter Criteres optionnels de filtre
*/
function select_remises ( $selected = '' , $htmlname = 'remise_id' , $filter = '' , $socid )
{
global $langs , $conf ;
// On recherche les societes
2007-04-03 01:45:50 +02:00
$sql = " SELECT re.rowid, re.amount_ht, re.amount_tva, re.amount_ttc, " ;
$sql .= " re.description " ;
$sql .= " FROM " . MAIN_DB_PREFIX . " societe_remise_except as re " ;
2006-06-04 00:01:38 +02:00
$sql .= " WHERE fk_soc = " . $socid ;
2007-04-03 01:45:50 +02:00
if ( $filter ) $sql .= " AND " . $filter ;
2006-06-04 00:01:38 +02:00
$sql .= " ORDER BY re.description ASC " ;
$resql = $this -> db -> query ( $sql );
if ( $resql )
{
print '<select class="flat" name="' . $htmlname . '">' ;
$num = $this -> db -> num_rows ( $resql );
$i = 0 ;
if ( $num )
{
print '<option value="0"> </option>' ;
while ( $i < $num )
{
$obj = $this -> db -> fetch_object ( $resql );
2007-04-03 01:45:50 +02:00
$desc = dolibarr_trunc ( $obj -> description , 40 );
if ( $desc == '(CREDIT_NOTE)' ) $desc = $langs -> trans ( " CreditNote " );
if ( $selected > 0 && $selected == $obj -> rowid )
2006-06-04 00:01:38 +02:00
{
2007-07-05 00:07:53 +02:00
print '<option value="' . $obj -> rowid . '" selected="true">' . $desc . ' (' . price ( $obj -> amount_ht ) . ' ' . $langs -> trans ( " HT " ) . ' - ' . price ( $obj -> amount_ttc ) . ' ' . $langs -> trans ( " TTC " ) . ')</option>' ;
2006-06-04 00:01:38 +02:00
}
else
{
2007-07-05 00:07:53 +02:00
print '<option value="' . $obj -> rowid . '">' . $desc . ' (' . price ( $obj -> amount_ht ) . ' ' . $langs -> trans ( " HT " ) . ' - ' . price ( $obj -> amount_ttc ) . ' ' . $langs -> trans ( " TTC " ) . ')</option>' ;
2006-06-04 00:01:38 +02:00
}
$i ++ ;
}
}
print '</select>' ;
}
else {
dolibarr_print_error ( $this -> db );
}
}
2006-02-09 18:36:09 +01:00
/**
2006-02-18 23:04:32 +01:00
* \brief Retourne la liste d<EFBFBD> roulante des contacts d ' une soci<EFBFBD> t<EFBFBD> donn<EFBFBD> e
* \param socid Id de la soci<EFBFBD> t<EFBFBD>
* \param selected Id contact pr<EFBFBD> - s<EFBFBD> lectionn
* \param htmlname Nom champ formulaire ( 'none' pour champ non editable )
* \return int < 0 si ko , >= 0 si ok
2006-02-09 18:36:09 +01:00
*/
2006-06-16 02:31:33 +02:00
function select_contacts ( $socid , $selected = '' , $htmlname = 'contactid' , $showempty = 0 )
2006-02-09 18:36:09 +01:00
{
2006-02-18 23:04:32 +01:00
// On recherche les societes
2007-06-12 00:51:47 +02:00
$sql = " SELECT s.rowid, s.name, s.firstname FROM " ;
2006-04-06 20:36:52 +02:00
$sql .= " " . MAIN_DB_PREFIX . " socpeople as s " ;
$sql .= " WHERE fk_soc= " . $socid ;
$sql .= " ORDER BY s.name ASC " ;
2006-02-18 23:04:32 +01:00
$resql = $this -> db -> query ( $sql );
if ( $resql )
{
$num = $this -> db -> num_rows ();
if ( $num == 0 ) return 0 ;
if ( $htmlname != 'none' ) print '<select class="flat" name="' . $htmlname . '">' ;
2006-06-16 02:31:33 +02:00
if ( $showempty ) print '<option value="1"> </option>' ;
2006-02-18 23:04:32 +01:00
$num = $this -> db -> num_rows ();
$i = 0 ;
if ( $num )
{
while ( $i < $num )
{
$obj = $this -> db -> fetch_object ();
if ( $htmlname != 'none' )
{
2007-06-12 00:51:47 +02:00
if ( $selected && $selected == $obj -> rowid )
2006-02-18 23:04:32 +01:00
{
2007-06-12 00:51:47 +02:00
print '<option value="' . $obj -> rowid . '" selected="true">' . $obj -> name . ' ' . $obj -> firstname . '</option>' ;
2006-02-18 23:04:32 +01:00
}
else
{
2007-06-12 00:51:47 +02:00
print '<option value="' . $obj -> rowid . '">' . $obj -> name . ' ' . $obj -> firstname . '</option>' ;
2006-02-18 23:04:32 +01:00
}
}
else
{
2007-06-12 00:51:47 +02:00
if ( $selected == $obj -> rowid ) print $obj -> name . ' ' . $obj -> firstname ;
2006-02-18 23:04:32 +01:00
}
$i ++ ;
}
}
if ( $htmlname != 'none' ) print '</select>' ;
2006-04-06 02:12:49 +02:00
return 1 ;
2006-02-18 23:04:32 +01:00
}
else
{
dolibarr_print_error ( $this -> db );
return - 1 ;
}
2006-02-09 18:36:09 +01:00
}
/**
* \brief Retourne la liste d<EFBFBD> roulante des utilisateurs
* \param selected Id contact pr<EFBFBD> - s<EFBFBD> lectionn
* \param htmlname Nom champ formulaire
*/
2007-03-21 19:22:32 +01:00
function select_users ( $selected = '' , $htmlname = 'userid' , $show_empty = 0 )
2006-02-09 18:36:09 +01:00
{
2006-04-10 18:43:40 +02:00
// On recherche les utilisateurs
2006-02-09 18:36:09 +01:00
$sql = " SELECT u.rowid, u.name, u.firstname FROM " ;
$sql .= MAIN_DB_PREFIX . " user as u " ;
$sql .= " ORDER BY u.name ASC " ;
if ( $this -> db -> query ( $sql ))
{
print '<select class="flat" name="' . $htmlname . '">' ;
2007-03-21 19:22:32 +01:00
if ( $show_empty ) print '<option value="-1"' . ( $id ==- 1 ? ' selected="true"' : '' ) . '> </option>' . " \n " ;
2006-02-09 18:36:09 +01:00
$num = $this -> db -> num_rows ();
$i = 0 ;
if ( $num )
{
while ( $i < $num )
{
$obj = $this -> db -> fetch_object ();
2007-03-21 19:22:32 +01:00
2006-02-09 18:36:09 +01:00
if ( $selected && $selected == $obj -> rowid )
{
print '<option value="' . $obj -> rowid . '" selected="true">' . $obj -> name . ' ' . $obj -> firstname . '</option>' ;
}
else
{
print '<option value="' . $obj -> rowid . '">' . $obj -> name . ' ' . $obj -> firstname . '</option>' ;
}
$i ++ ;
}
}
print '</select>' ;
}
else
{
dolibarr_print_error ( $this -> db );
}
}
2007-01-05 10:55:48 +01:00
/**
\brief Affiche la liste d<EFBFBD> roulante des projets d ' une soci<EFBFBD> t<EFBFBD> donn<EFBFBD> e
\param socid Id soci<EFBFBD> t<EFBFBD>
\param selected Id projet pr<EFBFBD> s<EFBFBD> lectionn<EFBFBD>
\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"> </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>' ;
}
2006-05-03 17:36:22 +02:00
else
2007-01-05 10:55:48 +01:00
{
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<EFBFBD> ou renvoie <EFBFBD> select_produits_do
\param selected Produit pr<EFBFBD> s<EFBFBD> lectionn<EFBFBD>
\param htmlname Nom de la zone select
\param filtretype Pour filtre sur type de produit
\param limit Limite sur le nombre de lignes retourn<EFBFBD> es
2007-05-07 14:47:22 +02:00
\param price_level Niveau de prix en fonction du client
2007-01-05 10:55:48 +01:00
*/
function select_produits ( $selected = '' , $htmlname = 'productid' , $filtretype = '' , $limit = 20 , $price_level = 0 )
{
2007-05-07 14:47:22 +02:00
global $langs , $conf ;
2007-02-10 02:49:49 +01:00
if ( $conf -> global -> PRODUIT_USE_SEARCH_TO_SELECT )
2007-02-08 12:00:18 +01:00
{
2007-05-26 01:24:21 +02:00
print '<table class="nobordernopadding"><tr class="nocellnopadd">' ;
2007-05-26 04:18:06 +02:00
print '<td class="nobordernopadding" width="80" nowrap="nowrap">' ;
2007-05-26 01:24:21 +02:00
print $langs -> trans ( " RefOrLabel " ) . ':</td>' ;
print '<td class="nobordernopadding" align="left" width="16">' ;
2007-06-23 09:03:20 +02:00
print ajax_indicator ( $htmlname , 'working' );
2007-05-26 01:24:21 +02:00
print '</td>' ;
2007-05-26 04:18:06 +02:00
print '<td align="left"><input type="text" size="16" name="keysearch' . $htmlname . '" id="keysearch' . $htmlname . '"> ' ;
2007-05-26 01:24:21 +02:00
print '</td>' ;
print '</tr>' ;
print '<tr class="nocellnopadd">' ;
print '<td class="nobordernopadding" colspan="3">' ;
print ajax_updater ( $htmlname , 'keysearch' , '/product/ajaxproducts.php' , '&price_level=' . $price_level . '&type=1' , '' );
print '</td></tr>' ;
print '</table>' ;
}
2007-01-05 10:55:48 +01:00
else
2007-02-08 12:00:18 +01:00
{
$this -> select_produits_do ( $selected , $htmlname , $filtretype , $limit , $price_level );
}
2007-01-05 10:55:48 +01:00
}
2006-05-04 00:02:32 +02:00
2007-05-26 01:24:21 +02:00
/**
\brief Retourne la liste des produits
\param selected Produit pr<EFBFBD> s<EFBFBD> lectionn<EFBFBD>
\param htmlname Nom de la zone select
\param filtretype Pour filtre sur type de produit
\param limit Limite sur le nombre de lignes retourn<EFBFBD> es
\param price_level Niveau de prix en fonction du client
\param ajaxkeysearch Filtre des produits si ajax est utilis<EFBFBD>
*/
function select_produits_do ( $selected = '' , $htmlname = 'productid' , $filtretype = '' , $limit = 20 , $price_level = 0 , $ajaxkeysearch = '' )
{
global $langs , $conf , $user ;
$user -> getrights ( " categorie " );
$sql = " SELECT " ;
if ( $conf -> categorie -> enabled && ! $user -> rights -> categorie -> voir )
{
$sql .= " DISTINCT " ;
}
2007-06-22 00:56:17 +02:00
$sql .= " p.rowid, p.label, p.ref, p.price, p.price_ttc, p.price_base_type, p.duration " ;
2007-05-26 01:24:21 +02:00
$sql .= " FROM " . MAIN_DB_PREFIX . " product as p " ;
if ( $conf -> categorie -> enabled && ! $user -> rights -> categorie -> voir )
{
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " categorie_product as cp ON p.rowid = cp.fk_product " ;
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " categorie as c ON cp.fk_categorie = c.rowid " ;
}
$sql .= " WHERE p.envente = 1 " ;
if ( $conf -> categorie -> enabled && ! $user -> rights -> categorie -> voir )
{
$sql .= ' AND IFNULL(c.visible,1)=1' ;
}
if ( $filtretype && $filtretype != '' ) $sql .= " AND p.fk_product_type= " . $filtretype ;
if ( $ajaxkeysearch && $ajaxkeysearch != '' ) $sql .= " AND p.ref like '% " . $ajaxkeysearch . " %' OR p.label like '% " . $ajaxkeysearch . " %' " ;
$sql .= " ORDER BY p.nbvente DESC " ;
if ( $limit ) $sql .= " LIMIT $limit " ;
dolibarr_syslog ( " Form::select_produits_do sql= $sql " , LOG_DEBUG );
2006-04-01 15:34:35 +02:00
2007-05-26 01:24:21 +02:00
$result = $this -> db -> query ( $sql );
if ( ! $result ) dolibarr_print_error ( $this -> db );
// Multilang : on construit une liste des traductions des produits list<73> s
if ( $conf -> global -> MAIN_MULTILANGS )
{
$sqld = " SELECT d.fk_product, d.label " ;
2006-06-14 01:55:33 +02:00
$sqld .= " FROM " . MAIN_DB_PREFIX . " product as p, " . MAIN_DB_PREFIX . " product_det as d " ;
$sqld .= " WHERE d.fk_product=p.rowid AND p.envente=1 AND d.lang=' " . $langs -> getDefaultLang () . " ' " ;
$sqld .= " ORDER BY p.nbvente DESC " ;
$resultd = $this -> db -> query ( $sqld );
if ( $resultd ) $objtp = $this -> db -> fetch_object ( $resultd );
}
2007-05-08 15:33:22 +02:00
if ( $result )
{
$num = $this -> db -> num_rows ( $result );
if ( $conf -> use_ajax )
{
2006-06-14 01:55:33 +02:00
if ( ! $num )
{
2006-08-02 03:39:27 +02:00
print '<select class="flat" name="' . $htmlname . '">' ;
print '<option value="0">-- ' . $langs -> trans ( " NoProductMatching " ) . ' --</option>' ;
2006-06-14 01:55:33 +02:00
}
2006-08-02 03:39:27 +02:00
else
{
2006-06-14 01:55:33 +02:00
print '<select class="flat" name="' . $htmlname . '" onchange="publish_selvalue(this);">' ;
2007-05-26 01:24:21 +02:00
print '<option value="0" selected="true">-- ' . $langs -> trans ( " MatchingProducts " ) . ' --</option>' ;
2006-08-02 03:39:27 +02:00
}
2006-06-14 01:55:33 +02:00
}
2006-05-11 11:00:11 +02:00
else
2006-06-14 01:55:33 +02:00
{
2006-05-11 11:00:11 +02:00
print '<select class="flat" name="' . $htmlname . '">' ;
2007-05-26 01:24:21 +02:00
print '<option value="0" selected="true"> </option>' ;
}
$i = 0 ;
while ( $num && $i < $num )
{
$objp = $this -> db -> fetch_object ( $result );
2006-06-14 01:55:33 +02:00
// Multilangs : modification des donn<6E> e si une traduction existe
2006-03-22 00:47:01 +01:00
if ( $conf -> global -> MAIN_MULTILANGS )
2006-06-14 01:55:33 +02:00
{
2006-02-27 17:15:07 +01:00
if ( $objp -> rowid == $objtp -> fk_product ) // si on a une traduction
{
if ( $objtp -> label != '' ) $objp -> label = $objtp -> label ;
if ( $resultd ) $objtp = $this -> db -> fetch_object ( $resultd ); // on charge la traduction suivante
}
2006-06-14 01:55:33 +02:00
}
$opt = '<option value="' . $objp -> rowid . '">' . $objp -> ref . ' - ' ;
$opt .= dolibarr_trunc ( $objp -> label , 32 ) . ' - ' ;
2007-07-16 00:26:29 +02:00
2006-06-14 01:55:33 +02:00
// Multiprix
if ( $price_level > 1 )
2006-02-09 18:36:09 +01:00
{
2007-06-22 00:56:17 +02:00
$sql = " SELECT price, price_ttc, price_base_type " ;
2007-05-26 01:24:21 +02:00
$sql .= " FROM " . MAIN_DB_PREFIX . " product_price " ;
$sql .= " where fk_product=' " . $objp -> rowid . " ' and price_level= " . $price_level ;
$sql .= " order by date_price DESC limit 1 " ;
2007-07-16 00:26:29 +02:00
$result2 = $this -> db -> query ( $sql );
2007-05-26 01:24:21 +02:00
$objp2 = $this -> db -> fetch_object ( $result2 );
2007-07-16 00:26:29 +02:00
if ( $objp2 )
{
if ( $objp2 -> price_base_type == 'HT' )
$opt .= price2num ( $objp2 -> price , 'MU' ) . ' ' . $langs -> trans ( " Currency " . $conf -> monnaie ) . ' ' . $langs -> trans ( " HT " );
else
$opt .= price2num ( $objp2 -> price_ttc , 'MU' ) . ' ' . $langs -> trans ( " Currency " . $conf -> monnaie ) . ' ' . $langs -> trans ( " TTC " );
}
//si il n'y a pas de prix multiple on prend le prix de base du produit/service
2007-05-26 01:24:21 +02:00
else
2007-07-16 00:26:29 +02:00
{
if ( $objp -> price_base_type == 'HT' )
$opt .= price2num ( $objp -> price , 'MU' ) . ' ' . $langs -> trans ( " Currency " . $conf -> monnaie ) . ' ' . $langs -> trans ( " HT " );
else
$opt .= price2num ( $objp -> price_ttc , 'MU' ) . ' ' . $langs -> trans ( " Currency " . $conf -> monnaie ) . ' ' . $langs -> trans ( " TTC " );
}
2006-02-09 18:36:09 +01:00
}
else
2007-05-08 15:33:22 +02:00
{
2007-06-22 00:56:17 +02:00
if ( $objp -> price_base_type == 'HT' )
$opt .= price2num ( $objp -> price , 'MU' ) . ' ' . $langs -> trans ( " Currency " . $conf -> monnaie ) . ' ' . $langs -> trans ( " HT " );
else
$opt .= price2num ( $objp -> price_ttc , 'MU' ) . ' ' . $langs -> trans ( " Currency " . $conf -> monnaie ) . ' ' . $langs -> trans ( " TTC " );
2007-05-08 15:33:22 +02:00
}
if ( $objp -> duration ) $opt .= ' - ' . $objp -> duration ;
$opt .= " </option> \n " ;
2007-05-26 01:24:21 +02:00
print $opt ;
$i ++ ;
}
print '</select>' ;
$this -> db -> free ( $result );
}
else
{
dolibarr_print_error ( $db );
}
}
2006-02-09 18:36:09 +01:00
2007-07-08 14:41:24 +02:00
/**
\brief Retourne la liste des produits fournisseurs en Ajax si ajax activ<EFBFBD> ou renvoie <EFBFBD> select_produits_fournisseurs_do
\param selected Produit pr<EFBFBD> s<EFBFBD> lectionn<EFBFBD>
\param htmlname Nom de la zone select
\param filtretype Pour filtre sur type de produit
\param limit Limite sur le nombre de lignes retourn<EFBFBD> es
*/
function select_produits_fournisseurs ( $socid , $selected = '' , $htmlname = 'productid' , $filtretype = '' , $filtre = '' )
{
global $langs , $conf ;
if ( $conf -> global -> PRODUIT_USE_SEARCH_TO_SELECT )
{
print $langs -> trans ( " RefOrLabel " ) . ' : <input type="text" size="16" name="keysearch' . $htmlname . '" id="keysearch' . $htmlname . '">' ;
print ajax_updater ( $htmlname , 'keysearch' , '/product/ajaxproducts.php' , '&socid=' . $socid . '&type=2' , 'working' );
}
else
{
$this -> select_produits_fournisseurs_do ( $socid , $selected , $htmlname , $filtretype , $filtre );
}
}
2007-01-05 10:55:48 +01:00
2007-04-02 01:04:24 +02:00
/**
\brief Retourne la liste des produits de fournisseurs
2007-07-08 14:41:24 +02:00
\param socid Id soci<EFBFBD> t<EFBFBD> ( 0 pour aucun filtre )
2007-04-02 01:04:24 +02:00
\param selected Produit pr<EFBFBD> s<EFBFBD> lectionn<EFBFBD>
\param htmlname Nom de la zone select
\param filtretype Pour filtre sur type de produit
\param filtre Pour filtre
2007-05-07 14:47:22 +02:00
\param ajaxkeysearch Filtre des produits si ajax est utilis<EFBFBD>
2007-04-02 01:04:24 +02:00
*/
2007-05-07 14:47:22 +02:00
function select_produits_fournisseurs_do ( $socid , $selected = '' , $htmlname = 'productid' , $filtretype = '' , $filtre = '' , $ajaxkeysearch = '' )
2007-04-02 01:04:24 +02:00
{
global $langs , $conf ;
2007-07-09 00:23:03 +02:00
$sql = " SELECT p.rowid, p.label, p.ref, p.price, p.duration, " ;
$sql .= " pfp.price as fprice, pfp.quantity, pfp.unitprice " ;
2007-04-02 01:04:24 +02:00
$sql .= " FROM " . MAIN_DB_PREFIX . " product as p " ;
2007-04-24 13:09:55 +02:00
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " product_fournisseur_price as pfp ON p.rowid = pfp.fk_product " ;
2007-04-02 01:04:24 +02:00
$sql .= " WHERE p.envente = 1 " ;
2007-04-24 13:09:55 +02:00
if ( $socid ) $sql .= " AND pfp.fk_soc = " . $socid ;
2007-04-02 01:04:24 +02:00
if ( $filtretype && $filtretype != '' ) $sql .= " AND p.fk_product_type= " . $filtretype ;
if ( $filtre ) $sql .= " $filtre " ;
2007-05-07 14:47:22 +02:00
if ( $ajaxkeysearch && $ajaxkeysearch != '' ) $sql .= " AND p.ref like '% " . $ajaxkeysearch . " %' OR p.label like '% " . $ajaxkeysearch . " %' " ;
2007-04-02 01:04:24 +02:00
$sql .= " ORDER BY p.ref DESC " ;
dolibarr_syslog ( " Form::select_produits_fournisseurs sql= $sql " , LOG_DEBUG );
$result = $this -> db -> query ( $sql );
if ( $result )
{
$num = $this -> db -> num_rows ( $result );
2007-05-07 14:47:22 +02:00
if ( $conf -> use_ajax )
2007-07-08 14:41:24 +02:00
{
if ( ! $num )
{
print '<select class="flat" name="' . $htmlname . '">' ;
print '<option value="0">-- ' . $langs -> trans ( " NoProductMatching " ) . ' --</option>' ;
}
else
{
print '<select class="flat" name="' . $htmlname . '" onchange="publish_selvalue(this);">' ;
print '<option value="0" selected="true">-- ' . $langs -> trans ( " MatchingProducts " ) . ' --</option>' ;
}
}
else
{
print '<select class="flat" name="' . $htmlname . '">' ;
if ( ! $selected ) print '<option value="0" selected="true"> </option>' ;
else print '<option value="0"> </option>' ;
}
2007-05-07 14:47:22 +02:00
2007-04-02 01:04:24 +02:00
$i = 0 ;
while ( $i < $num )
{
$objp = $this -> db -> fetch_object ( $result );
2007-07-08 14:41:24 +02:00
2007-04-02 01:04:24 +02:00
$opt = '<option value="' . $objp -> rowid . '"' ;
if ( $selected == $objp -> rowid ) $opt .= ' selected="true"' ;
2007-07-08 14:41:24 +02:00
if ( $objp -> fprice == '' ) $opt .= ' disabled="disabled"' ;
2007-04-25 16:50:59 +02:00
$opt .= '>' . $objp -> ref . ' - ' ;
2007-07-08 14:41:24 +02:00
$opt .= dolibarr_trunc ( $objp -> label , 18 ) . ' - ' ;
if ( $objp -> fprice != '' )
{
2007-07-09 00:23:03 +02:00
$opt .= price ( $objp -> fprice );
2007-07-08 14:41:24 +02:00
$opt .= $langs -> trans ( " Currency " . $conf -> monnaie ) . " / " . $objp -> quantity . $langs -> trans ( " Units " );
if ( $objp -> quantity > 1 )
{
$opt .= " - " ;
2007-07-09 00:23:03 +02:00
$opt .= price ( $objp -> unitprice ) . $langs -> trans ( " Currency " . $conf -> monnaie ) . " / " . $langs -> trans ( " Unit " );
2007-07-08 14:41:24 +02:00
}
if ( $objp -> duration ) $opt .= " - " . $objp -> duration ;
}
else
2007-04-02 01:04:24 +02:00
{
2007-07-08 14:41:24 +02:00
$opt .= $langs -> trans ( " NoPriceDefinedForThisSupplier " );
2007-04-02 01:04:24 +02:00
}
$opt .= " </option> \n " ;
print $opt ;
$i ++ ;
}
print '</select>' ;
$this -> db -> free ( $result );
}
else
{
dolibarr_print_error ( $db );
}
}
2006-02-09 18:36:09 +01:00
2006-04-21 17:16:34 +02:00
/**
* \brief Retourne la liste d<EFBFBD> roulante des adresses de livraison
* \param selected Id contact pr<EFBFBD> - s<EFBFBD> lectionn
* \param htmlname Nom champ formulaire
*/
2006-06-30 16:23:57 +02:00
function select_adresse_livraison ( $selected = '' , $socid , $htmlname = 'adresse_livraison_id' , $showempty = 0 )
2006-04-21 17:16:34 +02:00
{
// On recherche les utilisateurs
$sql = " SELECT a.rowid, a.label " ;
$sql .= " FROM " . MAIN_DB_PREFIX . " societe_adresse_livraison as a " ;
$sql .= " WHERE a.fk_societe = " . $socid ;
$sql .= " ORDER BY a.label ASC " ;
if ( $this -> db -> query ( $sql ))
{
print '<select class="flat" name="' . $htmlname . '">' ;
2006-06-30 16:23:57 +02:00
if ( $showempty ) print '<option value="0"> </option>' ;
2006-04-21 17:16:34 +02:00
$num = $this -> db -> num_rows ();
$i = 0 ;
if ( $num )
{
while ( $i < $num )
{
$obj = $this -> db -> fetch_object ();
if ( $selected && $selected == $obj -> rowid )
{
print '<option value="' . $obj -> rowid . '" selected="true">' . $obj -> label . '</option>' ;
}
else
{
print '<option value="' . $obj -> rowid . '">' . $obj -> label . '</option>' ;
}
$i ++ ;
}
}
print '</select>' ;
2006-04-24 12:51:32 +02:00
return $num ;
2006-04-21 17:16:34 +02:00
}
else
{
dolibarr_print_error ( $this -> db );
}
}
2006-02-09 18:36:09 +01:00
/**
* \brief Charge dans cache la liste des conditions de paiements possibles
* \return int Nb lignes charg<EFBFBD> es , 0 si d<EFBFBD> j<EFBFBD> charg<EFBFBD> es , < 0 si ko
*/
function load_cache_conditions_paiements ()
{
global $langs ;
if ( sizeof ( $this -> cache_conditions_paiements_code )) return 0 ; // Cache d<> ja charg<72>
2007-01-05 10:55:48 +01:00
dolibarr_syslog ( 'Form::load_cache_conditions_paiements' , LOG_DEBUG );
2006-06-18 14:56:57 +02:00
2006-04-22 02:56:55 +02:00
$sql = " SELECT rowid, code, libelle " ;
2006-02-09 18:36:09 +01:00
$sql .= " FROM " . MAIN_DB_PREFIX . " cond_reglement " ;
$sql .= " WHERE active=1 " ;
$sql .= " ORDER BY sortorder " ;
$resql = $this -> db -> query ( $sql );
if ( $resql )
{
$num = $this -> db -> num_rows ( $result );
$i = 0 ;
while ( $i < $num )
{
$obj = $this -> db -> fetch_object ( $resql );
// Si traduction existe, on l'utilise, sinon on prend le libell<6C> par d<> faut
2006-04-22 02:56:55 +02:00
$libelle = ( $langs -> trans ( " PaymentConditionShort " . $obj -> code ) != ( " PaymentConditionShort " . $obj -> code ) ? $langs -> trans ( " PaymentConditionShort " . $obj -> code ) : ( $obj -> libelle != '-' ? $obj -> libelle : '' ));
2006-02-09 18:36:09 +01:00
$this -> cache_conditions_paiements_code [ $obj -> rowid ] = $obj -> code ;
$this -> cache_conditions_paiements_libelle [ $obj -> rowid ] = $libelle ;
$i ++ ;
}
return 1 ;
}
else {
dolibarr_print_error ( $this -> db );
return - 1 ;
}
}
/**
* \brief Charge dans cache la liste des types de paiements possibles
* \return int Nb lignes charg<EFBFBD> es , 0 si d<EFBFBD> j<EFBFBD> charg<EFBFBD> es , < 0 si ko
*/
function load_cache_types_paiements ()
{
global $langs ;
if ( sizeof ( $this -> cache_types_paiements_code )) return 0 ; // Cache d<> ja charg<72>
2007-01-05 10:55:48 +01:00
dolibarr_syslog ( 'Form::load_cache_types_paiements' , LOG_DEBUG );
2006-06-18 14:56:57 +02:00
2006-02-09 18:36:09 +01:00
$sql = " SELECT id, code, libelle, type " ;
$sql .= " FROM " . MAIN_DB_PREFIX . " c_paiement " ;
$sql .= " WHERE active > 0 " ;
$sql .= " ORDER BY id " ;
$resql = $this -> db -> query ( $sql );
if ( $resql )
{
$num = $this -> db -> num_rows ( $result );
$i = 0 ;
while ( $i < $num )
{
$obj = $this -> db -> fetch_object ( $resql );
// Si traduction existe, on l'utilise, sinon on prend le libell<6C> par d<> faut
2007-01-06 01:31:26 +01:00
$libelle = ( $langs -> trans ( " PaymentTypeShort " . $obj -> code ) != ( " PaymentTypeShort " . $obj -> code ) ? $langs -> trans ( " PaymentTypeShort " . $obj -> code ) : ( $obj -> libelle != '-' ? $obj -> libelle : '' ));
2006-02-09 18:36:09 +01:00
$this -> cache_types_paiements_code [ $obj -> id ] = $obj -> code ;
$this -> cache_types_paiements_libelle [ $obj -> id ] = $libelle ;
$this -> cache_types_paiements_type [ $obj -> id ] = $obj -> type ;
$i ++ ;
}
return $num ;
}
else {
dolibarr_print_error ( $this -> db );
return - 1 ;
}
}
/**
* \brief Retourne la liste des types de paiements possibles
* \param selected Id du type de paiement pr<EFBFBD> s<EFBFBD> lectionn<EFBFBD>
* \param htmlname Nom de la zone select
* \param filtertype Pour filtre
2006-02-25 14:06:35 +01:00
* \param addempty Ajoute entr<EFBFBD> e vide
2006-02-09 18:36:09 +01:00
*/
2006-02-25 14:06:35 +01:00
function select_conditions_paiements ( $selected = '' , $htmlname = 'condid' , $filtertype =- 1 , $addempty = 0 )
2006-02-09 18:36:09 +01:00
{
global $langs ;
$this -> load_cache_conditions_paiements ();
print '<select class="flat" name="' . $htmlname . '">' ;
2006-02-25 14:06:35 +01:00
if ( $addempty ) print '<option value="0"> </option>' ;
2006-02-09 18:36:09 +01:00
foreach ( $this -> cache_conditions_paiements_code as $id => $code )
{
if ( $selected == $id )
{
print '<option value="' . $id . '" selected="true">' ;
}
else
{
print '<option value="' . $id . '">' ;
}
print $this -> cache_conditions_paiements_libelle [ $id ];
print '</option>' ;
}
print '</select>' ;
}
2006-02-25 14:06:35 +01:00
2006-12-19 11:58:33 +01:00
/**
* \brief Selection HT ou TTC
* \param selected Id pr<EFBFBD> s<EFBFBD> lectionn<EFBFBD>
* \param htmlname Nom de la zone select
*/
function select_PriceBaseType ( $selected = '' , $htmlname = 'price_base_type' )
{
global $langs ;
print '<select class="flat" name="' . $htmlname . '">' ;
$options = array (
'HT' => $langs -> trans ( " HT " ),
'TTC' => $langs -> trans ( " TTC " )
);
foreach ( $options as $id => $value )
{
if ( $selected == $id )
{
print '<option value="' . $id . '" selected="true">' . $value ;
}
else
{
print '<option value="' . $id . '">' . $value ;
}
print '</option>' ;
}
print '</select>' ;
}
2006-02-09 18:36:09 +01:00
/**
* \brief Retourne la liste des modes de paiements possibles
* \param selected Id du mode de paiement pr<EFBFBD> s<EFBFBD> lectionn<EFBFBD>
* \param htmlname Nom de la zone select
* \param filtertype Pour filtre
* \param format 0 = id + libelle , 1 = code + code , 2 = code + libelle
2007-02-04 22:23:58 +01:00
* \param empty 1 = peut etre vide , 0 sinon
2006-02-09 18:36:09 +01:00
*/
2007-02-04 22:23:58 +01:00
function select_types_paiements ( $selected = '' , $htmlname = 'paiementtype' , $filtertype = '' , $format = 0 , $empty = 0 )
2006-02-09 18:36:09 +01:00
{
global $langs ;
2006-06-24 22:29:06 +02:00
2007-02-04 22:23:58 +01:00
dolibarr_syslog ( " Form::select_type_paiements $selected , $htmlname , $filtertype , $format " , LOG_DEBUG );
2006-06-24 22:29:06 +02:00
2006-02-09 18:36:09 +01:00
$filterarray = array ();
2006-06-24 22:29:06 +02:00
if ( $filtertype == 'CRDT' ) $filterarray = array ( 0 , 2 );
elseif ( $filtertype == 'DBIT' ) $filterarray = array ( 1 , 2 );
2006-06-25 21:13:09 +02:00
elseif ( $filtertype != '' && $filtertype != '-1' ) $filterarray = split ( ',' , $filtertype );
2006-02-09 18:36:09 +01:00
$this -> load_cache_types_paiements ();
print '<select class="flat" name="' . $htmlname . '">' ;
2007-02-04 22:23:58 +01:00
if ( $empty ) print '<option value=""> </option>' ;
2006-02-09 18:36:09 +01:00
foreach ( $this -> cache_types_paiements_code as $id => $code )
{
// On passe si on a demand<6E> de filtrer sur des modes de paiments particuli<6C> rs
if ( sizeof ( $filterarray ) && ! in_array ( $this -> cache_types_paiements_type [ $id ], $filterarray )) continue ;
if ( $format == 0 ) print '<option value="' . $id . '"' ;
if ( $format == 1 ) print '<option value="' . $code . '"' ;
if ( $format == 2 ) print '<option value="' . $code . '"' ;
// Si selected est text, on compare avec code, sinon avec id
if ( eregi ( '[a-z]' , $selected ) && $selected == $code ) print ' selected="true"' ;
elseif ( $selected == $id ) print ' selected="true"' ;
print '>' ;
2006-04-04 02:12:45 +02:00
if ( $format == 0 ) $value = $this -> cache_types_paiements_libelle [ $id ];
if ( $format == 1 ) $value = $code ;
if ( $format == 2 ) $value = $this -> cache_types_paiements_libelle [ $id ];
print $value ? $value : ' ' ;
2006-02-09 18:36:09 +01:00
print '</option>' ;
}
print '</select>' ;
}
2007-07-27 10:10:11 +02:00
/**
* \brief Retourne la liste d<EFBFBD> roulante des diff<EFBFBD> rents <EFBFBD> tats d ' une propal .
* Les valeurs de la liste sont les id de la table c_propalst
* \param selected etat pre - s<EFBFBD> l<EFBFBD> ctionn<EFBFBD>
*/
function select_propal_statut ( $selected = '' )
{
$sql = " SELECT id, code, label, active FROM " . MAIN_DB_PREFIX . " c_propalst " ;
$sql .= " WHERE active = 1 " ;
if ( $this -> db -> query ( $sql ))
{
print '<select class="flat" name="propal_statut">' ;
print '<option value=""> </option>' ;
$num = $this -> db -> num_rows ();
$i = 0 ;
if ( $num )
{
while ( $i < $num )
{
$obj = $this -> db -> fetch_object ();
if ( $selected == $obj -> id )
{
print '<option value="' . $obj -> id . '" selected="true">' ;
}
else
{
print '<option value="' . $obj -> id . '">' ;
}
// Si traduction existe, on l'utilise, sinon on prend le libell<6C> par d<> faut
//print ($langs->trans("Civility".$obj->code)!="Civility".$obj->code ? $langs->trans("Civility".$obj->code) : ($obj->civilite!='-'?$obj->civilite:''));
print $obj -> label ;
print '</option>' ;
$i ++ ;
}
}
print '</select>' ;
}
else
{
dolibarr_print_error ( $this -> db );
}
}
2006-02-09 18:36:09 +01:00
/**
* \brief Retourne la liste des comptes
* \param selected Id compte pr<EFBFBD> s<EFBFBD> lectionn<EFBFBD>
* \param htmlname Nom de la zone select
* \param statut Statut des comptes recherch<EFBFBD> s
* \param filtre Pour filtre sur la liste
* \param useempty Affiche valeur vide dans liste
*/
function select_comptes ( $selected = '' , $htmlname = 'accountid' , $statut = 0 , $filtre = '' , $useempty = 0 )
{
global $langs ;
$sql = " SELECT rowid, label, bank " ;
$sql .= " FROM " . MAIN_DB_PREFIX . " bank_account " ;
$sql .= " WHERE clos = ' " . $statut . " ' " ;
if ( $filtre ) $sql .= " AND " . $filtre ;
$sql .= " ORDER BY rowid " ;
$result = $this -> db -> query ( $sql );
if ( $result )
{
print '<select class="flat" name="' . $htmlname . '">' ;
if ( $useempty )
{
2006-11-10 01:28:39 +01:00
print '<option value="' . $obj -> rowid . '"> </option>' ;
2006-02-09 18:36:09 +01:00
}
$num = $this -> db -> num_rows ( $result );
$i = 0 ;
while ( $i < $num )
{
$obj = $this -> db -> fetch_object ( $result );
if ( $selected == $obj -> rowid )
{
print '<option value="' . $obj -> rowid . '" selected="true">' ;
}
else
{
print '<option value="' . $obj -> rowid . '">' ;
}
print $obj -> label ;
print '</option>' ;
$i ++ ;
}
print " </select> " ;
}
else {
dolibarr_print_error ( $this -> db );
}
}
2006-02-22 16:13:11 +01:00
2006-08-15 19:33:56 +02:00
/**
* \brief Retourne la ou les listes d<EFBFBD> roulante des cat<EFBFBD> gories en fonction
* du nombre choisi
* \param selected nombre de cat<EFBFBD> gorie <EFBFBD> cr<EFBFBD> er
2006-02-22 16:13:11 +01:00
*/
2007-04-30 12:53:58 +02:00
function select_all_categories ( $type , $selected = '' , $select_name = " " )
2006-02-22 16:13:11 +01:00
{
global $langs ;
$langs -> load ( " categorie " );
2006-08-15 19:33:56 +02:00
if ( $select_name == " " ) $select_name = " catMere " ;
2007-07-08 15:04:23 +02:00
$cat = new Categorie ( $this -> db );
2007-04-30 12:53:58 +02:00
$cate_arbo = $cat -> get_full_arbo ( $type );
2006-08-15 19:33:56 +02:00
2007-07-09 00:50:35 +02:00
$output = '<select class="flat" name="' . $select_name . '">' ;
2007-07-08 15:04:23 +02:00
$output .= '<option value="-1" id="choix" disabled="disabled">' . $langs -> trans ( " NoCategoriesDefined " ) . '</option>' ;
2006-03-13 17:44:13 +01:00
2006-04-07 23:04:14 +02:00
if ( $cate_arbo )
2006-03-13 17:44:13 +01:00
{
2006-04-07 23:04:14 +02:00
foreach ( $cate_arbo as $key => $value )
{
2006-12-19 21:33:32 +01:00
if ( $cate_arbo [ $key ][ 'id' ] == $selected )
2006-08-15 19:33:56 +02:00
{
2006-04-07 23:04:14 +02:00
$add = " selected='true' " ;
2006-08-15 19:33:56 +02:00
}
2006-04-07 23:04:14 +02:00
else
2006-08-15 19:33:56 +02:00
{
2006-04-07 23:04:14 +02:00
$add = " " ;
2006-08-15 19:33:56 +02:00
}
$output .= '<option ' . $add . 'value="' . $cate_arbo [ $key ][ 'id' ] . '">' . $cate_arbo [ $key ][ 'fulllabel' ] . '</option>' ;
2006-04-07 23:04:14 +02:00
}
2006-03-13 17:44:13 +01:00
}
2006-04-07 23:04:14 +02:00
2006-03-16 16:59:05 +01:00
$output .= '</select>' ;
2006-07-30 02:37:31 +02:00
$output .= " \n " ;
2006-04-07 23:04:14 +02:00
return $output ;
}
2006-02-22 16:13:11 +01:00
2006-02-09 18:36:09 +01:00
/**
* \brief Retourne la liste d<EFBFBD> roulante des civilite actives
* \param selected civilite pr<EFBFBD> - s<EFBFBD> lectionn<EFBFBD> e
*/
function select_civilite ( $selected = '' )
{
global $conf , $langs ;
$langs -> load ( " dict " );
$sql = " SELECT rowid, code, civilite, active FROM " . MAIN_DB_PREFIX . " c_civilite " ;
$sql .= " WHERE active = 1 " ;
if ( $this -> db -> query ( $sql ))
{
print '<select class="flat" name="civilite_id">' ;
print '<option value=""> </option>' ;
$num = $this -> db -> num_rows ();
$i = 0 ;
if ( $num )
{
while ( $i < $num )
{
$obj = $this -> db -> fetch_object ();
if ( $selected == $obj -> code )
{
print '<option value="' . $obj -> code . '" selected="true">' ;
}
else
{
print '<option value="' . $obj -> code . '">' ;
}
// Si traduction existe, on l'utilise, sinon on prend le libell<6C> par d<> faut
print ( $langs -> trans ( " Civility " . $obj -> code ) != " Civility " . $obj -> code ? $langs -> trans ( " Civility " . $obj -> code ) : ( $obj -> civilite != '-' ? $obj -> civilite : '' ));
print '</option>' ;
$i ++ ;
}
}
print '</select>' ;
}
else
{
dolibarr_print_error ( $this -> db );
}
}
/**
* \brief Retourne le nom traduit de la civilit<EFBFBD>
* \param code Code de la civilit<EFBFBD>
* \return string Nom traduit de la civilit<EFBFBD>
*/
function civilite_name ( $code )
{
global $langs ;
$langs -> load ( " dict " );
return $langs -> trans ( " Civility " . $code ) != " Civility " . $code ? $langs -> trans ( " Civility " . $code ) : $code ;
}
/**
* \brief Retourne la liste d<EFBFBD> roulante des formes juridiques tous pays confondus ou pour un pays donn<EFBFBD> .
* \remarks Dans le cas d ' une liste tous pays confondu , on affiche une rupture sur le pays
* \param selected Code forme juridique a pr<EFBFBD> s<EFBFBD> lectionn
* \param pays_code 0 = liste tous pays confondus , sinon code du pays <EFBFBD> afficher
*/
function select_forme_juridique ( $selected = '' , $pays_code = 0 )
{
global $conf , $langs ;
$langs -> load ( " dict " );
// On recherche les formes juridiques actives des pays actifs
$sql = " SELECT f.rowid, f.code as code , f.libelle as nom, f.active, p.libelle as libelle_pays, p.code as code_pays " ;
$sql .= " FROM llx_c_forme_juridique as f, llx_c_pays as p " ;
$sql .= " WHERE f.fk_pays=p.rowid " ;
$sql .= " AND f.active = 1 AND p.active = 1 " ;
if ( $pays_code ) $sql .= " AND p.code = ' " . $pays_code . " ' " ;
$sql .= " ORDER BY p.code, f.code " ;
$result = $this -> db -> query ( $sql );
if ( $result )
{
2006-06-05 20:26:46 +02:00
print '<div id="particulier2" class="visible">' ;
2006-02-09 18:36:09 +01:00
print '<select class="flat" name="forme_juridique_code">' ;
if ( $pays_code ) print '<option value="0"> </option>' ;
$num = $this -> db -> num_rows ( $result );
$i = 0 ;
if ( $num )
{
$pays = '' ;
while ( $i < $num )
{
$obj = $this -> db -> fetch_object ( $result );
if ( $obj -> code == 0 ) {
print '<option value="0"> </option>' ;
}
else {
if ( ! $pays || $pays != $obj -> libelle_pays ) {
// Affiche la rupture si on est en mode liste multipays
if ( ! $pays_code && $obj -> code_pays ) {
print '<option value="0">----- ' . $obj -> libelle_pays . " -----</option> \n " ;
$pays = $obj -> libelle_pays ;
}
}
if ( $selected > 0 && $selected == $obj -> code )
{
print '<option value="' . $obj -> code . '" selected="true">' ;
}
else
{
print '<option value="' . $obj -> code . '">' ;
}
// Si traduction existe, on l'utilise, sinon on prend le libell<6C> par d<> faut
2007-01-06 02:01:32 +01:00
print $obj -> code . ' - ' . ( $langs -> trans ( " JuridicalStatus " . $obj -> code ) != " JuridicalStatus " . $obj -> code ? $langs -> trans ( " JuridicalStatus " . $obj -> code ) : ( $obj -> nom != '-' ? $obj -> nom : '' ));
2006-02-09 18:36:09 +01:00
print '</option>' ;
}
$i ++ ;
}
}
print '</select>' ;
2006-06-05 20:26:46 +02:00
print '</div>' ;
2006-02-09 18:36:09 +01:00
}
else
{
dolibarr_print_error ( $this -> db );
}
}
/**
* \brief Retourne le nom traduit de la forme juridique
* \param code Code de la forme juridique
* \return string Nom traduit du pays
*/
function forme_juridique_name ( $code )
{
global $langs ;
if ( ! $code ) return '' ;
$sql = " SELECT libelle FROM " . MAIN_DB_PREFIX . " c_forme_juridique " ;
$sql .= " WHERE code=' $code '; " ;
if ( $this -> db -> query ( $sql ))
{
$num = $this -> db -> num_rows ();
if ( $num )
{
$obj = $this -> db -> fetch_object ();
$label = ( $obj -> libelle != '-' ? $obj -> libelle : '' );
return $label ;
}
else
{
return $langs -> trans ( " NotDefined " );
}
}
}
/**
* \brief Retourne le formulaire de saisie d ' un identifiant professionnel ( siren , siret , etc ... )
* \param idprof 1 , 2 , 3 , 4 ( Exemple : 1 = siren , 2 = siret , 3 = naf , 4 = rcs / rm )
* \param soc Objet societe
* \param htmlname Nom de la zone input
*/
function id_prof ( $idprof , $soc , $htmlname , $selected = '' )
{
global $langs ;
$formlength = 16 ;
if ( $idprof == 1 && $soc -> pays_code == 'FR' ) $formlength = 9 ;
if ( $idprof == 2 && $soc -> pays_code == 'FR' ) $formlength = 14 ;
if ( $idprof == 3 && $soc -> pays_code == 'FR' ) $formlength = 4 ;
2007-02-10 14:43:49 +01:00
if ( $idprof == 4 && $soc -> pays_code == 'FR' ) $formlength = 12 ;
2006-02-09 18:36:09 +01:00
print '<input type="text" name="' . $htmlname . '" size="' . ( $formlength + 1 ) . '" maxlength="' . $formlength . '" value="' . $selected . '">' ;
}
/**
* \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 Retourne le nom traduit ou code + nom d ' une devise
* \param code_iso Code iso de la devise
* \param withcode 1 = affiche code + nom
* \return string Nom traduit de la devise
*/
function currency_name ( $code_iso , $withcode = 0 )
{
global $langs ;
// Si il existe une traduction, on peut renvoyer de suite le libell<6C>
if ( $langs -> trans ( " Currency " . $code_iso ) != " Currency " . $code_iso )
{
return $langs -> trans ( " Currency " . $code_iso );
}
// Si pas de traduction, on consulte libell<6C> par d<> faut en table
$sql = " SELECT label FROM " . MAIN_DB_PREFIX . " c_currencies " ;
$sql .= " WHERE code_iso=' $code_iso '; " ;
if ( $this -> db -> query ( $sql ))
{
$num = $this -> db -> num_rows ();
if ( $num )
{
$obj = $this -> db -> fetch_object ();
$label = ( $obj -> label != '-' ? $obj -> label : '' );
if ( $withcode ) return $label == $code_iso ? " $code_iso " : " $code_iso - $label " ;
else return $label ;
}
else
{
return $code_iso ;
}
}
}
/**
* \brief Affiche formulaire de demande de confirmation
2006-08-20 01:00:53 +02:00
* \param page page
* \param title title
* \param question question
* \param action action
2006-11-10 01:28:39 +01:00
* \param formquestion an array with forms complementary inputs
2006-02-09 18:36:09 +01:00
*/
2006-08-20 01:00:53 +02:00
function form_confirm ( $page , $title , $question , $action , $formquestion = '' )
2006-02-09 18:36:09 +01:00
{
global $langs ;
2006-08-20 01:00:53 +02:00
print '<form method="post" action="' . $page . '" class="notoptoleftroright">' ;
2006-02-09 18:36:09 +01:00
print '<input type="hidden" name="action" value="' . $action . '">' ;
2006-08-20 01:00:53 +02:00
print '<table width="100%" class="valid">' ;
2006-02-09 18:36:09 +01:00
// Ligne titre
2006-08-20 01:00:53 +02:00
print '<tr class="validtitre"><td class="validtitre" colspan="3">' . img_picto ( '' , 'recent' ) . ' ' . $title . '</td></tr>' ;
// Ligne formulaire
if ( $formquestion )
{
print '<tr class="valid"><td class="valid" colspan="3">' ;
print '<table class="notopnoleftnoright" width="100%">' ;
2006-08-21 23:46:21 +02:00
print '<tr><td colspan="3" valign="top">' . $formquestion [ 'text' ] . '</td></tr>' ;
2006-08-20 01:00:53 +02:00
foreach ( $formquestion as $key => $input )
{
2006-11-10 01:28:39 +01:00
if ( $input [ 'type' ] == 'text' )
{
print '<tr><td valign="top">' . $input [ 'label' ] . '</td><td colspan="2"><input type="text" class="flat" name="' . $input [ 'name' ] . '" size="' . $input [ 'size' ] . '" value="' . $input [ 'value' ] . '"></td></tr>' ;
}
if ( $input [ 'type' ] == 'select' )
{
// TODO
}
2006-08-20 01:00:53 +02:00
if ( $input [ 'type' ] == 'radio' )
{
$i = 0 ;
foreach ( $input [ 'values' ] as $selkey => $selval )
{
print '<tr>' ;
2006-08-21 23:46:21 +02:00
if ( $i == 0 ) print '<td valign="top">' . $input [ 'label' ] . '</td>' ;
2006-08-20 01:00:53 +02:00
else print '<td> </td>' ;
2007-03-06 17:14:14 +01:00
print '<td valign="top" width="20"><input type="radio" class="flat" name="' . $input [ 'name' ] . '" value="' . $selkey . '"></td>' ;
print '<td valign="top" align="left">' ;
2006-08-21 23:46:21 +02:00
print $selval ;
print '</td></tr>' ;
2006-08-20 01:00:53 +02:00
$i ++ ;
}
}
}
2006-11-10 01:28:39 +01:00
print '</table>' ;
print '</td></tr>' ;
2006-08-20 01:00:53 +02:00
}
2006-02-09 18:36:09 +01:00
// Ligne message
2006-11-10 01:28:39 +01:00
print '<tr class="valid">' ;
print '<td class="valid">' . $question . '</td>' ;
2006-08-20 01:00:53 +02:00
print '<td class="valid">' ;
2007-04-30 13:01:10 +02:00
print $this -> selectyesno ( " confirm " , " no " );
2006-08-20 01:00:53 +02:00
print '</td>' ;
2006-11-10 01:28:39 +01:00
print '<td class="valid" align="center"><input class="button" type="submit" value="' . $langs -> trans ( " Validate " ) . '"></td>' ;
print '</tr>' ;
2006-02-09 18:36:09 +01:00
print '</table>' ;
2006-11-10 01:28:39 +01:00
2006-11-11 01:46:15 +01:00
if ( is_array ( $formquestion ))
{
foreach ( $formquestion as $key => $input )
{
if ( $input [ 'type' ] == 'hidden' ) print '<input type="hidden" name="' . $input [ 'name' ] . '" value="' . $input [ 'value' ] . '">' ;
}
2006-11-10 01:28:39 +01:00
}
2006-11-11 01:46:15 +01:00
2006-02-09 18:36:09 +01:00
print " </form> \n " ;
}
/**
* \brief Affiche formulaire de selection de projet
* \param page Page
* \param socid Id societe
* \param selected Id projet pr<EFBFBD> s<EFBFBD> lectionn<EFBFBD>
* \param htmlname Nom du formulaire select
*/
function form_project ( $page , $socid , $selected = '' , $htmlname = 'projectid' )
{
global $langs ;
2006-08-05 20:38:22 +02:00
2006-02-09 18:36:09 +01:00
$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 );
print '</td>' ;
print '<td align="left"><input type="submit" class="button" value="' . $langs -> trans ( " Modify " ) . '"></td>' ;
print '</tr></table></form>' ;
}
else
{
if ( $selected ) {
$projet = New Project ( $this -> db );
$projet -> fetch ( $selected );
print '<a href="' . DOL_URL_ROOT . '/projet/fiche.php?id=' . $selected . '">' . $projet -> title . '</a>' ;
} else {
print " " ;
}
}
}
/**
2006-02-25 14:06:35 +01:00
* \brief Affiche formulaire de selection de conditions de paiement
* \param page Page
* \param selected Id condition pr<EFBFBD> s<EFBFBD> lectionn<EFBFBD> e
* \param htmlname Nom du formulaire select
* \param addempty Ajoute entr<EFBFBD> e vide
2006-02-09 18:36:09 +01:00
*/
2006-02-25 14:06:35 +01:00
function form_conditions_reglement ( $page , $selected = '' , $htmlname = 'cond_reglement_id' , $addempty = 0 )
2006-02-09 18:36:09 +01:00
{
global $langs ;
if ( $htmlname != " none " )
{
print '<form method="post" action="' . $page . '">' ;
print '<input type="hidden" name="action" value="setconditions">' ;
print '<table class="noborder" cellpadding="0" cellspacing="0">' ;
print '<tr><td>' ;
2006-02-25 14:06:35 +01:00
$this -> select_conditions_paiements ( $selected , $htmlname , - 1 , $addempty );
2006-02-09 18:36:09 +01:00
print '</td>' ;
print '<td align="left"><input type="submit" class="button" value="' . $langs -> trans ( " Modify " ) . '"></td>' ;
print '</tr></table></form>' ;
}
else
{
if ( $selected )
{
$this -> load_cache_conditions_paiements ();
print $this -> cache_conditions_paiements_libelle [ $selected ];
} else {
print " " ;
2006-02-20 17:22:10 +01:00
}
}
}
2006-02-25 14:06:35 +01:00
2006-02-20 17:22:10 +01:00
/**
* \brief Affiche formulaire de selection de l ' assuj<EFBFBD> tissement <EFBFBD> la TVA
* \param page Page
* \param selected Id condition pr<EFBFBD> s<EFBFBD> lectionn<EFBFBD> e
* \param htmlname Nom du formulaire select
*/
function form_assujetti_tva ( $page , $selected = '' , $htmlname = '' )
{
global $langs ;
2006-02-20 17:29:55 +01:00
$options = array ( 0 => " non " , 1 => " oui " );
2006-02-20 17:22:10 +01:00
if ( $htmlname != " none " )
{
print '<form method="post" action="' . $page . '">' ;
print '<input type="hidden" name="action" value="setassujtva">' ;
print '<table class="noborder" cellpadding="0" cellspacing="0">' ;
print '<tr><td>' ;
$this -> select_assujetti_tva ( $selected , $htmlname );
print '</td>' ;
print '<td align="left"><input type="submit" class="button" value="' . $langs -> trans ( " Modify " ) . '"></td>' ;
print '</tr></table></form>' ;
}
else
{
2006-02-20 17:43:05 +01:00
if ( $selected != " " )
2006-02-20 17:22:10 +01:00
{
2006-02-20 17:29:55 +01:00
print $options [ $selected ];
2006-02-20 17:22:10 +01:00
} else {
print " " ;
2006-02-09 18:36:09 +01:00
}
}
}
/**
* \brief Affiche formulaire de selection des modes de reglement
* \param page Page
* \param selected Id mode pr<EFBFBD> s<EFBFBD> lectionn<EFBFBD>
* \param htmlname Nom du formulaire select
*/
function form_modes_reglement ( $page , $selected = '' , $htmlname = 'mode_reglement_id' )
{
global $langs ;
if ( $htmlname != " none " )
{
print '<form method="post" action="' . $page . '">' ;
print '<input type="hidden" name="action" value="setmode">' ;
print '<table class="noborder" cellpadding="0" cellspacing="0">' ;
print '<tr><td>' ;
$this -> select_types_paiements ( $selected , $htmlname );
print '</td>' ;
print '<td align="left"><input type="submit" class="button" value="' . $langs -> trans ( " Modify " ) . '"></td>' ;
print '</tr></table></form>' ;
}
else
{
if ( $selected )
{
$this -> load_cache_types_paiements ();
print $this -> cache_types_paiements_libelle [ $selected ];
} else {
print " " ;
}
}
}
2006-04-04 02:12:45 +02:00
/**
* \brief Affiche formulaire de selection de la remise relative
* \param page Page
* \param selected Valeur remise
* \param htmlname Nom du formulaire select . Si none , non modifiable
*/
function form_remise_percent ( $page , $selected = '' , $htmlname = 'remise_percent' )
{
global $langs ;
if ( $htmlname != " none " )
{
print '<form method="post" action="' . $page . '">' ;
print '<input type="hidden" name="action" value="setremisepercent">' ;
print '<table class="noborder" cellpadding="0" cellspacing="0">' ;
print '<tr><td>' ;
print '<input type="text" name="' . $htmlname . '" size="1" value="' . $selected . '">%' ;
print '</td>' ;
print '<td align="left"><input type="submit" class="button" value="' . $langs -> trans ( " Modify " ) . '"></td>' ;
print '</tr></table></form>' ;
}
else
{
if ( $selected )
{
print $selected ;
} else {
print " 0% " ;
}
}
}
2006-02-09 18:36:09 +01:00
2006-11-13 23:01:35 +01:00
/**
* \brief Affiche formulaire ajout fichier
* \param url Url
* \param titre Titre zone
* \param addcancel 1 = Ajoute un bouton 'Annuler'
* \return int < 0 si ko , > 0 si ok
*/
function form_attach_new_file ( $url , $titre = '' , $addcancel = 0 )
{
global $conf , $langs ;
if ( $conf -> upload != 0 )
{
print " \n \n <!-- Start form attach new file --> \n " ;
if ( ! $titre ) $titre = $langs -> trans ( " AttachANewFile " );
print_titre ( $titre );
print '<form name="userfile" action="' . $url . '" enctype="multipart/form-data" method="POST">' ;
print '<table width="100%" class="noborder">' ;
print '<tr><td width="50%" valign="top">' ;
2006-11-16 01:08:54 +01:00
$max = $conf -> upload ; // En Kb
2006-12-16 23:36:14 +01:00
$maxphp =@ ini_get ( 'upload_max_filesize' ); // En inconnu
if ( eregi ( 'm$' , $maxphp )) $maxphp = $maxphp * 1024 ;
if ( eregi ( 'k$' , $maxphp )) $maxphp = $maxphp ;
// Now $max and $maxphp are in Kb
if ( $maxphp > 0 ) $max = min ( $max , $maxphp );
2006-11-16 01:08:54 +01:00
2006-11-13 23:01:35 +01:00
if ( $conf -> upload > 0 )
{
2006-11-16 01:08:54 +01:00
print '<input type="hidden" name="max_file_size" value="' . ( $max * 1024 ) . '">' ;
2006-11-13 23:01:35 +01:00
}
print '<input class="flat" type="file" name="userfile" size="70">' ;
print ' ' ;
print '<input type="submit" class="button" name="sendit" value="' . $langs -> trans ( " Upload " ) . '">' ;
if ( $addcancel )
{
print ' ' ;
print '<input type="submit" class="button" name="cancel" value="' . $langs -> trans ( " Cancel " ) . '">' ;
}
2006-11-16 01:08:54 +01:00
print ' (' . $langs -> trans ( " MaxSize " ) . ': ' . $max . ' ' . $langs -> trans ( " Kb " ) . ')' ;
2006-11-13 23:01:35 +01:00
print " </td></tr> " ;
print " </table> " ;
print '</form>' ;
print '<br>' ;
print " \n <!-- End form attach new file --> \n \n " ;
}
return 1 ;
}
2006-04-04 02:12:45 +02:00
/**
2006-06-04 00:01:38 +02:00
* \brief Affiche formulaire de selection de la remise fixe
2006-04-04 02:12:45 +02:00
* \param page Page
* \param selected Valeur <EFBFBD> appliquer
* \param htmlname Nom du formulaire select . Si none , non modifiable
*/
2006-06-30 01:48:44 +02:00
function form_remise_dispo ( $page , $selected = '' , $htmlname = 'remise_id' , $socid , $absolute_discount )
2006-04-04 02:12:45 +02:00
{
2006-06-30 01:48:44 +02:00
global $conf , $langs ;
2006-04-04 02:12:45 +02:00
if ( $htmlname != " none " )
{
print '<form method="post" action="' . $page . '">' ;
2006-06-04 00:01:38 +02:00
print '<input type="hidden" name="action" value="setabsolutediscount">' ;
print '<table class="nobordernopadding" cellpadding="0" cellspacing="0">' ;
2006-04-04 02:12:45 +02:00
print '<tr><td>' ;
2007-07-05 00:07:53 +02:00
print $langs -> trans ( " CompanyHasAbsoluteDiscount " , price ( $absolute_discount ), $langs -> trans ( " Currency " . $conf -> monnaie )) . ': ' ;
2006-06-30 01:48:44 +02:00
// print $langs->trans("AvailableGlobalDiscounts").': ';
2006-06-04 00:01:38 +02:00
print $this -> select_remises ( '' , $htmlname , 'fk_facture IS NULL' , $socid );
2006-04-04 02:12:45 +02:00
print '</td>' ;
2006-06-04 00:01:38 +02:00
print '<td align="left"> <input type="submit" class="button" value="' . $langs -> trans ( " UseDiscount " ) . '"></td>' ;
2006-04-04 02:12:45 +02:00
print '</tr></table></form>' ;
}
else
{
if ( $selected )
{
print $selected ;
2007-07-05 00:07:53 +02:00
}
else
{
2006-04-04 02:12:45 +02:00
print " 0 " ;
}
}
}
2006-02-18 23:04:32 +01:00
/**
* \brief Affiche formulaire de selection des contacts
* \param page Page
* \param selected Id contact pr<EFBFBD> s<EFBFBD> lectionn<EFBFBD>
* \param htmlname Nom du formulaire select
*/
function form_contacts ( $page , $societe , $selected = '' , $htmlname = 'contactidp' )
{
global $langs ;
if ( $htmlname != " none " )
{
print '<form method="post" action="' . $page . '">' ;
print '<input type="hidden" name="action" value="set_contact">' ;
print '<table class="noborder" cellpadding="0" cellspacing="0">' ;
print '<tr><td>' ;
$num = $this -> select_contacts ( $societe -> id , $selected , $htmlname );
if ( $num == 0 )
{
print '<font class="error">Cette societe n\'a pas de contact, veuillez en cr<63> er un avant de faire votre proposition commerciale</font><br>' ;
print '<a href="' . DOL_URL_ROOT . '/contact/fiche.php?socid=' . $societe -> id . '&action=create&backtoreferer=1">' . $langs -> trans ( 'AddContact' ) . '</a>' ;
}
print '</td>' ;
print '<td align="left"><input type="submit" class="button" value="' . $langs -> trans ( " Modify " ) . '"></td>' ;
print '</tr></table></form>' ;
}
else
{
if ( $selected )
{
require_once ( DOL_DOCUMENT_ROOT . " /contact.class.php " );
//$this->load_cache_contacts();
//print $this->cache_contacts[$selected];
$contact = new Contact ( $this -> db );
$contact -> fetch ( $selected );
print $contact -> nom . ' ' . $contact -> prenom ;
} else {
print " " ;
}
}
}
2006-04-21 17:16:34 +02:00
/**
* \brief Affiche formulaire de selection de l ' adresse de livraison
* \param page Page
* \param selected Id condition pr<EFBFBD> s<EFBFBD> lectionn<EFBFBD> e
* \param htmlname Nom du formulaire select
2006-07-01 15:25:58 +02:00
* \param origin Origine de l ' appel pour pouvoir cr<EFBFBD> er un retour
* \param originid Id de l ' origine
2006-04-21 17:16:34 +02:00
*/
2006-04-24 15:00:07 +02:00
function form_adresse_livraison ( $page , $selected = '' , $socid , $htmlname = 'adresse_livraison_id' , $origin = '' , $originid = '' )
2006-04-21 17:16:34 +02:00
{
2006-04-24 13:08:10 +02:00
global $langs , $conf ;
2006-04-21 17:16:34 +02:00
if ( $htmlname != " none " )
{
print '<form method="post" action="' . $page . '">' ;
print '<input type="hidden" name="action" value="setdeliveryadress">' ;
print '<table class="noborder" cellpadding="0" cellspacing="0">' ;
print '<tr><td>' ;
2007-02-05 19:56:44 +01:00
$this -> select_adresse_livraison ( $selected , $socid , $htmlname , 1 );
2006-04-21 17:16:34 +02:00
print '</td>' ;
2006-04-24 13:09:41 +02:00
print '<td align="left"><input type="submit" class="button" value="' . $langs -> trans ( " Modify " ) . '">' ;
2007-02-05 19:56:44 +01:00
$langs -> load ( " companies " );
print ' <a href=' . DOL_URL_ROOT . '/comm/adresse_livraison.php?socid=' . $socid . '&action=create&origin=' . $origin . '&originid=' . $originid . '>' . $langs -> trans ( " AddAddress " ) . '</a>' ;
2006-04-24 13:09:41 +02:00
print '</td></tr></table></form>' ;
2006-04-21 17:16:34 +02:00
}
else
{
if ( $selected )
{
require_once ( DOL_DOCUMENT_ROOT . " /comm/adresse_livraison.class.php " );
2006-06-24 22:37:32 +02:00
$livraison = new AdresseLivraison ( $this -> db );
2006-04-21 17:16:34 +02:00
$livraison -> fetch_adresse ( $selected );
2007-02-05 19:56:44 +01:00
print '<a href=' . DOL_URL_ROOT . '/comm/adresse_livraison.php?socid=' . $livraison -> socid . '&idl=' . $livraison -> idl . '&action=edit&origin=' . $origin . '&originid=' . $originid . '>' . $livraison -> label . '</a>' ;
2006-04-21 17:16:34 +02:00
}
else
{
print " " ;
}
}
}
2006-02-18 23:04:32 +01:00
2006-02-09 18:36:09 +01:00
/**
* \brief Retourne la liste des devises , dans la langue de l ' utilisateur
* \param selected code devise pr<EFBFBD> - s<EFBFBD> lectionn<EFBFBD> e
* \param htmlname nom de la liste deroulante
* \todo trier liste sur noms apr<EFBFBD> s traduction plutot que avant
*/
function select_currency ( $selected = '' , $htmlname = 'currency_id' )
{
global $conf , $langs ;
$langs -> load ( " dict " );
if ( $selected == 'euro' || $selected == 'euros' ) $selected = 'EUR' ; // Pour compatibilit<69>
$sql = " SELECT code_iso, label, active FROM " . MAIN_DB_PREFIX . " c_currencies " ;
$sql .= " WHERE active = 1 " ;
$sql .= " ORDER BY code_iso ASC; " ;
if ( $this -> db -> query ( $sql ))
{
print '<select class="flat" name="' . $htmlname . '">' ;
$num = $this -> db -> num_rows ();
$i = 0 ;
if ( $num )
{
$foundselected = false ;
while ( $i < $num )
{
$obj = $this -> db -> fetch_object ();
if ( $selected && $selected == $obj -> code_iso )
{
$foundselected = true ;
print '<option value="' . $obj -> code_iso . '" selected="true">' ;
}
else
{
print '<option value="' . $obj -> code_iso . '">' ;
}
// Si traduction existe, on l'utilise, sinon on prend le libell<6C> par d<> faut
if ( $obj -> code_iso ) { print $obj -> code_iso . ' - ' ; }
print ( $obj -> code_iso && $langs -> trans ( " Currency " . $obj -> code_iso ) != " Currency " . $obj -> code_iso ? $langs -> trans ( " Currency " . $obj -> code_iso ) : ( $obj -> label != '-' ? $obj -> label : '' ));
print '</option>' ;
$i ++ ;
}
}
print '</select>' ;
return 0 ;
}
else {
dolibarr_print_error ( $this -> db );
return 1 ;
}
}
/**
2006-03-16 02:03:55 +01:00
* \brief Selection du taux de tva appliqu<EFBFBD> par vendeur
2006-02-09 18:36:09 +01:00
* \param name Nom champ html
2006-03-16 02:03:55 +01:00
* \param defaulttx For <EFBFBD> age du taux tva pr<EFBFBD> s<EFBFBD> lectionn<EFBFBD> . Mettre '' pour appliquer r<EFBFBD> gle par d<EFBFBD> faut .
2006-02-09 18:36:09 +01:00
* \param societe_vendeuse Objet soci<EFBFBD> t<EFBFBD> vendeuse
* \param societe_acheteuse Objet soci<EFBFBD> t<EFBFBD> acheteuse
* \param taux_produit Taux par defaut du produit vendu
* \remarks Si vendeur non assujeti <EFBFBD> TVA , TVA par d<EFBFBD> faut = 0. Fin de r<EFBFBD> gle .
* Si le ( pays vendeur = pays acheteur ) alors la TVA par d<EFBFBD> faut = TVA du produit vendu . Fin de r<EFBFBD> gle .
* Si vendeur et acheteur dans Communaut<EFBFBD> europ<EFBFBD> enne et bien vendu = moyen de transports neuf ( auto , bateau , avion ), TVA par d<EFBFBD> faut = 0 ( La TVA doit <EFBFBD> tre pay<EFBFBD> par l 'acheteur au centre d' impots de son pays et non au vendeur ) . Fin de r<EFBFBD> gle .
* Si vendeur et acheteur dans Communaut<EFBFBD> europ<EFBFBD> enne et bien vendu autre que transport neuf alors la TVA par d<EFBFBD> faut = TVA du produit vendu . Fin de r<EFBFBD> gle .
* Sinon la TVA propos<EFBFBD> e par d<EFBFBD> faut = 0. Fin de r<EFBFBD> gle .
*/
function select_tva ( $name = 'tauxtva' , $defaulttx = '' , $societe_vendeuse = '' , $societe_acheteuse = '' , $taux_produit = '' )
2006-12-09 19:09:02 +01:00
{
2007-01-30 02:20:16 +01:00
global $langs , $conf , $mysoc ;
2007-07-13 01:24:47 +02:00
$txtva = array ();
$libtva = array ();
2007-01-30 02:20:16 +01:00
//print $societe_vendeuse."-".$societe_acheteuse;
if ( is_object ( $societe_vendeuse ) && ! $societe_vendeuse -> pays_code )
{
if ( $societe_vendeuse -> id == $mysoc -> id )
{
print '<font class="error">' . $langs -> trans ( " ErrorYourCountryIsNotDefined " ) . '</div>' ;
}
else
{
print '<font class="error">' . $langs -> trans ( " ErrorSupplierCountryIsNotDefined " ) . '</div>' ;
}
return ;
}
if ( is_object ( $societe_vendeuse ))
{
$code_pays = $societe_vendeuse -> pays_code ;
}
else
{
$code_pays = $mysoc -> pays_code ; // Pour compatibilite ascendente
}
// Recherche liste des codes TVA du pays vendeur
$sql = " SELECT t.taux,t.recuperableonly " ;
$sql .= " FROM " . MAIN_DB_PREFIX . " c_tva as t, " . MAIN_DB_PREFIX . " c_pays as p " ;
$sql .= " WHERE t.fk_pays = p.rowid AND p.code = ' " . $code_pays . " ' " ;
$sql .= " AND t.active = 1 " ;
$sql .= " ORDER BY t.taux ASC, t.recuperableonly ASC " ;
$resql = $this -> db -> query ( $sql );
if ( $resql )
{
$num = $this -> db -> num_rows ( $resql );
2007-07-13 01:24:47 +02:00
if ( $num )
2007-01-30 02:20:16 +01:00
{
2007-07-13 01:24:47 +02:00
for ( $i = 0 ; $i < $num ; $i ++ )
{
$obj = $this -> db -> fetch_object ( $resql );
$txtva [ $i ] = $obj -> taux ;
$libtva [ $i ] = $obj -> taux . '%' . ( $obj -> recuperableonly ? ' *' : '' );
}
}
else
{
print '<font class="error">' . $langs -> trans ( " ErrorNoVATRateDefinedForSellerCountry " , $code_pays ) . '</font>' ;
2007-01-30 02:20:16 +01:00
}
}
else
{
2007-07-13 01:24:47 +02:00
print '<font class="error">' . $this -> db -> error () . '</font>' ;
2007-01-30 02:20:16 +01:00
}
// D<> finition du taux <20> pr<70> s<EFBFBD> lectionner
if ( $defaulttx == '' ) $defaulttx = get_default_tva ( $societe_vendeuse , $societe_acheteuse , $taux_produit );
// Si taux par defaut n'a pu etre trouv<75> , on prend dernier.
// Comme ils sont tri<72> s par ordre croissant, dernier = plus <20> lev<65> = taux courant
if ( $defaulttx == '' ) $defaulttx = $txtva [ sizeof ( $txtva ) - 1 ];
$nbdetaux = sizeof ( $txtva );
2007-07-13 01:24:47 +02:00
if ( sizeof ( $txtva ))
2007-01-30 02:20:16 +01:00
{
2007-07-13 01:24:47 +02:00
print '<select class="flat" name="' . $name . '">' ;
if ( $default ) print '<option value="0">' . $langs -> trans ( " Default " ) . '</option>' ;
for ( $i = 0 ; $i < $nbdetaux ; $i ++ )
2007-01-30 02:20:16 +01:00
{
2007-07-13 01:24:47 +02:00
print '<option value="' . $txtva [ $i ] . '"' ;
if ( $txtva [ $i ] == $defaulttx )
{
print ' selected="true"' ;
}
print '>' . vatrate ( $libtva [ $i ]) . '</option>' ;
$this -> tva_taux_value [ $i ] = $txtva [ $i ];
$this -> tva_taux_libelle [ $i ] = $libtva [ $i ];
2007-01-30 02:20:16 +01:00
}
2007-07-13 01:24:47 +02:00
print '</select>' ;
2007-01-30 02:20:16 +01:00
}
2006-12-09 19:09:02 +01:00
}
2006-12-12 17:53:34 +01:00
/**
2007-05-11 18:01:11 +02:00
* \brief Selection des unites de mesure
2006-12-12 17:53:34 +01:00
* \param name Nom champ html
2007-05-11 18:01:11 +02:00
* \param measuring_style Le style de mesure : weight , volume , ...
2006-12-12 17:53:34 +01:00
* \param default For <EFBFBD> age de l ' unite
* \remarks pour l ' instant on ne definit pas les unites dans la base
*/
2007-05-11 18:01:11 +02:00
function select_measuring_units ( $name = 'measuring_units' , $measuring_style = '' , $default = '0' , $adddefault = 0 )
2006-12-12 17:53:34 +01:00
{
2006-12-12 23:31:27 +01:00
global $langs , $conf , $mysoc ;
$langs -> load ( " other " );
2007-05-11 18:01:11 +02:00
if ( $measuring_style == 'weight' )
{
$measuring_units [ 3 ] = $langs -> trans ( " WeightUnitton " );
$measuring_units [ 0 ] = $langs -> trans ( " WeightUnitkg " );
$measuring_units [ - 3 ] = $langs -> trans ( " WeightUnitg " );
$measuring_units [ - 6 ] = $langs -> trans ( " WeightUnitmg " );
}
else if ( $measuring_style == 'volume' )
{
$measuring_units [ 0 ] = $langs -> trans ( " VolumeUnitm3 " );
$measuring_units [ - 3 ] = $langs -> trans ( " VolumeUnitcm3 " );
$measuring_units [ - 6 ] = $langs -> trans ( " VolumeUnitmm3 " );
}
2006-12-12 23:31:27 +01:00
print '<select class="flat" name="' . $name . '">' ;
if ( $adddefault ) print '<option value="0">' . $langs -> trans ( " Default " ) . '</option>' ;
2007-05-11 18:01:11 +02:00
foreach ( $measuring_units as $key => $value )
2006-12-12 23:31:27 +01:00
{
print '<option value="' . $key . '"' ;
if ( $key == $default )
{
print ' selected="true"' ;
}
print '>' . $value . '</option>' ;
}
print '</select>' ;
2007-05-11 18:01:11 +02:00
}
/**
*
*
*
*
*/
2006-12-09 19:09:02 +01:00
function load_tva ( $name = 'tauxtva' , $defaulttx = '' , $societe_vendeuse = '' , $societe_acheteuse = '' , $taux_produit = '' )
{
global $langs , $conf , $mysoc ;
if ( is_object ( $societe_vendeuse -> pays_code ))
{
$code_pays = $societe_vendeuse -> pays_code ;
}
else
{
$code_pays = $mysoc -> pays_code ; // Pour compatibilite ascendente
}
// Recherche liste des codes TVA du pays vendeur
$sql = " SELECT t.taux,t.recuperableonly " ;
$sql .= " FROM " . MAIN_DB_PREFIX . " c_tva as t, " . MAIN_DB_PREFIX . " c_pays as p " ;
$sql .= " WHERE t.fk_pays = p.rowid AND p.code = ' " . $code_pays . " ' " ;
$sql .= " AND t.active = 1 " ;
$sql .= " ORDER BY t.taux ASC, t.recuperableonly ASC " ;
$resql = $this -> db -> query ( $sql );
if ( $resql )
2006-02-09 18:36:09 +01:00
{
2006-12-09 19:09:02 +01:00
$num = $this -> db -> num_rows ( $resql );
for ( $i = 0 ; $i < $num ; $i ++ )
2006-02-09 18:36:09 +01:00
{
2006-12-09 19:09:02 +01:00
$obj = $this -> db -> fetch_object ( $resql );
$txtva [ $i ] = $obj -> taux ;
$libtva [ $i ] = $obj -> taux . '%' . ( $obj -> recuperableonly ? ' *' : '' );
2006-02-09 18:36:09 +01:00
}
}
2006-12-09 19:09:02 +01:00
// D<> finition du taux <20> pr<70> s<EFBFBD> lectionner
if ( $defaulttx == '' ) $defaulttx = get_default_tva ( $societe_vendeuse , $societe_acheteuse , $taux_produit );
// Si taux par defaut n'a pu etre trouv<75> , on prend dernier.
// Comme ils sont tri<72> s par ordre croissant, dernier = plus <20> lev<65> = taux courant
if ( $defaulttx == '' ) $defaulttx = $txtva [ sizeof ( $txtva ) - 1 ];
$nbdetaux = sizeof ( $txtva );
for ( $i = 0 ; $i < $nbdetaux ; $i ++ )
{
$this -> tva_taux_value [ $i ] = $txtva [ $i ];
$this -> tva_taux_libelle [ $i ] = $libtva [ $i ];
}
2006-02-09 18:36:09 +01:00
}
/**
2006-03-14 01:54:42 +01:00
* \brief Affiche zone de selection de date
* Liste deroulante pour les jours , mois , annee et eventuellement heurs et minutes
* Les champs sont pr<EFBFBD> s<EFBFBD> lectionn<EFBFBD> es avec :
* - La date set_time ( timestamps ou date au format YYYY - MM - DD ou YYYY - MM - DD HH : MM )
* - La date du jour si set_time vaut ''
2006-09-10 15:46:25 +02:00
* - Aucune date ( champs vides ) si set_time vaut - 1 ( dans ce cas empty doit valoir 1 )
2006-03-18 00:27:30 +01:00
* \param set_time Date de pr<EFBFBD> - s<EFBFBD> lection
* \param prefix Prefix pour nom champ
2006-09-10 15:46:25 +02:00
* \param h 1 = Affiche aussi les heures
* \param m 1 = Affiche aussi les minutes
2006-03-18 00:27:30 +01:00
* \param empty 0 = Champ obligatoire , 1 = Permet une saisie vide
* \param form_name Nom du formulaire de provenance . Utilis<EFBFBD> pour les dates en popup style andre .
2007-01-05 21:42:44 +01:00
* \param d 1 = Affiche aussi les jours , mois , annees
2006-02-09 18:36:09 +01:00
*/
2007-01-05 21:42:44 +01:00
function select_date ( $set_time = '' , $prefix = 're' , $h = 0 , $m = 0 , $empty = 0 , $form_name = " " , $d = 1 )
2006-02-09 18:36:09 +01:00
{
global $conf , $langs ;
2006-03-18 00:27:30 +01:00
2006-03-02 09:39:40 +01:00
if ( $prefix == '' ) $prefix = 're' ;
if ( $h == '' ) $h = 0 ;
if ( $m == '' ) $m = 0 ;
if ( $empty == '' ) $empty = 0 ;
2006-03-18 00:27:30 +01:00
2006-02-09 18:36:09 +01:00
if ( ! $set_time && $empty == 0 ) $set_time = time ();
// Analyse de la date de pr<70> selection
2006-03-18 00:27:30 +01:00
if ( eregi ( '^([0-9]+)\-([0-9]+)\-([0-9]+)\s?([0-9]+)?:?([0-9]+)?' , $set_time , $reg ))
{
2006-02-09 18:36:09 +01:00
// 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 ];
}
2006-03-18 00:27:30 +01:00
elseif ( $set_time > 0 )
{
2006-02-09 18:36:09 +01:00
// Date est un timestamps
$syear = date ( " Y " , $set_time );
$smonth = date ( " n " , $set_time );
$sday = date ( " d " , $set_time );
$shour = date ( " H " , $set_time );
$smin = date ( " i " , $set_time );
}
2006-03-18 00:27:30 +01:00
else
{
// Date est vide ou vaut -1
2006-02-09 18:36:09 +01:00
$syear = '' ;
$smonth = '' ;
$sday = '' ;
$shour = '' ;
$smin = '' ;
}
2007-01-05 21:42:44 +01:00
if ( $d )
2006-03-01 11:49:10 +01:00
{
2007-01-05 21:42:44 +01:00
/*
* Affiche date en popup
*/
if ( $conf -> use_javascript && $conf -> use_popup_calendar )
2007-06-04 17:44:49 +02:00
{
//print "e".$set_time." t ".$conf->format_date_short;
if ( $set_time > 0 )
{
$formated_date = dolibarr_print_date ( $set_time , $conf -> format_date_short );
2007-01-05 21:42:44 +01:00
}
// Calendrier popup version eldy
if ( " $conf->use_popup_calendar " == " eldy " ) // Laisser conf->use_popup_calendar entre quote
{
2007-03-20 13:12:51 +01:00
// Zone de saisie manuelle de la date
2007-04-04 21:49:57 +02:00
print '<input id="' . $prefix . '" name="' . $prefix . '" type="text" size="10" maxlength="11" value="' . $formated_date . '"' ;
2007-03-20 13:12:51 +01:00
print ' onChange="dpChangeDay(\'' . $prefix . '\',\'' . $conf -> format_date_short_java . '\')"' ;
print '>' ;
2007-01-05 21:42:44 +01:00
// Icone calendrier
2007-03-20 13:12:51 +01:00
print '<button id="' . $prefix . 'Button" type="button" class="dpInvisibleButtons"' ;
$base = DOL_URL_ROOT . '/lib/' ;
print ' onClick="showDP(\'' . $base . '\',\'' . $prefix . '\',\'' . $conf -> format_date_short_java . '\');">' . img_object ( $langs -> trans ( " SelectDate " ), 'calendar' ) . '</button>' ;
print '<input type="hidden" id="' . $prefix . 'day" name="' . $prefix . 'day" value="' . $sday . '">' . " \n " ;
print '<input type="hidden" id="' . $prefix . 'month" name="' . $prefix . 'month" value="' . $smonth . '">' . " \n " ;
print '<input type="hidden" id="' . $prefix . 'year" name="' . $prefix . 'year" value="' . $syear . '">' . " \n " ;
2006-03-12 00:03:05 +01:00
}
else
2007-01-05 21:42:44 +01:00
{
// Calendrier popup version defaut
if ( $langs -> defaultlang != " " )
{
print '<script language="javascript" type="text/javascript">' ;
print 'selectedLanguage = "' . substr ( $langs -> defaultlang , 0 , 2 ) . '"' ;
print '</script>' ;
}
print '<script language="javascript" type="text/javascript" src="' . DOL_URL_ROOT . '/lib/lib_calendar.js"></script>' ;
print '<input id="' . $prefix . '" type="text" name="' . $prefix . '" size="10" value="' . $formated_date . '"' ;
print ' onChange="dpChangeDay(\'' . $prefix . '\',\'' . $conf -> format_date_short_java . '\')"' ;
2007-03-20 13:12:51 +01:00
print '> ' ;
2007-01-05 21:42:44 +01:00
print '<input type="hidden" id="' . $prefix . 'day" name="' . $prefix . 'day" value="' . $sday . '">' . " \n " ;
2007-03-20 13:12:51 +01:00
print '<input type="hidden" id="' . $prefix . 'month" name="' . $prefix . 'month" value="' . $smonth . '">' . " \n " ;
print '<input type="hidden" id="' . $prefix . 'year" name="' . $prefix . 'year" value="' . $syear . '">' . " \n " ;
2007-01-05 21:42:44 +01:00
if ( $form_name == " " )
print '<A HREF="javascript:showCalendar(document.forms[3].' . $prefix . ')">' . img_cal () . '</a>' ;
else
print '<A HREF="javascript:showCalendar(document.forms[\'' . $form_name . '\'].' . $prefix . ')">' . img_cal () . '</a>' ;
}
2007-03-20 13:12:51 +01:00
}
2007-01-05 21:42:44 +01:00
/*
* Affiche date en select
*/
if ( ! $conf -> use_javascript || ! $conf -> use_popup_calendar )
{
/*
if ( $set_time == - 1 )
{
$sday = 0 ;
$smonth = 0 ;
$syear = 0 ;
$shour = 0 ;
$smin = 0 ;
}
*/
// Jour
print '<select class="flat" name="' . $prefix . 'day">' ;
if ( $empty || $set_time == - 1 )
{
print '<option value="0" selected="true"> </option>' ;
}
for ( $day = 1 ; $day <= 31 ; $day ++ )
{
if ( $day == $sday )
{
print " <option value= \" $day\ " selected = \ " true \" > $day " ;
}
else
{
print " <option value= \" $day\ " > $day " ;
}
print " </option> " ;
}
print " </select> " ;
print '<select class="flat" name="' . $prefix . 'month">' ;
if ( $empty || $set_time == - 1 )
{
print '<option value="0" selected="true"> </option>' ;
}
// Mois
for ( $month = 1 ; $month <= 12 ; $month ++ )
{
print '<option value="' . $month . '"' . ( $month == $smonth ? ' selected="true"' : '' ) . '>' ;
print dolibarr_print_date ( mktime ( 1 , 1 , 1 , $month , 1 , 2000 ), " %b " );
print " </option> " ;
}
print " </select> " ;
// Ann<6E> e
if ( $empty || $set_time == - 1 )
{
2007-02-04 21:01:55 +01:00
print '<input class="flat" type="text" size="2" maxlength="4" name="' . $prefix . 'year" value="' . $syear . '">' ;
2007-01-05 21:42:44 +01:00
}
else
{
print '<select class="flat" name="' . $prefix . 'year">' ;
for ( $year = $syear - 5 ; $year < $syear + 10 ; $year ++ )
{
if ( $year == $syear )
{
print " <option value= \" $year\ " selected = \ " true \" > $year " ;
}
else
{
print " <option value= \" $year\ " > $year " ;
}
print " </option> " ;
}
print " </select> \n " ;
}
}
}
if ( $d && $h ) print ' ' ;
2006-02-09 18:36:09 +01:00
if ( $h )
{
2007-01-05 21:42:44 +01:00
/*
* Affiche heure en select
*/
2006-02-09 18:36:09 +01:00
print '<select class="flat" name="' . $prefix . 'hour">' ;
2006-09-10 15:46:25 +02:00
if ( $empty ) print '<option value="-1"> </option>' ;
for ( $hour = 0 ; $hour < 24 ; $hour ++ )
2006-02-09 18:36:09 +01:00
{
if ( strlen ( $hour ) < 2 )
{
$hour = " 0 " . $hour ;
}
if ( $hour == $shour )
{
2006-09-10 15:46:25 +02:00
print " <option value= \" $hour\ " selected = \ " true \" > $hour </option> " ;
2006-02-09 18:36:09 +01:00
}
else
{
2006-09-10 15:46:25 +02:00
print " <option value= \" $hour\ " > $hour </ option > " ;
2006-02-09 18:36:09 +01:00
}
}
2006-09-10 15:46:25 +02:00
print " </select> " ;
print " H \n " ;
}
if ( $m )
{
2007-01-05 21:42:44 +01:00
/*
* Affiche min en select
*/
2006-09-10 15:46:25 +02:00
print '<select class="flat" name="' . $prefix . 'min">' ;
if ( $empty ) print '<option value="-1"> </option>' ;
for ( $min = 0 ; $min < 60 ; $min ++ )
2006-02-09 18:36:09 +01:00
{
2006-09-10 15:46:25 +02:00
if ( strlen ( $min ) < 2 )
2006-02-09 18:36:09 +01:00
{
2006-09-10 15:46:25 +02:00
$min = " 0 " . $min ;
}
if ( $min == $smin )
{
print " <option value= \" $min\ " selected = \ " true \" > $min </option> " ;
}
else
{
print " <option value= \" $min\ " > $min </ option > " ;
2006-02-09 18:36:09 +01:00
}
}
2006-09-10 15:46:25 +02:00
print " </select> " ;
print " M \n " ;
2006-02-09 18:36:09 +01:00
}
}
2006-09-10 15:46:25 +02:00
/**
\brief Fonction servant a afficher une dur<EFBFBD> e dans une liste d<EFBFBD> roulante
\param prefix prefix
*/
function select_duree ( $prefix )
{
print '<select class="flat" name="' . $prefix . 'hour">' ;
print " <option value= \" 0 \" >0</option> " ;
for ( $hour = 1 ; $hour < 24 ; $hour ++ )
{
print " <option value= \" $hour\ " " ;
if ( $hour == 1 ) print " selected= \" true \" " ;
print " > $hour </option> " ;
}
print " </select> " ;
print " H " ;
print '<select class="flat" name="' . $prefix . 'min">' ;
for ( $min = 0 ; $min < 55 ; $min = $min + 5 )
{
print " <option value= \" $min\ " > $min </ option > " ;
}
print " </select> " ;
print " M " ;
}
2006-02-09 18:36:09 +01:00
/**
\brief Affiche un select <EFBFBD> partir d ' un tableau
\param htmlname Nom de la zone select
\param array Tableau de key + valeur
\param id Key pr<EFBFBD> - s<EFBFBD> lectionn<EFBFBD> e
2006-07-14 13:31:57 +02:00
\param show_empty 1 si il faut ajouter une valeur vide dans la liste , 0 sinon
2006-02-09 18:36:09 +01:00
\param key_in_label 1 pour afficher la key dans la valeur " [key] value "
\param value_as_key 1 pour utiliser la valeur comme cl<EFBFBD>
*/
2006-06-05 20:26:46 +02:00
function select_array ( $htmlname , $array , $id = '' , $show_empty = 0 , $key_in_label = 0 , $value_as_key = 0 , $use_java = 0 , $fonction = '' )
2006-02-09 18:36:09 +01:00
{
2006-06-05 20:26:46 +02:00
if ( $use_java == 1 && $fonction != '' )
{
print '<select class="flat" name="' . $htmlname . '" ' . $fonction . '>' ;
}
else
{
print '<select class="flat" name="' . $htmlname . '">' ;
}
2006-02-09 18:36:09 +01:00
2006-05-06 18:32:47 +02:00
if ( $show_empty )
2006-02-09 18:36:09 +01:00
{
2006-05-06 18:32:47 +02:00
print '<option value="-1"' . ( $id ==- 1 ? ' selected="true"' : '' ) . '> </option>' . " \n " ;
2006-02-09 18:36:09 +01:00
}
while ( list ( $key , $value ) = each ( $array ))
{
2006-02-25 01:15:58 +01:00
print '<option value="' . ( $value_as_key ? $value : $key ) . '"' ;
2006-02-09 18:36:09 +01:00
// Si il faut pr<70> s<EFBFBD> lectionner une valeur
if ( $id && $id == $key )
{
2006-02-25 01:15:58 +01:00
print ' selected="true"' ;
2006-02-09 18:36:09 +01:00
}
if ( $key_in_label )
{
print '>' . $key . ' - ' . $value . " </option> \n " ;
}
else
{
2006-02-25 01:15:58 +01:00
if ( $value == '' || $value == '-' ) { $value = ' ' ; }
2006-02-09 18:36:09 +01:00
print " > " . $value . " </option> \n " ;
}
}
print " </select> \n " ;
}
/**
* \brief Renvoie la cha<EFBFBD> ne de caract<EFBFBD> re d<EFBFBD> crivant l ' erreur
*/
function error ()
{
2006-11-20 02:13:13 +01:00
return $this -> error ;
2006-02-09 18:36:09 +01:00
}
/**
* \brief Selection de oui / non en chaine ( renvoie yes / no )
* \param name Nom du select
* \param value Valeur pr<EFBFBD> s<EFBFBD> lectionn<EFBFBD> e
* \param option 0 retourne yes / no , 1 retourne 1 / 0
*/
function selectyesno ( $name , $value = '' , $option = 0 )
{
global $langs ;
$yes = " yes " ; $no = " no " ;
if ( $option )
{
$yes = " 1 " ;
$no = " 0 " ;
}
2007-04-30 01:50:43 +02:00
$resultyesno = '<select class="flat" name="' . $name . '">' . " \n " ;
2006-02-09 18:36:09 +01:00
if (( " $value " == 'yes' ) || ( $value == 1 ))
{
2007-04-30 01:50:43 +02:00
$resultyesno .= '<option value="' . $yes . '" selected="true">' . $langs -> trans ( " yes " ) . '</option>' . " \n " ;
$resultyesno .= '<option value="' . $no . '">' . $langs -> trans ( " no " ) . '</option>' . " \n " ;
2006-02-09 18:36:09 +01:00
}
else
{
2007-04-30 01:50:43 +02:00
$resultyesno .= '<option value="' . $yes . '">' . $langs -> trans ( " yes " ) . '</option>' . " \n " ;
$resultyesno .= '<option value="' . $no . '" selected="true">' . $langs -> trans ( " no " ) . '</option>' . " \n " ;
2006-02-09 18:36:09 +01:00
}
2007-04-30 01:50:43 +02:00
$resultyesno .= '</select>' . " \n " ;
return $resultyesno ;
2006-02-09 18:36:09 +01:00
}
/**
* \brief Checkbox
*
*/
function checkbox ( $name , $checked = 0 , $value = 1 )
{
if ( $checked == 1 ){
print " <input type= \" checkbox \" name= \" $name\ " value = \ " $value\ " checked /> \n " ;
} else {
print " <input type= \" checkbox \" name= \" $name\ " value = \ " $value\ " /> \n " ;
}
}
/**
* \brief Affiche la cartouche g<EFBFBD> n<EFBFBD> rique d ' un rapport
* \param nom Valeur pour nom du rapport
* \param variante Lien optionnel de variante du rapport
* \param period Periode du reporting
* \param periodlink Lien pour changer de p<EFBFBD> riode
* \param description Description
* \param builddate Date g<EFBFBD> n<EFBFBD> ration
* \param exportlink Lien pour export
*/
function report_header ( $nom , $variante = '' , $period , $periodlink , $description , $builddate , $exportlink )
{
global $langs ;
print " \n \n <!-- debut cartouche rapport --> \n " ;
$h = 0 ;
$head [ $h ][ 0 ] = $_SERVER [ " PHP_SELF " ];
$head [ $h ][ 1 ] = $langs -> trans ( " Report " );
dolibarr_fiche_head ( $head , $hselected , $societe -> nom );
print '<table width="100%" class="border">' ;
// Ligne de titre
print '<tr>' ;
2006-12-23 16:36:46 +01:00
print '<td valign="top" width="110">' . $langs -> trans ( " ReportName " ) . '</td>' ;
2006-02-09 18:36:09 +01:00
if ( ! $variante ) print '<td colspan="3">' ;
else print '<td>' ;
print $nom ;
if ( $variante ) print '</td><td colspan="2">' . $variante ;
print '</td>' ;
print '</tr>' ;
// Ligne de la periode d'analyse du rapport
print '<tr>' ;
print '<td>' . $langs -> trans ( " ReportPeriod " ) . '</td>' ;
if ( ! $periodlink ) print '<td colspan="3">' ;
else print '<td>' ;
print $period ;
if ( $periodlink ) print '</td><td colspan="2">' . $periodlink ;
print '</td>' ;
print '</tr>' ;
// Ligne de description
print '<tr>' ;
print '<td valign="top">' . $langs -> trans ( " ReportDescription " ) . '</td>' ;
print '<td colspan="3">' . $description . '</td>' ;
print '</tr>' ;
// Ligne d'export
print '<tr>' ;
print '<td>' . $langs -> trans ( " GeneratedOn " ) . '</td>' ;
if ( ! $exportlink ) print '<td colspan="3">' ;
else print '<td>' ;
print dolibarr_print_date ( $builddate );
if ( $exportlink ) print '</td><td>' . $langs -> trans ( " Export " ) . '</td><td>' . $exportlink ;
print '</td></tr>' ;
print '</table>' ;
print '</div>' ;
print " \n <!-- fin cartouche rapport --> \n \n " ;
}
/**
* \brief Affiche la cartouche de la liste des documents d ' une propale , facture ...
* \param modulepart propal = propal , facture = facture , ...
2006-08-20 21:15:47 +02:00
* \param filename Sous rep <EFBFBD> scanner ( vide si filedir deja complet )
2006-02-09 18:36:09 +01:00
* \param filedir Repertoire <EFBFBD> scanner
* \param urlsource Url page origine
* \param genallowed G<EFBFBD> n<EFBFBD> ration autoris<EFBFBD> e ( 1 / 0 ou array des formats )
* \param delallowed Suppression autoris<EFBFBD> e ( 1 / 0 )
* \param modelselected Modele <EFBFBD> pr<EFBFBD> s<EFBFBD> lectionner par d<EFBFBD> faut
2007-07-13 18:40:57 +02:00
* \param modelliste Tableau des modeles possibles
* \param forcenomultilang N ' affiche pas option langue meme si MAIN_MULTILANGS d<EFBFBD> fini
* \param iconPDF N 'affiche que l' icone PDF avec le lien ( 1 / 0 )
2006-02-09 18:36:09 +01:00
* \remarks Le fichier de facture d<EFBFBD> taill<EFBFBD> e est de la forme
* REFFACTURE - XXXXXX - detail . pdf ou XXXXX est une forme diverse
2006-05-01 01:59:46 +02:00
* \return int < 0 si ko , nbre de fichiers affich<EFBFBD> s si ok
2006-02-09 18:36:09 +01:00
*/
2007-07-13 17:45:51 +02:00
function show_documents ( $modulepart , $filename , $filedir , $urlsource , $genallowed , $delallowed = 0 , $modelselected = '' , $modelliste = array (), $forcenomultilang = 0 , $iconPDF = 0 )
2006-02-09 18:36:09 +01:00
{
// filedir = conf->...dir_ouput."/".get_exdir(id)
2006-03-22 11:30:25 +01:00
global $langs , $bc , $conf ;
2006-02-09 18:36:09 +01:00
$var = true ;
2007-07-13 18:40:57 +02:00
if ( $iconPDF == 1 )
{
$genallowed = '' ;
$delallowed = 0 ;
$modelselected = '' ;
$modelliste = '' ;
$forcenomultilang = 0 ;
}
2006-02-09 18:36:09 +01:00
$filename = sanitize_string ( $filename );
$headershown = 0 ;
2006-05-01 01:59:46 +02:00
$i = 0 ;
2006-02-09 18:36:09 +01:00
// Affiche en-tete tableau
if ( $genallowed )
{
2007-07-13 17:45:51 +02:00
$modellist = array ();
if ( $modulepart == 'propal' )
{
if ( is_array ( $genallowed )) $modellist = $genallowed ;
else
{
include_once ( DOL_DOCUMENT_ROOT . '/includes/modules/propale/modules_propale.php' );
$model = new ModelePDFPropales ();
$modellist = $model -> liste_modeles ( $this -> db );
2006-02-09 18:36:09 +01:00
}
2007-07-13 17:45:51 +02:00
}
else if ( $modulepart == 'commande' )
{
if ( is_array ( $genallowed )) $modellist = $genallowed ;
else
2006-02-09 18:36:09 +01:00
{
2007-07-13 17:45:51 +02:00
include_once ( DOL_DOCUMENT_ROOT . '/includes/modules/commande/modules_commande.php' );
$model = new ModelePDFCommandes ();
$modellist = $model -> liste_modeles ( $this -> db );
2006-04-29 03:28:16 +02:00
}
2007-07-13 17:45:51 +02:00
}
elseif ( $modulepart == 'expedition' )
{
if ( is_array ( $genallowed )) $modellist = $genallowed ;
else
2006-05-29 17:44:35 +02:00
{
2007-07-13 17:45:51 +02:00
include_once ( DOL_DOCUMENT_ROOT . '/expedition/mods/pdf/ModelePdfExpedition.class.php' );
$model = new ModelePDFExpedition ();
$modellist = $model -> liste_modeles ( $this -> db );
2006-05-29 17:44:35 +02:00
}
2007-07-13 17:45:51 +02:00
}
elseif ( $modulepart == 'livraison' )
{
if ( is_array ( $genallowed )) $modellist = $genallowed ;
else
2006-04-29 03:28:16 +02:00
{
2007-07-13 17:45:51 +02:00
include_once ( DOL_DOCUMENT_ROOT . '/livraison/mods/modules_livraison.php' );
$model = new ModelePDFDeliveryOrder ();
$modellist = $model -> liste_modeles ( $this -> db );
2006-02-09 18:36:09 +01:00
}
2007-07-13 17:45:51 +02:00
}
else if ( $modulepart == 'ficheinter' )
{
if ( is_array ( $genallowed )) $modellist = $genallowed ;
else
2006-02-09 18:36:09 +01:00
{
2007-07-13 17:45:51 +02:00
include_once ( DOL_DOCUMENT_ROOT . '/includes/modules/fichinter/modules_fichinter.php' );
$model = new ModelePDFFicheinter ();
$modellist = $model -> liste_modeles ( $this -> db );
2006-02-09 18:36:09 +01:00
}
2007-07-13 17:45:51 +02:00
}
elseif ( $modulepart == 'facture' )
{
if ( is_array ( $genallowed )) $modellist = $genallowed ;
else
2006-02-09 18:36:09 +01:00
{
2007-07-13 17:45:51 +02:00
include_once ( DOL_DOCUMENT_ROOT . '/includes/modules/facture/modules_facture.php' );
$model = new ModelePDFFactures ();
$modellist = $model -> liste_modeles ( $this -> db );
2006-02-09 18:36:09 +01:00
}
2007-07-13 17:45:51 +02:00
}
elseif ( $modulepart == 'export' )
{
if ( is_array ( $genallowed )) $modellist = $genallowed ;
else
2006-02-09 18:36:09 +01:00
{
2007-07-13 17:45:51 +02:00
include_once ( DOL_DOCUMENT_ROOT . '/includes/modules/export/modules_export.php' );
$model = new ModeleExports ();
$modellist = $model -> liste_modeles ( $this -> db );
2006-02-09 18:36:09 +01:00
}
2007-07-13 17:45:51 +02:00
}
else if ( $modulepart == 'commande_fournisseur' )
{
if ( is_array ( $genallowed )) $modellist = $genallowed ;
else
{
include_once ( DOL_DOCUMENT_ROOT . '/fourn/commande/modules/modules_commandefournisseur.php' );
$model = new ModelePDFSuppliersOrders ();
$modellist = $model -> liste_modeles ( $this -> db );
}
}
else if ( $modulepart == 'facture_fournisseur' )
{
if ( is_array ( $genallowed )) $modellist = $genallowed ;
else
{
include_once ( DOL_DOCUMENT_ROOT . '/fourn/facture/modules/modules_facturefournisseur.php' );
$model = new ModelePDFFacturesSuppliers ();
$modellist = $model -> liste_modeles ( $this -> db );
}
}
else if ( $modulepart == 'remisecheque' )
{
if ( is_array ( $genallowed )) $modellist = $genallowed ;
else
{
// ??
}
}
else
{
dolibarr_print_error ( $this -> db , 'Bad value for modulepart' );
return - 1 ;
}
$headershown = 1 ;
2006-12-21 22:52:45 +01:00
2007-07-13 17:45:51 +02:00
print '<form action="' . $urlsource . '#builddoc" method="post">' ;
print '<input type="hidden" name="action" value="builddoc">' ;
print_titre ( $langs -> trans ( " Documents " ));
print '<table class="border" width="100%">' ;
print '<tr ' . $bc [ $var ] . '>' ;
print '<td>' . $langs -> trans ( 'Model' ) . '</td>' ;
print '<td align="center">' ;
$this -> select_array ( 'model' , $modellist , $modelselected , 0 , 0 , 1 );
$texte = $langs -> trans ( 'Generate' );
print '</td>' ;
print '<td align="center">' ;
if ( $conf -> global -> MAIN_MULTILANGS && ! $forcenomultilang )
{
$this -> select_lang ( $langs -> getDefaultLang ());
}
else
{
print ' ' ;
}
print '</td>' ;
print '<td align="center" colspan="' . ( $delallowed ? '2' : '1' ) . '">' ;
print '<input class="button" type="submit" value="' . $texte . '">' ;
print '</td></tr>' ;
2006-02-09 18:36:09 +01:00
}
2006-06-24 15:38:00 +02:00
// Recupe liste des fichiers
2007-07-14 17:48:42 +02:00
$png = '' ;
$filter = '' ;
if ( $iconPDF == 1 )
{
$png = '|\.png$' ;
2007-07-14 17:53:03 +02:00
$filter = $filename . '.pdf' ;
2007-07-14 17:48:42 +02:00
}
$file_list = dolibarr_dir_list ( $filedir , 'files' , 0 , $filter , '\.meta$' . $png , 'date' , SORT_DESC );
2006-06-24 15:38:00 +02:00
// Affiche en-tete tableau si non deja affich<63>
2007-07-13 17:45:51 +02:00
if ( sizeof ( $file_list ) && ! $headershown && ! $iconPDF )
2006-06-24 15:38:00 +02:00
{
$headershown = 1 ;
2007-07-13 17:45:51 +02:00
print_titre ( $langs -> trans ( " Documents " ));
print '<table class="border" width="100%">' ;
2006-06-24 15:38:00 +02:00
}
// Boucle sur chaque ligne trouv<75> e
foreach ( $file_list as $i => $file )
{
2007-07-13 17:45:51 +02:00
// D<> fini chemin relatif par rapport au module pour lien download
$relativepath = $file [ " name " ]; // Cas general
if ( $filename ) $relativepath = $filename . " / " . $file [ " name " ]; // Cas prpal, facture...
// Autre cas
if ( $modulepart == 'don' ) { $relativepath = get_exdir ( $filename , 2 ) . $file [ " name " ]; }
if ( $modulepart == 'export' ) { $relativepath = $file [ " name " ]; }
// D<> fini le type MIME du document
if ( eregi ( '\.([^\.]+)$' , $file [ " name " ], $reg )) $extension = $reg [ 1 ];
$mimetype = strtoupper ( $extension );
if ( $extension == 'pdf' ) $mimetype = 'PDF' ;
if ( $extension == 'html' ) $mimetype = 'HTML' ;
if ( eregi ( '\-detail\.pdf' , $file [ " name " ])) $mimetype = 'PDF D<> taill<6C> ' ;
if ( ! $iconPDF ) print " <tr $bc[$var] > " ;
// Affiche colonne type MIME
if ( ! $iconPDF ) print '<td nowrap>' . $mimetype . '</td>' ;
// Affiche nom fichier avec lien download
if ( ! $iconPDF ) print '<td>' ;
print '<a href="' . DOL_URL_ROOT . '/document.php?modulepart=' . $modulepart . '&file=' . urlencode ( $relativepath ) . '">' ;
if ( ! $iconPDF )
{
2007-07-13 18:32:34 +02:00
print $file [ " name " ];
2007-07-13 17:45:51 +02:00
}
else
{
print img_pdf ( $file [ " name " ], 2 );
}
print '</a>' ;
if ( ! $iconPDF ) print '</td>' ;
// Affiche taille fichier
if ( ! $iconPDF ) print '<td align="right">' . filesize ( $filedir . " / " . $file [ " name " ]) . ' bytes</td>' ;
// Affiche date fichier
if ( ! $iconPDF ) print '<td align="right">' . dolibarr_print_date ( filemtime ( $filedir . " / " . $file [ " name " ]), 'dayhour' ) . '</td>' ;
2006-05-06 23:09:26 +02:00
if ( $delallowed )
{
2006-12-23 15:49:36 +01:00
print '<td><a href="' . DOL_URL_ROOT . '/document.php?action=remove_file&modulepart=' . $modulepart . '&file=' . urlencode ( $relativepath ) . '&urlsource=' . urlencode ( $urlsource ) . '">' . img_delete () . '</a></td>' ;
2006-05-06 23:09:26 +02:00
}
2006-03-22 00:47:01 +01:00
2007-07-13 17:45:51 +02:00
if ( ! $iconPDF ) print '</tr>' ;
2006-02-09 18:36:09 +01:00
2007-07-13 17:45:51 +02:00
$i ++ ;
}
2006-06-24 15:38:00 +02:00
if ( $headershown )
{
// Affiche pied du tableau
print " </table> \n " ;
if ( $genallowed )
{
print '</form>' ;
}
}
2007-07-24 01:59:40 +02:00
return ( $i ? $i : $headershown );
2006-06-24 15:38:00 +02:00
}
2006-05-06 23:09:26 +02:00
2006-11-19 05:56:10 +01:00
2007-04-26 03:00:27 +02:00
function show_ldap_content ( $result , $level , $count , $var , $hide = 0 )
2006-11-19 05:56:10 +01:00
{
2006-12-20 21:53:33 +01:00
global $bc , $conf ;
2006-11-19 05:56:10 +01:00
$count ++ ;
2006-11-26 08:00:14 +01:00
if ( $count > 1000 ) return - 1 ; // To avoid infinite loop
if ( ! is_array ( $result )) return - 1 ;
2006-12-20 23:34:13 +01:00
2006-11-19 05:56:10 +01:00
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 ))
{
2007-04-26 03:00:27 +02:00
$hide = 0 ;
2006-11-19 05:56:10 +01:00
if ( ! is_numeric ( $key ))
{
$var =! $var ;
print '<tr ' . $bc [ $var ] . '><td>' ;
print $key ;
print '</td><td>' ;
2007-04-26 03:00:27 +02:00
if ( strtolower ( $key ) == 'userpassword' ) $hide = 1 ;
2006-11-19 05:56:10 +01:00
}
2007-04-26 03:00:27 +02:00
$this -> show_ldap_content ( $val , $level + 1 , $count , $var , $hide );
2006-11-19 05:56:10 +01:00
}
else
{
2007-04-26 03:00:27 +02:00
if ( $hide ) print eregi_replace ( '.' , '*' , utf8_decode ( " $val " ));
else print utf8_decode ( $val );
2006-11-19 05:56:10 +01:00
print '</td></tr>' ;
}
}
return 1 ;
}
2007-04-29 23:03:45 +02:00
/**
2007-03-23 18:58:06 +01:00
* \brief Retourne la liste des mod<EFBFBD> les d ' export
* \param selected Id mod<EFBFBD> le pr<EFBFBD> s<EFBFBD> lectionn<EFBFBD>
* \param htmlname Nom de la zone select
* \param type Type des mod<EFBFBD> les recherch<EFBFBD> s
* \param useempty Affiche valeur vide dans liste
*/
function select_export_model ( $selected = '' , $htmlname = 'exportmodelid' , $type = '' , $useempty = 0 )
{
2007-03-23 19:14:08 +01:00
$sql = " SELECT rowid, label " ;
2007-03-23 18:58:06 +01:00
$sql .= " FROM " . MAIN_DB_PREFIX . " export_model " ;
$sql .= " WHERE type = ' " . $type . " ' " ;
$sql .= " ORDER BY rowid " ;
$result = $this -> db -> query ( $sql );
if ( $result )
{
print '<select class="flat" name="' . $htmlname . '">' ;
if ( $useempty )
{
print '<option value="-1"> </option>' ;
}
$num = $this -> db -> num_rows ( $result );
$i = 0 ;
while ( $i < $num )
{
$obj = $this -> db -> fetch_object ( $result );
if ( $selected == $obj -> rowid )
{
print '<option value="' . $obj -> rowid . '" selected="true">' ;
}
else
{
print '<option value="' . $obj -> rowid . '">' ;
}
2007-03-23 19:14:08 +01:00
print $obj -> label ;
2007-03-23 18:58:06 +01:00
print '</option>' ;
$i ++ ;
}
print " </select> " ;
}
else {
dolibarr_print_error ( $this -> db );
}
}
2007-04-29 23:03:45 +02:00
/**
* \brief Retourne la liste des mois
* \param selected Id mois pr<EFBFBD> s<EFBFBD> lectionn<EFBFBD>
* \param htmlname Nom de la zone select
* \param useempty Affiche valeur vide dans liste
*/
function select_month ( $selected = '' , $htmlname = 'monthid' , $useempty = 0 )
{
global $langs ;
$langs -> load ( " main " );
$month = array ( 1 => " January " ,
2 => " February " ,
3 => " March " ,
4 => " April " ,
5 => " May " ,
6 => " June " ,
7 => " July " ,
8 => " August " ,
9 => " September " ,
10 => " October " ,
11 => " November " ,
12 => " December "
);
2007-04-30 02:25:20 +02:00
2007-04-30 01:50:43 +02:00
$select_month = '<select class="flat" name="' . $htmlname . '">' ;
2007-04-29 23:03:45 +02:00
if ( $useempty )
{
2007-04-30 01:50:43 +02:00
$select_month .= '<option value="0"> </option>' ;
2007-04-29 23:03:45 +02:00
}
foreach ( $month as $key => $val )
{
2007-04-30 02:25:20 +02:00
if ( $selected == $key )
2007-04-29 23:03:45 +02:00
{
2007-04-30 02:25:20 +02:00
$select_month .= '<option value="' . $key . '" selected="true">' ;
2007-04-29 23:03:45 +02:00
}
else
{
2007-04-30 02:25:20 +02:00
$select_month .= '<option value="' . $key . '">' ;
2007-04-29 23:03:45 +02:00
}
2007-04-30 01:50:43 +02:00
$select_month .= $langs -> trans ( $val );
2007-04-29 23:03:45 +02:00
}
2007-04-30 01:50:43 +02:00
$select_month .= '</select>' ;
return $select_month ;
2007-04-29 23:03:45 +02:00
}
2007-07-29 12:18:31 +02:00
/**
* \brief Affiche tableau avec ref et bouton navigation pour un objet metier
* \param object Objet a afficher
2007-07-29 12:32:07 +02:00
* \param paramid Nom du parametre a utiliser pour nommer id dans liens URL
2007-07-29 13:09:04 +02:00
* \param morehtml Code html supplementaire a afficher avant barre nav
2007-07-29 12:18:31 +02:00
* \return string Portion HTML avec ref + boutons nav
*/
2007-07-29 13:09:04 +02:00
function showrefnav ( $object , $paramid , $morehtml = '' )
2007-07-29 12:18:31 +02:00
{
$ret = '' ;
$object -> load_previous_next_ref ( $object -> next_prev_filter );
2007-07-29 12:32:07 +02:00
$previous_ref = $object -> ref_previous ? '<a href="' . $_SERVER [ " PHP_SELF " ] . '?' . $paramid . '=' . urlencode ( $object -> ref_previous ) . '">' . img_previous () . '</a>' : '' ;
$next_ref = $object -> ref_next ? '<a href="' . $_SERVER [ " PHP_SELF " ] . '?' . $paramid . '=' . urlencode ( $object -> ref_next ) . '">' . img_next () . '</a>' : '' ;
2007-07-29 12:18:31 +02:00
2007-07-29 13:09:04 +02:00
if ( $previous_ref || $next_ref || $morehtml ) {
$ret .= '<table class="nobordernopadding" width="100%"><tr class="nobordernopadding"><td class="nobordernopadding">' ;
}
//$ret.=$object->getNomUrl(0);
$ret .= $object -> ref ;
if ( $morehtml ) {
$ret .= '</td><td class="nobordernopadding" align="right">' . $morehtml ;
}
2007-07-29 12:18:31 +02:00
if ( $previous_ref || $next_ref ) {
$ret .= '</td><td class="nobordernopadding" align="center" width="20">' . $previous_ref . '</td>' ;
2007-07-29 13:09:04 +02:00
$ret .= '<td class="nobordernopadding" align="center" width="20">' . $next_ref ;
}
if ( $previous_ref || $next_ref || $morehtml )
{
$ret .= '</td></tr></table>' ;
2007-07-29 12:18:31 +02:00
}
return $ret ;
}
2006-02-09 18:36:09 +01:00
}
2006-02-09 09:36:22 +01:00
?>