mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-26 00:29:38 +01:00
- Implemented a hook for timesheet_ui::edit to query calling apps for additional information to set in new tickets incl. links.
Replaces existing $_GET parameters, which are hard to set for new action system. - also adding category color to infolog and tracker
This commit is contained in:
parent
a147a9a4a8
commit
486e99ec0c
@ -1946,4 +1946,30 @@ class calendar_bo
|
||||
if ($this->debug > 1) error_log(__METHOD__. "($user, '$filter') = $ctag = ".date('Y-m-d H:i:s',$ctag)." took ".(microtime(true)-$startime)." secs");
|
||||
return $ctag;
|
||||
}
|
||||
|
||||
/**
|
||||
* Hook for timesheet to set some extra data and links
|
||||
*
|
||||
* @param array $data
|
||||
* @param int $data[id] cal_id:recurrence
|
||||
* @return array with key => value pairs to set in new timesheet and link_app/link_id arrays
|
||||
*/
|
||||
function timesheet_set($data)
|
||||
{
|
||||
$set = array();
|
||||
list($id,$recurrence) = explode(':',$data['id']);
|
||||
if ((int)$id && ($event = $this->read($id,$recurrence)))
|
||||
{
|
||||
$set['ts_start'] = $event['start'];
|
||||
$set['ts_title'] = $this->link_title($event);
|
||||
$set['start_time'] = egw_time::to($event['start'],'H:i');
|
||||
$set['ts_description'] = $event['description'];
|
||||
if ($this->isWholeDay($event)) $event['end']++; // whole day events are 1sec short
|
||||
$set['ts_duration'] = ($event['end'] - $event['start']) / 60;
|
||||
$set['ts_quantity'] = ($event['end'] - $event['start']) / 3600;
|
||||
$set['end_time'] = null; // unset end-time
|
||||
$set['cat_id'] = (int)$event['category'];
|
||||
}
|
||||
return $set;
|
||||
}
|
||||
}
|
||||
|
@ -42,6 +42,7 @@ $setup_info['calendar']['hooks']['settings'] = 'calendar_hooks::settings';
|
||||
$setup_info['calendar']['hooks']['sidebox_menu'] = 'calendar.calendar_ui.sidebox_menu';
|
||||
$setup_info['calendar']['hooks']['search_link'] = 'calendar_hooks::search_link';
|
||||
$setup_info['calendar']['hooks']['config_validate'] = 'calendar_hooks::config_validate';
|
||||
$setup_info['calendar']['hooks']['timesheet_set'] = 'calendar.calendar_bo.timesheet_set';
|
||||
|
||||
/* Dependencies for this app to work */
|
||||
$setup_info['calendar']['depends'][] = array(
|
||||
|
@ -222,11 +222,6 @@ class infolog_ui
|
||||
$info['pm_id'] = $link['id'];
|
||||
}
|
||||
if ($link['app'] == 'timesheet') $timesheets[] = $link['id'];
|
||||
|
||||
if ($link['app'] != 'timesheet' && $link['app'] != egw_link::VFS_APPNAME)
|
||||
{
|
||||
$info['extra_links'] .= '&link_app[]='.$link['app'].'&link_id[]='.$link['id'];
|
||||
}
|
||||
}
|
||||
if ($this->prefs['show_times'] && isset($GLOBALS['egw_info']['user']['apps']['timesheet']) && $timesheets)
|
||||
{
|
||||
@ -460,6 +455,32 @@ class infolog_ui
|
||||
return $query['total'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Hook for timesheet to set some extra data and links
|
||||
*
|
||||
* @param array $data
|
||||
* @param int $data[id] info_id
|
||||
* @return array with key => value pairs to set in new timesheet and link_app/link_id arrays
|
||||
*/
|
||||
function timesheet_set($data)
|
||||
{
|
||||
$set = array();
|
||||
if ((int)$data['id'] && ($info = $this->bo->read($data['id'])))
|
||||
{
|
||||
if ($info['info_cat']) $set['cat_id'] = $info['info_cat'];
|
||||
|
||||
foreach(egw_link::get_links('infolog',$info['info_id'],'','link_lastmod DESC',true) as $link)
|
||||
{
|
||||
if ($link['app'] != 'timesheet' && $link['app'] != egw_link::VFS_APPNAME)
|
||||
{
|
||||
$set['link_app'][] = $link['app'];
|
||||
$set['link_id'][] = $link['id'];
|
||||
}
|
||||
}
|
||||
}
|
||||
return $set;
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows the infolog list
|
||||
*
|
||||
|
File diff suppressed because one or more lines are too long
@ -60,6 +60,7 @@ $setup_info['infolog']['hooks']['calendar_include_todos'] = 'infolog.infolog_bo
|
||||
$setup_info['infolog']['hooks']['sidebox_menu'] = 'infolog_hooks::all_hooks';
|
||||
$setup_info['infolog']['hooks']['search_link'] = 'infolog_hooks::search_link';
|
||||
$setup_info['infolog']['hooks']['pm_custom_app_icons'] = 'infolog.infolog_bo.pm_icons';
|
||||
$setup_info['infolog']['hooks']['timesheet_set'] = 'infolog.infolog_ui.timesheet_set';
|
||||
|
||||
/* Dependencies for this app to work */
|
||||
$setup_info['infolog']['depends'][] = array(
|
||||
|
@ -79,7 +79,7 @@
|
||||
<description value="Sub" class="noPrint"/>
|
||||
<nextmatch-header label="Action" id="actions" class="noPrint"/>
|
||||
</row>
|
||||
<row class="row $row_cont[class] $row_cont[cat_id]" valign="top">
|
||||
<row class="$row_cont[info_cat] $row_cont[class]" valign="top">
|
||||
<hbox align="center" options="5">
|
||||
<image label="$row_cont[info_type]" src="${row}[info_type]"/>
|
||||
<button statustext="Change the status of an entry, eg. close it" label="$row_cont[info_status_label]" id="edit_status[$row_cont[info_id]]" onclick="window.open(egw::link('/index.php','menuaction=infolog.infolog_ui.edit&info_id=$row_cont[info_id]'),'_blank','dependent=yes,width=750,height=600,scrollbars=yes,status=yes'); return false;" image="$row_cont[info_status_label]" ro_image="$row_cont[info_status_label]"/>
|
||||
@ -147,7 +147,7 @@
|
||||
<button align="center" statustext="Add a new sub-task, -note, -call to this entry" label="Add sub" id="sp[$row_cont[info_id]]" onclick="window.open(egw::link('/index.php','menuaction=infolog.infolog_ui.edit&action=sp&action_id=$row_cont[info_id]'),'_blank','dependent=yes,width=750,height=600,scrollbars=yes,status=yes'); return false;" image="new"/>
|
||||
<button align="center" statustext="View all subs of this entry" label="View subs" id="view[$row_cont[info_id]]" image="view"/>
|
||||
<button align="center" statustext="View the parent of this entry and all his subs" label="View parent" id="view[$row_cont[info_id_parent]]" image="parent"/>
|
||||
<button align="center" label="Add timesheet entry" id="timesheet[$row_cont[info_id]]" onclick="window.open(egw::link('/index.php','menuaction=timesheet.timesheet_ui.edit&link_app[]=infolog&cat_id=$row_cont[info_cat]&link_id[]=$row_cont[info_id]$row_cont[extra_links]'),'_blank','dependent=yes,width=600,height=400,scrollbars=yes,status=yes'); return false;" image="timesheet"/>
|
||||
<button align="center" label="Add timesheet entry" id="timesheet[$row_cont[info_id]]" onclick="window.open(egw::link('/index.php','menuaction=timesheet.timesheet_ui.edit&link_app[]=infolog&link_id[]=$row_cont[info_id]'),'_blank','dependent=yes,width=600,height=400,scrollbars=yes,status=yes'); return false;" image="timesheet"/>
|
||||
</vbox>
|
||||
<vbox options="0" class="noPrint" orient="0">
|
||||
<hbox options="0,0" class="noPrint" orient="0">
|
||||
|
@ -293,27 +293,28 @@ class timesheet_ui extends timesheet_bo
|
||||
{
|
||||
switch ($link_app)
|
||||
{
|
||||
case 'calendar':
|
||||
if (!$n) // only if calendar is first link_app (clicked on ts icon in calendar)!
|
||||
{
|
||||
$calendar_bo = new calendar_bo();
|
||||
list($link_id, $recurrence) = explode(':', $link_id);
|
||||
$event = $calendar_bo->read($link_id, $recurrence);
|
||||
$content['ts_start'] = $event['start'];
|
||||
$content['ts_title'] = $calendar_bo->link_title($event);
|
||||
$content['start_time'] = egw_time::to($event['start'],'H:i');
|
||||
$content['ts_description'] = $event['description'];
|
||||
$content['ts_duration'] = ($event['end'] - $event['start']) / 60;
|
||||
$content['ts_quantity'] = ($event['end'] - $event['start']) / 3600;
|
||||
unset($content['end_time']);
|
||||
}
|
||||
break;
|
||||
case 'projectmanager':
|
||||
$links[] = $link_id;
|
||||
// fall-through;
|
||||
default:
|
||||
// get title from first linked app
|
||||
if(!$n) $preserv['ts_title_blur'] = egw_link::title($link_app,$link_id);
|
||||
if(!$n)
|
||||
{
|
||||
// get title from first linked app
|
||||
$preserv['ts_title_blur'] = egw_link::title($link_app,$link_id);
|
||||
// ask first linked app via "timesheet_set" hook, for further data to set, incl. links
|
||||
if (($set = $GLOBALS['egw']->hooks->single(array('location'=>'timesheet_set','id'=>$link_id),$link_app)))
|
||||
{
|
||||
foreach((array)$set['link_app'] as $i => $l_app)
|
||||
{
|
||||
if (($l_id=$set['link_id'][$i])) egw_link::link(TIMESHEET_APP,$content['link_to']['to_id'],$l_app,$l_id);
|
||||
if ($l_app == 'projectmanager') $links[] = $l_id;
|
||||
}
|
||||
unset($set['link_app']);
|
||||
unset($set['link_id']);
|
||||
|
||||
$content = array_merge($content,$set);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
egw_link::link(TIMESHEET_APP,$content['link_to']['to_id'],$link_app,$link_id);
|
||||
|
Loading…
Reference in New Issue
Block a user