diff --git a/timesheet/inc/class.timesheet_ui.inc.php b/timesheet/inc/class.timesheet_ui.inc.php index 7b0f9cc0f5..edea7999ea 100644 --- a/timesheet/inc/class.timesheet_ui.inc.php +++ b/timesheet/inc/class.timesheet_ui.inc.php @@ -88,6 +88,10 @@ class timesheet_ui extends timesheet_bo 'ts_project' => $_REQUEST['ts_project'], 'ts_title_blur' => $_REQUEST['ts_project'], ); + if(!is_numeric($_REQUEST['ts_project'])) + { + $this->data['pm_id'] = $this->find_pm_id($_REQUEST['ts_project']); + } } $matches = null; $referer = preg_match('/menuaction=([^&]+)/',$_SERVER['HTTP_REFERER'],$matches) ? $matches[1] : @@ -442,6 +446,10 @@ class timesheet_ui extends timesheet_bo { $content['ts_viewtype'] = $readonlys['tabs']['notes'] = true; $content['ts_description_short'] = $content['ts_description']; + if(!$content['pm_id'] && $this->pm_integration != 'full' && $content['ts_project']) + { + $etpl->setElementAttribute('pm_id','blur',$content['ts_project']); + } } if (!$this->customfields) $readonlys['tabs']['customfields'] = true; // suppress tab if there are not customfields if (!$this->data['ts_id']) $readonlys['tabs']['history'] = true; //suppress history for the first loading without ID @@ -1243,4 +1251,26 @@ class timesheet_ui extends timesheet_bo $etpl = new Etemplate('timesheet.editstatus'); $etpl->exec('timesheet.timesheet_ui.editstatus',$content,$sel_options,array(),$preserv); } + + /** + * Try to find a PM ID from project title + * + * @param string $project + */ + protected function find_pm_id($project) + { + list($pm_number, $pm_title) = explode(': ', $project, 2); + if(!$pm_number || !$pm_title) + { + return false; + } + + $pm = new projectmanager_bo(); + $pm_ids = $pm->search(array('pm_number' => $pm_number, 'pm_title' => $pm_title)); + if($pm_ids && count($pm_ids) >= 1) + { + return $pm_ids[0]['pm_id']; + } + return false; + } }