2015-05-06 21:03:45 +02:00
|
|
|
<?php
|
2016-05-01 19:47:59 +02:00
|
|
|
/**
|
2015-05-06 21:03:45 +02:00
|
|
|
* Egroupware
|
|
|
|
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
|
|
|
* @link http://www.egroupware.org
|
|
|
|
* @author Nathan Gray
|
|
|
|
* @version $Id$
|
|
|
|
*/
|
|
|
|
|
2016-05-01 19:47:59 +02:00
|
|
|
use EGroupware\Api;
|
|
|
|
use EGroupware\Api\Etemplate;
|
|
|
|
|
2015-05-06 21:03:45 +02:00
|
|
|
/**
|
|
|
|
* Creates a grid with rows for the time, columns for (multiple) days containing events
|
|
|
|
*
|
|
|
|
* The associated javascript files are loaded by calendar/js/app.js using the
|
|
|
|
* server-side include manager to get all the dependancies
|
|
|
|
*
|
|
|
|
* @author Nathan Gray
|
|
|
|
*/
|
2016-05-01 19:47:59 +02:00
|
|
|
class calendar_timegrid_etemplate_widget extends Etemplate\Widget
|
2015-05-06 21:03:45 +02:00
|
|
|
{
|
2015-06-10 23:51:28 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set up what we know on the server side.
|
|
|
|
*
|
|
|
|
* Sending a first chunk of rows
|
|
|
|
*
|
|
|
|
* @param string $cname
|
|
|
|
* @param array $expand values for keys 'c', 'row', 'c_', 'row_', 'cont'
|
|
|
|
*/
|
|
|
|
public function beforeSendToClient($cname, array $expand=null)
|
|
|
|
{
|
|
|
|
$form_name = self::form_name($cname, $this->id, $expand);
|
|
|
|
$value =& self::get_array(self::$request->content, $form_name, true);
|
2016-02-22 23:45:48 +01:00
|
|
|
if(!is_array($value)) $value = array();
|
2015-06-10 23:51:28 +02:00
|
|
|
|
2016-05-01 19:47:59 +02:00
|
|
|
foreach($value as &$events)
|
2015-06-10 23:51:28 +02:00
|
|
|
{
|
2015-10-14 16:32:33 +02:00
|
|
|
if(!is_array($events))
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
2015-06-10 23:51:28 +02:00
|
|
|
foreach($events as &$event)
|
|
|
|
{
|
|
|
|
if(!is_array($event)) continue;
|
|
|
|
foreach(array('start','end') as $date)
|
|
|
|
{
|
2016-05-01 19:47:59 +02:00
|
|
|
$event[$date] = Api\DateTime::to($event[$date],'Y-m-d\TH:i:s\Z');
|
2015-06-10 23:51:28 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-05-06 21:03:45 +02:00
|
|
|
/**
|
|
|
|
* Ajax callback to fetch the holidays for a given year.
|
|
|
|
* @param type $year
|
|
|
|
*/
|
|
|
|
public static function ajax_get_holidays($year)
|
|
|
|
{
|
|
|
|
$cal_bo = new calendar_bo();
|
|
|
|
$holidays = $cal_bo->read_holidays((int)$year);
|
2016-05-01 19:47:59 +02:00
|
|
|
Api\Json\Response::get()->data($holidays);
|
2015-05-06 21:03:45 +02:00
|
|
|
}
|
|
|
|
}
|