Fix: choice of country in list of juridal status

This commit is contained in:
Laurent Destailleur 2008-02-17 15:20:47 +00:00
parent 5dc5b85269
commit ce08087a41
5 changed files with 176 additions and 166 deletions

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2007 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be> * Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
* Copyright (C) 2005-2007 Regis Houssin <regis@dolibarr.fr> * Copyright (C) 2005-2007 Regis Houssin <regis@dolibarr.fr>
* *
@ -521,11 +521,12 @@ if ($_GET["id"])
{ {
// Ligne de titre // Ligne de titre
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
foreach ($fieldlist as $field => $value) { foreach ($fieldlist as $field => $value)
{
// Determine le nom du champ par rapport aux noms possibles // Determine le nom du champ par rapport aux noms possibles
// dans les dictionnaires de données // dans les dictionnaires de données
$showfield=1; // Par defaut $showfield=1; // Par defaut
$valuetoshow=ucfirst($fieldlist[$field]); // Par defaut $valuetoshow=ucfirst($fieldlist[$field]); // Par defaut
if ($fieldlist[$field]=='source') { $valuetoshow=$langs->trans("Contact"); } if ($fieldlist[$field]=='source') { $valuetoshow=$langs->trans("Contact"); }
if ($fieldlist[$field]=='price') { $valuetoshow=$langs->trans("PriceUHT"); } if ($fieldlist[$field]=='price') { $valuetoshow=$langs->trans("PriceUHT"); }
if ($fieldlist[$field]=='organization') { $valuetoshow=$langs->trans("Organization"); } if ($fieldlist[$field]=='organization') { $valuetoshow=$langs->trans("Organization"); }
@ -571,52 +572,52 @@ if ($_GET["id"])
print '&nbsp;<input type="submit" class="button" name="actioncancel" value="'.$langs->trans("Cancel").'"></td>'; print '&nbsp;<input type="submit" class="button" name="actioncancel" value="'.$langs->trans("Cancel").'"></td>';
} }
else else
{ {
foreach ($fieldlist as $field => $value) foreach ($fieldlist as $field => $value)
{ {
$showfield=1; $showfield=1;
$valuetoshow=$obj->$fieldlist[$field]; $valuetoshow=$obj->$fieldlist[$field];
if ($valuetoshow=='all') { if ($valuetoshow=='all') {
$valuetoshow=$langs->trans('All'); $valuetoshow=$langs->trans('All');
} }
if ($fieldlist[$field]=='recuperableonly' || $fieldlist[$field]=='fdm') { if ($fieldlist[$field]=='recuperableonly' || $fieldlist[$field]=='fdm') {
$valuetoshow=yn($valuetoshow); $valuetoshow=yn($valuetoshow);
} }
if ($fieldlist[$field]=='price') { if ($fieldlist[$field]=='price') {
$valuetoshow=price($valuetoshow); $valuetoshow=price($valuetoshow);
} }
if ($fieldlist[$field]=='region_id' || $fieldlist[$field]=='pays_id') { if ($fieldlist[$field]=='region_id' || $fieldlist[$field]=='pays_id') {
$showfield=0; $showfield=0;
} }
if ($showfield) print '<td>'.$valuetoshow.'</td>'; if ($showfield) print '<td>'.$valuetoshow.'</td>';
} }
print '<td align="center" nowrap="nowrap">'; print '<td align="center" nowrap="nowrap">';
// Est-ce une entrée du dictionnaire qui peut etre désactivée ? // Est-ce une entrée du dictionnaire qui peut etre désactivée ?
$iserasable=1; // Oui par defaut $iserasable=1; // Oui par defaut
if (isset($obj->code) && ($obj->code == '0' || $obj->code == '' || eregi('unknown',$obj->code))) $iserasable=0; if (isset($obj->code) && ($obj->code == '0' || $obj->code == '' || eregi('unknown',$obj->code))) $iserasable=0;
if ($obj->type && $obj->type == 'system') $iserasable=0; if ($obj->type && $obj->type == 'system') $iserasable=0;
if ($iserasable) { if ($iserasable) {
print '<a href="'."dict.php".'?sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.($obj->rowid?$obj->rowid:$obj->code).'&amp;code='.$obj->code.'&amp;id='.$_GET["id"].'&amp;action='.$acts[$obj->active].'">'.$actl[$obj->active].'</a>'; print '<a href="'."dict.php".'?sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.($obj->rowid?$obj->rowid:$obj->code).'&amp;code='.$obj->code.'&amp;id='.$_GET["id"].'&amp;action='.$acts[$obj->active].'">'.$actl[$obj->active].'</a>';
} else { } else {
print $langs->trans("AlwaysActive"); print $langs->trans("AlwaysActive");
} }
print "</td>"; print "</td>";
if ($iserasable) { if ($iserasable) {
print '<td align="center"><a href="dict.php?sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.($obj->rowid?$obj->rowid:$obj->code).'&amp;code='.$obj->code.'&amp;id='.$_GET["id"].'&amp;action=modify#'.($obj->rowid?$obj->rowid:$obj->code).'">'.img_edit().'</a></td>'; print '<td align="center"><a href="dict.php?sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.($obj->rowid?$obj->rowid:$obj->code).'&amp;code='.$obj->code.'&amp;id='.$_GET["id"].'&amp;action=modify#'.($obj->rowid?$obj->rowid:$obj->code).'">'.img_edit().'</a></td>';
} else { } else {
print '<td>&nbsp;</td>'; print '<td>&nbsp;</td>';
} }
if ($iserasable) { if ($iserasable) {
print '<td align="center"><a href="dict.php?sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.($obj->rowid?$obj->rowid:$obj->code).'&amp;code='.$obj->code.'&amp;id='.$_GET["id"].'&amp;action=delete">'.img_delete().'</a></td>'; print '<td align="center"><a href="dict.php?sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.($obj->rowid?$obj->rowid:$obj->code).'&amp;code='.$obj->code.'&amp;id='.$_GET["id"].'&amp;action=delete">'.img_delete().'</a></td>';
} else { } else {
print '<td>&nbsp;</td>'; print '<td>&nbsp;</td>';
} }
print "</tr>\n"; print "</tr>\n";
} }
$i++; $i++;
} }
} }
@ -680,91 +681,92 @@ llxFooter('$Date$ - $Revision$');
function fieldList($fieldlist,$obj='') function fieldList($fieldlist,$obj='')
{ {
global $conf,$langs,$db; global $conf,$langs,$db;
global $region_id,$pays_id; global $region_id;
$html = new Form($db); $html = new Form($db);
foreach ($fieldlist as $field => $value) foreach ($fieldlist as $field => $value)
{ {
if ($fieldlist[$field] == 'pays') { if ($fieldlist[$field] == 'pays') {
print '<td>'; //var_dump($obj);
$html->select_pays($pays_id,'pays'); print '<td>';
print '</td>'; $html->select_pays($obj->pays,'pays');
} print '</td>';
elseif ($fieldlist[$field] == 'pays_id') { }
$pays_id = $obj->$fieldlist[$field]?$obj->$fieldlist[$field]:0; elseif ($fieldlist[$field] == 'pays_id') {
print '<input type="hidden" name="'.$fieldlist[$field].'" value="'.$pays_id.'">'; $pays_id = (! empty($obj->$fieldlist[$field])) ? $obj->$fieldlist[$field] : 0;
} print '<input type="hidden" name="'.$fieldlist[$field].'" value="'.$pays_id.'">';
elseif ($fieldlist[$field] == 'region') { }
print '<td>'; elseif ($fieldlist[$field] == 'region') {
$html->select_region($region_id,'region'); print '<td>';
print '</td>'; $html->select_region($region_id,'region');
} print '</td>';
elseif ($fieldlist[$field] == 'region_id') { }
$region_id = $obj->$fieldlist[$field]?$obj->$fieldlist[$field]:0; elseif ($fieldlist[$field] == 'region_id') {
print '<input type="hidden" name="'.$fieldlist[$field].'" value="'.$region_id.'">'; $region_id = $obj->$fieldlist[$field]?$obj->$fieldlist[$field]:0;
} print '<input type="hidden" name="'.$fieldlist[$field].'" value="'.$region_id.'">';
elseif ($fieldlist[$field] == 'lang') { }
print '<td>'; elseif ($fieldlist[$field] == 'lang') {
$html->select_lang($conf->global->MAIN_LANG_DEFAULT,'lang'); print '<td>';
print '</td>'; $html->select_lang($conf->global->MAIN_LANG_DEFAULT,'lang');
} print '</td>';
// Le type de l'element (pour les type de contact).' }
elseif ($fieldlist[$field] == 'element') // Le type de l'element (pour les type de contact).'
{ elseif ($fieldlist[$field] == 'element')
$langs->load("orders"); {
$langs->load("contracts"); $langs->load("orders");
$langs->load("project"); $langs->load("contracts");
$langs->load("propal"); $langs->load("project");
$langs->load("bills"); $langs->load("propal");
print '<td>'; $langs->load("bills");
$elementList = array("commande"=>$langs->trans("Order"), print '<td>';
"contrat"=>$langs->trans("Contract"), $elementList = array("commande"=>$langs->trans("Order"),
"projet"=>$langs->trans("Project"), "contrat"=>$langs->trans("Contract"),
"propal"=>$langs->trans("Propal"), "projet"=>$langs->trans("Project"),
"facture"=>$langs->trans("Bill")); "propal"=>$langs->trans("Propal"),
$html->select_array('element', $elementList,$obj->$fieldlist[$field]); "facture"=>$langs->trans("Bill"));
print '</td>'; $html->select_array('element', $elementList,$obj->$fieldlist[$field]);
} print '</td>';
// La source de l'element (pour les type de contact).' }
elseif ($fieldlist[$field] == 'source') // La source de l'element (pour les type de contact).'
{ elseif ($fieldlist[$field] == 'source')
print '<td>'; {
$elementList = array("internal"=>$langs->trans("Internal"), print '<td>';
"external"=>$langs->trans("External")); $elementList = array("internal"=>$langs->trans("Internal"),
$html->select_array('source', $elementList,$obj->$fieldlist[$field]); "external"=>$langs->trans("External"));
print '</td>'; $html->select_array('source', $elementList,$obj->$fieldlist[$field]);
} print '</td>';
elseif ($fieldlist[$field] == 'type' && $tabname[$_GET["id"]] == MAIN_DB_PREFIX."c_actioncomm") }
{ elseif ($fieldlist[$field] == 'type' && $tabname[$_GET["id"]] == MAIN_DB_PREFIX."c_actioncomm")
print '<td>'; {
print 'user<input type="hidden" name="type" value="user">'; print '<td>';
print '</td>'; print 'user<input type="hidden" name="type" value="user">';
} print '</td>';
elseif ($fieldlist[$field] == 'recuperableonly' || $fieldlist[$field] == 'fdm') { }
print '<td>'; elseif ($fieldlist[$field] == 'recuperableonly' || $fieldlist[$field] == 'fdm') {
print $html->selectyesno($fieldlist[$field],$obj->$fieldlist[$field],1); print '<td>';
print '</td>'; print $html->selectyesno($fieldlist[$field],$obj->$fieldlist[$field],1);
} print '</td>';
elseif ($fieldlist[$field] == 'nbjour' || $fieldlist[$field] == 'decalage' || $fieldlist[$field] == 'taux') { }
print '<td><input type="text" class="flat" value="'.$obj->$fieldlist[$field].'" size="3" name="'.$fieldlist[$field].'"></td>'; elseif ($fieldlist[$field] == 'nbjour' || $fieldlist[$field] == 'decalage' || $fieldlist[$field] == 'taux') {
} print '<td><input type="text" class="flat" value="'.$obj->$fieldlist[$field].'" size="3" name="'.$fieldlist[$field].'"></td>';
elseif ($fieldlist[$field] == 'price') { }
print '<td><input type="text" class="flat" value="'.price($obj->$fieldlist[$field]).'" size="8" name="'.$fieldlist[$field].'"></td>'; elseif ($fieldlist[$field] == 'price') {
} print '<td><input type="text" class="flat" value="'.price($obj->$fieldlist[$field]).'" size="8" name="'.$fieldlist[$field].'"></td>';
elseif ($fieldlist[$field] == 'code') { }
print '<td><input type="text" class="flat" value="'.$obj->$fieldlist[$field].'" size="10" name="'.$fieldlist[$field].'"></td>'; elseif ($fieldlist[$field] == 'code') {
} print '<td><input type="text" class="flat" value="'.$obj->$fieldlist[$field].'" size="10" name="'.$fieldlist[$field].'"></td>';
elseif ($fieldlist[$field]=='unit') { }
print '<td>'; elseif ($fieldlist[$field]=='unit') {
$html->select_array('unit',array('mm','cm','point','inch'),$obj->$fieldlist[$field],0,0,1); print '<td>';
print '</td>'; $html->select_array('unit',array('mm','cm','point','inch'),$obj->$fieldlist[$field],0,0,1);
} print '</td>';
else }
{ else
print '<td><input type="text" class="flat" value="'.$obj->$fieldlist[$field].'" name="'.$fieldlist[$field].'" ></td>'; {
} print '<td><input type="text" class="flat" value="'.$obj->$fieldlist[$field].'" name="'.$fieldlist[$field].'" ></td>';
} }
}
} }
?> ?>

View File

@ -23,13 +23,12 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Id$
*/ */
/** /**
\file htdocs/html.form.class.php \file htdocs/html.form.class.php
\brief Fichier de la classe des fonctions prédéfinie de composants html \brief Fichier de la classe des fonctions prédéfinie de composants html
\version $Id$
*/ */
@ -370,7 +369,7 @@ class Form
/** /**
* \brief Retourne la liste déroulante des pays actifs, dans la langue de l'utilisateur * \brief Retourne la liste déroulante des pays actifs, dans la langue de l'utilisateur
* \param selected Id ou code pays pré-sélectionné * \param selected Id ou Code pays ou Libelle pays pré-sélectionné
* \param htmlname Nom de la liste deroulante * \param htmlname Nom de la liste deroulante
* \param htmloption Options html sur le select * \param htmloption Options html sur le select
* \todo trier liste sur noms après traduction plutot que avant * \todo trier liste sur noms après traduction plutot que avant
@ -441,32 +440,33 @@ class Form
{ {
print '<select class="flat" name="'.$htmlname.'" '.$htmloption.'>'; print '<select class="flat" name="'.$htmlname.'" '.$htmloption.'>';
$num = $this->db->num_rows($resql); $num = $this->db->num_rows($resql);
$i = 0; $i = 0;
if ($num) if ($num)
{ {
$foundselected=false; $foundselected=false;
while ($i < $num) while ($i < $num)
{ {
$obj = $this->db->fetch_object($resql); $obj = $this->db->fetch_object($resql);
if ($selected && $selected != '-1' && ($selected == $obj->rowid || $selected == $obj->code)) if ($selected && $selected != '-1' &&
{ ($selected == $obj->rowid || $selected == $obj->code || $selected == $obj->libelle) )
$foundselected=true; {
print '<option value="'.$obj->rowid.'" selected="true">'; $foundselected=true;
} print '<option value="'.$obj->rowid.'" selected="true">';
else }
{ else
print '<option value="'.$obj->rowid.'">'; {
} print '<option value="'.$obj->rowid.'">';
// Si traduction existe, on l'utilise, sinon on prend le libellé par défaut }
if ($obj->code) { print $obj->code . ' - '; } // Si traduction existe, on l'utilise, sinon on prend le libellé par défaut
print ($obj->code && $langs->trans("Country".$obj->code)!="Country".$obj->code?$langs->trans("Country".$obj->code):($obj->libelle!='-'?$obj->libelle:'&nbsp;')); if ($obj->code) { print $obj->code . ' - '; }
print '</option>'; print ($obj->code && $langs->trans("Country".$obj->code)!="Country".$obj->code?$langs->trans("Country".$obj->code):($obj->libelle!='-'?$obj->libelle:'&nbsp;'));
$i++; print '</option>';
} $i++;
} }
print '</select>'; }
return 0; print '</select>';
} return 0;
}
} }
else else
{ {

View File

@ -215,6 +215,8 @@ function dolibarr_del_const($db, $name)
$sql = "DELETE FROM llx_const"; $sql = "DELETE FROM llx_const";
$sql.=" WHERE name='".addslashes($name)."' or rowid='".addslashes($name)."'"; $sql.=" WHERE name='".addslashes($name)."' or rowid='".addslashes($name)."'";
dolibarr_syslog("admin.lib::dolibarr_del_const sql=".$sql);
$resql=$db->query($sql); $resql=$db->query($sql);
if ($resql) if ($resql)
{ {
@ -241,6 +243,8 @@ function dolibarr_get_const($db, $name)
$sql ="SELECT value"; $sql ="SELECT value";
$sql.=" FROM llx_const"; $sql.=" FROM llx_const";
$sql.=" WHERE name = '".addslashes($name)."'"; $sql.=" WHERE name = '".addslashes($name)."'";
dolibarr_syslog("admin.lib::dolibarr_get_const sql=".$sql);
$resql=$db->query($sql); $resql=$db->query($sql);
if ($resql) if ($resql)
{ {
@ -260,13 +264,13 @@ function dolibarr_get_const($db, $name)
\param type Type de constante (chaine par défaut) \param type Type de constante (chaine par défaut)
\param visible La constante est elle visible (0 par défaut) \param visible La constante est elle visible (0 par défaut)
\param note Explication de la constante \param note Explication de la constante
\return int <0 si ko, >0 si ok \return int <0 si ko, >0 si ok
*/ */
function dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $note='') function dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $note='')
{ {
global $conf; global $conf;
if (! $name) if (empty($name))
{ {
dolibarr_print_error("Error: Call to function dolibarr_set_const with wrong parameters", LOG_ERR); dolibarr_print_error("Error: Call to function dolibarr_set_const with wrong parameters", LOG_ERR);
exit; exit;
@ -276,12 +280,15 @@ function dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $not
//dolibarr_syslog("dolibarr_set_const name=$name, value=$value"); //dolibarr_syslog("dolibarr_set_const name=$name, value=$value");
$sql = "DELETE FROM llx_const WHERE name = '".addslashes($name)."';"; $sql = "DELETE FROM llx_const WHERE name = '".addslashes($name)."';";
$resql=$db->query($sql); dolibarr_syslog("admin.lib::dolibarr_set_const sql=".$sql);
$resql=$db->query($sql);
if (strcmp($value,'')) // true if different. Must work for $value='0' or $value=0 if (strcmp($value,'')) // true if different. Must work for $value='0' or $value=0
{ {
$sql = "INSERT INTO llx_const(name,value,type,visible,note)"; $sql = "INSERT INTO llx_const(name,value,type,visible,note)";
$sql.= " VALUES ('".$name."','".addslashes($value)."','".$type."',".$visible.",'".addslashes($note)."')"; $sql.= " VALUES ('".$name."','".addslashes($value)."','".$type."',".$visible.",'".addslashes($note)."')";
dolibarr_syslog("admin.lib::dolibarr_set_const sql=".$sql);
$resql=$db->query($sql); $resql=$db->query($sql);
} }
@ -298,6 +305,4 @@ function dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $not
} }
} }
?> ?>

View File

@ -188,4 +188,6 @@ create table llx_events
ALTER TABLE llx_events ADD INDEX idx_events_dateevent (dateevent); ALTER TABLE llx_events ADD INDEX idx_events_dateevent (dateevent);
ALTER TABLE llx_c_forme_juridique ADD isvatexempted tinyint DEFAULT 0 NOT NULL after libelle;

View File

@ -21,11 +21,12 @@
create table llx_c_forme_juridique create table llx_c_forme_juridique
( (
rowid integer AUTO_INCREMENT PRIMARY KEY, rowid integer AUTO_INCREMENT PRIMARY KEY,
code varchar(12) UNIQUE NOT NULL, code varchar(12) UNIQUE NOT NULL,
fk_pays integer NOT NULL, fk_pays integer NOT NULL,
libelle varchar(255), libelle varchar(255),
active tinyint DEFAULT 1 NOT NULL isvatexempted tinyint DEFAULT 0 NOT NULL,
active tinyint DEFAULT 1 NOT NULL
)type=innodb; )type=innodb;