New: extrafields are available onto users cards.
This commit is contained in:
parent
75fa37cde9
commit
008f5fbcfc
@ -30,7 +30,7 @@ For users:
|
|||||||
- New: Add link to third party into sells and purchase journal.
|
- New: Add link to third party into sells and purchase journal.
|
||||||
- New: Suggest a method to generate a backup file for user with no access
|
- New: Suggest a method to generate a backup file for user with no access
|
||||||
to mysqldump binary.
|
to mysqldump binary.
|
||||||
- New: Can use extrafields on contacts/addresses.
|
- New: Can also use extrafields on contacts/addresses and users.
|
||||||
- New: Support unique field for extrafields.
|
- New: Support unique field for extrafields.
|
||||||
- New: Extra fields supports more types (int, string, double, date, datetime).
|
- New: Extra fields supports more types (int, string, double, date, datetime).
|
||||||
- New: Can correct stock of a warehouse from warehouse card.
|
- New: Can correct stock of a warehouse from warehouse card.
|
||||||
|
|||||||
@ -27,7 +27,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
require '../main.inc.php';
|
require '../main.inc.php';
|
||||||
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/usergroups.lib.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
|
||||||
|
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
|
||||||
|
|
||||||
$langs->load("admin");
|
$langs->load("admin");
|
||||||
$langs->load("members");
|
$langs->load("members");
|
||||||
@ -35,6 +37,9 @@ $langs->load("users");
|
|||||||
|
|
||||||
if (! $user->admin) accessforbidden();
|
if (! $user->admin) accessforbidden();
|
||||||
|
|
||||||
|
$extrafields = new ExtraFields($db);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Action
|
* Action
|
||||||
*/
|
*/
|
||||||
@ -71,14 +76,17 @@ if (preg_match('/del_(.*)/',$action,$reg))
|
|||||||
* View
|
* View
|
||||||
*/
|
*/
|
||||||
|
|
||||||
llxHeader();
|
$help_url='EN:Module_Users|FR:Module_Utilisateurs|ES:Módulo_Usuarios';
|
||||||
|
llxHeader('',$langs->trans("UsersSetup"),$help_url);
|
||||||
|
|
||||||
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
|
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
|
||||||
print_fiche_titre($langs->trans("UsersSetup"),$linkback,'setup');
|
print_fiche_titre($langs->trans("UsersSetup"),$linkback,'setup');
|
||||||
print "<br>";
|
|
||||||
|
|
||||||
|
|
||||||
print_fiche_titre($langs->trans("MemberMainOptions"),'','');
|
$head=user_admin_prepare_head();
|
||||||
|
|
||||||
|
dol_fiche_head($head,'card', $langs->trans("User"), 0, 'user');
|
||||||
|
|
||||||
print '<table class="noborder" width="100%">';
|
print '<table class="noborder" width="100%">';
|
||||||
print '<tr class="liste_titre">';
|
print '<tr class="liste_titre">';
|
||||||
print '<td>'.$langs->trans("Description").'</td>';
|
print '<td>'.$langs->trans("Description").'</td>';
|
||||||
@ -114,7 +122,8 @@ else
|
|||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
print '</table>';
|
print '</table>';
|
||||||
print '<br><br>';
|
|
||||||
|
dol_fiche_end();
|
||||||
|
|
||||||
llxFooter();
|
llxFooter();
|
||||||
$db->close();
|
$db->close();
|
||||||
|
|||||||
@ -150,6 +150,43 @@ function group_prepare_head($object)
|
|||||||
return $head;
|
return $head;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prepare array with list of tabs
|
||||||
|
*
|
||||||
|
* @return array Array of tabs to shoc
|
||||||
|
*/
|
||||||
|
function user_admin_prepare_head()
|
||||||
|
{
|
||||||
|
global $langs, $conf, $user;
|
||||||
|
|
||||||
|
$langs->load("users");
|
||||||
|
$h=0;
|
||||||
|
|
||||||
|
$head[$h][0] = DOL_URL_ROOT.'/admin/user.php';
|
||||||
|
$head[$h][1] = $langs->trans("Parameters");
|
||||||
|
$head[$h][2] = 'card';
|
||||||
|
$h++;
|
||||||
|
|
||||||
|
$head[$h][0] = DOL_URL_ROOT.'/user/admin/user_extrafields.php';
|
||||||
|
$head[$h][1] = $langs->trans("ExtraFields");
|
||||||
|
$head[$h][2] = 'attributes';
|
||||||
|
$h++;
|
||||||
|
|
||||||
|
// Show more tabs from modules
|
||||||
|
// Entries must be declared in modules descriptor with line
|
||||||
|
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
|
||||||
|
// $this->tabs = array('entity:-tabname); to remove a tab
|
||||||
|
complete_head_from_modules($conf,$langs,$object,$head,$h,'useradmin');
|
||||||
|
|
||||||
|
complete_head_from_modules($conf,$langs,$object,$head,$h,'useradmin','remove');
|
||||||
|
|
||||||
|
return $head;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prepare array with list of tabs
|
* Prepare array with list of tabs
|
||||||
*
|
*
|
||||||
|
|||||||
@ -841,4 +841,17 @@ INSERT INTO llx_c_paper_format (rowid, code, label, width, height, unit, active)
|
|||||||
|
|
||||||
|
|
||||||
-- increase field size
|
-- increase field size
|
||||||
ALTER TABLE llx_bank_account MODIFY COLUMN code_banque varchar(8);
|
ALTER TABLE llx_bank_account MODIFY COLUMN code_banque varchar(8);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
create table llx_user_extrafields
|
||||||
|
(
|
||||||
|
rowid integer AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
tms timestamp,
|
||||||
|
fk_object integer NOT NULL, -- member id
|
||||||
|
import_key varchar(14) -- import key
|
||||||
|
)ENGINE=innodb;
|
||||||
|
|
||||||
|
ALTER TABLE llx_user_extrafields ADD INDEX idx_user_extrafields (fk_object);
|
||||||
|
|
||||||
|
|||||||
23
htdocs/install/mysql/tables/llx_user_extrafields.key.sql
Normal file
23
htdocs/install/mysql/tables/llx_user_extrafields.key.sql
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
-- ===================================================================
|
||||||
|
-- Copyright (C) 2002-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||||
|
-- Copyright (C) 2002-2003 Jean-Louis Bergamo <jlb@j1b.org>
|
||||||
|
-- Copyright (C) 2009 Regis Houssin <regis@dolibarr.fr>
|
||||||
|
-- Copyright (C) 2011 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
|
--
|
||||||
|
-- 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, see <http://www.gnu.org/licenses/>.
|
||||||
|
--
|
||||||
|
-- ===================================================================
|
||||||
|
|
||||||
|
|
||||||
|
ALTER TABLE llx_user_extrafields ADD INDEX idx_user_extrafields (fk_object);
|
||||||
27
htdocs/install/mysql/tables/llx_user_extrafields.sql
Normal file
27
htdocs/install/mysql/tables/llx_user_extrafields.sql
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
-- ===================================================================
|
||||||
|
-- Copyright (C) 2002-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||||
|
-- Copyright (C) 2002-2003 Jean-Louis Bergamo <jlb@j1b.org>
|
||||||
|
-- Copyright (C) 2009 Regis Houssin <regis@dolibarr.fr>
|
||||||
|
--
|
||||||
|
-- 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, see <http://www.gnu.org/licenses/>.
|
||||||
|
--
|
||||||
|
-- ===================================================================
|
||||||
|
|
||||||
|
create table llx_user_extrafields
|
||||||
|
(
|
||||||
|
rowid integer AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
tms timestamp,
|
||||||
|
fk_object integer NOT NULL, -- member id
|
||||||
|
import_key varchar(14) -- import key
|
||||||
|
)ENGINE=innodb;
|
||||||
157
htdocs/user/admin/user_extrafields.php
Normal file
157
htdocs/user/admin/user_extrafields.php
Normal file
@ -0,0 +1,157 @@
|
|||||||
|
<?php
|
||||||
|
/* Copyright (C) 2001-2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||||
|
* Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org>
|
||||||
|
* Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
|
* Copyright (C) 2012 Regis Houssin <regis@dolibarr.fr>
|
||||||
|
*
|
||||||
|
* 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, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \file htdocs/adherents/admin/adherent_extrafields.php
|
||||||
|
* \ingroup member
|
||||||
|
* \brief Page to setup extra fields of members
|
||||||
|
*/
|
||||||
|
|
||||||
|
require '../../main.inc.php';
|
||||||
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/usergroups.lib.php';
|
||||||
|
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
|
||||||
|
|
||||||
|
$langs->load("users");
|
||||||
|
$langs->load("admin");
|
||||||
|
|
||||||
|
$extrafields = new ExtraFields($db);
|
||||||
|
$form = new Form($db);
|
||||||
|
|
||||||
|
// List of supported format
|
||||||
|
$tmptype2label=getStaticMember(get_class($extrafields),'type2label');
|
||||||
|
$type2label=array('');
|
||||||
|
foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->trans($val);
|
||||||
|
|
||||||
|
$action=GETPOST('action', 'alpha');
|
||||||
|
$attrname=GETPOST('attrname', 'alpha');
|
||||||
|
$elementtype='user';
|
||||||
|
|
||||||
|
if (!$user->admin) accessforbidden();
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Actions
|
||||||
|
*/
|
||||||
|
|
||||||
|
require DOL_DOCUMENT_ROOT.'/core/admin_extrafields.inc.php';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* View
|
||||||
|
*/
|
||||||
|
|
||||||
|
$textobject=$langs->transnoentitiesnoconv("Users");
|
||||||
|
|
||||||
|
$help_url='EN:Module_Users|FR:Module_Utilisateurs|ES:Módulo_Usuarios';
|
||||||
|
llxHeader('',$langs->trans("UsersSetup"),$help_url);
|
||||||
|
|
||||||
|
|
||||||
|
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
|
||||||
|
print_fiche_titre($langs->trans("UsersSetup"),$linkback,'setup');
|
||||||
|
|
||||||
|
|
||||||
|
$head = user_admin_prepare_head();
|
||||||
|
|
||||||
|
dol_fiche_head($head, 'attributes', $langs->trans("User"), 0, 'user');
|
||||||
|
|
||||||
|
|
||||||
|
print $langs->trans("DefineHereComplementaryAttributes",$textobject).'<br>'."\n";
|
||||||
|
print '<br>';
|
||||||
|
|
||||||
|
dol_htmloutput_errors($mesg);
|
||||||
|
|
||||||
|
// Load attribute_label
|
||||||
|
$extrafields->fetch_name_optionals_label($elementtype);
|
||||||
|
|
||||||
|
print "<table summary=\"listofattributes\" class=\"noborder\" width=\"100%\">";
|
||||||
|
|
||||||
|
print '<tr class="liste_titre">';
|
||||||
|
print '<td>'.$langs->trans("Label").'</td>';
|
||||||
|
print '<td>'.$langs->trans("AttributeCode").'</td>';
|
||||||
|
print '<td>'.$langs->trans("Type").'</td>';
|
||||||
|
print '<td align="right">'.$langs->trans("Size").'</td>';
|
||||||
|
print '<td align="center">'.$langs->trans("Unique").'</td>';
|
||||||
|
print '<td align="center">'.$langs->trans("Required").'</td>';
|
||||||
|
print '<td width="80"> </td>';
|
||||||
|
print "</tr>\n";
|
||||||
|
|
||||||
|
$var=True;
|
||||||
|
foreach($extrafields->attribute_type as $key => $value)
|
||||||
|
{
|
||||||
|
$var=!$var;
|
||||||
|
print "<tr ".$bc[$var].">";
|
||||||
|
print "<td>".$extrafields->attribute_label[$key]."</td>\n";
|
||||||
|
print "<td>".$key."</td>\n";
|
||||||
|
print "<td>".$type2label[$extrafields->attribute_type[$key]]."</td>\n";
|
||||||
|
print '<td align="right">'.$extrafields->attribute_size[$key]."</td>\n";
|
||||||
|
print '<td align="center">'.yn($extrafields->attribute_unique[$key])."</td>\n";
|
||||||
|
print '<td align="center">'.yn($extrafields->attribute_required[$key])."</td>\n";
|
||||||
|
print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=edit&attrname='.$key.'">'.img_edit().'</a>';
|
||||||
|
print " <a href=\"".$_SERVER["PHP_SELF"]."?action=delete&attrname=".$key."\">".img_delete()."</a></td>\n";
|
||||||
|
print "</tr>";
|
||||||
|
// $i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
print "</table>";
|
||||||
|
|
||||||
|
dol_fiche_end();
|
||||||
|
|
||||||
|
|
||||||
|
// Buttons
|
||||||
|
if ($action != 'create' && $action != 'edit')
|
||||||
|
{
|
||||||
|
print '<div class="tabsAction">';
|
||||||
|
print "<a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?action=create\">".$langs->trans("NewAttribute")."</a>";
|
||||||
|
print "</div>";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* Creation d'un champ optionnel
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
if ($action == 'create')
|
||||||
|
{
|
||||||
|
print "<br>";
|
||||||
|
print_titre($langs->trans('NewAttribute'));
|
||||||
|
|
||||||
|
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php';
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* Edition d'un champ optionnel */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
if ($action == 'edit' && ! empty($attrname))
|
||||||
|
{
|
||||||
|
print "<br>";
|
||||||
|
print_titre($langs->trans("FieldEdition", $attrname));
|
||||||
|
|
||||||
|
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php';
|
||||||
|
}
|
||||||
|
|
||||||
|
llxFooter();
|
||||||
|
|
||||||
|
$db->close();
|
||||||
|
?>
|
||||||
@ -1189,6 +1189,25 @@ class User extends CommonObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Actions on extra fields (by external module or standard code)
|
||||||
|
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
|
||||||
|
$hookmanager=new HookManager($this->db);
|
||||||
|
$hookmanager->initHooks(array('userdao'));
|
||||||
|
$parameters=array('socid'=>$this->id);
|
||||||
|
$reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
|
||||||
|
if (empty($reshook))
|
||||||
|
{
|
||||||
|
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
|
||||||
|
{
|
||||||
|
$result=$this->insertExtraFields();
|
||||||
|
if ($result < 0)
|
||||||
|
{
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if ($reshook < 0) $error++;
|
||||||
|
|
||||||
if (! $error && ! $notrigger)
|
if (! $error && ! $notrigger)
|
||||||
{
|
{
|
||||||
// Appel des triggers
|
// Appel des triggers
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user