added hirachie for status and option, that only admin can change accounted status timesheets

This commit is contained in:
Stefan Becker 2009-09-08 09:23:41 +00:00
parent 7272217d14
commit 51f0999141
6 changed files with 179 additions and 18 deletions

View File

@ -111,7 +111,16 @@ class timesheet_bo extends so_sql_cf
* @var array
*/
var $status_labels = array();
/**
* Array with status label configuration
*
* @var array
*/
var $status_labels_config = array();
/**
* Array with substatus of label configuration
*/
var $status_labels_substatus = array();
/**
* Name of the timesheet table storing custom fields
*/
@ -123,8 +132,48 @@ class timesheet_bo extends so_sql_cf
$this->config_data = config::read(TIMESHEET_APP);
$this->quantity_sum = $this->config_data['quantity_sum'] == 'true';
if($this->config_data['status_labels']) $this->status_labels =& $this->config_data['status_labels'];
if($this->config_data['status_labels'])
{
$this->status_labels =& $this->config_data['status_labels'];
if (!is_array($this->status_labels)) $this->status_labels= array($this->status_labels);
foreach ($this->status_labels as $status_id => $label)
{
if (!is_array($label))
{ //old values, bevor parent status
$name = $label;
$label=array();
$label['name'] = $name;
$label['parent'] = '';
}
$sort_labels[$status_id][] = $label['name'];
$this->status_labels_config[$status_id] = $label;
if ($label['parent']!='')
{
$sort = $label['parent']?$label['parent']:$status_id;
$sort_labels[$sort][$status_id]= $label['name'];
$this->status_labels_substatus[$sort][$status_id] = $status_id;
if (!isset($this->status_labels_substatus[$sort][$sort]))
{
$this->status_labels_substatus[$sort][$sort]= $sort;
}
}
}
unset($this->status_labels);
foreach ($sort_labels as $status_id => $label_sub)
{
if (!isset($this->status_labels[$status_id])) $this->status_labels[$status_id] = $this->status_labels_config[$status_id]['name'];
foreach ($sort_labels[$status_id] as $sub_status_id => $sub_label)
{
if (isset($this->status_labels_config[$sub_status_id]))
{
$level = '  ';
if (isset($this->status_labels_substatus[$sub_status_id])) $this->status_labels_substatus['2level'][$sub_status_id] = $sub_status_id ;
if (isset($this->status_labels_substatus['2level'][$status_id])) $level = '    ';
$this->status_labels[$sub_status_id]= $level.$this->status_labels_config[$sub_status_id]['name'];
}
}
}
}
$this->tz_offset_s = $GLOBALS['egw']->datetime->tz_offset;
$this->now = time() + $this->tz_offset_s; // time() is server-time and we need a user-time
$this->today = mktime(0,0,0,date('m',$this->now),date('d',$this->now),date('Y',$this->now));

View File

