diff --git a/htdocs/adherents/options.php b/htdocs/adherents/options.php
index cfde8db6d0d..b80b88908ef 100644
--- a/htdocs/adherents/options.php
+++ b/htdocs/adherents/options.php
@@ -29,82 +29,125 @@ require("../main.inc.php");
require_once(DOL_DOCUMENT_ROOT."/core/class/extrafields.class.php");
$langs->load("members");
+$langs->load("admin");
-$adho = new ExtraFields($db);
+$extrafields = new ExtraFields($db);
$form = new Form($db);
+// List of supported format
+$type2label=array(
+'varchar'=>$langs->trans('String'),
+'text'=>$langs->trans('Text'),
+'int'=>$langs->trans('Int'),
+'date'=>$langs->trans('Date'),
+'datetime'=>$langs->trans('DateAndTime')
+);
+
+$action=GETPOST("action");
+$elementtype='member';
+
+
/*
* Actions
*/
-if ($_POST["action"] == 'add' && $user->rights->adherent->configurer)
+if ($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']))
- {
- $result=$adho->addExtraField($_POST['attrname'],$_POST['label'],$_POST['type'],$_POST['pos'],$_POST['size'],'member');
- if ($result > 0)
- {
- Header("Location: ".$_SERVER["PHP_SELF"]);
- exit;
- }
- else
- {
- $mesg=$adho->error;
- }
- }
- else
- {
- $langs->load("errors");
- $mesg=$langs->trans("ErrorFieldCanNotContainSpecialCharacters",$langs->transnoentities("AttributeCode"));
- $_GET["action"] = 'create';
- }
+ // Check values
+ if (GETPOST('type')=='varchar' && GETPOST('size') > 255)
+ {
+ $error++;
+ $langs->load("errors");
+ $mesg=$langs->trans("ErrorSizeTooLongForVarcharType");
+ $action = 'create';
+ }
+
+ if (! $error)
+ {
+ // Type et taille non encore pris en compte => varchar(255)
+ if (isset($_POST["attrname"]) && preg_match("/^\w[a-zA-Z0-9-_]*$/",$_POST['attrname']))
+ {
+ $result=$extrafields->addExtraField($_POST['attrname'],$_POST['label'],$_POST['type'],$_POST['pos'],$_POST['size'],$elementtype);
+ if ($result > 0)
+ {
+ Header("Location: ".$_SERVER["PHP_SELF"]);
+ exit;
+ }
+ else
+ {
+ $error++;
+ $mesg=$extrafields->error;
+ }
+ }
+ else
+ {
+ $error++;
+ $langs->load("errors");
+ $mesg=$langs->trans("ErrorFieldCanNotContainSpecialCharacters",$langs->transnoentities("AttributeCode"));
+ $action = 'create';
+ }
+ }
}
}
// Rename field
-if ($_POST["action"] == 'update' && $user->rights->adherent->configurer)
+if ($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']))
- {
- $result=$adho->update($_POST['attrname'],$_POST['type'],$_POST['size']);
- if ($result > 0)
- {
- if (isset($_POST['label']))
- {
- $adho->update_label($_POST['attrname'],$_POST['label'],$_POST['type'],$_POST['size']);
- }
- Header("Location: ".$_SERVER["PHP_SELF"]);
- exit;
- }
- else
- {
- $mesg=$adho->error;
- }
- }
- else
- {
- $langs->load("errors");
- $mesg=$langs->trans("ErrorFieldCanNotContainSpecialCharacters",$langs->transnoentities("AttributeCode"));
- }
+ // Check values
+ if (GETPOST('type')=='varchar' && GETPOST('size') > 255)
+ {
+ $error++;
+ $langs->load("errors");
+ $mesg=$langs->trans("ErrorSizeTooLongForVarcharType");
+ $action = 'edit';
+ }
+
+ if (! $error)
+ {
+ if (isset($_POST["attrname"]) && preg_match("/^\w[a-zA-Z0-9-_]*$/",$_POST['attrname']))
+ {
+ $result=$extrafields->update($_POST['attrname'],$_POST['type'],$_POST['size'],$elementtype);
+ if ($result > 0)
+ {
+ if (isset($_POST['label']))
+ {
+ $extrafields->update_label($_POST['attrname'],$_POST['label'],$_POST['type'],$_POST['size'],$elementtype);
+ }
+ Header("Location: ".$_SERVER["PHP_SELF"]);
+ exit;
+ }
+ else
+ {
+ $error++;
+ $mesg=$extrafields->error;
+ }
+ }
+ else
+ {
+ $error++;
+ $langs->load("errors");
+ $mesg=$langs->trans("ErrorFieldCanNotContainSpecialCharacters",$langs->transnoentities("AttributeCode"));
+ }
+ }
}
}
# Suppression attribut
-if ($_GET["action"] == 'delete' && $user->rights->adherent->configurer)
+if ($action == 'delete' && $user->rights->adherent->configurer)
{
if(isset($_GET["attrname"]) && preg_match("/^\w[a-zA-Z0-9-_]*$/",$_GET["attrname"]))
{
- $adho->delete($_GET["attrname"]);
+ $extrafields->delete($_GET["attrname"],$elementtype);
Header("Location: ".$_SERVER["PHP_SELF"]);
exit;
}
else
{
+ $error++;
$langs->load("errors");
$mesg=$langs->trans("ErrorFieldCanNotContainSpecialCharacters",$langs->transnoentities("AttributeCode"));
}
@@ -116,35 +159,41 @@ if ($_GET["action"] == 'delete' && $user->rights->adherent->configurer)
* View
*/
-llxHeader('',$langs->trans("OptionalFieldsSetup"),'EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Miembros');
+$textobject=$langs->transnoentitiesnoconv("Members");
+
+$help_url='EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Miembros';
+llxHeader('',$langs->trans("OptionalFieldsSetup"),$help_url);
print_fiche_titre($langs->trans("OptionalFieldsSetup"));
-if ($mesg) print '
'.$mesg.'
';
+print $langs->trans("DefineHereComplementaryAttributes",$textobject).' '."\n";
+print ' ';
+
+dol_htmloutput_errors($mesg);
// Load attribute_label
-$adho->fetch_name_optionals_label();
+$extrafields->fetch_name_optionals_label();
print "";
print '';
-print ''.$langs->trans("AttributeCode").' ';
print ''.$langs->trans("Label").' ';
+print ''.$langs->trans("AttributeCode").' ';
print ''.$langs->trans("Type").' ';
print ''.$langs->trans("Size").' ';
print ' ';
print " \n";
$var=True;
-foreach($adho->attribute_type as $key => $value)
+foreach($extrafields->attribute_type as $key => $value)
{
$var=!$var;
print "";
+ print "".$extrafields->attribute_label[$key]." \n";
print "".$key." \n";
- print "".$adho->attribute_label[$key]." \n";
- print "".$adho->attribute_type[$key]." \n";
- print ''.$adho->attribute_size[$key]." \n";
+ print "".$type2label[$extrafields->attribute_type[$key]]." \n";
+ print ''.$extrafields->attribute_size[$key]." \n";
print ''.img_edit().' ';
print " ".img_delete()." \n";
print " ";
@@ -157,7 +206,7 @@ print "
";
* Barre d'actions
*
*/
-if ($_GET["action"] != 'create' && $_GET["action"] != 'edit')
+if ($action != 'create' && $action != 'edit')
{
print '';
print "
".$langs->trans("NewAttribute")." ";
@@ -171,7 +220,7 @@ if ($_GET["action"] != 'create' && $_GET["action"] != 'edit')
/* */
/* ************************************************************************** */
-if ($_GET["action"] == 'create')
+if ($action == 'create')
{
print "
";
print_titre($langs->trans('NewAttribute'));
@@ -182,16 +231,16 @@ if ($_GET["action"] == 'create')
print '
';
- print '
'.$langs->trans("Label").' ';
- print '
'.$langs->trans("AttributeCode").' ('.$langs->trans("AlphaNumOnlyCharsAndNoSpace").') ';
- print '
'.$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')));
+ // Label
+ print ' '.$langs->trans("Label").' ';
+ // Code
+ print '
'.$langs->trans("AttributeCode").' ('.$langs->trans("AlphaNumOnlyCharsAndNoSpace").') ';
+ // Type
+ print '
'.$langs->trans("Type").' ';
+ print $form->selectarray('type',$type2label,GETPOST('type'));
print ' ';
- print '
Taille ';
+ // Size
+ print '
'.$langs->trans("Size").' ';
print '
';
print '';
@@ -204,7 +253,7 @@ if ($_GET["action"] == 'create')
/* Edition d'un champ optionnel */
/* */
/* ************************************************************************** */
-if ($_GET["attrname"] && $_GET["action"] == 'edit')
+if ($_GET["attrname"] && $action == 'edit')
{
print "
";
print_titre($langs->trans("FieldEdition",$_GET["attrname"]));
@@ -218,30 +267,25 @@ if ($_GET["attrname"] && $_GET["action"] == 'edit')
print '
';
print '
';
diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php
index 17144f693c9..cfc49cd4358 100755
--- a/htdocs/core/class/extrafields.class.php
+++ b/htdocs/core/class/extrafields.class.php
@@ -414,6 +414,10 @@ class ExtraFields
{
$showsize=10;
}
+ elseif ($type == 'datetime')
+ {
+ $showsize=19;
+ }
elseif ($type == 'int')
{
$showsize=10;
@@ -426,7 +430,8 @@ class ExtraFields
//print $type.'-'.$size;
$out='
';
if ($type == 'date') $out.=' (YYYY-MM-DD)';
- return $out;
+ if ($type == 'datetime') $out.=' (YYYY-MM-DD HH:MM:SS)';
+ return $out;
}
/**
@@ -444,6 +449,10 @@ class ExtraFields
{
$showsize=10;
}
+ elseif ($type == 'datetime')
+ {
+ $showsize=19;
+ }
elseif ($type == 'int')
{
$showsize=10;
diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang
index 52aa227b036..f1a516fea69 100644
--- a/htdocs/langs/en_US/admin.lang
+++ b/htdocs/langs/en_US/admin.lang
@@ -840,6 +840,7 @@ MAIN_PROXY_HOST=Name/Address of proxy server
MAIN_PROXY_PORT=Port of proxy server
MAIN_PROXY_USER=Login to use the proxy server
MAIN_PROXY_PASS=Password to use the proxy server
+DefineHereComplementaryAttributes=Define here all atributes, not already available by default, and that you want to be supported for %s.
##### Module password generation
PasswordGenerationStandard=Return a password generated according to internal Dolibarr algorithm: 8 characters containing shared numbers and characters in lowercase.
diff --git a/htdocs/langs/fr_FR/admin.lang b/htdocs/langs/fr_FR/admin.lang
index aea5962551a..8a7b48f40aa 100644
--- a/htdocs/langs/fr_FR/admin.lang
+++ b/htdocs/langs/fr_FR/admin.lang
@@ -852,6 +852,8 @@ MAIN_PROXY_HOST=Nom/Adresse du serveur proxy mandataire
MAIN_PROXY_PORT=Port du serveur proxy mandataire
MAIN_PROXY_USER=Login pour passer le serveur proxy mandataire
MAIN_PROXY_PASS=Mot de passe pour passer le serveur proxy mandataire
+DefineHereComplementaryAttributes=Definissez ici la liste des attributs supplémentaire, non disponible en standard, et que vous voulez voir gérez sur les %s.
+
##### Module password generation= undefined
PasswordGenerationStandard= Renvoie un mot de passe généré selon algorithme interne Dolibarr: 8 caractères, chiffres et caractères en minuscules mélangés.
PasswordGenerationNone= Ne propose pas de mots de passe générés. Le mot de passe est à saisir manuellement.