From 06cc08026b6364845fb4a1793b5215d13edb1cb4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 9 Oct 2014 17:05:57 +0200 Subject: [PATCH] Some fix on per user view. --- htdocs/comm/action/card.php | 82 ++++++++++--------- htdocs/comm/action/class/actioncomm.class.php | 2 +- htdocs/comm/action/index.php | 5 ++ htdocs/comm/action/listactions.php | 13 ++- htdocs/comm/action/peruser.php | 49 ++++++----- htdocs/core/lib/agenda.lib.php | 2 +- htdocs/langs/en_US/agenda.lang | 1 + htdocs/theme/eldy/style.css.php | 2 +- 8 files changed, 89 insertions(+), 67 deletions(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index e4c0fe78aa9..a306ff202b4 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -1248,46 +1248,48 @@ if ($id > 0) print ''; - - // Link to agenda views - print '
'; - print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; - //print ''; - print img_picto($langs->trans("ViewCal"),'object_calendar','class="hideonsmartphone"').' '; - print '
'."\n"; - print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; - //print ''; - print img_picto($langs->trans("ViewCal"),'object_calendarweek','class="hideonsmartphone"').' '; - print '
'."\n"; - print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; - //print ''; - print img_picto($langs->trans("ViewCal"),'object_calendarday','class="hideonsmartphone"').' '; - print '
'."\n"; - print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; - //print ''; - print img_picto($langs->trans("ViewCal"),'object_calendarperuser','class="hideonsmartphone"').' '; - print '
'."\n"; - print '
'; + if ($action != 'edit') + { + // Link to agenda views + print '
'; + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + //print ''; + print img_picto($langs->trans("ViewCal"),'object_calendar','class="hideonsmartphone"').' '; + print '
'."\n"; + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + //print ''; + print img_picto($langs->trans("ViewCal"),'object_calendarweek','class="hideonsmartphone"').' '; + print '
'."\n"; + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + //print ''; + print img_picto($langs->trans("ViewCal"),'object_calendarday','class="hideonsmartphone"').' '; + print '
'."\n"; + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + //print ''; + print img_picto($langs->trans("ViewCal"),'object_calendarperuser','class="hideonsmartphone"').' '; + print '
'."\n"; + print '
'; + } } diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 1d99a8eec34..62acfb963b1 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -419,7 +419,7 @@ class ActionComm extends CommonObject while ($obj = $this->db->fetch_object($resql2)) { - $this->userassigned[$obj->fk_element]=array('id'=>$obj->fk_element, 'mandatory'=>$obj->mandatory, 'answer_status'=>$obj->answer_status, 'transparency'=>$obj->transparency); + if ($obj->fk_element > 0) $this->userassigned[$obj->fk_element]=array('id'=>$obj->fk_element, 'mandatory'=>$obj->mandatory, 'answer_status'=>$obj->answer_status, 'transparency'=>$obj->transparency); if (empty($this->userownerid)) $this->userownerid=$obj->fk_element; // If not defined (should not happened, we fix this) } diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index a1c03a7f15e..6c2173b1b40 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -46,6 +46,11 @@ $filterd = GETPOST("userdone","int",3)?GETPOST("userdone","int",3):GETPOST("filt $usergroup = GETPOST("usergroup","int",3); $showbirthday = empty($conf->use_javascript_ajax)?GETPOST("showbirthday","int"):1; +// If not choice done on calendar owner, we filter on user. +if (empty($filtert) && empty($conf->AGENDA_ALL_CALENDARS)) +{ + $filtert=$user->id; +} $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); diff --git a/htdocs/comm/action/listactions.php b/htdocs/comm/action/listactions.php index bc8a15827e0..8a5c698724f 100644 --- a/htdocs/comm/action/listactions.php +++ b/htdocs/comm/action/listactions.php @@ -56,6 +56,12 @@ $filterd = GETPOST("userdone","int",3)?GETPOST("userdone","int",3):GETPOST("filt $usergroup = GETPOST("usergroup","int",3); $showbirthday = empty($conf->use_javascript_ajax)?GETPOST("showbirthday","int"):1; +// If not choice done on calendar owner, we filter on user. +if (empty($filtert) && empty($conf->AGENDA_ALL_CALENDARS)) +{ + $filtert=$user->id; +} + $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); @@ -98,6 +104,7 @@ $hookmanager->initHooks(array('agendalist')); /* * Actions */ + if (GETPOST("viewcal") || GETPOST("viewweek") || GETPOST("viewday")) { $param=''; @@ -144,7 +151,7 @@ $sql.= " a.fk_contact, a.note, a.label, a.percent as percent,"; $sql.= " c.code as acode, c.libelle,"; $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.= " 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,'; @@ -154,7 +161,7 @@ $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"; +//$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"; $sql.= " WHERE c.id = a.fk_action"; $sql.= ' AND a.fk_user_author = u.rowid'; @@ -244,7 +251,7 @@ if ($resql) 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("AffectedTo"),$_SERVER["PHP_SELF"],"ut.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("Status"),$_SERVER["PHP_SELF"],"a.percent",$param,"",'align="right"',$sortfield,$sortorder); print "\n"; diff --git a/htdocs/comm/action/peruser.php b/htdocs/comm/action/peruser.php index b4c0b4edbfa..1ca9af2b251 100644 --- a/htdocs/comm/action/peruser.php +++ b/htdocs/comm/action/peruser.php @@ -47,6 +47,11 @@ $usergroup = GETPOST("usergroup","int",3); //$showbirthday = empty($conf->use_javascript_ajax)?GETPOST("showbirthday","int"):1; $showbirthday = 0; +// If not choice done on calendar owner, we filter on user. +if (empty($filtert) && empty($conf->AGENDA_ALL_CALENDARS)) +{ + $filtert=$user->id; +} $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); @@ -557,30 +562,32 @@ while ($i < 7) } echo "\n"; + // Define $usernames $usernames = array(); //init -/* Use this to have list of users only if users have events +$usernamesid = array(); +/* Use this to have list of users only if users have events */ foreach ($eventarray as $daykey => $notused) { - $annee = date('Y',$daykey); - $mois = date('m',$daykey); - $jour = date('d',$daykey); - //if ($day==$jour && $month==$mois && $year==$annee) - //{ - //Tout les events à la même date : - foreach ($eventarray[$daykey] as $index => $event) - { - $myuser = new User($db); - $user_id = $event->usertodo->id; - $myuser->fetch($user_id); - $username = $myuser->getFullName($langs); - if (! in_array($username, $usernames)) - { - $usernames[] = $username; - } - } - //} -}*/ + // Get all assigned users for each event + foreach ($eventarray[$daykey] as $index => $event) + { + $event->fetch_userassigned(); + $listofuserid=$event->userassigned; + foreach($listofuserid as $userid => $tmp) + { + if (! in_array($userid, $usernamesid)) $usernamesid[$userid] = $userid; + } + } +} +foreach($usernamesid as $id) +{ + $tmpuser=new User($db); + $result=$tmpuser->fetch($id); + $usernames[]=$tmpuser; +} + +/* if ($filtert > 0) { $tmpuser = new User($db); @@ -598,7 +605,7 @@ else $tmpgroup = new UserGroup($db); //$tmpgroup->fetch($usergroup); No fetch, we want all users for all groups $usernames = $tmpgroup->listUsersForGroup(); -} +}*/ // Load array of colors by type $colorsbytype=array(); diff --git a/htdocs/core/lib/agenda.lib.php b/htdocs/core/lib/agenda.lib.php index ddfcd239a41..3d9a5e8299c 100644 --- a/htdocs/core/lib/agenda.lib.php +++ b/htdocs/core/lib/agenda.lib.php @@ -74,7 +74,7 @@ function print_actions_filter($form, $canedit, $status, $year, $month, $day, $sh //print '  '; //print $form->select_dolusers($filtera, 'userasked', 1, '', ! $canedit); //print '   '.$langs->trans("or") . ' '; - print $langs->trans("ActionAffectedTo").'   '; + print $langs->trans("ActionsOwnedBy").'   '; print ''; //print $langs->trans("User"); print $form->select_dolusers($filtert, 'usertodo', 1, '', ! $canedit); diff --git a/htdocs/langs/en_US/agenda.lang b/htdocs/langs/en_US/agenda.lang index cb19170dab3..227f7a61118 100644 --- a/htdocs/langs/en_US/agenda.lang +++ b/htdocs/langs/en_US/agenda.lang @@ -7,6 +7,7 @@ Agendas=Agendas Calendar=Calendar Calendars=Calendars LocalAgenda=Internal calendar +ActionsOwnedBy=Event owned by AffectedTo=Assigned to DoneBy=Done by Event=Event diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index a7e60a6cdcd..43aee0161af 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -2375,7 +2375,7 @@ table.cal_month { border-spacing: 0px; } .cal_past { } .cal_peruser { padding: 0px; } .peruser_busy { background: #CC8888; } -.peruser_notbusy { background: #EEDDDD; } +.peruser_notbusy { background: #EEDDDD; opacity: 0.5; } table.cal_event { border: none; border-collapse: collapse; margin-bottom: 1px; -webkit-border-radius: 6px; border-radius: 6px; -webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 1px 2px rgba(0, 0, 0, 0.25); moz-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 1px 2px rgba(0, 0, 0, 0.25);