@ -60,7 +60,6 @@ class timesheet_ui extends timesheet_bo
{
$tabs = 'general|notes|links|customfields';
$etpl = new etemplate('timesheet.edit');
if (!is_array($content))
{
if ($view || (int)$_GET['ts_id'])
@ -87,6 +86,15 @@ class timesheet_ui extends timesheet_bo
}
$referer = preg_match('/menuaction=([^&]+)/',$_SERVER['HTTP_REFERER'],$matches) ? $matches[1] :
(strpos($_SERVER['HTTP_REFERER'],'/infolog/index.php') !== false ? 'infolog.infolog_ui.index' : TIMESHEET_APP.'.timesheet_ui.index');
if (!isset($GLOBALS['egw_info']['user']['apps']['admin']) && $this->data['ts_status'])
{
if ($this->status_labels_config[$this->data['ts_status']]['admin'])
{
$view = true; //only admin can edit with this status
$only_admin_edit = true;
$msg = lang('only Admin can edit this status');
}
}
}
else
{
@ -117,7 +125,7 @@ class timesheet_ui extends timesheet_bo
switch($button)
{
case 'edit':
if ($this->check_acl(EGW_ACL_EDIT)) $view = false;
if ($this->check_acl(EGW_ACL_EDIT) && $only_admin_edit) $view = false;
break;
case 'save':
@ -300,7 +308,6 @@ class timesheet_ui extends timesheet_bo
// 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
$content['ts_title_blur'] = $preserv['ts_title_blur'] ? $preserv['ts_title_blur'] : $preserv['ts_project_blur'];
$readonlys = array(
'button[delete]' => !$this->data['ts_id'] || !$this->check_acl(EGW_ACL_DELETE),
'button[edit]' => !$view || !$this->check_acl(EGW_ACL_EDIT),
@ -440,6 +447,17 @@ class timesheet_ui extends timesheet_bo
$query['col_filter']['ts_status'] = null;
}
#_debug_array($query['col_filter']);
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]);
}
}
}
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']);
@ -650,7 +668,6 @@ class timesheet_ui extends timesheet_bo
$etpl = new etemplate('timesheet.index');
if ($_GET['msg']) $msg = $_GET['msg'];
if ($content['nm']['rows']['delete'])
{
list($ts_id) = each($content['nm']['rows']['delete']);
@ -663,7 +680,6 @@ class timesheet_ui extends timesheet_bo
$msg = lang('Error deleting the entry!!!');
}
}
if ($content['action'] != '')
{
if (!count($content['nm']['rows']['checked']) && !$content['use_all'])
@ -842,15 +858,19 @@ class timesheet_ui extends timesheet_bo
foreach($content['statis'] as $cat)
{
$id = $cat['id'];
if (($cat ['name'] !== $this->status_labels[$id]) && ($cat ['name'] !== ''))
if (($cat ['name'] !== $this->status_labels_config[$id]) && ($cat ['name'] !== '') || ($cat ['parent'] !== $this->status_labels_config[$id]['parent']) && ($cat ['parent'] !== ''))
{
$this->status_labels[$id] = $cat['name'];
$this->status_labels_config[$id] = array(
'name' => $cat['name'],
'parent' => $cat['parent'],
'admin' => $cat['admin']);
$need_update = true;
}
}
if ($need_update)
{
config::save_value('status_labels',$this->status_labels,TIMESHEET_APP);
config::save_value('status_labels',$this->status_labels_config,TIMESHEET_APP);
$msg .= lang('Status updated.');
}
}
@ -859,10 +879,10 @@ class timesheet_ui extends timesheet_bo
if (isset($content['statis']['delete']))
{
list($id) = each($content['statis']['delete']);
if (isset($this->status_labels[$id]))
if (isset($this->status_labels_config[$id]))
{
unset($this->status_labels[$id]);
config::save_value('status_labels',$this->status_labels,TIMESHEET_APP);
unset($this->status_labels_config[$id]);
config::save_value('status_labels',$this->status_labels_config,TIMESHEET_APP);
unset($this->status_labels[$id]);
$msg .= lang('Status deleted.');
}
@ -870,18 +890,22 @@ class timesheet_ui extends timesheet_bo
$i = 1;
unset($content['statis']);
foreach($this->status_labels as $id => $label)
foreach($this->status_labels_config as $id => $label)
{
$content['statis'][$i]['name']= $label;
$content['statis'][$i]['name']= $label['name'];
$content['statis'][$i]['id']= $id;
$content['statis'][$i]['parent']= $label['parent'];
$content['statis'][$i]['admin']= $label['admin'];
$i++;
}
$content['statis'][$i]['name'] = '';
$content['statis'][$i]['parent'];
$content['statis'][$i]['admin'] = '';
$content['statis'][$i]['id'] = ++$id;
$content['msg'] = $msg;
$preserv = $content;
$sel_options['parent'] = $this->status_labels;
$etpl = new etemplate('timesheet.editstatus');
$etpl->exec('timesheet.timesheet_ui.editstatus',$content,$sel_options,$readonlys,$preserv);
}

View File

