1 | <?php |
---|
2 | /** |
---|
3 | * TimeSheet - Projectmanager datasource |
---|
4 | * |
---|
5 | * @link http://www.egroupware.org |
---|
6 | * @author Ralf Becker <RalfBecker-AT-outdoor-training.de> |
---|
7 | * @package timesheet |
---|
8 | * @copyright (c) 2005 by Ralf Becker <RalfBecker-AT-outdoor-training.de> |
---|
9 | * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License |
---|
10 | * @version $Id: class.datasource_timesheet.inc.php 22356 2006-08-26 16:32:29Z ralfbecker $ |
---|
11 | */ |
---|
12 | |
---|
13 | include_once(PHPGW_INCLUDE_ROOT.'/projectmanager/inc/class.datasource.inc.php'); |
---|
14 | include_once(PHPGW_INCLUDE_ROOT.'/timesheet/inc/class.botimesheet.inc.php'); |
---|
15 | |
---|
16 | /** |
---|
17 | * Projectmanager DataSource for the TimeSheet |
---|
18 | */ |
---|
19 | class datasource_timesheet extends datasource |
---|
20 | { |
---|
21 | /** |
---|
22 | * Constructor |
---|
23 | */ |
---|
24 | function datasource_timesheet() |
---|
25 | { |
---|
26 | $this->datasource(TIMESHEET_APP); |
---|
27 | |
---|
28 | $this->valid = PM_REAL_START|PM_REAL_END|PM_USED_TIME|PM_USED_BUDGET|PM_USED_QUANTITY| |
---|
29 | PM_PRICELIST_ID|PM_UNITPRICE|PM_RESOURCES|PM_DETAILS|PM_COMPLETION; |
---|
30 | } |
---|
31 | |
---|
32 | /** |
---|
33 | * get an entry from the underlaying app (if not given) and convert it into a datasource array |
---|
34 | * |
---|
35 | * @param mixed $data_id id as used in the link-class for that app, or complete entry as array |
---|
36 | * @return array/boolean array with the data supported by that source or false on error (eg. not found, not availible) |
---|
37 | */ |
---|
38 | function get($data_id) |
---|
39 | { |
---|
40 | // we use $GLOBALS['bocal'] as an already running instance is availible there |
---|
41 | if (!is_object($GLOBALS['botimesheet'])) |
---|
42 | { |
---|
43 | $GLOBALS['botimesheet'] =& new botimesheet(); |
---|
44 | } |
---|
45 | if (!is_array($data_id)) |
---|
46 | { |
---|
47 | if (!(int) $data_id || !($data = $GLOBALS['botimesheet']->read((int) $data_id))) |
---|
48 | { |
---|
49 | return false; |
---|
50 | } |
---|
51 | } |
---|
52 | else |
---|
53 | { |
---|
54 | $data =& $data_id; |
---|
55 | } |
---|
56 | $ds = array( |
---|
57 | 'pe_title' => $GLOBALS['botimesheet']->link_title($data), |
---|
58 | 'pe_real_start' => $data['ts_start'], |
---|
59 | 'pe_resources' => array($data['ts_owner']), |
---|
60 | 'pe_details' => $data['ts_description'] ? nl2br($data['ts_description']) : '', |
---|
61 | 'pl_id' => $data['pl_id'], |
---|
62 | 'pe_unitprice' => $data['ts_unitprice'], |
---|
63 | 'pe_used_quantity' => $data['ts_quantity'], |
---|
64 | 'pe_used_budget' => $data['ts_quantity'] * $data['ts_unitprice'], |
---|
65 | 'pe_completion' => 100, |
---|
66 | ); |
---|
67 | if ($data['ts_duration']) |
---|
68 | { |
---|
69 | $ds['pe_real_end'] = $data['ts_start'] + 60*$data['ts_duration']; |
---|
70 | $ds['pe_used_time'] = $data['ts_duration']; |
---|
71 | } |
---|
72 | if ($this->debug) |
---|
73 | { |
---|
74 | echo "datasource_timesheet($data_id) data="; _debug_array($data); |
---|
75 | echo "datasource="; _debug_array($ds); |
---|
76 | } |
---|
77 | return $ds; |
---|
78 | } |
---|
79 | |
---|
80 | /** |
---|
81 | * Copy method (usally copies a projectelement) returns only false to prevent copying |
---|
82 | * |
---|
83 | * @param array $element source project element representing an InfoLog entry, $element['pe_app_id'] = info_id |
---|
84 | * @param int $target target project id |
---|
85 | * @param array $target_data=null data of target-project, atm not used by the infolog datasource |
---|
86 | * @return array/boolean array(info_id,link_id) on success, false otherwise |
---|
87 | */ |
---|
88 | function copy($element,$target,$extra=null) |
---|
89 | { |
---|
90 | return false; |
---|
91 | } |
---|
92 | } |
---|