diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 8e3dce72196..99e803e649c 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -11,6 +11,7 @@ * Copyright (C) 2013-2015 Alexandre Spangaro * Copyright (C) 2015 Jean-François Ferry * Copyright (C) 2015 Ari Elbaz (elarifr) + * Copyright (C) 2015 Charlie Benke * * 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 @@ -43,6 +44,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; if (! empty($conf->ldap->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/class/ldap.class.php'; if (! empty($conf->adherent->enabled)) require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; if (! empty($conf->multicompany->enabled)) dol_include_once('/multicompany/class/actions_multicompany.class.php'); +if (! empty($conf->categorie->enabled)) require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; + $id = GETPOST('id','int'); $action = GETPOST('action','alpha'); @@ -244,7 +247,11 @@ if (empty($reshook)) { if (isset($_POST['password']) && trim($_POST['password'])) { $object->setPassword($user, trim($_POST['password'])); } - + if (! empty($conf->categorie->enabled)) { + // Categories association + $usercats = GETPOST( 'usercats', 'array' ); + $object->setCategories($usercats); + } $db->commit(); header("Location: ".$_SERVER['PHP_SELF'].'?id='.$id); @@ -472,7 +479,13 @@ if (empty($reshook)) { } } } - + if (! $error && ! count($object->errors)) + { + // Then we add the associated categories + $categories = GETPOST( 'usercats', 'array' ); + $object->setCategories($categories); + } + if (!$error && !count($object->errors)) { setEventMessages($langs->trans("UserModified"), null, 'mesgs'); $db->commit(); @@ -1081,7 +1094,16 @@ if (($action == 'create') || ($action == 'adduserldap')) print $formother->selectColor(GETPOST('color')?GETPOST('color'):$object->color, 'color', null, 1, '', 'hideifnotset'); print ''; } - + + // Categories + if (! empty($conf->categorie->enabled) && ! empty($user->rights->categorie->lire)) { + print '' . fieldLabel( 'Categories', 'usercats' ) . ''; + $cate_arbo = $form->select_all_categories( Categorie::TYPE_USER, null, 'parent', null, null, 1 ); + print $form->multiselectarray( 'usercats', $cate_arbo, GETPOST( 'usercats', 'array' ), null, null, null, + null, '90%' ); + print ""; + } + // Note print ''; print $langs->trans("Note"); @@ -1425,7 +1447,16 @@ else print ''; print "\n"; } - + + // Categories + if (! empty($conf->categorie->enabled) && ! empty($user->rights->categorie->lire)) + { + print '' . $langs->trans( "Categories" ) . ''; + print ''; + print $form->showCategories( $object->id, 'user', 1 ); + print ''; + } + // Company / Contact if (! empty($conf->societe->enabled)) { @@ -2172,33 +2203,47 @@ else print ''; print "\n"; - // Accountancy code - if ($conf->salaries->enabled) + // Accountancy code + if ($conf->salaries->enabled) + { + print ""; + print ''.$langs->trans("AccountancyCode").''; + print ''; + if ($caneditfield) { - print ""; - print ''.$langs->trans("AccountancyCode").''; - print ''; - if ($caneditfield) - { - print ''; - } - else - { - print ''; - print $object->accountancy_code; - } - print ''; - print ""; + print ''; } + else + { + print ''; + print $object->accountancy_code; + } + print ''; + print ""; + } - // User color - if (! empty($conf->agenda->enabled)) - { - print ''.$langs->trans("ColorUser").''; - print ''; - print $formother->selectColor(GETPOST('color')?GETPOST('color'):$object->color, 'color', null, 1, '', 'hideifnotset'); - print ''; + // User color + if (! empty($conf->agenda->enabled)) + { + print ''.$langs->trans("ColorUser").''; + print ''; + print $formother->selectColor(GETPOST('color')?GETPOST('color'):$object->color, 'color', null, 1, '', 'hideifnotset'); + print ''; + } + + // Categories + if (!empty( $conf->categorie->enabled ) && !empty( $user->rights->categorie->lire )) { + print '' . fieldLabel( 'Categories', 'usercats' ) . ''; + print ''; + $cate_arbo = $form->select_all_categories( Categorie::TYPE_CONTACT, null, null, null, null, 1 ); + $c = new Categorie( $db ); + $cats = $c->containing( $object->id, Categorie::TYPE_CONTACT ); + foreach ($cats as $cat) { + $arrayselected[] = $cat->id; } + print $form->multiselectarray( 'usercats', $cate_arbo, $arrayselected, '', 0, '', 0, '90%' ); + print ""; + } // Status print ''.$langs->trans("Status").'';