This repository was archived by the owner on Jan 7, 2022. It is now read-only.
Repository navigation
Expand file tree
/
Copy pathStreamtimeTask.php
More file actions
106 lines (96 loc) · 2.77 KB
/
Copy pathStreamtimeTask.php
File metadata and controls
106 lines (96 loc) · 2.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
<?php
App::uses('StreamtimeAppModel', 'Streamtime.Model');
class StreamtimeTask extends StreamtimeAppModel {
public $name = 'Task';
public $displayField = 'Notes';
public $belongsTo = array(
'StreamtimeJob' => array(
'className' => 'Streamtime.StreamtimeJob',
'foreignKey' => 'JobNumber',
// 'conditions' => array(
// 'StreamtimeJob.UID' => 'StreamtimeTask.JobNumber'
// )
)
);
public $_schema = array(
'UID' => array(
'type' => 'integer',
'null' => false
),
'Material' => array(
'type' => 'text',
'null' => false
),
'Notes' => array(
'type' => 'text',
'null' => false
),
'DateStart' => array(
'type' => 'date',
'null' => false
),
'TimeStart' => array(
'type' => 'time',
'null' => false
),
'DateDue' => array(
'type' => 'date',
'null' => false
),
'TimeDue' => array(
'type' => 'time',
'null' => false
),
'DateActual' => array(
'type' => 'date',
'null' => false
),
'EstimatedTime' => array(
'type' => 'float',
'null' => false
),
'UsedTime' => array(
'type' => 'float',
'null' => false
),
'Billable' => array(
'type' => 'boolean',
'null' => false
),
'JobNumber' => array(
'type' => 'integer',
'null' => false
),
'JobStatus' => array(
'type' => 'text',
'null' => false
),
);
public function afterFind($results, $primary = false) {
if ($primary) {
foreach ($results as &$result) {
if (isset($result[$this->alias]['DateStart']) && isset($result[$this->alias]['TimeStart'])) {
$date = DateTime::createFromFormat(
$this->getDataSource()->columns['date']['format'] . ' ' . $this->getDataSource()->columns['time']['format'],
str_replace('-', '/', $result[$this->alias]['DateStart']) . ' ' . $result[$this->alias]['TimeStart'],
new DateTimeZone('Europe/Amsterdam')
);
$date->setTimezone(new DateTimeZone('UTC'));
$result[$this->alias]['DateStart'] = $date->format($this->getDataSource()->columns['date']['format']);
$result[$this->alias]['TimeStart'] = $date->format($this->getDataSource()->columns['time']['format']);
}
if (isset($result[$this->alias]['DateDue']) && isset($result[$this->alias]['TimeDue'])) {
$date = DateTime::createFromFormat(
$this->getDataSource()->columns['date']['format'] . ' ' . $this->getDataSource()->columns['time']['format'],
str_replace('-', '/', $result[$this->alias]['DateDue']) . ' ' . $result[$this->alias]['TimeDue'],
new DateTimeZone('Europe/Amsterdam')
);
$date->setTimezone(new DateTimeZone('UTC'));
$result[$this->alias]['DateDue'] = $date->format($this->getDataSource()->columns['date']['format']);
$result[$this->alias]['TimeDue'] = $date->format($this->getDataSource()->columns['time']['format']);
}
}
}
return $results;
}
}