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
/* 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) 2005-2007 Regis Houssin <regis@dolibarr.fr>
*
@ -521,11 +521,12 @@ if ($_GET["id"])
{
// Ligne de 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
// dans les dictionnaires de données
$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]=='price') { $valuetoshow=$langs->trans("PriceUHT"); }
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>';
}
else
{
foreach ($fieldlist as $field => $value)
{
$showfield=1;
$valuetoshow=$obj->$fieldlist[$field];
{
foreach ($fieldlist as $field => $value)
{
$showfield=1;
$valuetoshow=$obj->$fieldlist[$field];
if ($valuetoshow=='all') {
$valuetoshow=$langs->trans('All');
}
if ($fieldlist[$field]=='recuperableonly' || $fieldlist[$field]=='fdm') {
$valuetoshow=yn($valuetoshow);
}
if ($fieldlist[$field]=='price') {
$valuetoshow=price($valuetoshow);
}
if ($fieldlist[$field]=='region_id' || $fieldlist[$field]=='pays_id') {
$showfield=0;
}
if ($showfield) print '<td>'.$valuetoshow.'</td>';
}
if ($valuetoshow=='all') {
$valuetoshow=$langs->trans('All');
}
if ($fieldlist[$field]=='recuperableonly' || $fieldlist[$field]=='fdm') {
$valuetoshow=yn($valuetoshow);
}
if ($fieldlist[$field]=='price') {
$valuetoshow=price($valuetoshow);
}
if ($fieldlist[$field]=='region_id' || $fieldlist[$field]=='pays_id') {
$showfield=0;
}
if ($showfield) print '<td>'.$valuetoshow.'</td>';
}
print '<td align="center" nowrap="nowrap">';
// Est-ce une entrée du dictionnaire qui peut etre désactivée ?
$iserasable=1; // Oui par defaut
if (isset($obj->code) && ($obj->code == '0' || $obj->code == '' || eregi('unknown',$obj->code))) $iserasable=0;
if ($obj->type && $obj->type == 'system') $iserasable=0;
print '<td align="center" nowrap="nowrap">';
// Est-ce une entrée du dictionnaire qui peut etre désactivée ?
$iserasable=1; // Oui par defaut
if (isset($obj->code) && ($obj->code == '0' || $obj->code == '' || eregi('unknown',$obj->code))) $iserasable=0;
if ($obj->type && $obj->type == 'system') $iserasable=0;
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>';
} else {
print $langs->trans("AlwaysActive");
}
print "</td>";
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>';
} else {
print '<td>&nbsp;</td>';
}
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>';
} else {
print '<td>&nbsp;</td>';
}
print "</tr>\n";
}
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>';
} else {
print $langs->trans("AlwaysActive");
}
print "</td>";
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>';
} else {
print '<td>&nbsp;</td>';
}
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>';
} else {
print '<td>&nbsp;</td>';
}
print "</tr>\n";
}
$i++;
}
}
@ -680,91 +681,92 @@ llxFooter('$Date$ - $Revision$');
function fieldList($fieldlist,$obj='')
{
global $conf,$langs,$db;
global $region_id,$pays_id;
global $region_id;
$html = new Form($db);
foreach ($fieldlist as $field => $value)
{
if ($fieldlist[$field] == 'pays') {
print '<td>';
$html->select_pays($pays_id,'pays');
print '</td>';
}
elseif ($fieldlist[$field] == 'pays_id') {
$pays_id = $obj->$fieldlist[$field]?$obj->$fieldlist[$field]:0;
print '<input type="hidden" name="'.$fieldlist[$field].'" value="'.$pays_id.'">';
}
elseif ($fieldlist[$field] == 'region') {
print '<td>';
$html->select_region($region_id,'region');
print '</td>';
}
elseif ($fieldlist[$field] == '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>';
$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')
{
$langs->load("orders");
$langs->load("contracts");
$langs->load("project");
$langs->load("propal");
$langs->load("bills");
print '<td>';
$elementList = array("commande"=>$langs->trans("Order"),
"contrat"=>$langs->trans("Contract"),
"projet"=>$langs->trans("Project"),
"propal"=>$langs->trans("Propal"),
"facture"=>$langs->trans("Bill"));
$html->select_array('element', $elementList,$obj->$fieldlist[$field]);
print '</td>';
}
// La source de l'element (pour les type de contact).'
elseif ($fieldlist[$field] == 'source')
{
print '<td>';
$elementList = array("internal"=>$langs->trans("Internal"),
"external"=>$langs->trans("External"));
$html->select_array('source', $elementList,$obj->$fieldlist[$field]);
print '</td>';
}
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>';
}
elseif ($fieldlist[$field] == 'recuperableonly' || $fieldlist[$field] == 'fdm') {
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] == '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]=='unit') {
print '<td>';
$html->select_array('unit',array('mm','cm','point','inch'),$obj->$fieldlist[$field],0,0,1);
print '</td>';
}
else
{
print '<td><input type="text" class="flat" value="'.$obj->$fieldlist[$field].'" name="'.$fieldlist[$field].'" ></td>';
}
}
{
if ($fieldlist[$field] == 'pays') {
//var_dump($obj);
print '<td>';
$html->select_pays($obj->pays,'pays');
print '</td>';
}
elseif ($fieldlist[$field] == '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>';
$html->select_region($region_id,'region');
print '</td>';
}
elseif ($fieldlist[$field] == '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>';
$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')
{
$langs->load("orders");
$langs->load("contracts");
$langs->load("project");
$langs->load("propal");
$langs->load("bills");
print '<td>';
$elementList = array("commande"=>$langs->trans("Order"),
"contrat"=>$langs->trans("Contract"),
"projet"=>$langs->trans("Project"),
"propal"=>$langs->trans("Propal"),
"facture"=>$langs->trans("Bill"));
$html->select_array('element', $elementList,$obj->$fieldlist[$field]);
print '</td>';
}
// La source de l'element (pour les type de contact).'
elseif ($fieldlist[$field] == 'source')
{
print '<td>';
$elementList = array("internal"=>$langs->trans("Internal"),
"external"=>$langs->trans("External"));
$html->select_array('source', $elementList,$obj->$fieldlist[$field]);
print '</td>';
}
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>';
}
elseif ($fieldlist[$field] == 'recuperableonly' || $fieldlist[$field] == 'fdm') {
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] == '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]=='unit') {
print '<td>';
$html->select_array('unit',array('mm','cm','point','inch'),$obj->$fieldlist[$field],0,0,1);
print '</td>';
}
else
{
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
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Id$
*/
/**
\file htdocs/html.form.class.php
\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
* \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 htmloption Options html sur le select
* \todo trier liste sur noms après traduction plutot que avant
@ -441,32 +440,33 @@ class Form
{
print '<select class="flat" name="'.$htmlname.'" '.$htmloption.'>';
$num = $this->db->num_rows($resql);
$i = 0;
if ($num)
{
$foundselected=false;
while ($i < $num)
{
$obj = $this->db->fetch_object($resql);
if ($selected && $selected != '-1' && ($selected == $obj->rowid || $selected == $obj->code))
{
$foundselected=true;
print '<option value="'.$obj->rowid.'" selected="true">';
}
else
{
print '<option value="'.$obj->rowid.'">';
}
// Si traduction existe, on l'utilise, sinon on prend le libellé par défaut
if ($obj->code) { print $obj->code . ' - '; }
print ($obj->code && $langs->trans("Country".$obj->code)!="Country".$obj->code?$langs->trans("Country".$obj->code):($obj->libelle!='-'?$obj->libelle:'&nbsp;'));
print '</option>';
$i++;
}
}
print '</select>';
return 0;
}
$i = 0;
if ($num)
{
$foundselected=false;
while ($i < $num)
{
$obj = $this->db->fetch_object($resql);
if ($selected && $selected != '-1' &&
($selected == $obj->rowid || $selected == $obj->code || $selected == $obj->libelle) )
{
$foundselected=true;
print '<option value="'.$obj->rowid.'" selected="true">';
}
else
{
print '<option value="'.$obj->rowid.'">';
}
// Si traduction existe, on l'utilise, sinon on prend le libellé par défaut
if ($obj->code) { print $obj->code . ' - '; }
print ($obj->code && $langs->trans("Country".$obj->code)!="Country".$obj->code?$langs->trans("Country".$obj->code):($obj->libelle!='-'?$obj->libelle:'&nbsp;'));
print '</option>';
$i++;
}
}
print '</select>';
return 0;
}
}
else
{

View File

@ -215,6 +215,8 @@ function dolibarr_del_const($db, $name)
$sql = "DELETE FROM llx_const";
$sql.=" WHERE name='".addslashes($name)."' or rowid='".addslashes($name)."'";
dolibarr_syslog("admin.lib::dolibarr_del_const sql=".$sql);
$resql=$db->query($sql);
if ($resql)
{
@ -241,6 +243,8 @@ function dolibarr_get_const($db, $name)
$sql ="SELECT value";
$sql.=" FROM llx_const";
$sql.=" WHERE name = '".addslashes($name)."'";
dolibarr_syslog("admin.lib::dolibarr_get_const sql=".$sql);
$resql=$db->query($sql);
if ($resql)
{
@ -260,13 +264,13 @@ function dolibarr_get_const($db, $name)
\param type Type de constante (chaine par défaut)
\param visible La constante est elle visible (0 par défaut)
\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='')
{
global $conf;
if (! $name)
if (empty($name))
{
dolibarr_print_error("Error: Call to function dolibarr_set_const with wrong parameters", LOG_ERR);
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");
$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
{
$sql = "INSERT INTO llx_const(name,value,type,visible,note)";
$sql.= " VALUES ('".$name."','".addslashes($value)."','".$type."',".$visible.",'".addslashes($note)."')";
dolibarr_syslog("admin.lib::dolibarr_set_const sql=".$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_c_forme_juridique ADD isvatexempted tinyint DEFAULT 0 NOT NULL after libelle;

View File

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