2004-08-01 17:36:04 +02:00
|
|
|
<?php
|
2007-03-09 12:26:22 +01:00
|
|
|
/**
|
|
|
|
* eGroupWare - Calendar's views and widgets
|
|
|
|
*
|
|
|
|
* @link http://www.egroupware.org
|
|
|
|
* @package calendar
|
|
|
|
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
|
2015-01-19 20:32:26 +01:00
|
|
|
* @copyright (c) 2004-15 by RalfBecker-At-outdoor-training.de
|
2007-03-09 12:26:22 +01:00
|
|
|
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
|
|
|
* @version $Id$
|
|
|
|
*/
|
2004-08-01 17:36:04 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Class to generate the calendar views and the necesary widgets
|
2008-06-07 19:45:33 +02:00
|
|
|
*
|
2010-01-17 03:03:11 +01:00
|
|
|
* The listview is in a separate class calendar_uilist!
|
2004-08-01 17:36:04 +02:00
|
|
|
*
|
2007-03-09 12:26:22 +01:00
|
|
|
* The new UI, BO and SO classes have a strikt definition, in which time-zone they operate:
|
|
|
|
* UI only operates in user-time, so there have to be no conversation at all !!!
|
|
|
|
* BO's functions take and return user-time only (!), they convert internaly everything to servertime, because
|
|
|
|
* SO operates only on server-time
|
|
|
|
*
|
|
|
|
* The state of the UI elements is managed in the uical class, which all UI classes extend.
|
|
|
|
*
|
2010-01-17 03:03:11 +01:00
|
|
|
* All permanent debug messages of the calendar-code should done via the debug-message method of the calendar_bo class !!!
|
2004-08-01 17:36:04 +02:00
|
|
|
*/
|
2008-06-07 19:45:33 +02:00
|
|
|
class calendar_uiviews extends calendar_ui
|
2004-08-01 17:36:04 +02:00
|
|
|
{
|
|
|
|
var $public_functions = array(
|
2008-06-07 19:45:33 +02:00
|
|
|
'index' => True,
|
2004-08-01 17:36:04 +02:00
|
|
|
);
|
2006-06-02 21:38:08 +02:00
|
|
|
|
2004-08-01 17:36:04 +02:00
|
|
|
/**
|
2006-06-02 21:38:08 +02:00
|
|
|
* integer level or string function- or widget-name
|
2008-06-07 19:45:33 +02:00
|
|
|
*
|
2006-12-29 08:57:47 +01:00
|
|
|
* @var mixed
|
2004-08-01 17:36:04 +02:00
|
|
|
*/
|
2005-11-09 00:15:14 +01:00
|
|
|
var $debug=false;
|
2004-08-01 17:36:04 +02:00
|
|
|
|
2005-11-09 00:15:14 +01:00
|
|
|
/**
|
2006-06-02 21:38:08 +02:00
|
|
|
* extra rows above and below the workday
|
2008-06-07 19:45:33 +02:00
|
|
|
*
|
2006-12-29 08:57:47 +01:00
|
|
|
* @var int
|
2005-11-09 00:15:14 +01:00
|
|
|
*/
|
2006-10-17 22:01:08 +02:00
|
|
|
var $extraRows = 2;
|
|
|
|
|
2010-12-09 22:04:34 +01:00
|
|
|
/**
|
|
|
|
* removes n extra rows below the workday
|
|
|
|
*
|
|
|
|
* @var int
|
|
|
|
*/
|
|
|
|
var $remBotExtraRows = 0;
|
|
|
|
|
2006-10-17 22:01:08 +02:00
|
|
|
/**
|
|
|
|
* extra rows original (save original value even if it gets changed in the class)
|
2008-06-07 19:45:33 +02:00
|
|
|
*
|
2006-12-29 08:57:47 +01:00
|
|
|
* @var int
|
2006-10-17 22:01:08 +02:00
|
|
|
*/
|
|
|
|
var $extraRowsOriginal;
|
2004-08-01 17:36:04 +02:00
|
|
|
|
|
|
|
var $timeRow_width = 40;
|
|
|
|
|
2005-11-09 00:15:14 +01:00
|
|
|
/**
|
2010-07-31 09:51:52 +02:00
|
|
|
* how many rows per day get displayed, gets set by the timeGridWidget
|
2008-06-07 19:45:33 +02:00
|
|
|
*
|
2006-12-29 08:57:47 +01:00
|
|
|
* @var int
|
2005-11-09 00:15:14 +01:00
|
|
|
*/
|
|
|
|
var $rowsToDisplay;
|
|
|
|
|
|
|
|
/**
|
2010-07-31 09:51:52 +02:00
|
|
|
* height in percent of one row, gets set by the timeGridWidget
|
2008-06-07 19:45:33 +02:00
|
|
|
*
|
2006-12-29 08:57:47 +01:00
|
|
|
* @var int
|
2005-11-09 00:15:14 +01:00
|
|
|
*/
|
2006-05-14 18:50:20 +02:00
|
|
|
var $rowHeight;
|
2008-06-07 19:45:33 +02:00
|
|
|
|
2005-11-09 00:15:14 +01:00
|
|
|
/**
|
2006-06-02 21:38:08 +02:00
|
|
|
* standard params for calling bocal::search for all views, set by the constructor
|
2008-06-07 19:45:33 +02:00
|
|
|
*
|
2006-12-29 08:57:47 +01:00
|
|
|
* @var array
|
2005-11-09 00:15:14 +01:00
|
|
|
*/
|
|
|
|
var $search_params;
|
2008-06-07 19:45:33 +02:00
|
|
|
|
2006-05-31 02:33:27 +02:00
|
|
|
/**
|
2006-06-02 21:38:08 +02:00
|
|
|
* should we use a time grid, can be set for week- and month-view to false by the cal_pref no_time_grid
|
2008-06-07 19:45:33 +02:00
|
|
|
*
|
2006-12-29 08:57:47 +01:00
|
|
|
* @var boolean
|
2006-05-31 02:33:27 +02:00
|
|
|
*/
|
|
|
|
var $use_time_grid=true;
|
2015-01-19 20:32:26 +01:00
|
|
|
|
2014-11-26 14:30:13 +01:00
|
|
|
/**
|
|
|
|
* Pref value of use_time_grid preference
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
var $use_time_grid_pref = '';
|
2015-01-19 20:32:26 +01:00
|
|
|
|
2006-06-02 21:38:08 +02:00
|
|
|
/**
|
|
|
|
* Can we display the whole day in a timeGrid of the size of the workday and just scroll to workday start
|
|
|
|
*
|
2006-12-29 08:57:47 +01:00
|
|
|
* @var boolean
|
2006-06-02 21:38:08 +02:00
|
|
|
*/
|
|
|
|
var $scroll_to_wdstart=false;
|
2008-06-07 19:45:33 +02:00
|
|
|
|
2006-10-17 22:01:08 +02:00
|
|
|
/**
|
|
|
|
* counter for the current whole day event of a single day
|
|
|
|
*
|
2006-12-29 08:57:47 +01:00
|
|
|
* @var int
|
2006-10-17 22:01:08 +02:00
|
|
|
*/
|
|
|
|
var $wholeDayPosCounter=1;
|
2006-05-31 02:33:27 +02:00
|
|
|
|
2009-08-03 11:51:35 +02:00
|
|
|
/**
|
|
|
|
* Switch to disable private data and possibility to view and edit events
|
|
|
|
* in case of a public view (sitemgr)
|
|
|
|
*/
|
|
|
|
var $allowEdit = true;
|
|
|
|
|
2011-08-03 17:12:07 +02:00
|
|
|
/**
|
|
|
|
* Display holidays as event, currenlty only used in day-view
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
*/
|
2010-12-22 16:17:56 +01:00
|
|
|
var $display_holiday_event_types = array(
|
|
|
|
'bdays' => false,
|
|
|
|
'hdays' => false
|
|
|
|
);
|
|
|
|
|
2004-08-01 17:36:04 +02:00
|
|
|
/**
|
|
|
|
* Constructor
|
2005-11-09 00:15:14 +01:00
|
|
|
*
|
2014-11-05 17:13:26 +01:00
|
|
|
* @param array $set_states = null to manualy set / change one of the states, default NULL = use $_REQUEST
|
2004-08-01 17:36:04 +02:00
|
|
|
*/
|
2008-06-07 19:45:33 +02:00
|
|
|
function __construct($set_states=null)
|
2004-08-01 17:36:04 +02:00
|
|
|
{
|
2008-06-07 19:45:33 +02:00
|
|
|
parent::__construct(false,$set_states); // call the parent's constructor
|
2006-10-17 22:01:08 +02:00
|
|
|
$this->extraRowsOriginal = $this->extraRows; //save original extraRows value
|
2004-08-01 17:36:04 +02:00
|
|
|
|
2005-11-09 00:15:14 +01:00
|
|
|
$GLOBALS['egw_info']['flags']['nonavbar'] = False;
|
2016-01-26 15:47:05 +01:00
|
|
|
|
2015-10-09 21:48:28 +02:00
|
|
|
// Check for GET message (from merge)
|
|
|
|
if($_GET['msg'])
|
|
|
|
{
|
|
|
|
egw_framework::message($_GET['msg']);
|
|
|
|
unset($_GET['msg']);
|
|
|
|
}
|
2004-08-01 17:36:04 +02:00
|
|
|
// standard params for calling bocal::search for all views
|
2010-02-02 12:35:13 +01:00
|
|
|
$this->owner = str_replace('%2C',',',$this->owner);
|
2004-08-01 17:36:04 +02:00
|
|
|
$this->search_params = array(
|
|
|
|
'start' => $this->date,
|
2012-02-07 15:10:34 +01:00
|
|
|
'cat_id' => $this->cat_id ? (is_array($this->cat_id)?$this->cat_id:explode(',',$this->cat_id)) : 0,
|
2006-03-03 19:51:46 +01:00
|
|
|
'users' => explode(',',$this->owner),
|
2004-08-01 17:36:04 +02:00
|
|
|
'filter' => $this->filter,
|
|
|
|
'daywise' => True,
|
2015-01-19 20:32:26 +01:00
|
|
|
'use_so_events' => $this->test === 'true',
|
2004-08-01 17:36:04 +02:00
|
|
|
);
|
|
|
|
$this->holidays = $this->bo->read_holidays($this->year);
|
2013-01-31 15:16:48 +01:00
|
|
|
|
2006-03-03 19:51:46 +01:00
|
|
|
$this->check_owners_access();
|
2015-01-19 20:32:26 +01:00
|
|
|
|
2014-11-26 14:30:13 +01:00
|
|
|
//ATM: Forces use_time_grid preference to use all views by ignoring the preference value
|
|
|
|
//@TODO: the whole use_time_grid preference should be removed (including dependent vars)
|
|
|
|
// after we decided that is not neccessary to have it at all
|
|
|
|
$this->use_time_grid_pref = 'all'; //$this->cal_prefs['use_time_grid'];
|
2004-08-01 17:36:04 +02:00
|
|
|
}
|
2008-06-07 19:45:33 +02:00
|
|
|
|
2011-02-15 21:35:46 +01:00
|
|
|
|
2011-01-05 22:49:55 +01:00
|
|
|
/**
|
|
|
|
* Calculate iso8601 week-number, which is defined for Monday as first day of week only
|
|
|
|
*
|
2011-01-05 23:26:34 +01:00
|
|
|
* We addjust the day, if user prefs want a different week-start-day
|
|
|
|
*
|
|
|
|
* @param int|string|DateTime $time
|
2011-01-05 22:49:55 +01:00
|
|
|
* @return string
|
|
|
|
*/
|
2011-01-05 23:26:34 +01:00
|
|
|
public function week_number($time)
|
2011-01-05 22:49:55 +01:00
|
|
|
{
|
2011-01-05 23:26:34 +01:00
|
|
|
if (!is_a($time,'DateTime')) $time = new egw_time($time);
|
|
|
|
|
|
|
|
// if week does not start Monday and $time is Sunday --> add one day
|
|
|
|
if ($this->cal_prefs['weekdaystarts'] != 'Monday' && !($wday = $time->format('w')))
|
|
|
|
{
|
|
|
|
$time->modify('+1day');
|
|
|
|
}
|
|
|
|
// if week does start Saturday and $time is Saturday --> add two days
|
|
|
|
elseif ($this->cal_prefs['weekdaystarts'] == 'Saturday' && $wday == 6)
|
2011-01-05 22:49:55 +01:00
|
|
|
{
|
2011-01-05 23:26:34 +01:00
|
|
|
$time->modify('+2days');
|
2011-01-05 22:49:55 +01:00
|
|
|
}
|
|
|
|
return $time->format('W');
|
|
|
|
}
|
|
|
|
|
2005-11-09 00:15:14 +01:00
|
|
|
/**
|
2016-03-14 20:36:22 +01:00
|
|
|
* Load all views used by calendar, client side switches between them as needed
|
2005-11-09 00:15:14 +01:00
|
|
|
*/
|
2015-07-01 00:26:59 +02:00
|
|
|
function index($content=array())
|
2005-11-09 00:15:14 +01:00
|
|
|
{
|
2015-06-25 19:44:28 +02:00
|
|
|
if($content['merge'])
|
|
|
|
{
|
|
|
|
// View from sidebox is JSON encoded
|
|
|
|
$this->manage_states(array_merge($content,json_decode($content['view'],true)));
|
|
|
|
if($content['first'])
|
|
|
|
{
|
|
|
|
$this->first = egw_time::to($content['first'],'ts');
|
|
|
|
}
|
|
|
|
if($content['last'])
|
|
|
|
{
|
|
|
|
$this->last = egw_time::to($content['last'],'ts');
|
|
|
|
}
|
|
|
|
$_GET['merge'] = $content['merge'];
|
|
|
|
$this->merge();
|
|
|
|
return;
|
|
|
|
}
|
2005-11-09 00:15:14 +01:00
|
|
|
|
|
|
|
// handle views in other files
|
2015-06-10 23:51:28 +02:00
|
|
|
if (!isset($this->public_functions[$this->view]) && $this->view !== 'listview')
|
2005-11-09 00:15:14 +01:00
|
|
|
{
|
2015-06-15 23:38:03 +02:00
|
|
|
$this->view = 'week';
|
2005-11-09 00:15:14 +01:00
|
|
|
}
|
|
|
|
// get manual to load the right page
|
|
|
|
$GLOBALS['egw_info']['flags']['params']['manual'] = array('page' => 'ManualCalendar'.ucfirst($this->view));
|
2008-06-07 19:45:33 +02:00
|
|
|
|
2015-06-10 23:51:28 +02:00
|
|
|
// Sidebox & iframe for old views
|
2015-08-12 00:30:50 +02:00
|
|
|
if(in_array($this->view,array('year')) && $_GET['view'])
|
2015-06-10 23:51:28 +02:00
|
|
|
{
|
2015-06-15 23:38:03 +02:00
|
|
|
$GLOBALS['egw_info']['flags']['nonavbar'] = true;
|
|
|
|
$this->manage_states($_GET);
|
2015-06-10 23:51:28 +02:00
|
|
|
$old_calendar = $this->{$this->view}();
|
2015-06-15 23:38:03 +02:00
|
|
|
return;
|
2015-06-10 23:51:28 +02:00
|
|
|
}
|
|
|
|
|
2016-01-06 19:24:45 +01:00
|
|
|
// Toolbar
|
|
|
|
$tmpl = new etemplate_new('calendar.toolbar');
|
|
|
|
$tmpl->setElementAttribute('toolbar', 'actions', $this->getToolbarActions($content));
|
2016-02-10 18:03:42 +01:00
|
|
|
// Adjust toolbar for mobile
|
|
|
|
if(html::$ua_mobile){
|
|
|
|
$tmpl->setElementAttribute('toolbar','class', 'et2_head_toolbar');
|
|
|
|
$tmpl->setElementAttribute('toolbar','view_range', '3');
|
|
|
|
}
|
2016-01-06 19:24:45 +01:00
|
|
|
$tmpl->exec('calendar_uiviews::index',array());
|
|
|
|
|
2015-06-10 23:51:28 +02:00
|
|
|
// Load the different views once, we'll switch between them on the client side
|
|
|
|
$tmpl = new etemplate_new('calendar.todo');
|
|
|
|
$label = '';
|
|
|
|
$tmpl->exec('calendar_uiviews::index',array('todos'=>$this->get_todos($label), 'label' => $label));
|
|
|
|
|
|
|
|
// Actually, this takes care of most of it...
|
|
|
|
$this->week();
|
2015-07-03 11:10:01 +02:00
|
|
|
|
2015-06-25 19:44:28 +02:00
|
|
|
$tmpl = new etemplate_new('calendar.planner');
|
|
|
|
// Get the actions
|
|
|
|
$tmpl->setElementAttribute('planner','actions',$this->get_actions());
|
|
|
|
$tmpl->exec('calendar_uiviews::index',array());
|
2015-06-10 23:51:28 +02:00
|
|
|
|
|
|
|
// List view in a separate file
|
|
|
|
$list_ui = new calendar_uilist();
|
|
|
|
$list_ui->listview();
|
2005-11-09 00:15:14 +01:00
|
|
|
}
|
2008-06-07 19:45:33 +02:00
|
|
|
|
2016-01-06 19:24:45 +01:00
|
|
|
/**
|
|
|
|
* Generate the calendar toolbar actions
|
|
|
|
*
|
|
|
|
* @param Array $content
|
|
|
|
*/
|
|
|
|
protected function getToolbarActions($content = array())
|
|
|
|
{
|
|
|
|
$group = 0;
|
|
|
|
$actions = array(
|
|
|
|
'add' => array(
|
|
|
|
'caption' => 'Add',
|
2016-01-21 19:41:54 +01:00
|
|
|
'icon' => 'add',
|
2016-01-06 19:24:45 +01:00
|
|
|
'group' => ++$group,
|
2016-01-06 21:37:29 +01:00
|
|
|
'onExecute' => 'javaScript:app.calendar.toolbar_action',
|
2016-01-06 19:24:45 +01:00
|
|
|
'hint' => 'Add',
|
|
|
|
'toolbarDefault' => true,
|
|
|
|
),
|
|
|
|
'day_view' => array(
|
|
|
|
'caption' => 'Day view',
|
|
|
|
'icon' => 'day',
|
|
|
|
'group' => ++$group,
|
|
|
|
'onExecute' => 'javaScript:app.calendar.toolbar_action',
|
|
|
|
'hint' => 'Day view',
|
|
|
|
'toolbarDefault' => true,
|
|
|
|
'data' => array('state' => array('view' => 'day'))
|
|
|
|
),
|
|
|
|
'4day_view' => array(
|
|
|
|
'caption' => 'Four days view',
|
2016-01-26 15:47:05 +01:00
|
|
|
'icon' => 'cal4',
|
2016-01-06 19:24:45 +01:00
|
|
|
'group' => $group,
|
|
|
|
'onExecute' => 'javaScript:app.calendar.toolbar_action',
|
|
|
|
'hint' => 'Four days view',
|
|
|
|
'toolbarDefault' => false,
|
|
|
|
'data' => array('state' => array('view' => 'day4'))
|
|
|
|
),
|
|
|
|
'week_view' => array(
|
|
|
|
'caption' => 'Week view',
|
|
|
|
'icon' => 'week',
|
|
|
|
'group' => $group,
|
|
|
|
'onExecute' => 'javaScript:app.calendar.toolbar_action',
|
|
|
|
'hint' => 'Week view',
|
|
|
|
'toolbarDefault' => true,
|
|
|
|
'data' => array('state' => array('view' => 'week'))
|
|
|
|
),
|
|
|
|
'weekN_view' => array(
|
|
|
|
'caption' => 'Multiple week view',
|
|
|
|
'icon' => 'multiweek',
|
|
|
|
'group' => $group,
|
|
|
|
'onExecute' => 'javaScript:app.calendar.toolbar_action',
|
|
|
|
'hint' => 'Multiple week view',
|
|
|
|
'toolbarDefault' => true,
|
|
|
|
'data' => array('state' => array('view' => 'weekN'))
|
|
|
|
),
|
|
|
|
'month_view' => array(
|
|
|
|
'caption' => 'Month view',
|
|
|
|
'icon' => 'month',
|
|
|
|
'group' => $group,
|
|
|
|
'onExecute' => 'javaScript:app.calendar.toolbar_action',
|
|
|
|
'hint' => 'Month view',
|
|
|
|
'toolbarDefault' => false,
|
|
|
|
'data' => array('state' => array('view' => 'month'))
|
|
|
|
),
|
|
|
|
'planner_category' => array(
|
|
|
|
'caption' => 'Planner by category',
|
|
|
|
'icon' => 'planner',
|
|
|
|
'group' => $group,
|
|
|
|
'onExecute' => 'javaScript:app.calendar.toolbar_action',
|
|
|
|
'hint' => 'Planner by category',
|
|
|
|
'toolbarDefault' => false,
|
|
|
|
'data' => array('state' => array('view' => 'planner', 'sortby' => 'category')),
|
|
|
|
),
|
|
|
|
'planner_user' => array(
|
|
|
|
'caption' => 'Planner by user',
|
|
|
|
'icon' => 'planner',
|
|
|
|
'group' => $group,
|
|
|
|
'onExecute' => 'javaScript:app.calendar.toolbar_action',
|
|
|
|
'hint' => 'Planner by user',
|
|
|
|
'toolbarDefault' => false,
|
|
|
|
'data' => array('state' => array('view' => 'planner', 'sortby' => 'user')),
|
|
|
|
),
|
|
|
|
'planner_month' => array(
|
|
|
|
'caption' => 'Yearly planner',
|
|
|
|
'icon' => 'year',
|
|
|
|
'group' => $group,
|
|
|
|
'onExecute' => 'javaScript:app.calendar.toolbar_action',
|
|
|
|
'hint' => 'Yearly planner',
|
|
|
|
'toolbarDefault' => false,
|
|
|
|
'data' => array('state' => array('view' => 'planner', 'sortby' => 'month')),
|
|
|
|
),
|
|
|
|
'list' => array(
|
|
|
|
'caption' => 'Listview',
|
|
|
|
'icon' => 'list',
|
|
|
|
'group' => $group,
|
|
|
|
'onExecute' => 'javaScript:app.calendar.toolbar_action',
|
|
|
|
'hint' => 'Listview',
|
|
|
|
'toolbarDefault' => true,
|
|
|
|
'data' => array('state' => array('view' => 'listview')),
|
|
|
|
),
|
|
|
|
'weekend' => array(
|
|
|
|
'caption' => 'Weekend',
|
|
|
|
'icon' => 'weekend',
|
|
|
|
'checkbox' => true,
|
|
|
|
'checked' => $this->cal_prefs['saved_states']['weekend'],
|
|
|
|
'group' => $group,
|
|
|
|
'onExecute' => 'javaScript:app.calendar.toolbar_action',
|
|
|
|
'hint' => 'Toggle weekend',
|
|
|
|
'toolbarDefault' => false,
|
2016-01-09 01:54:27 +01:00
|
|
|
'data' => array('toggle_off' => '5', 'toggle_on' => '7')
|
2016-01-06 19:24:45 +01:00
|
|
|
),
|
|
|
|
'previous' => array(
|
|
|
|
'caption' => 'Previous',
|
|
|
|
'icon' => 'previous',
|
|
|
|
'group' => ++$group,
|
|
|
|
'onExecute' => 'javaScript:app.calendar.toolbar_action',
|
|
|
|
'hint' => 'Previous',
|
|
|
|
'toolbarDefault' => true,
|
|
|
|
),
|
2016-01-21 19:41:54 +01:00
|
|
|
'today' => array(
|
|
|
|
'caption' => 'Today',
|
|
|
|
'group' => $group,
|
|
|
|
'onExecute' => 'javaScript:app.calendar.toolbar_action',
|
|
|
|
'hint' => 'Today',
|
|
|
|
'toolbarDefault' => true,
|
|
|
|
),
|
2016-01-06 19:24:45 +01:00
|
|
|
'next' => array(
|
|
|
|
'caption' => 'Next',
|
|
|
|
'icon' => 'next',
|
|
|
|
'group' => $group,
|
|
|
|
'onExecute' => 'javaScript:app.calendar.toolbar_action',
|
|
|
|
'hint' => 'Next',
|
|
|
|
'toolbarDefault' => true,
|
|
|
|
),
|
|
|
|
);
|
|
|
|
|
|
|
|
return $actions;
|
|
|
|
}
|
|
|
|
|
2005-11-09 00:15:14 +01:00
|
|
|
/**
|
|
|
|
* Displays the planner view
|
|
|
|
*
|
2015-08-05 23:24:07 +02:00
|
|
|
* @param boolean|etemplate_new $home = false if etemplate return content suitable for home-page
|
2005-11-09 00:15:14 +01:00
|
|
|
*/
|
2015-08-05 23:24:07 +02:00
|
|
|
function &planner($content = array(), $home=false)
|
2005-11-09 00:15:14 +01:00
|
|
|
{
|
2010-01-15 04:53:12 +01:00
|
|
|
if ($this->sortby == 'month') // yearly planner with month rows
|
|
|
|
{
|
|
|
|
$this->first = $this->bo->date2array($this->date);
|
|
|
|
$this->first['day'] = 1;
|
|
|
|
unset($this->first['raw']);
|
|
|
|
$this->last = $this->first;
|
|
|
|
$this->last['year']++;
|
|
|
|
$this->last = $this->bo->date2ts($this->last)-1;
|
|
|
|
}
|
2016-02-03 19:27:52 +01:00
|
|
|
elseif (!$this->planner_view || $this->planner_view == 'month') // planner monthview
|
2005-11-09 00:15:14 +01:00
|
|
|
{
|
|
|
|
if ($this->day < 15) // show one complete month
|
|
|
|
{
|
|
|
|
$this->_week_align_month($this->first,$this->last);
|
|
|
|
}
|
|
|
|
else // show 2 half month
|
|
|
|
{
|
|
|
|
$this->_week_align_month($this->first,$this->last,15);
|
|
|
|
}
|
|
|
|
}
|
2016-02-03 19:27:52 +01:00
|
|
|
elseif ($this->planner_view == 'week' || $this->planner_view == 'weekN') // weeekview
|
2005-11-09 00:15:14 +01:00
|
|
|
{
|
|
|
|
$this->first = $this->datetime->get_weekday_start($this->year,$this->month,$this->day);
|
|
|
|
$this->last = $this->bo->date2array($this->first);
|
2016-02-03 19:27:52 +01:00
|
|
|
$this->last['day'] += ($this->planner_view == 'week' ? 7 : 7 * $this->cal_prefs['multiple_weeks'])-1;
|
2005-11-09 00:15:14 +01:00
|
|
|
$this->last['hour'] = 23; $this->last['minute'] = $this->last['sec'] = 59;
|
|
|
|
unset($this->last['raw']);
|
|
|
|
$this->last = $this->bo->date2ts($this->last);
|
|
|
|
}
|
|
|
|
else // dayview
|
|
|
|
{
|
|
|
|
$this->first = $this->bo->date2ts($this->date);
|
|
|
|
$this->last = $this->bo->date2array($this->first);
|
2016-02-03 19:27:52 +01:00
|
|
|
$this->last['day'] += 0;
|
2005-11-09 00:15:14 +01:00
|
|
|
$this->last['hour'] = 23; $this->last['minute'] = $this->last['sec'] = 59;
|
|
|
|
unset($this->last['raw']);
|
|
|
|
$this->last = $this->bo->date2ts($this->last);
|
|
|
|
}
|
2008-06-07 19:45:33 +02:00
|
|
|
|
2011-02-15 21:35:46 +01:00
|
|
|
$merge = $this->merge();
|
2011-06-22 17:34:00 +02:00
|
|
|
if($merge)
|
|
|
|
{
|
|
|
|
egw::redirect_link('/index.php',array(
|
|
|
|
'menuaction' => 'calendar.calendar_uiviews.index',
|
|
|
|
'msg' => $merge,
|
|
|
|
));
|
|
|
|
}
|
2011-02-15 21:35:46 +01:00
|
|
|
|
2005-11-09 00:15:14 +01:00
|
|
|
$search_params = $this->search_params;
|
|
|
|
$search_params['daywise'] = false;
|
|
|
|
$search_params['start'] = $this->first;
|
|
|
|
$search_params['end'] = $this->last;
|
2005-11-23 15:21:20 +01:00
|
|
|
$search_params['enum_groups'] = $this->sortby == 'user';
|
2015-08-05 23:24:07 +02:00
|
|
|
$content['planner'] = $this->bo->search($search_params);
|
|
|
|
foreach($content['planner'] as &$event)
|
|
|
|
{
|
|
|
|
$this->to_client($event);
|
|
|
|
}
|
2005-11-09 00:15:14 +01:00
|
|
|
|
|
|
|
if ($this->debug > 0) $this->bo->debug_message('uiviews::planner() date=%1: first=%2, last=%3',False,$this->date,$this->bo->date2string($this->first),$this->bo->date2string($this->last));
|
|
|
|
|
2015-08-05 23:24:07 +02:00
|
|
|
$tmpl = $home ? $home :new etemplate_new('calendar.planner');
|
2010-04-15 20:23:02 +02:00
|
|
|
|
2015-08-05 23:24:07 +02:00
|
|
|
$tmpl->setElementAttribute('planner','start_date', egw_time::to($this->first, egw_time::ET2));
|
|
|
|
$tmpl->setElementAttribute('planner','end_date', egw_time::to($this->last, egw_time::ET2));
|
2016-02-23 22:47:33 +01:00
|
|
|
$tmpl->setElementAttribute('planner','owner', $search_params['users']);
|
2015-08-05 23:24:07 +02:00
|
|
|
$tmpl->setElementAttribute('planner','group_by', $this->sortby);
|
|
|
|
// Get the actions
|
|
|
|
$tmpl->setElementAttribute('planner','actions',$this->get_actions());
|
2008-06-07 19:45:33 +02:00
|
|
|
|
2015-08-05 23:24:07 +02:00
|
|
|
$tmpl->exec(__METHOD__, $content);
|
2005-11-09 00:15:14 +01:00
|
|
|
}
|
2008-06-07 19:45:33 +02:00
|
|
|
|
2004-08-01 17:36:04 +02:00
|
|
|
/**
|
|
|
|
* Displays the monthview or a multiple week-view
|
2005-11-09 00:15:14 +01:00
|
|
|
*
|
2014-11-05 17:13:26 +01:00
|
|
|
* @param int $weeks = 0 number of weeks to show, if 0 (default) all weeks of one month are shown
|
2016-02-22 23:45:48 +01:00
|
|
|
* @param boolean|etemplate2 $home = false if not false return content suitable for home-page
|
2004-08-01 17:36:04 +02:00
|
|
|
*/
|
2005-11-09 00:15:14 +01:00
|
|
|
function &month($weeks=0,$home=false)
|
2004-08-01 17:36:04 +02:00
|
|
|
{
|
|
|
|
if ($this->debug > 0) $this->bo->debug_message('uiviews::month(weeks=%1) date=%2',True,$weeks,$this->date);
|
|
|
|
|
2016-02-22 23:45:48 +01:00
|
|
|
if (!$home)
|
|
|
|
{
|
|
|
|
trigger_error(__METHOD__ .' only used by home app', E_USER_DEPRECATED);
|
|
|
|
return;
|
|
|
|
}
|
2014-10-20 11:14:24 +02:00
|
|
|
|
2016-02-22 23:45:48 +01:00
|
|
|
$this->use_time_grid = !$this->use_time_grid_pref || $this->use_time_grid_pref == 'all'; // all views
|
|
|
|
$granularity = 0;
|
2011-02-15 21:35:46 +01:00
|
|
|
if($weeks)
|
|
|
|
{
|
2016-02-22 23:45:48 +01:00
|
|
|
$granularity = ($this->cal_prefs['interval'] ? (int)$this->cal_prefs['interval'] : 30);
|
|
|
|
|
|
|
|
$list = $this->cal_prefs['use_time_grid'];
|
|
|
|
if(!is_array($list))
|
2011-02-15 21:35:46 +01:00
|
|
|
{
|
2016-02-22 23:45:48 +01:00
|
|
|
$list = explode(',',$list);
|
|
|
|
}
|
|
|
|
if(is_array($list))
|
|
|
|
{
|
|
|
|
$granularity = in_array('weekN',$list) ? 0 : $granularity;
|
2011-02-15 21:35:46 +01:00
|
|
|
}
|
2011-06-22 17:34:00 +02:00
|
|
|
}
|
2016-02-22 23:45:48 +01:00
|
|
|
$content = array('view' => array());
|
2016-03-06 15:58:36 +01:00
|
|
|
|
2004-08-01 17:36:04 +02:00
|
|
|
if ($weeks)
|
|
|
|
{
|
2008-03-20 09:54:18 +01:00
|
|
|
$this->first = $this->datetime->get_weekday_start($this->year,$this->month,$this->day);
|
|
|
|
$this->last = strtotime("+$weeks weeks",$this->first) - 1;
|
2014-02-25 10:41:08 +01:00
|
|
|
$weekNavH = "$weeks weeks";
|
2015-02-18 09:46:43 +01:00
|
|
|
$navHeader = lang('Week').' '.$this->week_number($this->first).' - '.$this->week_number($this->last).': '.
|
|
|
|
$this->bo->long_date($this->first,$this->last);
|
2004-08-01 17:36:04 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-11-09 00:15:14 +01:00
|
|
|
$this->_week_align_month($this->first,$this->last);
|
2014-02-25 10:41:08 +01:00
|
|
|
$weekNavH = "1 month";
|
2015-02-18 09:46:43 +01:00
|
|
|
$navHeader = lang(adodb_date('F',$this->bo->date2ts($this->date))).' '.$this->year;
|
2004-08-01 17:36:04 +02:00
|
|
|
}
|
2005-11-09 00:15:14 +01:00
|
|
|
if ($this->debug > 0) $this->bo->debug_message('uiviews::month(%1) date=%2: first=%3, last=%4',False,$weeks,$this->date,$this->bo->date2string($this->first),$this->bo->date2string($this->last));
|
2004-08-01 17:36:04 +02:00
|
|
|
|
2016-02-22 23:45:48 +01:00
|
|
|
// Loop through, using egw_time to handle DST
|
|
|
|
$week = 0;
|
2016-03-18 16:49:11 +01:00
|
|
|
$week_start = new EGroupware\Api\DateTime($this->first);
|
2016-02-22 23:45:48 +01:00
|
|
|
$week_start->setTime(0,0,0);
|
|
|
|
$week_end = new egw_time($week_start);
|
|
|
|
$week_end->add(new DateInterval('P6DT23H59M59S'));
|
2016-03-18 16:49:11 +01:00
|
|
|
$last = new EGroupware\Api\DateTime($this->last);
|
2016-02-22 23:45:48 +01:00
|
|
|
for ($week_start; $week_start < $last; $week_start->add('1 week'), $week_end->add('1 week'))
|
2005-11-09 00:15:14 +01:00
|
|
|
{
|
2016-02-22 23:45:48 +01:00
|
|
|
$search_params = $this->search_params;
|
|
|
|
$search_params['start'] = $week_start->format('ts');
|
|
|
|
$search_params['end'] = $week_end->format('ts');
|
2016-03-06 15:58:36 +01:00
|
|
|
|
2016-02-23 22:29:13 +01:00
|
|
|
$content['view'][] = (array)$this->tagWholeDayOnTop($this->bo->search($search_params)) +
|
|
|
|
array(
|
|
|
|
'id' => $week_start->format('Ymd')
|
|
|
|
);
|
2016-02-22 23:45:48 +01:00
|
|
|
$home->setElementAttribute("view[$week]",'onchange',false);
|
|
|
|
$home->setElementAttribute("view[$week]",'granularity',$granularity);
|
|
|
|
$home->setElementAttribute("view[$week]",'show_weekend', $this->search_params['weekend']);
|
|
|
|
$week++;
|
2004-08-01 17:36:04 +02:00
|
|
|
}
|
2016-02-23 22:29:13 +01:00
|
|
|
|
|
|
|
// Get the actions
|
|
|
|
$home->setElementAttribute('view','actions',$this->get_actions());
|
2016-03-06 15:58:36 +01:00
|
|
|
|
2016-02-22 23:45:48 +01:00
|
|
|
$home->exec(__METHOD__, $content);
|
2005-11-09 00:15:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* get start and end of a month aligned to full weeks
|
|
|
|
*
|
|
|
|
* @param int &$first timestamp 0h of first day of week containing the first of the current month
|
|
|
|
* @param int &$last timestamp 23:59:59 of last day of week containg the last day of the current month
|
2014-11-05 17:13:26 +01:00
|
|
|
* @param int $day = 1 should the alignment be based on the 1. of the month or an other date, eg. the 15.
|
2005-11-09 00:15:14 +01:00
|
|
|
*/
|
|
|
|
function _week_align_month(&$first,&$last,$day=1)
|
|
|
|
{
|
|
|
|
$first = $this->datetime->get_weekday_start($this->year,$this->month,$this->day=$day);
|
|
|
|
if ($day == 1)
|
|
|
|
{
|
|
|
|
$last = $this->datetime->get_weekday_start($this->year,$this->month,
|
|
|
|
$this->datetime->days_in_month($this->month,$this->year));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$last = $this->datetime->get_weekday_start($this->year,$this->month+1,$day);
|
2008-06-07 19:45:33 +02:00
|
|
|
}
|
2005-11-09 00:15:14 +01:00
|
|
|
// now we need to calculate the end of the last day of that week
|
|
|
|
// as simple $last += WEEK_s - 1; does NOT work, if daylight saving changes in that week!!!
|
|
|
|
$last = $this->bo->date2array($last);
|
2008-06-07 19:45:33 +02:00
|
|
|
$last['day'] += 6;
|
|
|
|
$last['hour'] = 23;
|
2005-11-09 00:15:14 +01:00
|
|
|
$last['min'] = $last['sec'] = 59;
|
|
|
|
unset($last['raw']); // otherwise date2ts does not calc raw new, but uses it
|
|
|
|
$last = $this->bo->date2ts($last);
|
2004-08-01 17:36:04 +02:00
|
|
|
}
|
2008-06-07 19:45:33 +02:00
|
|
|
|
2012-01-05 05:12:13 +01:00
|
|
|
/**
|
|
|
|
* Display a button to close one of multiple calendars shown
|
|
|
|
*
|
|
|
|
* Necessare to eg. close the calendar of a contact
|
|
|
|
*
|
|
|
|
* @param string $uid calendar to close
|
|
|
|
*/
|
|
|
|
private function close_button($uid)
|
|
|
|
{
|
2012-01-09 10:49:20 +01:00
|
|
|
return html::a_href(html::image('phpgwapi', 'close.button', 'Close','style="width: 12px; padding-top: 1px;"'), array(
|
2012-01-05 05:12:13 +01:00
|
|
|
'menuaction' => 'calendar.calendar_uiviews.index',
|
|
|
|
'close' => $uid,
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
2004-08-01 17:36:04 +02:00
|
|
|
/**
|
|
|
|
* Displays the weekview, with 5 or 7 days
|
2004-08-31 11:40:09 +02:00
|
|
|
*
|
2014-11-05 17:13:26 +01:00
|
|
|
* @param int $days = 0 number of days to show, if 0 (default) the value from the URL or the prefs is used
|
2016-02-22 23:45:48 +01:00
|
|
|
* @param boolean|etemplate2 $home = false if not false return content suitable for home-page
|
2004-08-01 17:36:04 +02:00
|
|
|
*/
|
2005-11-09 00:15:14 +01:00
|
|
|
function week($days=0,$home=false)
|
2004-08-01 17:36:04 +02:00
|
|
|
{
|
|
|
|
if (!$days)
|
|
|
|
{
|
|
|
|
$days = isset($_GET['days']) ? $_GET['days'] : $this->cal_prefs['days_in_weekview'];
|
|
|
|
if ($days != 5) $days = 7;
|
|
|
|
if ($days != $this->cal_prefs['days_in_weekview']) // save the preference
|
|
|
|
{
|
2005-11-09 00:15:14 +01:00
|
|
|
$GLOBALS['egw']->preferences->add('calendar','days_in_weekview',$days);
|
|
|
|
$GLOBALS['egw']->preferences->save_repository();
|
2004-08-01 17:36:04 +02:00
|
|
|
$this->cal_prefs['days_in_weekview'] = $days;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ($this->debug > 0) $this->bo->debug_message('uiviews::week(days=%1) date=%2',True,$days,$this->date);
|
|
|
|
|
2016-01-27 18:48:33 +01:00
|
|
|
if ($days <= 4) // next 4 days view
|
2006-06-02 21:38:08 +02:00
|
|
|
{
|
|
|
|
$wd_start = $this->first = $this->bo->date2ts($this->date);
|
2008-03-20 09:54:18 +01:00
|
|
|
$this->last = strtotime("+$days days",$this->first) - 1;
|
2016-02-22 23:45:48 +01:00
|
|
|
$view = $days == 1 ? 'day' : 'day4';
|
2014-10-20 11:14:24 +02:00
|
|
|
}
|
2006-06-02 21:38:08 +02:00
|
|
|
else
|
2004-08-01 17:36:04 +02:00
|
|
|
{
|
2006-06-02 21:38:08 +02:00
|
|
|
$wd_start = $this->first = $this->datetime->get_weekday_start($this->year,$this->month,$this->day);
|
2015-08-05 23:24:07 +02:00
|
|
|
if ($days <= 5) // no weekend-days
|
2004-08-01 17:36:04 +02:00
|
|
|
{
|
2006-06-02 21:38:08 +02:00
|
|
|
switch($this->cal_prefs['weekdaystarts'])
|
|
|
|
{
|
|
|
|
case 'Saturday':
|
2008-03-20 09:54:18 +01:00
|
|
|
$this->first = strtotime("+2 days",$this->first);
|
|
|
|
break;
|
2006-06-02 21:38:08 +02:00
|
|
|
case 'Sunday':
|
2008-03-20 09:54:18 +01:00
|
|
|
$this->first = strtotime("+1 day",$this->first);
|
2006-06-02 21:38:08 +02:00
|
|
|
break;
|
|
|
|
}
|
2004-08-01 17:36:04 +02:00
|
|
|
}
|
2008-06-07 19:45:33 +02:00
|
|
|
$this->last = strtotime("+$days days",$this->first) - 1;
|
2016-02-22 23:45:48 +01:00
|
|
|
$view = 'week';
|
|
|
|
}
|
|
|
|
|
|
|
|
$granularity = ($this->cal_prefs['interval'] ? (int)$this->cal_prefs['interval'] : 30);
|
|
|
|
|
|
|
|
$list = $this->cal_prefs['use_time_grid'];
|
|
|
|
if(!is_array($list))
|
|
|
|
{
|
|
|
|
$list = explode(',',$list);
|
|
|
|
}
|
|
|
|
if(is_array($list))
|
|
|
|
{
|
|
|
|
$granularity = in_array($view,$list) ? 0 : $granularity;
|
2011-06-22 17:34:00 +02:00
|
|
|
}
|
2011-02-15 21:35:46 +01:00
|
|
|
|
2004-09-01 15:54:57 +02:00
|
|
|
$search_params = array(
|
2005-11-09 00:15:14 +01:00
|
|
|
'start' => $this->first,
|
|
|
|
'end' => $this->last,
|
2004-09-01 15:54:57 +02:00
|
|
|
) + $this->search_params;
|
|
|
|
|
2004-08-31 11:40:09 +02:00
|
|
|
$users = $this->search_params['users'];
|
|
|
|
if (!is_array($users)) $users = array($users);
|
2008-06-07 19:45:33 +02:00
|
|
|
|
2015-05-06 21:03:45 +02:00
|
|
|
$content = array('view' => array());
|
2006-12-15 21:05:47 +01:00
|
|
|
|
2016-01-05 21:43:19 +01:00
|
|
|
if(!$home)
|
2015-05-06 21:03:45 +02:00
|
|
|
{
|
2016-01-05 21:43:19 +01:00
|
|
|
// Fill with the minimum needed 'weeks'
|
|
|
|
$min = max(
|
|
|
|
6, // Some months need 6 weeks for full display
|
|
|
|
$this->cal_prefs['multiple_weeks'], // WeekN view
|
|
|
|
$this->cal_prefs['week_consolidate'] // We collapse after this many users
|
|
|
|
);
|
|
|
|
for($i = 0; $i < $min; $i++)
|
|
|
|
{
|
|
|
|
$content['view'][] = array();
|
|
|
|
}
|
2015-05-06 21:03:45 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-01-05 21:43:19 +01:00
|
|
|
// Always do 7 days for a week so scrolling works properly
|
|
|
|
$this->last = ($days == 4 ? $this->last : $search_params['end'] = strtotime("+$days days",$this->first) - 1);
|
2016-01-27 18:35:25 +01:00
|
|
|
if (count($users) == 1 || count($users) >= $this->cal_prefs['week_consolidate'] ||// for more then X users, show all in one row
|
|
|
|
$days == 1 // Showing just 1 day
|
|
|
|
)
|
2015-05-06 21:03:45 +02:00
|
|
|
{
|
2016-01-05 21:43:19 +01:00
|
|
|
$content['view'][] = (array)$this->tagWholeDayOnTop($this->bo->search($search_params)) +
|
|
|
|
array('owner' => $users);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
foreach($this->_get_planner_users(false) as $uid => $label)
|
|
|
|
{
|
|
|
|
$search_params['users'] = $uid;
|
|
|
|
$content['view'][] = $this->tagWholeDayOnTop($this->bo->search($search_params))
|
|
|
|
+ array('owner' => $uid);
|
|
|
|
}
|
2015-05-06 21:03:45 +02:00
|
|
|
}
|
|
|
|
}
|
2015-06-10 23:51:28 +02:00
|
|
|
$tmpl = $home ? $home :new etemplate_new('calendar.view');
|
2016-02-22 23:45:48 +01:00
|
|
|
foreach($content['view'] as $index => $week)
|
|
|
|
{
|
|
|
|
$tmpl->setElementAttribute("view[$index]",'granularity',$granularity);
|
|
|
|
$tmpl->setElementAttribute("view[$index]",'show_weekend',$this->search_params['weekend']);
|
|
|
|
}
|
2015-06-10 23:51:28 +02:00
|
|
|
|
|
|
|
// Get the actions
|
|
|
|
$tmpl->setElementAttribute('view','actions',$this->get_actions());
|
2015-07-03 11:10:01 +02:00
|
|
|
|
2015-05-06 21:03:45 +02:00
|
|
|
$tmpl->exec(__METHOD__, $content);
|
2004-08-01 17:36:04 +02:00
|
|
|
}
|
|
|
|
|
2015-06-10 23:51:28 +02:00
|
|
|
/**
|
|
|
|
* Get todos via AJAX
|
|
|
|
*/
|
|
|
|
public static function ajax_get_todos($date, $owner)
|
|
|
|
{
|
|
|
|
$date = egw_time::to($date, 'array');
|
|
|
|
$ui = new calendar_uiviews();
|
|
|
|
$ui->year = $date['year'];
|
|
|
|
$ui->month = $date['month'];
|
|
|
|
$ui->day = $date['day'];
|
|
|
|
$ui->owner = (int)$owner;
|
|
|
|
|
|
|
|
$label = '';
|
|
|
|
$todos = $ui->get_todos($label);
|
|
|
|
egw_json_response::get()->data(array(
|
|
|
|
'label' => $label,
|
|
|
|
'todos' => $todos
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
2004-08-01 17:36:04 +02:00
|
|
|
/**
|
|
|
|
* Query the open ToDo's via a hook from InfoLog or any other 'calendar_include_todos' provider
|
|
|
|
*
|
2004-08-31 11:40:09 +02:00
|
|
|
* @param array/string $todo_label label for the todo-box or array with 2 values: the label and a boolean show_all
|
2004-08-01 17:36:04 +02:00
|
|
|
* On return $todo_label contains the label for the todo-box
|
2005-11-09 00:15:14 +01:00
|
|
|
* @return string/boolean html with a table of open todo's or false if no hook availible
|
2004-08-01 17:36:04 +02:00
|
|
|
*/
|
|
|
|
function get_todos(&$todo_label)
|
|
|
|
{
|
2005-11-09 00:15:14 +01:00
|
|
|
$todos_from_hook = $GLOBALS['egw']->hooks->process(array(
|
2004-08-01 17:36:04 +02:00
|
|
|
'location' => 'calendar_include_todos',
|
|
|
|
'year' => $this->year,
|
|
|
|
'month' => $this->month,
|
|
|
|
'day' => $this->day,
|
|
|
|
'owner' => $this->owner // num. id of the user, not necessary current user
|
|
|
|
));
|
|
|
|
|
|
|
|
if(is_array($todo_label))
|
|
|
|
{
|
|
|
|
list($label,$showall)=$todo_label;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$label=$todo_label;
|
|
|
|
$showall=true;
|
|
|
|
}
|
2005-11-09 00:15:14 +01:00
|
|
|
$maxshow = (int)$GLOBALS['egw_info']['user']['preferences']['infolog']['mainscreen_maxshow'];
|
2004-08-01 17:36:04 +02:00
|
|
|
if($maxshow <= 0)
|
|
|
|
{
|
|
|
|
$maxshow=10;
|
|
|
|
}
|
|
|
|
//print_debug("get_todos(): label=$label; showall=$showall; max=$maxshow");
|
|
|
|
|
|
|
|
$content = $todo_label = '';
|
|
|
|
if (is_array($todos_from_hook) && count($todos_from_hook))
|
|
|
|
{
|
|
|
|
foreach($todos_from_hook as $todos)
|
|
|
|
{
|
|
|
|
$i = 0;
|
2005-11-09 00:15:14 +01:00
|
|
|
if (is_array($todos))
|
2004-08-01 17:36:04 +02:00
|
|
|
{
|
2005-11-09 00:15:14 +01:00
|
|
|
$todo_label = !empty($label) ? $label : lang("open ToDo's:");
|
|
|
|
|
2015-07-15 18:29:10 +02:00
|
|
|
foreach($todos as &$todo)
|
2004-08-01 17:36:04 +02:00
|
|
|
{
|
|
|
|
if(!$showall && ($i++ > $maxshow))
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
$icons = '';
|
2015-12-28 18:59:47 +01:00
|
|
|
foreach($todo['icons'] as $name => $alt)
|
2004-08-01 17:36:04 +02:00
|
|
|
{
|
2015-12-28 18:59:47 +01:00
|
|
|
$icons .= ($icons?' ':'').$GLOBALS['egw']->html->image('infolog',$name,lang($alt),'border="0" width="15" height="15"');
|
2004-08-01 17:36:04 +02:00
|
|
|
}
|
2015-07-15 18:29:10 +02:00
|
|
|
$todo['icons'] = $icons;
|
2004-08-01 17:36:04 +02:00
|
|
|
$class = $class == 'row_on' ? 'row_off' : 'row_on';
|
2010-12-10 21:05:51 +01:00
|
|
|
if($todo['edit']) {
|
2015-07-15 18:29:10 +02:00
|
|
|
$todo['edit_size'] = $todo['edit']['size'];
|
2010-12-10 21:05:51 +01:00
|
|
|
unset($todo['edit']['size']);
|
2014-01-17 11:28:15 +01:00
|
|
|
$edit_icon_href = html::a_href( $icons, $todo['edit'],'',' data-todo="app|'.$width.'x'.$height.'" ');
|
|
|
|
$edit_href = html::a_href( $todo['title'], $todo['edit'],'',' data-todo="app|750x590" ');
|
2015-07-15 18:29:10 +02:00
|
|
|
$todo['edit'] = egw_framework::link('/index.php',$todo['edit'],true);
|
2010-12-10 21:05:51 +01:00
|
|
|
}
|
2010-12-13 16:37:25 +01:00
|
|
|
$icon_href = html::a_href($icons,$todo['view']);
|
|
|
|
$href = html::a_href($todo['title'], $todo['view']);
|
2004-08-01 17:36:04 +02:00
|
|
|
$content .= " <tr class=\"$class\">\n <td valign=\"top\" width=\"15%\" nowrap>".
|
2010-12-13 16:37:25 +01:00
|
|
|
($this->bo->printer_friendly?$icons:($edit_icon_href ? $edit_icon_href : $icon_href)).
|
2004-08-01 17:36:04 +02:00
|
|
|
"</td>\n <td>".($this->printer_friendly?$todo['title']:
|
2011-07-06 18:04:18 +02:00
|
|
|
$edit_href)."</td>\n </tr>\n";
|
2005-11-09 00:15:14 +01:00
|
|
|
/**
|
|
|
|
* ToDo: add delete and closing action
|
|
|
|
*/
|
2004-08-01 17:36:04 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-07-15 18:29:10 +02:00
|
|
|
return $todos;
|
2004-08-01 17:36:04 +02:00
|
|
|
}
|
2008-06-07 19:45:33 +02:00
|
|
|
|
2004-08-01 17:36:04 +02:00
|
|
|
/**
|
|
|
|
* Calculates the vertical position based on the time
|
|
|
|
*
|
|
|
|
* workday start- and end-time, is taken into account, as well as timeGrids px_m - minutes per pixel param
|
2005-11-09 00:15:14 +01:00
|
|
|
*
|
2004-08-31 11:40:09 +02:00
|
|
|
* @param int $time in minutes
|
2005-11-09 00:15:14 +01:00
|
|
|
* @return float position in percent
|
2004-08-01 17:36:04 +02:00
|
|
|
*/
|
|
|
|
function time2pos($time)
|
|
|
|
{
|
2006-06-02 21:38:08 +02:00
|
|
|
if ($this->scroll_to_wdstart) // we display the complete day - thought only workday is visible without scrolling
|
|
|
|
{
|
|
|
|
return $this->rowHeight * (1 + $this->extraRows + $time/$this->granularity_m);
|
|
|
|
}
|
2005-11-09 00:15:14 +01:00
|
|
|
// time before workday => condensed in the first $this->extraRows rows
|
2004-08-01 17:36:04 +02:00
|
|
|
if ($this->wd_start > 0 && $time < $this->wd_start)
|
|
|
|
{
|
2006-10-17 22:01:08 +02:00
|
|
|
$pos = (($this->extraRows - $this->extraRowsOriginal + 1) + ($time / $this->wd_start * ($this->extraRowsOriginal - 1))) * $this->rowHeight;
|
2004-08-01 17:36:04 +02:00
|
|
|
}
|
|
|
|
// time after workday => condensed in the last row
|
2005-11-09 00:15:14 +01:00
|
|
|
elseif ($this->wd_end < 24*60 && $time > $this->wd_end+1*$this->granularity_m)
|
2004-08-01 17:36:04 +02:00
|
|
|
{
|
2010-12-09 22:04:34 +01:00
|
|
|
$pos = 100 - (($this->extraRows - $this->remBotExtraRows) * $this->rowHeight * (1 - ($time - $this->wd_end) / (24*60 - $this->wd_end)));
|
2004-08-01 17:36:04 +02:00
|
|
|
}
|
|
|
|
// time during the workday => 2. row on (= + granularity)
|
|
|
|
else
|
|
|
|
{
|
2005-11-09 00:15:14 +01:00
|
|
|
$pos = $this->rowHeight * (1+$this->extraRows+($time-$this->wd_start)/$this->granularity_m);
|
2004-08-01 17:36:04 +02:00
|
|
|
}
|
2005-11-09 00:15:14 +01:00
|
|
|
$pos = round($pos,1);
|
|
|
|
|
2004-08-01 17:36:04 +02:00
|
|
|
if ($this->debug > 3) $this->bo->debug_message('uiviews::time2pos(%1)=%2',False,$time,$pos);
|
|
|
|
|
|
|
|
return $pos;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2010-07-31 09:51:52 +02:00
|
|
|
* Calculates the height of a difference between 2 times
|
2004-08-01 17:36:04 +02:00
|
|
|
*
|
|
|
|
* workday start- and end-time, is taken into account, as well as timeGrids px_m - minutes per pixel param
|
2005-11-09 00:15:14 +01:00
|
|
|
*
|
2004-08-31 11:40:09 +02:00
|
|
|
* @param int $start time in minutes
|
|
|
|
* @param int $end time in minutes
|
2014-11-05 17:13:26 +01:00
|
|
|
* @param int $minimum = 0 minimum height
|
2005-11-09 00:15:14 +01:00
|
|
|
* @return float height in percent
|
2004-08-01 17:36:04 +02:00
|
|
|
*/
|
|
|
|
function times2height($start,$end,$minimum=0)
|
|
|
|
{
|
2006-05-14 18:50:20 +02:00
|
|
|
$minimum = $this->rowHeight;
|
2004-08-01 17:36:04 +02:00
|
|
|
$height = $this->time2pos($end) - $this->time2pos($start);
|
|
|
|
|
|
|
|
if ($this->debug > 3) $this->bo->debug_message('uiviews::times2height(%1,%2,min=%3)=%4',False,$start,$end,$minimum,$height);
|
|
|
|
|
|
|
|
return $height >= $minimum ? $height : $minimum;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a grid with rows for the time, columns for (multiple) days containing events
|
|
|
|
*
|
|
|
|
* Uses the dayColWidget to display each day.
|
|
|
|
*
|
|
|
|
* @param $daysEvents array with subarrays of events for each day to show, day as YYYYMMDD as key
|
2014-11-05 17:13:26 +01:00
|
|
|
* @param int $granularity_m = 30 granularity in minutes of the rows
|
|
|
|
* @param int $height = 400 height of the widget
|
|
|
|
* @param string $indent = '' string for correct indention
|
|
|
|
* @param string $title = '' title of the time-grid
|
|
|
|
* @param int/array $owner = 0 owner of the calendar (default 0 = $this->owner) or array with owner for each column
|
|
|
|
* @param boolean $last = true last timeGrid displayed, default true
|
2004-08-01 17:36:04 +02:00
|
|
|
*/
|
2006-06-02 21:38:08 +02:00
|
|
|
function &timeGridWidget($daysEvents,$granularity_m=30,$height=400,$indent='',$title='',$owner=0,$last=true)
|
2004-08-01 17:36:04 +02:00
|
|
|
{
|
2005-11-09 00:15:14 +01:00
|
|
|
if ($this->debug > 1 || $this->debug==='timeGridWidget') $this->bo->debug_message('uiviews::timeGridWidget(events=%1,granularity_m=%2,height=%3,,title=%4)',True,$daysEvents,$granularity_m,$height,$title);
|
2004-08-01 17:36:04 +02:00
|
|
|
|
2006-06-02 21:38:08 +02:00
|
|
|
// determine if the browser supports scrollIntoView: IE4+, firefox1.0+ and safari2.0+ does
|
|
|
|
// then show all hours in a div of the size of the workday and scroll to the workday start
|
|
|
|
// still disabled, as things need to be re-aranged first, to that the column headers are not scrolled
|
2008-06-07 19:45:33 +02:00
|
|
|
$this->scroll_to_wdstart = false;/*$this->use_time_grid && (html::$user_agent == 'msie' ||
|
2008-03-21 21:30:19 +01:00
|
|
|
html::$user_agent == 'mozilla' && html::ua_version >= 5.0 ||
|
|
|
|
html::$user_agent == 'safari' && html::ua_version >= 2.0);*/
|
2008-06-07 19:45:33 +02:00
|
|
|
|
2006-06-02 21:38:08 +02:00
|
|
|
if ($this->scroll_to_wdstart)
|
|
|
|
{
|
|
|
|
$this->extraRows = 0; // no extra rows necessary
|
2010-12-09 22:04:34 +01:00
|
|
|
$this->remBotExtraRows = 0;
|
2006-06-02 21:38:08 +02:00
|
|
|
$overflow = 'overflow: scroll;';
|
|
|
|
}
|
2004-08-01 17:36:04 +02:00
|
|
|
$this->granularity_m = $granularity_m;
|
2005-11-09 00:15:14 +01:00
|
|
|
$this->display_start = $this->wd_start - ($this->extraRows * $this->granularity_m);
|
2010-12-09 22:04:34 +01:00
|
|
|
$this->display_end = $this->wd_end + (($this->extraRows - $this->remBotExtraRows) * $this->granularity_m);
|
2004-08-01 17:36:04 +02:00
|
|
|
|
2006-06-02 21:38:08 +02:00
|
|
|
if (!$this->wd_end) $this->wd_end = 1440;
|
|
|
|
$totalDisplayMinutes = $this->wd_end - $this->wd_start;
|
2010-12-09 22:04:34 +01:00
|
|
|
$this->rowsToDisplay = ($totalDisplayMinutes/$granularity_m)+2+2*$this->extraRows - $this->remBotExtraRows;
|
2005-11-09 00:15:14 +01:00
|
|
|
$this->rowHeight = round(100/$this->rowsToDisplay,1);
|
2008-06-07 19:45:33 +02:00
|
|
|
|
2006-03-01 10:43:24 +01:00
|
|
|
// ensure a minimum height of each row
|
|
|
|
if ($height < ($this->rowsToDisplay+1) * 12)
|
|
|
|
{
|
|
|
|
$height = ($this->rowsToDisplay+1) * 12;
|
|
|
|
}
|
2013-11-11 15:02:08 +01:00
|
|
|
$html = $indent.'<div class="calendar_calTimeGrid" style="height: '.$height.'px;'.$overflow.'">'."\n";
|
2004-08-01 17:36:04 +02:00
|
|
|
|
2013-11-11 15:02:08 +01:00
|
|
|
$html .= $indent."\t".'<div class="calendar_calGridHeader" style="height: '.
|
2005-11-09 00:15:14 +01:00
|
|
|
$this->rowHeight.'%;">'.$title."</div>\n";
|
|
|
|
|
2006-05-31 02:33:27 +02:00
|
|
|
if ($this->use_time_grid)
|
2005-11-09 00:15:14 +01:00
|
|
|
{
|
2006-05-31 02:33:27 +02:00
|
|
|
$off = false; // Off-row means a different bgcolor
|
|
|
|
$add_links = count($daysEvents) == 1;
|
2008-06-07 19:45:33 +02:00
|
|
|
|
2006-05-31 02:33:27 +02:00
|
|
|
// the hour rows
|
2006-06-02 21:38:08 +02:00
|
|
|
for($t = $this->scroll_to_wdstart ? 0 : $this->wd_start,$i = 1+$this->extraRows;
|
|
|
|
$t <= $this->wd_end || $this->scroll_to_wdstart && $t < 24*60;
|
|
|
|
$t += $this->granularity_m,++$i)
|
2004-08-01 17:36:04 +02:00
|
|
|
{
|
2006-06-02 21:38:08 +02:00
|
|
|
$set_id = '';
|
|
|
|
if ($t == $this->wd_start)
|
|
|
|
{
|
|
|
|
list($id) = @each($daysEvents);
|
2012-01-05 05:12:13 +01:00
|
|
|
if (is_numeric($id))
|
|
|
|
{
|
|
|
|
$id = 'wd_start_'.$id;
|
|
|
|
$set_id = ' id="'.$id.'"';
|
|
|
|
}
|
2006-06-02 21:38:08 +02:00
|
|
|
}
|
2013-11-11 15:02:08 +01:00
|
|
|
$html .= $indent."\t".'<div'.$set_id.' class="calendar_calTimeRow'.($off ? 'Off row_off' : ' row_on').
|
2006-06-02 21:38:08 +02:00
|
|
|
'" style="height: '.$this->rowHeight.'%; top:'. $i*$this->rowHeight .'%;">'."\n";
|
|
|
|
// show time for full hours, allways for 45min interval and at least on every 3 row
|
|
|
|
$time = '';
|
|
|
|
static $show = array(
|
|
|
|
5 => array(0,15,30,45),
|
|
|
|
10 => array(0,30),
|
|
|
|
15 => array(0,30),
|
|
|
|
45 => array(0,15,30,45),
|
|
|
|
);
|
|
|
|
if (!isset($show[$this->granularity_m]) ? $t % 60 == 0 : in_array($t % 60,$show[$this->granularity_m]))
|
2006-05-31 02:33:27 +02:00
|
|
|
{
|
2006-06-02 21:38:08 +02:00
|
|
|
$time = $GLOBALS['egw']->common->formattime(sprintf('%02d',$t/60),sprintf('%02d',$t%60));
|
2006-05-31 02:33:27 +02:00
|
|
|
}
|
2006-06-02 21:38:08 +02:00
|
|
|
if ($add_links) $time = $this->add_link($time,$this->date,(int) ($t/60),$t%60);
|
2013-11-11 15:02:08 +01:00
|
|
|
$html .= $indent."\t\t".'<div class="calendar_calTimeRowTime">'.$time."</div>\n";
|
|
|
|
$html .= $indent."\t</div>\n"; // calendar_calTimeRow
|
2006-06-02 21:38:08 +02:00
|
|
|
$off = !$off;
|
2004-08-01 17:36:04 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (is_array($daysEvents) && count($daysEvents))
|
|
|
|
{
|
2005-11-09 00:15:14 +01:00
|
|
|
$numberOfDays = count($daysEvents);
|
|
|
|
$dayColWidth = 100/$numberOfDays;
|
|
|
|
|
2004-08-01 17:36:04 +02:00
|
|
|
$dayCols_width = $width - $this->timeRow_width - 1;
|
2005-11-09 00:15:14 +01:00
|
|
|
|
2013-11-11 15:02:08 +01:00
|
|
|
$html .= $indent."\t".'<div id="calendar_calDayCols" class="calendar_calDayCols'.
|
2006-06-19 22:46:25 +02:00
|
|
|
($this->use_time_grid ? ($this->bo->common_prefs['timeformat'] == 12 ? '12h' : '') : 'NoTime').'">'."\n";
|
|
|
|
|
2008-03-21 21:30:19 +01:00
|
|
|
if (html::$user_agent == 'msie') // necessary IE hack - stupid thing ...
|
2006-06-19 22:46:25 +02:00
|
|
|
{
|
|
|
|
// Lars Kneschke 2005-08-28
|
|
|
|
// why do we use a div in a div which has the same height and width???
|
2008-06-07 19:45:33 +02:00
|
|
|
// To make IE6 happy!!! Without the second div you can't use
|
2006-06-19 22:46:25 +02:00
|
|
|
// style="left: 50px; right: 0px;"
|
|
|
|
//$html .= '<div style="width=100%; height: 100%;">'."\n";
|
|
|
|
|
|
|
|
// Ralf Becker 2006-06-19
|
2008-06-07 19:45:33 +02:00
|
|
|
// Lars original typo "width=100%; height: 100%;" is important ;-)
|
2006-06-19 22:46:25 +02:00
|
|
|
// means you width: 100% does NOT work, you need no width!
|
|
|
|
$html .= '<div style="height: 100%;">'."\n";
|
|
|
|
}
|
2004-08-01 17:36:04 +02:00
|
|
|
$dayCol_width = $dayCols_width / count($daysEvents);
|
|
|
|
$n = 0;
|
|
|
|
foreach($daysEvents as $day => $events)
|
|
|
|
{
|
2006-10-17 22:01:08 +02:00
|
|
|
$this->wholeDayPosCounter=1;
|
2005-11-09 00:15:14 +01:00
|
|
|
$short_title = count($daysEvents) > 1;
|
|
|
|
$col_owner = $owner;
|
|
|
|
if (!is_numeric($day))
|
|
|
|
{
|
|
|
|
$short_title = $day;
|
|
|
|
$day = $this->date;
|
|
|
|
$col_owner = $owner[$n];
|
|
|
|
}
|
|
|
|
$html .= $this->dayColWidget($day,$events,$n*$dayColWidth,
|
|
|
|
$dayColWidth,$indent."\t\t",$short_title,++$on_off & 1,$col_owner);
|
2004-08-01 17:36:04 +02:00
|
|
|
++$n;
|
|
|
|
}
|
2008-03-21 21:30:19 +01:00
|
|
|
if (html::$user_agent == 'msie') $html .= "</div>\n";
|
2006-06-19 22:46:25 +02:00
|
|
|
|
2013-11-11 15:02:08 +01:00
|
|
|
$html .= $indent."\t</div>\n"; // calendar_calDayCols
|
2004-08-01 17:36:04 +02:00
|
|
|
}
|
2013-11-11 15:02:08 +01:00
|
|
|
$html .= $indent."</div>\n"; // calendar_calTimeGrid
|
2008-06-07 19:45:33 +02:00
|
|
|
|
2006-06-02 21:38:08 +02:00
|
|
|
if ($this->scroll_to_wdstart)
|
|
|
|
{
|
|
|
|
$html .= "<script>\n\tdocument.getElementById('$id').scrollIntoView();\n";
|
|
|
|
if ($last) // last timeGrid --> scroll whole document back up
|
|
|
|
{
|
|
|
|
$html .= "\tdocument.getElementById('divMain').scrollIntoView();\n";
|
|
|
|
}
|
|
|
|
$html .= "</script>\n";
|
|
|
|
}
|
2006-12-15 21:05:47 +01:00
|
|
|
|
2004-08-01 17:36:04 +02:00
|
|
|
return $html;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2010-07-31 09:51:52 +02:00
|
|
|
* Sorts the events of a day into columns with non-overlapping events, the events
|
|
|
|
* are already sorted by start-time
|
2004-08-01 17:36:04 +02:00
|
|
|
*
|
2004-08-31 11:40:09 +02:00
|
|
|
* @param string/int $day_ymd date as Ymd
|
2010-07-31 09:51:52 +02:00
|
|
|
* @param array &$events events to split into non-overlapping groups
|
2004-08-01 17:36:04 +02:00
|
|
|
*/
|
2010-07-31 09:51:52 +02:00
|
|
|
function getEventCols($day_ymd, &$events)
|
2004-08-01 17:36:04 +02:00
|
|
|
{
|
|
|
|
$day_start = $this->bo->date2ts((string)$day_ymd);
|
2008-06-07 19:45:33 +02:00
|
|
|
|
2006-10-29 13:51:53 +01:00
|
|
|
// if daylight saving is switched on or off, correct $day_start
|
|
|
|
// gives correct times after 2am, times between 0am and 2am are wrong
|
|
|
|
if(($daylight_diff = $day_start + 12*HOUR_s - ($this->bo->date2ts($day_ymd."T120000"))))
|
|
|
|
{
|
|
|
|
$day_start -= $daylight_diff;
|
|
|
|
}
|
2010-07-31 09:51:52 +02:00
|
|
|
|
2004-08-01 17:36:04 +02:00
|
|
|
$eventCols = $col_ends = array();
|
|
|
|
foreach($events as $event)
|
|
|
|
{
|
|
|
|
$event['multiday'] = False;
|
2005-11-09 00:15:14 +01:00
|
|
|
$event['start_m'] = ($event['start'] - $day_start) / 60;
|
2004-08-01 17:36:04 +02:00
|
|
|
if ($event['start_m'] < 0)
|
|
|
|
{
|
|
|
|
$event['start_m'] = 0;
|
|
|
|
$event['multiday'] = True;
|
|
|
|
}
|
2005-11-09 00:15:14 +01:00
|
|
|
$event['end_m'] = ($event['end'] - $day_start) / 60;
|
2004-08-01 17:36:04 +02:00
|
|
|
if ($event['end_m'] >= 24*60)
|
|
|
|
{
|
|
|
|
$event['end_m'] = 24*60-1;
|
|
|
|
$event['multiday'] = True;
|
|
|
|
}
|
2006-10-17 22:01:08 +02:00
|
|
|
if ($this->use_time_grid && !$event['whole_day_on_top'])
|
2006-05-31 02:33:27 +02:00
|
|
|
{
|
|
|
|
for($c = 0; $event['start_m'] < $col_ends[$c]; ++$c);
|
|
|
|
$col_ends[$c] = $event['end_m'];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$c = 0; // without grid we only use one column
|
|
|
|
}
|
2004-08-01 17:36:04 +02:00
|
|
|
$eventCols[$c][] = $event;
|
|
|
|
}
|
2010-07-31 09:51:52 +02:00
|
|
|
return $eventCols;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates (if necessary multiple) columns for the events of a day
|
|
|
|
*
|
|
|
|
* Uses the eventColWidget to display each column.
|
|
|
|
*
|
|
|
|
* @param string/int $day_ymd date as Ymd
|
|
|
|
* @param array $events of events to show
|
2011-11-11 08:28:13 +01:00
|
|
|
* @param int $pleft start of the widget
|
|
|
|
* @param int $pwidth width of the widget
|
2010-07-31 09:51:52 +02:00
|
|
|
* @param string $indent string for correct indention
|
2014-11-05 17:13:26 +01:00
|
|
|
* @param boolean/string $short_title = True should we add a label (weekday, day) with link to the day-view above each day or string with title
|
|
|
|
* @param boolean $on_off = false start with row_on or row_off, default false=row_off
|
|
|
|
* @param int $owner = 0 if != 0 owner to add to the add-event link
|
2010-07-31 09:51:52 +02:00
|
|
|
*/
|
2011-11-11 08:28:13 +01:00
|
|
|
function dayColWidget($day_ymd,$events,$pleft,$pwidth,$indent,$short_title=True,$on_off=False,$owner=0)
|
2010-07-31 09:51:52 +02:00
|
|
|
{
|
2011-11-11 08:28:13 +01:00
|
|
|
if ($this->debug > 1 || $this->debug==='dayColWidget') $this->bo->debug_message('uiviews::dayColWidget(%1,%2,left=%3,width=%4,)',False,$day_ymd,$events,$pleft,$pwidth);
|
2005-11-09 00:15:14 +01:00
|
|
|
|
2014-11-05 17:13:26 +01:00
|
|
|
$html = $indent.'<div id="calColumn'.$this->calColumnCounter++.'" class="calendar_calDayCol" '.'data-sortable-id="'.$owner.'" style="left: '.$pleft.
|
|
|
|
'%;width: '.$pwidth.'%;">'."\n";
|
2004-08-01 17:36:04 +02:00
|
|
|
|
|
|
|
// Creation of the header-column with date, evtl. holiday-names and a matching background-color
|
|
|
|
$ts = $this->bo->date2ts((string)$day_ymd);
|
2006-06-20 21:55:06 +02:00
|
|
|
$title = !is_bool($short_title) ? $short_title :
|
|
|
|
($short_title ? lang(adodb_date('l',$ts)).' '.adodb_date('d.',$ts) : $this->bo->long_date($ts,0,false,true));
|
2008-06-07 19:45:33 +02:00
|
|
|
|
2004-08-01 17:36:04 +02:00
|
|
|
$day_view = array(
|
2008-06-07 19:45:33 +02:00
|
|
|
'menuaction' => 'calendar.calendar_uiviews.day',
|
2004-08-01 17:36:04 +02:00
|
|
|
'date' => $day_ymd,
|
|
|
|
);
|
2007-05-19 09:49:57 +02:00
|
|
|
$this->_day_class_holiday($day_ymd,$class,$holidays);
|
|
|
|
// the weekday and date
|
2010-07-31 09:51:52 +02:00
|
|
|
if (!$short_title && $holidays) $title .= html::htmlspecialchars(': '.$holidays);
|
2007-05-19 09:49:57 +02:00
|
|
|
|
2005-11-09 00:15:14 +01:00
|
|
|
if ($short_title === true)
|
2004-08-01 17:36:04 +02:00
|
|
|
{
|
2009-08-03 11:51:35 +02:00
|
|
|
if ($this->allowEdit)
|
|
|
|
{
|
|
|
|
$title = html::a_href($title,$day_view,'',
|
2014-02-25 16:55:22 +01:00
|
|
|
!isset($this->holidays[$day_ymd])?' title="'.$this->bo->long_date($ts,0,false,true).'"':'');
|
2009-08-03 11:51:35 +02:00
|
|
|
}
|
2004-08-01 17:36:04 +02:00
|
|
|
}
|
2006-05-31 02:33:27 +02:00
|
|
|
elseif ($short_title === false)
|
|
|
|
{
|
|
|
|
// add arrows to go to the previous and next day (dayview only)
|
|
|
|
$day_view['date'] = $this->bo->date2string($ts -= 12*HOUR_s);
|
2009-08-03 11:51:35 +02:00
|
|
|
if ($this->allowEdit)
|
|
|
|
{
|
2014-03-05 14:48:28 +01:00
|
|
|
$title = html::a_href(html::image('phpgwapi','left',$this->bo->long_date($ts)),$day_view).' <span> '.$title;
|
2009-08-03 11:51:35 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-03-05 14:48:28 +01:00
|
|
|
$title = $day_view.' <span> '.$title;
|
2009-08-03 11:51:35 +02:00
|
|
|
}
|
2006-05-31 02:33:27 +02:00
|
|
|
$day_view['date'] = $this->bo->date2string($ts += 48*HOUR_s);
|
2009-08-03 11:51:35 +02:00
|
|
|
if ($this->allowEdit)
|
|
|
|
{
|
2014-03-05 14:48:28 +01:00
|
|
|
$title .= ' </span> '.html::a_href(html::image('phpgwapi','right',$this->bo->long_date($ts)),$day_view);
|
2009-08-03 11:51:35 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-03-05 14:48:28 +01:00
|
|
|
$title .= ' </span> '.$day_view;
|
2009-08-03 11:51:35 +02:00
|
|
|
}
|
2006-05-31 02:33:27 +02:00
|
|
|
}
|
2010-07-31 09:51:52 +02:00
|
|
|
if (is_bool($short_title) || ($short_title != "")) {
|
2013-11-11 15:02:08 +01:00
|
|
|
$html .= $indent."\t".'<div style="height: '. $this->rowHeight .'%;" class="calendar_calDayColHeader '.$class.'"'.
|
2010-07-31 09:51:52 +02:00
|
|
|
($holidays ? ' title="'.html::htmlspecialchars($holidays).'"':'').'>'.$title."</div>\n";
|
|
|
|
}
|
2005-11-09 00:15:14 +01:00
|
|
|
|
2006-05-31 02:33:27 +02:00
|
|
|
if ($this->use_time_grid)
|
2005-11-09 00:15:14 +01:00
|
|
|
{
|
2006-12-15 21:05:47 +01:00
|
|
|
// drag and drop: check if the current user has EDIT permissions on the grid
|
2013-12-19 11:19:14 +01:00
|
|
|
if($owner)
|
2006-12-15 21:05:47 +01:00
|
|
|
{
|
2013-12-19 11:19:14 +01:00
|
|
|
$dropPermission = $this->bo->check_perms(EGW_ACL_EDIT,0,$owner);
|
2006-12-15 21:05:47 +01:00
|
|
|
}
|
2013-12-19 11:19:14 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
$dropPermission = true;
|
|
|
|
}
|
|
|
|
|
2006-05-31 02:33:27 +02:00
|
|
|
// adding divs to click on for each row / time-span
|
2010-07-31 09:51:52 +02:00
|
|
|
for($t = $this->scroll_to_wdstart ? 0 : $this->wd_start,$i = 1 + $this->extraRows;
|
2006-06-02 21:38:08 +02:00
|
|
|
$t <= $this->wd_end || $this->scroll_to_wdstart && $t < 24*60;
|
|
|
|
$t += $this->granularity_m,++$i)
|
2006-05-31 02:33:27 +02:00
|
|
|
{
|
|
|
|
$linkData = array(
|
2008-06-07 19:45:33 +02:00
|
|
|
'menuaction' =>'calendar.calendar_uiforms.edit',
|
2006-05-31 02:33:27 +02:00
|
|
|
'date' => $day_ymd,
|
2006-12-15 21:05:47 +01:00
|
|
|
'hour' => sprintf("%02d",floor($t / 60)),
|
|
|
|
'minute' => sprintf("%02d",floor($t % 60)),
|
2006-05-31 02:33:27 +02:00
|
|
|
);
|
|
|
|
if ($owner) $linkData['owner'] = $owner;
|
2006-12-15 21:05:47 +01:00
|
|
|
|
|
|
|
$droppableDateTime = $linkData['date'] . "T" . $linkData['hour'] . $linkData['minute'];
|
2010-06-14 10:11:22 +02:00
|
|
|
$droppableID='drop_'.$droppableDateTime.'_O'.($owner<0?str_replace('-','group',$owner):$owner);
|
2008-06-07 19:45:33 +02:00
|
|
|
|
2006-12-15 21:05:47 +01:00
|
|
|
$html .= $indent."\t".'<div id="' . $droppableID . '" style="height:'. $this->rowHeight .'%; top: '. $i*$this->rowHeight .
|
2013-11-11 15:02:08 +01:00
|
|
|
'%;" class="calendar_calAddEvent"';
|
2009-08-03 11:51:35 +02:00
|
|
|
if ($this->allowEdit)
|
|
|
|
{
|
2013-12-13 19:18:56 +01:00
|
|
|
$html .= ' data-date=' .$linkData['date'].'|'.$linkData['hour'].'|'.$linkData['minute'];
|
2009-08-03 11:51:35 +02:00
|
|
|
}
|
2013-12-13 19:18:56 +01:00
|
|
|
if($dropPermission && $owner)
|
2006-12-15 21:05:47 +01:00
|
|
|
{
|
2013-12-13 19:18:56 +01:00
|
|
|
$html .= ' data-owner ='.$owner;
|
|
|
|
|
2006-12-15 21:05:47 +01:00
|
|
|
}
|
2013-12-13 19:18:56 +01:00
|
|
|
$html .= '></div>'."\n";
|
|
|
|
|
2006-05-31 02:33:27 +02:00
|
|
|
}
|
2005-11-09 00:15:14 +01:00
|
|
|
}
|
2010-07-31 09:51:52 +02:00
|
|
|
|
|
|
|
$eventCols = $this->getEventCols($day_ymd,$events);
|
2005-11-09 00:15:14 +01:00
|
|
|
// displaying all event columns of the day
|
|
|
|
foreach($eventCols as $n => $eventCol)
|
|
|
|
{
|
2011-02-11 16:43:40 +01:00
|
|
|
// equal sized columns
|
2011-11-11 08:28:13 +01:00
|
|
|
//$width = 95.0 / count($eventCols);
|
|
|
|
//$left = 2.5 + $n * $width;
|
2011-02-11 17:50:24 +01:00
|
|
|
// alternative overlapping columns
|
2011-11-11 08:28:13 +01:00
|
|
|
$left = 2.5 + (1.5 * 100 / $pwidth);
|
2011-02-11 17:50:24 +01:00
|
|
|
if (count($eventCols) == 1)
|
|
|
|
{
|
2011-11-11 08:28:13 +01:00
|
|
|
$width = 100 - $left;
|
2011-02-11 17:50:24 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-11-11 08:28:13 +01:00
|
|
|
$width = !$n ? 70 : 50;
|
|
|
|
$left += $n * (100.0-$left) / count($eventCols);
|
2011-02-11 17:50:24 +01:00
|
|
|
}
|
|
|
|
if ($left + $width > 100.0) $width = 100.0 - $left;
|
2011-11-11 08:28:13 +01:00
|
|
|
//echo "<p>count(\$eventCols)=".count($eventCols).", n=$n, pWidth=$pwidth, pLeft=$pleft, width=$width, left=$left</p>\n";
|
2011-02-11 16:43:40 +01:00
|
|
|
$html .= $this->eventColWidget($eventCol,$left,$width,$indent."\t",
|
2011-02-14 12:03:12 +01:00
|
|
|
$owner ? $owner : $this->user, 20+10*$n);
|
2005-11-09 00:15:14 +01:00
|
|
|
}
|
2013-11-11 15:02:08 +01:00
|
|
|
$html .= $indent."</div>\n"; // calendar_calDayCol
|
2005-11-09 00:15:14 +01:00
|
|
|
|
|
|
|
return $html;
|
|
|
|
}
|
2008-06-07 19:45:33 +02:00
|
|
|
|
2005-11-09 00:15:14 +01:00
|
|
|
/**
|
|
|
|
* get the CSS class and holidays for a given day
|
|
|
|
*
|
|
|
|
* @param string $day_ymd date
|
|
|
|
* @param string &$class class to use
|
|
|
|
* @param string &$holidays commaseparted holidays or empty if none
|
2014-11-05 17:13:26 +01:00
|
|
|
* @param boolean $only_weekend = false show only the weekend in header-color, otherwise every second days is shown too
|
|
|
|
* @param boolean $show_bdays = true If available, also show birthdays (or hide Bdays)
|
2010-07-31 09:51:52 +02:00
|
|
|
* Note that this is not the place to disable a preference.
|
|
|
|
* If the preferences allow birthdays to be displayed, they are cached within the holidays structure.
|
|
|
|
* This setting just suppressing the available data in the view.
|
2005-11-09 00:15:14 +01:00
|
|
|
*/
|
2010-07-31 09:51:52 +02:00
|
|
|
function _day_class_holiday($day_ymd,&$class,&$holidays,$only_weekend=false,$show_bdays=true)
|
2005-11-09 00:15:14 +01:00
|
|
|
{
|
|
|
|
$class = $holidays = '';
|
|
|
|
$bday = false;
|
2004-08-01 17:36:04 +02:00
|
|
|
if (isset($this->holidays[$day_ymd]))
|
|
|
|
{
|
2010-07-31 09:51:52 +02:00
|
|
|
$h = array();
|
2004-08-01 17:36:04 +02:00
|
|
|
foreach($this->holidays[$day_ymd] as $holiday)
|
|
|
|
{
|
2005-11-09 00:15:14 +01:00
|
|
|
if (isset($holiday['birthyear']))
|
|
|
|
{
|
2010-07-31 09:51:52 +02:00
|
|
|
if ($show_bdays)
|
|
|
|
{
|
|
|
|
$bday = true;
|
2010-12-22 16:17:56 +01:00
|
|
|
|
|
|
|
//If the birthdays are already displayed as event, don't
|
|
|
|
//show them in the caption
|
|
|
|
if (!$this->display_holiday_event_types['bdays'])
|
|
|
|
{
|
|
|
|
$h[] = $holiday['name'];
|
|
|
|
}
|
2010-07-31 09:51:52 +02:00
|
|
|
}
|
2005-11-09 00:15:14 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-11-11 15:02:08 +01:00
|
|
|
$class = 'calendar_calHoliday';
|
2010-12-22 16:17:56 +01:00
|
|
|
|
|
|
|
//If the birthdays are already displayed as event, don't
|
|
|
|
//show them in the caption
|
|
|
|
if (!$this->display_holiday_event_types['hdays'])
|
|
|
|
{
|
|
|
|
$h[] = $holiday['name'];
|
|
|
|
}
|
2005-11-09 00:15:14 +01:00
|
|
|
}
|
2004-08-01 17:36:04 +02:00
|
|
|
}
|
2010-07-31 09:51:52 +02:00
|
|
|
$holidays = implode(', ',$h);
|
2004-08-01 17:36:04 +02:00
|
|
|
}
|
2005-11-09 00:15:14 +01:00
|
|
|
if (!$class)
|
2004-08-01 17:36:04 +02:00
|
|
|
{
|
2005-11-09 00:15:14 +01:00
|
|
|
if ($day_ymd == $this->bo->date2string($this->bo->now_su))
|
|
|
|
{
|
2013-11-11 15:02:08 +01:00
|
|
|
$class = 'calendar_calToday';
|
2005-11-09 00:15:14 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$day = (int) date('w',$this->bo->date2ts((string) $day_ymd));
|
2008-06-07 19:45:33 +02:00
|
|
|
|
2005-11-09 00:15:14 +01:00
|
|
|
if ($only_weekend)
|
|
|
|
{
|
|
|
|
$class = $day == 0 || $day == 6 ? 'th' : 'row_off';
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$class = $day & 1 ? 'row_on' : 'th';
|
|
|
|
}
|
|
|
|
}
|
2004-08-01 17:36:04 +02:00
|
|
|
}
|
2013-11-11 15:02:08 +01:00
|
|
|
if ($bday) $class .= ' calendar_calBirthday';
|
2004-08-01 17:36:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates colunm for non-overlaping (!) events
|
|
|
|
*
|
|
|
|
* Uses the eventWidget to display each event.
|
|
|
|
*
|
2004-08-31 11:40:09 +02:00
|
|
|
* @param array $events of events to show
|
|
|
|
* @param int $left start of the widget
|
|
|
|
* @param int $width width of the widget
|
|
|
|
* @param string $indent string for correct indention
|
2006-12-15 21:05:47 +01:00
|
|
|
* @param int $owner owner of the eventCol
|
2004-08-01 17:36:04 +02:00
|
|
|
*/
|
2011-02-11 16:43:40 +01:00
|
|
|
function eventColWidget($events,$left,$width,$indent,$owner,$z_index=null)
|
2004-08-01 17:36:04 +02:00
|
|
|
{
|
|
|
|
if ($this->debug > 1 || $this->debug==='eventColWidget') $this->bo->debug_message('uiviews::eventColWidget(%1,left=%2,width=%3,)',False,$events,$left,$width);
|
|
|
|
|
2013-11-11 15:02:08 +01:00
|
|
|
$html = $indent.'<div class="calendar_calEventCol" style="left: '.$left.'%; width:'.$width.'%;'.
|
|
|
|
// the "calendar_calEventCol" spans across a whole column (as the name suggests) - setting the
|
2011-02-14 12:03:12 +01:00
|
|
|
// z-index here would give the whole invisible column a z-index and thus the underlying
|
|
|
|
// regions are not clickable anymore. The z_index has now moved the the eventWidget
|
|
|
|
// function.
|
|
|
|
//(!is_null($z_index) ? ' z-index:'.$z_index.';' : '').
|
2006-05-31 02:33:27 +02:00
|
|
|
(!$this->use_time_grid ? ' top: '.$this->rowHeight.'%;' : '').'">'."\n";
|
2004-08-01 17:36:04 +02:00
|
|
|
foreach($events as $event)
|
|
|
|
{
|
2011-02-14 12:03:12 +01:00
|
|
|
$html .= $this->eventWidget($event,$width,$indent."\t",$owner,false,'event_widget',$z_index);
|
2004-08-01 17:36:04 +02:00
|
|
|
}
|
|
|
|
$html .= $indent."</div>\n";
|
|
|
|
|
|
|
|
return $html;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Shows one event
|
|
|
|
*
|
2004-08-31 11:40:09 +02:00
|
|
|
* The display of the event and it's tooltip is done via the event_widget.tpl template
|
|
|
|
*
|
2004-08-01 17:36:04 +02:00
|
|
|
* @param $event array with the data of event to show
|
|
|
|
* @param $width int width of the widget
|
2004-08-31 11:40:09 +02:00
|
|
|
* @param string $indent string for correct indention
|
2006-12-15 21:05:47 +01:00
|
|
|
* @param int $owner owner of the calendar the event is in
|
2014-11-05 17:13:26 +01:00
|
|
|
* @param boolean $return_array = false should an array with keys(tooltip,popup,html) be returned or the complete widget as string
|
|
|
|
* @param string $block = 'event_widget' template used the render the widget
|
2011-02-14 12:03:12 +01:00
|
|
|
* @param int $z_index is the z-index of the drag-drobable outer box of the event.
|
2008-06-07 19:45:33 +02:00
|
|
|
* @return string/array
|
2004-08-01 17:36:04 +02:00
|
|
|
*/
|
2011-02-14 12:03:12 +01:00
|
|
|
function eventWidget($event,$width,$indent,$owner,$return_array=false,$block='event_widget',$z_index=null)
|
2004-08-01 17:36:04 +02:00
|
|
|
{
|
2005-11-09 00:15:14 +01:00
|
|
|
if ($this->debug > 1 || $this->debug==='eventWidget') $this->bo->debug_message('uiviews::eventWidget(%1,width=%2)',False,$event,$width);
|
2004-08-01 17:36:04 +02:00
|
|
|
|
2009-08-04 19:14:16 +02:00
|
|
|
if($this->use_time_grid && $event['whole_day_on_top']) $block = 'event_widget_wholeday_on_top';
|
2006-10-17 22:01:08 +02:00
|
|
|
|
2004-08-01 17:36:04 +02:00
|
|
|
static $tpl = False;
|
|
|
|
if (!$tpl)
|
|
|
|
{
|
2010-01-19 23:17:01 +01:00
|
|
|
$tpl = new Template(common::get_tpl_dir('calendar'));
|
2008-06-07 19:45:33 +02:00
|
|
|
|
2004-08-01 17:36:04 +02:00
|
|
|
$tpl->set_file('event_widget_t','event_widget.tpl');
|
|
|
|
$tpl->set_block('event_widget_t','event_widget');
|
2006-10-17 22:01:08 +02:00
|
|
|
$tpl->set_block('event_widget_t','event_widget_wholeday_on_top');
|
2004-08-01 17:36:04 +02:00
|
|
|
$tpl->set_block('event_widget_t','event_tooltip');
|
2005-11-09 00:15:14 +01:00
|
|
|
$tpl->set_block('event_widget_t','planner_event');
|
2004-08-01 17:36:04 +02:00
|
|
|
}
|
2006-08-25 10:17:40 +02:00
|
|
|
if (($return_array || $event['start_m'] == 0) && $event['end_m'] >= 24*60-1)
|
2004-08-01 17:36:04 +02:00
|
|
|
{
|
2006-08-25 10:17:40 +02:00
|
|
|
if ($return_array && $event['end_m'] > 24*60)
|
|
|
|
{
|
|
|
|
$timespan = $this->bo->format_date($event['start'],false).' - '.$this->bo->format_date($event['end']);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$timespan = lang('all day');
|
|
|
|
}
|
2004-08-01 17:36:04 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-06-20 21:55:06 +02:00
|
|
|
$timespan = $this->bo->timespan($event['start_m'],$event['end_m']);
|
2004-08-01 17:36:04 +02:00
|
|
|
}
|
2013-01-14 15:16:11 +01:00
|
|
|
$icons = array();
|
2010-01-21 04:00:53 +01:00
|
|
|
if(!(int)$event['id'] && preg_match('/^([a-z_-]+)([0-9]+)$/i',$event['id'],$matches))
|
|
|
|
{
|
|
|
|
$app = $matches[1];
|
|
|
|
$app_id = $matches[2];
|
2010-01-22 00:36:05 +01:00
|
|
|
if (($is_private = calendar_bo::integration_get_private($app,$app_id,$event)))
|
2010-01-21 04:00:53 +01:00
|
|
|
{
|
|
|
|
$icons[] = html::image('calendar','private');
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-01-22 00:36:05 +01:00
|
|
|
$icons = self::integration_get_icons($app,$app_id,$event);
|
2010-01-21 04:00:53 +01:00
|
|
|
}
|
|
|
|
}
|
2011-08-03 17:12:07 +02:00
|
|
|
elseif($event['id'])
|
2010-01-21 04:00:53 +01:00
|
|
|
{
|
|
|
|
if (($is_private = !$this->bo->check_perms(EGW_ACL_READ,$event)))
|
|
|
|
{
|
|
|
|
$icons = array(html::image('calendar','private'));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-04-03 15:16:39 +02:00
|
|
|
$icons = $this->event_icons($event);
|
2010-01-21 04:00:53 +01:00
|
|
|
}
|
|
|
|
}
|
2009-11-26 09:28:06 +01:00
|
|
|
$cats = $this->bo->categories($this->categories->check_list(EGW_ACL_READ, $event['category']),$color);
|
2004-08-01 17:36:04 +02:00
|
|
|
// these values control varius aspects of the geometry of the eventWidget
|
|
|
|
$small_trigger_width = 120 + 20*count($icons);
|
|
|
|
$corner_radius=$width > $small_trigger_width ? 10 : 5;
|
|
|
|
$header_height=$width > $small_trigger_width ? 19 : 12; // multi_3 icon has a height of 19=16+2*1padding+1border !
|
2010-07-31 09:51:52 +02:00
|
|
|
if (!$return_array)
|
|
|
|
{
|
|
|
|
$height = $this->times2height($event['start_m'],$event['end_m'],$header_height);
|
|
|
|
}
|
2005-11-09 00:15:14 +01:00
|
|
|
//$body_height = max(0,$height - $header_height - $corner_radius);
|
2004-08-01 17:36:04 +02:00
|
|
|
$border=1;
|
|
|
|
$headerbgcolor = $color ? $color : '#808080';
|
2008-09-13 14:43:14 +02:00
|
|
|
$headercolor = self::brightness($headerbgcolor) > 128 ? 'black' : 'white';
|
2004-08-01 17:36:04 +02:00
|
|
|
// the body-colors (gradient) are calculated from the headercolor, which depends on the cat of an event
|
2006-06-02 21:38:08 +02:00
|
|
|
$bodybgcolor1 = $this->brighter($headerbgcolor,$headerbgcolor == '#808080' ? 100 : 170);
|
2004-08-01 17:36:04 +02:00
|
|
|
$bodybgcolor2 = $this->brighter($headerbgcolor,220);
|
2008-06-07 19:45:33 +02:00
|
|
|
|
2009-11-25 13:58:09 +01:00
|
|
|
// mark event as invitation, by NOT using category based background color, but plain white
|
2009-11-18 14:58:01 +01:00
|
|
|
if ($event['participants'][$this->user][0] == 'U')
|
|
|
|
{
|
|
|
|
$bodybgcolor1 = $bodybgcolor2 = 'white';
|
|
|
|
}
|
|
|
|
|
2013-11-11 15:02:08 +01:00
|
|
|
// get status class of event: calendar_calEventAllAccepted, calendar_calEventAllAnswered or calendar_calEventSomeUnknown
|
|
|
|
$status_class = 'calendar_calEventAllAccepted';
|
2009-11-18 14:58:01 +01:00
|
|
|
foreach($event['participants'] as $id => $status)
|
|
|
|
{
|
2012-11-13 10:53:06 +01:00
|
|
|
if ($id < 0) continue; // as we cant accept/reject groups, we dont care about them here
|
|
|
|
|
2009-11-18 14:58:01 +01:00
|
|
|
calendar_so::split_status($status,$quantity,$role);
|
|
|
|
|
|
|
|
switch ($status)
|
|
|
|
{
|
|
|
|
case 'A':
|
2010-01-21 04:00:53 +01:00
|
|
|
case '': // app without status
|
2009-11-18 14:58:01 +01:00
|
|
|
break;
|
|
|
|
case 'U':
|
2013-11-11 15:02:08 +01:00
|
|
|
$status_class = 'calendar_calEventSomeUnknown';
|
2009-11-18 14:58:01 +01:00
|
|
|
break 2; // break foreach
|
|
|
|
default:
|
2013-11-11 15:02:08 +01:00
|
|
|
$status_class = 'calendar_calEventAllAnswered';
|
2009-11-18 14:58:01 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2005-11-09 00:15:14 +01:00
|
|
|
// seperate each participant types
|
|
|
|
$part_array = array();
|
2009-08-03 11:51:35 +02:00
|
|
|
if ($this->allowEdit)
|
|
|
|
{
|
|
|
|
foreach($this->bo->participants($event) as $part_key => $participant)
|
|
|
|
{
|
|
|
|
if(is_numeric($part_key))
|
|
|
|
{
|
|
|
|
$part_array[lang('Participants')][$part_key] = $participant;
|
|
|
|
}
|
2009-08-04 19:14:16 +02:00
|
|
|
elseif(isset($this->bo->resources[$part_key[0]]))
|
2009-08-03 11:51:35 +02:00
|
|
|
{
|
2009-08-04 19:14:16 +02:00
|
|
|
$part_array[((isset($this->bo->resources[$part_key[0]]['participants_header'])) ? $this->bo->resources[$part_key[0]]['participants_header'] : lang($this->bo->resources[$part_key[0]]['app']))][$part_key] = $participant;
|
2009-08-03 11:51:35 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
foreach($part_array as $part_group => $participant)
|
|
|
|
{
|
2014-11-19 21:10:07 +01:00
|
|
|
$participants .= $this->add_nonempty($participant,$part_group,True,False,false);
|
2009-08-03 11:51:35 +02:00
|
|
|
}
|
|
|
|
}
|
2006-05-31 02:33:27 +02:00
|
|
|
// as we only deal with percentual widht, we consider only the full dayview (1 colum) as NOT small
|
|
|
|
$small = $this->view != 'day' || $width < 50;
|
|
|
|
// $small = $width <= $small_trigger_width
|
2006-06-02 21:38:08 +02:00
|
|
|
|
2008-06-07 19:45:33 +02:00
|
|
|
$small_height = $this->use_time_grid && ( $event['end_m']-$event['start_m'] < 2*$this->granularity_m ||
|
2006-06-02 21:38:08 +02:00
|
|
|
$event['end_m'] <= $this->wd_start || $event['start_m'] >= $this->wd_end);
|
|
|
|
|
2004-08-01 17:36:04 +02:00
|
|
|
$tpl->set_var(array(
|
|
|
|
// event-content, some of it displays only if it really has content or is needed
|
2008-03-20 09:54:18 +01:00
|
|
|
'owner' => $GLOBALS['egw']->common->grab_owner_name($event['owner']),
|
2006-05-31 02:33:27 +02:00
|
|
|
'header_icons' => $small ? '' : implode("",$icons),
|
|
|
|
'body_icons' => $small ? implode("\n",$icons) : '',
|
2006-06-02 21:38:08 +02:00
|
|
|
'icons' => implode('',$icons),
|
|
|
|
'timespan' => $timespan,
|
2008-03-21 21:30:19 +01:00
|
|
|
'title' => ($title = !$is_private ? html::htmlspecialchars($event['title']) : lang('private')),
|
2006-06-02 21:38:08 +02:00
|
|
|
'header' => $small_height ? $title : $timespan,
|
2008-03-21 21:30:19 +01:00
|
|
|
'description' => !$is_private ? nl2br(html::htmlspecialchars($event['description'])) : '',
|
2004-09-01 15:54:57 +02:00
|
|
|
'location' => !$is_private ? $this->add_nonempty($event['location'],lang('Location')) : '',
|
2005-11-09 00:15:14 +01:00
|
|
|
'participants' => $participants,
|
2006-06-20 21:55:06 +02:00
|
|
|
'times' => !$event['multiday'] ? $this->add_nonempty($this->bo->timespan($event['start_m'],$event['end_m'],true),lang('Time')) :
|
2006-03-03 09:50:17 +01:00
|
|
|
$this->add_nonempty($this->bo->format_date($event['start']),lang('Start')).
|
|
|
|
$this->add_nonempty($this->bo->format_date($event['end']),lang('End')),
|
2004-08-01 17:36:04 +02:00
|
|
|
'multidaytimes' => !$event['multiday'] ? '' :
|
2006-03-03 09:50:17 +01:00
|
|
|
$this->add_nonempty($this->bo->format_date($event['start']),lang('Start')).
|
|
|
|
$this->add_nonempty($this->bo->format_date($event['end']),lang('End')),
|
2004-09-01 15:54:57 +02:00
|
|
|
'category' => !$is_private ? $this->add_nonempty($cats,lang('Category')) : '',
|
2004-08-01 17:36:04 +02:00
|
|
|
// the tooltip is based on the content of the actual widget, this way it takes no extra bandwidth/volum
|
2008-03-21 21:30:19 +01:00
|
|
|
// 'tooltip' => html::tooltip(False,False,array('BorderWidth'=>0,'Padding'=>0)),
|
2004-08-01 17:36:04 +02:00
|
|
|
// various aspects of the geometry or style
|
|
|
|
'corner_radius' => $corner_radius.'px',
|
|
|
|
'header_height' => $header_height.'px',
|
2005-11-09 00:15:14 +01:00
|
|
|
//'body_height' => $body_height.'px',
|
2004-08-01 17:36:04 +02:00
|
|
|
'height' => $height,
|
|
|
|
'width' => ($width-20).'px',
|
|
|
|
'border' => $border,
|
|
|
|
'bordercolor' => $headerbgcolor,
|
|
|
|
'headerbgcolor' => $headerbgcolor,
|
2008-09-13 14:43:14 +02:00
|
|
|
'headercolor' => $headercolor,
|
2006-06-02 21:38:08 +02:00
|
|
|
'bodybackground' => ($background = 'url('.$GLOBALS['egw_info']['server']['webserver_url'].
|
2004-08-01 17:36:04 +02:00
|
|
|
'/calendar/inc/gradient.php?color1='.urlencode($bodybgcolor1).'&color2='.urlencode($bodybgcolor2).
|
2006-06-02 21:38:08 +02:00
|
|
|
'&width='.$width.') repeat-y '.$bodybgcolor2),
|
2006-05-31 02:33:27 +02:00
|
|
|
'Small' => $small ? 'Small' : '', // to use in css class-names
|
2006-06-02 21:38:08 +02:00
|
|
|
'indent' => $indent."\t",
|
2009-11-18 14:58:01 +01:00
|
|
|
'status_class' => $status_class,
|
2004-08-01 17:36:04 +02:00
|
|
|
));
|
2006-06-02 21:38:08 +02:00
|
|
|
/* not used at the moment
|
2004-08-01 17:36:04 +02:00
|
|
|
foreach(array(
|
|
|
|
'upper_left'=>array('width'=>-$corner_radius,'height'=>$header_height,'border'=>0,'bgcolor'=>$headerbgcolor),
|
|
|
|
'upper_right'=>array('width'=>$corner_radius,'height'=>$header_height,'border'=>0,'bgcolor'=>$headerbgcolor),
|
|
|
|
'lower_left'=>array('width'=>-$corner_radius,'height'=>-$corner_radius,'border'=>$border,'color'=>$headerbgcolor,'bgcolor'=>$bodybgcolor1),
|
|
|
|
'lower_right'=>array('width'=>$corner_radius,'height'=>-$corner_radius,'border'=>$border,'color'=>$headerbgcolor,'bgcolor'=>$bodybgcolor2),
|
|
|
|
) as $name => $data)
|
|
|
|
{
|
2005-11-09 00:15:14 +01:00
|
|
|
$tpl->set_var($name.'_corner',$GLOBALS['egw_info']['server']['webserver_url'].
|
2004-08-01 17:36:04 +02:00
|
|
|
'/calendar/inc/round_corners.php?width='.$data['width'].'&height='.$data['height'].
|
|
|
|
'&bgcolor='.urlencode($data['bgcolor']).
|
|
|
|
(isset($data['color']) ? '&color='.urlencode($data['color']) : '').
|
|
|
|
(isset($data['border']) ? '&border='.urlencode($data['border']) : ''));
|
|
|
|
}
|
2006-06-02 21:38:08 +02:00
|
|
|
*/
|
2014-10-27 16:02:21 +01:00
|
|
|
// Add event description to cal event view body if the event is long enough (ATM 3 times longer than interval)
|
2014-10-27 15:37:38 +01:00
|
|
|
// to be able to show some lines of description text
|
2014-10-27 16:02:21 +01:00
|
|
|
if ($event['whole_day'] || ($event['end'] - $event['start']) > ($this->cal_prefs['interval'] * 3 * 60))
|
2014-10-27 15:37:38 +01:00
|
|
|
{
|
|
|
|
$tpl->set_var('bodydescription', !$is_private ? nl2br(html::htmlspecialchars($event['description'])) : '');
|
|
|
|
}
|
2014-12-11 17:38:45 +01:00
|
|
|
// set the bodydescription to empty if it is not visible
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$tpl->set_var('bodydescription', '');
|
|
|
|
}
|
2014-11-19 21:10:07 +01:00
|
|
|
|
2004-08-01 17:36:04 +02:00
|
|
|
$tooltip = $tpl->fp('tooltip','event_tooltip');
|
2005-11-09 00:15:14 +01:00
|
|
|
$html = $tpl->fp('out',$block);
|
2004-08-01 17:36:04 +02:00
|
|
|
|
2010-01-19 23:17:01 +01:00
|
|
|
if ($is_private || !$this->allowEdit)
|
2008-02-07 14:59:34 +01:00
|
|
|
{
|
2010-01-19 23:17:01 +01:00
|
|
|
$popup = '';
|
|
|
|
}
|
2010-01-21 04:00:53 +01:00
|
|
|
elseif($app && $app_id)
|
2010-01-19 23:17:01 +01:00
|
|
|
{
|
2010-01-22 00:36:05 +01:00
|
|
|
$popup = $this->integration_get_popup($app,$app_id);
|
2008-02-07 14:59:34 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-01-09 10:38:55 +01:00
|
|
|
if ($event['recur_type'] != MCAL_RECUR_NONE)
|
|
|
|
{
|
|
|
|
$popup = $event['id']."|r";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$popup = $event['id']."|n";
|
|
|
|
}
|
2008-02-07 14:59:34 +01:00
|
|
|
}
|
2014-11-19 21:10:07 +01:00
|
|
|
$tooltip = html::htmlspecialchars($tooltip, true); // true=need double-encoding, as it is transported as attribute!
|
2008-02-07 14:59:34 +01:00
|
|
|
//_debug_array($event);
|
2008-06-07 19:45:33 +02:00
|
|
|
|
2005-11-09 00:15:14 +01:00
|
|
|
if ($return_array)
|
|
|
|
{
|
|
|
|
return array(
|
|
|
|
'tooltip' => $tooltip,
|
|
|
|
'popup' => $popup,
|
|
|
|
'html' => $html,
|
|
|
|
'private' => $is_private,
|
|
|
|
'color' => $color,
|
|
|
|
);
|
|
|
|
}
|
2010-02-02 12:23:11 +01:00
|
|
|
|
2013-12-13 19:18:56 +01:00
|
|
|
$draggableID = $event['id'].'_O'.$event['owner'].'_C'.($owner<0?str_replace('-','group',$owner):$owner);
|
2010-02-02 12:23:11 +01:00
|
|
|
|
2006-05-31 02:33:27 +02:00
|
|
|
if ($this->use_time_grid)
|
|
|
|
{
|
2006-10-17 22:01:08 +02:00
|
|
|
if($event['whole_day_on_top'])
|
|
|
|
{
|
|
|
|
$style = 'top: '.($this->rowHeight*$this->wholeDayPosCounter).'%; height: '.$this->rowHeight.'%;';
|
|
|
|
$this->wholeDayPosCounter++;
|
|
|
|
}
|
|
|
|
else
|
2010-01-19 23:17:01 +01:00
|
|
|
{ $view_link = $GLOBALS['egw']->link('/index.php',array('menuaction'=>'calendar.calendar_uiforms.edit','cal_id'=>$event['id'],'date'=>$this->bo->date2string($event['start'])));
|
2010-04-03 15:16:39 +02:00
|
|
|
|
2006-10-17 22:01:08 +02:00
|
|
|
$style = 'top: '.$this->time2pos($event['start_m']).'%; height: '.$height.'%;';
|
|
|
|
}
|
2006-05-31 02:33:27 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-06-02 21:38:08 +02:00
|
|
|
$style = 'position: relative; margin-top: 3px;';
|
2006-05-31 02:33:27 +02:00
|
|
|
}
|
2006-12-15 21:05:47 +01:00
|
|
|
|
2010-12-22 16:17:56 +01:00
|
|
|
$prefix_icon = isset($event['prepend_icon']) ? $event['prepend_icon'] : '';
|
2011-03-28 12:41:23 +02:00
|
|
|
|
2011-02-14 12:03:12 +01:00
|
|
|
$z_index = is_null($z_index) ? 20 : (int)$z_index;
|
2010-12-22 16:17:56 +01:00
|
|
|
|
2013-12-19 11:19:14 +01:00
|
|
|
if ($this->use_time_grid &&
|
2014-08-21 16:26:27 +02:00
|
|
|
((int)$event['id'] || substr($event['id'],0,7) == 'infolog') && $this->bo->check_perms(EGW_ACL_EDIT,$event))
|
2011-02-14 12:58:43 +01:00
|
|
|
{
|
|
|
|
if (!$event['whole_day_on_top'] &&
|
|
|
|
!$event['whole_day'] &&
|
|
|
|
!$event['recur_type'])
|
|
|
|
{
|
2013-12-13 19:18:56 +01:00
|
|
|
$draggableID = 'drag_'.$event['id'].'_O'.$event['owner'].'_C'.($owner<0?str_replace('-','group',$owner):$owner);
|
2011-02-14 12:58:43 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-01-24 13:50:20 +01:00
|
|
|
$draggableID = 'drag_'.$event['id'].'_O'.$event['owner'].'_C'.($owner<0?str_replace('-','group',$owner):$owner);
|
2013-12-13 19:18:56 +01:00
|
|
|
|
2011-02-14 12:58:43 +01:00
|
|
|
}
|
2006-12-15 21:05:47 +01:00
|
|
|
}
|
2014-01-24 13:50:20 +01:00
|
|
|
if (!$event['whole_day_on_top'] &&
|
|
|
|
!$event['whole_day'])
|
|
|
|
{
|
2014-08-25 12:30:52 +02:00
|
|
|
// S represents Series
|
|
|
|
// '' represents Single
|
|
|
|
$eventTypeTag = $event['recur_type']?'S':'';
|
|
|
|
}
|
|
|
|
else if (!$event['recur_type'])
|
|
|
|
{
|
|
|
|
// WD represents Whole Day
|
|
|
|
$eventTypeTag = 'WD';
|
2014-01-24 13:50:20 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-08-25 12:30:52 +02:00
|
|
|
// WDS represents Whole Day Series (recurrent whole day event)
|
|
|
|
$eventTypeTag = 'WDS';
|
2014-01-24 13:50:20 +01:00
|
|
|
}
|
2014-08-25 12:30:52 +02:00
|
|
|
// Helps client-side to bind handler to events with specific types tag
|
|
|
|
$resizableHelper = $this->bo->date2string($event['start']). '|' .$this->bo->format_date($event['start'],false) . '|' . $this->cal_prefs['interval'].'|'.$eventTypeTag;
|
2014-10-20 11:14:24 +02:00
|
|
|
|
2014-01-24 13:50:20 +01:00
|
|
|
$html = $indent.'<div id="'.$draggableID.'" data-tooltip ="'.$tooltip .'" data-resize="'.$resizableHelper.'" class="calendar_calEvent'.($is_private ? 'Private' : '').' '.$status_class.
|
2011-02-14 12:58:43 +01:00
|
|
|
'" style="'.$style.' border-color: '.$headerbgcolor.'; background: '.$background.'; z-index: '.$z_index.';"'.
|
2014-01-06 16:36:49 +01:00
|
|
|
'>'.$prefix_icon."\n".$html."\n".
|
2011-02-14 12:58:43 +01:00
|
|
|
$indent."</div>"."\n";
|
|
|
|
|
2006-12-15 21:05:47 +01:00
|
|
|
return $html;
|
2004-08-01 17:36:04 +02:00
|
|
|
}
|
2010-04-03 15:16:39 +02:00
|
|
|
|
2010-01-22 00:36:05 +01:00
|
|
|
/**
|
|
|
|
* Get onclick attribute to open integration item for edit
|
2010-04-03 15:16:39 +02:00
|
|
|
*
|
2010-01-22 00:36:05 +01:00
|
|
|
* Name of the attribute is 'edit_link' and it should be an array with values for keys:
|
|
|
|
* - 'edit' => array('menuaction' => 'app.class.method')
|
|
|
|
* - 'edit_id' => 'app_id'
|
|
|
|
* - 'edit_popup' => '400x300' (optional)
|
2010-04-03 15:16:39 +02:00
|
|
|
*
|
2010-01-22 00:36:05 +01:00
|
|
|
* @param string $app
|
|
|
|
* @param int|string $id
|
|
|
|
* @return string
|
|
|
|
*/
|
2015-07-03 11:10:01 +02:00
|
|
|
public static function integration_get_popup($app,$id)
|
2010-01-22 00:36:05 +01:00
|
|
|
{
|
|
|
|
$app_data = calendar_bo::integration_get_data($app,'edit_link');
|
2010-04-03 15:16:39 +02:00
|
|
|
|
2010-01-22 00:36:05 +01:00
|
|
|
if (is_array($app_data) && isset($app_data['edit']))
|
|
|
|
{
|
|
|
|
$popup_size = $app_data['edit_popup'];
|
|
|
|
$edit = $app_data['edit'];
|
|
|
|
$edit[$app_data['edit_id']] = $id;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$edit = egw_link::edit($app,$id,$popup_size);
|
|
|
|
}
|
|
|
|
if ($edit)
|
|
|
|
{
|
|
|
|
$view_link = egw::link('/index.php',$edit);
|
2010-04-03 15:16:39 +02:00
|
|
|
|
2010-01-22 00:36:05 +01:00
|
|
|
if ($popup_size)
|
|
|
|
{
|
2014-01-17 11:28:15 +01:00
|
|
|
$popup = ' data-app="app|'.$popup_size.'"';
|
2010-01-22 00:36:05 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-01-17 11:28:15 +01:00
|
|
|
$popup = ' data-app="app|'.$app.'|'.'"';
|
2010-01-22 00:36:05 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return $popup;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get icons for an integration event
|
2010-04-03 15:16:39 +02:00
|
|
|
*
|
|
|
|
* Attribute 'icons' is either null (--> navbar icon), false (--> no icon)
|
2010-01-22 00:36:05 +01:00
|
|
|
* or a callback with parameters $id,$event
|
2010-04-03 15:16:39 +02:00
|
|
|
*
|
2010-01-22 00:36:05 +01:00
|
|
|
* Icons specified in $events['icons'] are always displayed!
|
2010-04-03 15:16:39 +02:00
|
|
|
*
|
2010-01-22 00:36:05 +01:00
|
|
|
* @param string $app
|
|
|
|
* @param int|string $id
|
|
|
|
* @param array $event
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
static function integration_get_icons($app,$id,$event)
|
|
|
|
{
|
|
|
|
$icons = array();
|
|
|
|
if ($event['icons'])
|
|
|
|
{
|
|
|
|
foreach(explode(',',$event['icons']) as $icon)
|
|
|
|
{
|
|
|
|
list($icon_app,$icon) = explode(':',$icon);
|
|
|
|
if (common::find_image($icon_app,$icon))
|
|
|
|
{
|
|
|
|
$icons[] = html::image($icon_app,$icon);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$app_data = calendar_bo::integration_get_data($app,'icons');
|
|
|
|
if (is_null($app_data))
|
|
|
|
{
|
|
|
|
$icons[] = html::image($app,'navbar'); // use navbar icon
|
|
|
|
}
|
|
|
|
elseif ($app_data)
|
|
|
|
{
|
|
|
|
$icons += (array)ExecMethod2($app_data,$id,$event);
|
|
|
|
}
|
|
|
|
return $icons;
|
|
|
|
}
|
2004-08-01 17:36:04 +02:00
|
|
|
|
2014-11-19 21:10:07 +01:00
|
|
|
function add_nonempty($content,$label,$one_per_line=False,$space = True,$htmlspecialchars=true)
|
2004-08-01 17:36:04 +02:00
|
|
|
{
|
|
|
|
if (is_array($content))
|
|
|
|
{
|
2006-12-07 09:55:08 +01:00
|
|
|
if($space)
|
|
|
|
{
|
|
|
|
$content = implode($one_per_line ? ",\n" : ', ',$content);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$content = implode($one_per_line ? "\n" : ', ',$content);
|
|
|
|
}
|
2004-08-01 17:36:04 +02:00
|
|
|
}
|
|
|
|
if (!empty($content))
|
|
|
|
{
|
2013-11-11 15:02:08 +01:00
|
|
|
return '<span class="calendar_calEventLabel">'.$label.'</span>:'.
|
2004-08-01 17:36:04 +02:00
|
|
|
($one_per_line ? '<br>' : ' ').
|
2014-11-19 21:10:07 +01:00
|
|
|
nl2br($htmlspecialchars?html::htmlspecialchars($content):$content).'<br>';
|
2004-08-01 17:36:04 +02:00
|
|
|
}
|
|
|
|
return '';
|
|
|
|
}
|
2016-03-18 16:49:11 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Calculates a brighter color for a given color
|
|
|
|
*
|
|
|
|
* @param $rgb string color as #rrggbb value
|
|
|
|
* @param $decr int value to add to each component, default 64
|
|
|
|
* @return string the brighter color
|
|
|
|
*/
|
|
|
|
static function brighter($rgb,$decr=64)
|
|
|
|
{
|
|
|
|
if (!preg_match('/^#?([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})$/',$rgb,$components))
|
|
|
|
{
|
|
|
|
return '#ffffff';
|
|
|
|
}
|
|
|
|
$brighter = '#';
|
|
|
|
for ($i = 1; $i <=3; ++$i)
|
|
|
|
{
|
|
|
|
$val = hexdec($components[$i]) + $decr;
|
|
|
|
if ($val > 255) $val = 255;
|
|
|
|
$brighter .= sprintf('%02x',$val);
|
|
|
|
}
|
|
|
|
//echo "brighter($rgb=".print_r($components,True).")=$brighter</p>\n";
|
|
|
|
return $brighter;
|
|
|
|
}
|
2008-06-07 19:45:33 +02:00
|
|
|
|
2008-09-13 14:43:14 +02:00
|
|
|
/**
|
|
|
|
* Calculates the brightness of a hexadecimal rgb color (median of the r, g and b components)
|
|
|
|
*
|
|
|
|
* @param string $rgb eg. #808080
|
|
|
|
* @return int between 0 and 255
|
|
|
|
*/
|
|
|
|
static function brightness($rgb)
|
|
|
|
{
|
|
|
|
if ($rgb[0] != '#' || strlen($rgb) != 7)
|
|
|
|
{
|
|
|
|
return 128; // no rgb color, return some default
|
|
|
|
}
|
|
|
|
$dec = hexdec(substr($rgb,1));
|
|
|
|
for($i = 0; $i < 24; $i += 8)
|
|
|
|
{
|
|
|
|
$sum += ($dec >> $i) & 255;
|
|
|
|
}
|
|
|
|
return (int)round($sum / 3.0, 0);
|
|
|
|
}
|
|
|
|
|
2010-01-17 03:03:11 +01:00
|
|
|
/**
|
|
|
|
* Number of month to display in yearly planner
|
|
|
|
*/
|
|
|
|
const YEARLY_PLANNER_NUM_MONTH = 12;
|
2008-06-07 19:45:33 +02:00
|
|
|
|
2004-08-01 17:36:04 +02:00
|
|
|
/**
|
2005-11-09 00:15:14 +01:00
|
|
|
* Creates a planner view: grid with columns for the time and rows for categories or users
|
2004-08-01 17:36:04 +02:00
|
|
|
*
|
2005-11-09 00:15:14 +01:00
|
|
|
* Uses the plannerRowWidget to display rows
|
|
|
|
*
|
|
|
|
* @param array $events events to show
|
|
|
|
* @param mixed $start start-time of the grid
|
|
|
|
* @param mixed $end end-time of the grid
|
2010-01-15 04:53:12 +01:00
|
|
|
* @param string|int $by_cat rows by sub-categories of $by_cat (cat_id or 0 for upmost level) or by 'user' or 'month'
|
2014-11-05 17:13:26 +01:00
|
|
|
* @param string $indent = '' string for correct indention
|
2005-11-09 00:15:14 +01:00
|
|
|
* @return string with widget
|
2004-08-01 17:36:04 +02:00
|
|
|
*/
|
2010-01-15 04:53:12 +01:00
|
|
|
function &plannerWidget(&$events,$start,$end,$by_cat=0,$indent='')
|
2004-08-01 17:36:04 +02:00
|
|
|
{
|
2013-11-11 15:02:08 +01:00
|
|
|
$content = $indent.'<div class="calendar_plannerWidget">'."\n";
|
2008-06-07 19:45:33 +02:00
|
|
|
|
2005-11-09 00:15:14 +01:00
|
|
|
// display the header, containing a headerTitle and multiple headerRows with the scales
|
2013-11-11 15:02:08 +01:00
|
|
|
$content .= $indent."\t".'<div class="calendar_plannerHeader">'."\n";
|
2010-01-15 04:53:12 +01:00
|
|
|
|
|
|
|
// display the headerTitle, and get sort2labels
|
|
|
|
switch($by_cat)
|
|
|
|
{
|
|
|
|
case 'user':
|
|
|
|
$title = lang('User');
|
|
|
|
$sort2label = $this->_get_planner_users();
|
|
|
|
break;
|
|
|
|
case 'month':
|
|
|
|
$title = lang('Month');
|
|
|
|
$sort2label = array();
|
|
|
|
$time = new egw_time($start);
|
2010-01-17 03:03:11 +01:00
|
|
|
for($n = 0; $n < self::YEARLY_PLANNER_NUM_MONTH; ++$n)
|
2010-01-15 04:53:12 +01:00
|
|
|
{
|
|
|
|
$sort2label[$time->format('Y-m')] = lang($time->format('F')).' '.$time->format('Y');
|
|
|
|
$time->modify('+1 month');
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
$title = lang('Category');
|
|
|
|
$sort2label = array();
|
|
|
|
break;
|
|
|
|
}
|
2013-11-11 15:02:08 +01:00
|
|
|
$content .= $indent."\t\t".'<div class="calendar_plannerHeaderTitle th">'.$title."</div>\n";
|
2008-06-07 19:45:33 +02:00
|
|
|
|
2005-11-09 00:15:14 +01:00
|
|
|
// display the headerRows with the scales
|
2013-11-11 15:02:08 +01:00
|
|
|
$content .= $indent."\t\t".'<div class="calendar_plannerHeaderRows">'."\n";
|
2005-11-09 00:15:14 +01:00
|
|
|
// set start & end to timestamp and first & last to timestamp of 12h midday, to avoid trouble with daylight saving
|
|
|
|
foreach(array('start' => 'first','end' => 'last') as $t => $v)
|
|
|
|
{
|
|
|
|
$$t = $this->bo->date2ts($$t);
|
|
|
|
$$v = $this->bo->date2array($$t);
|
|
|
|
unset(${$v}['raw']);
|
|
|
|
${$v}['hour'] = 12;
|
|
|
|
${$v}['minute'] = ${$v}['second'] = 0;
|
|
|
|
${$v} = $this->bo->date2ts($$v);
|
2004-08-01 17:36:04 +02:00
|
|
|
}
|
2010-01-15 04:53:12 +01:00
|
|
|
if ($by_cat === 'month')
|
2005-11-09 00:15:14 +01:00
|
|
|
{
|
2010-01-15 04:53:12 +01:00
|
|
|
$content .= $this->plannerDayOfMonthScale($indent."\t\t\t");
|
2005-11-09 00:15:14 +01:00
|
|
|
}
|
2010-01-15 04:53:12 +01:00
|
|
|
else
|
2004-08-01 17:36:04 +02:00
|
|
|
{
|
2010-01-15 04:53:12 +01:00
|
|
|
$days = 1 + (int) round(($last - $first) / DAY_s); // we have to use round to get the right number if daylight saving changes
|
|
|
|
if ($days >= 28) // display the month scale
|
|
|
|
{
|
|
|
|
$content .= $this->plannerMonthScale($first,$days,$indent."\t\t\t");
|
|
|
|
}
|
|
|
|
if ($days >= 5) // display the week scale
|
|
|
|
{
|
|
|
|
$content .= $this->plannerWeekScale($first,$days,$indent."\t\t\t");
|
|
|
|
}
|
|
|
|
$content .= $this->plannerDayScale($first,$days,$indent."\t\t\t"); // day-scale, always displayed
|
|
|
|
if ($days <= 7) // display the hour scale
|
|
|
|
{
|
|
|
|
$content .= $this->plannerHourScale($start,$days,$indent."\t\t\t");
|
|
|
|
}
|
2005-11-09 00:15:14 +01:00
|
|
|
}
|
|
|
|
$content .= $indent."\t\t</div>\n"; // end of the plannerHeaderRows
|
|
|
|
$content .= $indent."\t</div>\n"; // end of the plannerHeader
|
2008-06-07 19:45:33 +02:00
|
|
|
|
2005-11-09 00:15:14 +01:00
|
|
|
// sort the events after user or category
|
2010-01-15 04:53:12 +01:00
|
|
|
$rows = array();
|
2007-01-03 09:13:10 +01:00
|
|
|
if (!is_array($events)) $events = array();
|
|
|
|
|
2010-04-03 15:16:39 +02:00
|
|
|
if ($by_cat === 'user') // planner by user
|
|
|
|
{
|
|
|
|
// convert filter to allowed status
|
|
|
|
switch($this->filter)
|
|
|
|
{
|
|
|
|
case 'unknown':
|
|
|
|
$status_to_show = array('U','G'); break;
|
|
|
|
case 'accepted':
|
|
|
|
$status_to_show = array('A'); break;
|
|
|
|
case 'tentative':
|
|
|
|
$status_to_show = array('T'); break;
|
|
|
|
case 'rejected':
|
|
|
|
$status_to_show = array('R'); break;
|
|
|
|
case 'delegated':
|
|
|
|
$status_to_show = array('D'); break;
|
|
|
|
case 'all':
|
|
|
|
$status_to_show = array('U','A','T','D','G','R'); break;
|
|
|
|
default:
|
|
|
|
$status_to_show = array('U','A','T','D','G'); break;
|
|
|
|
}
|
|
|
|
}
|
2005-11-09 00:15:14 +01:00
|
|
|
foreach($events as $key => $event)
|
|
|
|
{
|
2010-01-15 04:53:12 +01:00
|
|
|
if ($by_cat === 'user') // planner by user
|
2005-11-09 00:15:14 +01:00
|
|
|
{
|
|
|
|
foreach($event['participants'] as $sort => $status)
|
|
|
|
{
|
2010-04-03 15:16:39 +02:00
|
|
|
calendar_so::split_status($status,$nul,$nul);
|
|
|
|
// only show if participant with status visible with current filter
|
|
|
|
if (isset($sort2label[$sort]) && (in_array($status,$status_to_show) ||
|
|
|
|
$this->filter == 'owner' && $event['owner'] == $sort)) // owner too additionally uses owner
|
2005-11-09 00:15:14 +01:00
|
|
|
{
|
|
|
|
$rows[$sort][] =& $events[$key];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-01-15 04:53:12 +01:00
|
|
|
elseif ($by_cat === 'month') // planner by month / yearly planner
|
|
|
|
{
|
|
|
|
$sort = date('Y-m',$event['start']);
|
|
|
|
$rows[$sort][] =& $events[$key];
|
|
|
|
// end in a different month?
|
|
|
|
if ($sort != ($end_sort = date('Y-m',$event['end'])))
|
|
|
|
{
|
2010-01-15 05:08:10 +01:00
|
|
|
while($sort != $end_sort)
|
|
|
|
{
|
|
|
|
list($y,$m) = explode('-',$sort);
|
|
|
|
if (++$m > 12)
|
|
|
|
{
|
|
|
|
++$y;
|
|
|
|
$m = 1;
|
|
|
|
}
|
|
|
|
$sort = sprintf('%04d-%02d',$y,$m);
|
|
|
|
$rows[$sort][] =& $events[$key];
|
|
|
|
}
|
2010-01-15 04:53:12 +01:00
|
|
|
}
|
|
|
|
}
|
2005-11-09 00:15:14 +01:00
|
|
|
else // planner by cat
|
|
|
|
{
|
|
|
|
foreach($this->_get_planner_cats($event['category'],$sort2label,$sort2color) as $sort)
|
|
|
|
{
|
|
|
|
if (!is_array($rows[$sort])) $rows[$sort] = array();
|
|
|
|
|
|
|
|
$rows[$sort][] =& $events[$key];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-01-05 05:12:13 +01:00
|
|
|
$owners = explode(',',$this->owner);
|
2005-11-09 00:15:14 +01:00
|
|
|
// display a plannerRowWidget for each row (user or category)
|
|
|
|
foreach($sort2label as $sort => $label)
|
|
|
|
{
|
2007-03-09 12:26:22 +01:00
|
|
|
if (!isset($rows[$sort]) && (!$this->cal_prefs['planner_show_empty_rows'] ||
|
2010-01-15 04:53:12 +01:00
|
|
|
$by_cat === 'user' && $this->cal_prefs['planner_show_empty_rows'] == 'cat' ||
|
|
|
|
is_int($by_cat) && $this->cal_prefs['planner_show_empty_rows'] == 'user'))
|
2007-03-09 12:26:22 +01:00
|
|
|
{
|
|
|
|
continue; // dont show empty categories or user rows
|
|
|
|
}
|
2005-11-09 00:15:14 +01:00
|
|
|
$class = $class == 'row_on' ? 'row_off' : 'row_on';
|
2010-01-15 04:53:12 +01:00
|
|
|
if ($by_cat === 'month')
|
|
|
|
{
|
|
|
|
$time = new egw_time($sort.'-01');
|
|
|
|
$start = $time->format('ts');
|
|
|
|
$time->modify('+1month -1second');
|
|
|
|
$end = $time->format('ts');
|
|
|
|
}
|
2012-01-05 05:12:13 +01:00
|
|
|
// display close button only for directly set users, eg. not group-members (as we cant unset them!)
|
|
|
|
if ($by_cat === 'user' && in_array($sort, $owners))
|
|
|
|
{
|
|
|
|
$label .= $this->close_button($sort);
|
|
|
|
}
|
2005-11-09 00:15:14 +01:00
|
|
|
$content .= $this->plannerRowWidget(isset($rows[$sort]) ? $rows[$sort] : array(),$start,$end,$label,$class,$indent."\t");
|
|
|
|
}
|
|
|
|
$content .= $indent."</div>\n"; // end of the plannerWidget
|
2008-06-07 19:45:33 +02:00
|
|
|
|
2005-11-09 00:15:14 +01:00
|
|
|
return $content;
|
|
|
|
}
|
2008-06-07 19:45:33 +02:00
|
|
|
|
2005-11-09 00:15:14 +01:00
|
|
|
/**
|
|
|
|
* get all users to display in the planner_by_user
|
|
|
|
*
|
2014-11-05 17:13:26 +01:00
|
|
|
* @param boolean $enum_groups = true should groups be returned as there members (eg. planner) or not (day & week)
|
2006-03-09 13:32:41 +01:00
|
|
|
* @return array with uid => label pairs, first all users alphabetically sorted, then all resources
|
2005-11-09 00:15:14 +01:00
|
|
|
*/
|
2006-03-09 13:32:41 +01:00
|
|
|
function _get_planner_users($enum_groups=true)
|
2005-11-09 00:15:14 +01:00
|
|
|
{
|
2006-03-09 13:32:41 +01:00
|
|
|
$users = $resources = array();
|
2005-11-09 00:15:14 +01:00
|
|
|
foreach(explode(',',$this->owner) as $user)
|
|
|
|
{
|
2015-03-19 16:00:24 +01:00
|
|
|
if($user === '0')
|
|
|
|
{
|
|
|
|
// 0 means current user
|
|
|
|
$user = $this->user;
|
|
|
|
}
|
2006-03-09 13:32:41 +01:00
|
|
|
if (!is_numeric($user)) // resources
|
|
|
|
{
|
|
|
|
$resources[$user] = $this->bo->participant_name($user);
|
|
|
|
}
|
|
|
|
elseif ($enum_groups && $GLOBALS['egw']->accounts->get_type($user) == 'g') // groups
|
2005-11-09 00:15:14 +01:00
|
|
|
{
|
2016-03-06 17:09:58 +01:00
|
|
|
foreach((array) $GLOBALS['egw']->accounts->members($user, true) as $user)
|
2005-11-09 00:15:14 +01:00
|
|
|
{
|
2010-10-12 16:33:19 +02:00
|
|
|
if ($this->bo->check_perms(EGW_ACL_READ | EGW_ACL_FREEBUSY,0,$user))
|
2005-11-09 00:15:14 +01:00
|
|
|
{
|
|
|
|
$users[$user] = $this->bo->participant_name($user);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-03-09 13:32:41 +01:00
|
|
|
else // users
|
2005-11-09 00:15:14 +01:00
|
|
|
{
|
|
|
|
$users[$user] = $this->bo->participant_name($user);
|
|
|
|
}
|
|
|
|
}
|
2014-11-05 17:13:26 +01:00
|
|
|
// Only sort users in planner views
|
|
|
|
if ($enum_groups)
|
|
|
|
{
|
|
|
|
asort($users);
|
|
|
|
asort($resources);
|
|
|
|
}
|
2014-11-19 21:10:07 +01:00
|
|
|
|
2006-03-09 13:32:41 +01:00
|
|
|
return $users+$resources;
|
2005-11-09 00:15:14 +01:00
|
|
|
}
|
2008-06-07 19:45:33 +02:00
|
|
|
|
2005-11-09 00:15:14 +01:00
|
|
|
/**
|
|
|
|
* get all categories used as sort criteria for the planner by category
|
2008-06-07 19:45:33 +02:00
|
|
|
*
|
2005-11-09 00:15:14 +01:00
|
|
|
* the returned cat is as direct sub-category of $this->cat_id or a main (level 1) category if !$this->cat_id
|
|
|
|
*
|
|
|
|
* @param string $cats comma-delimited cat_id's or empty for no cat
|
|
|
|
* @param array &$sort2label labels for the returned cats
|
|
|
|
* @return array with cat_id's
|
|
|
|
*/
|
|
|
|
function _get_planner_cats($cats,&$sort2label)
|
|
|
|
{
|
|
|
|
static $cat2sort;
|
2008-06-07 19:45:33 +02:00
|
|
|
|
2005-11-09 00:15:14 +01:00
|
|
|
if (!is_array($cat2sort))
|
|
|
|
{
|
|
|
|
$cat2sort = array();
|
2014-10-20 11:14:24 +02:00
|
|
|
$cat_filter = $this->cat_id ? (array)$this->cat_id : array();
|
2010-10-06 18:25:27 +02:00
|
|
|
foreach((array)$this->categories->return_sorted_array(0,false,'','','',true) as $data)
|
2005-11-09 00:15:14 +01:00
|
|
|
{
|
2014-10-20 11:14:24 +02:00
|
|
|
if (in_array($data['parent'], $cat_filter) || in_array($data['id'], $cat_filter) ||
|
|
|
|
!$data['parent'] && !$cat_filter) // cat is a direct sub of $this->cat_id
|
2005-11-09 00:15:14 +01:00
|
|
|
{
|
|
|
|
$cat2sort[$data['id']] = $data['id'];
|
|
|
|
$sort2label[$data['id']] = stripslashes($data['name']);
|
|
|
|
}
|
|
|
|
elseif(isset($cat2sort[$data['parent']])) // parent is already in the array => add us with same target
|
|
|
|
{
|
|
|
|
$cat2sort[$data['id']] = $cat2sort[$data['parent']];
|
2008-06-07 19:45:33 +02:00
|
|
|
}
|
2005-11-09 00:15:14 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
$ret = array();
|
|
|
|
foreach(!is_array($cats) ? explode(',',$cats) : $cats as $cat)
|
|
|
|
{
|
|
|
|
if (isset($cat2sort[$cat]) && !in_array($cat2sort[$cat],$ret))
|
|
|
|
{
|
|
|
|
$ret[] = $cat2sort[$cat];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!count($ret))
|
|
|
|
{
|
|
|
|
$sort2label[0] = lang('none');
|
|
|
|
$ret[] = 0;
|
|
|
|
}
|
2009-11-25 13:58:09 +01:00
|
|
|
//echo "<p>uiviews::_get_planner_cats($cats=".$this->categories->id2name($cats).") (this->cat_id=$this->cat_id) = ".print_r($ret,true).'='.$this->categories->id2name($ret[0])."</p>\n";
|
2005-11-09 00:15:14 +01:00
|
|
|
return $ret;
|
|
|
|
}
|
2004-09-30 15:38:23 +02:00
|
|
|
|
2005-11-09 00:15:14 +01:00
|
|
|
/**
|
|
|
|
* Creates month scale for the planner
|
|
|
|
*
|
|
|
|
* @param int $start start-time (12h) of the scale
|
|
|
|
* @param int $days number of days to display
|
2014-11-05 17:13:26 +01:00
|
|
|
* @param string $indent = '' string for correct indention
|
2005-11-09 00:15:14 +01:00
|
|
|
* @return string with scale
|
|
|
|
*/
|
|
|
|
function plannerMonthScale($start,$days,$indent)
|
2004-08-01 17:36:04 +02:00
|
|
|
{
|
2005-11-09 00:15:14 +01:00
|
|
|
$day_width = round(100 / $days,2);
|
|
|
|
|
2013-11-11 15:02:08 +01:00
|
|
|
$content .= $indent.'<div class="calendar_plannerScale">'."\n";
|
2005-11-09 00:15:14 +01:00
|
|
|
for($t = $start,$left = 0,$i = 0; $i < $days; $t += $days_in_month*DAY_s,$left += $days_in_month*$day_width,$i += $days_in_month)
|
|
|
|
{
|
|
|
|
$t_arr = $this->bo->date2array($t);
|
|
|
|
unset($t_arr['raw']); // force recalculation
|
|
|
|
unset($t_arr['full']);
|
|
|
|
$days_in_month = $this->datetime->days_in_month($t_arr['month'],$t_arr['year']) - ($t_arr['day']-1);
|
|
|
|
if ($i + $days_in_month > $days)
|
|
|
|
{
|
|
|
|
$days_in_month = $days - $i;
|
|
|
|
}
|
|
|
|
if ($days_in_month > 10)
|
|
|
|
{
|
|
|
|
$title = lang(date('F',$t)).' '.$t_arr['year'];
|
|
|
|
// previous links
|
|
|
|
$prev = $t_arr;
|
|
|
|
$prev['day'] = 1;
|
|
|
|
if ($prev['month']-- <= 1)
|
|
|
|
{
|
|
|
|
$prev['month'] = 12;
|
|
|
|
$prev['year']--;
|
|
|
|
}
|
|
|
|
if ($this->bo->date2ts($prev) < $start-20*DAY_s)
|
|
|
|
{
|
|
|
|
$prev['day'] = $this->day;
|
|
|
|
$full = $this->bo->date2string($prev);
|
|
|
|
if ($this->day >= 15) $prev = $t_arr; // we stay in the same month
|
|
|
|
$prev['day'] = $this->day < 15 ? 15 : 1;
|
|
|
|
$half = $this->bo->date2string($prev);
|
2009-07-24 12:34:20 +02:00
|
|
|
$title = html::a_href(html::image('phpgwapi','first',lang('back one month'),$options=' alt="<<"'),array(
|
2005-11-09 00:15:14 +01:00
|
|
|
'menuaction' => $this->view_menuaction,
|
|
|
|
'date' => $full,
|
|
|
|
)) . ' '.
|
2009-07-24 12:34:20 +02:00
|
|
|
html::a_href(html::image('phpgwapi','left',lang('back half a month'),$options=' alt="<"'),array(
|
2005-11-09 00:15:14 +01:00
|
|
|
'menuaction' => $this->view_menuaction,
|
|
|
|
'date' => $half,
|
|
|
|
)) . ' '.$title;
|
|
|
|
}
|
|
|
|
// next links
|
|
|
|
$next = $t_arr;
|
|
|
|
if ($next['month']++ >= 12)
|
|
|
|
{
|
|
|
|
$next['month'] = 1;
|
|
|
|
$next['year']++;
|
|
|
|
}
|
2005-11-12 18:57:18 +01:00
|
|
|
// dont show next scales, if there are more then 10 days in the next month or there is no next month
|
|
|
|
$days_in_next_month = (int) date('d',$end = $start+$days*DAY_s);
|
|
|
|
if ($days_in_next_month <= 10 || date('m',$end) == date('m',$t))
|
2005-11-09 00:15:14 +01:00
|
|
|
{
|
|
|
|
if ($this->day >= 15) $next = $t_arr; // we stay in the same month
|
|
|
|
$next['day'] = $this->day;
|
|
|
|
$full = $this->bo->date2string($next);
|
|
|
|
if ($this->day < 15) $next = $t_arr; // we stay in the same month
|
|
|
|
$next['day'] = $this->day < 15 ? 15 : 1;
|
|
|
|
$half = $this->bo->date2string($next);
|
2009-07-24 12:34:20 +02:00
|
|
|
$title .= ' '.html::a_href(html::image('phpgwapi','right',lang('forward half a month'),$options=' alt=">>"'),array(
|
2005-11-09 00:15:14 +01:00
|
|
|
'menuaction' => $this->view_menuaction,
|
|
|
|
'date' => $half,
|
|
|
|
)). ' '.
|
2009-07-24 12:34:20 +02:00
|
|
|
html::a_href(html::image('phpgwapi','last',lang('forward one month'),$options=' alt=">>"'),array(
|
2005-11-09 00:15:14 +01:00
|
|
|
'menuaction' => $this->view_menuaction,
|
|
|
|
'date' => $full,
|
|
|
|
));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$title = ' ';
|
|
|
|
}
|
|
|
|
$class = $class == 'row_on' ? 'th' : 'row_on';
|
2013-11-11 15:02:08 +01:00
|
|
|
$content .= $indent."\t".'<div class="calendar_plannerMonthScale '.$class.'" style="left: '.$left.'%; width: '.($day_width*$days_in_month).'%;">'.
|
2005-11-09 00:15:14 +01:00
|
|
|
$title."</div>\n";
|
|
|
|
}
|
|
|
|
$content .= $indent."</div>\n"; // end of plannerScale
|
|
|
|
|
|
|
|
return $content;
|
2004-08-01 17:36:04 +02:00
|
|
|
}
|
2008-06-07 19:45:33 +02:00
|
|
|
|
2005-11-09 00:15:14 +01:00
|
|
|
/**
|
|
|
|
* Creates a week scale for the planner
|
|
|
|
*
|
|
|
|
* @param int $start start-time (12h) of the scale
|
|
|
|
* @param int $days number of days to display
|
2014-11-05 17:13:26 +01:00
|
|
|
* @param string $indent = '' string for correct indention
|
2005-11-09 00:15:14 +01:00
|
|
|
* @return string with scale
|
|
|
|
*/
|
|
|
|
function plannerWeekScale($start,$days,$indent)
|
2004-08-01 17:36:04 +02:00
|
|
|
{
|
2005-11-09 00:15:14 +01:00
|
|
|
$week_width = round(100 / $days * ($days <= 7 ? $days : 7),2);
|
|
|
|
|
2013-11-11 15:02:08 +01:00
|
|
|
$content .= $indent.'<div class="calendar_plannerScale">'."\n";
|
2005-11-09 00:15:14 +01:00
|
|
|
for($t = $start,$left = 0,$i = 0; $i < $days; $t += 7*DAY_s,$left += $week_width,$i += 7)
|
|
|
|
{
|
2011-01-05 22:49:55 +01:00
|
|
|
$title = lang('Week').' '.$this->week_number($t);
|
2005-11-09 00:15:14 +01:00
|
|
|
if ($days > 7)
|
|
|
|
{
|
2008-03-21 21:30:19 +01:00
|
|
|
$title = html::a_href($title,array(
|
2008-06-07 19:45:33 +02:00
|
|
|
'menuaction' => 'calendar.calendar_uiviews.planner',
|
2005-11-09 00:15:14 +01:00
|
|
|
'planner_days' => 7,
|
|
|
|
'date' => date('Ymd',$t),
|
2008-03-21 21:30:19 +01:00
|
|
|
),false,' title="'.html::htmlspecialchars(lang('Weekview')).'"');
|
2005-11-09 00:15:14 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// prev. week
|
2009-07-24 12:34:20 +02:00
|
|
|
$title = html::a_href(html::image('phpgwapi','first',lang('previous'),$options=' alt="<<"'),array(
|
2005-11-09 00:15:14 +01:00
|
|
|
'menuaction' => $this->view_menuaction,
|
|
|
|
'date' => date('Ymd',$t-7*DAY_s),
|
|
|
|
)) . ' <b>'.$title;
|
|
|
|
// next week
|
2009-07-24 12:34:20 +02:00
|
|
|
$title .= '</b> '.html::a_href(html::image('phpgwapi','last',lang('next'),$options=' alt=">>"'),array(
|
2005-11-09 00:15:14 +01:00
|
|
|
'menuaction' => $this->view_menuaction,
|
|
|
|
'date' => date('Ymd',$t+7*DAY_s),
|
|
|
|
));
|
|
|
|
}
|
|
|
|
$class = $class == 'row_on' ? 'th' : 'row_on';
|
2013-11-11 15:02:08 +01:00
|
|
|
$content .= $indent."\t".'<div class="calendar_plannerWeekScale '.$class.'" style="left: '.$left.'%; width: '.$week_width.'%;">'.$title."</div>\n";
|
2005-11-09 00:15:14 +01:00
|
|
|
}
|
|
|
|
$content .= $indent."</div>\n"; // end of plannerScale
|
|
|
|
|
|
|
|
return $content;
|
2004-08-01 17:36:04 +02:00
|
|
|
}
|
2008-06-07 19:45:33 +02:00
|
|
|
|
2005-11-09 00:15:14 +01:00
|
|
|
/**
|
|
|
|
* Creates day scale for the planner
|
|
|
|
*
|
|
|
|
* @param int $start start-time (12h) of the scale
|
|
|
|
* @param int $days number of days to display
|
2014-11-05 17:13:26 +01:00
|
|
|
* @param string $indent = '' string for correct indention
|
2005-11-09 00:15:14 +01:00
|
|
|
* @return string with scale
|
|
|
|
*/
|
|
|
|
function plannerDayScale($start,$days,$indent)
|
|
|
|
{
|
|
|
|
$day_width = round(100 / $days,2);
|
|
|
|
|
2013-11-11 15:02:08 +01:00
|
|
|
$content .= $indent.'<div class="calendar_plannerScale'.($days > 3 ? 'Day' : '').'">'."\n";
|
2005-11-09 00:15:14 +01:00
|
|
|
for($t = $start,$left = 0,$i = 0; $i < $days; $t += DAY_s,$left += $day_width,++$i)
|
|
|
|
{
|
2005-11-12 18:57:18 +01:00
|
|
|
$this->_day_class_holiday($this->bo->date2string($t),$class,$holidays,$days > 7);
|
|
|
|
|
2005-11-09 00:15:14 +01:00
|
|
|
if ($days <= 3)
|
2004-08-01 17:36:04 +02:00
|
|
|
{
|
2005-11-09 00:15:14 +01:00
|
|
|
$title = '<b>'.lang(date('l',$t)).', '.date('j',$t).'. '.lang(date('F',$t)).'</b>';
|
2004-08-01 17:36:04 +02:00
|
|
|
}
|
2005-11-09 00:15:14 +01:00
|
|
|
elseif ($days <= 7)
|
|
|
|
{
|
|
|
|
$title = lang(date('l',$t)).'<br />'.date('j',$t).'. '.lang(date('F',$t));
|
|
|
|
}
|
|
|
|
else
|
2004-09-02 11:58:36 +02:00
|
|
|
{
|
2008-06-07 19:45:33 +02:00
|
|
|
$title = substr(lang(date('D',$t)),0,2).'<br />'.date('j',$t);
|
2004-09-02 11:58:36 +02:00
|
|
|
}
|
2005-11-09 00:15:14 +01:00
|
|
|
if ($days > 1)
|
2004-09-02 11:58:36 +02:00
|
|
|
{
|
2008-03-21 21:30:19 +01:00
|
|
|
$title = html::a_href($title,array(
|
2008-06-07 19:45:33 +02:00
|
|
|
'menuaction' => 'calendar.calendar_uiviews.planner',
|
2005-11-09 00:15:14 +01:00
|
|
|
'planner_days' => 1,
|
|
|
|
'date' => date('Ymd',$t),
|
2013-11-11 15:02:08 +01:00
|
|
|
),false,strpos($class,'calendar_calHoliday') !== false || strpos($class,'calendar_calBirthday') !== false ? '' : ' title="'.html::htmlspecialchars(lang('Dayview')).'"');
|
2005-11-09 00:15:14 +01:00
|
|
|
}
|
|
|
|
if ($days < 5)
|
|
|
|
{
|
|
|
|
if (!$i) // prev. day only for the first day
|
|
|
|
{
|
2009-07-24 12:34:20 +02:00
|
|
|
$title = html::a_href(html::image('phpgwapi','first',lang('previous'),$options=' alt="<<"'),array(
|
2005-11-09 00:15:14 +01:00
|
|
|
'menuaction' => $this->view_menuaction,
|
|
|
|
'date' => date('Ymd',$start-DAY_s),
|
|
|
|
)) . ' '.$title;
|
|
|
|
}
|
|
|
|
if ($i == $days-1) // next day only for the last day
|
|
|
|
{
|
2009-07-24 12:34:20 +02:00
|
|
|
$title .= ' '.html::a_href(html::image('phpgwapi','last',lang('next'),$options=' alt=">>"'),array(
|
2005-11-09 00:15:14 +01:00
|
|
|
'menuaction' => $this->view_menuaction,
|
|
|
|
'date' => date('Ymd',$start+DAY_s),
|
|
|
|
));
|
|
|
|
}
|
2004-09-02 11:58:36 +02:00
|
|
|
}
|
2013-11-11 15:02:08 +01:00
|
|
|
$content .= $indent."\t".'<div class="calendar_plannerDayScale '.$class.'" style="left: '.$left.'%; width: '.$day_width.'%;"'.
|
2008-03-21 21:30:19 +01:00
|
|
|
($holidays ? ' title="'.html::htmlspecialchars($holidays).'"' : '').'>'.$title."</div>\n";
|
2004-08-01 17:36:04 +02:00
|
|
|
}
|
2005-11-09 00:15:14 +01:00
|
|
|
$content .= $indent."</div>\n"; // end of plannerScale
|
|
|
|
|
|
|
|
return $content;
|
|
|
|
}
|
2010-04-03 15:16:39 +02:00
|
|
|
|
2010-01-15 04:53:12 +01:00
|
|
|
/**
|
|
|
|
* Creates DayOfMonth scale for planner by month
|
2010-04-03 15:16:39 +02:00
|
|
|
*
|
2010-01-15 04:53:12 +01:00
|
|
|
* @param string $indent
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
function plannerDayOfMonthScale($indent)
|
|
|
|
{
|
|
|
|
$day_width = round(100 / 31,2);
|
2010-04-03 15:16:39 +02:00
|
|
|
|
2010-01-17 03:03:11 +01:00
|
|
|
// month scale with navigation
|
2013-11-11 15:02:08 +01:00
|
|
|
$content .= $indent.'<div class="calendar_plannerScale">'."\n";
|
2010-04-03 15:16:39 +02:00
|
|
|
|
2010-01-17 03:03:11 +01:00
|
|
|
$title = lang(egw_time::to($this->first,'F')).' '.egw_time::to($this->first,'Y').' - '.
|
|
|
|
lang(egw_time::to($this->last,'F')).' '.egw_time::to($this->last,'Y');
|
|
|
|
|
|
|
|
// calculate date for navigation links
|
|
|
|
$time = new egw_time($this->first);
|
|
|
|
$time->modify('-1year');
|
|
|
|
$last_year = $time->format('Ymd');
|
|
|
|
$time->modify('+11month');
|
|
|
|
$last_month = $time->format('Ymd');
|
|
|
|
$time->modify('+2month');
|
|
|
|
$next_month = $time->format('Ymd');
|
|
|
|
$time->modify('+11month');
|
|
|
|
$next_year = $time->format('Ymd');
|
2010-04-03 15:16:39 +02:00
|
|
|
|
2010-01-17 03:03:11 +01:00
|
|
|
$title = html::a_href(html::image('phpgwapi','first',lang('back one year'),$options=' alt="<<"'),array(
|
|
|
|
'menuaction' => $this->view_menuaction,
|
|
|
|
'date' => $last_year,
|
|
|
|
)) . ' '.
|
|
|
|
html::a_href(html::image('phpgwapi','left',lang('back one month'),$options=' alt="<"'),array(
|
|
|
|
'menuaction' => $this->view_menuaction,
|
|
|
|
'date' => $last_month,
|
|
|
|
)) . ' '.$title;
|
|
|
|
$title .= ' '.html::a_href(html::image('phpgwapi','right',lang('forward one month'),$options=' alt=">>"'),array(
|
|
|
|
'menuaction' => $this->view_menuaction,
|
|
|
|
'date' => $next_month,
|
|
|
|
)). ' '.
|
|
|
|
html::a_href(html::image('phpgwapi','last',lang('forward one year'),$options=' alt=">>"'),array(
|
|
|
|
'menuaction' => $this->view_menuaction,
|
|
|
|
'date' => $next_year,
|
|
|
|
));
|
2010-04-03 15:16:39 +02:00
|
|
|
|
2013-11-11 15:02:08 +01:00
|
|
|
$content .= $indent."\t".'<div class="calendar_plannerMonthScale th" style="left: 0; width: 100%;">'.
|
2010-01-17 03:03:11 +01:00
|
|
|
$title."</div>\n";
|
|
|
|
$content .= $indent."</div>\n"; // end of plannerScale
|
|
|
|
|
|
|
|
// day of month scale
|
2013-11-11 15:02:08 +01:00
|
|
|
$content .= $indent.'<div class="calendar_plannerScale">'."\n";
|
2010-01-15 04:53:12 +01:00
|
|
|
$today = egw_time::to('now','d');
|
|
|
|
for($left = 0,$i = 0; $i < 31; $left += $day_width,++$i)
|
|
|
|
{
|
2010-01-17 03:03:11 +01:00
|
|
|
$class = $i & 1 ? 'row_on' : 'row_off';
|
2013-11-11 15:02:08 +01:00
|
|
|
$content .= $indent."\t".'<div class="calendar_plannerDayOfMonthScale '.$class.'" style="left: '.$left.'%; width: '.$day_width.'%;">'.
|
2010-01-15 04:53:12 +01:00
|
|
|
(1+$i)."</div>\n";
|
|
|
|
}
|
|
|
|
$content .= $indent."</div>\n"; // end of plannerScale
|
|
|
|
|
|
|
|
return $content;
|
|
|
|
}
|
2008-06-07 19:45:33 +02:00
|
|
|
|
2005-11-09 00:15:14 +01:00
|
|
|
/**
|
|
|
|
* Creates hour scale for the planner
|
|
|
|
*
|
|
|
|
* @param int $start start-time (12h) of the scale
|
|
|
|
* @param int $days number of days to display
|
2014-11-05 17:13:26 +01:00
|
|
|
* @param string $indent = '' string for correct indention
|
2005-11-09 00:15:14 +01:00
|
|
|
* @return string with scale
|
|
|
|
*/
|
|
|
|
function plannerHourScale($start,$days,$indent)
|
|
|
|
{
|
|
|
|
foreach(array(1,2,3,4,6,8,12) as $d) // numbers dividing 24 without rest
|
|
|
|
{
|
|
|
|
if ($d > $days) break;
|
|
|
|
$decr = $d;
|
|
|
|
}
|
|
|
|
$hours = $days * 24;
|
|
|
|
if ($days == 1) // for a single day we calculate the hours of a days, to take into account daylight saving changes (23 or 25 hours)
|
|
|
|
{
|
|
|
|
$t_arr = $this->bo->date2array($start);
|
|
|
|
unset($t_arr['raw']);
|
|
|
|
$t_arr['hour'] = $t_arr['minute'] = $t_arr['second'] = 0;
|
|
|
|
$s = $this->bo->date2ts($t_arr);
|
|
|
|
$t_arr['hour'] = 23; $t_arr['minute'] = $t_arr['second'] = 59;
|
|
|
|
$hours = ($this->bo->date2ts($t_arr) - $s) / HOUR_s;
|
|
|
|
}
|
|
|
|
$cell_width = round(100 / $hours * $decr,2);
|
2008-06-07 19:45:33 +02:00
|
|
|
|
2013-11-11 15:02:08 +01:00
|
|
|
$content .= $indent.'<div class="calendar_plannerScale">'."\n";
|
2005-11-09 00:15:14 +01:00
|
|
|
for($t = $start,$left = 0,$i = 0; $i < $hours; $t += $decr*HOUR_s,$left += $cell_width,$i += $decr)
|
|
|
|
{
|
|
|
|
$title = date($this->cal_prefs['timeformat'] == 12 ? 'ha' : 'H',$t);
|
|
|
|
|
|
|
|
$class = $class == 'row_on' ? 'th' : 'row_on';
|
2013-11-11 15:02:08 +01:00
|
|
|
$content .= $indent."\t".'<div class="calendar_plannerHourScale '.$class.'" style="left: '.$left.'%; width: '.($cell_width).'%;">'.$title."</div>\n";
|
2005-11-09 00:15:14 +01:00
|
|
|
}
|
|
|
|
$content .= $indent."</div>\n"; // end of plannerScale
|
|
|
|
|
|
|
|
return $content;
|
|
|
|
}
|
2008-06-07 19:45:33 +02:00
|
|
|
|
2005-11-09 00:15:14 +01:00
|
|
|
/**
|
|
|
|
* Creates a row for one user or category, with a header (user or category name) and (multiple) rows with non-overlapping events
|
|
|
|
*
|
2013-11-11 15:02:08 +01:00
|
|
|
* Uses the calendar_eventRowWidget to display a row of non-overlapping events
|
2005-11-09 00:15:14 +01:00
|
|
|
*
|
|
|
|
* @param array $events to show
|
|
|
|
* @param int $start start-time of the row
|
|
|
|
* @param int $end end-time of the row
|
|
|
|
* @param string $header user or category name for the row-header
|
|
|
|
* @param string $class additional css class for the row
|
2014-11-05 17:13:26 +01:00
|
|
|
* @param string $indent = '' string for correct indention
|
2005-11-09 00:15:14 +01:00
|
|
|
* @return string with widget
|
|
|
|
*/
|
|
|
|
function plannerRowWidget($events,$start,$end,$header,$class,$indent='')
|
|
|
|
{
|
2013-11-11 15:02:08 +01:00
|
|
|
$content = $indent.'<div class="calendar_plannerRowWidget '.$class.'">'."\n";
|
2005-11-09 00:15:14 +01:00
|
|
|
|
|
|
|
// display the row-header
|
2013-11-11 15:02:08 +01:00
|
|
|
$content .= $indent."\t".'<div class="calendar_plannerRowHeader">'.$header."</div>\n";
|
2008-06-07 19:45:33 +02:00
|
|
|
|
2005-11-09 00:15:14 +01:00
|
|
|
// sorting the events in non-overlapping rows
|
|
|
|
$rows = array(array());
|
|
|
|
$row_end = array();
|
|
|
|
foreach($events as $n => $event)
|
|
|
|
{
|
|
|
|
for($row = 0; (int) $row_end[$row] > $event['start']; ++$row); // find a "free" row (no other event)
|
|
|
|
$rows[$row][] =& $events[$n];
|
|
|
|
$row_end[$row] = $event['end'];
|
|
|
|
}
|
|
|
|
//echo $header; _debug_array($rows);
|
|
|
|
// display the rows
|
2013-11-11 15:02:08 +01:00
|
|
|
$content .= $indent."\t".'<div class="calendar_eventRows"';
|
2010-01-17 03:03:11 +01:00
|
|
|
|
|
|
|
if ($this->sortby == 'month' && ($days = date('j',$end)) < 31)
|
|
|
|
{
|
|
|
|
$width = round(85*$days/31,2);
|
|
|
|
$content .= ' style="width: '.$width.'%;"';
|
|
|
|
}
|
|
|
|
$content .= ">\n";
|
2010-04-03 15:16:39 +02:00
|
|
|
|
2010-01-17 03:03:11 +01:00
|
|
|
// mark weekends and other special days in yearly planner
|
|
|
|
if ($this->sortby == 'month')
|
|
|
|
{
|
|
|
|
$content .= $this->yearlyPlannerMarkDays($start,$days,$indent."\t\t");
|
|
|
|
}
|
2005-11-09 00:15:14 +01:00
|
|
|
foreach($rows as $row)
|
|
|
|
{
|
|
|
|
$content .= $this->eventRowWidget($row,$start,$end,$indent."\t\t");
|
|
|
|
}
|
|
|
|
$content .= $indent."\t</div>\n"; // end of the eventRows
|
|
|
|
|
2010-01-17 03:03:11 +01:00
|
|
|
if ($this->sortby == 'month' && $days < 31)
|
|
|
|
{
|
|
|
|
// add a filler for non existing days in that month
|
2013-11-11 15:02:08 +01:00
|
|
|
$content .= $indent."\t".'<div class="calendar_eventRowsFiller"'.
|
2010-01-17 03:03:11 +01:00
|
|
|
' style="left:'.(15+$width).'%; width:'.(85-$width).'%;" ></div>'."\n";
|
|
|
|
}
|
2005-11-09 00:15:14 +01:00
|
|
|
$content .= $indent."</div>\n"; // end of the plannerRowWidget
|
2008-06-07 19:45:33 +02:00
|
|
|
|
2005-11-09 00:15:14 +01:00
|
|
|
return $content;
|
|
|
|
}
|
2010-04-03 15:16:39 +02:00
|
|
|
|
2010-01-17 03:03:11 +01:00
|
|
|
/**
|
|
|
|
* Mark weekends and other special days in yearly planner
|
2010-04-03 15:16:39 +02:00
|
|
|
*
|
2010-01-17 03:03:11 +01:00
|
|
|
* @param int $start timestamp of start of row
|
|
|
|
* @param int $days number of days in month of row
|
2014-11-05 17:13:26 +01:00
|
|
|
* @param string $indent = ''
|
2010-01-17 03:03:11 +01:00
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
function yearlyPlannerMarkDays($start,$days,$indent='')
|
|
|
|
{
|
|
|
|
$day_width = round(100/$days,2);
|
|
|
|
for($t = $start,$left = 0,$i = 0; $i < $days; $t += DAY_s,$left += $day_width,++$i)
|
|
|
|
{
|
|
|
|
$this->_day_class_holiday($this->bo->date2string($t),$class,$holidays,true);
|
2010-04-03 15:16:39 +02:00
|
|
|
|
2010-01-17 04:59:50 +01:00
|
|
|
$class = trim(str_replace(array('row_on','row_off'),'',$class));
|
|
|
|
if ($class) // no regular weekday
|
2010-01-17 03:03:11 +01:00
|
|
|
{
|
2013-11-11 15:02:08 +01:00
|
|
|
$content .= $indent.'<div class="calendar_eventRowsMarkedDay '.$class.
|
2010-01-17 03:03:11 +01:00
|
|
|
'" style="left: '.$left.'%; width:'.$day_width.'%;"'.
|
|
|
|
($holidays ? ' title="'.html::htmlspecialchars($holidays).'"' : '').
|
|
|
|
' ></div>'."\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $content;
|
|
|
|
}
|
2005-11-09 00:15:14 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a row with non-overlapping events
|
|
|
|
*
|
|
|
|
* Uses the plannerEventWidget to display the events
|
|
|
|
*
|
|
|
|
* @param array $events non-overlapping events to show
|
|
|
|
* @param int $start start-time of the row
|
|
|
|
* @param int $end end-time of the row
|
2014-11-05 17:13:26 +01:00
|
|
|
* @param string $indent = '' string for correct indention
|
2005-11-09 00:15:14 +01:00
|
|
|
* @return string with widget
|
|
|
|
*/
|
|
|
|
function eventRowWidget($events,$start,$end,$indent='')
|
|
|
|
{
|
2013-11-11 15:02:08 +01:00
|
|
|
$content = $indent.'<div class="calendar_eventRowWidget">'."\n";
|
2008-06-07 19:45:33 +02:00
|
|
|
|
2005-11-09 00:15:14 +01:00
|
|
|
foreach($events as $event)
|
2004-08-01 17:36:04 +02:00
|
|
|
{
|
2005-11-09 00:15:14 +01:00
|
|
|
$content .= $this->plannerEventWidget($event,$start,$end,$indent."\t");
|
2004-08-01 17:36:04 +02:00
|
|
|
}
|
2005-11-09 00:15:14 +01:00
|
|
|
$content .= $indent."</div>\n";
|
2008-06-07 19:45:33 +02:00
|
|
|
|
2005-11-09 00:15:14 +01:00
|
|
|
return $content;
|
|
|
|
}
|
2008-06-07 19:45:33 +02:00
|
|
|
|
2005-11-09 00:15:14 +01:00
|
|
|
/**
|
|
|
|
* Calculate a time-dependent position in the planner
|
|
|
|
*
|
|
|
|
* We use a non-linear scale in the planner monthview, which shows the workday start or end
|
|
|
|
* as start or end of the whole day. This improves the resolution a bit.
|
|
|
|
*
|
|
|
|
* @param int $time
|
|
|
|
* @param int $start start-time of the planner
|
|
|
|
* @param int $end end-time of the planner
|
|
|
|
* @return float percentage position between 0-100
|
|
|
|
*/
|
|
|
|
function _planner_pos($time,$start,$end)
|
|
|
|
{
|
|
|
|
if ($time <= $start) return 0; // we are left of our scale
|
|
|
|
if ($time >= $end) return 100; // we are right of our scale
|
2008-06-07 19:45:33 +02:00
|
|
|
|
2010-01-15 04:53:12 +01:00
|
|
|
if ($this->planner_days || $this->sortby == 'month')
|
2005-11-09 00:15:14 +01:00
|
|
|
{
|
|
|
|
$percent = ($time - $start) / ($end - $start);
|
|
|
|
}
|
|
|
|
else // monthview
|
|
|
|
{
|
|
|
|
$t_arr = $this->bo->date2array($time);
|
|
|
|
$day_start = $this->bo->date2ts((string)$t_arr['full']);
|
|
|
|
$percent = ($day_start - $start) / ($end - $start);
|
2008-06-07 19:45:33 +02:00
|
|
|
|
2005-11-09 00:15:14 +01:00
|
|
|
$time_of_day = 60 * $t_arr['hour'] + $t_arr['minute'];
|
|
|
|
if ($time_of_day >= $this->wd_start)
|
|
|
|
{
|
|
|
|
if ($time_of_day > $this->wd_end)
|
|
|
|
{
|
|
|
|
$day_percentage = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-02-07 05:35:12 +01:00
|
|
|
$wd_lenght = $this->wd_end - $this->wd_start;
|
|
|
|
if ($wd_lenght <= 0) $wd_lenght = 24*60;
|
|
|
|
$day_percentage = ($time_of_day-$this->wd_start) / $wd_lenght; // between 0 and 1
|
2005-11-09 00:15:14 +01:00
|
|
|
}
|
|
|
|
$days = ($end - $start) / DAY_s;
|
|
|
|
$percent += $day_percentage / $days;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$percent = round(100 * $percent,2);
|
2008-06-07 19:45:33 +02:00
|
|
|
|
2005-11-09 00:15:14 +01:00
|
|
|
//echo "<p>_planner_pos(".date('Y-m-d H:i',$time).', '.date('Y-m-d H:i',$start).', '.date('Y-m-d H:i',$end).") = $percent</p>\n";
|
|
|
|
return $percent;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Displays one event for the planner, using the eventWidget of the other views
|
|
|
|
*
|
|
|
|
* @param array $event
|
|
|
|
* @param int $start start-time of the planner
|
|
|
|
* @param int $end end-time of the planner
|
|
|
|
* @return string with widget
|
|
|
|
*/
|
|
|
|
function plannerEventWidget($event,$start,$end,$indent='')
|
|
|
|
{
|
2006-08-25 10:17:40 +02:00
|
|
|
// some fields set by the dayColWidget for the other views
|
|
|
|
$day_start = $this->bo->date2ts((string)$this->bo->date2string($event['start']));
|
|
|
|
$event['start_m'] = ($event['start'] - $day_start) / 60;
|
|
|
|
$event['end_m'] = round(($event['end'] - $day_start) / 60);
|
|
|
|
$event['multiday'] = true;
|
2006-12-18 12:47:58 +01:00
|
|
|
unset($event['whole_day_on_top']);
|
|
|
|
|
|
|
|
$data = $this->eventWidget($event,200,$indent,$this->owner,true,'planner_event');
|
2006-08-25 10:17:40 +02:00
|
|
|
|
2005-11-09 00:15:14 +01:00
|
|
|
$left = $this->_planner_pos($event['start'],$start,$end);
|
|
|
|
$width = $this->_planner_pos($event['end'],$start,$end) - $left;
|
|
|
|
$color = $data['color'] ? $data['color'] : 'gray';
|
2008-06-07 19:45:33 +02:00
|
|
|
|
2014-01-09 10:04:59 +01:00
|
|
|
$tooltip = html::htmlspecialchars(str_replace(array("\n","\r","'",'"'),array('','',"\\'",'"'),$data['tooltip']));
|
2013-11-11 15:02:08 +01:00
|
|
|
return $indent.'<div class="calendar_plannerEvent'.($data['private'] ? 'Private' : '').'" style="left: '.$left.
|
2014-01-09 10:04:59 +01:00
|
|
|
'%; width: '.$width.'%; background-color: '.$color.';"'.'data-tooltip="'. $tooltip.'" '.
|
2014-01-09 10:38:55 +01:00
|
|
|
'" data-date ="'.$this->bo->date2string($event['start']).'|'.$data['popup'].'">'."\n".$data['html'].$indent."</div>\n";
|
2004-08-01 17:36:04 +02:00
|
|
|
}
|
2006-10-17 22:01:08 +02:00
|
|
|
|
2015-07-01 00:26:59 +02:00
|
|
|
/**
|
|
|
|
* Get the actions for the non-list views
|
|
|
|
*
|
|
|
|
* We use the actions from the list as a base, and only change what we have to
|
|
|
|
* to get it to work outside of a nextmatch.
|
|
|
|
*
|
|
|
|
* @return Array
|
|
|
|
*/
|
2015-06-10 23:51:28 +02:00
|
|
|
protected static function get_actions()
|
|
|
|
{
|
|
|
|
// Just copy from the list, but change to match our needs
|
|
|
|
$ui = new calendar_uilist();
|
|
|
|
$actions = $ui->get_actions();
|
|
|
|
|
|
|
|
unset($actions['no_notifications']);
|
|
|
|
unset($actions['select_all']);
|
|
|
|
|
|
|
|
// This disables the event actions for the grid rows (calendar weeks/owners)
|
|
|
|
foreach($actions as $id => &$action)
|
|
|
|
{
|
|
|
|
if($id=='add') continue;
|
|
|
|
if(!$action['enabled'])
|
|
|
|
{
|
|
|
|
$action['enabled'] = 'javaScript:app.calendar.is_event';
|
|
|
|
}
|
|
|
|
}
|
2015-12-29 01:19:45 +01:00
|
|
|
$actions['add']['open'] = '{"app":"calendar","type":"add"}';
|
|
|
|
$actions['add']['onExecute'] = 'javaScript:app.calendar.action_open';
|
2015-07-01 00:26:59 +02:00
|
|
|
$actions['copy']['open'] = '{"app": "calendar", "type": "add", "extra": "cal_id=$id&action=copy"}';
|
|
|
|
$actions['copy']['onExecute'] = 'javaScript:app.calendar.action_open';
|
|
|
|
|
2015-06-10 23:51:28 +02:00
|
|
|
foreach($actions['status']['children'] as $id => &$status)
|
|
|
|
{
|
|
|
|
$status = array(
|
|
|
|
'id' => $id,
|
|
|
|
'caption' => $status,
|
|
|
|
'onExecute' => 'javaScript:app.calendar.status'
|
|
|
|
);
|
|
|
|
}
|
2015-07-01 00:26:59 +02:00
|
|
|
|
|
|
|
if ($actions['filemanager'])
|
|
|
|
{
|
|
|
|
$actions['filemanager']['url'] = '/index.php?'. $actions['filemanager']['url'];
|
|
|
|
$actions['filemanager']['onExecute'] = 'javaScript:app.calendar.action_open';
|
|
|
|
}
|
|
|
|
if ($actions['infolog_app'])
|
|
|
|
{
|
|
|
|
$actions['infolog_app']['open'] = '{"app": "infolog", "type": "add", "extra": "type=task&action=$app&action_id=$id"}';
|
|
|
|
$actions['infolog_app']['onExecute'] = 'javaScript:app.calendar.action_open';
|
|
|
|
}
|
|
|
|
if ($actions['timesheet'])
|
|
|
|
{
|
|
|
|
$actions['timesheet']['open'] = '{"app": "timesheet", "type": "add", "extra": "link_app[]=$app&link_id[]=$id"}';
|
|
|
|
$actions['timesheet']['onExecute'] = 'javaScript:app.calendar.action_open';
|
|
|
|
}
|
2015-08-05 23:24:07 +02:00
|
|
|
if ($actions['documents'])
|
|
|
|
{
|
|
|
|
// TODO: See if we can get this working sensibly
|
|
|
|
$actions['documents']['enabled'] = false;
|
|
|
|
}
|
2015-07-03 11:10:01 +02:00
|
|
|
|
2015-07-15 18:29:10 +02:00
|
|
|
$actions['delete']['onExecute'] = 'javaScript:app.calendar.delete';
|
|
|
|
|
2015-06-10 23:51:28 +02:00
|
|
|
return $actions;
|
|
|
|
}
|
|
|
|
|
2006-10-17 22:01:08 +02:00
|
|
|
/**
|
|
|
|
* Marks whole day events for later usage and increments extraRows
|
|
|
|
*
|
|
|
|
* @param array $dayEvents
|
|
|
|
* @return array $dayEvents
|
|
|
|
*/
|
|
|
|
function tagWholeDayOnTop($dayEvents)
|
|
|
|
{
|
2006-11-15 20:46:20 +01:00
|
|
|
$this->extraRows = $this->extraRowsOriginal;
|
2010-12-09 22:04:34 +01:00
|
|
|
$this->remBotExtraRows = 0;
|
2010-01-21 00:21:00 +01:00
|
|
|
|
|
|
|
if (is_array($dayEvents))
|
2006-10-17 22:01:08 +02:00
|
|
|
{
|
2010-01-21 00:21:00 +01:00
|
|
|
foreach ($dayEvents as $day=>$oneDayEvents)
|
2006-10-17 22:01:08 +02:00
|
|
|
{
|
2010-01-21 00:21:00 +01:00
|
|
|
$extraRowsToAdd = 0;
|
|
|
|
foreach ($oneDayEvents as $num => $event)
|
2006-10-17 22:01:08 +02:00
|
|
|
{
|
2010-01-21 00:21:00 +01:00
|
|
|
$start = $this->bo->date2array($event['start']);
|
|
|
|
$end = $this->bo->date2array($event['end']);
|
|
|
|
if(!$start['hour'] && !$start['minute'] && $end['hour'] == 23 && $end['minute'] == 59)
|
2006-12-15 21:05:47 +01:00
|
|
|
{
|
2010-01-21 00:21:00 +01:00
|
|
|
if($event['non_blocking'])
|
|
|
|
{
|
|
|
|
$dayEvents[$day][$num]['whole_day_on_top']=true;
|
|
|
|
$this->whole_day_positions[$num]=($this->rowHeight*($num+2));
|
|
|
|
$extraRowsToAdd++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$dayEvents[$day][$num]['whole_day']=true;
|
|
|
|
}
|
2006-12-15 21:05:47 +01:00
|
|
|
}
|
2015-10-27 21:10:53 +01:00
|
|
|
$this->to_client($dayEvents[$day][$num]);
|
2006-10-17 22:01:08 +02:00
|
|
|
}
|
2010-01-21 00:21:00 +01:00
|
|
|
// check after every day if we have to increase $this->extraRows
|
|
|
|
if(($this->extraRowsOriginal+$extraRowsToAdd) > $this->extraRows)
|
|
|
|
{
|
2010-12-09 22:04:34 +01:00
|
|
|
$this->remBotExtraRows = $extraRowsToAdd;
|
2010-01-21 00:21:00 +01:00
|
|
|
$this->extraRows = ($this->extraRowsOriginal+$extraRowsToAdd);
|
|
|
|
}
|
2006-10-17 22:01:08 +02:00
|
|
|
}
|
2010-01-21 00:21:00 +01:00
|
|
|
}
|
2006-10-17 22:01:08 +02:00
|
|
|
return $dayEvents;
|
|
|
|
}
|
2010-12-22 16:17:56 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* Returns the special icon html code for holidays
|
|
|
|
*
|
|
|
|
* @param string $type is the type of the holiday, currently either 'hday' or
|
|
|
|
* 'bday'
|
|
|
|
*/
|
|
|
|
function _get_holiday_icon($type)
|
|
|
|
{
|
|
|
|
//Set the special icon which will be prepended to the event
|
|
|
|
switch ($type) {
|
|
|
|
case "bday":
|
|
|
|
return html::image('calendar', 'cake', '', "style=\"float:left; padding: 1px 2px 0px 2px;\"");
|
|
|
|
case "hday":
|
|
|
|
return html::image('calendar', 'date', '', "style=\"float:left; padding: 1px 2px 0px 2px;\"");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* Creates a dummy holiday event. This event is shown in the day view, when
|
|
|
|
* added to the event list.
|
|
|
|
*
|
|
|
|
* @param int $day_start is a unix timestamp which contains the start of the day
|
|
|
|
* when the event occurs.
|
|
|
|
* @param string $title is the title of the dummy event which will be shown
|
|
|
|
* @param string $description is the long description of the event which will
|
|
|
|
* be shown in the event tooltip
|
|
|
|
*/
|
|
|
|
function _make_holiday_event($day_start, $title, $description, $type = 'bday')
|
|
|
|
{
|
|
|
|
//Calculate the end of the day by adding 23h:59min seconds
|
|
|
|
$day_end = $day_start + 24 * 3600 - 60;
|
|
|
|
|
|
|
|
//Setup the event data
|
|
|
|
$event = array(
|
|
|
|
'title' => $title,
|
|
|
|
'description' => $description,
|
|
|
|
'participants' => array(
|
|
|
|
),
|
|
|
|
'whole_day_on_top' => true,
|
|
|
|
'start' => $day_start,
|
|
|
|
'end' => $day_end,
|
|
|
|
'non_blocking' => true,
|
|
|
|
'prepend_icon' => $this->_get_holiday_icon($type)
|
|
|
|
);
|
|
|
|
|
|
|
|
return $event;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* Collects all holidays/birthdays corresponding to the given day and creates
|
|
|
|
* an array containing all this events.
|
|
|
|
*
|
|
|
|
* @param string $day_ymd contains the Ymd of the day
|
|
|
|
* @param array $types is an array which determines which types of events should
|
|
|
|
* be added to the holiday list. May contain the indices "bdays" and "hdays".
|
|
|
|
* The default is "bdays => true"
|
|
|
|
*/
|
|
|
|
function _get_holiday_events($day_ymd, $types = array("bdays" => true, "hdays" => false))
|
|
|
|
{
|
|
|
|
//Check whether there are any holidays set for the current day_ymd
|
|
|
|
$events = array();
|
|
|
|
if (isset($this->holidays[$day_ymd]))
|
|
|
|
{
|
|
|
|
//Translate the day_ymd to a timestamp
|
|
|
|
$day_start = $this->bo->date2ts((string)$day_ymd);
|
|
|
|
|
|
|
|
//Iterate over the holidays array and add those the the events list
|
|
|
|
foreach($this->holidays[$day_ymd] as $holiday)
|
|
|
|
{
|
|
|
|
if (isset($holiday['birthyear']))
|
|
|
|
{
|
|
|
|
if (array_key_exists("bdays", $types) && $types['bdays'])
|
|
|
|
{
|
|
|
|
$events[] = $this->_make_holiday_event(
|
|
|
|
$day_start, $holiday['name'],
|
|
|
|
lang('Age:').(date('Y') - $holiday['birthyear']));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (array_key_exists("hdays", $types) && $types['hdays'])
|
|
|
|
{
|
|
|
|
$events[] = $this->_make_holiday_event($day_start, $holiday['name'], '', 'hday');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return $events;
|
|
|
|
}
|
2004-08-01 17:36:04 +02:00
|
|
|
}
|