mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-12-25 10:51:34 +01:00
227 lines
7.0 KiB
PHP
227 lines
7.0 KiB
PHP
<?PHP
|
|
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
|
* Copyright (C) 2004 Laurent Destailleur <eldy@users.sourceforge.net>
|
|
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
|
|
*
|
|
* 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
|
|
|
|
// Nom des tables des dictionnaires
|
|
$tabid[1] = "llx_c_forme_juridique";
|
|
$tabid[2] = "llx_c_departements";
|
|
$tabid[3] = "llx_c_regions";
|
|
$tabid[4] = "llx_c_pays";
|
|
$tabid[5] = "llx_c_civilite";
|
|
|
|
// Libellé des dictionnaires
|
|
$tabnom[1] = "Formes juridiques";
|
|
$tabnom[2] = "Départements/Provinces/Cantons";
|
|
$tabnom[3] = "Régions";
|
|
$tabnom[4] = "Pays";
|
|
$tabnom[5] = "Titres de civilité";
|
|
|
|
// Requete pour extraction des données des dictionnaires
|
|
$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";
|
|
$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";
|
|
$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";
|
|
$tabsql[4] = "SELECT rowid, code, libelle, active FROM llx_c_pays";
|
|
$tabsql[5] = "SELECT c.rowid AS rowid, c.civilite AS libelle, c.active FROM llx_c_civilite AS c, llx_c_pays AS p WHERE c.fk_pays = p.rowid";
|
|
|
|
// Tri par defaut
|
|
$tabsqlsort[1]="p.rowid, code ASC";
|
|
$tabsqlsort[2]="p.rowid, code ASC";
|
|
$tabsqlsort[3]="p.rowid, code ASC";
|
|
$tabsqlsort[4]="code ASC";
|
|
$tabsqlsort[5]="libelle ASC";
|
|
|
|
// Champs à afficher
|
|
$tabfield[1] = "code,libelle,pays";
|
|
$tabfield[2] = "code,libelle,pays";
|
|
$tabfield[3] = "code,libelle,pays";
|
|
$tabfield[4] = "code,libelle";
|
|
$tabfield[5] = "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");
|
|
print '<br>';
|
|
|
|
// Complète requete recherche valeurs avec critere de tri
|
|
$sql=$tabsql[$_GET["id"]];
|
|
if ($_GET["sortfield"]) {
|
|
$sql .= " ORDER BY ".$_GET["sortfield"];
|
|
if ($_GET["sortorder"]) {
|
|
$sql.=" ".$_GET["sortorder"];
|
|
}
|
|
$sql.=", ";
|
|
}
|
|
else {
|
|
$sql.=" ORDER BY ";
|
|
}
|
|
$sql.=$tabsqlsort[$_GET["id"]];
|
|
|
|
$fieldlist=split(',',$tabfield[$_GET["id"]]);
|
|
print '<table class="noborder" cellpadding="3" cellspacing="0" width="100%">';
|
|
|
|
// Ligne d'ajout
|
|
if ($tabid[$_GET["id"]]) {
|
|
print_titre($tabnom[$_GET["id"]]);
|
|
$var=False;
|
|
$fieldlist=split(',',$tabfield[$_GET["id"]]);
|
|
print '<table class="noborder" cellpadding="3" cellspacing="0" width="100%">';
|
|
|
|
print '<tr class="liste_titre">';
|
|
foreach ($fieldlist as $field => $value) {
|
|
print '<td>';
|
|
print ucfirst($fieldlist[$field]);
|
|
print '</td>';
|
|
}
|
|
print '<td> </td>';
|
|
print '</td>';
|
|
|
|
print "<tr $bc[$var] class=\"value\">";
|
|
foreach ($fieldlist as $field => $value) {
|
|
if ($fieldlist[$field] == 'pays') {
|
|
$html = new Form($db);
|
|
print '<td>';
|
|
$html->select_pays();
|
|
print '</td>';
|
|
}
|
|
else {
|
|
print '<td><input type="text" value="" name="'.$fieldlist[$field].'"></td>';
|
|
}
|
|
}
|
|
print '<td colspan=2><input type="submit" name="Ajouter" value="Ajouter"></td>';
|
|
print "</tr>";
|
|
print '<tr><td colspan="'.(count($fieldlist)+2).'"></td></tr>';
|
|
}
|
|
|
|
// Affiche table des valeurs
|
|
if ($db->query($sql))
|
|
{
|
|
$num = $db->num_rows();
|
|
$i = 0;
|
|
$var=False;
|
|
if ($num)
|
|
{
|
|
print '<tr class="liste_titre">';
|
|
foreach ($fieldlist as $field => $value) {
|
|
print '<td>';
|
|
print_liste_field_titre(ucfirst($fieldlist[$field]),$PHP_SELF,$fieldlist[$field],"&id=".$_GET["id"]);
|
|
print '</td>';
|
|
}
|
|
print '<td>';
|
|
print_liste_field_titre("Activer/Désactiver",$PHP_SELF,"active","&id=".$_GET["id"]);
|
|
print '</td>';
|
|
print '</tr>';
|
|
|
|
|
|
while ($i < $num)
|
|
{
|
|
$obj = $db->fetch_object($i);
|
|
$var=!$var;
|
|
|
|
print "<tr $bc[$var] class=\"value\">";
|
|
|
|
foreach ($fieldlist as $field => $value) {
|
|
print '<td>'.$obj->$fieldlist[$field].'</td>';
|
|
}
|
|
print '<td>';
|
|
if ($obj->code) {
|
|
print '<a href="'.$PHP_SELF.'?sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.$obj->rowid.'&code='.$obj->code.'&id='.$_GET["id"].'&action='.$acts[$obj->active].'">'.$actl[$obj->active].'</a>';
|
|
} else {
|
|
print '<a href="'.$PHP_SELF.'?sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.$obj->rowid.'&code='.$obj->code.'&id='.$_GET["id"].'&action='.$acts[$obj->active].'">'.$actl[$obj->active].'</a>';
|
|
}
|
|
print "</td>";
|
|
|
|
print "</tr>\n";
|
|
$i++;
|
|
}
|
|
}
|
|
}
|
|
else {
|
|
print "Erreur : $sql : ".$db->error();
|
|
}
|
|
|
|
print '</table>';
|
|
}
|
|
else
|
|
{
|
|
print_titre("Configuration des dictionnaires de données");
|
|
print '<br>';
|
|
|
|
foreach ($tabid as $i => $value) {
|
|
print '<a href="dict.php?id='.$i.'">'.$tabnom[$i].'</a> (Table '.$tabid[$i].')<br>';
|
|
}
|
|
}
|
|
|
|
print '<br>';
|
|
|
|
$db->close();
|
|
|
|
llxFooter();
|
|
|
|
|
|
?>
|