From a23acf1dfa6e5c3e4de6f3dced5d5f133358eed5 Mon Sep 17 00:00:00 2001 From: nathangray Date: Tue, 17 Jan 2017 10:34:10 -0700 Subject: [PATCH] * Add creation field to timesheet --- timesheet/inc/class.timesheet_bo.inc.php | 8 +++++-- .../inc/class.timesheet_egw_record.inc.php | 2 +- timesheet/inc/class.timesheet_merge.inc.php | 11 +++++----- .../class.timesheet_wizard_export_csv.inc.php | 5 ++++- timesheet/setup/setup.inc.php | 2 +- timesheet/setup/tables_current.inc.php | 1 + timesheet/setup/tables_update.inc.php | 14 +++++++++++++ timesheet/templates/default/edit.xet | 21 +++++++++++-------- timesheet/templates/default/index.xet | 3 +++ timesheet/templates/mobile/edit.xet | 4 ++++ timesheet/templates/mobile/view.xet | 4 ++++ 11 files changed, 56 insertions(+), 19 deletions(-) diff --git a/timesheet/inc/class.timesheet_bo.inc.php b/timesheet/inc/class.timesheet_bo.inc.php index 2ab360c9d9..6959f3307d 100644 --- a/timesheet/inc/class.timesheet_bo.inc.php +++ b/timesheet/inc/class.timesheet_bo.inc.php @@ -56,7 +56,7 @@ class timesheet_bo extends Api\Storage * @var array */ var $timestamps = array( - 'ts_start','ts_modified' + 'ts_start','ts_created', 'ts_modified' ); /** * Start of today in user-time @@ -527,7 +527,7 @@ class timesheet_bo extends Api\Storage parent::search($criteria,array( (string)$sum_ts_id[$type],"''","''","''",'MIN(ts_start)','SUM(ts_duration) AS ts_duration', ($this->quantity_sum ? "SUM(ts_quantity) AS ts_quantity" : '0'), - '0','NULL','0','0','0','0','0',"SUM($total_sql) AS ts_total" + '0','NULL','0','0','0','0','0','0',"SUM($total_sql) AS ts_total" ),'GROUP BY '.$sum_sql[$type],$sum_extra_cols,$wildcard,$empty,$op,'UNION',$filter,$join,$need_full_no_count); $sum_extra_cols[$type]{0} = '0'; } @@ -597,6 +597,10 @@ class timesheet_bo extends Api\Storage if (isset($new[$name]) && $new[$name] != $value) $changed[] = $name; } } + if (!$this->data['ts_created']) + { + $this->data['ts_created'] = time(); + } if (isset($old) && !$changed) { return false; diff --git a/timesheet/inc/class.timesheet_egw_record.inc.php b/timesheet/inc/class.timesheet_egw_record.inc.php index e27a5528c0..cb786b26a2 100644 --- a/timesheet/inc/class.timesheet_egw_record.inc.php +++ b/timesheet/inc/class.timesheet_egw_record.inc.php @@ -27,7 +27,7 @@ class timesheet_egw_record implements importexport_iface_egw_record // Used in conversions static $types = array( 'select-account' => array('ts_owner','ts_modifier'), - 'date-time' => array('ts_start', 'ts_modified'), + 'date-time' => array('ts_start', 'ts_created', 'ts_modified'), 'select-cat' => array('cat_id'), 'links' => array('pl_id'), 'select' => array('ts_status'), diff --git a/timesheet/inc/class.timesheet_merge.inc.php b/timesheet/inc/class.timesheet_merge.inc.php index cd99a939a5..a5799a38ba 100644 --- a/timesheet/inc/class.timesheet_merge.inc.php +++ b/timesheet/inc/class.timesheet_merge.inc.php @@ -57,10 +57,7 @@ class timesheet_merge extends Api\Storage\Merge $this->parse_html_styles = Api\Storage\Customfields::use_html('timesheet'); $this->bo = new timesheet_bo(); - $this->date_fields += array( - 'ts_start', - 'ts_modified', - ); + $this->date_fields += timesheet_egw_record::$types['date-time']; } /** @@ -168,7 +165,11 @@ class timesheet_merge extends Api\Storage\Merge echo '

'.lang('Timesheet fields:')."

"; $n = 0; - $fields = array('ts_id' => lang('Timesheet ID')) + $this->bo->field2label + array('ts_total' => lang('total')); + $fields = array('ts_id' => lang('Timesheet ID')) + $this->bo->field2label + array( + 'ts_total' => lang('total'), + 'ts_created' => lang('Created'), + 'ts_modified' => lang('Modified'), + ); foreach($fields as $name => $label) { if (in_array($name,array('pl_id','customfields'))) continue; // dont show them diff --git a/timesheet/inc/class.timesheet_wizard_export_csv.inc.php b/timesheet/inc/class.timesheet_wizard_export_csv.inc.php index b17dd9a7ec..9f078334aa 100644 --- a/timesheet/inc/class.timesheet_wizard_export_csv.inc.php +++ b/timesheet/inc/class.timesheet_wizard_export_csv.inc.php @@ -19,7 +19,10 @@ class timesheet_wizard_export_csv extends importexport_wizard_basic_export_csv // Field mapping $bo = new timesheet_bo(); - $this->export_fields = array('ts_id' => 'Timesheet ID') + $bo->field2label + array('ts_modified'=> 'Modified'); + $this->export_fields = array('ts_id' => 'Timesheet ID') + $bo->field2label + array( + 'ts_created' => 'Created', + 'ts_modified'=> 'Modified' + ); // Custom fields unset($this->export_fields['customfields']); diff --git a/timesheet/setup/setup.inc.php b/timesheet/setup/setup.inc.php index 8f2270c1eb..f8cc31e7de 100644 --- a/timesheet/setup/setup.inc.php +++ b/timesheet/setup/setup.inc.php @@ -17,7 +17,7 @@ if (!defined('TIMESHEET_APP')) } $setup_info[TIMESHEET_APP]['name'] = TIMESHEET_APP; -$setup_info[TIMESHEET_APP]['version'] = '16.1'; +$setup_info[TIMESHEET_APP]['version'] = '17.1'; $setup_info[TIMESHEET_APP]['app_order'] = 5; $setup_info[TIMESHEET_APP]['tables'] = array('egw_timesheet','egw_timesheet_extra'); $setup_info[TIMESHEET_APP]['enable'] = 1; diff --git a/timesheet/setup/tables_current.inc.php b/timesheet/setup/tables_current.inc.php index bbba2c3aeb..9e6c19b3de 100644 --- a/timesheet/setup/tables_current.inc.php +++ b/timesheet/setup/tables_current.inc.php @@ -24,6 +24,7 @@ $phpgw_baseline = array( 'ts_unitprice' => array('type' => 'float','precision' => '4','comment' => 'unitprice'), 'cat_id' => array('type' => 'int','meta' => 'category','precision' => '4','default' => '0','comment' => 'category'), 'ts_owner' => array('type' => 'int','meta' => 'user','precision' => '4','nullable' => False,'comment' => 'owner of the timesheet'), + 'ts_created' => array('type' => 'int','meta' => 'timestamp','precision' => '8','nullable' => False,'comment' => 'Creation date of the timesheet'), 'ts_modified' => array('type' => 'int','meta' => 'timestamp','precision' => '8','nullable' => False,'comment' => 'date modified ot the timesheet'), 'ts_modifier' => array('type' => 'int','meta' => 'user','precision' => '4','nullable' => False,'comment' => 'account id of the last modifier'), 'pl_id' => array('type' => 'int','precision' => '4','default' => '0','comment' => 'id of the linked project'), diff --git a/timesheet/setup/tables_update.inc.php b/timesheet/setup/tables_update.inc.php index 17577ad90f..c12ddc0ba0 100644 --- a/timesheet/setup/tables_update.inc.php +++ b/timesheet/setup/tables_update.inc.php @@ -131,3 +131,17 @@ function timesheet_upgrade14_1() { return $GLOBALS['setup_info']['timesheet']['currentver'] = '16.1'; } + +function timesheet_upgrade16_1() +{ + $GLOBALS['egw_setup']->oProc->AddColumn('egw_timesheet','ts_created',array( + 'type' => 'int', + 'meta' => 'timestamp', + 'precision' => '8', + 'nullable' => False + )); + // Initialize to start + $GLOBALS['egw']->db->query('UPDATE egw_timesheet set ts_created = ts_start'); + + return $GLOBALS['setup_info']['timesheet']['currentver'] = '17.1'; +} \ No newline at end of file diff --git a/timesheet/templates/default/edit.xet b/timesheet/templates/default/edit.xet index 9279474b2c..a568176972 100644 --- a/timesheet/templates/default/edit.xet +++ b/timesheet/templates/default/edit.xet @@ -134,10 +134,12 @@ - - - - + + + + + + @@ -146,11 +148,12 @@ - - - - - + + + + + + diff --git a/timesheet/templates/default/index.xet b/timesheet/templates/default/index.xet index 638b361d4b..d36c864478 100644 --- a/timesheet/templates/default/index.xet +++ b/timesheet/templates/default/index.xet @@ -24,6 +24,7 @@ + @@ -65,6 +66,7 @@ + @@ -86,6 +88,7 @@ + diff --git a/timesheet/templates/mobile/edit.xet b/timesheet/templates/mobile/edit.xet index 3e7c88621d..527709786c 100644 --- a/timesheet/templates/mobile/edit.xet +++ b/timesheet/templates/mobile/edit.xet @@ -91,6 +91,10 @@ + + + + diff --git a/timesheet/templates/mobile/view.xet b/timesheet/templates/mobile/view.xet index 38007dc00b..29b519d522 100644 --- a/timesheet/templates/mobile/view.xet +++ b/timesheet/templates/mobile/view.xet @@ -73,6 +73,10 @@ + + + +