New: Can filter events on a group of users.
This commit is contained in:
parent
03c6d8fdc3
commit
6916d251b5
@ -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.
|
||||
|
||||
@ -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 '<tr><td>';
|
||||
|
||||
//print $langs->trans("Calendars").': ';
|
||||
//print '<td align="center" valign="middle" class="nowrap">';
|
||||
$s.='<script type="text/javascript">' . "\n";
|
||||
$s.='jQuery(document).ready(function () {' . "\n";
|
||||
$s.='jQuery("#check_mytasks").click(function() { jQuery(".family_mytasks").toggle(); jQuery(".family_other").toggle(); });' . "\n";
|
||||
$s.='jQuery("#check_birthday").click(function() { jQuery(".family_birthday").toggle(); });' . "\n";
|
||||
$s.='jQuery(".family_birthday").toggle();' . "\n";
|
||||
$s.='});' . "\n";
|
||||
$s.='</script>' . "\n";
|
||||
if (! empty($conf->use_javascript_ajax))
|
||||
{
|
||||
$s.='<div class="nowrap clear float"><input type="checkbox" id="check_mytasks" name="check_mytasks" checked="true" disabled="disabled"> ' . $langs->trans("LocalAgenda").' </div>';
|
||||
if (is_array($showextcals) && count($showextcals) > 0)
|
||||
{
|
||||
foreach ($showextcals as $val)
|
||||
{
|
||||
$htmlname = dol_string_nospecial($val['name']);
|
||||
$s.='<script type="text/javascript">' . "\n";
|
||||
$s.='jQuery(document).ready(function () {' . "\n";
|
||||
$s.=' jQuery("#check_' . $htmlname . '").click(function() {';
|
||||
$s.=' /* alert("'.$htmlname.'"); */';
|
||||
$s.=' jQuery(".family_' . $htmlname . '").toggle();';
|
||||
$s.=' });' . "\n";
|
||||
$s.='});' . "\n";
|
||||
$s.='</script>' . "\n";
|
||||
$s.='<div class="nowrap float"><input type="checkbox" id="check_' . $htmlname . '" name="check_' . $htmlname . '" checked="true"> ' . $val ['name'] . ' </div>';
|
||||
}
|
||||
}
|
||||
}
|
||||
$s.='<div class="nowrap float"><input type="checkbox" id="check_birthday" name="check_birthday"> '.$langs->trans("AgendaShowBirthdayEvents").' </div>';
|
||||
|
||||
//print '</td></tr>';
|
||||
}
|
||||
|
||||
|
||||
$link='';
|
||||
// Add link to show birthdays
|
||||
if (empty($conf->use_javascript_ajax))
|
||||
@ -314,7 +357,7 @@ if (empty($conf->use_javascript_ajax))
|
||||
$link.='</a>';
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -4239,7 +4239,7 @@ class Form
|
||||
$i = 0;
|
||||
if ($num)
|
||||
{
|
||||
$out.= '<select class="flat" name="'.$htmlname.'"'.($disabled?' disabled="disabled"':'').'>';
|
||||
$out.= '<select class="flat" id="'.$htmlname.'" name="'.$htmlname.'"'.($disabled?' disabled="disabled"':'').'>';
|
||||
if ($show_empty) $out.= '<option value="-1"'.($selected==-1?' selected="selected"':'').'> </option>'."\n";
|
||||
|
||||
while ($i < $num)
|
||||
|
||||
@ -41,17 +41,16 @@
|
||||
* @param int $socid Third party id
|
||||
* @param array $showextcals Array with list of external calendars (used to show links to select calendar), or -1 to show no legend
|
||||
* @param string $actioncode Preselected value of actioncode for filter on type
|
||||
* @param int $showbirthday Show check to toggle birthday events
|
||||
* @param int $usergroupid Id of group to filter on users
|
||||
* @return void
|
||||
*/
|
||||
function print_actions_filter($form, $canedit, $status, $year, $month, $day, $showbirthday, $filtera, $filtert, $filterd, $pid, $socid, $showextcals=array(), $actioncode='', $showbirthday=0)
|
||||
function print_actions_filter($form, $canedit, $status, $year, $month, $day, $showbirthday, $filtera, $filtert, $filterd, $pid, $socid, $showextcals=array(), $actioncode='', $usergroupid='')
|
||||
{
|
||||
global $conf, $user, $langs, $db;
|
||||
|
||||
// Filters
|
||||
print '<form name="listactionsfilter" class="listactionsfilter" action="' . $_SERVER["PHP_SELF"] . '" method="POST">';
|
||||
print '<input type="hidden" name="token" value="' . $_SESSION ['newtoken'] . '">';
|
||||
print '<input type="hidden" name="status" value="' . $status . '">';
|
||||
print '<input type="hidden" name="year" value="' . $year . '">';
|
||||
print '<input type="hidden" name="month" value="' . $month . '">';
|
||||
print '<input type="hidden" name="day" value="' . $day . '">';
|
||||
@ -80,6 +79,10 @@ function print_actions_filter($form, $canedit, $status, $year, $month, $day, $sh
|
||||
//print ' ';
|
||||
print $form->select_dolusers($filtert, 'usertodo', 1, '', ! $canedit);
|
||||
print ajax_combobox('usertodo');
|
||||
print ' '.$langs->trans("or") . ' ';
|
||||
print $langs->trans("ActionsForUsersGroup").' ';
|
||||
print $form->select_dolgroups($usergroupid, 'usergroup', 1, '', ! $canedit);
|
||||
print ajax_combobox('usergroup');
|
||||
print '</td></tr>';
|
||||
|
||||
/*print '<tr>';
|
||||
@ -146,44 +149,6 @@ function print_actions_filter($form, $canedit, $status, $year, $month, $day, $sh
|
||||
print '</div>';
|
||||
print '</td></tr>';
|
||||
|
||||
// Legend
|
||||
if ($conf->use_javascript_ajax)
|
||||
{
|
||||
print '<tr><td>';
|
||||
|
||||
//print $langs->trans("Calendars").': ';
|
||||
//print '<td align="center" valign="middle" class="nowrap">';
|
||||
print '<script type="text/javascript">' . "\n";
|
||||
print 'jQuery(document).ready(function () {' . "\n";
|
||||
print 'jQuery("#check_mytasks").click(function() { jQuery(".family_mytasks").toggle(); jQuery(".family_other").toggle(); });' . "\n";
|
||||
print 'jQuery("#check_birthday").click(function() { jQuery(".family_birthday").toggle(); });' . "\n";
|
||||
print 'jQuery(".family_birthday").toggle();' . "\n";
|
||||
print '});' . "\n";
|
||||
print '</script>' . "\n";
|
||||
if (! empty($conf->use_javascript_ajax))
|
||||
{
|
||||
if (is_array($showextcals) && count($showextcals) > 0)
|
||||
{
|
||||
print '<div class="nowrap clear float"><input type="checkbox" id="check_mytasks" name="check_mytasks" checked="true" disabled="disabled"> ' . $langs->trans("LocalAgenda").' </div>';
|
||||
foreach ($showextcals as $val)
|
||||
{
|
||||
$htmlname = dol_string_nospecial($val['name']);
|
||||
print '<script type="text/javascript">' . "\n";
|
||||
print 'jQuery(document).ready(function () {' . "\n";
|
||||
print ' jQuery("#check_' . $htmlname . '").click(function() {';
|
||||
print ' /* alert("'.$htmlname.'"); */';
|
||||
print ' jQuery(".family_' . $htmlname . '").toggle();';
|
||||
print ' });' . "\n";
|
||||
print '});' . "\n";
|
||||
print '</script>' . "\n";
|
||||
print '<div class="nowrap float"><input type="checkbox" id="check_' . $htmlname . '" name="check_' . $htmlname . '" checked="true"> ' . $val ['name'] . ' </div>';
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($showbirthday) print '<div class="nowrap float"><input type="checkbox" id="check_birthday" name="check_birthday"> '.$langs->trans("AgendaShowBirthdayEvents").' </div>';
|
||||
|
||||
print '</td></tr>';
|
||||
}
|
||||
print '</table>';
|
||||
|
||||
print '</div>';
|
||||
|
||||
@ -25,7 +25,8 @@ ListOfEvents= List of Dolibarr events
|
||||
ActionsAskedBy=Events reported by
|
||||
ActionsToDoBy=Events assigned to
|
||||
ActionsDoneBy=Events done by
|
||||
ActionsAskedBy=Events for user
|
||||
ActionsForUser=Events for user
|
||||
ActionsForUsersGroup=Events for all users of group
|
||||
AllMyActions= All my events/tasks
|
||||
AllActions= All events/tasks
|
||||
ViewList=List view
|
||||
|
||||
Loading…
Reference in New Issue
Block a user