diff --git a/htdocs/html.form.class.php b/htdocs/html.form.class.php
index 384627e61bc..1ff83e98972 100644
--- a/htdocs/html.form.class.php
+++ b/htdocs/html.form.class.php
@@ -26,23 +26,23 @@
*/
/**
- \file htdocs/html.form.class.php
- \brief Fichier de la classe des fonctions prédéfinie de composants html
- \version $Id$
-*/
+ \file htdocs/html.form.class.php
+ \brief Fichier de la classe des fonctions prédéfinie de composants html
+ \version $Id$
+ */
/**
- \class Form
- \brief Classe permettant la génération de composants html
- \remarks Only common components must be here.
-*/
+ \class Form
+ \brief Classe permettant la génération de composants html
+ \remarks Only common components must be here.
+ */
class Form
{
var $db;
var $error;
-
+
// Cache arrays
var $cache_types_paiements=array();
var $cache_conditions_paiements=array();
@@ -50,19 +50,19 @@ class Form
var $tva_taux_value;
var $tva_taux_libelle;
-
- /**
- \brief Constructeur
- \param DB handler d'accès base de donnée
- */
- function Form($DB)
- {
- $this->db = $DB;
-
- return 1;
- }
-
-
+
+ /**
+ \brief Constructeur
+ \param DB handler d'accès base de donnée
+ */
+ function Form($DB)
+ {
+ $this->db = $DB;
+
+ return 1;
+ }
+
+
/**
\brief Affiche un texte+picto avec tooltip sur texte ou sur picto
\param text Texte à afficher
@@ -71,43 +71,43 @@ class Form
\param direction -1=Le picto est avant, 0=pas de picto, 1=le picto est après
\param img Code img du picto
\return string Code html du tooltip (texte+picto)
- */
+ */
function textwithtooltip($text,$htmltext,$tooltipon=1,$direction=0,$img='',$i=1,$width='200',$shiftX='10')
{
global $conf;
-
- if (! $htmltext) return $text;
-
- $paramfortooltiptext ='';
- $paramfortooltippicto ='';
-
- // Sanitize tooltip
- $htmltext=ereg_replace("'","\'",$htmltext);
- $htmltext=ereg_replace("'","\'",$htmltext);
- $htmltext=ereg_replace("\r","",$htmltext);
- $htmltext=ereg_replace(" \n"," ",$htmltext);
- $htmltext=ereg_replace("\n","",$htmltext);
- if ($conf->use_javascript_ajax && $tooltipon == 4)
- {
- $s = '
'."\n";
- $s.= $text;
- $s.= '
'."\n";
- $s.= ''."\n";
- $s.= $htmltext."\n";
- $s.= '
'."\n";
- $s.= ''."\n";
- }
- else
- {
- if ($conf->use_javascript_ajax)
- {
+ $s.= ''."\n";
+ }
+ else
+ {
+ if ($conf->use_javascript_ajax)
+ {
$htmltext=eregi_replace('"',"\'",$htmltext);
- if ($tooltipon==1 || $tooltipon==3)
- {
+ if ($tooltipon==1 || $tooltipon==3)
+ {
$paramfortooltiptext.=' onmouseover="showtip(\''.$htmltext.'\')"';
$paramfortooltiptext.=' onMouseout="hidetip()"';
}
@@ -116,7 +116,7 @@ class Form
$paramfortooltippicto.=' onmouseover="showtip(\''.$htmltext.'\')"';
$paramfortooltippicto.=' onMouseout="hidetip()"';
}
- }
+ }
$s="";
$s.='';
@@ -146,169 +146,169 @@ class Form
}
/**
- \brief Affiche un texte avec picto help qui affiche un tooltip
- \param text Texte à afficher
- \param htmltooltip Contenu html du tooltip
- \param direction 1=Le picto est après, -1=le picto est avant
- \param usehelpcursor 1=Utilise curseur help, 0=Curseur par defaut
- \return string Code html du texte,picto
- */
+ \brief Affiche un texte avec picto help qui affiche un tooltip
+ \param text Texte à afficher
+ \param htmltooltip Contenu html du tooltip
+ \param direction 1=Le picto est aprè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));
- }
-
- /**
- \brief Affiche un texte avec picto warning qui affiche un tooltip
- \param text Texte à afficher
- \param htmltooltip Contenu html du tooltip
- \param direction 1=Le picto est après, -1=le picto est avant
- \return string Code html du texte,picto
- */
- function textwithwarning($text,$htmltext,$direction=1)
- {
- return $this->textwithtooltip($text,$htmltext,2,$direction,img_warning(""));
- }
-
-
- /**
- * \brief Retourne la liste déroulante des départements/province/cantons tout pays confondu ou pour un pays donné.
- * \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ée pour
- * un code donnée mais dans ce cas, le champ pays diffère).
- * Ainsi les liens avec les départements se font sur un département indépendemment de son nom.
- * \param selected code forme juridique a présélectionné
- * \param pays_code 0=liste tous pays confondus, sinon code du pays à afficher
- */
- function select_departement($selected='',$pays_code=0)
- {
- global $conf,$langs,$user;
-
- dolibarr_syslog("Form::select_departement selected=$selected, pays_code=$pays_code",LOG_DEBUG);
-
- $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";
-
- dolibarr_syslog("Form::select_departement sql=".$sql);
- $result=$this->db->query($sql);
- if ($result)
{
+ return $this->textwithtooltip($text,$htmltext,2,$direction,img_help($usehelpcursor,0));
+ }
+
+ /**
+ \brief Affiche un texte avec picto warning qui affiche un tooltip
+ \param text Texte à afficher
+ \param htmltooltip Contenu html du tooltip
+ \param direction 1=Le picto est après, -1=le picto est avant
+ \return string Code html du texte,picto
+ */
+ function textwithwarning($text,$htmltext,$direction=1)
+ {
+ return $this->textwithtooltip($text,$htmltext,2,$direction,img_warning(""));
+ }
+
+
+ /**
+ * \brief Retourne la liste déroulante des départements/province/cantons tout pays confondu ou pour un pays donné.
+ * \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ée pour
+ * un code donnée mais dans ce cas, le champ pays diffère).
+ * Ainsi les liens avec les départements se font sur un département indépendemment de son nom.
+ * \param selected code forme juridique a présélectionné
+ * \param pays_code 0=liste tous pays confondus, sinon code du pays à afficher
+ */
+ function select_departement($selected='',$pays_code=0)
+ {
+ global $conf,$langs,$user;
+
+ dolibarr_syslog("Form::select_departement selected=$selected, pays_code=$pays_code",LOG_DEBUG);
+
+ $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";
+
+ dolibarr_syslog("Form::select_departement sql=".$sql);
+ $result=$this->db->query($sql);
+ if ($result)
+ {
print '';
if ($pays_code) print ' ';
$num = $this->db->num_rows($result);
$i = 0;
dolibarr_syslog("Form::select_departement num=$num",LOG_DEBUG);
if ($num)
- {
- $pays='';
- while ($i < $num)
- {
- $obj = $this->db->fetch_object($result);
- if ($obj->code == '0') // Le code peut etre une chaine
- {
- print ' ';
- }
- else {
- if (! $pays || $pays != $obj->libelle_pays)
- {
- // Affiche la rupture si on est en mode liste multipays
- if (! $pays_code && $obj->code_pays)
- {
- print '----- '.$obj->libelle_pays." ----- \n";
- $pays=$obj->libelle_pays;
- }
- }
-
- if ($selected > 0 && $selected == $obj->rowid)
- {
- print '';
- }
- else
- {
- print ' ';
- }
- // Si traduction existe, on l'utilise, sinon on prend le libellé par défaut
- print $obj->code . ' - ' . ($langs->trans($obj->code)!=$obj->code?$langs->trans($obj->code):($obj->nom!='-'?$obj->nom:''));
- print ' ';
- }
- $i++;
- }
- }
- print ' ';
- if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1);
- }
- else {
- dolibarr_print_error($this->db);
- }
- }
-
-
- /**
- * \brief Retourne la liste déroulante des regions actives dont le pays est actif
- * \remarks La cle de la liste est le code (il peut y avoir plusieurs entrée pour
- * un code donnée mais dans ce cas, le champ pays et lang diffère).
- * Ainsi les liens avec les regions se font sur une region independemment
- * de son nom.
- */
-
- 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";
-
- dolibarr_syslog("Form::select_region sql=".$sql);
- if ($this->db->query($sql))
- {
- print '';
- $num = $this->db->num_rows();
- $i = 0;
- if ($num)
{
- $pays='';
- while ($i < $num)
- {
- $obj = $this->db->fetch_object();
- if ($obj->code == 0) {
- print ' ';
+ $pays='';
+ while ($i < $num)
+ {
+ $obj = $this->db->fetch_object($result);
+ if ($obj->code == '0') // Le code peut etre une chaine
+ {
+ print ' ';
+ }
+ else {
+ if (! $pays || $pays != $obj->libelle_pays)
+ {
+ // Affiche la rupture si on est en mode liste multipays
+ if (! $pays_code && $obj->code_pays)
+ {
+ print '----- '.$obj->libelle_pays." ----- \n";
+ $pays=$obj->libelle_pays;
+ }
+ }
+
+ if ($selected > 0 && $selected == $obj->rowid)
+ {
+ print '';
+ }
+ else
+ {
+ print ' ';
+ }
+ // Si traduction existe, on l'utilise, sinon on prend le libellé par défaut
+ print $obj->code . ' - ' . ($langs->trans($obj->code)!=$obj->code?$langs->trans($obj->code):($obj->nom!='-'?$obj->nom:''));
+ print ' ';
+ }
+ $i++;
+ }
+ }
+ print ' ';
+ if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1);
}
else {
- if ($pays == '' || $pays != $obj->libelle_pays)
- {
- // Affiche la rupture
- print '----- '.$obj->libelle_pays." ----- \n";
- $pays=$obj->libelle_pays;
- }
-
- if ($selected > 0 && $selected == $obj->code)
- {
- print ''.$obj->libelle.' ';
- }
- else
- {
- print ''.$obj->libelle.' ';
- }
+ dolibarr_print_error($this->db);
}
- $i++;
- }
+ }
+
+
+ /**
+ * \brief Retourne la liste déroulante des regions actives dont le pays est actif
+ * \remarks La cle de la liste est le code (il peut y avoir plusieurs entrée pour
+ * un code donnée mais dans ce cas, le champ pays et lang diffère).
+ * Ainsi les liens avec les regions se font sur une region independemment
+ * de son nom.
+ */
+
+ 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";
+
+ dolibarr_syslog("Form::select_region sql=".$sql);
+ if ($this->db->query($sql))
+ {
+ print '';
+ $num = $this->db->num_rows();
+ $i = 0;
+ if ($num)
+ {
+ $pays='';
+ while ($i < $num)
+ {
+ $obj = $this->db->fetch_object();
+ if ($obj->code == 0) {
+ print ' ';
+ }
+ else {
+ if ($pays == '' || $pays != $obj->libelle_pays)
+ {
+ // Affiche la rupture
+ print '----- '.$obj->libelle_pays." ----- \n";
+ $pays=$obj->libelle_pays;
+ }
+
+ if ($selected > 0 && $selected == $obj->code)
+ {
+ print ''.$obj->libelle.' ';
+ }
+ else
+ {
+ print ''.$obj->libelle.' ';
+ }
+ }
+ $i++;
+ }
}
- print ' ';
- }
- else {
- dolibarr_print_error($this->db);
- }
- }
+ print '';
+ }
+ else {
+ dolibarr_print_error($this->db);
+ }
+ }
/**
@@ -320,10 +320,10 @@ class Form
*/
function selectSourcesCommande($selected='',$htmlname='source_id',$addempty=0)
{
- global $conf,$langs;
- print '';
+ global $conf,$langs;
+ print '';
if ($addempty) print ' ';
-
+
// \TODO Aller cherches les sources dans dictionnaire
print ''.$langs->trans('OrderSource0').' ';
print ''.$langs->trans('OrderSource1').' ';
@@ -332,20 +332,20 @@ class Form
print ''.$langs->trans('OrderSource4').' ';
print ''.$langs->trans('OrderSource5').' ';
print ''.$langs->trans('OrderSource6').' ';
-
+
print ' ';
}
-
-
+
+
/**
- *
- *
- */
+ *
+ *
+ */
function select_methodes_commande($selected='',$htmlname='source_id',$addempty=0)
{
- global $conf,$langs;
+ global $conf,$langs;
$listemethodes=array();
-
+
$sql = "SELECT rowid, libelle ";
$sql.= " FROM ".MAIN_DB_PREFIX."c_methode_commande_fournisseur";
$sql.= " WHERE active = 1";
@@ -368,12 +368,12 @@ class Form
dolibarr_print_error($this->db);
return -1;
}
-
+
print $this->select_array($htmlname,$listemethodes,$selected,$addempty);
return 1;
}
-
- /**
+
+ /**
* \brief Retourne la liste déroulante des pays actifs, dans la langue de l'utilisateur
* \param selected Id ou Code pays ou Libelle pays pré-sélectionné
* \param htmlname Nom de la liste deroulante
@@ -412,7 +412,7 @@ class Form
$langs->load("companies");
$obj = $this->db->fetch_object($resql);
$pays_id = $obj->rowid?$obj->rowid:'';
-
+
// On applique un delai d'execution pour le bon fonctionnement
$mode_create = substr($htmloption,-9,6);
$mode_edit = substr($htmloption,-7,4);
@@ -439,7 +439,7 @@ class Form
{
print ' ';
}
-
+
print ajax_autocompleter($pays_id,'pays','/societe/ajaxcountries.php','working');
}
else
@@ -454,7 +454,7 @@ class Form
{
$obj = $this->db->fetch_object($resql);
if ($selected && $selected != '-1' &&
- ($selected == $obj->rowid || $selected == $obj->code || $selected == $obj->libelle) )
+ ($selected == $obj->rowid || $selected == $obj->code || $selected == $obj->libelle) )
{
$foundselected=true;
print '';
@@ -473,67 +473,67 @@ class Form
print ' ';
return 0;
}
- }
- else
- {
- dolibarr_print_error($this->db);
+ }
+ else
+ {
+ dolibarr_print_error($this->db);
return 1;
}
}
- /**
- * \brief Retourne la liste déroulante des langues disponibles
- * \param selected Langue pré-sélectionné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 '';
- if ($showauto)
- {
- print ''.$langs->trans("AutoDetectLang").' ';
- }
- $num = count($langs_available);
- $i = 0;
- if ($num)
- {
- while ($i < $num)
- {
- if ($selected == $langs_available[$i])
- {
- print ''.$langs_available[$i].' ';
- }
- else
- {
- print ''.$langs_available[$i].' ';
- }
- $i++;
- }
- }
- print ' ';
- }
-
-
/**
- * \brief Retourne la liste des types de comptes financiers
- * \param selected Type pré-sélectionné
- * \param htmlname Nom champ formulaire
- */
+ * \brief Retourne la liste déroulante des langues disponibles
+ * \param selected Langue pré-sélectionné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 '';
+ if ($showauto)
+ {
+ print ''.$langs->trans("AutoDetectLang").' ';
+ }
+ $num = count($langs_available);
+ $i = 0;
+ if ($num)
+ {
+ while ($i < $num)
+ {
+ if ($selected == $langs_available[$i])
+ {
+ print ''.$langs_available[$i].' ';
+ }
+ else
+ {
+ print ''.$langs_available[$i].' ';
+ }
+ $i++;
+ }
+ }
+ print ' ';
+ }
+
+
+ /**
+ * \brief Retourne la liste des types de comptes financiers
+ * \param selected Type pré-sélectionné
+ * \param htmlname Nom champ formulaire
+ */
function select_type_comptes_financiers($selected=1,$htmlname='type')
{
global $langs;
$langs->load("banks");
-
+
$type_available=array(0,1,2);
-
+
print '';
$num = count($type_available);
$i = 0;
@@ -554,24 +554,24 @@ class Form
}
print ' ';
}
-
-
+
+
/**
- * \brief Retourne la liste des types de comptes financiers
- * \param selected Type pré-sélectionné
- * \param htmlname Nom champ formulaire
- */
+ * \brief Retourne la liste des types de comptes financiers
+ * \param selected Type pré-sélectionné
+ * \param htmlname Nom champ formulaire
+ */
function select_type_actions($selected='',$htmlname='actioncode')
{
global $langs,$user;
-
+
require_once(DOL_DOCUMENT_ROOT."/cactioncomm.class.php");
$caction=new CActionComm($this->db);
-
+
$arraylist=$caction->liste_array(1,'code');
$arraylist[0]=' ';
asort($arraylist);
-
+
$this->select_array($htmlname, $arraylist, $selected);
if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1);
}
@@ -588,34 +588,34 @@ class Form
$sql = "SELECT c.id, c.libelle as type";
$sql.= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c";
- $sql.= " WHERE active = 1";
+ $sql.= " WHERE active = 1";
$sql.= " ORDER BY c.libelle ASC";
dolibarr_syslog("Form::select_type_socialcontrib sql=".$sql, LOG_DEBUG);
$resql=$db->query($sql);
if ($resql)
- {
- print '';
- $num = $db->num_rows($resql);
- $i = 0;
+ {
+ print '';
+ $num = $db->num_rows($resql);
+ $i = 0;
- while ($i < $num)
- {
- $obj = $db->fetch_object($resql);
- print 'id == $selected) print ' selected="true"';
- print '>'.$obj->type;
- $i++;
- }
- print ' ';
- if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1);
- }
- else
- {
- dolibarr_print_error($db,$db->lasterror());
- }
+ while ($i < $num)
+ {
+ $obj = $db->fetch_object($resql);
+ print 'id == $selected) print ' selected="true"';
+ print '>'.$obj->type;
+ $i++;
+ }
+ print ' ';
+ if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1);
+ }
+ else
+ {
+ dolibarr_print_error($db,$db->lasterror());
+ }
}
-
+
/**
* \brief Return list of types of notes
* \param selected Preselected type
@@ -626,35 +626,35 @@ class Form
{
global $db,$langs,$user;
$langs->load("trips");
-
- print '';
- if ($showempty)
- {
- print ' ';
- }
-
- $sql = "SELECT c.code, c.libelle as type FROM ".MAIN_DB_PREFIX."c_type_fees as c";
- $sql.= " ORDER BY lower(c.libelle) ASC";
- $resql=$db->query($sql);
- if ($resql)
- {
- $num = $db->num_rows($resql);
- $i = 0;
- while ($i < $num)
- {
- $obj = $db->fetch_object($resql);
- print 'code == $selected) print ' selected="true"';
- print '>';
- if ($obj->code != $langs->trans($obj->code)) print $langs->trans($obj->code);
- else print $langs->trans($obj->type);
- $i++;
- }
- }
- print ' ';
+ print '';
+ if ($showempty)
+ {
+ print ' ';
+ }
+
+ $sql = "SELECT c.code, c.libelle as type FROM ".MAIN_DB_PREFIX."c_type_fees as c";
+ $sql.= " ORDER BY lower(c.libelle) ASC";
+ $resql=$db->query($sql);
+ if ($resql)
+ {
+ $num = $db->num_rows($resql);
+ $i = 0;
+
+ while ($i < $num)
+ {
+ $obj = $db->fetch_object($resql);
+ print 'code == $selected) print ' selected="true"';
+ print '>';
+ if ($obj->code != $langs->trans($obj->code)) print $langs->trans($obj->code);
+ else print $langs->trans($obj->type);
+ $i++;
+ }
+ }
+ print ' ';
if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1);
}
@@ -668,184 +668,184 @@ class Form
function select_societes($selected='',$htmlname='socid',$filter='',$showempty=0)
{
global $conf,$user;
-
- // On recherche les societes
- $sql = "SELECT s.rowid, s.nom";
- $sql.= " FROM ".MAIN_DB_PREFIX ."societe as s";
+
+ // On recherche les societes
+ $sql = "SELECT s.rowid, s.nom";
+ $sql.= " FROM ".MAIN_DB_PREFIX ."societe as s";
if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
- $sql.= " WHERE 1=1";
+ $sql.= " WHERE 1=1";
if ($filter) $sql.= " AND ".$filter;
- if ($selected && $conf->use_javascript_ajax && $conf->global->COMPANY_USE_SEARCH_TO_SELECT)
- {
- $sql.= " AND rowid = ".$selected;
- }
- if (!$user->rights->societe->client->voir && !$user->societe_id) //restriction
+ if ($selected && $conf->use_javascript_ajax && $conf->global->COMPANY_USE_SEARCH_TO_SELECT)
+ {
+ $sql.= " AND rowid = ".$selected;
+ }
+ if (!$user->rights->societe->client->voir && !$user->societe_id) //restriction
{
$sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
}
$sql.= " ORDER BY nom ASC";
-
- dolibarr_syslog("Form::select_societes sql=".$sql);
- $resql=$this->db->query($sql);
- if ($resql)
- {
- if ($conf->use_javascript_ajax && $conf->global->COMPANY_USE_SEARCH_TO_SELECT)
- {
- $socid = 0;
- if ($selected)
- {
- $obj = $this->db->fetch_object($resql);
- $socid = $obj->rowid?$obj->rowid:'';
- }
- print '';
- }
- else
- {
- print '';
- if ($showempty) print ' ';
- $num = $this->db->num_rows($resql);
- $i = 0;
- if ($num)
- {
- while ($i < $num)
- {
- $obj = $this->db->fetch_object($resql);
- if ($selected > 0 && $selected == $obj->rowid)
- {
- print ''.$obj->nom.' ';
- }
- else
- {
- print ''.$obj->nom.' ';
- }
- $i++;
- }
- }
- print ' ';
- }
- }
- else
- {
- dolibarr_print_error($this->db);
- }
- }
-
-
+
+ dolibarr_syslog("Form::select_societes sql=".$sql);
+ $resql=$this->db->query($sql);
+ if ($resql)
+ {
+ if ($conf->use_javascript_ajax && $conf->global->COMPANY_USE_SEARCH_TO_SELECT)
+ {
+ $socid = 0;
+ if ($selected)
+ {
+ $obj = $this->db->fetch_object($resql);
+ $socid = $obj->rowid?$obj->rowid:'';
+ }
+ print '';
+ }
+ else
+ {
+ print '';
+ if ($showempty) print ' ';
+ $num = $this->db->num_rows($resql);
+ $i = 0;
+ if ($num)
+ {
+ while ($i < $num)
+ {
+ $obj = $this->db->fetch_object($resql);
+ if ($selected > 0 && $selected == $obj->rowid)
+ {
+ print ''.$obj->nom.' ';
+ }
+ else
+ {
+ print ''.$obj->nom.' ';
+ }
+ $i++;
+ }
+ }
+ print ' ';
+ }
+ }
+ else
+ {
+ dolibarr_print_error($this->db);
+ }
+ }
+
+
/**
* \brief Retourne la liste déroulante des remises fixes
* \param selected Id remise fixe pré-sélectionnée
* \param htmlname Nom champ formulaire
* \param filter Criteres optionnels de filtre
- * \param maxvalue Max value for lines that can be selected
- * \return int Return number of qualifed lines in list
+ * \param maxvalue Max value for lines that can be selected
+ * \return int Return number of qualifed lines in list
*/
function select_remises($selected='',$htmlname='remise_id',$filter='',$socid, $maxvalue=0)
- {
- global $langs,$conf;
-
- // On recherche les remises
- $sql = "SELECT re.rowid, re.amount_ht, re.amount_tva, re.amount_ttc,";
+ {
+ global $langs,$conf;
+
+ // On recherche les remises
+ $sql = "SELECT re.rowid, re.amount_ht, re.amount_tva, re.amount_ttc,";
$sql.= " re.description, re.fk_facture_source";
$sql.= " FROM ".MAIN_DB_PREFIX ."societe_remise_except as re";
- $sql.= " WHERE fk_soc = ".$socid;
- if ($filter) $sql.= " AND ".$filter;
- $sql.= " ORDER BY re.description ASC";
-
- dolibarr_syslog("Form::select_remises sql=".$sql);
- $resql=$this->db->query($sql);
- if ($resql)
- {
- print '';
- $num = $this->db->num_rows($resql);
+ $sql.= " WHERE fk_soc = ".$socid;
+ if ($filter) $sql.= " AND ".$filter;
+ $sql.= " ORDER BY re.description ASC";
- $qualifiedlines=$num;
-
- $i = 0;
- if ($num)
- {
- print ' ';
- while ($i < $num)
- {
- $obj = $this->db->fetch_object($resql);
- $desc=dolibarr_trunc($obj->description,40);
- if ($desc=='(CREDIT_NOTE)')
+ dolibarr_syslog("Form::select_remises sql=".$sql);
+ $resql=$this->db->query($sql);
+ if ($resql)
+ {
+ print '';
+ $num = $this->db->num_rows($resql);
+
+ $qualifiedlines=$num;
+
+ $i = 0;
+ if ($num)
+ {
+ print ' ';
+ while ($i < $num)
+ {
+ $obj = $this->db->fetch_object($resql);
+ $desc=dolibarr_trunc($obj->description,40);
+ if ($desc=='(CREDIT_NOTE)')
{
$desc=$langs->trans("CreditNote");
//$desc.=$obj->fk_facture_source;
}
-
+
$selectstring='';
if ($selected > 0 && $selected == $obj->rowid) $selectstring=' selected="true"';
$disabled='';
- if ($maxvalue && $obj->amount_ttc > $maxvalue)
- {
- $qualifiedlines--;
- $disabled=' disabled="true"';
- }
+ if ($maxvalue && $obj->amount_ttc > $maxvalue)
+ {
+ $qualifiedlines--;
+ $disabled=' disabled="true"';
+ }
print ''.$desc.' ('.price($obj->amount_ht).' '.$langs->trans("HT").' - '.price($obj->amount_ttc).' '.$langs->trans("TTC").') ';
- $i++;
- }
- }
- print ' ';
- return $qualifiedlines;
- }
- else
- {
- dolibarr_print_error($this->db);
- return -1;
- }
- }
-
-
- /**
- * \brief Retourne la liste déroulante des contacts d'une société donnée
- * \param socid Id de la société
- * \param selected Id contact pré-sélectionné
- * \param htmlname Nom champ formulaire ('none' pour champ non editable)
- * \param show_empty 0=liste sans valeur nulle, 1=ajoute valeur inconnue
- * \param exclude Liste des id contacts à exclure
- * \return int <0 if KO, Nb of contact in list if OK
- */
- function select_contacts($socid,$selected='',$htmlname='contactid',$showempty=0,$exclude='')
+ $i++;
+ }
+ }
+ print ' ';
+ return $qualifiedlines;
+ }
+ else
+ {
+ dolibarr_print_error($this->db);
+ return -1;
+ }
+ }
+
+
+ /**
+ * \brief Retourne la liste déroulante des contacts d'une société donnée
+ * \param socid Id de la société
+ * \param selected Id contact pré-sélectionné
+ * \param htmlname Nom champ formulaire ('none' pour champ non editable)
+ * \param show_empty 0=liste sans valeur nulle, 1=ajoute valeur inconnue
+ * \param exclude Liste des id contacts à exclure
+ * \return int <0 if KO, Nb of contact in list if OK
+ */
+ function select_contacts($socid,$selected='',$htmlname='contactid',$showempty=0,$exclude='')
{
// Permettre l'exclusion de contacts
if (is_array($exclude))
{
$excludeContacts = implode("','",$exclude);
}
-
+
// On recherche les societes
$sql = "SELECT s.rowid, s.name, s.firstname FROM";
$sql.= " ".MAIN_DB_PREFIX ."socpeople as s";
$sql.= " WHERE fk_soc=".$socid;
if (is_array($exclude) && $excludeContacts) $sql.= " AND s.rowid NOT IN ('".$excludeContacts."')";
$sql.= " ORDER BY s.name ASC";
-
+
dolibarr_syslog("Form::select_contacts sql=".$sql);
$resql=$this->db->query($sql);
if ($resql)
{
$num=$this->db->num_rows($resql);
if ($num == 0) return 0;
-
+
if ($htmlname != 'none') print '';
if ($showempty) print ' ';
$num = $this->db->num_rows($resql);
@@ -885,24 +885,24 @@ class Form
return -1;
}
}
-
-
- /**
- * \brief Retourne la liste déroulante des utilisateurs
- * \param selected Id user preselected
- * \param htmlname Field name in form
- * \param show_empty 0=liste sans valeur nulle, 1=ajoute valeur inconnue
- * \param exclude List of users id to exclude
+
+
+ /**
+ * \brief Retourne la liste déroulante des utilisateurs
+ * \param selected Id user preselected
+ * \param htmlname Field name in form
+ * \param show_empty 0=liste sans valeur nulle, 1=ajoute valeur inconnue
+ * \param exclude List of users id to exclude
* \param disabled If select list must be disabled
- */
- function select_users($selected='',$htmlname='userid',$show_empty=0,$exclude='',$disabled=0)
- {
+ */
+ function select_users($selected='',$htmlname='userid',$show_empty=0,$exclude='',$disabled=0)
+ {
// Permettre l'exclusion d'utilisateurs
if (is_array($exclude))
{
$excludeUsers = implode("','",$exclude);
}
-
+
// On recherche les utilisateurs
$sql = "SELECT u.rowid, u.name, u.firstname FROM ";
$sql.= MAIN_DB_PREFIX ."user as u";
@@ -921,7 +921,7 @@ class Form
while ($i < $num)
{
$obj = $this->db->fetch_object();
-
+
if ($selected && $selected == $obj->rowid)
{
print ''.$obj->name.' '.$obj->firstname.' ';
@@ -939,45 +939,45 @@ class Form
{
dolibarr_print_error($this->db);
}
- }
-
-
- /**
- * \brief Retourne la liste des produits en Ajax si ajax activé ou renvoie à select_produits_do
- * \param selected Produit pré-sélectionné
- * \param htmlname Nom de la zone select
- * \param filtertype Filter on product type (''=nofilter, 0=product, 1=service)
- * \param limit Limite sur le nombre de lignes retournées
- * \param price_level Niveau de prix en fonction du client
- * \param status -1=Return all products, 0=Products not on sell, 1=Products on sell
- */
- function select_produits($selected='',$htmlname='productid',$filtertype='',$limit=20,$price_level=0,$status=1)
- {
- global $langs,$conf;
-
- if ($conf->global->PRODUIT_USE_SEARCH_TO_SELECT)
- {
- print '';
}
- else
- {
- $this->select_produits_do($selected,$htmlname,$filtertype,$limit,$price_level,'',$status);
- }
- }
-
+
+
+ /**
+ * \brief Retourne la liste des produits en Ajax si ajax activé ou renvoie à select_produits_do
+ * \param selected Produit pré-sélectionné
+ * \param htmlname Nom de la zone select
+ * \param filtertype Filter on product type (''=nofilter, 0=product, 1=service)
+ * \param limit Limite sur le nombre de lignes retournées
+ * \param price_level Niveau de prix en fonction du client
+ * \param status -1=Return all products, 0=Products not on sell, 1=Products on sell
+ */
+ function select_produits($selected='',$htmlname='productid',$filtertype='',$limit=20,$price_level=0,$status=1)
+ {
+ global $langs,$conf;
+
+ if ($conf->global->PRODUIT_USE_SEARCH_TO_SELECT)
+ {
+ print '';
+ }
+ else
+ {
+ $this->select_produits_do($selected,$htmlname,$filtertype,$limit,$price_level,'',$status);
+ }
+ }
+
/**
* \brief Retourne la liste des produits
* \param selected Produit pré-sélectionné
@@ -991,11 +991,11 @@ class Form
function select_produits_do($selected='',$htmlname='productid',$filtertype='',$limit=20,$price_level=0,$ajaxkeysearch='',$status=1)
{
global $langs,$conf,$user;
-
+
$sql = "SELECT ";
if ($conf->categorie->enabled && ! $user->rights->categorie->voir)
{
- $sql.="DISTINCT";
+ $sql.="DISTINCT";
}
$sql.= " p.rowid, p.label, p.ref, p.price, p.price_ttc, p.price_base_type, p.duration";
$sql.= " FROM ".MAIN_DB_PREFIX."product as p ";
@@ -1014,11 +1014,11 @@ class Form
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);
$result=$this->db->query($sql);
if (! $result) dolibarr_print_error($this->db);
-
+
// Multilang : on construit une liste des traductions des produits listés
if ($conf->global->MAIN_MULTILANGS)
{
@@ -1031,11 +1031,11 @@ class Form
$resultd = $this->db->query($sqld);
if ( $resultd ) $objtp = $this->db->fetch_object($resultd);
}
-
+
if ($result)
{
$num = $this->db->num_rows($result);
-
+
if ($conf->use_javascript_ajax)
{
if (! $num)
@@ -1045,7 +1045,9 @@ class Form
}
else
{
- print '';
+ print 'global->PRODUIT_USE_SEARCH_TO_SELECT) print ' onchange="publish_selvalue(this);"';
+ print '>';
print '-- '.$langs->trans("MatchingProducts").' -- ';
}
}
@@ -1054,12 +1056,12 @@ class Form
print '';
print ' ';
}
-
+
$i = 0;
while ($num && $i < $num)
{
$objp = $this->db->fetch_object($result);
-
+
// Multilangs : modification des donnée si une traduction existe
if ($conf->global->MAIN_MULTILANGS)
{
@@ -1085,28 +1087,28 @@ class Form
$objp2 = $this->db->fetch_object($result2);
if ($objp2)
{
- if ($objp2->price_base_type == 'HT')
- $opt.= price($objp2->price,1).' '.$langs->trans("Currency".$conf->monnaie).' '.$langs->trans("HT");
- else
- $opt.= price($objp2->price_ttc,1).' '.$langs->trans("Currency".$conf->monnaie).' '.$langs->trans("TTC");
+ if ($objp2->price_base_type == 'HT')
+ $opt.= price($objp2->price,1).' '.$langs->trans("Currency".$conf->monnaie).' '.$langs->trans("HT");
+ else
+ $opt.= price($objp2->price_ttc,1).' '.$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
else
{
if ($objp->price_base_type == 'HT')
- $opt.= price($objp->price,1).' '.$langs->trans("Currency".$conf->monnaie).' '.$langs->trans("HT");
- else
- $opt.= price($objp->price_ttc,1).' '.$langs->trans("Currency".$conf->monnaie).' '.$langs->trans("TTC");
- }
+ $opt.= price($objp->price,1).' '.$langs->trans("Currency".$conf->monnaie).' '.$langs->trans("HT");
+ else
+ $opt.= price($objp->price_ttc,1).' '.$langs->trans("Currency".$conf->monnaie).' '.$langs->trans("TTC");
+ }
}
else
{
if ($objp->price_base_type == 'HT')
- $opt.= price($objp->price,1).' '.$langs->trans("Currency".$conf->monnaie).' '.$langs->trans("HT");
+ $opt.= price($objp->price,1).' '.$langs->trans("Currency".$conf->monnaie).' '.$langs->trans("HT");
else
- $opt.= price($objp->price_ttc,1).' '.$langs->trans("Currency".$conf->monnaie).' '.$langs->trans("TTC");
+ $opt.= price($objp->price_ttc,1).' '.$langs->trans("Currency".$conf->monnaie).' '.$langs->trans("TTC");
}
-
+
if ($objp->duration)
{
$duration_value = substr($objp->duration,0,strlen($objp->duration)-1);
@@ -1121,14 +1123,14 @@ class Form
}
$opt.= ' - '.$duration_value.' '.$langs->trans($dur[$duration_unit]);
}
-
+
$opt.= "\n";
print $opt;
$i++;
}
-
- print ' ';
-
+
+ print ' ';
+
$this->db->free($result);
}
else
@@ -1136,7 +1138,7 @@ class Form
dolibarr_print_error($db);
}
}
-
+
/**
* \brief Retourne la liste des produits fournisseurs en Ajax si ajax activé ou renvoie à select_produits_fournisseurs_do
* \param socid Id third party
@@ -1156,9 +1158,9 @@ class Form
else
{
$this->select_produits_fournisseurs_do($socid,$selected,$htmlname,$filtertype,$filtre,'');
- }
+ }
}
-
+
/**
* \brief Retourne la liste des produits de fournisseurs
* \param socid Id société fournisseur (0 pour aucun filtre)
@@ -1171,9 +1173,9 @@ class Form
function select_produits_fournisseurs_do($socid,$selected='',$htmlname='productid',$filtertype='',$filtre='',$ajaxkeysearch='')
{
global $langs,$conf;
-
+
$langs->load('stocks');
-
+
$sql = "SELECT p.rowid, p.label, p.ref, p.price, p.duration,";
$sql.= " pf.ref_fourn,";
$sql.= " pfp.rowid as idprodfournprice, pfp.price as fprice, pfp.quantity, pfp.unitprice,";
@@ -1193,9 +1195,9 @@ class Form
$result=$this->db->query($sql);
if ($result)
{
-
+
$num = $this->db->num_rows($result);
-
+
if ($conf->use_javascript_ajax)
{
if (! $num)
@@ -1215,12 +1217,12 @@ class Form
if (! $selected) print ' ';
else print ' ';
}
-
+
$i = 0;
while ($i < $num)
{
$objp = $this->db->fetch_object($result);
-
+
$opt = 'idprodfournprice) $opt.= ' selected="true"';
if ($objp->fprice == '') $opt.=' disabled="disabled"';
@@ -1252,12 +1254,12 @@ class Form
$opt.= $langs->trans("NoPriceDefinedForThisSupplier");
}
$opt .= " \n";
-
+
print $opt;
$i++;
}
print ' ';
-
+
$this->db->free($result);
}
else
@@ -1265,17 +1267,17 @@ class Form
dolibarr_print_error($db);
}
}
-
+
/**
\brief Retourne la liste des tarifs fournisseurs pour un produit
\param productid Id product
- */
+ */
function select_product_fourn_price($productid,$htmlname='productfournpriceid')
{
global $langs,$conf;
-
+
$langs->load('stocks');
-
+
$sql = "SELECT p.rowid, p.label, p.ref, p.price, p.duration,";
$sql.= " pf.ref_fourn,";
$sql.= " pfp.rowid as idprodfournprice, pfp.price as fprice, pfp.quantity, pfp.unitprice,";
@@ -1291,13 +1293,13 @@ class Form
dolibarr_syslog("Form::select_product_fourn_price sql=".$sql,LOG_DEBUG);
$result=$this->db->query($sql);
-
+
if ($result)
{
$num = $this->db->num_rows($result);
-
+
$form = '';
-
+
if (! $num)
{
$form.= '-- '.$langs->trans("NoSupplierPriceDefinedForThisProduct").' -- ';
@@ -1305,23 +1307,23 @@ class Form
else
{
$form.= ' ';
-
+
$i = 0;
while ($i < $num)
{
$objp = $this->db->fetch_object($result);
-
+
$opt = ''.$objp->nom.' - '.$objp->ref_fourn.' - ';
-
+
if ($objp->quantity == 1)
{
$opt.= price($objp->fprice);
$opt.= $langs->trans("Currency".$conf->monnaie)."/";
}
-
+
$opt.= $objp->quantity.' ';
-
+
if ($objp->quantity == 1)
{
$opt.= strtolower($langs->trans("Unit"));
@@ -1337,12 +1339,12 @@ class Form
}
if ($objp->duration) $opt .= " - ".$objp->duration;
$opt .= " \n";
-
+
$form.= $opt;
$i++;
}
$form.= ' ';
-
+
$this->db->free($result);
}
return $form;
@@ -1353,451 +1355,451 @@ class Form
}
}
- /**
- * \brief Retourne la liste déroulante des adresses de livraison
- * \param selected Id contact pré-sélectionn
- * \param htmlname Nom champ formulaire
- */
- function select_adresse_livraison($selected='', $socid, $htmlname='adresse_livraison_id',$showempty=0)
- {
- // 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";
-
+ /**
+ * \brief Retourne la liste déroulante des adresses de livraison
+ * \param selected Id contact pré-sélectionn
+ * \param htmlname Nom champ formulaire
+ */
+ function select_adresse_livraison($selected='', $socid, $htmlname='adresse_livraison_id',$showempty=0)
+ {
+ // 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";
+
dolibarr_syslog("Form::select_adresse_livraison sql=".$sql);
- if ($this->db->query($sql))
- {
- print '';
- if ($showempty) print ' ';
- $num = $this->db->num_rows();
- $i = 0;
- if ($num)
- {
- while ($i < $num)
- {
- $obj = $this->db->fetch_object();
-
- if ($selected && $selected == $obj->rowid)
- {
- print ''.$obj->label.' ';
- }
- else
- {
- print ''.$obj->label.' ';
- }
- $i++;
- }
- }
- print ' ';
- return $num;
- }
- else
- {
- dolibarr_print_error($this->db);
- }
- }
+ if ($this->db->query($sql))
+ {
+ print '';
+ if ($showempty) print ' ';
+ $num = $this->db->num_rows();
+ $i = 0;
+ if ($num)
+ {
+ while ($i < $num)
+ {
+ $obj = $this->db->fetch_object();
-
- /**
- * \brief Renvoie la liste des types d'effectifs possibles (pas de traduction car nombre)
- * \param mode 0=renvoi id+libelle, 1=renvoi code+libelle
- * \return array tableau des types d'effectifs
- */
- function effectif_array($mode=0)
- {
- $effs = array();
+ if ($selected && $selected == $obj->rowid)
+ {
+ print ''.$obj->label.' ';
+ }
+ else
+ {
+ print ''.$obj->label.' ';
+ }
+ $i++;
+ }
+ }
+ print ' ';
+ return $num;
+ }
+ else
+ {
+ dolibarr_print_error($this->db);
+ }
+ }
- $sql = "SELECT id, code, libelle";
- $sql .= " FROM ".MAIN_DB_PREFIX."c_effectif";
- $sql.= " WHERE active = 1";
- $sql .= " ORDER BY id ASC";
- dolibarr_syslog('Form::effectif_array sql='.$sql,LOG_DEBUG);
- $resql=$this->db->query($sql);
- if ($resql)
- {
- $num = $this->db->num_rows($resql);
- $i = 0;
- while ($i < $num)
- {
- $objp = $this->db->fetch_object($resql);
- if (! $mode) $key=$objp->id;
- else $key=$objp->code;
+ /**
+ * \brief Renvoie la liste des types d'effectifs possibles (pas de traduction car nombre)
+ * \param mode 0=renvoi id+libelle, 1=renvoi code+libelle
+ * \return array tableau des types d'effectifs
+ */
+ function effectif_array($mode=0)
+ {
+ $effs = array();
- $effs[$key] = $objp->libelle!='-'?$objp->libelle:'';
- $i++;
- }
- $this->db->free($resql);
- }
- return $effs;
- }
+ $sql = "SELECT id, code, libelle";
+ $sql .= " FROM ".MAIN_DB_PREFIX."c_effectif";
+ $sql.= " WHERE active = 1";
+ $sql .= " ORDER BY id ASC";
+ dolibarr_syslog('Form::effectif_array sql='.$sql,LOG_DEBUG);
+ $resql=$this->db->query($sql);
+ if ($resql)
+ {
+ $num = $this->db->num_rows($resql);
+ $i = 0;
- /**
- * \brief Renvoie la liste des formes juridiques existantes (pas de traduction car unique au pays)
- * \return array tableau des formes juridiques
- */
- function forme_juridique_array()
- {
- $fj = array();
-
- $sql = "SELECT code, libelle";
- $sql.= " FROM ".MAIN_DB_PREFIX."c_forme_juridique";
- $sql.= " WHERE active = 1";
- $sql.= " ORDER BY code ASC";
- dolibarr_syslog('Form::forme_juridique_array sql='.$sql,LOG_DEBUG);
- $resql=$this->db->query($sql);
- if ($resql)
- {
- $num = $this->db->num_rows($resql);
- $i = 0;
-
- while ($i < $num)
- {
- $objp = $this->db->fetch_object($resql);
- $fj[$objp->code] = $objp->libelle!='-'?$objp->libelle:'';
- $i++;
- }
- $this->db->free($resql);
- }
- return $fj;
- }
-
- /**
- * \brief Renvoie la liste des libelles traduits des types actifs de societes
- * \param mode 0=renvoi id+libelle, 1=renvoi code+libelle
- * \return array tableau des types
- */
- function typent_array($mode=0)
- {
- global $langs;
-
- $effs = array();
-
- $sql = "SELECT id, code, libelle";
- $sql.= " FROM ".MAIN_DB_PREFIX."c_typent";
- $sql.= " WHERE active = 1";
- $sql.= " ORDER by id";
- dolibarr_syslog('Form::typent_array sql='.$sql,LOG_DEBUG);
- $resql=$this->db->query($sql);
- if ($resql)
- {
- $num = $this->db->num_rows($resql);
- $i = 0;
-
- while ($i < $num)
- {
- $objp = $this->db->fetch_object($resql);
+ while ($i < $num)
+ {
+ $objp = $this->db->fetch_object($resql);
if (! $mode) $key=$objp->id;
else $key=$objp->code;
- if ($langs->trans($objp->code) != $objp->code)
- $effs[$key] = $langs->trans($objp->code);
- else
- $effs[$key] = $objp->libelle!='-'?$objp->libelle:'';
- $i++;
- }
- $this->db->free($resql);
- }
+ $effs[$key] = $objp->libelle!='-'?$objp->libelle:'';
+ $i++;
+ }
+ $this->db->free($resql);
+ }
+ return $effs;
+ }
- return $effs;
- }
+ /**
+ * \brief Renvoie la liste des formes juridiques existantes (pas de traduction car unique au pays)
+ * \return array tableau des formes juridiques
+ */
+ function forme_juridique_array()
+ {
+ $fj = array();
- /**
- * \brief Charge dans cache la liste des conditions de paiements possibles
- * \return int Nb lignes chargées, 0 si déjà chargées, <0 si ko
- */
- function load_cache_conditions_paiements()
- {
- global $langs;
+ $sql = "SELECT code, libelle";
+ $sql.= " FROM ".MAIN_DB_PREFIX."c_forme_juridique";
+ $sql.= " WHERE active = 1";
+ $sql.= " ORDER BY code ASC";
+ dolibarr_syslog('Form::forme_juridique_array sql='.$sql,LOG_DEBUG);
+ $resql=$this->db->query($sql);
+ if ($resql)
+ {
+ $num = $this->db->num_rows($resql);
+ $i = 0;
- if (sizeof($this->cache_conditions_paiements)) return 0; // Cache déja chargé
+ while ($i < $num)
+ {
+ $objp = $this->db->fetch_object($resql);
+ $fj[$objp->code] = $objp->libelle!='-'?$objp->libelle:'';
+ $i++;
+ }
+ $this->db->free($resql);
+ }
+ return $fj;
+ }
- $sql = "SELECT rowid, code, libelle";
- $sql.= " FROM ".MAIN_DB_PREFIX."cond_reglement";
- $sql.= " WHERE active=1";
- $sql.= " ORDER BY sortorder";
- dolibarr_syslog('Form::load_cache_conditions_paiements sql='.$sql,LOG_DEBUG);
- $resql = $this->db->query($sql);
- if ($resql)
- {
- $num = $this->db->num_rows($resql);
- $i = 0;
- while ($i < $num)
- {
- $obj = $this->db->fetch_object($resql);
+ /**
+ * \brief Renvoie la liste des libelles traduits des types actifs de societes
+ * \param mode 0=renvoi id+libelle, 1=renvoi code+libelle
+ * \return array tableau des types
+ */
+ function typent_array($mode=0)
+ {
+ global $langs;
- // Si traduction existe, on l'utilise, sinon on prend le libellé par défaut
- $libelle=($langs->trans("PaymentConditionShort".$obj->code)!=("PaymentConditionShort".$obj->code)?$langs->trans("PaymentConditionShort".$obj->code):($obj->libelle!='-'?$obj->libelle:''));
- $this->cache_conditions_paiements[$obj->rowid]['code'] =$obj->code;
- $this->cache_conditions_paiements[$obj->rowid]['label']=$libelle;
- $i++;
- }
- return 1;
- }
- else {
- dolibarr_print_error($this->db);
- return -1;
- }
- }
+ $effs = array();
- /**
- * \brief Charge dans cache la liste des types de paiements possibles
- * \return int Nb lignes chargées, 0 si déjà chargées, <0 si ko
- */
- function load_cache_types_paiements()
- {
- global $langs;
+ $sql = "SELECT id, code, libelle";
+ $sql.= " FROM ".MAIN_DB_PREFIX."c_typent";
+ $sql.= " WHERE active = 1";
+ $sql.= " ORDER by id";
+ dolibarr_syslog('Form::typent_array sql='.$sql,LOG_DEBUG);
+ $resql=$this->db->query($sql);
+ if ($resql)
+ {
+ $num = $this->db->num_rows($resql);
+ $i = 0;
- if (sizeof($this->cache_types_paiements)) return 0; // Cache déja chargé
+ while ($i < $num)
+ {
+ $objp = $this->db->fetch_object($resql);
+ if (! $mode) $key=$objp->id;
+ else $key=$objp->code;
- $sql = "SELECT id, code, libelle, type";
- $sql.= " FROM ".MAIN_DB_PREFIX."c_paiement";
- $sql.= " WHERE active > 0";
- $sql.= " ORDER BY id";
- dolibarr_syslog('Form::load_cache_types_paiements sql='.$sql,LOG_DEBUG);
- $resql = $this->db->query($sql);
- if ($resql)
- {
- $num = $this->db->num_rows($resql);
- $i = 0;
- while ($i < $num)
- {
- $obj = $this->db->fetch_object($resql);
+ if ($langs->trans($objp->code) != $objp->code)
+ $effs[$key] = $langs->trans($objp->code);
+ else
+ $effs[$key] = $objp->libelle!='-'?$objp->libelle:'';
+ $i++;
+ }
+ $this->db->free($resql);
+ }
- // Si traduction existe, on l'utilise, sinon on prend le libellé par défaut
- $libelle=($langs->trans("PaymentTypeShort".$obj->code)!=("PaymentTypeShort".$obj->code)?$langs->trans("PaymentTypeShort".$obj->code):($obj->libelle!='-'?$obj->libelle:''));
- $this->cache_types_paiements[$obj->id]['code'] =$obj->code;
- $this->cache_types_paiements[$obj->id]['label']=$libelle;
- $this->cache_types_paiements[$obj->id]['type'] =$obj->type;
- $i++;
- }
- return $num;
- }
- else {
- dolibarr_print_error($this->db);
- return -1;
- }
- }
+ return $effs;
+ }
-
-
- /**
- * \brief Retourne la liste des types de paiements possibles
- * \param selected Id du type de paiement pré-sélectionné
- * \param htmlname Nom de la zone select
- * \param filtertype Pour filtre
- * \param addempty Ajoute entrée vide
- */
- function select_conditions_paiements($selected='',$htmlname='condid',$filtertype=-1,$addempty=0)
- {
- global $langs,$user;
-
- $this->load_cache_conditions_paiements();
-
- print '';
+ /**
+ * \brief Charge dans cache la liste des conditions de paiements possibles
+ * \return int Nb lignes chargées, 0 si déjà chargées, <0 si ko
+ */
+ function load_cache_conditions_paiements()
+ {
+ global $langs;
+
+ if (sizeof($this->cache_conditions_paiements)) return 0; // Cache déja chargé
+
+ $sql = "SELECT rowid, code, libelle";
+ $sql.= " FROM ".MAIN_DB_PREFIX."cond_reglement";
+ $sql.= " WHERE active=1";
+ $sql.= " ORDER BY sortorder";
+ dolibarr_syslog('Form::load_cache_conditions_paiements sql='.$sql,LOG_DEBUG);
+ $resql = $this->db->query($sql);
+ if ($resql)
+ {
+ $num = $this->db->num_rows($resql);
+ $i = 0;
+ while ($i < $num)
+ {
+ $obj = $this->db->fetch_object($resql);
+
+ // Si traduction existe, on l'utilise, sinon on prend le libellé par défaut
+ $libelle=($langs->trans("PaymentConditionShort".$obj->code)!=("PaymentConditionShort".$obj->code)?$langs->trans("PaymentConditionShort".$obj->code):($obj->libelle!='-'?$obj->libelle:''));
+ $this->cache_conditions_paiements[$obj->rowid]['code'] =$obj->code;
+ $this->cache_conditions_paiements[$obj->rowid]['label']=$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ées, 0 si déjà chargées, <0 si ko
+ */
+ function load_cache_types_paiements()
+ {
+ global $langs;
+
+ if (sizeof($this->cache_types_paiements)) return 0; // Cache déja chargé
+
+ $sql = "SELECT id, code, libelle, type";
+ $sql.= " FROM ".MAIN_DB_PREFIX."c_paiement";
+ $sql.= " WHERE active > 0";
+ $sql.= " ORDER BY id";
+ dolibarr_syslog('Form::load_cache_types_paiements sql='.$sql,LOG_DEBUG);
+ $resql = $this->db->query($sql);
+ if ($resql)
+ {
+ $num = $this->db->num_rows($resql);
+ $i = 0;
+ while ($i < $num)
+ {
+ $obj = $this->db->fetch_object($resql);
+
+ // Si traduction existe, on l'utilise, sinon on prend le libellé par défaut
+ $libelle=($langs->trans("PaymentTypeShort".$obj->code)!=("PaymentTypeShort".$obj->code)?$langs->trans("PaymentTypeShort".$obj->code):($obj->libelle!='-'?$obj->libelle:''));
+ $this->cache_types_paiements[$obj->id]['code'] =$obj->code;
+ $this->cache_types_paiements[$obj->id]['label']=$libelle;
+ $this->cache_types_paiements[$obj->id]['type'] =$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é-sélectionné
+ * \param htmlname Nom de la zone select
+ * \param filtertype Pour filtre
+ * \param addempty Ajoute entrée vide
+ */
+ function select_conditions_paiements($selected='',$htmlname='condid',$filtertype=-1,$addempty=0)
+ {
+ global $langs,$user;
+
+ $this->load_cache_conditions_paiements();
+
+ print '';
if ($addempty) print ' ';
- foreach($this->cache_conditions_paiements as $id => $arrayconditions)
- {
- if ($selected == $id)
- {
- print '';
- }
- else
- {
- print ' ';
- }
- print $arrayconditions['label'];
- print ' ';
- }
- print ' ';
+ foreach($this->cache_conditions_paiements as $id => $arrayconditions)
+ {
+ if ($selected == $id)
+ {
+ print '';
+ }
+ else
+ {
+ print ' ';
+ }
+ print $arrayconditions['label'];
+ print ' ';
+ }
+ print ' ';
if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1);
- }
-
+ }
+
+
+ /**
+ * \brief Retourne la liste des modes de paiements possibles
+ * \param selected Id du mode de paiement pré-sélectionné
+ * \param htmlname Nom de la zone select
+ * \param filtertype Pour filtre
+ * \param format 0=id+libelle, 1=code+code, 2=code+libelle
+ * \param empty 1=peut etre vide, 0 sinon
+ * \param noadmininfo 0=Add admin info, 1=Disable admin info
+ */
+ function select_types_paiements($selected='',$htmlname='paiementtype',$filtertype='',$format=0, $empty=0, $noadmininfo=0)
+ {
+ global $langs,$user;
- /**
- * \brief Retourne la liste des modes de paiements possibles
- * \param selected Id du mode de paiement pré-sélectionné
- * \param htmlname Nom de la zone select
- * \param filtertype Pour filtre
- * \param format 0=id+libelle, 1=code+code, 2=code+libelle
- * \param empty 1=peut etre vide, 0 sinon
- * \param noadmininfo 0=Add admin info, 1=Disable admin info
- */
- function select_types_paiements($selected='',$htmlname='paiementtype',$filtertype='',$format=0, $empty=0, $noadmininfo=0)
- {
- global $langs,$user;
-
dolibarr_syslog("Form::select_type_paiements $selected, $htmlname, $filtertype, $format",LOG_DEBUG);
-
- $filterarray=array();
+
+ $filterarray=array();
if ($filtertype == 'CRDT') $filterarray=array(0,2);
elseif ($filtertype == 'DBIT') $filterarray=array(1,2);
- elseif ($filtertype != '' && $filtertype != '-1') $filterarray=split(',',$filtertype);
-
- $this->load_cache_types_paiements();
+ elseif ($filtertype != '' && $filtertype != '-1') $filterarray=split(',',$filtertype);
- print '';
+ $this->load_cache_types_paiements();
+
+ print '';
if ($empty) print ' ';
- foreach($this->cache_types_paiements as $id => $arraytypes)
- {
- // On passe si on a demandé de filtrer sur des modes de paiments particuliers
- if (sizeof($filterarray) && ! in_array($arraytypes['type'],$filterarray)) continue;
+ foreach($this->cache_types_paiements as $id => $arraytypes)
+ {
+ // On passe si on a demandé de filtrer sur des modes de paiments particuliers
+ if (sizeof($filterarray) && ! in_array($arraytypes['type'],$filterarray)) continue;
- if ($format == 0) print '';
- if ($format == 0) $value=$arraytypes['label'];
- if ($format == 1) $value=$arraytypes['code'];
- if ($format == 2) $value=$arraytypes['label'];
- print $value?$value:' ';
- print ' ';
- }
- print ' ';
+ if ($format == 0) print '';
+ if ($format == 0) $value=$arraytypes['label'];
+ if ($format == 1) $value=$arraytypes['code'];
+ if ($format == 2) $value=$arraytypes['label'];
+ print $value?$value:' ';
+ print ' ';
+ }
+ print ' ';
if ($user->admin && ! $noadmininfo) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1);
- }
+ }
- /**
- * \brief Selection HT ou TTC
- * \param selected Id pré-sélectionné
- * \param htmlname Nom de la zone select
- */
- function select_PriceBaseType($selected='',$htmlname='price_base_type')
- {
- global $langs;
- print '';
+ /**
+ * \brief Selection HT ou TTC
+ * \param selected Id pré-sélectionné
+ * \param htmlname Nom de la zone select
+ */
+ function select_PriceBaseType($selected='',$htmlname='price_base_type')
+ {
+ global $langs;
+ print '';
$options = array(
'HT'=>$langs->trans("HT"),
'TTC'=>$langs->trans("TTC")
- );
- foreach($options as $id => $value)
- {
- if ($selected == $id)
- {
- print ''.$value;
- }
- else
- {
- print ' '.$value;
- }
- print ' ';
- }
- print ' ';
- }
-
- /**
- * \brief Retourne la liste déroulante des différents états d'une propal.
- * Les valeurs de la liste sont les id de la table c_propalst
- * \param selected etat pre-séléctionné
- */
- function select_propal_statut($selected='')
- {
- $sql = "SELECT id, code, label, active FROM ".MAIN_DB_PREFIX."c_propalst";
- $sql .= " WHERE active = 1";
-
+ );
+ foreach($options as $id => $value)
+ {
+ if ($selected == $id)
+ {
+ print ''.$value;
+ }
+ else
+ {
+ print ' '.$value;
+ }
+ print ' ';
+ }
+ print ' ';
+ }
+
+ /**
+ * \brief Retourne la liste déroulante des différents états d'une propal.
+ * Les valeurs de la liste sont les id de la table c_propalst
+ * \param selected etat pre-séléctionné
+ */
+ function select_propal_statut($selected='')
+ {
+ $sql = "SELECT id, code, label, active FROM ".MAIN_DB_PREFIX."c_propalst";
+ $sql .= " WHERE active = 1";
+
dolibarr_syslog("Form::select_propal_statut sql=".$sql);
- if ($this->db->query($sql))
- {
- print '';
- print ' ';
- $num = $this->db->num_rows();
- $i = 0;
- if ($num)
- {
- while ($i < $num)
- {
- $obj = $this->db->fetch_object();
- if ($selected == $obj->id)
- {
- print '';
- }
- else
- {
- print ' ';
- }
- // Si traduction existe, on l'utilise, sinon on prend le libellé 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 ' ';
- $i++;
- }
- }
- print ' ';
- }
- else
- {
- dolibarr_print_error($this->db);
- }
- }
+ if ($this->db->query($sql))
+ {
+ print '';
+ print ' ';
+ $num = $this->db->num_rows();
+ $i = 0;
+ if ($num)
+ {
+ while ($i < $num)
+ {
+ $obj = $this->db->fetch_object();
+ if ($selected == $obj->id)
+ {
+ print '';
+ }
+ else
+ {
+ print ' ';
+ }
+ // Si traduction existe, on l'utilise, sinon on prend le libellé 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 ' ';
+ $i++;
+ }
+ }
+ print ' ';
+ }
+ else
+ {
+ dolibarr_print_error($this->db);
+ }
+ }
- /**
- * \brief Retourne la liste des comptes
- * \param selected Id compte pré-sélectionné
- * \param htmlname Nom de la zone select
- * \param statut Statut des comptes recherché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";
+ /**
+ * \brief Retourne la liste des comptes
+ * \param selected Id compte pré-sélectionné
+ * \param htmlname Nom de la zone select
+ * \param statut Statut des comptes recherché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";
dolibarr_syslog("Form::select_comptes sql=".$sql);
- $result = $this->db->query($sql);
- if ($result)
- {
- print '';
- if ($useempty)
- {
- print ' ';
- }
+ $result = $this->db->query($sql);
+ if ($result)
+ {
+ print '';
+ if ($useempty)
+ {
+ print ' ';
+ }
- $num = $this->db->num_rows($result);
- $i = 0;
- while ($i < $num)
- {
- $obj = $this->db->fetch_object($result);
- if ($selected == $obj->rowid)
- {
- print '';
- }
- else
- {
- print ' ';
- }
- print $obj->label;
- print ' ';
- $i++;
- }
- print " ";
- }
- else {
- dolibarr_print_error($this->db);
- }
- }
-
- /**
- * \brief Retourne la liste des catégories du type choisi
- * \param type Type de categories (0=produit, 1=fournisseur, 2=client)
- * \param selected Id categorie preselectionnee
- * \param select_name Nom formulaire HTML
- */
- function select_all_categories($type,$selected='',$select_name="")
- {
- global $langs;
- $langs->load("categorie");
+ $num = $this->db->num_rows($result);
+ $i = 0;
+ while ($i < $num)
+ {
+ $obj = $this->db->fetch_object($result);
+ if ($selected == $obj->rowid)
+ {
+ print '';
+ }
+ else
+ {
+ print ' ';
+ }
+ print $obj->label;
+ print ' ';
+ $i++;
+ }
+ print " ";
+ }
+ else {
+ dolibarr_print_error($this->db);
+ }
+ }
+
+ /**
+ * \brief Retourne la liste des catégories du type choisi
+ * \param type Type de categories (0=produit, 1=fournisseur, 2=client)
+ * \param selected Id categorie preselectionnee
+ * \param select_name Nom formulaire HTML
+ */
+ function select_all_categories($type,$selected='',$select_name="")
+ {
+ global $langs;
+ $langs->load("categorie");
if ($select_name=="") $select_name="catMere";
@@ -1827,393 +1829,393 @@ class Form
}
$output.= ' ';
$output.= "\n";
- return $output;
+ return $output;
}
-
-
-
- /**
- * \brief Retourne la liste déroulante des civilite actives
- * \param selected civilite pré-sélectionnée
- */
- function select_civilite($selected='')
- {
- global $conf,$langs,$user;
- $langs->load("dict");
-
- $sql = "SELECT rowid, code, civilite, active FROM ".MAIN_DB_PREFIX."c_civilite";
- $sql .= " WHERE active = 1";
-
- dolibarr_syslog("Form::select_civilite sql=".$sql);
- if ($this->db->query($sql))
- {
- print '';
- print ' ';
- $num = $this->db->num_rows();
- $i = 0;
- if ($num)
- {
- while ($i < $num)
- {
- $obj = $this->db->fetch_object();
- if ($selected == $obj->code)
- {
- print '';
- }
- else
- {
- print ' ';
- }
- // Si traduction existe, on l'utilise, sinon on prend le libellé par défaut
- print ($langs->trans("Civility".$obj->code)!="Civility".$obj->code ? $langs->trans("Civility".$obj->code) : ($obj->civilite!='-'?$obj->civilite:''));
- print ' ';
- $i++;
- }
- }
- print ' ';
- if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1);
- }
- else
- {
- dolibarr_print_error($this->db);
- }
- }
- /**
- * \brief Retourne la liste déroulante des formes juridiques tous pays confondus ou pour un pays donné.
- * \remarks Dans le cas d'une liste tous pays confondu, on affiche une rupture sur le pays
- * \param selected Code forme juridique a pré-sélectionné
- * \param pays_code 0=liste tous pays confondus, sinon code du pays à afficher
- */
- function select_forme_juridique($selected='',$pays_code=0)
- {
- global $conf,$langs,$user;
- $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";
-
- dolibarr_syslog("Form::select_forme_juridique sql=".$sql);
- $result=$this->db->query($sql);
- if ($result)
- {
- print '';
- print '';
- if ($pays_code) print ' ';
- $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 ' ';
- }
- else {
- if (! $pays || $pays != $obj->libelle_pays) {
- // Affiche la rupture si on est en mode liste multipays
- if (! $pays_code && $obj->code_pays) {
- print '----- '.$obj->libelle_pays." ----- \n";
- $pays=$obj->libelle_pays;
- }
- }
-
- if ($selected > 0 && $selected == $obj->code)
- {
- print '';
- }
- else
- {
- print ' ';
- }
- // Si traduction existe, on l'utilise, sinon on prend le libellé par défaut
- print $obj->code . ' - ' .($langs->trans("JuridicalStatus".$obj->code)!="JuridicalStatus".$obj->code?$langs->trans("JuridicalStatus".$obj->code):($obj->nom!='-'?$obj->nom:''));
- print ' ';
- }
- $i++;
- }
- }
- print ' ';
- if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1);
- print '
';
- }
- else
- {
- dolibarr_print_error($this->db);
- }
- }
-
- /**
- * \brief Affiche formulaire de demande de confirmation
- * \param page page
- * \param title title
- * \param question question
- * \param action action
- * \param formquestion an array with forms complementary inputs
- */
- function form_confirm($page, $title, $question, $action, $formquestion='')
- {
- global $langs;
-
- print '\n";
- }
-
-
- /**
- * \brief Affiche formulaire de selection de projet
- * \param page Page
- * \param socid Id societe
- * \param selected Id projet pré-sélectionné
- * \param htmlname Nom du formulaire select
- */
- function form_project($page, $socid, $selected='', $htmlname='projectid')
- {
- global $langs;
-
- require_once(DOL_DOCUMENT_ROOT."/lib/project.lib.php");
-
- $langs->load("project");
- if ($htmlname != "none")
- {
- print '';
- }
- else
- {
- if ($selected) {
- $projet = new Project($this->db);
- $projet->fetch($selected);
- print ''.$projet->title.' ';
- } else {
- print " ";
- }
- }
- }
-
- /**
- * \brief Affiche formulaire de selection de conditions de paiement
- * \param page Page
- * \param selected Id condition pré-sélectionné
- * \param htmlname Nom du formulaire select
- * \param addempty Ajoute entrée vide
- */
- function form_conditions_reglement($page, $selected='', $htmlname='cond_reglement_id', $addempty=0)
- {
- global $langs;
- if ($htmlname != "none")
- {
- print '';
- }
- else
- {
- if ($selected)
- {
- $this->load_cache_conditions_paiements();
- print $this->cache_conditions_paiements[$selected]['label'];
- } else {
- print " ";
- }
- }
- }
-
/**
- * \brief Affiche formulaire de selection de l'assujétissement à la TVA
- * \param page Page
- * \param selected Id condition pré-sélectionnée
- * \param htmlname Nom du formulaire select
- */
+ * \brief Retourne la liste déroulante des civilite actives
+ * \param selected civilite pré-sélectionnée
+ */
+ function select_civilite($selected='')
+ {
+ global $conf,$langs,$user;
+ $langs->load("dict");
+
+ $sql = "SELECT rowid, code, civilite, active FROM ".MAIN_DB_PREFIX."c_civilite";
+ $sql .= " WHERE active = 1";
+
+ dolibarr_syslog("Form::select_civilite sql=".$sql);
+ if ($this->db->query($sql))
+ {
+ print '';
+ print ' ';
+ $num = $this->db->num_rows();
+ $i = 0;
+ if ($num)
+ {
+ while ($i < $num)
+ {
+ $obj = $this->db->fetch_object();
+ if ($selected == $obj->code)
+ {
+ print '';
+ }
+ else
+ {
+ print ' ';
+ }
+ // Si traduction existe, on l'utilise, sinon on prend le libellé par défaut
+ print ($langs->trans("Civility".$obj->code)!="Civility".$obj->code ? $langs->trans("Civility".$obj->code) : ($obj->civilite!='-'?$obj->civilite:''));
+ print ' ';
+ $i++;
+ }
+ }
+ print ' ';
+ if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1);
+ }
+ else
+ {
+ dolibarr_print_error($this->db);
+ }
+ }
+
+
+ /**
+ * \brief Retourne la liste déroulante des formes juridiques tous pays confondus ou pour un pays donné.
+ * \remarks Dans le cas d'une liste tous pays confondu, on affiche une rupture sur le pays
+ * \param selected Code forme juridique a pré-sélectionné
+ * \param pays_code 0=liste tous pays confondus, sinon code du pays à afficher
+ */
+ function select_forme_juridique($selected='',$pays_code=0)
+ {
+ global $conf,$langs,$user;
+ $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";
+
+ dolibarr_syslog("Form::select_forme_juridique sql=".$sql);
+ $result=$this->db->query($sql);
+ if ($result)
+ {
+ print '';
+ print '';
+ if ($pays_code) print ' ';
+ $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 ' ';
+ }
+ else {
+ if (! $pays || $pays != $obj->libelle_pays) {
+ // Affiche la rupture si on est en mode liste multipays
+ if (! $pays_code && $obj->code_pays) {
+ print '----- '.$obj->libelle_pays." ----- \n";
+ $pays=$obj->libelle_pays;
+ }
+ }
+
+ if ($selected > 0 && $selected == $obj->code)
+ {
+ print '';
+ }
+ else
+ {
+ print ' ';
+ }
+ // Si traduction existe, on l'utilise, sinon on prend le libellé par défaut
+ print $obj->code . ' - ' .($langs->trans("JuridicalStatus".$obj->code)!="JuridicalStatus".$obj->code?$langs->trans("JuridicalStatus".$obj->code):($obj->nom!='-'?$obj->nom:''));
+ print ' ';
+ }
+ $i++;
+ }
+ }
+ print ' ';
+ if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1);
+ print '
';
+ }
+ else
+ {
+ dolibarr_print_error($this->db);
+ }
+ }
+
+
+ /**
+ * \brief Affiche formulaire de demande de confirmation
+ * \param page page
+ * \param title title
+ * \param question question
+ * \param action action
+ * \param formquestion an array with forms complementary inputs
+ */
+ function form_confirm($page, $title, $question, $action, $formquestion='')
+ {
+ global $langs;
+
+ print '\n";
+ }
+
+
+ /**
+ * \brief Affiche formulaire de selection de projet
+ * \param page Page
+ * \param socid Id societe
+ * \param selected Id projet pré-sélectionné
+ * \param htmlname Nom du formulaire select
+ */
+ function form_project($page, $socid, $selected='', $htmlname='projectid')
+ {
+ global $langs;
+
+ require_once(DOL_DOCUMENT_ROOT."/lib/project.lib.php");
+
+ $langs->load("project");
+ if ($htmlname != "none")
+ {
+ print '';
+ }
+ else
+ {
+ if ($selected) {
+ $projet = new Project($this->db);
+ $projet->fetch($selected);
+ print ''.$projet->title.' ';
+ } else {
+ print " ";
+ }
+ }
+ }
+
+ /**
+ * \brief Affiche formulaire de selection de conditions de paiement
+ * \param page Page
+ * \param selected Id condition pré-sélectionné
+ * \param htmlname Nom du formulaire select
+ * \param addempty Ajoute entrée vide
+ */
+ function form_conditions_reglement($page, $selected='', $htmlname='cond_reglement_id', $addempty=0)
+ {
+ global $langs;
+ if ($htmlname != "none")
+ {
+ print '';
+ }
+ else
+ {
+ if ($selected)
+ {
+ $this->load_cache_conditions_paiements();
+ print $this->cache_conditions_paiements[$selected]['label'];
+ } else {
+ print " ";
+ }
+ }
+ }
+
+ /**
+ * \brief Affiche formulaire de selection de l'assujétissement à la TVA
+ * \param page Page
+ * \param selected Id condition pré-sélectionnée
+ * \param htmlname Nom du formulaire select
+ */
function form_assujetti_tva($page, $selected='', $htmlname='')
- {
- global $langs;
+ {
+ global $langs;
$options = array(0=>"non",1=>"oui");
- if ($htmlname != "none")
- {
- print '';
- }
- else
- {
- if ($selected != "")
- {
- print $options[$selected];
- } else {
- print " ";
- }
- }
- }
+ if ($htmlname != "none")
+ {
+ print '';
+ }
+ else
+ {
+ if ($selected != "")
+ {
+ print $options[$selected];
+ } else {
+ print " ";
+ }
+ }
+ }
- /**
- * \brief Affiche formulaire de selection des modes de reglement
- * \param page Page
- * \param selected Id mode pré-sélectionné
- * \param htmlname Nom du formulaire select
- */
- function form_modes_reglement($page, $selected='', $htmlname='mode_reglement_id')
- {
- global $langs;
- if ($htmlname != "none")
- {
- print '';
- }
- else
- {
- if ($selected)
- {
- $this->load_cache_types_paiements();
- print $this->cache_types_paiements[$selected]['label'];
- } else {
- print " ";
- }
- }
- }
+ /**
+ * \brief Affiche formulaire de selection des modes de reglement
+ * \param page Page
+ * \param selected Id mode pré-sélectionné
+ * \param htmlname Nom du formulaire select
+ */
+ function form_modes_reglement($page, $selected='', $htmlname='mode_reglement_id')
+ {
+ global $langs;
+ if ($htmlname != "none")
+ {
+ print '';
+ }
+ else
+ {
+ if ($selected)
+ {
+ $this->load_cache_types_paiements();
+ print $this->cache_types_paiements[$selected]['label'];
+ } else {
+ print " ";
+ }
+ }
+ }
- /**
- * \brief Affiche formulaire de selection des modes de reglement
- * \param page Page
- * \param selected Id or code preselected
- * \param htmlname Nom du formulaire select
+ /**
+ * \brief Affiche formulaire de selection des modes de reglement
+ * \param page Page
+ * \param selected Id or code preselected
+ * \param htmlname Nom du formulaire select
* \param empty Add empty value in list
- */
- function form_prospect_level($page, $selected='', $htmlname='prospect_level_id', $empty=0)
- {
- global $langs;
-
+ */
+ function form_prospect_level($page, $selected='', $htmlname='prospect_level_id', $empty=0)
+ {
+ global $langs;
+
print '';
- }
+ }
- /**
- * \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 '';
+ }
+ else
+ {
+ if ($selected)
+ {
+ print $selected;
+ } else {
+ print "0%";
+ }
+ }
+ }
+
+
+ /**
+ * \brief Affiche formulaire de selection de la remise fixe
+ * \param page Page URL where form is shown
+ * \param selected Value pre-selected
+ * \param htmlname Nom du formulaire select. Si none, non modifiable
+ * \param socid Third party id
+ * \param amount Total amount available
+ * \param filter SQL filter on discounts
+ * \param maxvalue Max value for lines that can be selected
+ */
+ function form_remise_dispo($page, $selected='', $htmlname='remise_id',$socid, $amount, $filter='', $maxvalue=0)
+ {
+ global $conf,$langs;
+ if ($htmlname != "none")
+ {
+ print '';
print ' ';
- print ' ';
+ }
+ else
+ {
+ if ($selected)
+ {
+ print $selected;
+ }
else
{
- print "0";
- }
- }
- }
-
-
- /**
- * \brief Affiche formulaire de selection des contacts
- * \param page Page
- * \param selected Id contact pré-sélectionné
- * \param htmlname Nom du formulaire select
- */
- function form_contacts($page, $societe, $selected='', $htmlname='contactidp')
- {
- global $langs;
- if ($htmlname != "none")
- {
- print '';
- print ' ';
- print ' ';
- }
- else
- {
- if ($selected)
- {
+ }
+ }
+
+
+ /**
+ * \brief Affiche formulaire de selection des contacts
+ * \param page Page
+ * \param selected Id contact pré-sélectionné
+ * \param htmlname Nom du formulaire select
+ */
+ function form_contacts($page, $societe, $selected='', $htmlname='contactidp')
+ {
+ global $langs;
+ if ($htmlname != "none")
+ {
+ print '';
+ print ' ';
+ print ' ';
+ }
+ 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);
+ //$this->load_cache_contacts();
+ //print $this->cache_contacts[$selected];
+ $contact=new Contact($this->db);
$contact->fetch($selected);
- print $contact->nom.' '.$contact->prenom;
- } else {
- print " ";
- }
- }
- }
+ print $contact->nom.' '.$contact->prenom;
+ } else {
+ print " ";
+ }
+ }
+ }
- /**
- * \brief Affiche formulaire de selection de l'adresse de livraison
- * \param page Page
- * \param selected Id condition pré-sélectionné
- * \param htmlname Nom du formulaire select
- * \param origin Origine de l'appel pour pouvoir créer un retour
- * \param originid Id de l'origine
- */
- function form_adresse_livraison($page, $selected='', $socid, $htmlname='adresse_livraison_id', $origin='', $originid='')
- {
- global $langs,$conf;
- if ($htmlname != "none")
- {
- print '';
- print ' ';
- print ' ';
- }
- else
- {
- if ($selected)
- {
- require_once(DOL_DOCUMENT_ROOT ."/comm/adresse_livraison.class.php");
- $livraison=new AdresseLivraison($this->db);
- $livraison->fetch_adresse($selected);
- print 'socid.'&idl='.$livraison->idl.'&action=edit&origin='.$origin.'&originid='.$originid.'>'.$livraison->label.' ';
- }
- else
- {
- print " ";
- }
- }
- }
-
- /**
- * \brief Retourne la liste des devises, dans la langue de l'utilisateur
- * \param selected code devise pré-sélectionné
- * \param htmlname nom de la liste deroulante
- * \todo trier liste sur noms après traduction plutot que avant
- */
- function select_currency($selected='',$htmlname='currency_id')
- {
- global $conf,$langs,$user;
- $langs->load("dict");
-
- if ($selected=='euro' || $selected=='euros') $selected='EUR'; // Pour compatibilité
-
- $sql = "SELECT code, code_iso, label, active";
+ /**
+ * \brief Affiche formulaire de selection de l'adresse de livraison
+ * \param page Page
+ * \param selected Id condition pré-sélectionné
+ * \param htmlname Nom du formulaire select
+ * \param origin Origine de l'appel pour pouvoir créer un retour
+ * \param originid Id de l'origine
+ */
+ function form_adresse_livraison($page, $selected='', $socid, $htmlname='adresse_livraison_id', $origin='', $originid='')
+ {
+ global $langs,$conf;
+ if ($htmlname != "none")
+ {
+ print '';
+ print ' ';
+ print ' ';
+ }
+ else
+ {
+ if ($selected)
+ {
+ require_once(DOL_DOCUMENT_ROOT ."/comm/adresse_livraison.class.php");
+ $livraison=new AdresseLivraison($this->db);
+ $livraison->fetch_adresse($selected);
+ print 'socid.'&idl='.$livraison->idl.'&action=edit&origin='.$origin.'&originid='.$originid.'>'.$livraison->label.' ';
+ }
+ else
+ {
+ print " ";
+ }
+ }
+ }
+
+ /**
+ * \brief Retourne la liste des devises, dans la langue de l'utilisateur
+ * \param selected code devise pré-sélectionné
+ * \param htmlname nom de la liste deroulante
+ * \todo trier liste sur noms après traduction plutot que avant
+ */
+ function select_currency($selected='',$htmlname='currency_id')
+ {
+ global $conf,$langs,$user;
+ $langs->load("dict");
+
+ if ($selected=='euro' || $selected=='euros') $selected='EUR'; // Pour compatibilité
+
+ $sql = "SELECT code, code_iso, label, active";
$sql.= " FROM ".MAIN_DB_PREFIX."c_currencies";
- $sql.= " WHERE active = 1";
- $sql.= " ORDER BY code_iso ASC";
-
- $resql=$this->db->query($sql);
+ $sql.= " WHERE active = 1";
+ $sql.= " ORDER BY code_iso ASC";
+
+ $resql=$this->db->query($sql);
if ($resql)
- {
- print '';
- $num = $this->db->num_rows($resql);
- $i = 0;
- if ($num)
- {
- $foundselected=false;
- while ($i < $num)
- {
- $obj = $this->db->fetch_object($resql);
- if ($selected && $selected == $obj->code_iso)
- {
- $foundselected=true;
- print '';
- }
- else
- {
- print ' ';
- }
- if ($obj->code_iso) { print $obj->code_iso . ' - '; }
- // Si traduction existe, on l'utilise, sinon on prend le libellé par défaut
- 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 ' ';
- $i++;
- }
- }
- print ' ';
+ {
+ print '';
+ $num = $this->db->num_rows($resql);
+ $i = 0;
+ if ($num)
+ {
+ $foundselected=false;
+ while ($i < $num)
+ {
+ $obj = $this->db->fetch_object($resql);
+ if ($selected && $selected == $obj->code_iso)
+ {
+ $foundselected=true;
+ print '';
+ }
+ else
+ {
+ print ' ';
+ }
+ if ($obj->code_iso) { print $obj->code_iso . ' - '; }
+ // Si traduction existe, on l'utilise, sinon on prend le libellé par défaut
+ 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 ' ';
+ $i++;
+ }
+ }
+ print ' ';
if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1);
- return 0;
- }
- else {
- dolibarr_print_error($this->db);
- return 1;
- }
- }
+ return 0;
+ }
+ else {
+ dolibarr_print_error($this->db);
+ return 1;
+ }
+ }
- /**
- * \brief Selection du taux de tva à appliquer
- * \param name Nom champ html
- * \param selectedrate Forçage du taux tva pré-sélectionné. Mettre '' pour aucun forcage.
- * \param societe_vendeuse Objet société vendeuse
- * \param societe_acheteuse Objet société acheteuse
- * \param taux_produit Taux par defaut du produit vendu
- * \param info_bits Miscellanous information on line
- * \remarks Si vendeur non assujeti à TVA, TVA par défaut=0. Fin de règle.
- * Si le (pays vendeur = pays acheteur) alors la TVA par défaut=TVA du produit vendu. Fin de règle.
- * Si (vendeur et acheteur dans Communauté européenne) et bien vendu = moyen de transports neuf (auto, bateau, avion), TVA par défaut=0 (La TVA doit être payé par l'acheteur au centre d'impots de son pays et non au vendeur). Fin de règle.
- * Si (vendeur et acheteur dans Communauté européenne) et bien vendu autre que transport neuf alors la TVA par défaut=TVA du produit vendu. Fin de règle.
- * Sinon la TVA proposée par défaut=0. Fin de règle.
- */
- function select_tva($name='tauxtva', $selectedrate='', $societe_vendeuse='', $societe_acheteuse='', $taux_produit='', $info_bits=0)
+ /**
+ * \brief Selection du taux de tva à appliquer
+ * \param name Nom champ html
+ * \param selectedrate Forçage du taux tva pré-sélectionné. Mettre '' pour aucun forcage.
+ * \param societe_vendeuse Objet société vendeuse
+ * \param societe_acheteuse Objet société acheteuse
+ * \param taux_produit Taux par defaut du produit vendu
+ * \param info_bits Miscellanous information on line
+ * \remarks Si vendeur non assujeti à TVA, TVA par défaut=0. Fin de règle.
+ * Si le (pays vendeur = pays acheteur) alors la TVA par défaut=TVA du produit vendu. Fin de règle.
+ * Si (vendeur et acheteur dans Communauté européenne) et bien vendu = moyen de transports neuf (auto, bateau, avion), TVA par défaut=0 (La TVA doit être payé par l'acheteur au centre d'impots de son pays et non au vendeur). Fin de règle.
+ * Si (vendeur et acheteur dans Communauté européenne) et bien vendu autre que transport neuf alors la TVA par défaut=TVA du produit vendu. Fin de règle.
+ * Sinon la TVA proposée par défaut=0. Fin de règle.
+ */
+ function select_tva($name='tauxtva', $selectedrate='', $societe_vendeuse='', $societe_acheteuse='', $taux_produit='', $info_bits=0)
{
global $langs,$conf,$mysoc;
@@ -2496,7 +2498,7 @@ class Form
}
return;
}
-
+
if (is_object($societe_vendeuse))
{
$code_pays=$societe_vendeuse->pays_code;
@@ -2505,14 +2507,14 @@ class Form
{
$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)
{
@@ -2535,8 +2537,8 @@ class Form
else
{
print ''.$this->db->error().' ';
- }
-
+ }
+
// Définition du taux à pré-sélectionner (si defaulttx non forcé et donc vaut -1 ou '')
if ($defaulttx < 0 || strlen($defaulttx) == 0)
{
@@ -2549,13 +2551,13 @@ class Form
{
$defaulttx = $txtva[sizeof($txtva)-1];
}
-
+
$nbdetaux = sizeof($txtva);
-
+
if (sizeof($txtva))
{
print '';
-
+
for ($i = 0 ; $i < $nbdetaux ; $i++)
{
//print "xxxxx".$txtva[$i]."-".$nprtva[$i];
@@ -2569,7 +2571,7 @@ class Form
print '>'.vatrate($libtva[$i]);
print $nprtva[$i] ? ' *': '';
print '';
-
+
$this->tva_taux_value[$i] = $txtva[$i];
$this->tva_taux_libelle[$i] = $libtva[$i];
$this->tva_taux_npr[$i] = $nprtva[$i];
@@ -2581,36 +2583,36 @@ class Form
- /**
- * \brief Selection des unites de mesure
- * \param name Nom champ html
- * \param measuring_style Le style de mesure : weight, volume,...
- * \param default Forçage de l'unite
- * \remarks pour l'instant on ne definit pas les unites dans la base
- */
- function select_measuring_units($name='measuring_units', $measuring_style='', $default='0', $adddefault=0)
- {
+ /**
+ * \brief Selection des unites de mesure
+ * \param name Nom champ html
+ * \param measuring_style Le style de mesure : weight, volume,...
+ * \param default Forçage de l'unite
+ * \remarks pour l'instant on ne definit pas les unites dans la base
+ */
+ function select_measuring_units($name='measuring_units', $measuring_style='', $default='0', $adddefault=0)
+ {
global $langs,$conf,$mysoc;
$langs->load("other");
-
+
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("VolumeUnitdm3");
- $measuring_units[-6] = $langs->trans("VolumeUnitcm3");
- $measuring_units[-9] = $langs->trans("VolumeUnitmm3");
- }
-
+ $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("VolumeUnitdm3");
+ $measuring_units[-6] = $langs->trans("VolumeUnitcm3");
+ $measuring_units[-9] = $langs->trans("VolumeUnitmm3");
+ }
+
print '';
if ($adddefault) print ''.$langs->trans("Default").' ';
-
+
foreach ($measuring_units as $key => $value)
{
print ''.$value.' ';
}
print ' ';
- }
-
+ }
- /**
- * \brief Affiche zone de selection de date
- * Liste deroulante pour les jours, mois, annee et eventuellement heurs et minutes
- * Les champs sont pré-sélectionnés 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 ''
- * - Aucune date (champs vides) si set_time vaut -1 (dans ce cas empty doit valoir 1)
+
+ /**
+ * \brief Affiche zone de selection de date
+ * Liste deroulante pour les jours, mois, annee et eventuellement heurs et minutes
+ * Les champs sont pré-sélectionnés 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 ''
+ * - Aucune date (champs vides) si set_time vaut -1 (dans ce cas empty doit valoir 1)
* \param set_time Date de pré-sélection
* \param prefix Prefix pour nom champ
* \param h 1=Affiche aussi les heures
@@ -2638,60 +2640,60 @@ class Form
* \param empty 0=Champ obligatoire, 1=Permet une saisie vide
* \param form_name Nom du formulaire de provenance. Utilisé pour les dates en popup style andre.
* \param d 1=Affiche aussi les jours, mois, annees
- */
+ */
function select_date($set_time='', $prefix='re', $h=0, $m=0, $empty=0, $form_name="", $d=1)
- {
- global $conf,$langs;
+ {
+ global $conf,$langs;
- if($prefix=='') $prefix='re';
+ if($prefix=='') $prefix='re';
if($h == '') $h=0;
if($m == '') $m=0;
if($empty == '') $empty=0;
-
- if (! $set_time && $empty == 0) $set_time = time();
- // Analyse de la date de pré-selection
- if (eregi('^([0-9]+)\-([0-9]+)\-([0-9]+)\s?([0-9]+)?:?([0-9]+)?',$set_time,$reg))
- {
- // Date au format 'YYYY-MM-DD' ou 'YYYY-MM-DD HH:MM:SS'
- $syear = $reg[1];
- $smonth = $reg[2];
- $sday = $reg[3];
- $shour = $reg[4];
- $smin = $reg[5];
- }
- elseif (strval($set_time) != '' && $set_time != -1)
- {
- // Date est un timestamps (0 possible)
- $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);
- }
- else
- {
- // Date est '' ou vaut -1
- $syear = '';
- $smonth = '';
- $sday = '';
- $shour = '';
- $smin = '';
- }
+ if (! $set_time && $empty == 0) $set_time = time();
- if ($d)
- {
- /*
- * Affiche date en popup
- */
+ // Analyse de la date de pré-selection
+ if (eregi('^([0-9]+)\-([0-9]+)\-([0-9]+)\s?([0-9]+)?:?([0-9]+)?',$set_time,$reg))
+ {
+ // Date au format 'YYYY-MM-DD' ou 'YYYY-MM-DD HH:MM:SS'
+ $syear = $reg[1];
+ $smonth = $reg[2];
+ $sday = $reg[3];
+ $shour = $reg[4];
+ $smin = $reg[5];
+ }
+ elseif (strval($set_time) != '' && $set_time != -1)
+ {
+ // Date est un timestamps (0 possible)
+ $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);
+ }
+ else
+ {
+ // Date est '' ou vaut -1
+ $syear = '';
+ $smonth = '';
+ $sday = '';
+ $shour = '';
+ $smin = '';
+ }
+
+ if ($d)
+ {
+ /*
+ * Affiche date en popup
+ */
if ($conf->use_javascript_ajax && $conf->use_popup_calendar)
- {
+ {
//print "e".$set_time." t ".$conf->format_date_short;
if (strval($set_time) != '' && $set_time != -1)
{
$formated_date=dolibarr_print_date($set_time,$conf->format_date_short);
}
-
+
// Calendrier popup version eldy
if ("$conf->use_popup_calendar" == "eldy") // Laisser conf->use_popup_calendar entre quote
{
@@ -2699,18 +2701,18 @@ class Form
print ' ';
-
+
// Icone calendrier
print ''.img_object($langs->trans("SelectDate"),'calendar').' ';
-
+
print ' '."\n";
print ' '."\n";
print ' '."\n";
}
else
- {
+ {
// Calendrier popup version defaut
if ($langs->defaultlang != "")
{
@@ -2726,152 +2728,152 @@ class Form
print ' '."\n";
print ' '."\n";
if($form_name =="")
- print ''.img_cal().' ';
+ print ''.img_cal().' ';
else
- print ''.img_cal().' ';
+ print ''.img_cal().' ';
+ }
+ }
+
+ /*
+ * Affiche date en select
+ */
+ if (! $conf->use_javascript_ajax || ! $conf->use_popup_calendar)
+ {
+ // Jour
+ print '';
+
+ if ($empty || $set_time == -1)
+ {
+ print ' ';
}
- }
-
- /*
- * Affiche date en select
- */
- if (! $conf->use_javascript_ajax || ! $conf->use_popup_calendar)
- {
- // Jour
- print '';
-
- if ($empty || $set_time == -1)
- {
- print ' ';
- }
-
- for ($day = 1 ; $day <= 31; $day++)
- {
- if ($day == $sday)
- {
- print "$day";
- }
- else
- {
- print " $day";
- }
- print " ";
- }
-
- print " ";
-
- print '';
- if ($empty || $set_time == -1)
- {
- print ' ';
- }
-
- // Mois
- for ($month = 1 ; $month <= 12 ; $month++)
- {
- print '';
- print dolibarr_print_date(mktime(1,1,1,$month,1,2000),"%b");
- print " ";
- }
- print " ";
-
- // Année
- if ($empty || $set_time == -1)
- {
- print ' ';
- }
- else
- {
- print '';
-
- for ($year = $syear - 5; $year < $syear + 10 ; $year++)
- {
- if ($year == $syear)
- {
- print "$year";
- }
- else
- {
- print " $year";
- }
- print " ";
- }
- print " \n";
- }
- }
- }
-
- if ($d && $h) print ' ';
-
- if ($h)
- {
- /*
- * Affiche heure en select
- */
- print '';
- if ($empty) print ' ';
- for ($hour = 0; $hour < 24; $hour++)
- {
- if (strlen($hour) < 2)
- {
- $hour = "0" . $hour;
- }
- if ($hour == $shour)
- {
- print "$hour ";
- }
- else
- {
- print "$hour ";
- }
- }
- print " ";
- print "H\n";
- }
-
- if ($m)
- {
- /*
- * Affiche min en select
- */
- print '';
- if ($empty) print ' ';
- for ($min = 0; $min < 60 ; $min++)
- {
- if (strlen($min) < 2)
- {
- $min = "0" . $min;
- }
- if ($min == $smin)
- {
- print "$min ";
- }
- else
- {
- print "$min ";
- }
- }
- print " ";
- print "M\n";
- }
- }
-
+ for ($day = 1 ; $day <= 31; $day++)
+ {
+ if ($day == $sday)
+ {
+ print "$day";
+ }
+ else
+ {
+ print " $day";
+ }
+ print " ";
+ }
+
+ print " ";
+
+ print '';
+ if ($empty || $set_time == -1)
+ {
+ print ' ';
+ }
+
+ // Mois
+ for ($month = 1 ; $month <= 12 ; $month++)
+ {
+ print '';
+ print dolibarr_print_date(mktime(1,1,1,$month,1,2000),"%b");
+ print " ";
+ }
+ print " ";
+
+ // Année
+ if ($empty || $set_time == -1)
+ {
+ print ' ';
+ }
+ else
+ {
+ print '';
+
+ for ($year = $syear - 5; $year < $syear + 10 ; $year++)
+ {
+ if ($year == $syear)
+ {
+ print "$year";
+ }
+ else
+ {
+ print " $year";
+ }
+ print " ";
+ }
+ print " \n";
+ }
+ }
+ }
+
+ if ($d && $h) print ' ';
+
+ if ($h)
+ {
+ /*
+ * Affiche heure en select
+ */
+ print '';
+ if ($empty) print ' ';
+ for ($hour = 0; $hour < 24; $hour++)
+ {
+ if (strlen($hour) < 2)
+ {
+ $hour = "0" . $hour;
+ }
+ if ($hour == $shour)
+ {
+ print "$hour ";
+ }
+ else
+ {
+ print "$hour ";
+ }
+ }
+ print " ";
+ print "H\n";
+ }
+
+ if ($m)
+ {
+ /*
+ * Affiche min en select
+ */
+ print '';
+ if ($empty) print ' ';
+ for ($min = 0; $min < 60 ; $min++)
+ {
+ if (strlen($min) < 2)
+ {
+ $min = "0" . $min;
+ }
+ if ($min == $smin)
+ {
+ print "$min ";
+ }
+ else
+ {
+ print "$min ";
+ }
+ }
+ print " ";
+ print "M\n";
+ }
+
+ }
+
/**
- \brief Fonction servant a afficher une durée dans une liste déroulante
- \param prefix prefix
- \param iSecond Nombre de secondes
- */
+ \brief Fonction servant a afficher une durée dans une liste déroulante
+ \param prefix prefix
+ \param iSecond Nombre de secondes
+ */
function select_duree($prefix,$iSecond='')
{
if ($iSecond)
{
require_once(DOL_DOCUMENT_ROOT."/lib/date.lib.php");
-
+
$hourSelected = ConvertSecondToTime($iSecond,'hour');
$minSelected = ConvertSecondToTime($iSecond,'min');
}
-
+
print '';
for ($hour = 0; $hour < 24; $hour++)
{
@@ -2879,7 +2881,7 @@ class Form
if ($hourSelected == $hour || ($iSecond == '' && $hour == 1))
{
print " selected=\"true\"";
- }
+ }
print ">".$hour."";
}
print " ";
@@ -2896,236 +2898,236 @@ class Form
}
- /**
- \brief Affiche un select à partir d'un tableau
- \param htmlname Nom de la zone select
- \param array Tableau de key+valeur
- \param id Preselected key
- \param show_empty 1 si il faut ajouter une valeur vide dans la liste, 0 sinon
- \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é
- \param optionType Type de l'option: 1 pour des fonctions javascript
- \param option Valeur de l'option en fonction du type choisi
- \param translate Traduire la valeur
- */
- function select_array($htmlname, $array, $id='', $show_empty=0, $key_in_label=0, $value_as_key=0, $optionType=0, $option='', $translate=0)
- {
- global $langs;
- // \TODO Simplify optionType and option (only one should be necessary)
- if ($optionType == 1 && $option != '')
- {
- print '';
- }
- else
- {
- print '';
- }
-
- if ($show_empty)
- {
- print ' '."\n";
- }
-
- while (list($key, $value) = each ($array))
- {
- print '';
-
- if ($key_in_label)
- {
- $selectOptionValue = $key.' - '.($translate?$langs->trans($value):$value);
- print $selectOptionValue;
- }
- else
- {
- $selectOptionValue = ($translate?$langs->trans($value):$value);
- if ($value == '' || $value == '-') { $selectOptionValue=' '; }
- print $selectOptionValue;
- }
- print " \n";
- }
-
- print " ";
- }
+ /**
+ \brief Affiche un select à partir d'un tableau
+ \param htmlname Nom de la zone select
+ \param array Tableau de key+valeur
+ \param id Preselected key
+ \param show_empty 1 si il faut ajouter une valeur vide dans la liste, 0 sinon
+ \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é
+ \param optionType Type de l'option: 1 pour des fonctions javascript
+ \param option Valeur de l'option en fonction du type choisi
+ \param translate Traduire la valeur
+ */
+ function select_array($htmlname, $array, $id='', $show_empty=0, $key_in_label=0, $value_as_key=0, $optionType=0, $option='', $translate=0)
+ {
+ global $langs;
+ // \TODO Simplify optionType and option (only one should be necessary)
+ if ($optionType == 1 && $option != '')
+ {
+ print '';
+ }
+ else
+ {
+ print '';
+ }
+ if ($show_empty)
+ {
+ print ' '."\n";
+ }
- /**
- * \brief Selection de oui/non en chaine (renvoie yes/no)
- * \param name Nom du select
- * \param value Valeur pré-sélectionné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";
- }
+ while (list($key, $value) = each ($array))
+ {
+ print ''."\n";
- if (("$value" == 'yes') || ($value == 1))
- {
- $resultyesno .= ' '.$langs->trans("yes").' '."\n";
- $resultyesno .= ''.$langs->trans("no").' '."\n";
- }
- else
- {
- $resultyesno .= ''.$langs->trans("yes").' '."\n";
- $resultyesno .= ''.$langs->trans("no").' '."\n";
- }
- $resultyesno .= ' '."\n";
- return $resultyesno;
- }
-
+ print '>';
+
+ if ($key_in_label)
+ {
+ $selectOptionValue = $key.' - '.($translate?$langs->trans($value):$value);
+ print $selectOptionValue;
+ }
+ else
+ {
+ $selectOptionValue = ($translate?$langs->trans($value):$value);
+ if ($value == '' || $value == '-') { $selectOptionValue=' '; }
+ print $selectOptionValue;
+ }
+ print "\n";
+ }
+
+ print " ";
+ }
/**
- * \brief Retourne la liste des modèles d'export
- * \param selected Id modèle pré-sélectionné
- * \param htmlname Nom de la zone select
- * \param type Type des modèles recherchés
- * \param useempty Affiche valeur vide dans liste
- */
- function select_export_model($selected='',$htmlname='exportmodelid',$type='',$useempty=0)
- {
-
- $sql = "SELECT rowid, label";
- $sql.= " FROM ".MAIN_DB_PREFIX."export_model";
- $sql.= " WHERE type = '".$type."'";
- $sql.= " ORDER BY rowid";
- $result = $this->db->query($sql);
- if ($result)
- {
- print '';
- if ($useempty)
- {
- print ' ';
- }
+ * \brief Selection de oui/non en chaine (renvoie yes/no)
+ * \param name Nom du select
+ * \param value Valeur pré-sélectionnée
+ * \param option 0 retourne yes/no, 1 retourne 1/0
+ */
+ function selectyesno($name,$value='',$option=0)
+ {
+ global $langs;
- $num = $this->db->num_rows($result);
- $i = 0;
- while ($i < $num)
- {
- $obj = $this->db->fetch_object($result);
- if ($selected == $obj->rowid)
- {
- print '';
- }
- else
- {
- print ' ';
- }
- print $obj->label;
- print ' ';
- $i++;
- }
- print " ";
- }
- else {
- dolibarr_print_error($this->db);
- }
- }
-
- /**
- * \brief Retourne la liste des mois
- * \param selected Id mois pré-sélectionné
- * \param htmlname Nom de la zone select
- * \param useempty Affiche valeur vide dans liste
- */
- function select_month($selected='',$htmlname='monthid',$useempty=0)
- {
- $month = monthArrayOrSelected(-1); // Get array
+ $yes="yes"; $no="no";
- $select_month = '';
- if ($useempty)
- {
- $select_month .= ' ';
- }
- foreach ($month as $key => $val)
- {
- if ($selected == $key)
- {
- $select_month .= '';
- }
- else
- {
- $select_month .= ' ';
- }
- $select_month .= $val;
- }
- $select_month .= ' ';
- return $select_month;
- }
- /**
- * \brief Retourne la liste des années
- * \param selected Année pré-sélectionné
- * \param htmlname Nom de la zone select
- * \param useempty Affiche valeur vide dans liste
- * \param $min_year Valeur minimum de l'année dans la liste (par défaut année courante -10)
- * \param $max_year Valeur maximum de l'année dans la liste (par défaut année courante + 5)
- */
- function select_year($selected='',$htmlname='yearid',$useempty=0, $min_year='', $max_year='')
- {
- if($max_year == '')
- $max_year = date("Y") +5;
- if($min_year == '')
- $min_year = date("Y") - 10;
-
- print '';
- if($useempty)
- {
- if($selected == '')
- $selected_html = 'selected="true"';
- print ' ';
- }
- for ($y = $max_year; $y >= $min_year; $y--)
- {
- $selected_html='';
- if ($y == $selected)
- {
- $selected_html = 'selected="true"';
- }
- print "$y";
- print " ";
- }
- print " \n";
- }
+ if ($option)
+ {
+ $yes="1";
+ $no="0";
+ }
- /**
- * \brief Affiche tableau avec ref et bouton navigation pour un objet metier
- * \param object Object to show
- * \param paramid Nom du parametre a utiliser pour nommer id dans liens URL
- * \param morehtml Code html supplementaire a afficher avant barre nav
+ $resultyesno = ''."\n";
+ if (("$value" == 'yes') || ($value == 1))
+ {
+ $resultyesno .= ''.$langs->trans("yes").' '."\n";
+ $resultyesno .= ''.$langs->trans("no").' '."\n";
+ }
+ else
+ {
+ $resultyesno .= ''.$langs->trans("yes").' '."\n";
+ $resultyesno .= ''.$langs->trans("no").' '."\n";
+ }
+ $resultyesno .= ' '."\n";
+ return $resultyesno;
+ }
+
+
+
+ /**
+ * \brief Retourne la liste des modèles d'export
+ * \param selected Id modèle pré-sélectionné
+ * \param htmlname Nom de la zone select
+ * \param type Type des modèles recherchés
+ * \param useempty Affiche valeur vide dans liste
+ */
+ function select_export_model($selected='',$htmlname='exportmodelid',$type='',$useempty=0)
+ {
+
+ $sql = "SELECT rowid, label";
+ $sql.= " FROM ".MAIN_DB_PREFIX."export_model";
+ $sql.= " WHERE type = '".$type."'";
+ $sql.= " ORDER BY rowid";
+ $result = $this->db->query($sql);
+ if ($result)
+ {
+ print '';
+ if ($useempty)
+ {
+ print ' ';
+ }
+
+ $num = $this->db->num_rows($result);
+ $i = 0;
+ while ($i < $num)
+ {
+ $obj = $this->db->fetch_object($result);
+ if ($selected == $obj->rowid)
+ {
+ print '';
+ }
+ else
+ {
+ print ' ';
+ }
+ print $obj->label;
+ print ' ';
+ $i++;
+ }
+ print " ";
+ }
+ else {
+ dolibarr_print_error($this->db);
+ }
+ }
+
+ /**
+ * \brief Retourne la liste des mois
+ * \param selected Id mois pré-sélectionné
+ * \param htmlname Nom de la zone select
+ * \param useempty Affiche valeur vide dans liste
+ */
+ function select_month($selected='',$htmlname='monthid',$useempty=0)
+ {
+ $month = monthArrayOrSelected(-1); // Get array
+
+ $select_month = '';
+ if ($useempty)
+ {
+ $select_month .= ' ';
+ }
+ foreach ($month as $key => $val)
+ {
+ if ($selected == $key)
+ {
+ $select_month .= '';
+ }
+ else
+ {
+ $select_month .= ' ';
+ }
+ $select_month .= $val;
+ }
+ $select_month .= ' ';
+ return $select_month;
+ }
+ /**
+ * \brief Retourne la liste des années
+ * \param selected Année pré-sélectionné
+ * \param htmlname Nom de la zone select
+ * \param useempty Affiche valeur vide dans liste
+ * \param $min_year Valeur minimum de l'année dans la liste (par défaut année courante -10)
+ * \param $max_year Valeur maximum de l'année dans la liste (par défaut année courante + 5)
+ */
+ function select_year($selected='',$htmlname='yearid',$useempty=0, $min_year='', $max_year='')
+ {
+ if($max_year == '')
+ $max_year = date("Y") +5;
+ if($min_year == '')
+ $min_year = date("Y") - 10;
+
+ print '';
+ if($useempty)
+ {
+ if($selected == '')
+ $selected_html = 'selected="true"';
+ print ' ';
+ }
+ for ($y = $max_year; $y >= $min_year; $y--)
+ {
+ $selected_html='';
+ if ($y == $selected)
+ {
+ $selected_html = 'selected="true"';
+ }
+ print "$y";
+ print " ";
+ }
+ print " \n";
+ }
+
+ /**
+ * \brief Affiche tableau avec ref et bouton navigation pour un objet metier
+ * \param object Object to show
+ * \param paramid Nom du parametre a utiliser pour nommer id dans liens URL
+ * \param morehtml Code html supplementaire a afficher avant barre nav
* \param shownav Show Condition
- * \param fieldid Nom du champ a utiliser pour select next et previous
- * \return string Portion HTML avec ref + boutons nav
- */
+ * \param fieldid Nom du champ a utiliser pour select next et previous
+ * \return string Portion HTML avec ref + boutons nav
+ */
function showrefnav($object,$paramid,$morehtml='',$shownav=1,$fieldid='rowid',$fieldref='ref')
{
$ret='';
- $object->load_previous_next_ref($object->next_prev_filter,$fieldid);
- $previous_ref = $object->ref_previous?'ref_previous).'">'.img_previous().' ':'';
- $next_ref = $object->ref_next?'ref_next).'">'.img_next().' ':'';
+ $object->load_previous_next_ref($object->next_prev_filter,$fieldid);
+ $previous_ref = $object->ref_previous?'ref_previous).'">'.img_previous().' ':'';
+ $next_ref = $object->ref_next?'ref_next).'">'.img_next().' ':'';
//print "xx".$previous_ref."x".$next_ref;
if ($previous_ref || $next_ref || $morehtml) {
$ret.='';
}
-
+
$ret.=$object->$fieldref;
-
+
if ($morehtml) {
$ret.=' '.$morehtml;
}
@@ -3137,25 +3139,25 @@ class Form
{
$ret.='
';
}
- return $ret;
+ return $ret;
}
-
+
/**
- * \brief Retourne la liste des ecotaxes avec tooltip sur le libelle
- * \param selected code ecotaxes pre-selectionne
- * \param htmlname nom de la liste deroulante
- */
+ * \brief Retourne la liste des ecotaxes avec tooltip sur le libelle
+ * \param selected code ecotaxes pre-selectionne
+ * \param htmlname nom de la liste deroulante
+ */
function select_ecotaxes($selected='',$htmlname='ecotaxe_id')
{
global $langs;
-
+
$sql = "SELECT e.rowid, e.code, e.libelle, e.price, e.organization,";
$sql.= " p.libelle as pays";
$sql.= " FROM ".MAIN_DB_PREFIX."c_ecotaxe as e,".MAIN_DB_PREFIX."c_pays as p";
$sql.= " WHERE e.active = 1 AND e.fk_pays = p.rowid";
$sql.= " ORDER BY pays, e.organization ASC, e.code ASC";
-
+
if ($this->db->query($sql))
{
print '';
@@ -3191,7 +3193,7 @@ class Form
return 1;
}
}
-
+
}
?>