Simplify and standardize code for agenda pages
This commit is contained in:
parent
c16a150a70
commit
4cff4c6935
@ -545,8 +545,9 @@ if ($action == 'confirm_delete' && GETPOST("confirm") == 'yes')
|
||||
|
||||
/*
|
||||
* Action move update, used when user move an event in calendar by drag'n drop
|
||||
* TODO Move this into page comm/action/index that trigger this call by the drag and drop of event.
|
||||
*/
|
||||
if ($action == 'mupdate')
|
||||
if (GETPOST('actionmove','alpha') == 'mupdate')
|
||||
{
|
||||
$object->fetch($id);
|
||||
$object->fetch_userassigned();
|
||||
@ -557,7 +558,7 @@ if ($action == 'mupdate')
|
||||
$newdate=GETPOST('newdate','alpha');
|
||||
if (empty($newdate) || strpos($newdate,'dayevent_') != 0 )
|
||||
{
|
||||
header("Location: ".$backtopage);
|
||||
header("Location: ".$backtopage);
|
||||
exit;
|
||||
}
|
||||
|
||||
@ -1296,14 +1297,18 @@ if ($id > 0)
|
||||
|
||||
// Link to other agenda views
|
||||
$out='';
|
||||
$out.='</li><li class="noborder litext">'.img_picto($langs->trans("ViewPerUser"),'object_calendarperuser','class="hideonsmartphone pictoactionview"');
|
||||
$out.='<a href="'.DOL_URL_ROOT.'/comm/action/peruser.php?action=show_peruser&year='.dol_print_date($object->datep,'%Y').'&month='.dol_print_date($object->datep,'%m').'&day='.dol_print_date($object->datep,'%d').'">'.$langs->trans("ViewPerUser").'</a>';
|
||||
$out.='</li><li class="noborder litext">'.img_picto($langs->trans("ViewCal"),'object_calendar','class="hideonsmartphone pictoactionview"');
|
||||
$out.='</li>';
|
||||
$out.='<li class="noborder litext">'.img_picto($langs->trans("ViewCal"),'object_calendar','class="hideonsmartphone pictoactionview"');
|
||||
$out.='<a href="'.DOL_URL_ROOT.'/comm/action/index.php?action=show_month&year='.dol_print_date($object->datep,'%Y').'&month='.dol_print_date($object->datep,'%m').'&day='.dol_print_date($object->datep,'%d').'">'.$langs->trans("ViewCal").'</a>';
|
||||
$out.='</li><li class="noborder litext">'.img_picto($langs->trans("ViewWeek"),'object_calendarweek','class="hideonsmartphone pictoactionview"');
|
||||
$out.='</li>';
|
||||
$out.='<li class="noborder litext">'.img_picto($langs->trans("ViewWeek"),'object_calendarweek','class="hideonsmartphone pictoactionview"');
|
||||
$out.='<a href="'.DOL_URL_ROOT.'/comm/action/index.php?action=show_week&year='.dol_print_date($object->datep,'%Y').'&month='.dol_print_date($object->datep,'%m').'&day='.dol_print_date($object->datep,'%d').'">'.$langs->trans("ViewWeek").'</a>';
|
||||
$out.='</li><li class="noborder litext">'.img_picto($langs->trans("ViewDay"),'object_calendarday','class="hideonsmartphone pictoactionview"');
|
||||
$out.='</li>';
|
||||
$out.='<li class="noborder litext">'.img_picto($langs->trans("ViewDay"),'object_calendarday','class="hideonsmartphone pictoactionview"');
|
||||
$out.='<a href="'.DOL_URL_ROOT.'/comm/action/index.php?action=show_day&year='.dol_print_date($object->datep,'%Y').'&month='.dol_print_date($object->datep,'%m').'&day='.dol_print_date($object->datep,'%d').'">'.$langs->trans("ViewDay").'</a>';
|
||||
$out.='</li>';
|
||||
$out.='<li class="noborder litext">'.img_picto($langs->trans("ViewPerUser"),'object_calendarperuser','class="hideonsmartphone pictoactionview"');
|
||||
$out.='<a href="'.DOL_URL_ROOT.'/comm/action/peruser.php?action=show_peruser&year='.dol_print_date($object->datep,'%Y').'&month='.dol_print_date($object->datep,'%m').'&day='.dol_print_date($object->datep,'%d').'">'.$langs->trans("ViewPerUser").'</a>';
|
||||
$linkback.=$out;
|
||||
|
||||
$morehtmlref='<div class="refidno">';
|
||||
|
||||
@ -359,6 +359,8 @@ $paramnoaction=preg_replace('/action=[a-z_]+/','',$param);
|
||||
|
||||
$head = calendars_prepare_head($paramnoaction);
|
||||
|
||||
print '<form method="POST" id="searchFormList" class="listactionsfilter" action="'.$_SERVER["PHP_SELF"].'">'."\n";
|
||||
|
||||
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();
|
||||
@ -371,25 +373,28 @@ $showextcals=$listofextcals;
|
||||
|
||||
if (! empty($conf->use_javascript_ajax)) // If javascript on
|
||||
{
|
||||
$s.='<!-- Div to calendars selectors -->'."\n";
|
||||
$s.="\n".'<!-- Div to calendars selectors -->'."\n";
|
||||
$s.='<script type="text/javascript">' . "\n";
|
||||
$s.='jQuery(document).ready(function () {' . "\n";
|
||||
$s.='jQuery("#check_birthday").click(function() { console.log("Toggle birthday"); jQuery(".family_birthday").toggle(); });' . "\n";
|
||||
$s.='jQuery(".family_birthday").toggle();' . "\n";
|
||||
if ($action=="show_week" || $action=="show_month" || empty($action))
|
||||
{
|
||||
// Code to enable drag and drop
|
||||
$s.='jQuery( "div.sortable" ).sortable({connectWith: ".sortable", placeholder: "ui-state-highlight", items: "div.movable", receive: function( event, ui ) {';
|
||||
// Code to submit form
|
||||
$s.='console.log("submit form to record new event");';
|
||||
//$s.='console.log(event.target);';
|
||||
$s.='var newval = jQuery(event.target).closest("div.dayevent").attr("id");';
|
||||
$s.='console.log("found parent div.dayevent with id = "+newval);';
|
||||
$s.='var frm=jQuery("#move_event"); frm.attr("action",ui.item.find("a.cal_event").attr("href")).children("#newdate").val(newval);frm.submit();}';
|
||||
$s.='});'."\n";
|
||||
}
|
||||
$s.='});' . "\n";
|
||||
$s.='</script>' . "\n";
|
||||
// Code to enable drag and drop
|
||||
$s.='jQuery( "div.sortable" ).sortable({connectWith: ".sortable", placeholder: "ui-state-highlight", items: "div.movable", receive: function( event, ui ) {'."\n";
|
||||
// Code to submit form
|
||||
$s.='console.log("submit form to record new event");'."\n";
|
||||
//$s.='console.log(event.target);';
|
||||
$s.='var newval = jQuery(event.target).closest("div.dayevent").attr("id");'."\n";
|
||||
$s.='console.log("found parent div.dayevent with id = "+newval);'."\n";
|
||||
$s.='var frm=jQuery("#searchFormList");'."\n";
|
||||
$s.='var newurl = ui.item.find("a.cal_event").attr("href");'."\n";
|
||||
$s.='console.log(newurl);'."\n";
|
||||
$s.='frm.attr("action", newurl).children("#newdate").val(newval);frm.submit();}'."\n";
|
||||
$s.='});'."\n";
|
||||
}
|
||||
$s.='});' . "\n";
|
||||
$s.='</script>' . "\n";
|
||||
|
||||
// Local calendar
|
||||
$s.='<div class="nowrap clear inline-block minheight20"><input type="checkbox" id="check_mytasks" name="check_mytasks" checked disabled> ' . $langs->trans("LocalAgenda").' </div>';
|
||||
@ -1088,12 +1093,10 @@ if (empty($action) || $action == 'show_month') // View by month
|
||||
echo " </tr>\n";
|
||||
}
|
||||
echo "</table>\n";
|
||||
echo '<form id="move_event" action="" method="POST"><input type="hidden" name="action" value="mupdate">';
|
||||
echo '<input type="hidden" name="backtopage" value="'.dol_escape_htmltag($_SERVER['PHP_SELF']).'?'.dol_escape_htmltag($_SERVER['QUERY_STRING']).'">';
|
||||
echo '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
echo '<input type="hidden" name="newdate" id="newdate">' ;
|
||||
echo '</form>';
|
||||
|
||||
echo '<input type="hidden" name="actionmove" value="mupdate">';
|
||||
echo '<input type="hidden" name="backtopage" value="'.dol_escape_htmltag($_SERVER['PHP_SELF']).'?'.dol_escape_htmltag($_SERVER['QUERY_STRING']).'">';
|
||||
echo '<input type="hidden" name="newdate" id="newdate">' ;
|
||||
}
|
||||
elseif ($action == 'show_week') // View by week
|
||||
{
|
||||
@ -1142,11 +1145,10 @@ elseif ($action == 'show_week') // View by week
|
||||
echo " </tr>\n";
|
||||
|
||||
echo "</table>\n";
|
||||
echo '<form id="move_event" action="" method="POST"><input type="hidden" name="action" value="mupdate">';
|
||||
|
||||
echo '<input type="hidden" name="actionmove" value="mupdate">';
|
||||
echo '<input type="hidden" name="backtopage" value="'.dol_escape_htmltag($_SERVER['PHP_SELF']).'?'.dol_escape_htmltag($_SERVER['QUERY_STRING']).'">';
|
||||
echo '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
echo '<input type="hidden" name="newdate" id="newdate">' ;
|
||||
echo '</form>';
|
||||
}
|
||||
else // View by day
|
||||
{
|
||||
@ -1177,6 +1179,8 @@ else // View by day
|
||||
echo '</table>';
|
||||
}
|
||||
|
||||
print "\n".'</form>';
|
||||
|
||||
llxFooter();
|
||||
|
||||
$db->close();
|
||||
@ -1240,11 +1244,12 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa
|
||||
print '<div class="tagtd centpercent agendacell sortable">';
|
||||
|
||||
//$curtime = dol_mktime (0, 0, 0, $month, $day, $year);
|
||||
$i=0; $nummytasks=0; $numother=0; $numbirthday=0; $numical=0; $numicals=array();
|
||||
$i=0; $numother=0; $numbirthday=0; $numical=0; $numicals=array();
|
||||
$ymd=sprintf("%04d",$year).sprintf("%02d",$month).sprintf("%02d",$day);
|
||||
|
||||
$nextindextouse=count($colorindexused); // At first run this is 0, so fist user has 0, next 1, ...
|
||||
//print $nextindextouse;
|
||||
$colorindexused[$user->id] = 0; // Color index for current user (user->id) is always 0
|
||||
$nextindextouse=count($colorindexused); // At first run this is 0, so first user has 0, next 1, ...
|
||||
//var_dump($colorindexused);
|
||||
|
||||
foreach ($eventarray as $daykey => $notused)
|
||||
{
|
||||
@ -1258,25 +1263,24 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa
|
||||
if ($i < $maxprint || $maxprint == 0 || ! empty($conf->global->MAIN_JS_SWITCH_AGENDA))
|
||||
{
|
||||
$keysofuserassigned=array_keys($event->userassigned);
|
||||
|
||||
$ponct=($event->date_start_in_calendar == $event->date_end_in_calendar);
|
||||
|
||||
// Define $color (Hex string like '0088FF') and $cssclass of event
|
||||
$color=-1; $colorindex=-1;
|
||||
$color=-1; $cssclass=''; $colorindex=-1;
|
||||
if (in_array($user->id, $keysofuserassigned))
|
||||
{
|
||||
$nummytasks++; $cssclass='family_mytasks';
|
||||
$cssclass='family_mytasks';
|
||||
|
||||
if (empty($cacheusers[$event->userownerid]))
|
||||
{
|
||||
$newuser=new User($db);
|
||||
$newuser->fetch($event->userownerid);
|
||||
$cacheusers[$event->userownerid]=$newuser;
|
||||
}
|
||||
//var_dump($cacheusers[$event->userownerid]->color);
|
||||
if (empty($cacheusers[$event->userownerid]))
|
||||
{
|
||||
$newuser=new User($db);
|
||||
$newuser->fetch($event->userownerid);
|
||||
$cacheusers[$event->userownerid]=$newuser;
|
||||
}
|
||||
//var_dump($cacheusers[$event->userownerid]->color);
|
||||
|
||||
// We decide to choose color of owner of event (event->userownerid is user id of owner, event->userassigned contains all users assigned to event)
|
||||
if (! empty($cacheusers[$event->userownerid]->color)) $color=$cacheusers[$event->userownerid]->color;
|
||||
// We decide to choose color of owner of event (event->userownerid is user id of owner, event->userassigned contains all users assigned to event)
|
||||
if (! empty($cacheusers[$event->userownerid]->color)) $color=$cacheusers[$event->userownerid]->color;
|
||||
}
|
||||
else if ($event->type_code == 'ICALEVENT') // Event come from external ical file
|
||||
{
|
||||
@ -1287,6 +1291,7 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa
|
||||
}
|
||||
$numicals[dol_string_nospecial($event->icalname)]++;
|
||||
}
|
||||
|
||||
$color=($event->icalcolor?$event->icalcolor:-1);
|
||||
$cssclass=(! empty($event->icalname)?'family_ext'.md5($event->icalname):'family_other');
|
||||
}
|
||||
@ -1311,7 +1316,8 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa
|
||||
// We decide to choose color of owner of event (event->userownerid is user id of owner, event->userassigned contains all users assigned to event)
|
||||
if (! empty($cacheusers[$event->userownerid]->color)) $color=$cacheusers[$event->userownerid]->color;
|
||||
}
|
||||
if ($color == -1) // Color was not forced. Set color according to color index.
|
||||
|
||||
if ($color < 0) // Color was not set on user card. Set color according to color index.
|
||||
{
|
||||
// Define color index if not yet defined
|
||||
$idusertouse=($event->userownerid?$event->userownerid:0);
|
||||
@ -1321,8 +1327,8 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa
|
||||
}
|
||||
else
|
||||
{
|
||||
$colorindex=$nextindextouse;
|
||||
$colorindexused[$idusertouse]=$colorindex;
|
||||
$colorindex=$nextindextouse;
|
||||
$colorindexused[$idusertouse]=$colorindex;
|
||||
if (! empty($theme_datacolor[$nextindextouse+1])) $nextindextouse++; // Prepare to use next color
|
||||
}
|
||||
//print '|'.($color).'='.($idusertouse?$idusertouse:0).'='.$colorindex.'<br>';
|
||||
@ -1358,7 +1364,6 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa
|
||||
}else{
|
||||
$cssclass.= " unmovable";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$h=''; $nowrapontd=1;
|
||||
@ -1376,7 +1381,7 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa
|
||||
//var_dump($event->userassigned);
|
||||
//var_dump($event->transparency);
|
||||
print '<table class="centpercent cal_event'.(empty($event->transparency)?' cal_event_notbusy':' cal_event_busy').'" style="'.$h;
|
||||
if (empty($event->transparency))
|
||||
if (empty($event->transparency) && empty($conf->global->AGENDA_NO_TRANSPARENT_ON_NOT_BUSY))
|
||||
{
|
||||
print 'border: 2px solid #'.$color.';';
|
||||
}
|
||||
|
||||
@ -357,6 +357,8 @@ if ($resql)
|
||||
|
||||
$head = calendars_prepare_head($param);
|
||||
|
||||
print '<form method="POST" id="searchFormList" class="listactionsfilter" action="'.$_SERVER["PHP_SELF"].'">'."\n";
|
||||
|
||||
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,-1,$actioncode,$usergroup,'',$resourceid);
|
||||
dol_fiche_end();
|
||||
@ -393,7 +395,6 @@ if ($resql)
|
||||
}
|
||||
|
||||
|
||||
print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n";
|
||||
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" name="action" value="list">';
|
||||
@ -404,7 +405,7 @@ if ($resql)
|
||||
print '<input type="hidden" name="type" value="'.$type.'">';
|
||||
$nav='';
|
||||
if ($optioncss != '') $nav.= '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
|
||||
if ($actioncode) $nav.='<input type="hidden" name="actioncode" value="'.$actioncode.'">';
|
||||
//if ($actioncode) $nav.='<input type="hidden" name="actioncode" value="'.$actioncode.'">';
|
||||
if ($resourceid) $nav.='<input type="hidden" name="resourceid" value="'.$resourceid.'">';
|
||||
if ($filter) $nav.='<input type="hidden" name="filter" value="'.$filter.'">';
|
||||
if ($filtert) $nav.='<input type="hidden" name="filtert" value="'.$filtert.'">';
|
||||
@ -627,14 +628,16 @@ if ($resql)
|
||||
if ($late) print img_warning($langs->trans("Late")).' ';
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
// End date
|
||||
if (! empty($arrayfields['a.datep2']['checked'])) {
|
||||
// End date
|
||||
print '<td align="center" class="nowrap">';
|
||||
print dol_print_date($db->jdate($obj->dp2),"dayhour");
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
// Third party
|
||||
if (! empty($arrayfields['s.nom']['checked'])) {
|
||||
// Third party
|
||||
print '<td class="tdoverflowmax100">';
|
||||
if ($obj->socid)
|
||||
{
|
||||
@ -646,8 +649,9 @@ if ($resql)
|
||||
else print ' ';
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
// Contact
|
||||
if (! empty($arrayfields['a.fk_contact']['checked'])) {
|
||||
// Contact
|
||||
print '<td>';
|
||||
if ($obj->fk_contact > 0)
|
||||
{
|
||||
@ -662,8 +666,9 @@ if ($resql)
|
||||
}
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
// Linked object
|
||||
if (! empty($arrayfields['a.fk_element']['checked'])) {
|
||||
// Linked object
|
||||
print '<td>';
|
||||
if ($obj->fk_element > 0 && ! empty($obj->elementtype)) {
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
|
||||
@ -674,6 +679,7 @@ if ($resql)
|
||||
print '</td>';
|
||||
|
||||
}
|
||||
|
||||
// Extra fields
|
||||
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
|
||||
{
|
||||
|
||||
@ -218,8 +218,13 @@ 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') $param.='&action='.$action;
|
||||
if ($begin_h != '') $param.='&begin_h='.$begin_h;
|
||||
if ($end_h != '') $param.='&end_h='.$end_h;
|
||||
if ($begin_d != '') $param.='&begin_d='.$begin_d;
|
||||
if ($end_d != '') $param.='&end_d='.$end_d;
|
||||
$param.="&maxprint=".$maxprint;
|
||||
|
||||
|
||||
$prev = dol_get_first_day_week($day, $month, $year);
|
||||
//print "day=".$day." month=".$month." year=".$year;
|
||||
//var_dump($prev); exit;
|
||||
@ -248,15 +253,15 @@ $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='calendarweek';
|
||||
|
||||
$nav ="<a href=\"?year=".$prev_year."&month=".$prev_month."&day=".$prev_day.$param."\"><i class=\"fa fa-chevron-left\" title=\"".dol_escape_htmltag($langs->trans("Previous"))."\"></i></a> \n";
|
||||
$nav.=" <span id=\"month_name\">".dol_print_date(dol_mktime(0,0,0,$first_month,$first_day,$first_year),"%Y").", ".$langs->trans("Week")." ".$week;
|
||||
$nav.=" </span>\n";
|
||||
$nav.=" <a href=\"?year=".$next_year."&month=".$next_month."&day=".$next_day.$param."\"><i class=\"fa fa-chevron-right\" title=\"".dol_escape_htmltag($langs->trans("Next"))."\"></i></a>\n";
|
||||
$nav.=" (<a href=\"?year=".$nowyear."&month=".$nowmonth."&day=".$nowday.$param."\">".$langs->trans("Today")."</a>)";
|
||||
$picto='calendarweek';
|
||||
|
||||
$nav.=' <form name="dateselect" action="'.$_SERVER["PHP_SELF"].'?action=show_peruser'.$param.'">';
|
||||
/*$nav.=' <form name="dateselect" action="'.$_SERVER["PHP_SELF"].'?action=show_peruser'.$param.'">';
|
||||
$nav.='<input type="hidden" name="token" value="' . $_SESSION ['newtoken'] . '">';
|
||||
$nav.='<input type="hidden" name="action" value="' . $action . '">';
|
||||
$nav.='<input type="hidden" name="filtert" value="' . $filtert . '">';
|
||||
@ -271,10 +276,10 @@ $nav.='<input type="hidden" name="end_h" value="' . $end_h . '">';
|
||||
$nav.='<input type="hidden" name="begin_d" value="' . $begin_d . '">';
|
||||
$nav.='<input type="hidden" name="end_d" value="' . $end_d . '">';
|
||||
$nav.='<input type="hidden" name="showbirthday" value="' . $showbirthday . '">';
|
||||
|
||||
*/
|
||||
$nav.=$form->select_date($dateselect, 'dateselect', 0, 0, 1, '', 1, 0, 1);
|
||||
$nav.=' <input type="submit" name="submitdateselect" class="button" value="'.$langs->trans("Refresh").'">';
|
||||
$nav.='</form>';
|
||||
//$nav.='</form>';
|
||||
|
||||
// Must be after the nav definition
|
||||
$param.='&year='.$year.'&month='.$month.($day?'&day='.$day:'');
|
||||
@ -294,6 +299,8 @@ $paramnoaction=preg_replace('/action=[a-z_]+/','',$param);
|
||||
|
||||
$head = calendars_prepare_head($paramnoaction);
|
||||
|
||||
print '<form method="POST" id="searchFormList" class="listactionsfilter" action="'.$_SERVER["PHP_SELF"].'">'."\n";
|
||||
|
||||
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();
|
||||
@ -581,6 +588,7 @@ else
|
||||
$maxnbofchar=18;
|
||||
$cachethirdparties=array();
|
||||
$cachecontacts=array();
|
||||
$cacheusers=array();
|
||||
|
||||
// Define theme_datacolor array
|
||||
$color_file = DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/graph-color.php";
|
||||
@ -602,11 +610,9 @@ $newparam=preg_replace('/viewweek=[0-9]+&?/i','',$newparam);
|
||||
$newparam=preg_replace('/showbirthday_=/i','showbirthday=',$newparam); // Restore correct parameter
|
||||
$newparam.='&viewweek=1';
|
||||
|
||||
echo '<form id="move_event" action="" method="POST"><input type="hidden" name="action" value="mupdate">';
|
||||
echo '<input type="hidden" name="actionmove" value="mupdate">';
|
||||
echo '<input type="hidden" name="backtopage" value="'.dol_escape_htmltag($_SERVER['PHP_SELF']).'?'.dol_escape_htmltag($_SERVER['QUERY_STRING']).'">';
|
||||
echo '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
echo '<input type="hidden" name="newdate" id="newdate">' ;
|
||||
echo '</form>';
|
||||
|
||||
|
||||
// Line header with list of days
|
||||
@ -792,7 +798,7 @@ foreach ($usernames as $username)
|
||||
echo "</table>\n";
|
||||
echo '</div>';
|
||||
|
||||
if (! empty($conf->global->AGENDA_USE_EVENT_TYPE))
|
||||
if (! empty($conf->global->AGENDA_USE_EVENT_TYPE) && ! empty($conf->global->AGENDA_USE_COLOR_PER_EVENT_TYPE))
|
||||
{
|
||||
$langs->load("commercial");
|
||||
print '<br>'.$langs->trans("Legend").': <br>';
|
||||
@ -817,6 +823,9 @@ if (! empty($conf->global->AGENDA_USE_EVENT_TYPE))
|
||||
*/
|
||||
}
|
||||
|
||||
print "\n".'</form>';
|
||||
print "\n";
|
||||
|
||||
// Add js code to manage click on a box
|
||||
print '<script type="text/javascript" language="javascript">
|
||||
jQuery(document).ready(function() {
|
||||
@ -887,19 +896,19 @@ function show_day_events2($username, $day, $month, $year, $monthshown, $style, &
|
||||
global $user, $conf, $langs, $hookmanager, $action;
|
||||
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 $cachethirdparties, $cachecontacts, $cacheusers, $cacheprojects, $colorindexused;
|
||||
global $begin_h, $end_h;
|
||||
global $cache_project, $cache_thirdparty, $cache_contact;
|
||||
|
||||
$cases1 = array(); // Color first half hour
|
||||
$cases2 = array(); // Color second half hour
|
||||
|
||||
$curtime = dol_mktime(0, 0, 0, $month, $day, $year, false, 0);
|
||||
|
||||
$i=0; $nummytasks=0; $numother=0; $numbirthday=0; $numical=0; $numicals=array();
|
||||
$i=0; $numother=0; $numbirthday=0; $numical=0; $numicals=array();
|
||||
$ymd=sprintf("%04d",$year).sprintf("%02d",$month).sprintf("%02d",$day);
|
||||
|
||||
$nextindextouse=count($colorindexused); // At first run, this is 0, so fist user has 0, next 1, ...
|
||||
$colorindexused[$user->id] = 0; // Color index for current user (user->id) is always 0
|
||||
$nextindextouse=count($colorindexused); // At first run this is 0, so first user has 0, next 1, ...
|
||||
//if ($username->id && $day==1) var_dump($eventarray);
|
||||
|
||||
// We are in a particular day for $username, now we scan all events
|
||||
@ -918,6 +927,8 @@ function show_day_events2($username, $day, $month, $year, $monthshown, $style, &
|
||||
//var_dump($event);
|
||||
|
||||
$keysofuserassigned=array_keys($event->userassigned);
|
||||
$ponct=($event->date_start_in_calendar == $event->date_end_in_calendar);
|
||||
|
||||
if (! in_array($username->id,$keysofuserassigned)) continue; // We discard record if event is from another user than user we want to show
|
||||
//if ($username->id != $event->userownerid) continue; // We discard record if event is from another user than user we want to show
|
||||
|
||||
@ -925,14 +936,24 @@ function show_day_events2($username, $day, $month, $year, $monthshown, $style, &
|
||||
$reshook=$hookmanager->executeHooks('formatEvent',$parameters,$event,$action); // Note that $action and $object may have been modified by some hooks
|
||||
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||
|
||||
$ponct=($event->date_start_in_calendar == $event->date_end_in_calendar);
|
||||
|
||||
// Define $color (Hex string like '0088FF') and $cssclass of event
|
||||
$color=-1; $cssclass=''; $colorindex=-1;
|
||||
if (in_array($user->id, $keysofuserassigned))
|
||||
{
|
||||
$nummytasks++; $cssclass='family_mytasks';
|
||||
if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) $color=$event->type_color;
|
||||
$cssclass='family_mytasks';
|
||||
|
||||
if (empty($cacheusers[$event->userownerid]))
|
||||
{
|
||||
$newuser=new User($db);
|
||||
$newuser->fetch($event->userownerid);
|
||||
$cacheusers[$event->userownerid]=$newuser;
|
||||
}
|
||||
//var_dump($cacheusers[$event->userownerid]->color);
|
||||
|
||||
// We decide to choose color of owner of event (event->userownerid is user id of owner, event->userassigned contains all users assigned to event)
|
||||
if (! empty($cacheusers[$event->userownerid]->color)) $color=$cacheusers[$event->userownerid]->color;
|
||||
|
||||
if (! empty($conf->global->AGENDA_USE_COLOR_PER_EVENT_TYPE)) $color=$event->type_color;
|
||||
}
|
||||
else if ($event->type_code == 'ICALEVENT')
|
||||
{
|
||||
@ -954,11 +975,25 @@ function show_day_events2($username, $day, $month, $year, $monthshown, $style, &
|
||||
}
|
||||
else
|
||||
{
|
||||
$numother++; $cssclass='family_other';
|
||||
if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) $color=$event->type_color;
|
||||
$numother++;
|
||||
$color=($event->icalcolor?$event->icalcolor:-1);
|
||||
$cssclass=(! empty($event->icalname)?'family_ext'.md5($event->icalname):'family_other');
|
||||
|
||||
if (empty($cacheusers[$event->userownerid]))
|
||||
{
|
||||
$newuser=new User($db);
|
||||
$newuser->fetch($event->userownerid);
|
||||
$cacheusers[$event->userownerid]=$newuser;
|
||||
}
|
||||
//var_dump($cacheusers[$event->userownerid]->color);
|
||||
|
||||
// We decide to choose color of owner of event (event->userownerid is user id of owner, event->userassigned contains all users assigned to event)
|
||||
if (! empty($cacheusers[$event->userownerid]->color)) $color=$cacheusers[$event->userownerid]->color;
|
||||
|
||||
if (! empty($conf->global->AGENDA_USE_COLOR_PER_EVENT_TYPE)) $color=$event->type_color;
|
||||
}
|
||||
|
||||
if ($color < 0) // Color was not forced. Set color according to color index.
|
||||
if ($color < 0) // Color was not set on user card. Set color according to color index.
|
||||
{
|
||||
// Define color index if not yet defined
|
||||
$idusertouse=($event->userownerid?$event->userownerid:0);
|
||||
@ -1010,33 +1045,33 @@ function show_day_events2($username, $day, $month, $year, $monthshown, $style, &
|
||||
$cases1[$h][$event->id]['color']=$color;
|
||||
if ($event->fk_project > 0)
|
||||
{
|
||||
if (empty($cache_project[$event->fk_project]))
|
||||
if (empty($cacheprojects[$event->fk_project]))
|
||||
{
|
||||
$tmpproj=new Project($db);
|
||||
$tmpproj->fetch($event->fk_project);
|
||||
$cache_project[$event->fk_project]=$tmpproj;
|
||||
$cacheprojects[$event->fk_project]=$tmpproj;
|
||||
}
|
||||
$cases1[$h][$event->id]['string'].=', '.$langs->trans("Project").': '.$cache_project[$event->fk_project]->ref.' - '.$cache_project[$event->fk_project]->title;
|
||||
$cases1[$h][$event->id]['string'].=', '.$langs->trans("Project").': '.$cacheprojects[$event->fk_project]->ref.' - '.$cacheprojects[$event->fk_project]->title;
|
||||
}
|
||||
if ($event->socid > 0)
|
||||
{
|
||||
if (empty($cache_thirdparty[$event->socid]))
|
||||
if (empty($cachethirdparties[$event->socid]))
|
||||
{
|
||||
$tmpthirdparty=new Societe($db);
|
||||
$tmpthirdparty->fetch($event->socid);
|
||||
$cache_thirdparty[$event->socid]=$tmpthirdparty;
|
||||
$cachethirdparties[$event->socid]=$tmpthirdparty;
|
||||
}
|
||||
$cases1[$h][$event->id]['string'].=', '.$cache_thirdparty[$event->socid]->name;
|
||||
$cases1[$h][$event->id]['string'].=', '.$cachethirdparties[$event->socid]->name;
|
||||
}
|
||||
if ($event->contactid > 0)
|
||||
{
|
||||
if (empty($cache_contact[$event->contactid]))
|
||||
if (empty($cachecontacts[$event->contactid]))
|
||||
{
|
||||
$tmpcontact=new Contact($db);
|
||||
$tmpcontact->fetch($event->contactid);
|
||||
$cache_contact[$event->contactid]=$tmpcontact;
|
||||
$cachecontacts[$event->contactid]=$tmpcontact;
|
||||
}
|
||||
$cases1[$h][$event->id]['string'].=', '.$cache_contact[$event->contactid]->getFullName($langs);
|
||||
$cases1[$h][$event->id]['string'].=', '.$cachecontacts[$event->contactid]->getFullName($langs);
|
||||
}
|
||||
}
|
||||
if ($event->date_start_in_calendar < $c && $dateendtouse > $b)
|
||||
@ -1056,33 +1091,33 @@ function show_day_events2($username, $day, $month, $year, $monthshown, $style, &
|
||||
$cases2[$h][$event->id]['color']=$color;
|
||||
if ($event->fk_project > 0)
|
||||
{
|
||||
if (empty($cache_project[$event->fk_project]))
|
||||
if (empty($cacheprojects[$event->fk_project]))
|
||||
{
|
||||
$tmpproj=new Project($db);
|
||||
$tmpproj->fetch($event->fk_project);
|
||||
$cache_project[$event->fk_project]=$tmpproj;
|
||||
$cacheprojects[$event->fk_project]=$tmpproj;
|
||||
}
|
||||
$cases2[$h][$event->id]['string'].=', '.$langs->trans("Project").': '.$cache_project[$event->fk_project]->ref.' - '.$cache_project[$event->fk_project]->title;
|
||||
$cases2[$h][$event->id]['string'].=', '.$langs->trans("Project").': '.$cacheprojects[$event->fk_project]->ref.' - '.$cacheprojects[$event->fk_project]->title;
|
||||
}
|
||||
if ($event->socid > 0)
|
||||
{
|
||||
if (empty($cache_thirdparty[$event->socid]))
|
||||
if (empty($cachethirdparties[$event->socid]))
|
||||
{
|
||||
$tmpthirdparty=new Societe($db);
|
||||
$tmpthirdparty->fetch($event->socid);
|
||||
$cache_thirdparty[$event->socid]=$tmpthirdparty;
|
||||
$cachethirdparties[$event->socid]=$tmpthirdparty;
|
||||
}
|
||||
$cases2[$h][$event->id]['string'].=', '.$cache_thirdparty[$event->socid]->name;
|
||||
$cases2[$h][$event->id]['string'].=', '.$cachethirdparties[$event->socid]->name;
|
||||
}
|
||||
if ($event->contactid > 0)
|
||||
{
|
||||
if (empty($cache_contact[$event->contactid]))
|
||||
if (empty($cachecontacts[$event->contactid]))
|
||||
{
|
||||
$tmpcontact=new Contact($db);
|
||||
$tmpcontact->fetch($event->contactid);
|
||||
$cache_contact[$event->contactid]=$tmpcontact;
|
||||
$cachecontacts[$event->contactid]=$tmpcontact;
|
||||
}
|
||||
$cases2[$h][$event->id]['string'].=', '.$cache_contact[$event->contactid]->getFullName($langs);
|
||||
$cases2[$h][$event->id]['string'].=', '.$cachecontacts[$event->contactid]->getFullName($langs);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1170,9 +1205,25 @@ function show_day_events2($username, $day, $month, $year, $monthshown, $style, &
|
||||
$color2='222222';
|
||||
}
|
||||
print '<table class="nobordernopadding" width="100%">';
|
||||
print '<tr><td '.($color1?'style="background: #'.$color1.';"':'').'class="'.($style1?$style1.' ':'').'onclickopenref'.($title1?' cursorpointer':'').'" ref="ref_'.$username->id.'_'.sprintf("%04d",$year).'_'.sprintf("%02d",$month).'_'.sprintf("%02d",$day).'_'.sprintf("%02d",$h).'_00_'.($ids1?$ids1:'none').'"'.($title1?' title="'.$title1.'"':'').'>';
|
||||
print '<tr><td ';
|
||||
if ($style1 == 'peruser_notbusy') print 'style="border: 1px solid #'.($color1?$color1:"888").' !important" ';
|
||||
elseif ($color1)
|
||||
{
|
||||
print ($color1?'style="background: #'.$color1.';"':'');
|
||||
}
|
||||
print 'class="';
|
||||
print ($style1?$style1.' ':'');
|
||||
print 'onclickopenref'.($title1?' cursorpointer':'').'" ref="ref_'.$username->id.'_'.sprintf("%04d",$year).'_'.sprintf("%02d",$month).'_'.sprintf("%02d",$day).'_'.sprintf("%02d",$h).'_00_'.($ids1?$ids1:'none').'"'.($title1?' title="'.$title1.'"':'').'>';
|
||||
print $string1;
|
||||
print '</td><td '.($color2?'style="background: #'.$color2.';"':'').'class="'.($style2?$style2.' ':'').'onclickopenref'.($title1?' cursorpointer':'').'" ref="ref_'.$username->id.'_'.sprintf("%04d",$year).'_'.sprintf("%02d",$month).'_'.sprintf("%02d",$day).'_'.sprintf("%02d",$h).'_30_'.($ids2?$ids2:'none').'"'.($title2?' title="'.$title2.'"':'').'>';
|
||||
print '</td><td ';
|
||||
if ($style2 == 'peruser_notbusy') print 'style="border: 1px solid #'.($color2?$color2:"888").' !important" ';
|
||||
elseif ($color2)
|
||||
{
|
||||
print ($color2?'style="background: #'.$color2.';"':'');
|
||||
}
|
||||
print 'class="';
|
||||
print ($style2?$style2.' ':'');
|
||||
print 'onclickopenref'.($title1?' cursorpointer':'').'" ref="ref_'.$username->id.'_'.sprintf("%04d",$year).'_'.sprintf("%02d",$month).'_'.sprintf("%02d",$day).'_'.sprintf("%02d",$h).'_30_'.($ids2?$ids2:'none').'"'.($title2?' title="'.$title2.'"':'').'>';
|
||||
print $string2;
|
||||
print '</td></tr>';
|
||||
print '</table>';
|
||||
|
||||
@ -58,7 +58,7 @@ function print_actions_filter($form, $canedit, $status, $year, $month, $day, $sh
|
||||
$formactions=new FormActions($db);
|
||||
|
||||
// Filters
|
||||
print '<form name="listactionsfilter" class="listactionsfilter" action="' . $_SERVER["PHP_SELF"] . '" method="get">';
|
||||
//print '<form name="listactionsfilter" class="listactionsfilter" action="' . $_SERVER["PHP_SELF"] . '" method="get">';
|
||||
print '<input type="hidden" name="token" value="' . $_SESSION ['newtoken'] . '">';
|
||||
print '<input type="hidden" name="year" value="' . $year . '">';
|
||||
print '<input type="hidden" name="month" value="' . $month . '">';
|
||||
@ -199,7 +199,7 @@ function print_actions_filter($form, $canedit, $status, $year, $month, $day, $sh
|
||||
print '</div>'; // Close fichecenter
|
||||
print '<div style="clear:both"></div>';
|
||||
|
||||
print '</form>';
|
||||
//print '</form>';
|
||||
}
|
||||
|
||||
|
||||
@ -519,9 +519,9 @@ function calendars_prepare_head($param)
|
||||
$head[$h][2] = 'cardlist';
|
||||
$h++;
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/comm/action/index.php?action=show_day'.($param?'&'.$param:'');
|
||||
$head[$h][1] = $langs->trans("ViewDay");
|
||||
$head[$h][2] = 'cardday';
|
||||
$head[$h][0] = DOL_URL_ROOT.'/comm/action/index.php?action=show_month'.($param?'&'.$param:'');
|
||||
$head[$h][1] = $langs->trans("ViewCal");
|
||||
$head[$h][2] = 'cardmonth';
|
||||
$h++;
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/comm/action/index.php?action=show_week'.($param?'&'.$param:'');
|
||||
@ -529,9 +529,9 @@ function calendars_prepare_head($param)
|
||||
$head[$h][2] = 'cardweek';
|
||||
$h++;
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/comm/action/index.php?action=show_month'.($param?'&'.$param:'');
|
||||
$head[$h][1] = $langs->trans("ViewCal");
|
||||
$head[$h][2] = 'cardmonth';
|
||||
$head[$h][0] = DOL_URL_ROOT.'/comm/action/index.php?action=show_day'.($param?'&'.$param:'');
|
||||
$head[$h][1] = $langs->trans("ViewDay");
|
||||
$head[$h][2] = 'cardday';
|
||||
$h++;
|
||||
|
||||
//if (! empty($conf->global->AGENDA_USE_EVENT_TYPE))
|
||||
|
||||
@ -3530,8 +3530,8 @@ table.cal_month td:last-child { border-right: 0px; }
|
||||
.cal_peruser { padding-top: 0 !important; padding-bottom: 0 !important; padding-<?php print $left; ?>: 1px !important; padding-<?php print $right; ?>: 1px !important; }
|
||||
.cal_impair { background: #F8F8F8; }
|
||||
.cal_today_peruser_impair { background: #F8F8F0; }
|
||||
.peruser_busy { background: #CC8888; }
|
||||
.peruser_notbusy { background: #EEDDDD; opacity: 0.5; }
|
||||
.peruser_busy { }
|
||||
.peruser_notbusy { opacity: 0.5; }
|
||||
table.cal_event { border: none; border-collapse: collapse; margin-bottom: 1px; min-height: 20px; }
|
||||
table.cal_event td { border: none; padding-<?php print $left; ?>: 2px; padding-<?php print $right; ?>: 2px; padding-top: 0px; padding-bottom: 0px; }
|
||||
table.cal_event td.cal_event { padding: 4px 4px !important; }
|
||||
|
||||
Loading…
Reference in New Issue
Block a user