diff --git a/ChangeLog b/ChangeLog
index d018c4ec8ea..8e94283923e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -7,6 +7,7 @@ English Dolibarr ChangeLog
For users:
New: [ task #867 ] Remove ESAEB external module code from core.
New: Can create proposal from an intervention.
+New: Can filter events on a group of users.
For translators:
- Update language files.
diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php
index d5434ac86bf..da5b7f95137 100644
--- a/htdocs/comm/action/index.php
+++ b/htdocs/comm/action/index.php
@@ -42,6 +42,7 @@ $filter=GETPOST("filter",'',3);
$filtera = GETPOST("userasked","int",3)?GETPOST("userasked","int",3):GETPOST("filtera","int",3);
$filtert = GETPOST("usertodo","int",3)?GETPOST("usertodo","int",3):GETPOST("filtert","int",3);
$filterd = GETPOST("userdone","int",3)?GETPOST("userdone","int",3):GETPOST("filterd","int",3);
+$usergroup = GETPOST("usergroup","int",3);
$showbirthday = empty($conf->use_javascript_ajax)?GETPOST("showbirthday","int"):1;
@@ -296,9 +297,51 @@ $paramnoaction=preg_replace('/action=[a-z_]+/','',$param);
$head = calendars_prepare_head($paramnoaction);
dol_fiche_head($head, $tabactive, $langs->trans('Agenda'), 0, 'action');
-print_actions_filter($form,$canedit,$status,$year,$month,$day,$showbirthday,$filtera,$filtert,$filterd,$pid,$socid,$listofextcals,$actioncode,1);
+print_actions_filter($form,$canedit,$status,$year,$month,$day,$showbirthday,$filtera,$filtert,$filterd,$pid,$socid,$listofextcals,$actioncode,$usergroup);
dol_fiche_end();
+$showextcals=$listofextcals;
+// Legend
+if ($conf->use_javascript_ajax)
+{
+ $s='';
+ //print '
| ';
+
+ //print $langs->trans("Calendars").': ';
+ //print ' | ';
+ $s.='' . "\n";
+ if (! empty($conf->use_javascript_ajax))
+ {
+ $s.=' ' . $langs->trans("LocalAgenda").' ';
+ if (is_array($showextcals) && count($showextcals) > 0)
+ {
+ foreach ($showextcals as $val)
+ {
+ $htmlname = dol_string_nospecial($val['name']);
+ $s.='' . "\n";
+ $s.=' ' . $val ['name'] . ' ';
+ }
+ }
+ }
+ $s.=' '.$langs->trans("AgendaShowBirthdayEvents").' ';
+
+ //print ' |
';
+}
+
+
$link='';
// Add link to show birthdays
if (empty($conf->use_javascript_ajax))
@@ -314,7 +357,7 @@ if (empty($conf->use_javascript_ajax))
$link.='';
}
-print_fiche_titre($title,$link.' '.$nav, '');
+print_fiche_titre($s,$link.' '.$nav, '');
// Get event in an array
@@ -330,15 +373,16 @@ $sql.= ' a.fk_user_author,a.fk_user_action,a.fk_user_done,';
$sql.= ' a.transparency, a.priority, a.fulldayevent, a.location,';
$sql.= ' a.fk_soc, a.fk_contact,';
$sql.= ' ca.code';
-$sql.= ' FROM ('.MAIN_DB_PREFIX.'c_actioncomm as ca,';
-$sql.= " ".MAIN_DB_PREFIX."actioncomm as a)";
+$sql.= ' FROM '.MAIN_DB_PREFIX.'c_actioncomm as ca, '.MAIN_DB_PREFIX."actioncomm as a";
if (! $user->rights->societe->client->voir && ! $socid) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc";
+if ($usergroup) $sql.= ", ".MAIN_DB_PREFIX."usergroup_user as ugu";
$sql.= ' WHERE a.fk_action = ca.id';
$sql.= ' AND a.entity IN ('.getEntity('agenda', 1).')';
if ($actioncode) $sql.=" AND ca.code='".$db->escape($actioncode)."'";
if ($pid) $sql.=" AND a.fk_project=".$db->escape($pid);
if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND (a.fk_soc IS NULL OR sc.fk_user = " .$user->id . ")";
-if ($user->societe_id) $sql.= ' AND a.fk_soc = '.$user->societe_id; // To limit to external user company
+if ($socid) $sql.= ' AND a.fk_soc = '.$socid;
+if ($usergroup) $sql.= " AND ugu.fk_user = a.fk_user_action";
if ($action == 'show_day')
{
$sql.= " AND (";
@@ -372,12 +416,13 @@ if ($status == '-1') { $sql.= " AND a.percent = -1"; } // Not applicable
if ($status == '50') { $sql.= " AND (a.percent >= 0 AND a.percent < 100)"; } // Running
if ($status == 'done' || $status == '100') { $sql.= " AND (a.percent = 100 OR (a.percent = -1 AND a.datep2 <= '".$db->idate($now)."'))"; }
if ($status == 'todo') { $sql.= " AND ((a.percent >= 0 AND a.percent < 100) OR (a.percent = -1 AND a.datep2 > '".$db->idate($now)."'))"; }
-if ($filtera > 0 || $filtert > 0 || $filterd > 0)
+if ($filtera > 0 || $filtert > 0 || $filterd > 0 || $usergroup)
{
$sql.= " AND (";
if ($filtera > 0) $sql.= " a.fk_user_author = ".$filtera;
if ($filtert > 0) $sql.= ($filtera>0?" OR ":"")." a.fk_user_action = ".$filtert;
if ($filterd > 0) $sql.= ($filtera>0||$filtert>0?" OR ":"")." a.fk_user_done = ".$filterd;
+ if ($usergroup) $sql.= ($filtera>0||$filtert>0||$filterd>0?" OR ":"")." ugu.fk_usergroup = ".$usergroup;
$sql.= ")";
}
// Sort on date
diff --git a/htdocs/comm/action/listactions.php b/htdocs/comm/action/listactions.php
index 494a5339f96..d98c84e7bae 100644
--- a/htdocs/comm/action/listactions.php
+++ b/htdocs/comm/action/listactions.php
@@ -146,6 +146,7 @@ $sql.= " FROM ".MAIN_DB_PREFIX."c_actioncomm as c,";
$sql.= " ".MAIN_DB_PREFIX.'user as u,';
$sql.= " ".MAIN_DB_PREFIX."actioncomm as a";
if (! $user->rights->societe->client->voir && ! $socid) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc";
+if ($usergroup) $sql.= ", ".MAIN_DB_PREFIX."usergroup_user as ugu";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON a.fk_soc = s.rowid";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople as sp ON a.fk_contact = sp.rowid";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as ua ON a.fk_user_author = ua.rowid";
@@ -153,24 +154,26 @@ $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as ut ON a.fk_user_action = ut.rowid";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as ud ON a.fk_user_done = ud.rowid";
$sql.= " WHERE c.id = a.fk_action";
$sql.= ' AND a.fk_user_author = u.rowid';
-$sql.= ' AND a.entity IN ('.getEntity().')'; // To limit to entity
+$sql.= ' AND a.entity IN ('.getEntity('agenda', 1).')'; // To limit to entity
if ($actioncode) $sql.=" AND c.code='".$db->escape($actioncode)."'";
if ($pid) $sql.=" AND a.fk_project=".$db->escape($pid);
if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND (a.fk_soc IS NULL OR sc.fk_user = " .$user->id . ")";
if ($socid) $sql.= " AND s.rowid = ".$socid;
+if ($usergroup) $sql.= " AND ugu.fk_user = a.fk_user_action";
if ($type) $sql.= " AND c.id = ".$type;
if ($status == '0') { $sql.= " AND a.percent = 0"; }
if ($status == '-1') { $sql.= " AND a.percent = -1"; } // Not applicable
if ($status == '50') { $sql.= " AND (a.percent >= 0 AND a.percent < 100)"; } // Running
if ($status == 'done' || $status == '100') { $sql.= " AND (a.percent = 100 OR (a.percent = -1 AND a.datep2 <= '".$db->idate($now)."'))"; }
if ($status == 'todo') { $sql.= " AND ((a.percent >= 0 AND a.percent < 100) OR (a.percent = -1 AND a.datep2 > '".$db->idate($now)."'))"; }
-if ($filtera > 0 || $filtert > 0 || $filterd > 0)
+if ($filtera > 0 || $filtert > 0 || $filterd > 0 || $usergroup)
{
- $sql.= " AND (";
- if ($filtera > 0) $sql.= " a.fk_user_author = ".$filtera;
- if ($filtert > 0) $sql.= ($filtera>0?" OR ":"")." a.fk_user_action = ".$filtert;
- if ($filterd > 0) $sql.= ($filtera>0||$filtert>0?" OR ":"")." a.fk_user_done = ".$filterd;
- $sql.= ")";
+ $sql.= " AND (";
+ if ($filtera > 0) $sql.= " a.fk_user_author = ".$filtera;
+ if ($filtert > 0) $sql.= ($filtera>0?" OR ":"")." a.fk_user_action = ".$filtert;
+ if ($filterd > 0) $sql.= ($filtera>0||$filtert>0?" OR ":"")." a.fk_user_done = ".$filterd;
+ if ($usergroup) $sql.= ($filtera>0||$filtert>0||$filterd>0?" OR ":"")." ugu.fk_usergroup = ".$usergroup;
+ $sql.= ")";
}
$sql.= $db->order($sortfield,$sortorder);
$sql.= $db->plimit($limit + 1, $offset);
@@ -210,7 +213,7 @@ if ($resql)
$head = calendars_prepare_head('');
dol_fiche_head($head, $tabactive, $langs->trans('Agenda'), 0, 'action');
- print_actions_filter($form,$canedit,$status,$year,$month,$day,$showbirthday,$filtera,$filtert,$filterd,$pid,$socid,-1,'',0);
+ print_actions_filter($form,$canedit,$status,$year,$month,$day,$showbirthday,$filtera,$filtert,$filterd,$pid,$socid,-1,'');
dol_fiche_end();
// Add link to show birthdays
diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php
index e08a076624e..0adb10c1d22 100644
--- a/htdocs/core/class/html.form.class.php
+++ b/htdocs/core/class/html.form.class.php
@@ -4239,7 +4239,7 @@ class Form
$i = 0;
if ($num)
{
- $out.= '