Fix: The filter into event views on user must be done on assigned
resource, not only owner.
This commit is contained in:
parent
68441a563a
commit
ba49cce47a
@ -141,6 +141,9 @@ class ActionComm extends CommonObject
|
||||
$userownerid=$this->userownerid;
|
||||
$userdoneid=$this->userdoneid;
|
||||
|
||||
// Be sure assigned user array is not empty.
|
||||
if (count($this->userassigned) == 0) $this->userassigned = array('id'=>$this->$userownerid);
|
||||
|
||||
if (! $this->type_id || ! $this->type_code)
|
||||
{
|
||||
$key=empty($this->type_id)?$this->type_code:$this->type_id;
|
||||
|
||||
@ -40,9 +40,7 @@ if (! empty($conf->projet->enabled)) {
|
||||
if (! isset($conf->global->AGENDA_MAX_EVENTS_DAY_VIEW)) $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW=3;
|
||||
|
||||
$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;
|
||||
|
||||
@ -72,9 +70,7 @@ if (! $user->rights->agenda->myactions->read) accessforbidden();
|
||||
if (! $user->rights->agenda->allactions->read) $canedit=0;
|
||||
if (! $user->rights->agenda->allactions->read || $filter =='mine') // If no permission to see all, we show only affected to me
|
||||
{
|
||||
$filtera=$user->id;
|
||||
$filtert=$user->id;
|
||||
$filterd=$user->id;
|
||||
}
|
||||
|
||||
$action=GETPOST('action','alpha');
|
||||
@ -283,9 +279,7 @@ $param='';
|
||||
if ($actioncode || isset($_GET['actioncode']) || isset($_POST['actioncode'])) $param.="&actioncode=".$actioncode;
|
||||
if ($status || isset($_GET['status']) || isset($_POST['status'])) $param.="&status=".$status;
|
||||
if ($filter) $param.="&filter=".$filter;
|
||||
if ($filtera) $param.="&filtera=".$filtera;
|
||||
if ($filtert) $param.="&filtert=".$filtert;
|
||||
if ($filterd) $param.="&filterd=".$filterd;
|
||||
if ($socid) $param.="&socid=".$socid;
|
||||
if ($showbirthday) $param.="&showbirthday=1";
|
||||
if ($pid) $param.="&projectid=".$pid;
|
||||
@ -340,7 +334,7 @@ $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,$action,$listofextcals,$actioncode,$usergroup);
|
||||
print_actions_filter($form,$canedit,$status,$year,$month,$day,$showbirthday,0,$filtert,0,$pid,$socid,$action,$listofextcals,$actioncode,$usergroup);
|
||||
dol_fiche_end();
|
||||
|
||||
$showextcals=$listofextcals;
|
||||
@ -405,27 +399,29 @@ print_fiche_titre($s,$link.' '.$nav, '');
|
||||
// Get event in an array
|
||||
$eventarray=array();
|
||||
|
||||
$sql = 'SELECT a.id,a.label,';
|
||||
$sql = 'SELECT ';
|
||||
if ($usergroup > 0) $sql.=" DISTINCT";
|
||||
$sql.= ' a.id, a.label,';
|
||||
$sql.= ' a.datep,';
|
||||
$sql.= ' a.datep2,';
|
||||
$sql.= ' a.datea,';
|
||||
$sql.= ' a.datea2,';
|
||||
$sql.= ' a.percent,';
|
||||
$sql.= ' a.fk_user_author,a.fk_user_action,a.fk_user_done,';
|
||||
$sql.= ' a.fk_user_author,a.fk_user_action,';
|
||||
$sql.= ' a.transparency, a.priority, a.fulldayevent, a.location,';
|
||||
$sql.= ' a.fk_soc, a.fk_contact,';
|
||||
$sql.= ' ca.code as type_code, ca.libelle as type_label';
|
||||
$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 > 0) $sql.= ", ".MAIN_DB_PREFIX."usergroup_user as ugu";
|
||||
// We must filter on assignement table
|
||||
if ($filtert > 0 || $usergroup > 0) $sql.=", ".MAIN_DB_PREFIX."actioncomm_resources as ar";
|
||||
if ($usergroup > 0) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_user = ar.fk_element";
|
||||
$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 ($socid > 0) $sql.= ' AND a.fk_soc = '.$socid;
|
||||
// FIXME: We must filter on assignement table
|
||||
if ($usergroup > 0) $sql.= " AND ugu.fk_user = a.fk_user_action";
|
||||
// We must filter on assignement table
|
||||
if ($filtert > 0 || $usergroup > 0) $sql.= " AND ar.fk_actioncomm = a.id AND ar.element_type='user'";
|
||||
if ($action == 'show_day')
|
||||
{
|
||||
$sql.= " AND (";
|
||||
@ -459,14 +455,12 @@ if ($status == '-1') { $sql.= " AND a.percent = -1"; } // Not applicable
|
||||
if ($status == '50') { $sql.= " AND (a.percent > 0 AND a.percent < 100)"; } // Running already started
|
||||
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)."'))"; }
|
||||
// FIXME: We must filter on assignement table
|
||||
if ($filtera > 0 || $filtert > 0 || $filterd > 0 || $usergroup > 0)
|
||||
// We must filter on assignement table
|
||||
if ($filtert > 0 || $usergroup > 0)
|
||||
{
|
||||
$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 > 0) $sql.= ($filtera>0||$filtert>0||$filterd>0?" OR ":"")." ugu.fk_usergroup = ".$usergroup;
|
||||
if ($filtert > 0) $sql.= "ar.fk_element = ".$filtert;
|
||||
if ($usergroup > 0) $sql.= ($filtert>0?" OR ":"")." ugu.fk_usergroup = ".$usergroup;
|
||||
$sql.= ")";
|
||||
}
|
||||
// Sort on date
|
||||
@ -1094,7 +1088,7 @@ $db->close();
|
||||
function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventarray, $maxprint=0, $maxnbofchar=16, $newparam='', $showinfo=0, $minheight=60)
|
||||
{
|
||||
global $user, $conf, $langs;
|
||||
global $action, $filter, $filtera, $filtert, $filterd, $status, $actioncode; // Filters used into search form
|
||||
global $action, $filter, $filtert, $status, $actioncode; // Filters used into search form
|
||||
global $theme_datacolor;
|
||||
global $cachethirdparties, $cachecontacts, $cacheusers, $colorindexused;
|
||||
|
||||
@ -1383,7 +1377,7 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa
|
||||
{
|
||||
print '<a href="'.DOL_URL_ROOT.'/comm/action/index.php?action='.$action.'&maxprint=0&month='.$monthshown.'&year='.$year;
|
||||
print ($status?'&status='.$status:'').($filter?'&filter='.$filter:'');
|
||||
print ($filtera?'&filtera='.$filtera:'').($filtert?'&filtert='.$filtert:'').($filterd?'&filterd='.$filterd:'');
|
||||
print ($filtert?'&filtert='.$filtert:'');
|
||||
print ($actioncode!=''?'&actioncode='.$actioncode:'');
|
||||
print '">'.img_picto("all","1downarrow_selected.png").' ...';
|
||||
print ' +'.(count($eventarray[$daykey])-$maxprint);
|
||||
|
||||
@ -30,6 +30,7 @@ require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php';
|
||||
|
||||
$langs->load("users");
|
||||
$langs->load("companies");
|
||||
$langs->load("agenda");
|
||||
$langs->load("commercial");
|
||||
@ -52,9 +53,7 @@ if ($status == '' && ! isset($_GET['status']) && ! isset($_POST['status'])) $s
|
||||
if (empty($action) && ! isset($_GET['action']) && ! isset($_POST['action'])) $action=(empty($conf->global->AGENDA_DEFAULT_VIEW)?'show_month':$conf->global->AGENDA_DEFAULT_VIEW);
|
||||
|
||||
$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;
|
||||
|
||||
@ -94,9 +93,7 @@ if (! $user->rights->agenda->myactions->read) accessforbidden();
|
||||
if (! $user->rights->agenda->allactions->read) $canedit=0;
|
||||
if (! $user->rights->agenda->allactions->read || $filter=='mine') // If no permission to see all, we show only affected to me
|
||||
{
|
||||
$filtera=$user->id;
|
||||
$filtert=$user->id;
|
||||
$filterd=$user->id;
|
||||
}
|
||||
|
||||
// Purge search criteria
|
||||
@ -133,15 +130,14 @@ if (GETPOST("viewcal") || GETPOST("viewweek") || GETPOST("viewday"))
|
||||
*/
|
||||
|
||||
$form=new Form($db);
|
||||
$userstatic=new User($db);
|
||||
|
||||
$nav='';
|
||||
$nav.=' <form name="dateselect" action="'.$_SERVER["PHP_SELF"].'?action=show_peruser'.$param.'">';
|
||||
if ($actioncode || isset($_GET['actioncode']) || isset($_POST['actioncode'])) $nav.='<input type="hidden" name="actioncode" value="'.$actioncode.'">';
|
||||
if ($status || isset($_GET['status']) || isset($_POST['status'])) $nav.='<input type="hidden" name="status" value="'.$status.'">';
|
||||
if ($filter) $nav.='<input type="hidden" name="filter" value="'.$filter.'">';
|
||||
if ($filtera) $nav.='<input type="hidden" name="filtera" value="'.$filtera.'">';
|
||||
if ($filtert) $nav.='<input type="hidden" name="filtert" value="'.$filtert.'">';
|
||||
if ($filterd) $nav.='<input type="hidden" name="filterd" value="'.$filterd.'">';
|
||||
if ($socid) $nav.='<input type="hidden" name="socid" value="'.$socid.'">';
|
||||
if ($showbirthday) $nav.='<input type="hidden" name="showbirthday" value="1">';
|
||||
if ($pid) $nav.='<input type="hidden" name="projectid" value="'.$pid.'">';
|
||||
@ -163,65 +159,57 @@ $param='';
|
||||
if ($actioncode || isset($_GET['actioncode']) || isset($_POST['actioncode'])) $param.="&actioncode=".$actioncode;
|
||||
if ($status || isset($_GET['status']) || isset($_POST['status'])) $param.="&status=".$status;
|
||||
if ($filter) $param.="&filter=".$filter;
|
||||
if ($filtera) $param.="&filtera=".$filtera;
|
||||
if ($filtert) $param.="&filtert=".$filtert;
|
||||
if ($filterd) $param.="&filterd=".$filterd;
|
||||
if ($socid) $param.="&socid=".$socid;
|
||||
if ($showbirthday) $param.="&showbirthday=1";
|
||||
if ($pid) $param.="&projectid=".$pid;
|
||||
if ($type) $param.="&type=".$type;
|
||||
if ($usergroup) $param.="&usergroup=".$usergroup;
|
||||
|
||||
$sql = "SELECT s.nom as societe, s.rowid as socid, s.client,";
|
||||
$sql.= " a.id, a.datep as dp, a.datep2 as dp2,";
|
||||
$sql.= " a.fk_contact, a.note, a.label, a.percent as percent,";
|
||||
$sql = "SELECT";
|
||||
if ($usergroup > 0) $sql.=" DISTINCT";
|
||||
$sql.= " s.nom as societe, s.rowid as socid, s.client,";
|
||||
$sql.= " a.id, a.label, a.datep as dp, a.datep2 as dp2,";
|
||||
$sql.= ' a.fk_user_author,a.fk_user_action,';
|
||||
$sql.= " a.fk_contact, a.note, a.percent as percent,";
|
||||
$sql.= " c.code as type_code, c.libelle as type_label,";
|
||||
$sql.= " ua.login as loginauthor, ua.rowid as useridauthor,";
|
||||
$sql.= " ut.login as logintodo, ut.rowid as useridtodo,";
|
||||
//$sql.= " ud.login as logindone, ud.rowid as useriddone,";
|
||||
$sql.= " sp.lastname, sp.firstname";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."c_actioncomm as c,";
|
||||
$sql.= " ".MAIN_DB_PREFIX.'user as u,';
|
||||
$sql.= " ".MAIN_DB_PREFIX."actioncomm as a";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."c_actioncomm as c, ".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";
|
||||
$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";
|
||||
$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";
|
||||
if ($usergroup > 0) $sql.= ", ".MAIN_DB_PREFIX."usergroup_user as ugu";
|
||||
// We must filter on assignement table
|
||||
if ($filtert > 0 || $usergroup > 0) $sql.=", ".MAIN_DB_PREFIX."actioncomm_resources as ar";
|
||||
if ($usergroup > 0) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_user = ar.fk_element";
|
||||
$sql.= " WHERE c.id = a.fk_action";
|
||||
$sql.= ' AND a.fk_user_author = u.rowid';
|
||||
$sql.= ' AND a.entity IN ('.getEntity('agenda', 1).')';
|
||||
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 > 0) $sql.= " AND s.rowid = ".$socid;
|
||||
// FIXME: We must filter on assignement table
|
||||
if ($usergroup > 0) $sql.= " AND ugu.fk_user = a.fk_user_action";
|
||||
// We must filter on assignement table
|
||||
if ($filtert > 0 || $usergroup > 0) $sql.= " AND ar.fk_actioncomm = a.id AND ar.element_type='user'";
|
||||
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 already started
|
||||
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)."'))"; }
|
||||
// FIXME: We must filter on assignement table
|
||||
if ($filtera > 0 || $filtert > 0 || $filterd > 0 || $usergroup > 0)
|
||||
// We must filter on assignement table
|
||||
if ($filtert > 0 || $usergroup > 0)
|
||||
{
|
||||
$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 > 0) $sql.= ($filtera>0||$filtert>0||$filterd>0?" OR ":"")." ugu.fk_usergroup = ".$usergroup;
|
||||
if ($filtert > 0) $sql.= "ar.fk_element = ".$filtert;
|
||||
if ($usergroup > 0) $sql.= ($filtert>0?" OR ":"")." ugu.fk_usergroup = ".$usergroup;
|
||||
$sql.= ")";
|
||||
}
|
||||
|
||||
// The second or of next test is to take event with no end date (we suppose duration is 1 hour in such case)
|
||||
if ($dateselect > 0) $sql.= " AND ((a.datep2 >= '".$db->idate($dateselect)."' AND a.datep <= '".$db->idate($dateselect+3600*24-1)."') OR (a.datep2 IS NULL AND a.datep > '".$db->idate($dateselect-3600)."' AND a.datep <= '".$db->idate($dateselect+3600*24-1)."'))";
|
||||
if ($datestart > 0) $sql.= " AND a.datep BETWEEN '".$db->idate($datestart)."' AND '".$db->idate($datestart+3600*24-1)."'";
|
||||
if ($dateend > 0) $sql.= " AND a.datep2 BETWEEN '".$db->idate($dateend)."' AND '".$db->idate($dateend+3600*24-1)."'";
|
||||
$sql.= $db->order($sortfield,$sortorder);
|
||||
$sql.= $db->plimit($limit + 1, $offset);
|
||||
|
||||
//print $sql;
|
||||
|
||||
dol_syslog("comm/action/listactions.php", LOG_DEBUG);
|
||||
@ -246,7 +234,7 @@ if ($resql)
|
||||
$head = calendars_prepare_head($param);
|
||||
|
||||
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,$action,-1,$actioncode,$usergroup);
|
||||
print_actions_filter($form,$canedit,$status,$year,$month,$day,$showbirthday,0,$filtert,0,$pid,$socid,$action,-1,$actioncode,$usergroup);
|
||||
dol_fiche_end();
|
||||
|
||||
// Add link to show birthdays
|
||||
@ -275,14 +263,11 @@ if ($resql)
|
||||
print '<table class="liste" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
print_liste_field_titre($langs->trans("Action"),$_SERVER["PHP_SELF"],"a.label",$param,"","",$sortfield,$sortorder);
|
||||
//print_liste_field_titre($langs->trans("Title"),$_SERVER["PHP_SELF"],"a.label",$param,"","",$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("DateStart"),$_SERVER["PHP_SELF"],"a.datep",$param,'','align="center"',$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("DateEnd"),$_SERVER["PHP_SELF"],"a.datep2",$param,'','align="center"',$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("Company"),$_SERVER["PHP_SELF"],"s.nom",$param,"","",$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("Contact"),$_SERVER["PHP_SELF"],"a.fk_contact",$param,"","",$sortfield,$sortorder);
|
||||
//print_liste_field_titre($langs->trans("ActionUserAsk"),$_SERVER["PHP_SELF"],"ua.login",$param,"","",$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("ActionsOwnedBy"),$_SERVER["PHP_SELF"],"ut.login",$param,"","",$sortfield,$sortorder);
|
||||
//print_liste_field_titre($langs->trans("DoneBy"),$_SERVER["PHP_SELF"],"ud.login",$param,"","",$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("ActionsOwnedBy"),$_SERVER["PHP_SELF"],"",$param,"","",$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"a.percent",$param,"",'align="right"',$sortfield,$sortorder);
|
||||
print "</tr>\n";
|
||||
|
||||
@ -375,46 +360,16 @@ if ($resql)
|
||||
}
|
||||
print '</td>';
|
||||
|
||||
// User author
|
||||
/*
|
||||
print '<td align="left">';
|
||||
if ($obj->useridauthor)
|
||||
{
|
||||
$userstatic=new User($db);
|
||||
$userstatic->id=$obj->useridauthor;
|
||||
$userstatic->login=$obj->loginauthor;
|
||||
print $userstatic->getLoginUrl(1);
|
||||
}
|
||||
else print ' ';
|
||||
print '</td>';
|
||||
*/
|
||||
|
||||
// User to do
|
||||
print '<td align="left">';
|
||||
if ($obj->useridtodo)
|
||||
if ($obj->fk_user_action > 0)
|
||||
{
|
||||
$userstatic=new User($db);
|
||||
$userstatic->id=$obj->useridtodo;
|
||||
$userstatic->login=$obj->logintodo;
|
||||
$userstatic->fetch($obj->fk_user_action);
|
||||
print $userstatic->getLoginUrl(1);
|
||||
}
|
||||
else print ' ';
|
||||
print '</td>';
|
||||
|
||||
// User did
|
||||
/*
|
||||
print '<td align="left">';
|
||||
if ($obj->useriddone)
|
||||
{
|
||||
$userstatic=new User($db);
|
||||
$userstatic->id=$obj->useriddone;
|
||||
$userstatic->login=$obj->logindone;
|
||||
print $userstatic->getLoginUrl(1);
|
||||
}
|
||||
else print ' ';
|
||||
print '</td>';
|
||||
*/
|
||||
|
||||
// Status/Percent
|
||||
print '<td align="right" class="nowrap">'.$actionstatic->LibStatut($obj->percent,6).'</td>';
|
||||
|
||||
@ -434,6 +389,6 @@ else
|
||||
}
|
||||
|
||||
|
||||
$db->close();
|
||||
|
||||
llxFooter();
|
||||
|
||||
$db->close();
|
||||
|
||||
@ -39,9 +39,7 @@ if (! empty($conf->projet->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/class
|
||||
if (! isset($conf->global->AGENDA_MAX_EVENTS_DAY_VIEW)) $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW=3;
|
||||
|
||||
$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);
|
||||
//if (! ($usergroup > 0) && ! ($filtert > 0)) $filtert = $user->id;
|
||||
//$showbirthday = empty($conf->use_javascript_ajax)?GETPOST("showbirthday","int"):1;
|
||||
@ -73,9 +71,7 @@ if (! $user->rights->agenda->myactions->read) accessforbidden();
|
||||
if (! $user->rights->agenda->allactions->read) $canedit=0;
|
||||
if (! $user->rights->agenda->allactions->read || $filter =='mine') // If no permission to see all, we show only affected to me
|
||||
{
|
||||
$filtera=$user->id;
|
||||
$filtert=$user->id;
|
||||
$filterd=$user->id;
|
||||
}
|
||||
|
||||
//$action=GETPOST('action','alpha');
|
||||
@ -130,6 +126,7 @@ if (GETPOST('viewday') || $action == 'show_day') {
|
||||
} // View by day
|
||||
|
||||
|
||||
$langs->load("users");
|
||||
$langs->load("agenda");
|
||||
$langs->load("other");
|
||||
$langs->load("commercial");
|
||||
@ -198,9 +195,7 @@ $param='';
|
||||
if ($actioncode || isset($_GET['actioncode']) || isset($_POST['actioncode'])) $param.="&actioncode=".$actioncode;
|
||||
if ($status || isset($_GET['status']) || isset($_POST['status'])) $param.="&status=".$status;
|
||||
if ($filter) $param.="&filter=".$filter;
|
||||
if ($filtera) $param.="&filtera=".$filtera;
|
||||
if ($filtert) $param.="&filtert=".$filtert;
|
||||
if ($filterd) $param.="&filterd=".$filterd;
|
||||
if ($usergroup) $param.="&usergroup=".$usergroup;
|
||||
if ($socid) $param.="&socid=".$socid;
|
||||
if ($showbirthday) $param.="&showbirthday=1";
|
||||
@ -280,7 +275,7 @@ $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, $action, $listofextcals, $actioncode, $usergroup);
|
||||
print_actions_filter($form, $canedit, $status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, $listofextcals, $actioncode, $usergroup);
|
||||
dol_fiche_end();
|
||||
|
||||
$showextcals=$listofextcals;
|
||||
@ -332,27 +327,29 @@ print_fiche_titre($s,$link.' '.$nav, '');
|
||||
// Get event in an array
|
||||
$eventarray=array();
|
||||
|
||||
$sql = 'SELECT a.id,a.label,';
|
||||
$sql = 'SELECT';
|
||||
if ($usergroup > 0) $sql.=" DISTINCT";
|
||||
$sql.= ' a.id, a.label,';
|
||||
$sql.= ' a.datep,';
|
||||
$sql.= ' a.datep2,';
|
||||
$sql.= ' a.datea,';
|
||||
$sql.= ' a.datea2,';
|
||||
$sql.= ' a.percent,';
|
||||
$sql.= ' a.fk_user_author,a.fk_user_action,a.fk_user_done,';
|
||||
$sql.= ' a.fk_user_author,a.fk_user_action,';
|
||||
$sql.= ' a.transparency, a.priority, a.fulldayevent, a.location,';
|
||||
$sql.= ' a.fk_soc, a.fk_contact, a.fk_element, a.elementtype,';
|
||||
$sql.= ' ca.code, ca.color';
|
||||
$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 > 0) $sql.= ", ".MAIN_DB_PREFIX."usergroup_user as ugu";
|
||||
// We must filter on assignement table
|
||||
if ($filtert > 0 || $usergroup > 0) $sql.=", ".MAIN_DB_PREFIX."actioncomm_resources as ar";
|
||||
if ($usergroup > 0) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_user = ar.fk_element";
|
||||
$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 ($socid > 0) $sql.= ' AND a.fk_soc = '.$socid;
|
||||
// FIXME: We must filter on assignement table
|
||||
if ($usergroup > 0) $sql.= " AND ugu.fk_user = a.fk_user_action";
|
||||
// We must filter on assignement table
|
||||
if ($filtert > 0 || $usergroup > 0) $sql.= " AND ar.fk_actioncomm = a.id AND ar.element_type='user'";
|
||||
if ($action == 'show_day')
|
||||
{
|
||||
$sql.= " AND (";
|
||||
@ -386,14 +383,12 @@ if ($status == '-1') { $sql.= " AND a.percent = -1"; } // Not applicable
|
||||
if ($status == '50') { $sql.= " AND (a.percent > 0 AND a.percent < 100)"; } // Running already started
|
||||
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)."'))"; }
|
||||
// FIXME: We must filter on assignement table
|
||||
if ($filtera > 0 || $filtert > 0 || $filterd > 0 || $usergroup > 0)
|
||||
// We must filter on assignement table
|
||||
if ($filtert > 0 || $usergroup > 0)
|
||||
{
|
||||
$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 > 0) $sql.= ($filtera>0||$filtert>0||$filterd>0?" OR ":"")." ugu.fk_usergroup = ".$usergroup;
|
||||
if ($filtert > 0) $sql.= "ar.fk_element = ".$filtert;
|
||||
if ($usergroup > 0) $sql.= ($filtert>0?" OR ":"")." ugu.fk_usergroup = ".$usergroup;
|
||||
$sql.= ")";
|
||||
}
|
||||
// Sort on date
|
||||
@ -809,7 +804,7 @@ function show_day_events2($username, $day, $month, $year, $monthshown, $style, &
|
||||
{
|
||||
global $db;
|
||||
global $user, $conf, $langs, $hookmanager, $action;
|
||||
global $filter, $filtera, $filtert, $filterd, $status, $actioncode; // Filters used into search form
|
||||
global $filter, $filtert, $status, $actioncode; // Filters used into search form
|
||||
global $theme_datacolor; // Array with a list of different we can use (come from theme)
|
||||
global $cachethirdparties, $cachecontacts, $colorindexused;
|
||||
global $begin_h, $end_h;
|
||||
|
||||
@ -70,7 +70,7 @@ function print_actions_filter($form, $canedit, $status, $year, $month, $day, $sh
|
||||
{
|
||||
print '<tr>';
|
||||
print '<td class="nowrap">';
|
||||
print $langs->trans("ActionsOwnedBy").' ';
|
||||
print $langs->trans("ActionsToDoBy").' ';
|
||||
print '</td><td class="nowrap maxwidthonsmartphone">';
|
||||
print $form->select_dolusers($filtert, 'usertodo', 1, '', ! $canedit);
|
||||
if (empty($conf->dol_optimize_smallscreen)) print ' '.$langs->trans("or") . ' '.$langs->trans("Group").' ';
|
||||
|
||||
@ -153,6 +153,9 @@ ALTER TABLE llx_projet_task_time ADD COLUMN task_datehour datetime after task_da
|
||||
|
||||
ALTER TABLE llx_actioncomm_resources CHANGE COLUMN transparent transparency smallint default 1;
|
||||
|
||||
ALTER TABLE llx_actioncomm_resources DROP INDEX idx_actioncomm_resources_idx1;
|
||||
ALTER TABLE llx_actioncomm_resources ADD UNIQUE INDEX uk_actioncomm_resources(fk_actioncomm, element_type, fk_element);
|
||||
|
||||
|
||||
-- Localtaxes by thirds
|
||||
ALTER TABLE llx_c_tva MODIFY COLUMN localtax1 varchar(10);
|
||||
|
||||
@ -18,7 +18,7 @@
|
||||
-- ============================================================================
|
||||
|
||||
|
||||
ALTER TABLE llx_actioncomm_resources ADD UNIQUE INDEX idx_actioncomm_resources_idx1 (fk_actioncomm, element_type, fk_element);
|
||||
ALTER TABLE llx_actioncomm_resources ADD UNIQUE INDEX uk_actioncomm_resources(fk_actioncomm, element_type, fk_element);
|
||||
ALTER TABLE llx_actioncomm_resources ADD INDEX idx_actioncomm_resources_fk_element (fk_element);
|
||||
|
||||
-- Pas de contrainte sur fk_source et fk_target car pointe sur differentes tables
|
||||
|
||||
@ -362,6 +362,8 @@ if (! GETPOST("action") || preg_match('/upgrade/i',GETPOST('action')))
|
||||
$beforeversionarray=explode('.','3.7.9'); // target is before this
|
||||
if (versioncompare($versiontoarray,$afterversionarray) >= 0 && versioncompare($versiontoarray,$beforeversionarray) <= 0)
|
||||
{
|
||||
migrate_event_assignement($db,$langs,$conf);
|
||||
|
||||
// Reload modules (this must be always and only into last targeted version)
|
||||
$listofmodule=array(
|
||||
'MAIN_MODULE_AGENDA',
|
||||
@ -391,6 +393,7 @@ if (! GETPOST("action") || preg_match('/upgrade/i',GETPOST('action')))
|
||||
$db->commit();
|
||||
$db->close();
|
||||
|
||||
|
||||
// Actions for all version (not in database)
|
||||
migrate_delete_old_files($db,$langs,$conf);
|
||||
|
||||
@ -3519,6 +3522,83 @@ function migrate_categorie_association($db,$langs,$conf)
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Migrate event assignement to owner
|
||||
*
|
||||
* @param DoliDB $db Database handler
|
||||
* @param Translate $langs Object langs
|
||||
* @param Conf $conf Object conf
|
||||
* @return void
|
||||
*/
|
||||
function migrate_event_assignement($db,$langs,$conf)
|
||||
{
|
||||
print '<tr><td colspan="4">';
|
||||
|
||||
print '<br>';
|
||||
print '<b>'.$langs->trans('MigrationEvents')."</b><br>\n";
|
||||
|
||||
$error = 0;
|
||||
|
||||
dolibarr_install_syslog("upgrade2::migrate_event_assignement");
|
||||
|
||||
$db->begin();
|
||||
|
||||
$sqlSelect = "SELECT a.id, a.fk_user_action";
|
||||
$sqlSelect.= " FROM ".MAIN_DB_PREFIX."actioncomm as a";
|
||||
$sqlSelect.= " LEFT JOIN ".MAIN_DB_PREFIX."actioncomm_resources as ar ON ar.fk_actioncomm = a.id AND ar.element_type = 'user' AND ar.fk_element = a.fk_user_action";
|
||||
$sqlSelect.= " WHERE fk_user_action > 0 AND fk_user_action NOT IN (SELECT fk_element FROM ".MAIN_DB_PREFIX."actioncomm_resources as ar WHERE ar.fk_actioncomm = a.id AND ar.element_type = 'user')";
|
||||
$sqlSelect.= " ORDER BY a.id";
|
||||
//print $sqlSelect;
|
||||
|
||||
$resql = $db->query($sqlSelect);
|
||||
if ($resql)
|
||||
{
|
||||
$i = 0;
|
||||
$num = $db->num_rows($resql);
|
||||
|
||||
if ($num)
|
||||
{
|
||||
while ($i < $num)
|
||||
{
|
||||
$obj = $db->fetch_object($resql);
|
||||
|
||||
$sqlUpdate = "INSERT INTO ".MAIN_DB_PREFIX."actioncomm_resources(fk_actioncomm, element_type, fk_element) ";
|
||||
$sqlUpdate.= "VALUES(".$obj->id.", 'user', ".$obj->fk_user_action.")";
|
||||
|
||||
$result=$db->query($sqlUpdate);
|
||||
if (! $result)
|
||||
{
|
||||
$error++;
|
||||
dol_print_error($db);
|
||||
}
|
||||
print ". ";
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print $langs->trans('AlreadyDone')."<br>\n";
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
$db->commit();
|
||||
}
|
||||
else
|
||||
{
|
||||
$db->rollback();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_print_error($db);
|
||||
$db->rollback();
|
||||
}
|
||||
|
||||
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Migration directory
|
||||
*
|
||||
|
||||
@ -206,6 +206,7 @@ MigrationProjectTaskTime=Update time spent in seconds
|
||||
MigrationActioncommElement=Update data on actions
|
||||
MigrationPaymentMode=Data migration for payment mode
|
||||
MigrationCategorieAssociation=Migration of categories
|
||||
MigrationEvents=Migration of events to add event owner into assignement table
|
||||
|
||||
ShowNotAvailableOptions=Show not available options
|
||||
HideNotAvailableOptions=Hide not available options
|
||||
Loading…
Reference in New Issue
Block a user