From 3f29b1668307daf1df0a0e759d3f71ff9a0589bf Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 20 Mar 2026 12:22:34 +0100 Subject: [PATCH] NEW Can enable/disable external calender per calendar. --- htdocs/comm/action/index.php | 18 +++++---- htdocs/comm/action/pertype.php | 48 +++++++++++------------ htdocs/comm/action/peruser.php | 66 ++++++++++++++++++++++---------- htdocs/theme/eldy/global.inc.php | 18 ++++----- htdocs/theme/md/style.css.php | 4 +- 5 files changed, 91 insertions(+), 63 deletions(-) diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index 34905975345..b2c75bd541e 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -157,19 +157,22 @@ if (empty($mode) && !GETPOSTISSET('mode')) { if ($mode == 'default') { // When action is default, we want a calendar view and not the list $mode = (($defaultview != 'show_list') ? $defaultview : 'show_month'); } +// View by month if (GETPOST('viewcal') && GETPOST('mode') != 'show_day' && GETPOST('mode') != 'show_week') { $mode = 'show_month'; $day = ''; -} // View by month +} +// View by week if (GETPOST('viewweek') || GETPOST('mode') == 'show_week') { $mode = 'show_week'; $week = ($week ? $week : date("W")); $day = ($day ? $day : date("d")); -} // View by week +} +// View by day if (GETPOST('viewday') || GETPOST('mode') == 'show_day') { $mode = 'show_day'; $day = ($day ? $day : date("d")); -} // View by day +} $object = new ActionComm($db); @@ -413,10 +416,12 @@ if ($status == 'todo') { */ $param = ''; -if ($actioncode || GETPOSTISSET('search_actioncode')) { +if (($actioncode && $actioncode !== '-1') || GETPOSTISSET('search_actioncode')) { if (is_array($actioncode)) { foreach ($actioncode as $str_action) { - $param .= "&search_actioncode[]=".urlencode($str_action); + if ($str_action != '-1') { + $param .= "&search_actioncode[]=".urlencode($str_action); + } } } else { $param .= "&search_actioncode=".urlencode($actioncode); @@ -660,8 +665,7 @@ if (!empty($conf->use_javascript_ajax)) { // If javascript on // Holiday calendar if ($user->hasRight("holiday", "read")) { $s .= ' -
+
  diff --git a/htdocs/comm/action/pertype.php b/htdocs/comm/action/pertype.php index e44815eba88..9306f5a94d6 100644 --- a/htdocs/comm/action/pertype.php +++ b/htdocs/comm/action/pertype.php @@ -31,6 +31,13 @@ // Load Dolibarr environment require '../../main.inc.php'; +/** + * @var Conf $conf + * @var DoliDB $db + * @var HookManager $hookmanager + * @var Translate $langs + * @var User $user + */ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php'; @@ -40,18 +47,6 @@ require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; require_once DOL_DOCUMENT_ROOT.'/user/class/usergroup.class.php'; -/** - * @var Conf $conf - * @var DoliDB $db - * @var HookManager $hookmanager - * @var Translate $langs - * @var User $user - */ - -if (!isset($conf->global->AGENDA_MAX_EVENTS_DAY_VIEW)) { - $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW = 3; -} - $action = GETPOST('action', 'aZ09'); $disabledefaultvalues = GETPOSTINT('disabledefaultvalues'); @@ -69,14 +64,15 @@ if (empty($filtert) && !getDolGlobalString('AGENDA_ALL_CALENDARS')) { $filtert = $user->id; } -// Sorting +// Pagination parameters +$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page"); -if (empty($page) || $page == -1) { +if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) { + // If $page is not defined, or '' or -1 or if we click on clear filters $page = 0; -} // If $page is not defined, or '' or -1 -$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit; +} $offset = $limit * $page; if (!$sortorder) { $sortorder = "ASC"; @@ -115,7 +111,7 @@ $day = GETPOSTINT("day") ? GETPOSTINT("day") : date("d"); $pid = GETPOSTISSET("search_projectid") ? GETPOSTINT("search_projectid", 3) : GETPOSTINT("projectid", 3); $status = GETPOSTISSET("search_status") ? GETPOST("search_status", 'aZ09') : GETPOST("status", 'aZ09'); $type = GETPOSTISSET("search_type") ? GETPOST("search_type", 'alpha') : GETPOST("type", 'alpha'); -$maxprint = ((GETPOSTINT("maxprint") != '') ? GETPOSTINT("maxprint") : $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW); +$maxprint = GETPOSTISSET("maxprint") ? GETPOSTINT("maxprint") : getDolGlobalInt('AGENDA_MAX_EVENTS_DAY_VIEW', 3); $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') // Set actioncode (this code must be same for setting actioncode into peruser, listacton and index) @@ -195,7 +191,7 @@ $langs->loadLangs(array('users', 'agenda', 'other', 'commercial')); // Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context $hookmanager->initHooks(array('agenda')); -$result = restrictedArea($user, 'agenda', 0, 'actioncomm&societe', 'myactions'); +$result = restrictedArea($user, 'agenda', 0, 'actioncomm&societe', 'myactions|allactions', 'fk_soc', 'id'); if ($user->socid && $socid) { $result = restrictedArea($user, 'societe', $socid); } @@ -363,7 +359,7 @@ $lastdaytoshow = dol_time_plus_duree($firstdaytoshow, 7, 'd'); //print dol_print_date($firstdaytoshow, 'dayhour', 'gmt'); //print dol_print_date($lastdaytoshow,'dayhour', 'gmt'); -$max_day_in_month = date("t", dol_mktime(0, 0, 0, $month, 1, $year, 'gmt')); +$max_day_in_month = idate("t", dol_mktime(0, 0, 0, $month, 1, $year, 'gmt')); $tmpday = $first_day; $picto = 'calendarweek'; @@ -482,7 +478,7 @@ if (empty($reshook)) { $viewmode .= '
'; -$viewmode .= ''; +$viewmode .= ''; // To add a space before the navigation tools $newparam = ''; @@ -490,7 +486,7 @@ $newcardbutton = ''; if ($user->hasRight('agenda', 'myactions', 'create') || $user->hasRight('agenda', 'allactions', 'create')) { $tmpforcreatebutton = dol_getdate(dol_now('tzuserrel'), true); - $newparam .= '&month='.str_pad((string) $month, 2, "0", STR_PAD_LEFT).'&year='.((int) $tmpforcreatebutton['year']); + $newparam .= '&month='.urlencode(str_pad((string) $month, 2, "0", STR_PAD_LEFT)).'&year='.((int) $tmpforcreatebutton['year']); $urltocreateaction = DOL_URL_ROOT.'/comm/action/card.php?action=create'; $urltocreateaction .= '&apyear='.$tmpforcreatebutton['year'].'&apmonth='.$tmpforcreatebutton['mon'].'&apday='.$tmpforcreatebutton['mday'].'&aphour='.$tmpforcreatebutton['hours'].'&apmin='.$tmpforcreatebutton['minutes']; @@ -552,9 +548,9 @@ if (($filtert != '-1' && $filtert != '-2') || $usergroup > 0) { // TODO Replace with a AND EXISTS $sql .= " INNER JOIN ".MAIN_DB_PREFIX."actioncomm_resources as ar"; $sql .= " ON ar.fk_actioncomm = a.id AND ar.element_type = 'user'"; - if ($filtert != '-1' && $filtert != '-2' && $filtert != '-3') { + if ($filtert != '' && $filtert != '-1' && $filtert != '-2' && $filtert != '-3') { $sql .= " AND ar.fk_element IN (".$db->sanitize($filtert).")"; - } elseif ($filtert == -3) { + } elseif ($filtert == '-3') { $sql .= " AND ar.fk_element IN (".$db->sanitize(implode(',', $user->getAllChildIds(1))).")"; } if ($usergroup > 0) { @@ -701,7 +697,7 @@ if ($resql) { $obj = $db->fetch_object($resql); // Discard auto action if option is on - if (getDolGlobalString('AGENDA_ALWAYS_HIDE_AUTO') && $obj->code == 'AC_OTH_AUTO') { + if (getDolGlobalString('AGENDA_ALWAYS_HIDE_AUTO') && $obj->type_code == 'AC_OTH_AUTO') { $i++; continue; } @@ -949,6 +945,7 @@ jQuery(document).ready(function() { jQuery(".onclickopenref").click(function() { var ref=$(this).attr(\'ref\'); var res = ref.split("_"); + var type = res[0]; var userid = res[1]; var year = res[2]; var month = res[3]; @@ -956,6 +953,9 @@ jQuery(document).ready(function() { var hour = res[5]; var min = res[6]; var ids = res[7]; + + console.log("We click on a class onclickopenref in page peruser with ref="+ref+" type="+type); + if (ids == \'none\') /* No event */ { /* alert(\'no event\'); */ diff --git a/htdocs/comm/action/peruser.php b/htdocs/comm/action/peruser.php index 3ff55e32e0f..ac5a9ce497b 100644 --- a/htdocs/comm/action/peruser.php +++ b/htdocs/comm/action/peruser.php @@ -61,13 +61,15 @@ $filtert = GETPOST("search_filtert", "intcomma", 3) ? GETPOST("search_filtert", $usergroup = GETPOSTINT("search_usergroup", 3) ? GETPOSTINT("search_usergroup", 3) : GETPOSTINT("usergroup", 3); $showbirthday = getDolGlobalInt('AGENDA_ENABLE_SHOW_BIRTHDAY_PER_USER'); // disabled by default +// Pagination parameters +$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page"); -if (empty($page) || $page == -1) { +if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) { + // If $page is not defined, or '' or -1 or if we click on clear filters $page = 0; -} // If $page is not defined, or '' or -1 -$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit; +} $offset = $limit * $page; if (!$sortorder) { $sortorder = "ASC"; @@ -247,7 +249,7 @@ $nowday = $nowarray['mday']; $listofextcals = array(); -// Define list of all external calendars (global setup) +// Define list of external calendars (global admin setup) $i = 0; while ($i < $MAXAGENDA) { $i++; @@ -255,9 +257,10 @@ while ($i < $MAXAGENDA) { $name = 'AGENDA_EXT_NAME'.$i; $offsettz = 'AGENDA_EXT_OFFSETTZ'.$i; $color = 'AGENDA_EXT_COLOR'.$i; + $enabled = 'AGENDA_EXT_ENABLED'.$i; $default = 'AGENDA_EXT_ACTIVEBYDEFAULT'.$i; $buggedfile = 'AGENDA_EXT_BUGGEDFILE'.$i; - if (getDolGlobalString($source) && getDolGlobalString($name)) { + if (getDolGlobalString($source) && getDolGlobalString($name) && getDolGlobalString($enabled)) { // Note: $conf->global->buggedfile can be empty or 'uselocalandtznodaylight' or 'uselocalandtzdaylight' $listofextcals[] = array( 'type' => 'globalsetup', @@ -502,7 +505,7 @@ if (empty($reshook)) { $viewmode .= '
'; -$viewmode .= ''; +$viewmode .= ''; // To add a space before the navigation tools $newparam = ''; @@ -526,7 +529,7 @@ if ($user->hasRight('agenda', 'myactions', 'create') || $user->hasRight('agenda' $urltocreateaction = DOL_URL_ROOT.'/comm/action/card.php?action=create'; $urltocreateaction .= '&apyear='.$tmpforcreatebutton['year'].'&apmonth='.$tmpforcreatebutton['mon'].'&apday='.$tmpforcreatebutton['mday'].'&aphour='.$tmpforcreatebutton['hours'].'&apmin='.$tmpforcreatebutton['minutes']; - $urltocreateaction .= '&backtopage='.urlencode($_SERVER["PHP_SELF"].'?'.$newparam); + $urltocreateaction .= '&backtopage='.urlencode($_SERVER["PHP_SELF"].($newparam ? '?'.$newparam : '')); $newcardbutton .= dolGetButtonTitle($langs->trans("AddAction"), '', 'fa fa-plus-circle', $urltocreateaction); } @@ -559,7 +562,7 @@ if (isModEnabled("bookcal")) { while ($i < $num) { $objp = $db->fetch_object($resql); $label = !empty($objp->label) ? $objp->label : $objp->ref; - $bookcalcalendars["calendars"][] = array("id" => $objp->id_cal, "label" => $label); + $bookcalcalendars["calendars"][$objp->id_cal] = array("id" => $objp->id_cal, "label" => $label); $bookcalcalendars["availabilitieslink"][$objp->rowid] = $objp->id_cal; $i++; } @@ -597,24 +600,42 @@ if (!empty($conf->use_javascript_ajax)) { // If javascript on } // External calendars - if (count($showextcals) > 0) { + if (is_array($showextcals) && count($showextcals) > 0) { + $s .= ''."\n"; + foreach ($showextcals as $val) { $htmlname = md5($val['name']); // not used for security purpose, only to get a string with no special char - $s .= ''."\n"; - $s .= '
'.$val ['name'].'  
'; + if (!empty($val['default']) || GETPOSTINT('check_ext'.$htmlname)) { + $default = "checked"; + } else { + $default = ''; + } + + $tooltip = $langs->trans("Cache").' '.round($DELAYFORCACHE / 60).'mn'; + + $s .= '
 
'; } } // Birthdays - //$s.='
'.$langs->trans("AgendaShowBirthdayEvents").'  
'; + //$s .= '
 
'; // Bookcal Calendar /* @@ -661,7 +682,7 @@ if (!empty($conf->use_javascript_ajax)) { // If javascript on // Load events from database into $eventarray $eventarray = array(); - +$nbevents = 0; // DEFAULT CALENDAR + AUTOEVENT CALENDAR + CONFERENCEBOOTH CALENDAR $sql = "SELECT"; @@ -678,10 +699,13 @@ $sql .= " a.fk_soc, a.fk_contact, a.fk_project, a.fk_bookcal_calendar,"; $sql .= " a.fk_element, a.elementtype,"; $sql .= " ca.code as type_code, ca.libelle as type_label, ca.color as type_color, ca.type as type_type, ca.picto as type_picto"; +// Add fields from hooks $parameters = array(); -$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook +$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object, $action); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; +$sqlfields = $sql; // $sql fields to remove for count total + $sql .= " FROM ".MAIN_DB_PREFIX."c_actioncomm as ca, ".MAIN_DB_PREFIX."actioncomm as a"; // We must filter on resource table if ($resourceid > 0) { diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index 8afeea75bc8..089c7a8e184 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -6542,20 +6542,21 @@ table.cal_month td:first-child { border-left: 0px; } table.cal_month td:last-child { border-right: 0px; } table.cal_month td { padding-left: 1px !important; padding-right: 1px !important; } table.cal_month.cal_peruser td { padding-left: 0 !important; padding-right: 0 !important; } -.cal_current_month { border-top: 0; border-left: solid 1px #E0E0E0; border-right: 0; border-bottom: solid 1px #E0E0E0; } -.cal_current_month_peruserleft { border-top: 0; border-left: solid 2px #6C7C7B; border-right: 0; border-bottom: solid 1px #E0E0E0; } -.cal_current_month_oneday { border-right: solid 1px #E0E0E0; } +.cal_current_month { border-top: 0; border-left: solid 1px #E8E8E8; border-right: 0; border-bottom: solid 1px #E8E8E8; } +.cal_current_month_peruserleft { border-top: 0; border-left: solid 2px #6C7C7B; border-right: 0; border-bottom: solid 1px #E8E8E8; } +.cal_current_month_oneday { border-right: solid 1px #E8E8E8; } .cal_other_month { border-top: 0; border-left: solid 1px #C0C0C0; border-right: 0; border-bottom: solid 1px #C0C0C0; } .cal_other_month_peruserleft { border-top: 0; border-left: solid 2px #6C7C7B !important; border-right: 0; } -.cal_current_month_right { border-right: solid 1px #E0E0E0; } +.cal_current_month_right { border-right: solid 1px #E8E8E8; } .cal_other_month_right { border-right: solid 1px #C0C0C0; } .cal_other_month { /* opacity: 0.6; */ background: #FAFAFA; padding-: 2px; padding-: 1px; padding-top: 0px; padding-bottom: 0px; } .cal_past_month { /* opacity: 0.6; */ background: #EEEEEE; padding-: 2px; padding-: 1px; padding-top: 0px; padding-bottom: 0px; } -.cal_current_month { background: #FFFFFF; border-left: solid 1px #E0E0E0; padding-: 2px; padding-: 1px; padding-top: 0px; padding-bottom: 0px; } +.cal_current_month { background: #FFFFFF; border-left: solid 1px #E8E8E8; padding-: 2px; padding-: 1px; padding-top: 0px; padding-bottom: 0px; } .cal_current_month_peruserleft { background: #FFFFFF; border-left: solid 2px #6C7C7B; padding-: 2px; padding-: 1px; padding-top: 0px; padding-bottom: 0px; } -.cal_today { /* background: #FDFDF0; */ border-left: solid 1px #E0E0E0; border-bottom: solid 1px #E0E0E0; padding-: 2px; padding-: 1px; padding-top: 0px; padding-bottom: 0px; } -.cal_today_peruser { /* background: #FDFDF0; */ border-right: solid 1px #E0E0E0; border-bottom: solid 1px #E0E0E0; padding-: 2px; padding-: 1px; padding-top: 0px; padding-bottom: 0px; } -.cal_today_peruser_peruserleft { /* background: #FDFDF0; */ border-left: solid 2px #6C7C7B; border-right: solid 1px #E0E0E0; border-bottom: solid 1px #E0E0E0; padding-: 2px; padding-: 1px; padding-top: 0px; padding-bottom: 0px; } +.cal_today { /* background: #FDFDF0; */ border-left: solid 1px #E8E8E8; border-bottom: solid 1px #E8E8E8; padding-: 2px; padding-: 1px; padding-top: 0px; padding-bottom: 0px; } +.cal_today_peruser { /* background: #FDFDF0; */ border-right: solid 1px #E8E8E8; border-bottom: solid 1px #E8E8E8; padding-: 2px; padding-: 1px; padding-top: 0px; padding-bottom: 0px; } +.cal_today_peruser_peruserleft { /* background: #FDFDF0; */ border-left: solid 2px #6C7C7B; border-right: solid 1px #E8E8E8; border-bottom: solid 1px #E8E8E8; padding-: 2px; padding-: 1px; padding-top: 0px; padding-bottom: 0px; } +.cal_today_peruser_impair { /* background: #FDFDF0; */ } .cal_past { } .cal_peruser { padding-top: 0 !important; padding-bottom: 0 !important; padding-: 0 !important; padding-: 0 !important; } .cal_impair { @@ -6564,7 +6565,6 @@ table.cal_month.cal_peruser td { padding-left: 0 !important; padding-right: 0 !i background: -moz-linear-gradient(bottom, var(--colorbacklinepair2) 85%, var(--colorbacklinepair2) 100%); background: -webkit-linear-gradient(bottom, var(--colorbacklinepair2) 85%, var(--colorbacklinepair2) 100%); } -.cal_today_peruser_impair { background: #F8F8F0; } .peruser_busy { } .peruser_notbusy { opacity: 0.5; } div.event { margin-left: 8px; margin-right: 8px; margin-bottom: 8px; margin-top: 4px; border-radius: 4px; box-shadow: 2px 2px 5px rgba(100, 100, 100, 0.2); } diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index bbce268141d..189289ca9e3 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -6411,11 +6411,11 @@ table.cal_month.cal_peruser td { padding-left: 0 !important; padding-right: 0 !i .cal_today { /* background: #FDFDF0; */ border-left: solid 1px #E0E0E0; border-bottom: solid 1px #E0E0E0; padding-: 2px; padding-: 1px; padding-top: 0px; padding-bottom: 0px; } .cal_today_peruser { /* background: #FDFDF0; */ border-right: solid 1px #E0E0E0; border-bottom: solid 1px #E0E0E0; padding-: 2px; padding-: 1px; padding-top: 0px; padding-bottom: 0px; } .cal_today_peruser_peruserleft { /* background: #FDFDF0; */ border-left: solid 2px #6C7C7B; border-right: solid 1px #E0E0E0; border-bottom: solid 1px #E0E0E0; padding-: 2px; padding-: 1px; padding-top: 0px; padding-bottom: 0px; } +.cal_today_peruser_impair { /* background: #FDFDF0; */ } .cal_past { } .cal_peruser { padding: 0px; height: 22px !important; } .cal_peruserviewname { max-width: 140px; height: 22px !important; } -.cal_impair { background: #F8F8F8; } -.cal_today_peruser_impair { background: #F8F8F0; } +.cal_impair { background: #FBFBFB; } .peruser_busy { background: #CC8888; } .peruser_notbusy { background: #EEDDDD; opacity: 0.5; } div.event { margin-top: 4px; margin-bottom: 4px; margin-left: 2px; margin-right: 2px; border-radius: 4px; box-shadow: 2px 2px 5px rgba(100, 100, 100, 0.2); }