* Copyright (C) 2004 Laurent Destailleur * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * $Id$ * $Source$ */ require("./pre.inc.php"); $acts[0] = "add"; $acts[1] = "delete"; $actl[0] = "Activer"; $actl[1] = "Désactiver"; $active = 1; // Mettre ici tous les caractéristiques des dictionnaires editables $tabid[1] = "llx_c_forme_juridique"; $tabid[2] = "llx_c_departements"; $tabid[3] = "llx_c_regions"; $tabid[4] = "llx_c_pays"; $tabnom[1] = "Formes juridiques"; $tabnom[2] = "Départements/Provinces/Cantons"; $tabnom[3] = "Régions"; $tabnom[4] = "Pays"; $tabsql[1] = "SELECT f.code, f.libelle, p.libelle as pays, f.active FROM llx_c_forme_juridique as f, llx_c_pays as p WHERE f.fk_pays=p.rowid ORDER BY p.rowid, f.active DESC, code ASC"; $tabsql[2] = "SELECT d.rowid as rowid, d.code_departement as code , d.nom as libelle, p.libelle as pays, d.active FROM llx_c_departements as d, llx_c_regions as r, llx_c_pays as p WHERE d.fk_region=r.code_region and r.fk_pays=p.rowid ORDER BY p.rowid, d.active DESC, code ASC"; $tabsql[3] = "SELECT r.rowid as rowid, code_region as code , nom as libelle, p.libelle as pays, r.active FROM llx_c_regions as r, llx_c_pays as p WHERE r.fk_pays=p.rowid ORDER BY p.rowid, r.active DESC, code ASC"; $tabsql[4] = "SELECT rowid, code, libelle, active FROM llx_c_pays ORDER BY active DESC, code ASC"; // Champs à afficher $tabfield[1] = "code,libelle,pays"; $tabfield[2] = "code,libelle,pays"; $tabfield[3] = "code,libelle,pays"; $tabfield[4] = "code,libelle"; if (! $user->admin) accessforbidden(); if ($_GET["action"] == 'delete') { if ($_GET["rowid"] >0) { $sql = "UPDATE ".$tabid[$_GET["id"]]." SET active = 0 WHERE rowid=".$_GET["rowid"]; } elseif ($_GET["code"] >0) { $sql = "UPDATE ".$tabid[$_GET["id"]]." SET active = 0 WHERE code=".$_GET["code"]; } $result = $db->query($sql); if (!$result) { print $db->error(); } } if ($_GET["action"] == 'add') { $sql = "UPDATE ".$tabid[$_GET["id"]]." SET active = 1 WHERE rowid=".$_GET["rowid"]; $result = $db->query($sql); if (!$result) { print $db->error(); } } llxHeader(); if ($_GET["id"]) { print_titre("Configuration des dictionnaires de données : ".$tabnom[$_GET["id"]]); print '
'; // Affiche table des valeurs $sql=$tabsql[$_GET["id"]]; if ($db->query($sql)) { $num = $db->num_rows(); $i = 0; $var=True; if ($num) { print ''; print ''; $fieldlist=split(',',$tabfield[$_GET["id"]]); foreach ($fieldlist as $field => $value) { print ''; } print ''; print ''; print ''; while ($i < $num) { $obj = $db->fetch_object($i); $var=!$var; print ""; foreach ($fieldlist as $field => $value) { print ''; } if ($obj->active) { print '"; } else print ''; if (! $obj->active) { print '"; } else print ''; print "\n"; $i++; } print '
'.ucfirst($fieldlist[$field]).'ActifInactif
'.$obj->$fieldlist[$field].''; print ''.$actl[$obj->active].''; print " '; print ''.$actl[$obj->active].''; print " 
'; } } else { print "Erreur : $sql : ".$db->error(); } } else { print_titre("Configuration des dictionnaires de données"); print '
'; foreach ($tabid as $i => $value) { print ''.$tabnom[$i].' (Table '.$tabid[$i].')
'; } } print '
'; $db->close(); llxFooter(); ?>