From 3930b00e4d407adb50adfa6a48d88a856f8fd9ab Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 11 Sep 2020 14:35:52 +0200 Subject: [PATCH] Debug a not used page to show agenda per type of event --- htdocs/comm/action/index.php | 2 + htdocs/comm/action/pertype.php | 213 +++++++++++++++++++++++-------- htdocs/comm/action/peruser.php | 12 +- htdocs/theme/eldy/global.inc.php | 2 +- 4 files changed, 173 insertions(+), 56 deletions(-) diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index 0c6ca3c1acc..135f91c56f4 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -398,6 +398,8 @@ if ($action == 'show_month') $tabactive = 'cardmonth'; if ($action == 'show_week') $tabactive = 'cardweek'; if ($action == 'show_day') $tabactive = 'cardday'; if ($action == 'show_list') $tabactive = 'cardlist'; +if ($action == 'show_pertuser') $tabactive = 'cardperuser'; +if ($action == 'show_pertype') $tabactive = 'cardpertype'; $paramnoaction = preg_replace('/action=[a-z_]+/', '', $param); diff --git a/htdocs/comm/action/pertype.php b/htdocs/comm/action/pertype.php index 7eb5b9e5c6d..72b25c9d731 100644 --- a/htdocs/comm/action/pertype.php +++ b/htdocs/comm/action/pertype.php @@ -41,9 +41,9 @@ require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; if (!isset($conf->global->AGENDA_MAX_EVENTS_DAY_VIEW)) $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW = 3; -$filter = GETPOST("filter", 'alpha', 3); -$filtert = GETPOST("filtert", "int", 3); -$usergroup = GETPOST("usergroup", "int", 3); +$filter = GETPOST("search_filter", 'alpha', 3) ? GETPOST("search_filter", 'alpha', 3) : GETPOST("filter", 'alpha', 3); +$filtert = GETPOST("search_filtert", "int", 3) ? GETPOST("search_filtert", "int", 3) : GETPOST("filtert", "int", 3); +$usergroup = GETPOST("search_usergroup", "int", 3) ? GETPOST("search_usergroup", "int", 3) : GETPOST("usergroup", "int", 3); //if (! ($usergroup > 0) && ! ($filtert > 0)) $filtert = $user->id; //$showbirthday = empty($conf->use_javascript_ajax)?GETPOST("showbirthday","int"):1; $showbirthday = 0; @@ -64,7 +64,7 @@ if (!$sortorder) $sortorder = "ASC"; if (!$sortfield) $sortfield = "a.datec"; // Security check -$socid = GETPOST("socid", "int"); +$socid = GETPOST("search_socid", "int") ?GETPOST("search_socid", "int") : GETPOST("socid", "int"); if ($user->socid) $socid = $user->socid; $result = restrictedArea($user, 'agenda', 0, '', 'myactions'); if ($socid < 0) $socid = ''; @@ -79,22 +79,23 @@ if (!$user->rights->agenda->allactions->read || $filter == 'mine') // If no per //$action=GETPOST('action','alpha'); $action = 'show_pertype'; -$resourceid = GETPOST("resourceid", "int"); +$resourceid = GETPOST("search_resourceid", "int") ?GETPOST("search_resourceid", "int") : GETPOST("resourceid", "int"); $year = GETPOST("year", "int") ?GETPOST("year", "int") : date("Y"); $month = GETPOST("month", "int") ?GETPOST("month", "int") : date("m"); $week = GETPOST("week", "int") ?GETPOST("week", "int") : date("W"); $day = GETPOST("day", "int") ?GETPOST("day", "int") : date("d"); -$pid = GETPOST("projectid", "int", 3); -$status = GETPOST("status", 'alpha'); -$type = GETPOST("type", 'alpha'); +$pid = GETPOST("search_projectid", "int", 3) ?GETPOST("search_projectid", "int", 3) : GETPOST("projectid", "int", 3); +$status = GETPOST("search_status", 'alpha') ?GETPOST("search_status", 'alpha') : GETPOST("status", 'alpha'); +$type = GETPOST("search_type", 'alpha') ?GETPOST("search_type", 'alpha') : GETPOST("type", 'alpha'); $maxprint = ((GETPOST("maxprint", 'int') != '') ?GETPOST("maxprint", 'int') : $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW); +$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) -if (GETPOST('actioncode', 'array')) +if (GETPOST('search_actioncode', 'array')) { - $actioncode = GETPOST('actioncode', 'array', 3); + $actioncode = GETPOST('search_actioncode', 'array', 3); if (!count($actioncode)) $actioncode = '0'; } else { - $actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode", "alpha") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE)); + $actioncode = GETPOST("search_actioncode", "alpha", 3) ?GETPOST("search_actioncode", "alpha", 3) : (GETPOST("search_actioncode", "alpha") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE)); } if ($actioncode == '' && empty($actioncodearray)) $actioncode = (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE); @@ -107,6 +108,7 @@ if ($dateselect > 0) } $tmp = empty($conf->global->MAIN_DEFAULT_WORKING_HOURS) ? '9-18' : $conf->global->MAIN_DEFAULT_WORKING_HOURS; +$tmp = str_replace(' ', '', $tmp); // FIX 7533 $tmparray = explode('-', $tmp); $begin_h = GETPOST('begin_h', 'int') != '' ?GETPOST('begin_h', 'int') : ($tmparray[0] != '' ? $tmparray[0] : 9); $end_h = GETPOST('end_h', 'int') ?GETPOST('end_h', 'int') : ($tmparray[1] != '' ? $tmparray[1] : 18); @@ -115,14 +117,15 @@ if ($end_h < 1 || $end_h > 24) $end_h = 18; if ($end_h <= $begin_h) $end_h = $begin_h + 1; $tmp = empty($conf->global->MAIN_DEFAULT_WORKING_DAYS) ? '1-5' : $conf->global->MAIN_DEFAULT_WORKING_DAYS; +$tmp = str_replace(' ', '', $tmp); // FIX 7533 $tmparray = explode('-', $tmp); $begin_d = 1; -$end_d = 53; +$end_d = 53; if ($status == '' && !isset($_GET['status']) && !isset($_POST['status'])) $status = (empty($conf->global->AGENDA_DEFAULT_FILTER_STATUS) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_STATUS); if (empty($action) && !isset($_GET['action']) && !isset($_POST['action'])) $action = (empty($conf->global->AGENDA_DEFAULT_VIEW) ? 'show_month' : $conf->global->AGENDA_DEFAULT_VIEW); -if (GETPOST('viewcal') && $action != 'show_day' && $action != 'show_week' && $action != 'show_peruser') { +if (GETPOST('viewcal', 'alpha') && $action != 'show_day' && $action != 'show_week' && $action != 'show_peruser') { $action = 'show_month'; $day = ''; } // View by month if (GETPOST('viewweek', 'alpha') || $action == 'show_week') { @@ -150,6 +153,10 @@ if ($action == 'delete_action') { $event = new ActionComm($db); $event->fetch($actionid); + $event->fetch_optionals(); + $event->fetch_userassigned(); + $event->oldcopy = clone $event; + $result = $event->delete(); } @@ -159,6 +166,27 @@ if ($action == 'delete_action') * View */ +$parameters = array( + 'socid' => $socid, + 'status' => $status, + 'year' => $year, + 'month' => $month, + 'day' => $day, + 'type' => $type, + 'maxprint' => $maxprint, + 'filter' => $filter, + 'filtert' => $filtert, + 'showbirthday' => $showbirthday, + 'canedit' => $canedit, + 'optioncss' => $optioncss, + 'actioncode' => $actioncode, + 'pid' => $pid, + 'resourceid' => $resourceid, + 'usergroup' => $usergroup, +); +$reshook = $hookmanager->executeHooks('beforeAgendaPerType', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + $form = new Form($db); $companystatic = new Societe($db); @@ -199,18 +227,26 @@ if ($status == 'done') $title = $langs->trans("DoneActions"); if ($status == 'todo') $title = $langs->trans("ToDoActions"); $param = ''; -if ($actioncode || isset($_GET['actioncode']) || isset($_POST['actioncode'])) $param .= "&actioncode=".$actioncode; -if ($resourceid > 0) $param .= "&resourceid=".$resourceid; -if ($status || isset($_GET['status']) || isset($_POST['status'])) $param .= "&status=".$status; -if ($filter) $param .= "&filter=".$filter; -if ($filtert) $param .= "&filtert=".$filtert; -if ($usergroup) $param .= "&usergroup=".$usergroup; -if ($socid) $param .= "&socid=".$socid; -if ($showbirthday) $param .= "&showbirthday=1"; -if ($pid) $param .= "&projectid=".$pid; -if ($type) $param .= "&type=".$type; -if ($action == 'show_day' || $action == 'show_week' || $action == 'show_month' || $action != 'show_peruser' || $action != 'show_pertype') $param .= '&action='.$action; -$param .= "&maxprint=".$maxprint; +if ($actioncode || isset($_GET['search_actioncode']) || isset($_POST['search_actioncode'])) { + if (is_array($actioncode)) { + foreach ($actioncode as $str_action) $param .= "&search_actioncode[]=".urlencode($str_action); + } else $param .= "&search_actioncode=".urlencode($actioncode); +} +if ($resourceid > 0) $param .= "&search_resourceid=".urlencode($resourceid); +if ($status || isset($_GET['status']) || isset($_POST['status'])) $param .= "&search_status=".urlencode($status); +if ($filter) $param .= "&search_filter=".urlencode($filter); +if ($filtert) $param .= "&search_filtert=".urlencode($filtert); +if ($usergroup) $param .= "&search_usergroup=".urlencode($usergroup); +if ($socid) $param .= "&search_socid=".urlencode($socid); +if ($showbirthday) $param .= "&search_showbirthday=1"; +if ($pid) $param .= "&search_projectid=".urlencode($pid); +if ($type) $param .= "&search_type=".urlencode($type); +if ($action == 'show_day' || $action == 'show_week' || $action == 'show_month' || $action != 'show_peruser') $param .= '&action='.urlencode($action); +if ($begin_h != '') $param .= '&begin_h='.urlencode($begin_h); +if ($end_h != '') $param .= '&end_h='.urlencode($end_h); +if ($begin_d != '') $param .= '&begin_d='.urlencode($begin_d); +if ($end_d != '') $param .= '&end_d='.urlencode($end_d); +$param .= "&maxprint=".urlencode($maxprint); $prev = dol_get_first_day($year, 1); $prev_year = $year - 1; @@ -238,6 +274,7 @@ $lastdaytoshow = dol_time_plus_duree($firstdaytoshow, 7, 'd'); $max_day_in_month = date("t", dol_mktime(0, 0, 0, $month, 1, $year)); $tmpday = $first_day; +$picto = 'calendartype'; $nav = "".img_previous($langs->trans("Previous"))."\n"; $nav .= " ".dol_print_date(dol_mktime(0, 0, 0, $first_month, $first_day, $first_year), "%Y")." \n"; @@ -245,7 +282,7 @@ $nav .= "".$langs->trans("Today").")"; $picto = 'calendarweek'; -$nav .= '  
'; +/*$nav .= '   '; $nav .= ''; $nav .= ''; $nav .= ''; @@ -260,27 +297,30 @@ $nav .= ''; $nav .= ''; $nav .= ''; $nav .= ''; - +*/ $nav .= $form->selectDate($dateselect, 'dateselect', 0, 0, 1, '', 1, 0); -$nav .= ' '; -$nav .= '
'; +//$nav .= ' '; +$nav .= ' '; +//$nav .= ''; // Must be after the nav definition -$param .= '&year='.$year.'&month='.$month.($day ? '&day='.$day : ''); +$param .= '&year='.urlencode($year).'&month='.urlencode($month).($day ? '&day='.urlencode($day) : ''); //print 'x'.$param; - - -$tabactive = 'cardpertype'; +$tabactive = ''; +if ($action == 'show_month') $tabactive = 'cardmonth'; +if ($action == 'show_week') $tabactive = 'cardweek'; +if ($action == 'show_day') $tabactive = 'cardday'; +if ($action == 'show_list') $tabactive = 'cardlist'; +if ($action == 'show_peruser') $tabactive = 'cardperuser'; +if ($action == 'show_pertype') $tabactive = 'cardpertype'; $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, 0, $filtert, 0, $pid, $socid, $action, $listofextcals, $actioncode, $usergroup, '', $resourceid); -dol_fiche_end(); +print '
'."\n"; $showextcals = $listofextcals; // Legend @@ -334,10 +374,73 @@ if ($conf->use_javascript_ajax) } } +$massactionbutton = ''; + +$viewmode = ''; +$viewmode .= ''; +//$viewmode .= ''; +$viewmode .= img_picto($langs->trans("List"), 'object_list-alt', 'class="pictoactionview block"'); +//$viewmode .= ''; +$viewmode .= ''.$langs->trans("ViewList").''; + +$viewmode .= ''; +//$viewmode .= ''; +$viewmode .= img_picto($langs->trans("ViewCal"), 'object_calendar', 'class="pictoactionview block"'); +//$viewmode .= ''; +$viewmode .= ''.$langs->trans("ViewCal").''; + +$viewmode .= ''; +//$viewmode .= ''; +$viewmode .= img_picto($langs->trans("ViewWeek"), 'object_calendarweek', 'class="pictoactionview block"'); +//$viewmode .= ''; +$viewmode .= ''.$langs->trans("ViewWeek").''; + +$viewmode .= ''; +//$viewmode .= ''; +$viewmode .= img_picto($langs->trans("ViewDay"), 'object_calendarday', 'class="pictoactionview block"'); +//$viewmode .= ''; +$viewmode .= ''.$langs->trans("ViewDay").''; + +$viewmode .= ''; +//$viewmode .= ''; +$viewmode .= img_picto($langs->trans("ViewPerUser"), 'object_calendarperuser', 'class="pictoactionview block"'); +//$viewmode .= ''; +$viewmode .= ''.$langs->trans("ViewPerUser").''; + +$viewmode .= ''; + + +$newcardbutton = ''; +if ($user->rights->agenda->myactions->create || $user->rights->agenda->allactions->create) +{ + $tmpforcreatebutton = dol_getdate(dol_now(), true); + + $newparam .= '&month='.str_pad($month, 2, "0", STR_PAD_LEFT).'&year='.$tmpforcreatebutton['year']; + + //$param='month='.$monthshown.'&year='.$year; + $hourminsec = '100000'; + $newcardbutton .= dolGetButtonTitle($langs->trans("AddAction"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create&datep='.sprintf("%04d%02d%02d", $tmpforcreatebutton['year'], $tmpforcreatebutton['mon'], $tmpforcreatebutton['mday']).$hourminsec.'&backtopage='.urlencode($_SERVER["PHP_SELF"].($newparam ? '?'.$newparam : ''))); +} + +print_barre_liste($langs->trans("Agenda"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, -1, 'object_action', 0, $nav.''.$newcardbutton, '', $limit, 1, 0, 1, $viewmode); $link = ''; -print load_fiche_titre($s, $link.'     '.$nav, ''); +//print load_fiche_titre('', $link.'     '.$nav.' '.$newcardbutton, ''); + +// Local calendar +$newtitle = '
'; +$newtitle .= ' '.$langs->trans("LocalAgenda").'   '; +$newtitle .= '
'; +//$newtitle=$langs->trans($title); + +$s = $newtitle; + +print $s; + +print '
'; +print_actions_filter($form, $canedit, $search_status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, -1, $actioncode, $usergroup, '', $resourceid); +print '
'; // Get event in an array @@ -377,7 +480,12 @@ if (!empty($actioncode)) if ($actioncode == 'AC_NON_AUTO') $sql .= " AND ca.type != 'systemauto'"; elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND ca.type = 'systemauto'"; else { - $sql .= " AND ca.code IN ('".implode("','", explode(',', $actioncode))."')"; + if (is_array($actioncode)) + { + $sql .= " AND ca.code IN ('".implode("','", $actioncode)."')"; + } else { + $sql .= " AND ca.code IN ('".implode("','", explode(',', $actioncode))."')"; + } } } } @@ -430,7 +538,7 @@ if ($filtert > 0 || $usergroup > 0) $sql .= ' ORDER BY fk_user_action, datep'; //fk_user_action //print $sql; -dol_syslog("comm/action/index.php", LOG_DEBUG); +dol_syslog("comm/action/pertype.php", LOG_DEBUG); $resql = $db->query($sql); if ($resql) { @@ -529,6 +637,7 @@ if ($resql) } $i++; } + $db->free($resql); } else { dol_print_error($db); } @@ -536,6 +645,7 @@ if ($resql) $maxnbofchar = 18; $cachethirdparties = array(); $cachecontacts = array(); +$cacheusers = array(); // Define theme_datacolor array $color_file = DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/theme_vars.inc.php"; @@ -557,11 +667,10 @@ $newparam = preg_replace('/viewweek=[0-9]+&?/i', '', $newparam); $newparam = preg_replace('/showbirthday_=/i', 'showbirthday=', $newparam); // Restore correct parameter $newparam .= '&viewweek=1'; -echo ''; +print ''; echo ''; echo ''; echo ''; -echo '
'; // Line header with list of days @@ -603,6 +712,7 @@ $sql = "SELECT code, color, libelle as label FROM ".MAIN_DB_PREFIX."c_actioncomm $resql = $db->query($sql); while ($obj = $db->fetch_object($resql)) { + $typeofevents[$obj->code] = $obj->code; $colorsbytype[$obj->code] = $obj->color; $labelbytype[$obj->code] = $obj->label; } @@ -616,7 +726,7 @@ foreach ($typeofevents as $typeofevent) { $var = !$var; echo ""; - echo ''.$username->getNomUrl(1).''; + echo ''.$typeofevent.''; $tmpday = $sav; // Lopp on each day of week @@ -642,7 +752,7 @@ foreach ($typeofevents as $typeofevent) if ($todayarray['mday'] == $tmpday && $todayarray['mon'] == $tmpmonth && $todayarray['year'] == $tmpyear) $today = 1; if ($today) $style = 'cal_today_peruser'; - show_day_events_pertype($username, $tmpday, $tmpmonth, $tmpyear, $monthshown, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, $showheader, $colorsbytype, $var); + show_day_events_pertype($typeofevent, $tmpday, $tmpmonth, $tmpyear, $mont, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, $showheader, $colorsbytype, $var); $i++; } @@ -651,7 +761,7 @@ foreach ($typeofevents as $typeofevent) } echo "\n"; - +echo "
"; if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) { @@ -678,6 +788,9 @@ if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) */ } +print "\n".''; +print "\n"; + // Add js code to manage click on a box print '