diff --git a/timesheet/inc/class.timesheet_bo.inc.php b/timesheet/inc/class.timesheet_bo.inc.php index d964de726b..d919f6b77c 100644 --- a/timesheet/inc/class.timesheet_bo.inc.php +++ b/timesheet/inc/class.timesheet_bo.inc.php @@ -50,19 +50,6 @@ class timesheet_bo extends so_sql_cf var $timestamps = array( 'ts_start','ts_modified' ); - /** - * Offset in secconds between user and server-time, it need to be add to a server-time to get the user-time - * or substracted from a user-time to get the server-time - * - * @var int - */ - var $tz_offset_s; - /** - * Current time as timestamp in user-time - * - * @var int - */ - var $now; /** * Start of today in user-time * @@ -127,15 +114,17 @@ class timesheet_bo extends so_sql_cf * Array with substatus of label configuration */ var $status_labels_substatus = array(); - /** - * Name of the timesheet table storing custom fields - */ - var $historylog; /** * Instance of the timesheet_tracking object * * @var timesheet_tracking */ + var $tracking; + /** + * Translates field / acl-names to labels + * + * @var array + */ var $field2label = array( 'ts_project' => 'Project', 'ts_title' => 'Title', @@ -154,21 +143,13 @@ class timesheet_bo extends so_sql_cf 'customfields' => 'Custom fields', ); /** - * Translates field / acl-names to labels + * setting field-name from DB to history status * * @var array */ var $field2history = array(); /** - * setting field-name from DB to history status - * - * @var array - */ - var $tracking; - /** - * Names of all config vars - * - * @var array + * Name of the timesheet table storing custom fields */ const EXTRA_TABLE = 'egw_timesheet_extra'; @@ -220,8 +201,6 @@ class timesheet_bo extends so_sql_cf } } } - $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)); // save us in $GLOBALS['timesheet_bo'] for ExecMethod used in hooks @@ -232,9 +211,8 @@ class timesheet_bo extends so_sql_cf $this->grants = $GLOBALS['egw']->acl->get_grants(TIMESHEET_APP); //set fields for tracking $this->field2history = array_keys($this->db_cols); - $this->field2history = array_diff(array_combine($this->field2history,$this->field2history), - array('ts_modified')); - $this->field2history = $this->field2history +array('customfields' => '#c'); //add custom fields for history + $this->field2history = array_diff(array_combine($this->field2history,$this->field2history),array('ts_modified')); + $this->field2history += array('customfields' => '#c'); //add custom fields for history } /** @@ -616,50 +594,6 @@ class timesheet_bo extends so_sql_cf return $ret; } - /** - * changes the data from the db-format to your work-format - * - * reimplemented to adjust the timezone of the timestamps (adding $this->tz_offset_s to get user-time) - * Please note, we do NOT call the method of the parent so_sql !!! - * - * @param array $data if given works on that array and returns result, else works on internal data-array - * @return array with changed data - */ - function db2data($data=null) - { - if (!is_array($data)) - { - $data = &$this->data; - } - foreach($this->timestamps as $name) - { - if (isset($data[$name]) && $data[$name]) $data[$name] += $this->tz_offset_s; - } - return $data; - } - - /** - * changes the data from your work-format to the db-format - * - * reimplemented to adjust the timezone of the timestamps (subtraction $this->tz_offset_s to get server-time) - * Please note, we do NOT call the method of the parent so_sql !!! - * - * @param array $data if given works on that array and returns result, else works on internal data-array - * @return array with changed data - */ - function data2db($data=null) - { - if ($intern = !is_array($data)) - { - $data = &$this->data; - } - foreach($this->timestamps as $name) - { - if (isset($data[$name]) && $data[$name]) $data[$name] -= $this->tz_offset_s; - } - return $data; - } - /** * Get the time- and pricesum for the given timesheet entries * @@ -807,6 +741,4 @@ class timesheet_bo extends so_sql_cf } return array(); } - - } \ No newline at end of file diff --git a/timesheet/inc/class.timesheet_ui.inc.php b/timesheet/inc/class.timesheet_ui.inc.php index c4e0243ab6..6d8c061271 100644 --- a/timesheet/inc/class.timesheet_ui.inc.php +++ b/timesheet/inc/class.timesheet_ui.inc.php @@ -78,7 +78,7 @@ class timesheet_ui extends timesheet_bo { $this->data = array( 'ts_start' => $this->today, - 'end_time' => $this->now - $this->today, + 'end_time' => egw_time::to($this->now,'H:i'), 'ts_owner' => $GLOBALS['egw_info']['user']['account_id'], 'cat_id' => (int) $_REQUEST['cat_id'], ); @@ -98,7 +98,6 @@ class timesheet_ui extends timesheet_bo else { //echo "

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]

