2004-10-19 20:58:50 +02:00
|
|
|
|
<?php
|
2003-02-14 18:14:29 +01:00
|
|
|
|
/* Copyright (C) 2001-2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
2004-07-17 14:41:15 +02:00
|
|
|
|
* Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org>
|
2005-03-06 01:14:19 +01:00
|
|
|
|
* Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net>
|
2003-02-14 18:14:29 +01:00
|
|
|
|
*
|
|
|
|
|
|
* 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$
|
|
|
|
|
|
*/
|
2004-08-14 14:37:59 +02:00
|
|
|
|
|
2005-03-06 01:14:19 +01:00
|
|
|
|
/** \file htdocs/adherents/options.php
|
2004-08-14 14:37:59 +02:00
|
|
|
|
\ingroup adherent
|
|
|
|
|
|
\brief Page de configuratin des champs optionnels
|
|
|
|
|
|
\version $Revision$
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
2003-09-01 00:05:54 +02:00
|
|
|
|
require("./pre.inc.php");
|
|
|
|
|
|
require(DOL_DOCUMENT_ROOT."/adherents/adherent_options.class.php");
|
2003-02-14 18:14:29 +01:00
|
|
|
|
|
2005-03-06 01:14:19 +01:00
|
|
|
|
$langs->load("members");
|
|
|
|
|
|
|
2003-02-14 18:14:29 +01:00
|
|
|
|
$adho = new AdherentOptions($db);
|
2003-03-10 17:55:11 +01:00
|
|
|
|
$form = new Form($db);
|
2003-02-14 18:14:29 +01:00
|
|
|
|
|
2004-07-17 14:41:15 +02:00
|
|
|
|
if ($_POST["action"] == 'add' && $user->admin)
|
2003-02-14 18:14:29 +01:00
|
|
|
|
{
|
2004-08-29 18:11:37 +02:00
|
|
|
|
if ($_POST["button"] != $langs->trans("Cancel")) {
|
2004-07-17 14:41:15 +02:00
|
|
|
|
// Type et taille non encore pris en compte => varchar(255)
|
|
|
|
|
|
if (isset($_POST["attrname"]) && preg_match("/^\w[a-zA-Z0-9-]*$/",$_POST['attrname'])){
|
|
|
|
|
|
$adho->create($_POST['attrname'],$_POST['type'],$_POST['size']);
|
|
|
|
|
|
}
|
|
|
|
|
|
if (isset($_POST['label'])){
|
|
|
|
|
|
$adho->create_label($_POST['attrname'],$_POST['label']);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
Header("Location: ".$_SERVER["PHP_SELF"]);
|
2003-02-14 18:14:29 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2004-07-17 14:41:15 +02:00
|
|
|
|
if ($_POST["action"] == 'update' && $user->admin)
|
2003-02-14 18:14:29 +01:00
|
|
|
|
{
|
2004-08-29 18:11:37 +02:00
|
|
|
|
if ($_POST["button"] != $langs->trans("Cancel")) {
|
2004-07-17 14:41:15 +02:00
|
|
|
|
if (isset($_POST["attrname"]) && preg_match("/^\w[a-zA-Z0-9-]*$/",$_POST['attrname'])){
|
|
|
|
|
|
$adho->update($_POST['attrname'],$_POST['type'],$_POST['size']);
|
|
|
|
|
|
}
|
|
|
|
|
|
if (isset($_POST['label'])){
|
|
|
|
|
|
$adho->update_label($_POST['attrname'],$_POST['label']);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
Header("Location: ".$_SERVER["PHP_SELF"]);
|
2003-02-14 18:14:29 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2004-07-17 14:41:15 +02:00
|
|
|
|
# Suppression attribut
|
|
|
|
|
|
if ($_GET["action"] == 'delete' && $user->admin)
|
2003-02-14 18:14:29 +01:00
|
|
|
|
{
|
2004-07-17 14:41:15 +02:00
|
|
|
|
if(isset($_GET["attrname"]) && preg_match("/^\w[a-zA-Z0-9-]*$/",$_GET["attrname"])){
|
|
|
|
|
|
$adho->delete($_GET["attrname"]);
|
2003-02-14 18:14:29 +01:00
|
|
|
|
}
|
2004-07-17 14:41:15 +02:00
|
|
|
|
Header("Location: ".$_SERVER["PHP_SELF"]);
|
2003-02-14 18:14:29 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2004-07-17 14:41:15 +02:00
|
|
|
|
llxHeader();
|
2003-02-14 18:14:29 +01:00
|
|
|
|
|
|
|
|
|
|
|
2004-09-25 13:02:10 +02:00
|
|
|
|
|
2005-03-06 01:14:19 +01:00
|
|
|
|
print_titre($langs->trans("OptionalFieldsSetup"));
|
2004-09-25 13:02:10 +02:00
|
|
|
|
print '<br>';
|
|
|
|
|
|
|
|
|
|
|
|
/* ************************************************************************** */
|
|
|
|
|
|
/* */
|
|
|
|
|
|
/* */
|
|
|
|
|
|
/* */
|
|
|
|
|
|
/* ************************************************************************** */
|
|
|
|
|
|
|
|
|
|
|
|
$array_options=$adho->fetch_name_optionals();
|
|
|
|
|
|
$array_label=$adho->fetch_name_optionals_label();
|
|
|
|
|
|
|
2005-03-06 01:14:19 +01:00
|
|
|
|
print "<table class=\"noborder\" width=\"100%\">";
|
2004-09-25 13:02:10 +02:00
|
|
|
|
|
|
|
|
|
|
print '<tr class="liste_titre">';
|
|
|
|
|
|
print '<td>'.$langs->trans("Label").'</td>';
|
2005-03-06 01:14:19 +01:00
|
|
|
|
print '<td>'.$langs->trans("AttributeCode").'</td>';
|
2004-09-25 13:02:10 +02:00
|
|
|
|
print '<td>'.$langs->trans("Type").'</td><td width="80"> </td>';
|
|
|
|
|
|
print "</tr>\n";
|
|
|
|
|
|
|
|
|
|
|
|
if (sizeof($array_options)>0)
|
|
|
|
|
|
{
|
|
|
|
|
|
$var=True;
|
|
|
|
|
|
foreach($adho->attribute_name as $key => $value)
|
2003-02-14 18:14:29 +01:00
|
|
|
|
{
|
2004-09-25 13:02:10 +02:00
|
|
|
|
$var=!$var;
|
|
|
|
|
|
print "<tr $bc[$var]>";
|
|
|
|
|
|
print "<td>".$adho->attribute_label[$key]." </td>\n";
|
|
|
|
|
|
print "<td>$key</td>\n";
|
|
|
|
|
|
print "<td>$value</td>\n";
|
|
|
|
|
|
print "<td align=\"center\"><a href=\"options.php?action=edit&attrname=$key\">".img_edit()."</a>";
|
|
|
|
|
|
print " <a href=\"options.php?action=delete&attrname=$key\">".img_delete()."</a></td>\n";
|
|
|
|
|
|
print "</tr>";
|
|
|
|
|
|
// $i++;
|
2003-02-14 18:14:29 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2004-09-25 13:02:10 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
print "</table>";
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
* Barre d'actions
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
|
|
|
|
|
print '<div class="tabsAction">';
|
2005-03-06 01:14:19 +01:00
|
|
|
|
print "<a class=\"tabAction\" href=\"options.php?action=create\">".$langs->trans("NewAttribute")."</a>";
|
2004-09-25 13:02:10 +02:00
|
|
|
|
print "</div>";
|
|
|
|
|
|
|
2003-02-14 18:14:29 +01:00
|
|
|
|
|
|
|
|
|
|
/* ************************************************************************** */
|
|
|
|
|
|
/* */
|
2003-02-19 18:47:22 +01:00
|
|
|
|
/* Cr<43>ation d'un champ optionnel */
|
2003-02-14 18:14:29 +01:00
|
|
|
|
/* */
|
|
|
|
|
|
/* ************************************************************************** */
|
|
|
|
|
|
|
2004-07-17 14:41:15 +02:00
|
|
|
|
if ($_GET["action"] == 'create') {
|
2003-02-14 18:14:29 +01:00
|
|
|
|
|
|
|
|
|
|
print_titre("Nouvel attribut");
|
2004-07-17 14:41:15 +02:00
|
|
|
|
|
2004-07-30 12:13:11 +02:00
|
|
|
|
print "<form action=\"options.php\" method=\"post\">";
|
2004-09-25 13:02:10 +02:00
|
|
|
|
print '<table class="border" width="100%">';
|
2003-02-14 18:14:29 +01:00
|
|
|
|
|
|
|
|
|
|
print '<input type="hidden" name="action" value="add">';
|
|
|
|
|
|
|
2004-08-29 21:03:50 +02:00
|
|
|
|
print '<tr><td>'.$langs->trans("Label").'</td><td class="valeur"><input type="text" name="label" size="40"></td></tr>';
|
2005-03-06 01:14:19 +01:00
|
|
|
|
print '<tr><td>'.$langs->trans("AttributeCode").' (pas d\'espace et uniquement des carateres alphanumeriques)</td><td class="valeur"><input type="text" name="attrname" size="40"></td></tr>';
|
2004-08-29 21:03:50 +02:00
|
|
|
|
print '<tr><td>'.$langs->trans("Type").'</td><td class="valeur">';
|
2003-03-10 17:55:11 +01:00
|
|
|
|
$form->select_array('type',array('varchar'=>'chaine',
|
|
|
|
|
|
'text'=>'texte',
|
2004-07-17 14:41:15 +02:00
|
|
|
|
'int'=>'entier',
|
2003-03-10 17:55:11 +01:00
|
|
|
|
'date'=>'date',
|
|
|
|
|
|
'datetime'=>'date et heure'));
|
2003-02-14 18:14:29 +01:00
|
|
|
|
print '</td></tr>';
|
2004-07-17 14:41:15 +02:00
|
|
|
|
print '<tr><td>Taille</td><td><input type="text" name="size" size="5" value="255"></td></tr>';
|
2003-02-14 18:14:29 +01:00
|
|
|
|
|
2005-09-06 22:58:14 +02:00
|
|
|
|
print '<tr><td colspan="2" align="center"><input type="submit" name="button" class="button" value="'.$langs->trans("Save").'"> ';
|
|
|
|
|
|
print '<input type="submit" name="button" class="button" value="'.$langs->trans("Cancel").'"></td></tr>';
|
2003-02-14 18:14:29 +01:00
|
|
|
|
print "</form>\n";
|
|
|
|
|
|
print "</table>\n";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
/* ************************************************************************** */
|
|
|
|
|
|
/* */
|
2003-02-19 18:47:22 +01:00
|
|
|
|
/* Edition d'un champ optionnel */
|
2003-02-14 18:14:29 +01:00
|
|
|
|
/* */
|
|
|
|
|
|
/* ************************************************************************** */
|
2004-07-17 14:41:15 +02:00
|
|
|
|
if ($_GET["attrname"] && $_GET["action"] == 'edit')
|
2003-02-14 18:14:29 +01:00
|
|
|
|
{
|
|
|
|
|
|
|
2004-09-25 13:02:10 +02:00
|
|
|
|
print_titre("Edition du champ ".$_GET["attrname"]);
|
2003-02-14 18:14:29 +01:00
|
|
|
|
|
|
|
|
|
|
/*
|
2003-02-19 18:47:22 +01:00
|
|
|
|
* formulaire d'edition
|
2003-02-14 18:14:29 +01:00
|
|
|
|
*/
|
2004-07-30 12:13:11 +02:00
|
|
|
|
print '<form method="post" action="options.php?attrname='.$_GET["attrname"].'">';
|
2004-07-17 14:41:15 +02:00
|
|
|
|
print '<input type="hidden" name="attrname" value="'.$_GET["attrname"].'">';
|
2003-02-14 18:14:29 +01:00
|
|
|
|
print '<input type="hidden" name="action" value="update">';
|
2004-09-25 13:02:10 +02:00
|
|
|
|
print '<table class="border" width="100%">';
|
2003-02-14 18:14:29 +01:00
|
|
|
|
|
2004-08-29 21:03:50 +02:00
|
|
|
|
print '<tr><td>'.$langs->trans("Label").'</td><td class="valeur"><input type="text" name="label" size="40" value="'.$adho->attribute_label[$_GET["attrname"]].'"></td></tr>';
|
2004-07-17 14:41:15 +02:00
|
|
|
|
print '<tr><td>Nom de l\'attribut</td><td class="valeur">'.$_GET["attrname"].' </td></tr>';
|
|
|
|
|
|
list($type,$size)=preg_split('/\(|\)/',$adho->attribute_name[$_GET["attrname"]]);
|
2004-08-29 21:03:50 +02:00
|
|
|
|
print '<tr><td>'.$langs->trans("Type").'</td><td class="valeur">';
|
2003-03-10 17:55:11 +01:00
|
|
|
|
$form->select_array('type',array('varchar'=>'chaine',
|
|
|
|
|
|
'text'=>'texte',
|
2004-07-17 14:41:15 +02:00
|
|
|
|
'int'=>'entier',
|
2003-03-10 17:55:11 +01:00
|
|
|
|
'date'=>'date',
|
|
|
|
|
|
'datetime'=>'date et heure'),$type);
|
|
|
|
|
|
print '</td></tr>';
|
2004-09-25 13:02:10 +02:00
|
|
|
|
|
|
|
|
|
|
print '<tr><td>'.$langs->trans("Size").'</td><td class="valeur"><input type="text" name="size" size="5" value="'.$size.'"></td></tr>';
|
2005-09-06 22:58:14 +02:00
|
|
|
|
print '<tr><td colspan="2" align="center"><input type="submit" class="button" value="'.$langs->trans("Save").'"> ';
|
|
|
|
|
|
print '<input type="submit" name="button" class="button" value="'.$langs->trans("Cancel").'"></td></tr>';
|
2003-02-14 18:14:29 +01:00
|
|
|
|
print '</table>';
|
|
|
|
|
|
print "</form>";
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$db->close();
|
|
|
|
|
|
|
2005-09-06 22:58:14 +02:00
|
|
|
|
llxFooter('$Date$ - $Revision$');
|
2003-02-14 18:14:29 +01:00
|
|
|
|
?>
|