* Copyright (C) 2003 Jean-Louis Bergamo * Copyright (C) 2004-2009 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. */ /** * \file htdocs/adherents/options.php * \ingroup member * \brief Page de configuratin des champs optionnels * \version $Id$ */ require("../main.inc.php"); require(DOL_DOCUMENT_ROOT."/adherents/class/adherent_options.class.php"); $langs->load("members"); $adho = new AdherentOptions($db); $form = new Form($db); /* * Actions */ if ($_POST["action"] == 'add' && $user->rights->adherent->configurer) { if ($_POST["button"] != $langs->trans("Cancel")) { // 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'],$_POST['type'],$_POST['pos'],$_POST['size']); } Header("Location: ".$_SERVER["PHP_SELF"]); exit; } else { $langs->load("errors"); $mesg=$langs->trans("ErrorFieldCanNotContainSpecialCharacters",$langs->transnoentities("AttributeCode")); $_GET["action"] = 'create'; } } } // Rename field if ($_POST["action"] == 'update' && $user->rights->adherent->configurer) { if ($_POST["button"] != $langs->trans("Cancel")) { 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'],$_POST['type'],$_POST['size']); } Header("Location: ".$_SERVER["PHP_SELF"]); exit; } else { $langs->load("errors"); $mesg=$langs->trans("ErrorFieldCanNotContainSpecialCharacters",$langs->transnoentities("AttributeCode")); } } } # Suppression attribut if ($_GET["action"] == 'delete' && $user->rights->adherent->configurer) { if(isset($_GET["attrname"]) && preg_match("/^\w[a-zA-Z0-9-_]*$/",$_GET["attrname"])) { $adho->delete($_GET["attrname"]); Header("Location: ".$_SERVER["PHP_SELF"]); exit; } else { $langs->load("errors"); $mesg=$langs->trans("ErrorFieldCanNotContainSpecialCharacters",$langs->transnoentities("AttributeCode")); } } /* * View */ llxHeader('',$langs->trans("OptionalFieldsSetup"),'EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Miembros'); print_fiche_titre($langs->trans("OptionalFieldsSetup")); if ($mesg) print '
'.$mesg.'

'; // Load attribute_label $adho->fetch_name_optionals_label(); print ""; print ''; print ''; print ''; print ''; print ''; print ''; print "\n"; $var=True; foreach($adho->attribute_type as $key => $value) { $var=!$var; print ""; print "\n"; print "\n"; print "\n"; print '\n"; print '\n"; print ""; // $i++; } print "
'.$langs->trans("AttributeCode").''.$langs->trans("Label").''.$langs->trans("Type").''.$langs->trans("Size").' 
".$key."".$adho->attribute_label[$key]."".$adho->attribute_type[$key]."'.$adho->attribute_size[$key]."'.img_edit().''; print "  ".img_delete()."
"; /* * Barre d'actions * */ if ($_GET["action"] != 'create' && $_GET["action"] != 'edit') { print '"; } /* ************************************************************************** */ /* */ /* Creation d'un champ optionnel /* */ /* ************************************************************************** */ if ($_GET["action"] == 'create') { print "
"; print_titre($langs->trans('NewAttribute')); print '
'; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print "\n"; print "
'.$langs->trans("Label").'
'.$langs->trans("AttributeCode").' ('.$langs->trans("AlphaNumOnlyCharsAndNoSpace").')
'.$langs->trans("Type").''; print $form->selectarray('type',array('varchar'=>$langs->trans('String'), 'text'=>$langs->trans('Text'), 'int'=>$langs->trans('Int'), 'date'=>$langs->trans('Date'), 'datetime'=>$langs->trans('DateAndTime'))); print '
Taille
  '; print '
\n"; } /* ************************************************************************** */ /* */ /* Edition d'un champ optionnel */ /* */ /* ************************************************************************** */ if ($_GET["attrname"] && $_GET["action"] == 'edit') { print "
"; print_titre($langs->trans("FieldEdition",$_GET["attrname"])); /* * formulaire d'edition */ print '
'; print ''; print ''; print ''; print ''; // Code print ''; print ''; print ''; print ''; // Label print ''; print ''; print ''; $type=$adho->attribute_type[$_GET["attrname"]]; $size=$adho->attribute_size[$_GET["attrname"]]; print ''; print ''; print ''; print ''; print '
'.$langs->trans("AttributeCode").''.$_GET["attrname"].' 
'.$langs->trans("Label").'
'.$langs->trans("Type").''; $type2label=array('varchar'=>$langs->trans('String'), 'text'=>$langs->trans('Text'), 'int'=>$langs->trans('Int'), 'date'=>$langs->trans('Date'), 'datetime'=>$langs->trans('DateAndTime')); //print $form->selectarray('type',$type2label,$type); print $type2label[$type]; print ''; print '
'.$langs->trans("Size").'
  '; print '
'; print "
"; } $db->close(); llxFooter('$Date$ - $Revision$'); ?>