\n"; - // we only need 2 out of 3 values from start-, end-time or duration (the date in ts_start is always required!) if (!isset($GLOBALS['egw_info']['user']['apps']['admin']) && $content['ts_status']) { if ($this->status_labels_config[$content['ts_status']]['admin']) @@ -109,17 +108,30 @@ class timesheet_ui extends timesheet_bo } } - if ($content['start_time']) // start-time specified + // we only need 2 out of 3 values from start-, end-time or duration (the date in ts_start is always required!) + if ($content['start_time'] != '00:00') // start-time specified { - $content['ts_start'] += $content['start_time']; + //$content['ts_start'] += $content['start_time']; + $start = new egw_time($content['ts_start']); + $start_time = explode(':',$content['start_time']); + $start->setTime($start_time[0],$start_time[1]); + $content['ts_start'] = $start->format('ts'); } - if ($content['end_time'] && $content['start_time']) // start- & end-time --> calculate the duration + if ($content['end_time'] != '00:00') // end-time specified { - $content['ts_duration'] = ($content['end_time'] - $content['start_time']) / 60; + $end = new egw_time($content['ts_start']); + $end_time = explode(':',$content['end_time']); + $end->setTime($end_time[0],$end_time[1]); } - elseif ($content['ts_duration'] && $content['end_time']) // no start, calculate from end and duration + if ($end && $start) // start- & end-time --> calculate the duration { - $content['ts_start'] += $content['end_time'] - 60*$content['ts_duration']; + $content['ts_duration'] = ($end->format('ts') - $start->format('ts')) / 60; + //echo "

end_time=$content[end_time], start_time=$content[start_time] --> duration=$content[ts_duration]

\n"; + } + elseif ($content['ts_duration'] && $end) // no start, calculate from end and duration + { + $content['ts_start'] = $end->format('ts') - 60*$content['ts_duration']; + //echo "

end_time=$content[end_time], duration=$content[ts_duration] --> ts_start=$content[ts_start]=".egw_time::to($content['ts_start'])."

