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 .= '