Implement merge for timesheet

This commit is contained in:
Nathan Gray 2011-02-04 20:03:42 +00:00
parent 94165c9a59
commit 36f7301c5b
3 changed files with 85 additions and 10 deletions

View File

@ -109,9 +109,6 @@ class timesheet_hooks
'Grant Access' => egw::link('/index.php','menuaction=preferences.uiaclprefs.index&acl_app='.$appname),
'Edit Categories' => egw::link('/index.php','menuaction=preferences.uicategories.index&cats_app=' . $appname . '&cats_level=True&global_cats=True')
);
// until we have more then one preference
if (is_null(self::$timesheet_bo)) self::$timesheet_bo = new timesheet_bo();
if (!self::$timesheet_bo->status_labels) unset($file['Preferences']);
if ($location == 'preferences')
{
@ -150,10 +147,11 @@ class timesheet_hooks
*/
static function settings()
{
$settings = array();
if (is_null(self::$timesheet_bo)) self::$timesheet_bo = new timesheet_bo();
return array(
'predefined_status' => array(
if (self::$timesheet_bo->status_labels)
{
$settings['predefined_status'] = array(
'type' => 'select',
'label' => 'Status of created timesheets',
'name' => 'predefined_status',
@ -161,7 +159,40 @@ class timesheet_hooks
'help' => 'Select the predefined status, when creating a new timesheet ',
'xmlrpc' => True,
'admin' => False,
),
);
);
}
// Merge print
if ($GLOBALS['egw_info']['user']['apps']['filemanager'])
{
$link = egw::link('/index.php','menuaction=timesheet.timesheet_merge.show_replacements');
$settings['default_document'] = array(
'type' => 'input',
'size' => 60,
'label' => 'Default document to insert entries',
'name' => 'default_document',
'help' => lang('If you specify a document (full vfs path) here, infolog displays an extra document icon for each entry. That icon allows to download the specified document with the contact data inserted.').' '.
lang('The document can contain placeholder like $$subject$$, to be replaced with the contact data (%1full list of placeholder names%2).','<a href="'.$link.'" target="_blank">','</a>').' '.
lang('At the moment the following document-types are supported:').'*.rtf, *.txt',
'run_lang' => false,
'xmlrpc' => True,
'admin' => False,
);
$settings['document_dir'] = array(
'type' => 'input',
'size' => 60,
'label' => 'Directory with documents to insert entries',
'name' => 'document_dir',
'help' => lang('If you specify a directory (full vfs path) here, eGroupWare displays an action for each document. That action allows to download the specified document with the %1 data inserted.', lang('timesheet')).' '.
lang('The document can contain placeholder like $$info_subject$$, to be replaced with the contact data (%1full list of placeholder names%2).','<a href="'.$link.'" target="_blank">','</a>').' '.
lang('At the moment the following document-types are supported:').'*.rtf, *.txt',
'run_lang' => false,
'xmlrpc' => True,
'admin' => False,
);
}
return $settings;
}
}

View File

@ -719,6 +719,7 @@ class timesheet_ui extends timesheet_bo
}
}
}
$readonlys["document[{$row['ts_id']}]"] = !$GLOBALS['egw_info']['user']['preferences']['timesheet']['default_document'];
if (!$query['filter2'])
{
unset($row['ts_description']);
@ -774,6 +775,12 @@ class timesheet_ui extends timesheet_bo
$msg = lang('Error deleting the entry!!!');
}
}
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']);
$content['action'] = 'document';
$content['nm']['rows']['checked'] = array($id);
}
if ($content['action'] != '')
{
if (!count($content['nm']['rows']['checked']) && !$content['use_all'])
@ -855,6 +862,12 @@ class timesheet_ui extends timesheet_bo
$sel_options['action'][lang('Modify the Status of the Timesheet')] = $status;
unset($status);
// Merge print
if ($GLOBALS['egw_info']['user']['preferences']['timesheet']['document_dir'])
{
$sel_options['action'][lang('Insert in document').':'] = timesheet_merge::get_documents($GLOBALS['egw_info']['user']['preferences']['timesheet']['document_dir']);
}
if ($this->pm_integration != 'full')
{
$projects =& $this->query_list('ts_project');
@ -953,6 +966,10 @@ class timesheet_ui extends timesheet_bo
}
break;
case 'document':
$msg = $this->download_document($checked,$settings);
$failed = count($checked);
return false;
}
return !$failed;
@ -1083,4 +1100,31 @@ class timesheet_ui extends timesheet_bo
}
</script>';
}
/**
* Download a document with inserted entries
*
* @param array $ids timesheet-ids
* @param string $document vfs-path of document
* @return string error-message or error, otherwise the function does NOT return!
*/
function download_document($ids,$document='')
{
if (!$document)
{
$document = $GLOBALS['egw_info']['user']['preferences']['timesheet']['default_document'];
}
else
{
$document = $GLOBALS['egw_info']['user']['preferences']['timesheet']['document_dir'].'/'.$document;
}
if (!@egw_vfs::stat($document))
{
return lang("Document '%1' does not exist or is not readable for you!",$document);
}
require_once(EGW_INCLUDE_ROOT.'/timesheet/inc/class.timesheet_merge.inc.php');
$document_merge = new timesheet_merge();
return $document_merge->download($document,$ids);
}
}

File diff suppressed because one or more lines are too long