\n"; } if ($content['ts_duration'] > 0) unset($content['end_time']); // now we only deal with start (date+time) and duration @@ -262,7 +274,7 @@ class timesheet_ui extends timesheet_bo ), 'js' => "\n", 'ts_quantity_blur' => $this->data['ts_duration'] ? round($this->data['ts_duration'] / 60.0,3) : '', - 'start_time' => $this->datetime2time($this->data['ts_start']), + 'start_time' => egw_time::to($this->data['ts_start'],'H:i'), 'pm_integration' => $this->pm_integration, 'ts_status' => ($preserv['ts_status'] !='')? $preserv['ts_status'] : $GLOBALS['egw_info']['user']['preferences']['timesheet']['predefined_status'], )); diff --git a/timesheet/setup/etemplates.inc.php b/timesheet/setup/etemplates.inc.php index 387a49aaec..46b4fd2c34 100644 --- a/timesheet/setup/etemplates.inc.php +++ b/timesheet/setup/etemplates.inc.php @@ -2,7 +2,7 @@ /** * eGroupWare - eTemplates for Application timesheet * http://www.egroupware.org - * generated by soetemplate::dump4setup() 2009-09-26 13:15 + * generated by soetemplate::dump4setup() 2009-10-26 09:10 * * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @package timesheet @@ -12,134 +12,36 @@ $templ_version=1; -$templ_data[] = array('name' => 'timesheet.customfields','template' => '','lang' => '','group' => '0','version' => '0.1.001','data' => 'a:1:{i:0;a:4:{s:4:"type";s:4:"grid";s:4:"data";a:7:{i:0;a:3:{s:1:"C";s:3:"80%";s:2:"c4";s:6:"header";s:2:"h1";s:8:"40,!@msg";}i:1;a:3:{s:1:"A";a:5:{s:4:"type";s:5:"label";s:4:"span";s:13:"all,reditalic";s:4:"name";s:3:"msg";s:7:"no_lang";s:1:"1";s:5:"align";s:6:"center";}s:1:"B";a:1:{s:4:"type";s:5:"label";}s:1:"C";a:1:{s:4:"type";s:5:"label";}}i:2;a:3:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:5:"label";s:4:"type";}s:1:"B";a:5:{s:4:"type";s:6:"select";s:4:"name";s:3:"typ";s:8:"onchange";i:1;s:4:"help";s:52:"select a typ to edit it\'s status-values or delete it";s:7:"no_lang";s:1:"1";}s:1:"C";a:5:{s:4:"type";s:5:"label";s:4:"span";s:10:",error_msg";s:7:"no_lang";s:1:"1";s:5:"align";s:6:"center";s:4:"name";s:9:"error_msg";}}i:3;a:3:{s:1:"A";a:4:{s:4:"type";s:8:"template";s:4:"size";s:6:"status";s:4:"span";s:3:"all";s:4:"name";s:6:"status";}s:1:"B";a:1:{s:4:"type";s:5:"label";}s:1:"C";a:1:{s:4:"type";s:5:"label";}}i:4;a:3:{s:1:"A";a:3:{s:4:"type";s:5:"label";s:4:"span";s:3:"all";s:5:"label";s:13:"Custom fields";}s:1:"B";a:1:{s:4:"type";s:5:"label";}s:1:"C";a:1:{s:4:"type";s:5:"label";}}i:5;a:3:{s:1:"A";a:4:{s:4:"type";s:8:"template";s:4:"size";s:6:"fields";s:4:"span";s:3:"all";s:4:"name";s:6:"fields";}s:1:"B";a:1:{s:4:"type";s:5:"label";}s:1:"C";a:1:{s:4:"type";s:5:"label";}}i:6;a:3:{s:1:"A";a:6:{s:4:"type";s:4:"hbox";s:4:"size";s:1:"3";s:4:"span";s:3:"all";i:1;a:4:{s:4:"type";s:6:"button";s:5:"label";s:4:"Save";s:4:"name";s:12:"button[save]";s:4:"help";s:33:"saves the changes made and leaves";}i:2;a:4:{s:4:"type";s:6:"button";s:5:"label";s:5:"Apply";s:4:"name";s:13:"button[apply]";s:4:"help";s:19:"applies the changes";}i:3;a:4:{s:4:"type";s:6:"button";s:5:"label";s:6:"Cancel";s:4:"name";s:14:"button[cancel]";s:4:"help";s:22:"leaves without saveing";}}s:1:"B";a:1:{s:4:"type";s:5:"label";}s:1:"C";a:1:{s:4:"type";s:5:"label";}}}s:4:"rows";i:6;s:4:"cols";i:3;}}','size' => '','style' => '.header { font-weight: bold; font-size: 120%; } -.error_msg { color: red; font-style: italics; }','modified' => '1148375906',); - -$templ_data[] = array('name' => 'timesheet.customfields','template' => '','lang' => '','group' => '0','version' => '1.2.001','data' => 'a:1:{i:0;a:4:{s:4:"type";s:4:"grid";s:4:"data";a:5:{i:0;a:2:{s:1:"F";s:3:"80%";s:2:"c2";s:6:"header";}i:1;a:6:{s:1:"A";a:4:{s:4:"type";s:8:"template";s:4:"size";s:6:"status";s:4:"span";s:3:"all";s:4:"name";s:6:"status";}s:1:"B";a:1:{s:4:"type";s:5:"label";}s:1:"C";a:1:{s:4:"type";s:5:"label";}s:1:"D";a:1:{s:4:"type";s:5:"label";}s:1:"E";a:1:{s:4:"type";s:5:"label";}s:1:"F";a:1:{s:4:"type";s:5:"label";}}i:2;a:6:{s:1:"A";a:3:{s:4:"type";s:5:"label";s:4:"span";s:3:"all";s:5:"label";s:13:"Custom fields";}s:1:"B";a:1:{s:4:"type";s:5:"label";}s:1:"C";a:1:{s:4:"type";s:5:"label";}s:1:"D";a:1:{s:4:"type";s:5:"label";}s:1:"E";a:1:{s:4:"type";s:5:"label";}s:1:"F";a:1:{s:4:"type";s:5:"label";}}i:3;a:6:{s:1:"A";a:4:{s:4:"type";s:8:"template";s:4:"size";s:6:"fields";s:4:"span";s:3:"all";s:4:"name";s:6:"fields";}s:1:"B";a:1:{s:4:"type";s:5:"label";}s:1:"C";a:1:{s:4:"type";s:5:"label";}s:1:"D";a:1:{s:4:"type";s:5:"label";}s:1:"E";a:1:{s:4:"type";s:5:"label";}s:1:"F";a:1:{s:4:"type";s:5:"label";}}i:4;a:6:{s:1:"A";a:6:{s:4:"type";s:4:"hbox";s:4:"size";s:1:"3";s:4:"span";s:3:"all";i:1;a:4:{s:4:"type";s:6:"button";s:5:"label";s:4:"Save";s:4:"name";s:12:"button[save]";s:4:"help";s:33:"saves the changes made and leaves";}i:2;a:4:{s:4:"type";s:6:"button";s:5:"label";s:5:"Apply";s:4:"name";s:13:"button[apply]";s:4:"help";s:19:"applies the changes";}i:3;a:4:{s:4:"type";s:6:"button";s:5:"label";s:6:"Cancel";s:4:"name";s:14:"button[cancel]";s:4:"help";s:22:"leaves without saveing";}}s:1:"B";a:1:{s:4:"type";s:5:"label";}s:1:"C";a:1:{s:4:"type";s:5:"label";}s:1:"D";a:1:{s:4:"type";s:5:"label";}s:1:"E";a:1:{s:4:"type";s:5:"label";}s:1:"F";a:1:{s:4:"type";s:5:"label";}}}s:4:"rows";i:4;s:4:"cols";i:6;}}','size' => '','style' => '.header { font-weight: bold; font-size: 120%; } -.error_msg { color: red; font-style: italics; }','modified' => '1163155004',); - $templ_data[] = array('name' => 'timesheet.customfields','template' => '','lang' => '','group' => '0','version' => '1.2.002','data' => 'a:1:{i:0;a:4:{s:4:"type";s:4:"grid";s:4:"data";a:5:{i:0;a:2:{s:1:"F";s:3:"80%";s:2:"c2";s:6:"header";}i:1;a:6:{s:1:"A";a:4:{s:4:"type";s:8:"template";s:4:"size";s:6:"status";s:4:"span";s:3:"all";s:4:"name";s:6:"status";}s:1:"B";a:1:{s:4:"type";s:5:"label";}s:1:"C";a:1:{s:4:"type";s:5:"label";}s:1:"D";a:1:{s:4:"type";s:5:"label";}s:1:"E";a:1:{s:4:"type";s:5:"label";}s:1:"F";a:1:{s:4:"type";s:5:"label";}}i:2;a:6:{s:1:"A";a:3:{s:4:"type";s:5:"label";s:4:"span";s:3:"all";s:5:"label";s:13:"Custom fields";}s:1:"B";a:1:{s:4:"type";s:5:"label";}s:1:"C";a:1:{s:4:"type";s:5:"label";}s:1:"D";a:1:{s:4:"type";s:5:"label";}s:1:"E";a:1:{s:4:"type";s:5:"label";}s:1:"F";a:1:{s:4:"type";s:5:"label";}}i:3;a:6:{s:1:"A";a:4:{s:4:"type";s:8:"template";s:4:"size";s:6:"fields";s:4:"span";s:3:"all";s:4:"name";s:6:"fields";}s:1:"B";a:1:{s:4:"type";s:5:"label";}s:1:"C";a:1:{s:4:"type";s:5:"label";}s:1:"D";a:1:{s:4:"type";s:5:"label";}s:1:"E";a:1:{s:4:"type";s:5:"label";}s:1:"F";a:1:{s:4:"type";s:5:"label";}}i:4;a:6:{s:1:"A";a:6:{s:4:"type";s:4:"hbox";s:4:"size";s:1:"3";s:4:"span";s:3:"all";i:1;a:4:{s:4:"type";s:6:"button";s:5:"label";s:4:"Save";s:4:"name";s:12:"button[save]";s:4:"help";s:33:"saves the changes made and leaves";}i:2;a:4:{s:4:"type";s:6:"button";s:5:"label";s:5:"Apply";s:4:"name";s:13:"button[apply]";s:4:"help";s:19:"applies the changes";}i:3;a:4:{s:4:"type";s:6:"button";s:5:"label";s:6:"Cancel";s:4:"name";s:14:"button[cancel]";s:4:"help";s:22:"leaves without saveing";}}s:1:"B";a:1:{s:4:"type";s:5:"label";}s:1:"C";a:1:{s:4:"type";s:5:"label";}s:1:"D";a:1:{s:4:"type";s:5:"label";}s:1:"E";a:1:{s:4:"type";s:5:"label";}s:1:"F";a:1:{s:4:"type";s:5:"label";}}}s:4:"rows";i:4;s:4:"cols";i:6;}}','size' => '','style' => '.header { font-weight: bold; font-size: 120%; } .error_msg { color: red; font-style: italics; }','modified' => '1163162665',); -$templ_data[] = array('name' => 'timesheet.customfields.fields','template' => '','lang' => '','group' => '0','version' => '0.1.001','data' => 'a:1:{i:0;a:4:{s:4:"type";s:4:"grid";s:4:"data";a:3:{i:0;a:3:{s:2:"c1";s:2:"th";s:2:"c2";s:7:"row,top";s:1:"A";s:2:",!";}i:1;a:7:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:5:"label";s:3:"Typ";}s:1:"B";a:2:{s:4:"type";s:5:"label";s:5:"label";s:4:"Name";}s:1:"C";a:2:{s:4:"type";s:5:"label";s:5:"label";s:5:"Label";}s:1:"D";a:2:{s:4:"type";s:5:"label";s:5:"label";s:20:"Values for selectbox";}s:1:"E";a:2:{s:4:"type";s:5:"label";s:5:"label";s:14:"Length
Rows";}s:1:"F";a:2:{s:4:"type";s:5:"label";s:5:"label";s:5:"Order";}s:1:"G";a:4:{s:4:"type";s:5:"label";s:5:"label";s:6:"Action";s:5:"align";s:6:"center";s:4:"help";s:18:"deletes this field";}}i:2;a:7:{s:1:"A";a:4:{s:4:"type";s:6:"select";s:4:"size";s:3:"All";s:4:"name";s:11:"${row}[typ]";s:4:"help";s:41:"for which types should this field be used";}s:1:"B";a:4:{s:4:"type";s:4:"text";s:4:"size";s:5:"20,32";s:4:"name";s:12:"${row}[name]";s:4:"help";s:83:"the name used internaly (<= 20 chars), changeing it makes existing data unavailible";}s:1:"C";a:4:{s:4:"type";s:4:"vbox";s:4:"size";s:1:"2";i:1;a:4:{s:4:"type";s:4:"text";s:4:"size";s:4:",255";s:4:"name";s:13:"${row}[label]";s:4:"help";s:30:"the text displayed to the user";}i:2;a:2:{s:4:"type";s:5:"label";s:4:"name";s:13:"${row}[label]";}}s:1:"D";a:4:{s:4:"type";s:8:"textarea";s:4:"size";s:4:"2,30";s:4:"name";s:14:"${row}[values]";s:4:"help";s:40:"each value is a line like [=