2005-12-19 05:23:14 +01:00
|
|
|
<?php
|
2006-08-26 18:32:29 +02:00
|
|
|
/**
|
|
|
|
* TimeSheet - user interface
|
|
|
|
*
|
|
|
|
* @link http://www.egroupware.org
|
|
|
|
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
|
|
|
|
* @package timesheet
|
2016-02-17 20:56:54 +01:00
|
|
|
* @copyright (c) 2005-16 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
|
2006-08-26 18:32:29 +02:00
|
|
|
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
2008-04-18 23:09:30 +02:00
|
|
|
* @version $Id$
|
2006-08-26 18:32:29 +02:00
|
|
|
*/
|
2005-12-19 05:23:14 +01:00
|
|
|
|
2016-04-26 20:27:29 +02:00
|
|
|
use EGroupware\Api;
|
|
|
|
use EGroupware\Api\Link;
|
|
|
|
use EGroupware\Api\Framework;
|
|
|
|
use EGroupware\Api\Acl;
|
|
|
|
use EGroupware\Api\Etemplate;
|
|
|
|
|
2005-12-19 05:23:14 +01:00
|
|
|
/**
|
|
|
|
* User interface object of the TimeSheet
|
|
|
|
*/
|
2008-10-07 10:57:09 +02:00
|
|
|
class timesheet_ui extends timesheet_bo
|
2005-12-19 05:23:14 +01:00
|
|
|
{
|
|
|
|
var $public_functions = array(
|
2010-02-05 04:34:17 +01:00
|
|
|
'view' => true,
|
|
|
|
'edit' => true,
|
|
|
|
'index' => true,
|
|
|
|
'editstatus' => true,
|
2005-12-19 05:23:14 +01:00
|
|
|
);
|
2006-09-12 17:21:23 +02:00
|
|
|
/**
|
2007-03-08 12:22:57 +01:00
|
|
|
* ProjectManager integration: 'none', 'full' or default null
|
2006-09-12 17:21:23 +02:00
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
var $pm_integration;
|
2005-12-19 05:23:14 +01:00
|
|
|
|
2007-03-08 12:22:57 +01:00
|
|
|
/**
|
|
|
|
* TimeSheet view type: 'short' or 'normal'
|
|
|
|
*
|
|
|
|
* @var string
|
2008-04-18 23:09:30 +02:00
|
|
|
*/
|
2007-03-08 12:22:57 +01:00
|
|
|
var $ts_viewtype;
|
2008-04-18 23:09:30 +02:00
|
|
|
|
2008-10-07 10:57:09 +02:00
|
|
|
/**
|
|
|
|
* Constructor
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
function __construct()
|
2005-12-19 05:23:14 +01:00
|
|
|
{
|
2008-10-07 10:57:09 +02:00
|
|
|
parent::__construct();
|
2008-04-18 23:09:30 +02:00
|
|
|
|
2008-03-09 08:33:42 +01:00
|
|
|
$this->pm_integration = $this->config_data['pm_integration'];
|
|
|
|
$this->ts_viewtype = $this->config_data['ts_viewtype'];
|
2005-12-19 05:23:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function view()
|
|
|
|
{
|
|
|
|
$this->edit(null,true);
|
|
|
|
}
|
2008-04-18 23:09:30 +02:00
|
|
|
|
2005-12-19 05:23:14 +01:00
|
|
|
function edit($content = null,$view = false)
|
|
|
|
{
|
2016-04-26 20:27:29 +02:00
|
|
|
$etpl = new Etemplate('timesheet.edit');
|
2005-12-19 05:23:14 +01:00
|
|
|
if (!is_array($content))
|
|
|
|
{
|
2010-02-05 04:34:17 +01:00
|
|
|
if ($_GET['msg']) $msg = strip_tags($_GET['msg']);
|
2010-03-23 13:54:00 +01:00
|
|
|
|
2005-12-19 05:23:14 +01:00
|
|
|
if ($view || (int)$_GET['ts_id'])
|
|
|
|
{
|
|
|
|
if (!$this->read((int)$_GET['ts_id']))
|
|
|
|
{
|
2016-04-26 20:27:29 +02:00
|
|
|
Framework::window_close(lang('Permission denied!!!'));
|
2005-12-19 05:23:14 +01:00
|
|
|
}
|
2016-04-26 20:27:29 +02:00
|
|
|
if (!$view && !$this->check_acl(Acl::EDIT))
|
2005-12-19 05:23:14 +01:00
|
|
|
{
|
|
|
|
$view = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else // new entry
|
|
|
|
{
|
|
|
|
$this->data = array(
|
2009-05-06 09:04:29 +02:00
|
|
|
'ts_start' => $this->today,
|
2014-01-30 16:39:56 +01:00
|
|
|
'start_time' => '', // force empty start-time
|
2016-04-26 20:27:29 +02:00
|
|
|
'end_time' => Api\DateTime::to($this->now,'H:i'),
|
2009-05-06 09:04:29 +02:00
|
|
|
'ts_owner' => $GLOBALS['egw_info']['user']['account_id'],
|
|
|
|
'cat_id' => (int) $_REQUEST['cat_id'],
|
2010-03-23 13:54:00 +01:00
|
|
|
'ts_status'=> $GLOBALS['egw_info']['user']['preferences']['timesheet']['predefined_status'],
|
2016-08-12 18:39:06 +02:00
|
|
|
'ts_project' => $_REQUEST['ts_project'],
|
|
|
|
'ts_title_blur' => $_REQUEST['ts_project'],
|
2005-12-19 05:23:14 +01:00
|
|
|
);
|
2016-08-18 22:04:18 +02:00
|
|
|
if(!is_numeric($_REQUEST['ts_project']))
|
|
|
|
{
|
|
|
|
$this->data['pm_id'] = $this->find_pm_id($_REQUEST['ts_project']);
|
|
|
|
}
|
2005-12-19 05:23:14 +01:00
|
|
|
}
|
2014-01-30 16:39:56 +01:00
|
|
|
$matches = null;
|
2008-04-18 23:09:30 +02:00
|
|
|
$referer = preg_match('/menuaction=([^&]+)/',$_SERVER['HTTP_REFERER'],$matches) ? $matches[1] :
|
2009-05-06 09:04:29 +02:00
|
|
|
(strpos($_SERVER['HTTP_REFERER'],'/infolog/index.php') !== false ? 'infolog.infolog_ui.index' : TIMESHEET_APP.'.timesheet_ui.index');
|
2011-04-19 20:53:31 +02:00
|
|
|
|
2016-11-24 18:20:45 +01:00
|
|
|
if($_GET['action'] == 'copy')
|
|
|
|
{
|
|
|
|
$this->create_copy();
|
|
|
|
$msg = lang('%1 copied - the copy can now be edited', lang(Link::get_registry(TIMESHEET_APP,'entry')));
|
|
|
|
}
|
2011-11-10 09:45:44 +01:00
|
|
|
if (!$this->check_statusForEditRights($this->data))
|
2009-09-08 11:23:41 +02:00
|
|
|
{
|
2011-11-10 09:45:44 +01:00
|
|
|
$view = true; //only admin can edit with this status
|
|
|
|
$only_admin_edit = true;
|
|
|
|
$msg = lang('only Admin can edit this status');
|
2009-09-08 11:23:41 +02:00
|
|
|
}
|
2016-08-12 18:39:06 +02:00
|
|
|
if(!$this->data['ts_project_blur'])
|
|
|
|
{
|
|
|
|
$this->data['ts_project_blur'] = $this->data['pm_id'] ? Link::title('projectmanager', $this->data['pm_id']) : '';
|
|
|
|
}
|
2005-12-19 05:23:14 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-06-25 19:00:41 +02:00
|
|
|
//echo "<p>ts_start=$content[ts_start], start_time=$content[start_time], end_time=$content[end_time], ts_duration=$content[ts_duration], ts_quantity=$content[ts_quantity]</p>\n";
|
2009-10-01 16:29:30 +02:00
|
|
|
if (!isset($GLOBALS['egw_info']['user']['apps']['admin']) && $content['ts_status'])
|
|
|
|
{
|
|
|
|
if ($this->status_labels_config[$content['ts_status']]['admin'])
|
|
|
|
{
|
|
|
|
$view = true; //only admin can edit with this status
|
|
|
|
$only_admin_edit = true;
|
|
|
|
$msg = lang('only Admin can edit this status');
|
|
|
|
}
|
|
|
|
}
|
2009-11-04 14:02:05 +01:00
|
|
|
if ($this->ts_viewtype == 'short')
|
|
|
|
{
|
2014-09-10 00:20:52 +02:00
|
|
|
$content['ts_description'] = $content['ts_description_short'];
|
2009-11-14 19:02:21 +01:00
|
|
|
}
|
2009-10-26 09:17:06 +01:00
|
|
|
// we only need 2 out of 3 values from start-, end-time or duration (the date in ts_start is always required!)
|
2014-01-30 16:39:56 +01:00
|
|
|
if (isset($content['start_time'])) // start-time specified
|
2009-10-26 09:17:06 +01:00
|
|
|
{
|
|
|
|
//$content['ts_start'] += $content['start_time'];
|
2016-04-26 20:27:29 +02:00
|
|
|
$start = new Api\DateTime($content['ts_start']);
|
2009-10-26 09:17:06 +01:00
|
|
|
$start_time = explode(':',$content['start_time']);
|
|
|
|
$start->setTime($start_time[0],$start_time[1]);
|
|
|
|
$content['ts_start'] = $start->format('ts');
|
|
|
|
}
|
2014-01-30 16:39:56 +01:00
|
|
|
if (isset($content['end_time'])) // end-time specified
|
2006-09-12 12:37:13 +02:00
|
|
|
{
|
2016-04-26 20:27:29 +02:00
|
|
|
$end = new Api\DateTime($content['ts_start']);
|
2009-10-26 09:17:06 +01:00
|
|
|
$end_time = explode(':',$content['end_time']);
|
|
|
|
$end->setTime($end_time[0],$end_time[1]);
|
2006-09-12 12:37:13 +02:00
|
|
|
}
|
2009-10-26 09:17:06 +01:00
|
|
|
if ($end && $start) // start- & end-time --> calculate the duration
|
2006-09-12 12:37:13 +02:00
|
|
|
{
|
2009-10-26 09:17:06 +01:00
|
|
|
$content['ts_duration'] = ($end->format('ts') - $start->format('ts')) / 60;
|
2013-05-24 09:07:04 +02:00
|
|
|
// check if negative duration is caused by wrap over midnight
|
|
|
|
if ($content['ts_duration'] < 0 && $content['ts_duration'] > -24*60)
|
|
|
|
{
|
2014-08-27 14:04:05 +02:00
|
|
|
$content['ts_duration'] += 24*60;
|
2013-05-24 09:07:04 +02:00
|
|
|
}
|
2009-10-26 09:17:06 +01:00
|
|
|
//echo "<p>end_time=$content[end_time], start_time=$content[start_time] --> duration=$content[ts_duration]</p>\n";
|
2006-09-12 12:37:13 +02:00
|
|
|
}
|
2009-10-26 09:17:06 +01:00
|
|
|
elseif ($content['ts_duration'] && $end) // no start, calculate from end and duration
|
2006-09-12 12:37:13 +02:00
|
|
|
{
|
2009-10-26 09:17:06 +01:00
|
|
|
$content['ts_start'] = $end->format('ts') - 60*$content['ts_duration'];
|
2016-04-26 20:27:29 +02:00
|
|
|
//echo "<p>end_time=$content[end_time], duration=$content[ts_duration] --> ts_start=$content[ts_start]=".Api\DateTime::to($content['ts_start'])."</p>\n";
|
2006-09-12 12:37:13 +02:00
|
|
|
}
|
2006-10-19 20:52:18 +02:00
|
|
|
if ($content['ts_duration'] > 0) unset($content['end_time']);
|
2006-09-12 12:37:13 +02:00
|
|
|
// now we only deal with start (date+time) and duration
|
2006-01-11 06:17:15 +01:00
|
|
|
list($button) = @each($content['button']);
|
2005-12-19 05:23:14 +01:00
|
|
|
$view = $content['view'];
|
|
|
|
$referer = $content['referer'];
|
2016-04-26 20:27:29 +02:00
|
|
|
$content['ts_project_blur'] = $content['pm_id'] ? Link::title('projectmanager', $content['pm_id']) : '';
|
2005-12-19 05:23:14 +01:00
|
|
|
$this->data = $content;
|
2009-09-24 14:42:54 +02:00
|
|
|
foreach(array('button','view','referer','tabs','start_time') as $key)
|
2005-12-19 05:23:14 +01:00
|
|
|
{
|
|
|
|
unset($this->data[$key]);
|
|
|
|
}
|
|
|
|
switch($button)
|
|
|
|
{
|
|
|
|
case 'edit':
|
2016-04-26 20:27:29 +02:00
|
|
|
if ($this->check_acl(Acl::EDIT) && !$only_admin_edit) $view = false;
|
2005-12-19 05:23:14 +01:00
|
|
|
break;
|
2008-04-18 23:09:30 +02:00
|
|
|
|
2012-10-22 20:31:11 +02:00
|
|
|
case 'undelete':
|
2012-10-23 18:59:14 +02:00
|
|
|
if($content['ts_status'] == self::DELETED_STATUS)
|
|
|
|
{
|
|
|
|
unset($content['ts_status']);
|
|
|
|
$this->data['ts_status'] = '';
|
|
|
|
}
|
2012-10-22 20:31:11 +02:00
|
|
|
$button = 'apply';
|
|
|
|
// fall through
|
2005-12-19 05:23:14 +01:00
|
|
|
case 'save':
|
|
|
|
case 'save_new':
|
|
|
|
case 'apply':
|
2017-08-25 18:11:31 +02:00
|
|
|
if (($this->data['ts_quantity'] === '' || $this->ts_viewtype == 'short') && $this->data['ts_duration']) // set the quantity (in h) from the duration (in min)
|
2005-12-19 05:23:14 +01:00
|
|
|
{
|
2014-11-17 09:40:49 +01:00
|
|
|
// We need to keep the actual value of ts_quantity when we are storing it, as it is used in price calculation
|
|
|
|
// and rounding it causes miscalculation on prices
|
|
|
|
$this->data['ts_quantity'] = $this->data['ts_duration'] / 60.0;
|
2005-12-19 05:23:14 +01:00
|
|
|
}
|
2017-08-25 18:11:31 +02:00
|
|
|
if ($this->data['ts_quantity'] === '')
|
2006-09-12 17:21:23 +02:00
|
|
|
{
|
|
|
|
$etpl->set_validation_error('ts_quantity',lang('Field must not be empty !!!'));
|
|
|
|
}
|
2014-08-27 14:04:05 +02:00
|
|
|
if ($this->data['ts_duration'] < 0)
|
2006-10-19 20:52:18 +02:00
|
|
|
{
|
2014-08-27 14:04:05 +02:00
|
|
|
$etpl->set_validation_error('start_time',lang('Starttime has to be before endtime !!!'));
|
2006-10-19 20:52:18 +02:00
|
|
|
}
|
2008-04-18 23:09:30 +02:00
|
|
|
// set ts_title to ts_project if short viewtype (title is not editable)
|
|
|
|
if($this->ts_viewtype == 'short')
|
2007-05-25 10:31:05 +02:00
|
|
|
{
|
2016-10-18 18:01:54 +02:00
|
|
|
$this->data['ts_title'] = $this->data['ts_project'] = $this->data['pm_id'] ?
|
|
|
|
Link::title('projectmanager', $this->data['pm_id']) :
|
|
|
|
$this->data['ts_project'];
|
2007-05-25 10:31:05 +02:00
|
|
|
}
|
2006-09-12 17:21:23 +02:00
|
|
|
if (!$this->data['ts_title'])
|
|
|
|
{
|
2008-04-18 23:09:30 +02:00
|
|
|
$this->data['ts_title'] = $this->data['ts_title_blur'] ?
|
2011-03-03 18:06:57 +01:00
|
|
|
$this->data['ts_title_blur'] : $this->data['ts_project_blur'];
|
2007-06-09 16:56:49 +02:00
|
|
|
|
|
|
|
if (!$this->data['ts_title'])
|
|
|
|
{
|
|
|
|
$etpl->set_validation_error('ts_title',lang('Field must not be empty !!!'));
|
|
|
|
}
|
2012-05-22 13:58:10 +02:00
|
|
|
elseif($button != 'save_new')
|
2011-09-21 17:07:27 +02:00
|
|
|
{
|
|
|
|
// remove title-blur for same behavior after apply, as for opening the saved entry again
|
|
|
|
unset($this->data['ts_title_blur']);
|
|
|
|
unset($content['ts_title_blur']);
|
|
|
|
unset($this->data['ts_project_blur']);
|
|
|
|
unset($content['ts_project_blur']);
|
|
|
|
}
|
2006-09-12 17:21:23 +02:00
|
|
|
}
|
|
|
|
if ($etpl->validation_errors()) break; // the user need to fix the error, before we can save the entry
|
2005-12-19 05:23:14 +01:00
|
|
|
|
2014-10-14 17:58:37 +02:00
|
|
|
// account for changed project --> remove old one from links and add new one
|
|
|
|
if ((int) $this->data['pm_id'] != (int) $this->data['old_pm_id'])
|
|
|
|
{
|
|
|
|
// update links accordingly
|
|
|
|
if ($this->data['pm_id'])
|
|
|
|
{
|
2016-04-26 20:27:29 +02:00
|
|
|
Link::link(TIMESHEET_APP,$content['link_to']['to_id'],'projectmanager',$this->data['pm_id']);
|
2014-10-14 17:58:37 +02:00
|
|
|
}
|
|
|
|
if ($this->data['old_pm_id'])
|
|
|
|
{
|
2016-04-26 20:27:29 +02:00
|
|
|
Link::unlink2(0,TIMESHEET_APP,$content['link_to']['to_id'],0,'projectmanager',$this->data['old_pm_id']);
|
2014-10-14 17:58:37 +02:00
|
|
|
unset($this->data['old_pm_id']);
|
|
|
|
}
|
|
|
|
}
|
2012-05-30 10:21:18 +02:00
|
|
|
// check if we are linked to a project, but that is NOT set as project
|
|
|
|
if (!$this->data['pm_id'] && is_array($content['link_to']['to_id']))
|
|
|
|
{
|
|
|
|
foreach($content['link_to']['to_id'] as $data)
|
|
|
|
{
|
|
|
|
if ($data['app'] == 'projectmanager')
|
|
|
|
{
|
|
|
|
$this->data['pm_id'] = $data['id'];
|
2016-04-26 20:27:29 +02:00
|
|
|
$this->data['ts_project_blur'] = Link::title('projectmanager', $data['id']);
|
2012-05-30 10:21:18 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-12-19 05:23:14 +01:00
|
|
|
if ($this->save() != 0)
|
|
|
|
{
|
|
|
|
$msg = lang('Error saving the entry!!!');
|
|
|
|
$button = '';
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$msg = lang('Entry saved');
|
|
|
|
if (is_array($content['link_to']['to_id']) && count($content['link_to']['to_id']))
|
|
|
|
{
|
2016-04-26 20:27:29 +02:00
|
|
|
Link::link(TIMESHEET_APP,$this->data['ts_id'],$content['link_to']['to_id']);
|
2005-12-19 05:23:14 +01:00
|
|
|
}
|
|
|
|
}
|
2016-04-26 20:27:29 +02:00
|
|
|
Framework::refresh_opener($msg, 'timesheet', $this->data['ts_id'], $content['ts_id'] ? 'edit' : 'add');
|
2005-12-19 05:23:14 +01:00
|
|
|
if ($button == 'apply') break;
|
|
|
|
if ($button == 'save_new')
|
|
|
|
{
|
2006-09-12 12:37:13 +02:00
|
|
|
$msg .= ', '.lang('creating new entry'); // giving some feedback to the user
|
|
|
|
|
|
|
|
if (!is_array($content['link_to']['to_id'])) // set links again, so new entry gets the same links as the existing one
|
|
|
|
{
|
|
|
|
$content['link_to']['to_id'] = 0;
|
2016-04-26 20:27:29 +02:00
|
|
|
foreach(Link::get_links(TIMESHEET_APP,$this->data['ts_id'],'!'.Link::VFS_APPNAME) as $link)
|
2006-09-12 12:37:13 +02:00
|
|
|
{
|
2016-04-26 20:27:29 +02:00
|
|
|
Link::link(TIMESHEET_APP,$content['link_to']['to_id'],$link['app'],$link['id'],$link['remark']);
|
2006-09-12 12:37:13 +02:00
|
|
|
}
|
|
|
|
}
|
2005-12-19 05:23:14 +01:00
|
|
|
// create a new entry
|
|
|
|
$this->data['ts_start'] += 60 * $this->data['ts_duration'];
|
2017-03-01 19:39:01 +01:00
|
|
|
foreach(array('ts_id','ts_title','ts_description','ts_duration','ts_quantity','ts_modified','ts_modifier','link_to') as $name)
|
2005-12-19 05:23:14 +01:00
|
|
|
{
|
|
|
|
unset($this->data[$name]);
|
|
|
|
}
|
2007-06-07 11:13:55 +02:00
|
|
|
// save the selected project, to delete the project-link, if the user changes the project
|
|
|
|
$this->data['old_pm_id'] = $this->data['pm_id'];
|
2017-03-17 16:30:05 +01:00
|
|
|
if($this->pm_integration == 'none')
|
|
|
|
{
|
|
|
|
unset($this->data['pm_id']);
|
|
|
|
}
|
2005-12-19 05:23:14 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
// fall-through for save
|
|
|
|
case 'delete':
|
|
|
|
if ($button == 'delete')
|
|
|
|
{
|
2006-01-11 06:17:15 +01:00
|
|
|
if ($this->delete())
|
|
|
|
{
|
|
|
|
$msg = lang('Entry deleted');
|
2016-04-26 20:27:29 +02:00
|
|
|
Framework::refresh_opener($msg, 'timesheet', $this->data['ts_id'], 'delete');
|
2006-01-11 06:17:15 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$msg = lang('Error deleting the entry!!!');
|
|
|
|
break; // dont close window
|
|
|
|
}
|
2005-12-19 05:23:14 +01:00
|
|
|
}
|
2006-01-11 06:17:15 +01:00
|
|
|
// fall-through for save
|
2005-12-19 05:23:14 +01:00
|
|
|
case 'cancel':
|
2016-04-26 20:27:29 +02:00
|
|
|
Framework::window_close();
|
2005-12-19 05:23:14 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
$preserv = $this->data + array(
|
2009-05-06 09:04:29 +02:00
|
|
|
'view' => $view,
|
|
|
|
'referer' => $referer,
|
|
|
|
'ts_title_blur' => $content['ts_title_blur'],
|
2005-12-19 05:23:14 +01:00
|
|
|
);
|
2006-01-11 06:17:15 +01:00
|
|
|
$content = array_merge($this->data,array(
|
2009-05-06 09:04:29 +02:00
|
|
|
'msg' => $msg,
|
|
|
|
'view' => $view,
|
2009-09-24 14:42:54 +02:00
|
|
|
'tabs' => $content['tabs'],
|
2009-05-06 09:04:29 +02:00
|
|
|
'link_to' => array(
|
2017-04-04 16:52:25 +02:00
|
|
|
'to_id' => $this->data['ts_id'] ? $this->data['ts_id'] :
|
2016-11-24 18:20:45 +01:00
|
|
|
($this->data['link_to']['to_id'] ? $this->data['link_to']['to_id'] : $content['link_to']['to_id']),
|
2009-05-06 09:04:29 +02:00
|
|
|
'to_app' => TIMESHEET_APP,
|
|
|
|
),
|
|
|
|
'ts_quantity_blur' => $this->data['ts_duration'] ? round($this->data['ts_duration'] / 60.0,3) : '',
|
2014-06-12 10:30:21 +02:00
|
|
|
'ts_quantity' => $this->data['ts_duration']/60.0 == $this->data['ts_quantity'] ? null : $this->data['ts_quantity'],
|
2014-01-30 16:39:56 +01:00
|
|
|
'start_time' => isset($this->data['start_time']) ? $this->data['start_time'] : $this->data['ts_start'],
|
2009-05-06 09:04:29 +02:00
|
|
|
'pm_integration' => $this->pm_integration,
|
2012-10-22 20:42:02 +02:00
|
|
|
'no_ts_status' => !$this->status_labels && ($this->data['ts_status'] != self::DELETED_STATUS),
|
2006-01-11 06:17:15 +01:00
|
|
|
));
|
2006-02-08 19:30:20 +01:00
|
|
|
$links = array();
|
2006-03-21 14:52:49 +01:00
|
|
|
// create links specified in the REQUEST (URL)
|
|
|
|
if (!$this->data['ts_id'] && isset($_REQUEST['link_app']) && isset($_REQUEST['link_id']) && !is_array($content['link_to']['to_id']))
|
2005-12-19 05:23:14 +01:00
|
|
|
{
|
2006-03-21 14:52:49 +01:00
|
|
|
$link_ids = is_array($_REQUEST['link_id']) ? $_REQUEST['link_id'] : array($_REQUEST['link_id']);
|
|
|
|
foreach(is_array($_REQUEST['link_app']) ? $_REQUEST['link_app'] : array($_REQUEST['link_app']) as $n => $link_app)
|
2005-12-19 05:23:14 +01:00
|
|
|
{
|
2006-03-21 14:52:49 +01:00
|
|
|
$link_id = $link_ids[$n];
|
|
|
|
if (preg_match('/^[a-z_0-9-]+:[:a-z_0-9-]+$/i',$link_app.':'.$link_id)) // gard against XSS
|
|
|
|
{
|
|
|
|
switch ($link_app)
|
|
|
|
{
|
2011-03-03 18:06:57 +01:00
|
|
|
case 'projectmanager':
|
|
|
|
$links[] = $link_id;
|
|
|
|
// fall-through;
|
|
|
|
default:
|
2011-05-30 16:21:27 +02:00
|
|
|
if(!$n)
|
|
|
|
{
|
|
|
|
// get title from first linked app
|
2016-04-26 20:27:29 +02:00
|
|
|
$preserv['ts_title_blur'] = Link::title($link_app,$link_id);
|
2011-05-30 16:21:27 +02:00
|
|
|
// ask first linked app via "timesheet_set" hook, for further data to set, incl. links
|
2016-04-26 20:27:29 +02:00
|
|
|
if (($set = Api\Hooks::single(array('location'=>'timesheet_set','id'=>$link_id),$link_app)))
|
2011-05-30 16:21:27 +02:00
|
|
|
{
|
|
|
|
foreach((array)$set['link_app'] as $i => $l_app)
|
|
|
|
{
|
2016-04-26 20:27:29 +02:00
|
|
|
if (($l_id=$set['link_id'][$i])) Link::link(TIMESHEET_APP,$content['link_to']['to_id'],$l_app,$l_id);
|
2011-05-30 16:21:27 +02:00
|
|
|
if ($l_app == 'projectmanager') $links[] = $l_id;
|
|
|
|
}
|
|
|
|
unset($set['link_app']);
|
|
|
|
unset($set['link_id']);
|
|
|
|
|
|
|
|
$content = array_merge($content,$set);
|
|
|
|
}
|
|
|
|
}
|
2011-03-03 18:06:57 +01:00
|
|
|
break;
|
2006-03-21 14:52:49 +01:00
|
|
|
}
|
2016-04-26 20:27:29 +02:00
|
|
|
Link::link(TIMESHEET_APP,$content['link_to']['to_id'],$link_app,$link_id);
|
2006-03-21 14:52:49 +01:00
|
|
|
}
|
2005-12-19 05:23:14 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
elseif ($this->data['ts_id'])
|
|
|
|
{
|
2016-04-26 20:27:29 +02:00
|
|
|
$links = Link::get_links(TIMESHEET_APP,$this->data['ts_id'],'projectmanager');
|
2005-12-19 05:23:14 +01:00
|
|
|
}
|
2007-01-12 02:27:37 +01:00
|
|
|
// make all linked projects availible for the pm-pricelist widget, to be able to choose prices from all
|
|
|
|
$content['all_pm_ids'] = array_values($links);
|
2008-04-18 23:09:30 +02:00
|
|
|
|
2007-05-25 10:31:05 +02:00
|
|
|
// set old id, pm selector (for later removal)
|
2008-04-18 23:09:30 +02:00
|
|
|
if (count($links) > 0)
|
|
|
|
{
|
2007-05-25 10:31:05 +02:00
|
|
|
$preserv['old_pm_id'] = array_shift($links);
|
|
|
|
}
|
2016-08-26 10:27:36 +02:00
|
|
|
if ((!isset($this->data['pm_id']) || $this->data['pm_id'] === false) && $preserv['old_pm_id'])
|
2007-06-03 17:01:27 +02:00
|
|
|
{
|
2007-05-25 10:31:05 +02:00
|
|
|
$content['pm_id'] = $preserv['old_pm_id'];
|
|
|
|
}
|
2007-06-03 17:01:27 +02:00
|
|
|
if ($this->pm_integration == 'full')
|
|
|
|
{
|
|
|
|
$preserv['ts_project'] = $preserv['ts_project_blur'];
|
|
|
|
}
|
2009-09-10 10:20:27 +02:00
|
|
|
$content['history'] = array(
|
2014-06-12 10:30:21 +02:00
|
|
|
'id' => $this->data['ts_id'],
|
|
|
|
'app' => 'timesheet',
|
|
|
|
'status-widgets' => array(
|
|
|
|
'ts_status' => $this->status_labels + array(self::DELETED_STATUS => 'Deleted'),
|
|
|
|
'ts_modifier' => 'select-account',
|
|
|
|
'cat_id' => 'select-cat',
|
|
|
|
),
|
2009-09-10 10:20:27 +02:00
|
|
|
);
|
2011-04-19 20:53:31 +02:00
|
|
|
$sel_options['status'] = $this->field2label;
|
|
|
|
|
2007-06-07 11:13:55 +02:00
|
|
|
// the actual title-blur is either the preserved title blur (if we are called from infolog entry),
|
|
|
|
// or the preserved project-blur comming from the current selected project
|
2014-10-14 17:58:37 +02:00
|
|
|
$content['ts_title_blur'] = $preserv['ts_title_blur'] ? $preserv['ts_title_blur'] : $content['ts_project_blur'];
|
2005-12-19 05:23:14 +01:00
|
|
|
$readonlys = array(
|
2016-04-26 20:27:29 +02:00
|
|
|
'button[delete]' => !$this->data['ts_id'] || !$this->check_acl(Acl::DELETE) || $this->data['ts_status'] == self::DELETED_STATUS,
|
2012-10-22 20:31:11 +02:00
|
|
|
'button[undelete]' => $this->data['ts_status'] != self::DELETED_STATUS,
|
2016-04-26 20:27:29 +02:00
|
|
|
'button[edit]' => !$view || !$this->check_acl(Acl::EDIT),
|
2009-05-06 09:04:29 +02:00
|
|
|
'button[save]' => $view,
|
|
|
|
'button[save_new]' => $view,
|
|
|
|
'button[apply]' => $view,
|
2005-12-19 05:23:14 +01:00
|
|
|
);
|
2009-09-10 10:20:27 +02:00
|
|
|
|
2005-12-19 05:23:14 +01:00
|
|
|
if ($view)
|
|
|
|
{
|
2006-01-11 06:17:15 +01:00
|
|
|
foreach(array_merge(array_keys($this->data),array('pm_id','pl_id','link_to')) as $key)
|
2005-12-19 05:23:14 +01:00
|
|
|
{
|
|
|
|
$readonlys[$key] = true;
|
|
|
|
}
|
2006-11-20 15:17:28 +01:00
|
|
|
$readonlys['start_time'] = $readonlys['end_time'] = true;
|
2005-12-19 05:23:14 +01:00
|
|
|
}
|
2016-04-26 20:27:29 +02:00
|
|
|
$edit_grants = $this->grant_list(Acl::EDIT);
|
2005-12-19 05:23:14 +01:00
|
|
|
if (count($edit_grants) == 1)
|
|
|
|
{
|
|
|
|
$readonlys['ts_owner'] = true;
|
|
|
|
}
|
2017-09-05 17:04:31 +02:00
|
|
|
// in view mode or when editing existing entries, we need to add the owner
|
|
|
|
// if it does not exist, otherwise it's displayed empty or missing
|
|
|
|
if (($view || $content['ts_id']) && $content['ts_owner'] && !isset($edit_grants[$content['ts_owner']]))
|
2011-04-19 20:53:31 +02:00
|
|
|
{
|
2016-04-26 20:27:29 +02:00
|
|
|
$edit_grants[$content['ts_owner']] = Api\Accounts::username($content['ts_owner']);
|
2011-04-19 20:53:31 +02:00
|
|
|
}
|
2009-09-10 10:20:27 +02:00
|
|
|
$sel_options['ts_owner'] = $edit_grants;
|
|
|
|
$sel_options['ts_status'] = $this->status_labels;
|
2012-10-23 18:59:14 +02:00
|
|
|
if($this->config_data['history'] && $content['ts_status'] == self::DELETED_STATUS)
|
2012-10-22 20:42:02 +02:00
|
|
|
{
|
|
|
|
$sel_options['ts_status'][self::DELETED_STATUS] = 'Deleted';
|
|
|
|
}
|
2005-12-19 05:23:14 +01:00
|
|
|
$GLOBALS['egw_info']['flags']['app_header'] = lang('timesheet').' - '.
|
2009-05-06 09:04:29 +02:00
|
|
|
($view ? lang('View') : ($this->data['ts_id'] ? lang('Edit') : lang('Add')));
|
2008-04-18 23:09:30 +02:00
|
|
|
|
2006-01-11 06:17:15 +01:00
|
|
|
// supress unknow widget 'projectmanager-*', if projectmanager is not installed or old
|
|
|
|
if (!@file_exists(EGW_INCLUDE_ROOT.'/projectmanager/inc/class.projectmanager_widget.inc.php'))
|
|
|
|
{
|
|
|
|
$etpl->set_cell_attribute('pm_id','disabled',true);
|
|
|
|
$etpl->set_cell_attribute('pl_id','disabled',true);
|
2008-04-18 23:09:30 +02:00
|
|
|
}
|
2007-03-08 12:22:57 +01:00
|
|
|
|
2008-04-18 23:09:30 +02:00
|
|
|
if($this->ts_viewtype == 'short')
|
2007-06-03 17:01:27 +02:00
|
|
|
{
|
2009-09-24 14:42:54 +02:00
|
|
|
$content['ts_viewtype'] = $readonlys['tabs']['notes'] = true;
|
2014-09-10 00:20:52 +02:00
|
|
|
$content['ts_description_short'] = $content['ts_description'];
|
2016-08-18 22:04:18 +02:00
|
|
|
if(!$content['pm_id'] && $this->pm_integration != 'full' && $content['ts_project'])
|
|
|
|
{
|
|
|
|
$etpl->setElementAttribute('pm_id','blur',$content['ts_project']);
|
|
|
|
}
|
2007-03-08 12:22:57 +01:00
|
|
|
}
|
2009-09-24 14:42:54 +02:00
|
|
|
if (!$this->customfields) $readonlys['tabs']['customfields'] = true; // suppress tab if there are not customfields
|
|
|
|
if (!$this->data['ts_id']) $readonlys['tabs']['history'] = true; //suppress history for the first loading without ID
|
2010-03-23 13:54:00 +01:00
|
|
|
|
2009-09-10 10:20:27 +02:00
|
|
|
return $etpl->exec(TIMESHEET_APP.'.timesheet_ui.edit',$content,$sel_options,$readonlys,$preserv,2);
|
2005-12-19 05:23:14 +01:00
|
|
|
}
|
2008-04-18 23:09:30 +02:00
|
|
|
|
2006-09-12 12:37:13 +02:00
|
|
|
/**
|
|
|
|
* Calculate the time from a timestamp containing date & time
|
|
|
|
*
|
|
|
|
* @param int $datetime
|
|
|
|
* @return int
|
|
|
|
*/
|
|
|
|
function datetime2time($datetime)
|
|
|
|
{
|
|
|
|
if (!$datetime) return 0;
|
|
|
|
|
|
|
|
return $datetime - mktime(0,0,0,date('m',$datetime),date('d',$datetime),date('Y',$datetime));
|
|
|
|
}
|
2005-12-19 05:23:14 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* query projects for nextmatch in the projects-list
|
|
|
|
*
|
2016-04-26 20:27:29 +02:00
|
|
|
* reimplemented from Api\Storage\Base to disable action-buttons based on the Acl and make some modification on the data
|
2005-12-19 05:23:14 +01:00
|
|
|
*
|
2006-03-27 14:20:06 +02:00
|
|
|
* @param array &$query
|
2005-12-19 05:23:14 +01:00
|
|
|
* @param array &$rows returned rows/cups
|
2016-04-26 20:27:29 +02:00
|
|
|
* @param array &$readonlys eg. to disable buttons based on Acl
|
2014-06-12 14:39:52 +02:00
|
|
|
* @param boolean $id_only if true only return (via $rows) an array of contact-ids, dont save state to session
|
2007-03-08 12:22:57 +01:00
|
|
|
* @return int total number of contacts matching the selection
|
2005-12-19 05:23:14 +01:00
|
|
|
*/
|
2007-03-08 12:22:57 +01:00
|
|
|
function get_rows(&$query_in,&$rows,&$readonlys,$id_only=false)
|
2005-12-19 05:23:14 +01:00
|
|
|
{
|
2006-03-27 14:20:06 +02:00
|
|
|
$this->show_sums = false;
|
2017-05-23 23:32:49 +02:00
|
|
|
$end_date = false;
|
2016-05-27 18:36:51 +02:00
|
|
|
|
|
|
|
// Date filter
|
2017-05-23 23:32:49 +02:00
|
|
|
if($query_in['filter'] === 'custom')
|
2016-05-27 18:36:51 +02:00
|
|
|
{
|
2017-05-23 23:32:49 +02:00
|
|
|
$end_date = $query_in['enddate'] ? $query_in['enddate'] : false;
|
2016-05-27 18:36:51 +02:00
|
|
|
$query_in['startdate'] = $query_in['startdate'] ? $query_in['startdate'] : 1;
|
|
|
|
}
|
2016-05-25 20:59:44 +02:00
|
|
|
$date_filter = $this->date_filter($query_in['filter'],$query_in['startdate'],$end_date);
|
2016-05-04 00:18:49 +02:00
|
|
|
|
|
|
|
if ($query_in['startdate'])
|
2006-03-27 14:20:06 +02:00
|
|
|
{
|
2016-05-04 00:18:49 +02:00
|
|
|
$start = explode('-',date('Y-m-d',$query_in['startdate']+12*60*60));
|
2016-05-25 20:59:44 +02:00
|
|
|
$end = explode('-',date('Y-m-d',$end_date ? $end_date : $query_in['startdate']+7.5*24*60*60));
|
2008-04-18 23:09:30 +02:00
|
|
|
|
2016-05-04 00:18:49 +02:00
|
|
|
// show year-sums, if we are year-aligned (show full years)?
|
|
|
|
if ((int)$start[2] == 1 && (int)$start[1] == 1 && (int)$end[2] == 31 && (int)$end[1] == 12)
|
2006-03-27 14:20:06 +02:00
|
|
|
{
|
2016-05-04 00:18:49 +02:00
|
|
|
$this->show_sums[] = 'year';
|
|
|
|
}
|
|
|
|
// show month-sums, if we are month-aligned (show full monthes)?
|
|
|
|
if ((int)$start[2] == 1 && (int)$end[2] == (int)date('d',mktime(12,0,0,$end[1]+1,0,$end[0])))
|
|
|
|
{
|
|
|
|
$this->show_sums[] = 'month';
|
|
|
|
}
|
|
|
|
// show week-sums, if we are week-aligned (show full weeks)?
|
|
|
|
$week_start_day = $GLOBALS['egw_info']['user']['preferences']['calendar']['weekdaystarts'];
|
|
|
|
if (!$week_start_day) $week_start_day = 'Sunday';
|
|
|
|
switch($week_start_day)
|
|
|
|
{
|
|
|
|
case 'Sunday': $week_end_day = 'Saturday'; break;
|
|
|
|
case 'Monday': $week_end_day = 'Sunday'; break;
|
|
|
|
case 'Saturday': $week_end_day = 'Friday'; break;
|
|
|
|
}
|
|
|
|
$filter_start_day = date('l',$query_in['startdate']+12*60*60);
|
2017-05-23 23:32:49 +02:00
|
|
|
$filter_end_day = $end_date ? date('l',$end_date+12*60*60) : false;
|
2016-05-04 00:18:49 +02:00
|
|
|
//echo "<p align=right>prefs: $week_start_day - $week_end_day, filter: $filter_start_day - $filter_end_day</p>\n";
|
|
|
|
if ($filter_start_day == $week_start_day && (!$filter_end_day || $filter_end_day == $week_end_day))
|
|
|
|
{
|
|
|
|
$this->show_sums[] = 'week';
|
|
|
|
}
|
|
|
|
// show day-sums, if range <= 5 weeks
|
2017-05-23 23:32:49 +02:00
|
|
|
if (!$end_date || $end_date - $query_in['startdate'] < 36*24*60*60)
|
2016-05-04 00:18:49 +02:00
|
|
|
{
|
|
|
|
$this->show_sums[] = 'day';
|
2006-03-27 14:20:06 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
//echo "<p align=right>show_sums=".print_r($this->show_sums,true)."</p>\n";
|
2016-05-09 11:30:03 +02:00
|
|
|
if (!$id_only && !$query_in['csv_export']) Api\Cache::setSession(TIMESHEET_APP, 'index', $query_in);
|
2012-10-25 19:11:52 +02:00
|
|
|
|
|
|
|
// Refresh actions (undelete needs this)
|
|
|
|
$query_in['actions'] = $this->get_actions($query_in);
|
|
|
|
|
2006-03-27 14:20:06 +02:00
|
|
|
$query = $query_in; // keep the original query
|
2016-05-25 20:59:44 +02:00
|
|
|
$query['enddate'] = $end_date;
|
2009-09-26 13:17:19 +02:00
|
|
|
|
2009-02-16 09:36:22 +01:00
|
|
|
if($this->ts_viewtype == 'short') $query_in['options-selectcols'] = array('ts_quantity'=>false,'ts_unitprice'=>false,'ts_total'=>false);
|
2009-03-23 10:53:03 +01:00
|
|
|
if ($query['no_status']) $query_in['options-selectcols']['ts_status'] = false;
|
2010-03-23 13:54:00 +01:00
|
|
|
|
2009-09-28 11:25:24 +02:00
|
|
|
//_debug_array($query['col_filter']);
|
|
|
|
//echo "PM Integration:".$this->pm_integration.'<br>';
|
2006-09-12 17:21:23 +02:00
|
|
|
// PM project filter for the PM integration
|
2009-09-28 11:25:24 +02:00
|
|
|
if ($this->pm_integration == 'full')
|
|
|
|
{
|
|
|
|
unset($query['col_filter']['ts_project']);
|
|
|
|
}
|
|
|
|
if ((string)$query['col_filter']['pm_id'] != '' && (string)$query['col_filter']['pm_id'] != '0')
|
2006-09-12 17:21:23 +02:00
|
|
|
{
|
2016-04-26 20:27:29 +02:00
|
|
|
//$query['col_filter']['ts_id'] = Link::get_links('projectmanager',$query['col_filter']['pm_id'],'timesheet');
|
2007-03-08 12:22:57 +01:00
|
|
|
$query['col_filter']['ts_id'] = $this->get_ts_links($query['col_filter']['pm_id']);
|
2009-10-01 16:29:30 +02:00
|
|
|
if (empty($query['col_filter']['ts_id'])) $query['col_filter']['ts_id'] = -1;
|
2006-11-20 15:17:28 +01:00
|
|
|
if (!$query['col_filter']['ts_id']) $query['col_filter']['ts_id'] = 0;
|
2006-09-12 17:21:23 +02:00
|
|
|
}
|
2009-05-06 09:04:29 +02:00
|
|
|
if ((string)$query['col_filter']['pm_id'] != '' && (string)$query['col_filter']['pm_id'] == '0')
|
|
|
|
{
|
2009-01-27 16:51:04 +01:00
|
|
|
$query['col_filter']['ts_project'] = 0;
|
|
|
|
unset($query['col_filter']['ts_id']);
|
|
|
|
}
|
2006-09-12 17:21:23 +02:00
|
|
|
unset($query['col_filter']['pm_id']);
|
2008-04-18 23:09:30 +02:00
|
|
|
|
2009-09-26 13:17:19 +02:00
|
|
|
// handle linked filter (show only entries linked to a certain other entry)
|
|
|
|
if ($query['col_filter']['linked'])
|
|
|
|
{
|
2016-11-22 19:41:51 +01:00
|
|
|
if(!is_array($query['col_filter']['linked']))
|
|
|
|
{
|
|
|
|
list($app,$id) = explode(':',$query['col_filter']['linked']);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$app = $query['col_filter']['linked']['app'];
|
|
|
|
$id = $query['col_filter']['linked']['id'];
|
|
|
|
}
|
2016-04-26 20:27:29 +02:00
|
|
|
if (!($links = Link::get_links($app,$id,'timesheet')))
|
2009-09-26 13:17:19 +02:00
|
|
|
{
|
|
|
|
$rows = array(); // no infologs linked to project --> no rows to return
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
if (!$query['col_filter']['ts_id'])
|
|
|
|
{
|
|
|
|
$query['col_filter']['ts_id'] = array_values(array_unique($links));
|
|
|
|
}
|
|
|
|
// allow to combine with other filters using ts_id --> intersect ids
|
|
|
|
elseif (!($query['col_filter']['ts_id'] = array_intersect((array)$query['col_filter']['ts_id'],array_values(array_unique($links)))))
|
|
|
|
{
|
|
|
|
$rows = array(); // no infologs linked to project --> no rows to return
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
unset($query['col_filter']['linked']);
|
|
|
|
|
2006-09-12 17:21:23 +02:00
|
|
|
// filter for no project
|
2009-05-06 09:04:29 +02:00
|
|
|
if ((string)$query['col_filter']['ts_project'] == '0')
|
|
|
|
{
|
2009-01-27 16:51:04 +01:00
|
|
|
$query['col_filter']['ts_project'] = null;
|
|
|
|
}
|
2009-08-17 20:46:47 +02:00
|
|
|
// filter for no status
|
|
|
|
if ((string)$query['col_filter']['ts_status'] == '0')
|
|
|
|
{
|
|
|
|
$query['col_filter']['ts_status'] = null;
|
|
|
|
}
|
2009-01-27 16:51:04 +01:00
|
|
|
#_debug_array($query['col_filter']);
|
2009-09-08 11:23:41 +02:00
|
|
|
if (isset($this->status_labels_substatus[$query['col_filter']['ts_status']]))
|
|
|
|
{
|
|
|
|
$query['col_filter']['ts_status'] = $this->status_labels_substatus[$query['col_filter']['ts_status']];
|
|
|
|
foreach ($query['col_filter']['ts_status'] as $status_id)
|
|
|
|
{
|
|
|
|
if (isset($this->status_labels_substatus['2level'][$status_id]))
|
|
|
|
{
|
|
|
|
$query['col_filter']['ts_status'] = array_merge($query['col_filter']['ts_status'],$this->status_labels_substatus[$status_id]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-03-27 14:20:06 +02:00
|
|
|
if ((int)$query['filter2'] != (int)$GLOBALS['egw_info']['user']['preferences'][TIMESHEET_APP]['show_details'])
|
|
|
|
{
|
|
|
|
$GLOBALS['egw']->preferences->add(TIMESHEET_APP,'show_details',(int)$query['filter2']);
|
|
|
|
$GLOBALS['egw']->preferences->save_repository(true);
|
|
|
|
}
|
2006-09-12 17:21:23 +02:00
|
|
|
// category filter: cat_id or ''=All cats or 0=No cat
|
2005-12-19 05:23:14 +01:00
|
|
|
if ($query['cat_id'])
|
|
|
|
{
|
|
|
|
$cats = $GLOBALS['egw']->categories->return_all_children((int)$query['cat_id']);
|
|
|
|
$query['col_filter']['cat_id'] = count($cats) > 1 ? $cats : $query['cat_id'];
|
|
|
|
}
|
2006-09-12 17:21:23 +02:00
|
|
|
elseif ((string)$query['cat_id'] == '0') // no category
|
|
|
|
{
|
|
|
|
$query['col_filter']['cat_id'] = null;
|
|
|
|
}
|
|
|
|
else // all cats --> no filter
|
|
|
|
{
|
|
|
|
unset($query['col_filter']['cat_id']);
|
|
|
|
}
|
2006-03-21 23:18:29 +01:00
|
|
|
$GLOBALS['egw_info']['flags']['app_header'] = lang('timesheet');
|
|
|
|
if ($query['col_filter']['ts_owner'])
|
2005-12-19 05:23:14 +01:00
|
|
|
{
|
2016-04-26 20:27:29 +02:00
|
|
|
$GLOBALS['egw_info']['flags']['app_header'] .= ': '.Api\Accounts::username($query['col_filter']['ts_owner']);
|
2009-02-16 09:36:22 +01:00
|
|
|
#if ($GLOBALS['egw']->accounts->get_type($query['col_filter']['ts_owner']) == 'g') $GLOBALS['egw_info']['flags']['app_header'] .= ' '. lang("and its members");
|
|
|
|
#_debug_array($GLOBALS['egw']->accounts->members($query['col_filter']['ts_owner'],true));
|
2009-09-22 15:40:03 +02:00
|
|
|
if ($query['col_filter']['ts_owner']<0) $query['col_filter']['ts_owner'] = array_merge(array($query['col_filter']['ts_owner']),$GLOBALS['egw']->accounts->members($query['col_filter']['ts_owner'],true));
|
2005-12-19 05:23:14 +01:00
|
|
|
}
|
2006-03-21 23:18:29 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
unset($query['col_filter']['ts_owner']);
|
|
|
|
}
|
|
|
|
if ($query['filter'])
|
|
|
|
{
|
2006-03-27 14:20:06 +02:00
|
|
|
$query['col_filter'][0] = $date_filter;
|
2008-04-18 23:09:30 +02:00
|
|
|
|
2006-03-27 14:20:06 +02:00
|
|
|
// generate a meaningful app-header / report title
|
|
|
|
if ($this->show_sums['month'])
|
2006-03-21 23:18:29 +01:00
|
|
|
{
|
2006-03-27 14:20:06 +02:00
|
|
|
if ((int)$start[1] == 1 && (int) $end[1] == 12) // whole year(s)
|
2006-03-21 23:18:29 +01:00
|
|
|
{
|
2006-03-27 14:20:06 +02:00
|
|
|
$GLOBALS['egw_info']['flags']['app_header'] .= ': ' . $start[0] . ($start[0] != $end[0] ? ' - '.$end[0] : '');
|
2006-03-21 23:18:29 +01:00
|
|
|
}
|
2006-03-27 14:20:06 +02:00
|
|
|
else
|
2006-03-21 23:18:29 +01:00
|
|
|
{
|
2006-03-27 14:20:06 +02:00
|
|
|
$GLOBALS['egw_info']['flags']['app_header'] .= ': ' . lang(date('F',$query['startdate']+12*60*60)) . ' ' . $start[0];
|
|
|
|
if ($start[0] != $end[0] || $start[1] != $end[1])
|
|
|
|
{
|
|
|
|
$GLOBALS['egw_info']['flags']['app_header'] .= ' - ' . lang(date('F',$query['enddate']+12*60*60)) . ' ' . $end[0];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
elseif ($this->show_sums['week'])
|
|
|
|
{
|
|
|
|
$GLOBALS['egw_info']['flags']['app_header'] .= ': ' . lang('week') . ' ' . date('W',$query['startdate']+36*60*60) . '/' . $start[0];
|
|
|
|
if ($query['enddate'] && $query['enddate'] - $query['startdate'] > 10*24*60*60)
|
|
|
|
{
|
|
|
|
$GLOBALS['egw_info']['flags']['app_header'] .= ' - ' . date('W',$query['enddate']-36*60*60) . '/' . $end[0];
|
2006-03-21 23:18:29 +01:00
|
|
|
}
|
|
|
|
}
|
2014-08-25 20:22:50 +02:00
|
|
|
elseif ($query['startdate'])
|
2006-03-21 23:18:29 +01:00
|
|
|
{
|
2006-03-27 14:20:06 +02:00
|
|
|
$df = $GLOBALS['egw_info']['user']['preferences']['common']['dateformat'];
|
2016-04-26 20:27:29 +02:00
|
|
|
$GLOBALS['egw_info']['flags']['app_header'] .= ': ' . Api\DateTime::to($query['startdate']+12*60*60, $df);
|
2006-03-27 14:20:06 +02:00
|
|
|
if ($start != $end)
|
|
|
|
{
|
2016-05-25 20:59:44 +02:00
|
|
|
$GLOBALS['egw_info']['flags']['app_header'] .= ' - '.Api\DateTime::to($query['enddate'] ? $query['enddate']+12*60*60:'now', $df);
|
2006-03-27 14:20:06 +02:00
|
|
|
}
|
|
|
|
}
|
2006-03-21 23:18:29 +01:00
|
|
|
}
|
2016-04-25 23:21:40 +02:00
|
|
|
// Update start / end dates for custom
|
2017-12-14 22:33:53 +01:00
|
|
|
if($query_in['filter'] != 'custom' && Api\Json\Response::isJSONResponse())
|
2016-04-25 23:21:40 +02:00
|
|
|
{
|
2016-04-26 20:27:29 +02:00
|
|
|
Api\Json\Response::get()->call(
|
2016-04-25 23:21:40 +02:00
|
|
|
'app.timesheet.update_timespan',
|
2016-04-26 20:27:29 +02:00
|
|
|
Api\DateTime::to($query['startdate'] ? $query['startdate'] : 'now' , Api\DateTime::ET2),
|
|
|
|
$query['filter'] ? Api\DateTime::to($query['enddate'], Api\DateTime::ET2) : null
|
2016-04-25 23:21:40 +02:00
|
|
|
);
|
|
|
|
}
|
2005-12-19 05:23:14 +01:00
|
|
|
$total = parent::get_rows($query,$rows,$readonlys);
|
2008-04-18 23:09:30 +02:00
|
|
|
|
2008-03-09 08:33:42 +01:00
|
|
|
$ids = array();
|
2011-04-16 23:45:13 +02:00
|
|
|
foreach($rows as &$row)
|
2008-03-09 08:33:42 +01:00
|
|
|
{
|
2011-04-16 23:45:13 +02:00
|
|
|
if ($row['ts_id'] > 0) $ids[] = $row['ts_id'];
|
2008-03-09 08:33:42 +01:00
|
|
|
}
|
2007-03-08 12:22:57 +01:00
|
|
|
if ($id_only)
|
|
|
|
{
|
2008-03-09 08:33:42 +01:00
|
|
|
$rows = $ids;
|
2007-03-08 12:22:57 +01:00
|
|
|
return $this->total; // no need to set other fields or $readonlys
|
|
|
|
}
|
2012-10-14 10:20:00 +02:00
|
|
|
$links = array();
|
2016-04-26 20:27:29 +02:00
|
|
|
$links3 = Link::get_links_multiple(TIMESHEET_APP,$ids,true,'projectmanager'); // only check for pm links!
|
2009-01-27 16:51:04 +01:00
|
|
|
//as the full array is expected, we must supply the missing but needed (since expected further down) information
|
2009-05-06 09:04:29 +02:00
|
|
|
if (is_array($links3))
|
|
|
|
{
|
|
|
|
foreach ($links3 as $likey => $liarray)
|
|
|
|
{
|
|
|
|
if (is_array($liarray))
|
|
|
|
{
|
|
|
|
foreach ($liarray as $li2key => $lival)
|
|
|
|
{
|
2009-01-27 16:51:04 +01:00
|
|
|
$links[$likey][$li2key]['id'] = $lival;
|
|
|
|
$links[$likey][$li2key]['app'] = 'projectmanager';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2005-12-19 05:23:14 +01:00
|
|
|
unset($query['col_filter'][0]);
|
2008-04-18 23:09:30 +02:00
|
|
|
|
2005-12-19 05:23:14 +01:00
|
|
|
$readonlys = array();
|
2006-09-20 15:31:41 +02:00
|
|
|
$have_cats = false;
|
2008-03-09 08:33:42 +01:00
|
|
|
foreach($rows as &$row)
|
2005-12-19 05:23:14 +01:00
|
|
|
{
|
2006-09-20 15:31:41 +02:00
|
|
|
if ($row['cat_id']) $have_cats = true;
|
|
|
|
|
2006-03-27 00:11:58 +02:00
|
|
|
$row['class'] = 'row';
|
|
|
|
if ($row['ts_id'] <= 0) // sums
|
|
|
|
{
|
|
|
|
if ($query['sort'] == 'ASC') $row['ts_start'] -= 7200; // fix for DSL change
|
2014-06-12 10:30:21 +02:00
|
|
|
|
2014-04-02 21:49:14 +02:00
|
|
|
// Remove fake modified date, it breaks nextmatch checks
|
|
|
|
unset($row['ts_modified']);
|
2014-08-25 20:22:50 +02:00
|
|
|
|
2014-08-12 01:13:02 +02:00
|
|
|
// Set flag to avoid actions on these rows
|
|
|
|
$row['no_actions'] = true;
|
2014-08-25 20:22:50 +02:00
|
|
|
|
2006-03-27 00:11:58 +02:00
|
|
|
switch($row['ts_id'])
|
|
|
|
{
|
|
|
|
case 0: // day-sum
|
2016-04-26 20:27:29 +02:00
|
|
|
$row['ts_title'] = lang('Sum %1:',lang(date('l',$row['ts_start'])).' '.Api\DateTime::to($row['ts_start'], $GLOBALS['egw_info']['user']['preferences']['common']['dateformat']));
|
2014-01-30 19:47:42 +01:00
|
|
|
$row['ts_id'] = 'sum-day-'.$row['ts_start'];
|
2009-05-06 09:04:29 +02:00
|
|
|
break;
|
2006-03-27 00:11:58 +02:00
|
|
|
case -1: // week-sum
|
2009-05-06 09:04:29 +02:00
|
|
|
$row['ts_title'] = lang('Sum %1:',lang('week').' '.substr($row['ts_week'],4).'/'.substr($row['ts_week'],0,4));
|
2014-01-30 19:47:42 +01:00
|
|
|
$row['ts_id'] = 'sum-week-'.$row['ts_week'];
|
2009-05-06 09:04:29 +02:00
|
|
|
break;
|
2006-03-27 00:11:58 +02:00
|
|
|
case -2: // month-sum
|
2009-05-06 09:04:29 +02:00
|
|
|
$row['ts_title'] = lang('Sum %1:',lang(date('F',$row['ts_start'])).' '.substr($row['ts_month'],0,4));
|
2014-01-30 19:47:42 +01:00
|
|
|
$row['ts_id'] = 'sum-month-'.$row['ts_month'];
|
2009-05-06 09:04:29 +02:00
|
|
|
break;
|
2006-04-05 18:23:44 +02:00
|
|
|
case -3: // year-sum
|
2009-05-06 09:04:29 +02:00
|
|
|
$row['ts_title'] = lang('Sum %1:',$row['ts_year']);
|
2014-01-30 19:47:42 +01:00
|
|
|
$row['ts_id'] = 'sum-year-'.$row['ts_year'];
|
2009-05-06 09:04:29 +02:00
|
|
|
break;
|
2008-04-18 23:09:30 +02:00
|
|
|
}
|
2007-07-10 09:34:30 +02:00
|
|
|
$row['ts_start'] = $row['ts_unitprice'] = '';
|
|
|
|
if (!$this->quantity_sum) $row['ts_quantity'] = '';
|
2013-10-04 13:19:42 +02:00
|
|
|
$row['class'] = 'th rowNoEdit rowNoDelete rowNoUndelete';
|
2013-09-03 16:42:46 +02:00
|
|
|
$row['titleClass'] = 'timesheet_titleSum';
|
2006-03-27 00:11:58 +02:00
|
|
|
continue;
|
|
|
|
}
|
2014-09-09 23:38:37 +02:00
|
|
|
if($row['ts_quantity'])
|
|
|
|
{
|
|
|
|
$row['ts_quantity'] = round($row['ts_quantity'], 2);
|
|
|
|
}
|
2016-04-26 20:27:29 +02:00
|
|
|
if (!$this->check_acl(Acl::EDIT,$row))
|
2005-12-19 05:23:14 +01:00
|
|
|
{
|
2011-04-28 11:14:31 +02:00
|
|
|
$row['class'] .= ' rowNoEdit ';
|
2011-11-09 15:52:33 +01:00
|
|
|
}
|
|
|
|
if (!$this->check_statusForEditRights($row))
|
|
|
|
{
|
|
|
|
$row['class'] .= ' rowNoEdit ';
|
2005-12-19 05:23:14 +01:00
|
|
|
}
|
2016-04-26 20:27:29 +02:00
|
|
|
if (!$this->check_acl(Acl::DELETE,$row))
|
2005-12-19 05:23:14 +01:00
|
|
|
{
|
2011-04-28 11:14:31 +02:00
|
|
|
$row['class'] .= ' rowNoDelete ';
|
2005-12-19 05:23:14 +01:00
|
|
|
}
|
2012-10-24 17:50:48 +02:00
|
|
|
if($row['ts_status'] != self::DELETED_STATUS)
|
|
|
|
{
|
|
|
|
$row['class'] .= ' rowNoUndelete ';
|
|
|
|
}
|
2014-06-04 21:29:35 +02:00
|
|
|
if ($query['col_filter']['ts_project'])
|
2005-12-19 05:23:14 +01:00
|
|
|
{
|
|
|
|
unset($row['ts_project']); // dont need or want to show it
|
|
|
|
}
|
2008-03-09 08:33:42 +01:00
|
|
|
elseif ($links[$row['ts_id']])
|
2005-12-19 05:23:14 +01:00
|
|
|
{
|
2008-03-09 08:33:42 +01:00
|
|
|
foreach($links[$row['ts_id']] as $link)
|
2005-12-19 05:23:14 +01:00
|
|
|
{
|
2008-03-09 08:33:42 +01:00
|
|
|
if ($link['app'] == 'projectmanager')
|
|
|
|
{
|
|
|
|
$row['ts_link'] = $link;
|
|
|
|
$row['ts_link']['title'] = $row['ts_project'];
|
|
|
|
break;
|
|
|
|
}
|
2005-12-19 05:23:14 +01:00
|
|
|
}
|
|
|
|
}
|
2014-06-04 21:29:35 +02:00
|
|
|
|
|
|
|
if(!$row['titleClass']) $row['titleClass'] = 'timesheet_titleDetails';
|
|
|
|
|
2005-12-19 05:23:14 +01:00
|
|
|
}
|
2016-03-08 18:29:10 +01:00
|
|
|
$rows['no_cat_id'] = (!$have_cats || $query['cat_id']);
|
2006-03-27 14:20:06 +02:00
|
|
|
if ($query['col_filter']['ts_owner']) $rows['ownerClass'] = 'noPrint';
|
2005-12-19 05:23:14 +01:00
|
|
|
$rows['no_owner_col'] = $query['no_owner_col'];
|
2017-09-20 18:30:14 +02:00
|
|
|
if(is_string($query['selectcols']))
|
|
|
|
{
|
|
|
|
$query['selectcols'] = explode(',', $query['selectcols']);
|
|
|
|
}
|
|
|
|
if (!$rows['no_owner_col'] && $query['selectcols'] && !in_array('ts_owner', $query['selectcols']))
|
|
|
|
{
|
|
|
|
$rows['no_owner_col'] = 1;
|
|
|
|
}
|
2016-05-04 00:18:49 +02:00
|
|
|
|
|
|
|
$rows += $this->summary;
|
|
|
|
|
2006-09-12 17:21:23 +02:00
|
|
|
$rows['pm_integration'] = $this->pm_integration;
|
2009-02-16 09:36:22 +01:00
|
|
|
$rows['ts_viewtype'] = $rows['no_ts_quantity'] = $rows['no_ts_unitprice'] = $rows['no_ts_total'] = $this->ts_viewtype == 'short';
|
2009-05-06 09:04:29 +02:00
|
|
|
if (!$rows['ts_viewtype'])
|
|
|
|
{
|
2009-02-16 09:36:22 +01:00
|
|
|
#_debug_array($query['selectcols']);
|
2016-04-13 16:59:17 +02:00
|
|
|
if(!is_array($query['selectcols'])){
|
|
|
|
$query['selectcols'] = explode(',',$query['selectcols']);
|
|
|
|
}
|
2009-02-16 09:36:22 +01:00
|
|
|
#ts_quantity,ts_unitprice,ts_total
|
2016-04-14 20:34:06 +02:00
|
|
|
if ($query['selectcols'] && in_array('ts_quantity_quantity',$query['selectcols'])===false) $rows['no_ts_quantity'] = 1;
|
2016-04-13 16:59:17 +02:00
|
|
|
if ($query['selectcols'] && in_array('ts_unitprice', $query['selectcols'])===false) $rows['no_ts_unitprice'] = 1;
|
2016-04-14 20:34:06 +02:00
|
|
|
if ($query['selectcols'] && in_array('ts_total_price',$query['selectcols'])===false) $rows['no_ts_total'] = 1;
|
2009-02-16 09:36:22 +01:00
|
|
|
}
|
2016-04-13 16:59:17 +02:00
|
|
|
$rows['no_ts_status'] = in_array('ts_status', $query['selectcols']) === false && !$this->config_data['history'] ||
|
2012-10-23 18:59:14 +02:00
|
|
|
$query['no_status'];
|
2010-03-23 13:54:00 +01:00
|
|
|
|
2016-02-17 20:56:54 +01:00
|
|
|
if ($query['search'])
|
|
|
|
{
|
|
|
|
$GLOBALS['egw_info']['flags']['app_header'] = lang("Search for '%1'", $query['search']);
|
|
|
|
}
|
|
|
|
|
2008-04-18 23:09:30 +02:00
|
|
|
return $total;
|
2005-12-19 05:23:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* List timesheet entries
|
|
|
|
*
|
2014-06-12 14:39:52 +02:00
|
|
|
* @param array $content
|
|
|
|
* @param string $msg
|
2005-12-19 05:23:14 +01:00
|
|
|
*/
|
|
|
|
function index($content = null,$msg='')
|
|
|
|
{
|
2016-04-26 20:27:29 +02:00
|
|
|
$etpl = new Etemplate('timesheet.index');
|
2008-04-18 23:09:30 +02:00
|
|
|
|
2005-12-19 05:23:14 +01:00
|
|
|
if ($_GET['msg']) $msg = $_GET['msg'];
|
2006-01-11 06:17:15 +01:00
|
|
|
if ($content['nm']['rows']['delete'])
|
|
|
|
{
|
|
|
|
list($ts_id) = each($content['nm']['rows']['delete']);
|
|
|
|
if ($this->delete($ts_id))
|
|
|
|
{
|
|
|
|
$msg = lang('Entry deleted');
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$msg = lang('Error deleting the entry!!!');
|
|
|
|
}
|
|
|
|
}
|
2011-02-04 21:03:42 +01:00
|
|
|
if (is_array($content) && isset($content['nm']['rows']['document'])) // handle insert in default document button like an action
|
|
|
|
{
|
|
|
|
list($id) = @each($content['nm']['rows']['document']);
|
2011-04-17 11:52:54 +02:00
|
|
|
$content['nm']['action'] = 'document';
|
|
|
|
$content['nm']['selected'] = array($id);
|
2011-02-04 21:03:42 +01:00
|
|
|
}
|
2011-04-16 23:45:13 +02:00
|
|
|
if ($content['nm']['action'])
|
2009-03-23 10:53:03 +01:00
|
|
|
{
|
2014-01-31 12:58:58 +01:00
|
|
|
// remove sum-* rows from checked rows
|
|
|
|
$content['nm']['selected'] = array_filter($content['nm']['selected'], function($id)
|
|
|
|
{
|
|
|
|
return $id > 0;
|
|
|
|
});
|
2011-04-16 23:45:13 +02:00
|
|
|
if (!count($content['nm']['selected']) && !$content['nm']['select_all'])
|
2009-03-23 10:53:03 +01:00
|
|
|
{
|
2011-04-17 20:53:45 +02:00
|
|
|
$msg = lang('You need to select some entries first!');
|
2009-03-23 10:53:03 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-01-30 16:39:56 +01:00
|
|
|
$success = $failed = $action_msg = null;
|
2011-04-16 23:45:13 +02:00
|
|
|
if ($this->action($content['nm']['action'],$content['nm']['selected'],$content['nm']['select_all'],
|
|
|
|
$success,$failed,$action_msg,'index',$msg))
|
2009-03-23 10:53:03 +01:00
|
|
|
{
|
|
|
|
$msg .= lang('%1 timesheets(s) %2',$success,$action_msg);
|
|
|
|
}
|
2011-04-19 11:44:25 +02:00
|
|
|
elseif(empty($msg))
|
2009-03-23 10:53:03 +01:00
|
|
|
{
|
|
|
|
$msg .= lang('%1 timesheets(s) %2, %3 failed because of insufficent rights !!!',$success,$action_msg,$failed);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-12-19 05:23:14 +01:00
|
|
|
$content = array(
|
2016-05-09 11:30:03 +02:00
|
|
|
'nm' => Api\Cache::getSession(TIMESHEET_APP, 'index'),
|
2009-05-06 09:04:29 +02:00
|
|
|
'msg' => $msg,
|
2008-04-18 23:09:30 +02:00
|
|
|
);
|
2005-12-19 05:23:14 +01:00
|
|
|
if (!is_array($content['nm']))
|
|
|
|
{
|
|
|
|
$date_filters = array('All');
|
2014-01-30 16:39:56 +01:00
|
|
|
foreach(array_keys($this->date_filters) as $name)
|
2005-12-19 05:23:14 +01:00
|
|
|
{
|
|
|
|
$date_filters[$name] = $name;
|
|
|
|
}
|
2006-03-21 23:18:29 +01:00
|
|
|
$date_filters['custom'] = 'custom';
|
|
|
|
|
2005-12-19 05:23:14 +01:00
|
|
|
$content['nm'] = array(
|
2009-05-06 09:04:29 +02:00
|
|
|
'get_rows' => TIMESHEET_APP.'.timesheet_ui.get_rows',
|
|
|
|
'options-filter' => $date_filters,
|
|
|
|
'options-filter2' => array('No details','Details'),
|
|
|
|
'order' => 'ts_start',// IO name of the column to sort after (optional for the sortheaders)
|
|
|
|
'sort' => 'DESC',// IO direction of the sort: 'ASC' or 'DESC'
|
2013-08-27 12:46:42 +02:00
|
|
|
'filter_onchange' => "app.timesheet.filter_change();",
|
2014-06-04 21:29:35 +02:00
|
|
|
'filter2_onchange' => "app.timesheet.filter2_change();",
|
2009-05-06 09:04:29 +02:00
|
|
|
'filter2' => (int)$GLOBALS['egw_info']['user']['preferences'][TIMESHEET_APP]['show_details'],
|
2011-04-16 23:45:13 +02:00
|
|
|
'row_id' => 'ts_id',
|
2014-03-18 23:55:48 +01:00
|
|
|
'row_modified' => 'ts_modified',
|
2011-04-17 20:53:45 +02:00
|
|
|
//'actions' => $this->get_actions(),
|
2011-04-16 23:45:13 +02:00
|
|
|
'default_cols' => '!legacy_actions', // switch legacy actions column and row off by default
|
2014-07-09 00:06:04 +02:00
|
|
|
'pm_integration' => $this->pm_integration,
|
2016-04-27 01:11:29 +02:00
|
|
|
'placeholder_actions' => array('add')
|
2005-12-19 05:23:14 +01:00
|
|
|
);
|
|
|
|
}
|
2011-04-17 20:53:45 +02:00
|
|
|
|
2010-03-23 13:54:00 +01:00
|
|
|
if($_GET['search'])
|
|
|
|
{
|
2009-12-09 00:19:06 +01:00
|
|
|
$content['nm']['search'] = $_GET['search'];
|
|
|
|
}
|
2016-11-22 19:41:51 +01:00
|
|
|
if($_GET['link_app'] && Link::get_registry($_GET['link_app'], 'query') && $_GET['link_id'])
|
|
|
|
{
|
|
|
|
$content['nm']['col_filter']['linked'] = array(
|
|
|
|
'app' => $_GET['link_app'],
|
|
|
|
'id' => $_GET['link_id']
|
|
|
|
);
|
|
|
|
}
|
2016-04-26 20:27:29 +02:00
|
|
|
$read_grants = $this->grant_list(Acl::READ);
|
2005-12-19 05:23:14 +01:00
|
|
|
$content['nm']['no_owner_col'] = count($read_grants) == 1;
|
2009-04-20 16:06:13 +02:00
|
|
|
if ($GLOBALS['egw_info']['user']['preferences']['timesheet']['nextmatch-timesheet.index.rows']) $content['nm']['selectcols'] = $GLOBALS['egw_info']['user']['preferences']['timesheet']['nextmatch-timesheet.index.rows'];
|
2006-09-14 20:31:46 +02:00
|
|
|
$sel_options = array(
|
2009-05-06 09:04:29 +02:00
|
|
|
'ts_owner' => $read_grants,
|
|
|
|
'pm_id' => array(lang('No project')),
|
2016-03-24 19:52:59 +01:00
|
|
|
'cat_id' => array(array('value' => '', 'label' => lang('all categories')), array('value' => 0, 'label'=>lang('None'))),
|
2009-08-17 20:46:47 +02:00
|
|
|
'ts_status' => $this->status_labels+array(lang('No status')),
|
2006-09-14 20:31:46 +02:00
|
|
|
);
|
2012-10-22 20:31:11 +02:00
|
|
|
if($this->config_data['history'])
|
|
|
|
{
|
|
|
|
$sel_options['ts_status'][self::DELETED_STATUS] = 'Deleted';
|
|
|
|
}
|
2010-03-23 13:54:00 +01:00
|
|
|
$content['nm']['no_status'] = count($sel_options['ts_status']) <= 1; // 1 because of 'No status'
|
2013-08-29 10:25:46 +02:00
|
|
|
$content['nm']['favorites'] = true; //Enable favorite
|
2010-03-23 13:54:00 +01:00
|
|
|
|
2006-09-14 20:31:46 +02:00
|
|
|
if ($this->pm_integration != 'full')
|
|
|
|
{
|
|
|
|
$projects =& $this->query_list('ts_project');
|
|
|
|
if (!is_array($projects)) $projects = array();
|
|
|
|
$sel_options['ts_project'] = $projects + array(lang('No project'));
|
|
|
|
}
|
2011-04-16 23:45:13 +02:00
|
|
|
|
2007-05-09 10:21:26 +02:00
|
|
|
// dont show [Export] button if app is not availible to the user or we are on php4
|
|
|
|
$readonlys['export'] = !$GLOBALS['egw_info']['user']['apps']['importexport'] || (int) phpversion() < 5;
|
2014-01-30 16:39:56 +01:00
|
|
|
return $etpl->exec(TIMESHEET_APP.'.timesheet_ui.index',$content,$sel_options,$readonlys);
|
2005-12-19 05:23:14 +01:00
|
|
|
}
|
2007-03-08 12:22:57 +01:00
|
|
|
|
2011-04-16 23:45:13 +02:00
|
|
|
/**
|
|
|
|
* Get actions / context menu for index
|
|
|
|
*
|
2011-04-17 20:53:45 +02:00
|
|
|
* Changes here, require to log out, as $content['nm'] get stored in session!
|
|
|
|
*
|
2011-04-16 23:45:13 +02:00
|
|
|
* @return array see nextmatch_widget::egw_actions()
|
|
|
|
*/
|
2014-11-28 19:03:13 +01:00
|
|
|
public function get_actions(Array $query)
|
2011-04-16 23:45:13 +02:00
|
|
|
{
|
|
|
|
$actions = array(
|
2011-04-19 11:44:25 +02:00
|
|
|
'open' => array( // does edit if allowed, otherwise view
|
|
|
|
'caption' => 'Open',
|
|
|
|
'default' => true,
|
|
|
|
'allowOnMultiple' => false,
|
|
|
|
'url' => 'menuaction=timesheet.timesheet_ui.edit&ts_id=$id',
|
2016-04-26 20:27:29 +02:00
|
|
|
'popup' => Link::get_registry('timesheet', 'add_popup'),
|
2011-04-19 11:44:25 +02:00
|
|
|
'group' => $group=1,
|
2013-10-04 13:19:42 +02:00
|
|
|
'disableClass' => 'th',
|
2016-05-25 16:44:23 +02:00
|
|
|
'onExecute' => Api\Header\UserAgent::mobile()?'javaScript:app.timesheet.viewEntry':'',
|
2016-06-21 16:37:18 +02:00
|
|
|
'mobileViewTemplate' => 'view?'.filemtime(Api\Etemplate\Widget\Template::rel2path('/timesheet/templates/mobile/view.xet'))
|
2011-04-19 11:44:25 +02:00
|
|
|
),
|
|
|
|
/*
|
2011-04-16 23:45:13 +02:00
|
|
|
'view' => array(
|
|
|
|
'caption' => 'View',
|
|
|
|
'default' => true,
|
|
|
|
'allowOnMultiple' => false,
|
2011-04-17 11:52:54 +02:00
|
|
|
'url' => 'menuaction=timesheet.timesheet_ui.view&ts_id=$id',
|
2016-04-26 20:27:29 +02:00
|
|
|
'popup' => Link::get_registry('timesheet', 'view_popup'),
|
2011-04-16 23:45:13 +02:00
|
|
|
'group' => $group=1,
|
|
|
|
),
|
|
|
|
'edit' => array(
|
|
|
|
'caption' => 'Edit',
|
|
|
|
'allowOnMultiple' => false,
|
2011-04-17 11:52:54 +02:00
|
|
|
'url' => 'menuaction=timesheet.timesheet_ui.edit&ts_id=$id',
|
2016-04-26 20:27:29 +02:00
|
|
|
'popup' => Link::get_registry('timesheet', 'add_popup'),
|
2011-04-16 23:45:13 +02:00
|
|
|
'group' => $group,
|
2011-04-17 22:45:21 +02:00
|
|
|
'disableClass' => 'rowNoEdit',
|
2011-04-16 23:45:13 +02:00
|
|
|
),
|
2011-04-19 11:44:25 +02:00
|
|
|
*/
|
2011-04-16 23:45:13 +02:00
|
|
|
'add' => array(
|
|
|
|
'caption' => 'Add',
|
|
|
|
'group' => $group,
|
2016-11-24 18:20:45 +01:00
|
|
|
'children' => array(
|
|
|
|
'new' => array(
|
|
|
|
'caption' => 'New',
|
|
|
|
'onExecute' => 'javaScript:app.timesheet.add_action_handler',
|
|
|
|
'icon' => 'new',
|
|
|
|
),
|
|
|
|
'copy' => array(
|
|
|
|
'caption' => 'Copy',
|
|
|
|
'url' => 'menuaction=timesheet.timesheet_ui.edit&action=copy&ts_id=$id',
|
|
|
|
'popup' => Link::get_registry('infolog', 'add_popup'),
|
|
|
|
'allowOnMultiple' => false,
|
|
|
|
'icon' => 'copy',
|
|
|
|
),
|
|
|
|
)
|
2011-04-16 23:45:13 +02:00
|
|
|
),
|
2016-04-26 20:27:29 +02:00
|
|
|
'cat' => Etemplate\Widget\Nextmatch::category_action(
|
2011-04-16 23:45:13 +02:00
|
|
|
'timesheet',++$group,'Change category','cat_'
|
|
|
|
),
|
|
|
|
'status' => array(
|
|
|
|
'icon' => 'apply',
|
|
|
|
'caption' => 'Modify status',
|
2011-04-17 20:53:45 +02:00
|
|
|
'group' => $group,
|
2011-04-16 23:45:13 +02:00
|
|
|
'children' => $this->status_labels,
|
|
|
|
'prefix' => 'to_status_',
|
|
|
|
'enabled' => (boolean)$this->status_labels,
|
|
|
|
),
|
2013-04-02 00:47:26 +02:00
|
|
|
);
|
|
|
|
|
2016-04-26 20:27:29 +02:00
|
|
|
// Other Api\Applications
|
2013-04-02 00:47:26 +02:00
|
|
|
$group++;
|
2013-04-03 18:38:47 +02:00
|
|
|
if ($GLOBALS['egw_info']['user']['apps']['filemanager'])
|
2013-04-02 00:47:26 +02:00
|
|
|
{
|
|
|
|
$actions['filemanager'] = array(
|
|
|
|
'icon' => 'filemanager/navbar',
|
|
|
|
'caption' => 'Filemanager',
|
2014-01-16 18:23:39 +01:00
|
|
|
'url' => 'menuaction=filemanager.filemanager_ui.index&path=/apps/timesheet/$id&ajax=true',
|
2013-04-02 00:47:26 +02:00
|
|
|
'allowOnMultiple' => false,
|
|
|
|
'group' => $group,
|
2013-10-04 13:19:42 +02:00
|
|
|
'disableClass' => 'th',
|
2013-04-02 00:47:26 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
$group++;
|
|
|
|
$actions += array(
|
2011-04-16 23:45:13 +02:00
|
|
|
'documents' => timesheet_merge::document_action(
|
2011-04-25 13:30:37 +02:00
|
|
|
$GLOBALS['egw_info']['user']['preferences']['timesheet']['document_dir'],
|
|
|
|
$group, 'Insert in document', 'document_',
|
|
|
|
$GLOBALS['egw_info']['user']['preferences']['timesheet']['default_document']
|
2011-04-16 23:45:13 +02:00
|
|
|
),
|
|
|
|
'delete' => array(
|
|
|
|
'caption' => 'Delete',
|
|
|
|
'confirm' => 'Delete this entry',
|
2011-04-17 20:53:45 +02:00
|
|
|
'confirm_multiple' => 'Delete these entries',
|
2011-04-16 23:45:13 +02:00
|
|
|
'group' => ++$group,
|
2011-04-17 22:45:21 +02:00
|
|
|
'disableClass' => 'rowNoDelete',
|
2011-04-16 23:45:13 +02:00
|
|
|
),
|
2012-10-25 19:11:52 +02:00
|
|
|
);
|
|
|
|
if ($query['col_filter']['ts_status'] == self::DELETED_STATUS)
|
|
|
|
{
|
|
|
|
$actions['undelete'] = array(
|
2012-10-24 17:50:48 +02:00
|
|
|
'caption' => 'Un-Delete',
|
|
|
|
'confirm' => 'Recover this entry',
|
|
|
|
'confirm_multiple' => 'Recover these entries',
|
2012-10-25 19:11:52 +02:00
|
|
|
'icon' => 'revert',
|
2012-10-24 17:50:48 +02:00
|
|
|
'group' => $group,
|
|
|
|
'disableClass' => 'rowNoUndelete',
|
2012-10-25 19:11:52 +02:00
|
|
|
);
|
|
|
|
}
|
2011-04-19 11:44:25 +02:00
|
|
|
// enable additonal edit check for following actions, if they are generally available
|
|
|
|
foreach(array('cat','status') as $action)
|
|
|
|
{
|
|
|
|
if ($actions[$action]['enabled'])
|
|
|
|
{
|
|
|
|
$actions[$action]['disableClass'] = 'rowNoEdit';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//_debug_array($actions);
|
2011-04-16 23:45:13 +02:00
|
|
|
return $actions;
|
|
|
|
}
|
|
|
|
|
2009-03-23 10:53:03 +01:00
|
|
|
/**
|
|
|
|
* apply an action to multiple timesheets
|
|
|
|
*
|
|
|
|
* @param string/int $action 'status_to',set status to timeshhets
|
|
|
|
* @param array $checked timesheet id's to use if !$use_all
|
2013-08-21 17:25:42 +02:00
|
|
|
* @param boolean $use_all if true use all$key timesheets of the current selection (in the session)
|
2009-03-23 10:53:03 +01:00
|
|
|
* @param int &$success number of succeded actions
|
|
|
|
* @param int &$failed number of failed actions (not enought permissions)
|
|
|
|
* @param string &$action_msg translated verb for the actions, to be used in a message like %1 timesheets 'deleted'
|
|
|
|
* @param string/array $session_name 'index' or 'email', or array with session-data depending if we are in the main list or the popup
|
|
|
|
* @return boolean true if all actions succeded, false otherwise
|
|
|
|
*/
|
|
|
|
function action($action,$checked,$use_all,&$success,&$failed,&$action_msg,$session_name,&$msg)
|
|
|
|
{
|
|
|
|
$success = $failed = 0;
|
|
|
|
if ($use_all)
|
|
|
|
{
|
|
|
|
// get the whole selection
|
2016-04-26 20:27:29 +02:00
|
|
|
$query = is_array($session_name) ? $session_name : Api\Cache::getSession('timesheet', $session_name);
|
2009-03-23 10:53:03 +01:00
|
|
|
|
|
|
|
if ($use_all)
|
|
|
|
{
|
|
|
|
@set_time_limit(0); // switch off the execution time limit, as it's for big selections to small
|
|
|
|
$query['num_rows'] = -1; // all
|
2014-01-30 16:39:56 +01:00
|
|
|
$readonlys = null;
|
2009-03-23 10:53:03 +01:00
|
|
|
$this->get_rows($query,$checked,$readonlys,true); // true = only return the id's
|
|
|
|
}
|
|
|
|
}
|
2011-04-19 11:44:25 +02:00
|
|
|
//error_log(__METHOD__."('$action', ".array2string($checked).', '.array2string($use_all).",,, '$session_name')");
|
2009-03-23 10:53:03 +01:00
|
|
|
|
|
|
|
if (substr($action,0,9) == 'to_status')
|
|
|
|
{
|
|
|
|
$to_status = (int)substr($action,10);
|
|
|
|
$action = 'to_status';
|
|
|
|
}
|
2010-12-10 19:03:46 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
// Dialogs to get options
|
|
|
|
list($action, $settings) = explode('_', $action, 2);
|
|
|
|
}
|
2009-03-23 10:53:03 +01:00
|
|
|
|
|
|
|
switch($action)
|
|
|
|
{
|
|
|
|
case 'delete':
|
|
|
|
$action_msg = lang('deleted');
|
|
|
|
foreach((array)$checked as $n => $id)
|
|
|
|
{
|
|
|
|
if ($this->delete($id))
|
|
|
|
{
|
|
|
|
$success++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$failed++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2012-10-24 17:50:48 +02:00
|
|
|
case 'undelete':
|
|
|
|
$action_msg =lang('recovered');
|
|
|
|
foreach((array)$checked as $n => $id)
|
|
|
|
{
|
|
|
|
if ($this->set_status($id,''))
|
|
|
|
{
|
|
|
|
$success++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$failed++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2009-03-23 10:53:03 +01:00
|
|
|
case 'to_status':
|
|
|
|
$action_msg =lang('changed status');
|
|
|
|
foreach((array)$checked as $n => $id)
|
|
|
|
{
|
|
|
|
if ($this->set_status($id,$to_status))
|
|
|
|
{
|
|
|
|
$success++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$failed++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2010-12-10 19:03:46 +01:00
|
|
|
case 'cat':
|
2016-04-26 20:27:29 +02:00
|
|
|
$cat_name = Api\Categories::id2name($settings);
|
2010-12-10 19:03:46 +01:00
|
|
|
$action_msg = lang('changed category to %1', $cat_name);
|
|
|
|
foreach((array)$checked as $n => $id) {
|
2016-06-29 10:38:41 +02:00
|
|
|
if (($entry = $this->read($id)) &&
|
|
|
|
($entry['cat_id'] = $settings) &&
|
|
|
|
$this->save($entry) == 0)
|
2010-12-10 19:03:46 +01:00
|
|
|
{
|
|
|
|
$success++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$failed++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2011-02-04 21:03:42 +01:00
|
|
|
case 'document':
|
2011-06-14 12:48:15 +02:00
|
|
|
if (!$settings) $settings = $GLOBALS['egw_info']['user']['preferences']['timesheet']['default_document'];
|
|
|
|
$document_merge = new timesheet_merge();
|
|
|
|
$msg = $document_merge->download($settings, $checked, '', $GLOBALS['egw_info']['user']['preferences']['timesheet']['document_dir']);
|
2011-02-04 21:03:42 +01:00
|
|
|
$failed = count($checked);
|
2011-04-16 23:45:13 +02:00
|
|
|
return false;
|
2009-03-23 10:53:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return !$failed;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* function for setting individual Status
|
|
|
|
*
|
|
|
|
* @param conetnt
|
|
|
|
* @param view
|
|
|
|
*/
|
|
|
|
function editstatus($content = null,$msg='')
|
|
|
|
{
|
|
|
|
// this function requires admin rights
|
|
|
|
$GLOBALS['egw_info']['flags']['admin_only'] = true;
|
|
|
|
$GLOBALS['egw']->check_app_rights();
|
|
|
|
|
|
|
|
if (is_array($content))
|
|
|
|
{
|
|
|
|
list($button) = @each($content['button']);
|
2010-03-23 13:54:00 +01:00
|
|
|
unset ($content['button']);
|
2009-03-23 10:53:03 +01:00
|
|
|
|
|
|
|
switch($button)
|
|
|
|
{
|
|
|
|
case 'delete':
|
|
|
|
break;
|
|
|
|
case 'apply':
|
|
|
|
case 'save':
|
2011-06-13 19:43:51 +02:00
|
|
|
foreach($content['statis'] as &$cat)
|
2009-03-23 10:53:03 +01:00
|
|
|
{
|
|
|
|
$id = $cat['id'];
|
2009-09-08 11:23:41 +02:00
|
|
|
if (($cat ['name'] !== $this->status_labels_config[$id]) && ($cat ['name'] !== '') || ($cat ['parent'] !== $this->status_labels_config[$id]['parent']) && ($cat ['parent'] !== ''))
|
2009-03-23 10:53:03 +01:00
|
|
|
{
|
2009-09-08 11:23:41 +02:00
|
|
|
$this->status_labels_config[$id] = array(
|
2011-06-13 19:43:51 +02:00
|
|
|
'name' => trim(str_replace(' ', '', $cat['name'])),
|
2009-09-08 11:23:41 +02:00
|
|
|
'parent' => $cat['parent'],
|
|
|
|
'admin' => $cat['admin']);
|
2009-03-23 10:53:03 +01:00
|
|
|
$need_update = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ($need_update)
|
|
|
|
{
|
2016-04-26 20:27:29 +02:00
|
|
|
Api\Config::save_value('status_labels',$this->status_labels_config,TIMESHEET_APP);
|
|
|
|
$this->config_data = Api\Config::read(TIMESHEET_APP);
|
2011-06-13 19:43:51 +02:00
|
|
|
$this->load_statuses();
|
2009-03-23 10:53:03 +01:00
|
|
|
$msg .= lang('Status updated.');
|
|
|
|
}
|
2010-03-23 13:54:00 +01:00
|
|
|
if ($button == 'apply') break;
|
|
|
|
// fall-through
|
|
|
|
case 'cancel':
|
2014-07-08 17:10:24 +02:00
|
|
|
$GLOBALS['egw']->redirect_link('/admin/index.php', null, 'admin');
|
2009-03-23 10:53:03 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (isset($content['statis']['delete']))
|
|
|
|
{
|
|
|
|
list($id) = each($content['statis']['delete']);
|
2009-09-08 11:23:41 +02:00
|
|
|
if (isset($this->status_labels_config[$id]))
|
2009-03-23 10:53:03 +01:00
|
|
|
{
|
2009-09-08 11:23:41 +02:00
|
|
|
unset($this->status_labels_config[$id]);
|
2016-04-26 20:27:29 +02:00
|
|
|
Api\Config::save_value('status_labels',$this->status_labels_config,TIMESHEET_APP);
|
2009-03-23 10:53:03 +01:00
|
|
|
unset($this->status_labels[$id]);
|
|
|
|
$msg .= lang('Status deleted.');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$i = 1;
|
2011-06-13 19:43:51 +02:00
|
|
|
$max_id = 0;
|
2009-03-23 10:53:03 +01:00
|
|
|
unset($content['statis']);
|
2009-09-08 11:23:41 +02:00
|
|
|
foreach($this->status_labels_config as $id => $label)
|
2009-03-23 10:53:03 +01:00
|
|
|
{
|
2009-09-08 11:23:41 +02:00
|
|
|
$content['statis'][$i]['name']= $label['name'];
|
2009-03-23 10:53:03 +01:00
|
|
|
$content['statis'][$i]['id']= $id;
|
2009-09-08 11:23:41 +02:00
|
|
|
$content['statis'][$i]['parent']= $label['parent'];
|
|
|
|
$content['statis'][$i]['admin']= $label['admin'];
|
2009-03-23 10:53:03 +01:00
|
|
|
$i++;
|
2011-06-13 19:43:51 +02:00
|
|
|
$max_id = max($id, $max_id);
|
2009-03-23 10:53:03 +01:00
|
|
|
}
|
|
|
|
$content['statis'][$i]['name'] = '';
|
2009-09-08 11:23:41 +02:00
|
|
|
$content['statis'][$i]['admin'] = '';
|
2011-06-13 19:43:51 +02:00
|
|
|
$content['statis'][$i]['id'] = ++$max_id;
|
2009-03-23 10:53:03 +01:00
|
|
|
|
|
|
|
$content['msg'] = $msg;
|
|
|
|
$preserv = $content;
|
2009-09-08 11:23:41 +02:00
|
|
|
$sel_options['parent'] = $this->status_labels;
|
2016-04-26 20:27:29 +02:00
|
|
|
$etpl = new Etemplate('timesheet.editstatus');
|
2014-01-30 16:39:56 +01:00
|
|
|
$etpl->exec('timesheet.timesheet_ui.editstatus',$content,$sel_options,array(),$preserv);
|
2009-03-23 10:53:03 +01:00
|
|
|
}
|
2016-08-18 22:04:18 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Try to find a PM ID from project title
|
|
|
|
*
|
|
|
|
* @param string $project
|
|
|
|
*/
|
|
|
|
protected function find_pm_id($project)
|
|
|
|
{
|
|
|
|
list($pm_number, $pm_title) = explode(': ', $project, 2);
|
|
|
|
if(!$pm_number || !$pm_title)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
$pm = new projectmanager_bo();
|
|
|
|
$pm_ids = $pm->search(array('pm_number' => $pm_number, 'pm_title' => $pm_title));
|
|
|
|
if($pm_ids && count($pm_ids) >= 1)
|
|
|
|
{
|
|
|
|
return $pm_ids[0]['pm_id'];
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2016-11-24 18:20:45 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a copy from an entry currently read into $this->data including all
|
|
|
|
* customfields, attachments and links
|
|
|
|
*/
|
|
|
|
private function create_copy()
|
|
|
|
{
|
|
|
|
$original_id = $this->data['ts_id'];
|
|
|
|
unset($this->data['ts_id']);
|
2017-04-04 16:52:25 +02:00
|
|
|
|
2016-11-24 18:20:45 +01:00
|
|
|
$this->data['ts_title'] = lang('Copy of:') . ' ' .$this->data['ts_title'];
|
|
|
|
unset($this->data['ts_modified']);
|
|
|
|
unset($this->data['ts_modifier']);
|
|
|
|
$this->data['ts_owner'] = !(int)$this->data['ts_owner'] || !$this->check_acl(Acl::ADD,NULL,$this->data['ts_owner']) ? $this->user : $this->data['ts_owner'];
|
|
|
|
|
|
|
|
// Copy links
|
|
|
|
if(!is_array($this->data['link_to'])) $this->data['link_to'] = array();
|
|
|
|
$this->data['link_to']['to_app'] = 'timesheet';
|
|
|
|
$this->data['link_to']['to_id'] = 0;
|
|
|
|
|
|
|
|
foreach(Link::get_links($this->data['link_to']['to_app'], $original_id) as $link)
|
|
|
|
{
|
|
|
|
if ($link['app'] != Link::VFS_APPNAME)
|
|
|
|
{
|
|
|
|
Link::link('timesheet', $this->data['link_to']['to_id'], $link['app'], $link['id'], $link['remark']);
|
|
|
|
}
|
|
|
|
elseif ($link['app'] == Link::VFS_APPNAME)
|
|
|
|
{
|
|
|
|
Link::link('timesheet', $this->data['link_to']['to_id'], Link::VFS_APPNAME, array(
|
|
|
|
'tmp_name' => Link::vfs_path($link['app2'], $link['id2']).'/'.$link['id'],
|
|
|
|
'name' => $link['id'],
|
|
|
|
), $link['remark']);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-01-11 06:17:15 +01:00
|
|
|
}
|