@ -42,6 +42,8 @@ field must not be empty !!! timesheet de Dieses Feld darf nicht leer sein!!!
full: use only projectmanager admin de Komplett: verwende nur Projektmanager
general timesheet de Allgemein
global categories timesheet de Globale Kategorien
history timesheet de Historie
id timesheet de ID
last modified timesheet de Zuletzt geändert
last month timesheet de Letzten Monat
last week timesheet de Letzte Woche
@ -58,8 +60,10 @@ no project timesheet de Kein Projekt
no status timesheet de Kein Status
none: use only free project-names admin de Keine: verwende nur freie Projektnamen
number of row for a multiline inputfield or line of a multi-select-box timesheet de Anzahl von Reihen für ein Mehrzeiliges Textfeld oder einer Mehrfachauswahlbox
only admin timesheet de nur Admin
or endtime timesheet de oder Endzeit
order timesheet de Reihenfolge
parent timesheet de Übergeordnet
permission denied!!! timesheet de Zugriff verweigert!!!
price timesheet de Preis
projectmanager integration admin de Integration des Projektmanagers
@ -72,6 +76,7 @@ select a price timesheet de Preis auswählen
select a project timesheet de Projekt auswählen
select a status of the timesheet timesheet de einen status auswählen
select action timesheet de Bitte eine Aktion auswählen
select infolog timesheet de Infolog auswählen
select multiple timeshhets for a further action timesheet de Wählen Sie mehrere Stundenzettel für einen weitere Aktion aus
select the predefined status, whan creating a new timesheet timesheet de Wählen Sie einen Status als Vorgabe für neu zu erstellende Stundenzettel aus
show a quantity sum (eg. to sum up negative overtime) admin de Zeige eine Mengensumme (z.B. um negative Überstunden zu summieren)

View File

@ -42,6 +42,8 @@ field must not be empty !!! timesheet en Field must not be empty !!!
full: use only projectmanager admin en Full: use only ProjectManager
general timesheet en General
global categories timesheet en Global Categories
history timesheet en History
id timesheet en ID
last modified timesheet en Last modified
last month timesheet en Last month
last week timesheet en Last week
@ -58,8 +60,10 @@ no project timesheet en No project
no status timesheet en No status
none: use only free project-names admin en None: use only free project-names
number of row for a multiline inputfield or line of a multi-select-box timesheet en number of row for a multiline inputfield or line of a multi-select-box
only admin timesheet en Only Admin
or endtime timesheet en or Endtime
order timesheet en Order
parent timesheet en Parent
permission denied!!! timesheet en Permission denied!!!
price timesheet en Price
projectmanager integration admin en ProjectManager integration
@ -72,6 +76,7 @@ select a price timesheet en Select a price
select a project timesheet en Select a project
select a status of the timesheet timesheet en select a status of the timesheet
select action timesheet en Select action
select infolog timesheet en select Infolog
select multiple timeshhets for a further action timesheet en Select multiple timeshhets for a further action
select the predefined status, whan creating a new timesheet timesheet en Select the predefined status, whan creating a new timesheet
show a quantity sum (eg. to sum up negative overtime) admin en Show a quantity sum (eg. to sum up negative overtime)

File diff suppressed because one or more lines are too long

View File

@ -1,7 +1,7 @@
<?xml version="1.0"?>
<!-- $Id$ -->
<overlay>
<template id="timesheet.editstatus" template="" lang="" group="0" version="1.7.001">
<template id="timesheet.editstatus" template="" lang="" group="0" version="1.7.004">
<grid width="100%" height="450" overflow="auto">
<columns>
<column width="100"/>
@ -30,16 +30,27 @@
<description value="Status"/>
<grid width="100%" height="280" overflow="auto" id="statis">
<columns>
<column/>
<column/>
<column/>
<column/>
<column width="5%"/>
</columns>
<rows>
<row class="th">
<description value="ID"/>
<description value="Name"/>
<description value="Parent"/>
<description value="Only Admin"/>
<description value="Actions"/>
</row>
<row class="row">
<description id="${row}[id]"/>
<textbox size="80" maxlength="150" blur="--&gt; enter new name" id="${row}[name]"/>
<menulist>
<menupopup id="${row}[parent]" options="please select"/>
</menulist>
<checkbox id="${row}[admin]" statustext="Only Admin can change this Status"/>
<button image="delete" label="Delete" align="center" id="delete[$row_cont[id]]" statustext="Delete this status" onclick="return confirm('Delete this status');"/>
</row>
</rows>