From a65ad1dc154e3e35e0947c62d5d38a82e1757f3e Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Tue, 19 Jun 2012 17:07:15 +0000 Subject: [PATCH] * ProjectManager: allow datasources (eg. InfoLog) to set element category, update existing categories in elements to overwritten categories --- calendar/inc/class.calendar_datasource.inc.php | 11 ++++++++++- infolog/inc/class.infolog_datasource.inc.php | 5 +++-- timesheet/inc/class.timesheet_datasource.inc.php | 3 ++- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/calendar/inc/class.calendar_datasource.inc.php b/calendar/inc/class.calendar_datasource.inc.php index 9dc0352668..6a3c6c077c 100644 --- a/calendar/inc/class.calendar_datasource.inc.php +++ b/calendar/inc/class.calendar_datasource.inc.php @@ -24,7 +24,7 @@ class calendar_datasource extends datasource { $this->datasource('calendar'); - $this->valid = PM_PLANNED_START|PM_PLANNED_END|PM_PLANNED_TIME|PM_RESOURCES; + $this->valid = PM_PLANNED_START|PM_PLANNED_END|PM_PLANNED_TIME|PM_RESOURCES|PM_CAT_ID; } /** @@ -60,6 +60,15 @@ class calendar_datasource extends datasource 'pe_resources' => array(), 'pe_details' => $data['description'] ? nl2br($data['description']) : '', ); + // return first global category, as PM only supports one + foreach($data['category'] ? explode(',', $data['category']) : array() as $cat_id) + { + if (categories::is_global($cat_id)) + { + $ds['cat_id'] = $cat_id; + break; + } + } // calculation of the time $ds['pe_planned_time'] = (int) (($ds['pe_planned_end'] - $ds['pe_planned_start'])/60); // time is in minutes diff --git a/infolog/inc/class.infolog_datasource.inc.php b/infolog/inc/class.infolog_datasource.inc.php index b9d66cf258..5dc47fc99f 100644 --- a/infolog/inc/class.infolog_datasource.inc.php +++ b/infolog/inc/class.infolog_datasource.inc.php @@ -39,7 +39,7 @@ class infolog_datasource extends datasource { parent::__construct('infolog'); - $this->valid = PM_COMPLETION|PM_PLANNED_START|PM_PLANNED_END|PM_REAL_END|PM_PLANNED_TIME|PM_REPLANNED_TIME|PM_USED_TIME|PM_RESOURCES; + $this->valid = PM_COMPLETION|PM_PLANNED_START|PM_PLANNED_END|PM_REAL_END|PM_PLANNED_TIME|PM_REPLANNED_TIME|PM_USED_TIME|PM_RESOURCES|PM_CAT_ID; // we use $GLOBALS['infolog_bo'] as an already running instance might be availible there if (!is_object($GLOBALS['infolog_bo'])) @@ -84,6 +84,7 @@ class infolog_datasource extends datasource 'pe_planned_budget' => $data['info_planned_time'] / 60 * $data['info_price'], 'pe_used_quantity' => $data['info_used_time'] / 60, 'pe_used_budget' => $data['info_used_time'] / 60 * $data['info_price'], + 'cat_id' => $data['info_cat'], ); } @@ -146,7 +147,7 @@ class infolog_datasource extends datasource } return $ret; } - + /** * Callback called after copying of all datasource, used to: * - fix parent id's diff --git a/timesheet/inc/class.timesheet_datasource.inc.php b/timesheet/inc/class.timesheet_datasource.inc.php index 211e4c9a6c..afecf82a52 100644 --- a/timesheet/inc/class.timesheet_datasource.inc.php +++ b/timesheet/inc/class.timesheet_datasource.inc.php @@ -25,7 +25,7 @@ class timesheet_datasource extends datasource parent::__construct(TIMESHEET_APP); $this->valid = PM_REAL_START|PM_REAL_END|PM_USED_TIME|PM_USED_BUDGET|PM_USED_QUANTITY| - PM_PRICELIST_ID|PM_UNITPRICE|PM_RESOURCES|PM_DETAILS|PM_COMPLETION; + PM_PRICELIST_ID|PM_UNITPRICE|PM_RESOURCES|PM_DETAILS|PM_COMPLETION|PM_CAT_ID; } /** @@ -62,6 +62,7 @@ class timesheet_datasource extends datasource 'pe_used_quantity' => $data['ts_quantity'], 'pe_used_budget' => $data['ts_quantity'] * $data['ts_unitprice'], 'pe_completion' => 100, + 'cat_id' => $data['cat_id'], ); if ($data['ts_duration']) {