diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php
index 9a0fecba320..d87729ee0c5 100644
--- a/htdocs/adherents/card.php
+++ b/htdocs/adherents/card.php
@@ -34,9 +34,10 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php';
-require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
require_once DOL_DOCUMENT_ROOT.'/adherents/class/cotisation.class.php';
+require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
+require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
$langs->load("companies");
@@ -239,7 +240,7 @@ if (empty($reshook))
}
}
- if ($action == 'update' && $cancel='' && $user->rights->adherent->creer)
+ if ($action == 'update' && ! $cancel && $user->rights->adherent->creer)
{
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
@@ -322,8 +323,29 @@ if (empty($reshook))
}
$result=$object->update($user,0,$nosyncuser,$nosyncuserpass);
+
if ($result >= 0 && ! count($object->errors))
{
+ // Categories association
+ // First we delete all categories association
+ $sql = 'DELETE FROM ' . MAIN_DB_PREFIX . 'categorie_member';
+ $sql .= ' WHERE fk_member = ' . $object->id;
+ $resql = $db->query($sql);
+ if (! $resql) dol_print_error($db);
+
+ // Then we add the associated categories
+ $categories = GETPOST('memcats', 'array');
+
+ if (! empty($categories))
+ {
+ $cat = new Categorie($db);
+ foreach ($categories as $id_category)
+ {
+ $cat->fetch($id_category);
+ $cat->add_type($object, 'member');
+ }
+ }
+
// Logo/Photo save
$dir= $conf->adherent->dir_output . '/' . get_exdir($object->id,2,0,1,$object,'member').'/photos';
$file_OK = is_uploaded_file($_FILES['photo']['tmp_name']);
@@ -536,6 +558,18 @@ if (empty($reshook))
$result=$object->create($user);
if ($result > 0)
{
+ // Categories association
+ $memcats = GETPOST('memcats', 'array');
+ if (! empty($memcats))
+ {
+ $cat = new Categorie($db);
+ foreach ($memcats as $id_category)
+ {
+ $cat->fetch($id_category);
+ $cat->add_type($object, 'member');
+ }
+ }
+
$db->commit();
$rowid=$object->id;
$action='';
@@ -899,6 +933,15 @@ else
print $form->selectyesno("public",$object->public,1);
print "\n";
+ // Categories
+ if (! empty($conf->categorie->enabled) && ! empty($user->rights->categorie->lire))
+ {
+ print '
' . fieldLabel('Categories', 'memcars') . ' ';
+ $cate_arbo = $form->select_all_categories(Categorie::TYPE_MEMBER, null, 'parent', null, null, 1);
+ print $form->multiselectarray('memcats', $cate_arbo, GETPOST('memcats', 'array'), null, null, null, null, '100%');
+ print " ";
+ }
+
// Other attributes
$parameters=array();
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
@@ -1024,7 +1067,7 @@ else
print '';
// Ref
- print ''.$langs->trans("Ref").' '.$object->id.' ';
+ print ''.$langs->trans("Ref").' '.$object->id.' ';
// Login
if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED))
@@ -1070,7 +1113,7 @@ else
print ''.$langs->trans("Company").' societe).'"> ';
// Civility
- print ''.$langs->trans("UserTitle").' ';
+ print ' '.$langs->trans("UserTitle").' ';
print $formcompany->select_civility(isset($_POST["civility_id"])?$_POST["civility_id"]:$object->civility_id)."\n";
print ' ';
print ' ';
@@ -1144,12 +1187,27 @@ else
print $form->selectyesno("public",(isset($_POST["public"])?$_POST["public"]:$object->public),1);
print "\n";
+ // Categories
+ if (! empty( $conf->categorie->enabled ) && !empty( $user->rights->categorie->lire ))
+ {
+ print '' . fieldLabel('Categories', 'memcats') . ' ';
+ print '';
+ $cate_arbo = $form->select_all_categories(Categorie::TYPE_MEMBER, null, null, null, null, 1);
+ $c = new Categorie($db);
+ $cats = $c->containing($object->id, Categorie::TYPE_MEMBER);
+ foreach ($cats as $cat) {
+ $arrayselected[] = $cat->id;
+ }
+ print $form->multiselectarray('memcats', $cate_arbo, $arrayselected, '', 0, '', 0, '100%');
+ print " ";
+ }
+
// Other attributes
- $parameters=array();
+ $parameters=array("colspan"=>2);
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
if (empty($reshook) && ! empty($extrafields->attribute_label))
{
- print $object->showOptionals($extrafields,'edit');
+ print $object->showOptionals($extrafields,'edit',$parameters);
}
// Third party Dolibarr
@@ -1291,7 +1349,7 @@ else
$helpcontent.=dol_htmlentitiesbr($texttosend)."\n";
$label=$form->textwithpicto($tmp,$helpcontent,1,'help');
- // Cree un tableau formulaire
+ // Create form popup
$formquestion=array();
if ($object->email) $formquestion[]=array('type' => 'checkbox', 'name' => 'send_mail', 'label' => $label, 'value' => ($conf->global->ADHERENT_DEFAULT_SENDINFOBYMAIL?true:false));
if (! empty($conf->mailman->enabled) && ! empty($conf->global->ADHERENT_USE_MAILMAN)) {
@@ -1465,12 +1523,21 @@ else
// Status
print ''.$langs->trans("Status").' '.$object->getLibStatut(4).' ';
+ // Categories
+ if (! empty($conf->categorie->enabled) && ! empty($user->rights->categorie->lire))
+ {
+ print '' . $langs->trans("Categories") . ' ';
+ print '';
+ print $form->showCategories($object->id, 'member', 1);
+ print ' ';
+ }
+
// Other attributes
- $parameters=array();
+ $parameters=array('colspan'=>2);
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
if (empty($reshook) && ! empty($extrafields->attribute_label))
{
- print $object->showOptionals($extrafields);
+ print $object->showOptionals($extrafields, 'view', $parameters);
}
// Third party Dolibarr
diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php
index 8ae7332fc6e..1cd74a6748d 100644
--- a/htdocs/core/class/commonobject.class.php
+++ b/htdocs/core/class/commonobject.class.php
@@ -3572,8 +3572,8 @@ abstract class CommonObject
* Function to show lines of extrafields with output datas
*
* @param object $extrafields Extrafield Object
- * @param string $mode Show output (view) or input (edit) for extrafield
- * @param array $params Optionnal parameters
+ * @param string $mode Show output ('view') or input ('edit') for extrafield
+ * @param array $params Optionnal parameters. Example: array('colspan'=>2)
* @param string $keyprefix Prefix string to add into name and id of field (can be used to avoid duplicate names)
*
* @return string
diff --git a/htdocs/core/lib/member.lib.php b/htdocs/core/lib/member.lib.php
index 0dbdcf64a86..358209ef23e 100644
--- a/htdocs/core/lib/member.lib.php
+++ b/htdocs/core/lib/member.lib.php
@@ -1,5 +1,5 @@
+/* Copyright (C) 2006-2015 Laurent Destailleur
* Copyright (C) 2015 Alexandre Spangaro
* Copyright (C) 2015 Raphaƫl Doursenaud
*
@@ -68,17 +68,6 @@ function member_prepare_head(Adherent $object)
$h++;
}
- // Show category tab
- if (! empty($conf->categorie->enabled) && ! empty($user->rights->categorie->lire))
- {
- require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php';
- $type = Categorie::TYPE_MEMBER;
- $head[$h][0] = DOL_URL_ROOT."/categories/categorie.php?id=".$object->id.'&type='.$type;
- $head[$h][1] = $langs->trans('Categories');
- $head[$h][2] = 'category';
- $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
diff --git a/htdocs/product/card.php b/htdocs/product/card.php
index c6710c09680..31042ec240e 100644
--- a/htdocs/product/card.php
+++ b/htdocs/product/card.php
@@ -979,12 +979,12 @@ else
$doleditor->Create();
print "";
-
+
if($conf->categorie->enabled) {
// Categories
- print ''.$langs->trans("Categories").' ';
+ print ' '.$langs->trans("Categories").' ';
$cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, '', 'parent', 64, 0, 1);
- print $form->multiselectarray('categories', $cate_arbo, $arrayselected, '', 0, '', 0, 250);
+ print $form->multiselectarray('categories', $cate_arbo, $arrayselected, '', 0, '', 0, '100%');
print " ";
}
@@ -1272,7 +1272,7 @@ else
$doleditor->Create();
print "";
-
+
if($conf->categorie->enabled) {
// Categories
print ''.$langs->trans("Categories").' ';
@@ -1285,7 +1285,7 @@ else
print $form->multiselectarray('categories', $cate_arbo, $arrayselected, '', 0, '', 0, '100%');
print " ";
}
-
+
// Units
if($conf->global->PRODUCT_USE_UNITS)
{
@@ -1602,7 +1602,7 @@ else
print $form->showCategories($object->id,'product',1);
print "";
}
-
+
print "
\n";
dol_fiche_end();