[ Index ] |
|
Code source de Dolibarr 2.0.1 |
1 <?php 2 /* Copyright (C) 2001-2002 Rodolphe Quiedeville <rodolphe@quiedeville.org> 3 * Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org> 4 * Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net> 5 * 6 * This program is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 * 20 * $Id: options.php,v 1.15 2005/09/06 20:58:15 eldy Exp $ 21 * $Source: /cvsroot/dolibarr/dolibarr/htdocs/adherents/options.php,v $ 22 */ 23 24 /** \file htdocs/adherents/options.php 25 \ingroup adherent 26 \brief Page de configuratin des champs optionnels 27 \version $Revision: 1.15 $ 28 */ 29 30 require ("./pre.inc.php"); 31 require(DOL_DOCUMENT_ROOT."/adherents/adherent_options.class.php"); 32 33 $langs->load("members"); 34 35 $adho = new AdherentOptions($db); 36 $form = new Form($db); 37 38 if ($_POST["action"] == 'add' && $user->admin) 39 { 40 if ($_POST["button"] != $langs->trans("Cancel")) { 41 // Type et taille non encore pris en compte => varchar(255) 42 if (isset($_POST["attrname"]) && preg_match("/^\w[a-zA-Z0-9-]*$/",$_POST['attrname'])){ 43 $adho->create($_POST['attrname'],$_POST['type'],$_POST['size']); 44 } 45 if (isset($_POST['label'])){ 46 $adho->create_label($_POST['attrname'],$_POST['label']); 47 } 48 } 49 Header("Location: ".$_SERVER["PHP_SELF"]); 50 } 51 52 if ($_POST["action"] == 'update' && $user->admin) 53 { 54 if ($_POST["button"] != $langs->trans("Cancel")) { 55 if (isset($_POST["attrname"]) && preg_match("/^\w[a-zA-Z0-9-]*$/",$_POST['attrname'])){ 56 $adho->update($_POST['attrname'],$_POST['type'],$_POST['size']); 57 } 58 if (isset($_POST['label'])){ 59 $adho->update_label($_POST['attrname'],$_POST['label']); 60 } 61 } 62 Header("Location: ".$_SERVER["PHP_SELF"]); 63 } 64 65 # Suppression attribut 66 if ($_GET["action"] == 'delete' && $user->admin) 67 { 68 if(isset($_GET["attrname"]) && preg_match("/^\w[a-zA-Z0-9-]*$/",$_GET["attrname"])){ 69 $adho->delete($_GET["attrname"]); 70 } 71 Header("Location: ".$_SERVER["PHP_SELF"]); 72 } 73 74 75 llxHeader(); 76 77 78 79 print_titre($langs->trans("OptionalFieldsSetup")); 80 print '<br>'; 81 82 /* ************************************************************************** */ 83 /* */ 84 /* */ 85 /* */ 86 /* ************************************************************************** */ 87 88 $array_options=$adho->fetch_name_optionals(); 89 $array_label=$adho->fetch_name_optionals_label(); 90 91 print "<table class=\"noborder\" width=\"100%\">"; 92 93 print '<tr class="liste_titre">'; 94 print '<td>'.$langs->trans("Label").'</td>'; 95 print '<td>'.$langs->trans("AttributeCode").'</td>'; 96 print '<td>'.$langs->trans("Type").'</td><td width="80"> </td>'; 97 print "</tr>\n"; 98 99 if (sizeof($array_options)>0) 100 { 101 $var=True; 102 foreach($adho->attribute_name as $key => $value) 103 { 104 $var=!$var; 105 print "<tr $bc[$var]>"; 106 print "<td>".$adho->attribute_label[$key]." </td>\n"; 107 print "<td>$key</td>\n"; 108 print "<td>$value</td>\n"; 109 print "<td align=\"center\"><a href=\"options.php?action=edit&attrname=$key\">".img_edit()."</a>"; 110 print " <a href=\"options.php?action=delete&attrname=$key\">".img_delete()."</a></td>\n"; 111 print "</tr>"; 112 // $i++; 113 } 114 115 } 116 117 print "</table>"; 118 119 /* 120 * Barre d'actions 121 * 122 */ 123 print '<div class="tabsAction">'; 124 print "<a class=\"tabAction\" href=\"options.php?action=create\">".$langs->trans("NewAttribute")."</a>"; 125 print "</div>"; 126 127 128 /* ************************************************************************** */ 129 /* */ 130 /* Création d'un champ optionnel */ 131 /* */ 132 /* ************************************************************************** */ 133 134 if ($_GET["action"] == 'create') { 135 136 print_titre("Nouvel attribut"); 137 138 print "<form action=\"options.php\" method=\"post\">"; 139 print '<table class="border" width="100%">'; 140 141 print '<input type="hidden" name="action" value="add">'; 142 143 print '<tr><td>'.$langs->trans("Label").'</td><td class="valeur"><input type="text" name="label" size="40"></td></tr>'; 144 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>'; 145 print '<tr><td>'.$langs->trans("Type").'</td><td class="valeur">'; 146 $form->select_array('type',array('varchar'=>'chaine', 147 'text'=>'texte', 148 'int'=>'entier', 149 'date'=>'date', 150 'datetime'=>'date et heure')); 151 print '</td></tr>'; 152 print '<tr><td>Taille</td><td><input type="text" name="size" size="5" value="255"></td></tr>'; 153 154 print '<tr><td colspan="2" align="center"><input type="submit" name="button" class="button" value="'.$langs->trans("Save").'"> '; 155 print '<input type="submit" name="button" class="button" value="'.$langs->trans("Cancel").'"></td></tr>'; 156 print "</form>\n"; 157 print "</table>\n"; 158 159 160 } 161 /* ************************************************************************** */ 162 /* */ 163 /* Edition d'un champ optionnel */ 164 /* */ 165 /* ************************************************************************** */ 166 if ($_GET["attrname"] && $_GET["action"] == 'edit') 167 { 168 169 print_titre("Edition du champ ".$_GET["attrname"]); 170 171 /* 172 * formulaire d'edition 173 */ 174 print '<form method="post" action="options.php?attrname='.$_GET["attrname"].'">'; 175 print '<input type="hidden" name="attrname" value="'.$_GET["attrname"].'">'; 176 print '<input type="hidden" name="action" value="update">'; 177 print '<table class="border" width="100%">'; 178 179 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>'; 180 print '<tr><td>Nom de l\'attribut</td><td class="valeur">'.$_GET["attrname"].' </td></tr>'; 181 list($type,$size)=preg_split('/\(|\)/',$adho->attribute_name[$_GET["attrname"]]); 182 print '<tr><td>'.$langs->trans("Type").'</td><td class="valeur">'; 183 $form->select_array('type',array('varchar'=>'chaine', 184 'text'=>'texte', 185 'int'=>'entier', 186 'date'=>'date', 187 'datetime'=>'date et heure'),$type); 188 print '</td></tr>'; 189 190 print '<tr><td>'.$langs->trans("Size").'</td><td class="valeur"><input type="text" name="size" size="5" value="'.$size.'"></td></tr>'; 191 print '<tr><td colspan="2" align="center"><input type="submit" class="button" value="'.$langs->trans("Save").'"> '; 192 print '<input type="submit" name="button" class="button" value="'.$langs->trans("Cancel").'"></td></tr>'; 193 print '</table>'; 194 print "</form>"; 195 196 } 197 198 $db->close(); 199 200 llxFooter('$Date: 2005/09/06 20:58:15 $ - $Revision: 1.15 $'); 201 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Mon Nov 26 12:29:37 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |