NEW Replace category edition page on members with new select2 component.
This commit is contained in:
parent
b25d2ff00a
commit
ce6039f7f6
@ -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.'/core/lib/functions2.lib.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.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.'/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.'/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.'/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';
|
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
|
||||||
|
|
||||||
$langs->load("companies");
|
$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';
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||||
|
|
||||||
@ -322,8 +323,29 @@ if (empty($reshook))
|
|||||||
}
|
}
|
||||||
|
|
||||||
$result=$object->update($user,0,$nosyncuser,$nosyncuserpass);
|
$result=$object->update($user,0,$nosyncuser,$nosyncuserpass);
|
||||||
|
|
||||||
if ($result >= 0 && ! count($object->errors))
|
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
|
// Logo/Photo save
|
||||||
$dir= $conf->adherent->dir_output . '/' . get_exdir($object->id,2,0,1,$object,'member').'/photos';
|
$dir= $conf->adherent->dir_output . '/' . get_exdir($object->id,2,0,1,$object,'member').'/photos';
|
||||||
$file_OK = is_uploaded_file($_FILES['photo']['tmp_name']);
|
$file_OK = is_uploaded_file($_FILES['photo']['tmp_name']);
|
||||||
@ -536,6 +558,18 @@ if (empty($reshook))
|
|||||||
$result=$object->create($user);
|
$result=$object->create($user);
|
||||||
if ($result > 0)
|
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();
|
$db->commit();
|
||||||
$rowid=$object->id;
|
$rowid=$object->id;
|
||||||
$action='';
|
$action='';
|
||||||
@ -899,6 +933,15 @@ else
|
|||||||
print $form->selectyesno("public",$object->public,1);
|
print $form->selectyesno("public",$object->public,1);
|
||||||
print "</td></tr>\n";
|
print "</td></tr>\n";
|
||||||
|
|
||||||
|
// Categories
|
||||||
|
if (! empty($conf->categorie->enabled) && ! empty($user->rights->categorie->lire))
|
||||||
|
{
|
||||||
|
print '<tr><td>' . fieldLabel('Categories', 'memcars') . '</td><td>';
|
||||||
|
$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 "</td></tr>";
|
||||||
|
}
|
||||||
|
|
||||||
// Other attributes
|
// Other attributes
|
||||||
$parameters=array();
|
$parameters=array();
|
||||||
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
|
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
|
||||||
@ -1024,7 +1067,7 @@ else
|
|||||||
print '<table class="border" width="100%">';
|
print '<table class="border" width="100%">';
|
||||||
|
|
||||||
// Ref
|
// Ref
|
||||||
print '<tr><td>'.$langs->trans("Ref").'</td><td class="valeur" colspan="2">'.$object->id.'</td></tr>';
|
print '<tr><td width="20%">'.$langs->trans("Ref").'</td><td class="valeur" colspan="2">'.$object->id.'</td></tr>';
|
||||||
|
|
||||||
// Login
|
// Login
|
||||||
if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED))
|
if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED))
|
||||||
@ -1070,7 +1113,7 @@ else
|
|||||||
print '<tr><td id="tdcompany">'.$langs->trans("Company").'</td><td><input type="text" name="societe" size="40" value="'.(isset($_POST["societe"])?$_POST["societe"]:$object->societe).'"></td></tr>';
|
print '<tr><td id="tdcompany">'.$langs->trans("Company").'</td><td><input type="text" name="societe" size="40" value="'.(isset($_POST["societe"])?$_POST["societe"]:$object->societe).'"></td></tr>';
|
||||||
|
|
||||||
// Civility
|
// Civility
|
||||||
print '<tr><td width="20%">'.$langs->trans("UserTitle").'</td><td width="35%">';
|
print '<tr><td>'.$langs->trans("UserTitle").'</td><td>';
|
||||||
print $formcompany->select_civility(isset($_POST["civility_id"])?$_POST["civility_id"]:$object->civility_id)."\n";
|
print $formcompany->select_civility(isset($_POST["civility_id"])?$_POST["civility_id"]:$object->civility_id)."\n";
|
||||||
print '</td>';
|
print '</td>';
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
@ -1144,12 +1187,27 @@ else
|
|||||||
print $form->selectyesno("public",(isset($_POST["public"])?$_POST["public"]:$object->public),1);
|
print $form->selectyesno("public",(isset($_POST["public"])?$_POST["public"]:$object->public),1);
|
||||||
print "</td></tr>\n";
|
print "</td></tr>\n";
|
||||||
|
|
||||||
|
// Categories
|
||||||
|
if (! empty( $conf->categorie->enabled ) && !empty( $user->rights->categorie->lire ))
|
||||||
|
{
|
||||||
|
print '<tr><td>' . fieldLabel('Categories', 'memcats') . '</td>';
|
||||||
|
print '<td colspan="2">';
|
||||||
|
$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 "</td></tr>";
|
||||||
|
}
|
||||||
|
|
||||||
// Other attributes
|
// 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
|
$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))
|
if (empty($reshook) && ! empty($extrafields->attribute_label))
|
||||||
{
|
{
|
||||||
print $object->showOptionals($extrafields,'edit');
|
print $object->showOptionals($extrafields,'edit',$parameters);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Third party Dolibarr
|
// Third party Dolibarr
|
||||||
@ -1291,7 +1349,7 @@ else
|
|||||||
$helpcontent.=dol_htmlentitiesbr($texttosend)."\n";
|
$helpcontent.=dol_htmlentitiesbr($texttosend)."\n";
|
||||||
$label=$form->textwithpicto($tmp,$helpcontent,1,'help');
|
$label=$form->textwithpicto($tmp,$helpcontent,1,'help');
|
||||||
|
|
||||||
// Cree un tableau formulaire
|
// Create form popup
|
||||||
$formquestion=array();
|
$formquestion=array();
|
||||||
if ($object->email) $formquestion[]=array('type' => 'checkbox', 'name' => 'send_mail', 'label' => $label, 'value' => ($conf->global->ADHERENT_DEFAULT_SENDINFOBYMAIL?true:false));
|
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)) {
|
if (! empty($conf->mailman->enabled) && ! empty($conf->global->ADHERENT_USE_MAILMAN)) {
|
||||||
@ -1465,12 +1523,21 @@ else
|
|||||||
// Status
|
// Status
|
||||||
print '<tr><td>'.$langs->trans("Status").'</td><td class="valeur">'.$object->getLibStatut(4).'</td></tr>';
|
print '<tr><td>'.$langs->trans("Status").'</td><td class="valeur">'.$object->getLibStatut(4).'</td></tr>';
|
||||||
|
|
||||||
|
// Categories
|
||||||
|
if (! empty($conf->categorie->enabled) && ! empty($user->rights->categorie->lire))
|
||||||
|
{
|
||||||
|
print '<tr><td>' . $langs->trans("Categories") . '</td>';
|
||||||
|
print '<td colspan="2">';
|
||||||
|
print $form->showCategories($object->id, 'member', 1);
|
||||||
|
print '</td></tr>';
|
||||||
|
}
|
||||||
|
|
||||||
// Other attributes
|
// 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
|
$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))
|
if (empty($reshook) && ! empty($extrafields->attribute_label))
|
||||||
{
|
{
|
||||||
print $object->showOptionals($extrafields);
|
print $object->showOptionals($extrafields, 'view', $parameters);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Third party Dolibarr
|
// Third party Dolibarr
|
||||||
|
|||||||
@ -3572,8 +3572,8 @@ abstract class CommonObject
|
|||||||
* Function to show lines of extrafields with output datas
|
* Function to show lines of extrafields with output datas
|
||||||
*
|
*
|
||||||
* @param object $extrafields Extrafield Object
|
* @param object $extrafields Extrafield Object
|
||||||
* @param string $mode Show output (view) or input (edit) for extrafield
|
* @param string $mode Show output ('view') or input ('edit') for extrafield
|
||||||
* @param array $params Optionnal parameters
|
* @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)
|
* @param string $keyprefix Prefix string to add into name and id of field (can be used to avoid duplicate names)
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2006-2011 Laurent Destailleur <eldy@users.sourceforge.net>
|
/* Copyright (C) 2006-2015 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
* Copyright (C) 2015 Alexandre Spangaro <alexandre.spangaro@gmail.com>
|
* Copyright (C) 2015 Alexandre Spangaro <alexandre.spangaro@gmail.com>
|
||||||
* Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
|
* Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
|
||||||
*
|
*
|
||||||
@ -68,17 +68,6 @@ function member_prepare_head(Adherent $object)
|
|||||||
$h++;
|
$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
|
// Show more tabs from modules
|
||||||
// Entries must be declared in modules descriptor with line
|
// 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:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
|
||||||
|
|||||||
@ -982,9 +982,9 @@ else
|
|||||||
|
|
||||||
if($conf->categorie->enabled) {
|
if($conf->categorie->enabled) {
|
||||||
// Categories
|
// Categories
|
||||||
print '<tr><td valign="top">'.$langs->trans("Categories").'</td><td colspan="3">';
|
print '<tr><td>'.$langs->trans("Categories").'</td><td colspan="3">';
|
||||||
$cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, '', 'parent', 64, 0, 1);
|
$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 "</td></tr>";
|
print "</td></tr>";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user