forked from tjschuck/Harvest4Clients
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
167 lines (153 loc) · 6.24 KB
/
index.php
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
<?php
session_start();
require_once 'inc/settings.inc.php';
require_once 'inc/functions.inc.php';
require_once 'inc/login.inc.php';
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title><?php echo __('timetracking') ?></title>
<link type="text/css" href="css/style.css" rel="stylesheet"/>
<link type="text/css" href="css/ui-lightness/jquery-ui-1.8.16.custom.css" rel="stylesheet"/>
<script type="text/javascript" src="js/jquery-1.6.2.min.js"></script>
<script type="text/javascript" src="js/jquery-ui-1.8.16.custom.min.js"></script>
<script type="text/javascript" src="js/datepickers.js"></script>
</head>
<body>
<div id="container">
<?php
$startdate = isset($_POST['startdate']) ? $_POST['startdate'] : firstOfMonth();
$enddate = isset($_POST['enddate']) ? $_POST['enddate'] : lastOfMonth();
?>
<?php include 'inc/menu.inc.php';?>
<a href="http://www.kenters.com" id="logo"><img src="http://www.kenters.com/images/logo.png" alt="Jeroen Kenters Web Development" width="147" height="50" /></a>
<h1><?php echo __('timetracking'); ?></h1>
<form method="post" action="">
<input type="hidden" id="startfield" name="startdate" value="<?php echo htmlentities($startdate); ?>">
<input type="hidden" id="endfield" name="enddate" value="<?php echo htmlentities($enddate); ?>">
<div class="datepicker">
<strong><?php echo __('timetracking.startdate'); ?>:</strong>
<div id="startdate"> </div>
</div>
<div class="datepicker">
<strong><?php echo __('timetracking.enddate'); ?>:</strong>
<div id="enddate"> </div>
</div>
<div class="datepicker">
<strong><?php echo __('timetracking.showproject'); ?>:</strong><br />
<select name="project">
<option value=""><?php echo __('timetracking.showproject.all'); ?></option>
<?php
$projects = getData($domain.'projects?client='.$clients[$user]['client']);
$projects = simplexml_load_string($projects);
$myProjects = array();
foreach ($projects as $project)
{
if (is_array($clients[$user]['projects']) && !in_array((int)$project->{'id'}, $clients[$user]['projects']))
continue;
$myProjects[(int)$project->{'id'}] = (string)$project->{'name'};
}
unset($projects, $project);
foreach($myProjects as $projectId => $projectName)
{
echo '<option value="'.$projectId.'"'.(isset($_POST['project']) && $_POST['project'] == $projectId ? ' selected="selected"' : '').'>'.htmlentities($projectName).'</option>';
}
?>
</select><br />
<input type="submit" value="<?php echo __('submit'); ?>">
<p><strong><?php echo __('timetracking.mydetails'); ?>:</strong></p>
<p>
<?php
$clientData = getData($domain.'clients/'.$clients[$user]['client']);
$clientData = simplexml_load_string($clientData);
echo $clientData->name . '<br />' .nl2br($clientData->details);
?>
</p>
</div>
<br class="clear"/>
</form>
<hr />
<h1><?php echo __('timetracking.billable'); ?></h1>
<table>
<tr>
<th><?php echo __('timetracking.date'); ?></th>
<th><?php echo __('timetracking.project'); ?></th>
<th><?php echo __('timetracking.hours'); ?></th>
<th><?php echo __('timetracking.billed'); ?></th>
<th><?php echo __('timetracking.notes'); ?></th>
</tr>
<?php
$hoursRounded = 0;
//get billable time per project
foreach($myProjects as $projectId => $projectName)
{
$data = getData($domain.'projects/' . $projectId . '/entries?from=' . $startdate . '&to=' . $enddate . '&billable=yes');
$data = simplexml_load_string($data);
foreach ($data as $entry)
{
if(isset($_POST['project']) && !empty($_POST['project']) && $_POST['project'] != (int)$entry->{'project-id'})
{
continue;
}
$hoursRounded += ceil((float)$entry->{'hours'} * 60 / 15) * 0.25;
echo '<tr>
<td>' . $entry->{'spent-at'} . '</td>
<td>' . $myProjects[(int)$entry->{'project-id'}] . '</td>
<td class="hours">' . number_format(round((float)$entry->{'hours'} * 60 / 15) * 0.25, 2) . '</td>
<td>' . ($entry->{'is-billed'} == 'true' ? __('yes') : __('no')) . '</td>
<td>' . $entry->{'notes'} . '</td>
</tr>';
}
}
echo '<tr>
<td> </td>
<td> </td>
<td class="hours">' . number_format($hoursRounded,2) . '</td>
<td> </td>
<td> </td>
</tr>';
?>
</table>
<h1><?php echo __('timetracking.unbillable'); ?></h1>
<table>
<tr>
<th><?php echo __('timetracking.date'); ?></th>
<th><?php echo __('timetracking.project'); ?></th>
<th><?php echo __('timetracking.hours'); ?></th>
<th><?php echo __('timetracking.notes'); ?></th>
</tr>
<?php
$hoursRounded = 0;
//get unbillable time per project
foreach($myProjects as $projectId => $projectName)
{
if(isset($_POST['project']) && !empty($_POST['project']) && $_POST['project'] != $projectId)
{
continue;
}
$data = getData($domain.'projects/' . $projectId . '/entries?from=' . $startdate . '&to=' . $enddate . '&billable=no');
$data = simplexml_load_string($data);
foreach ($data as $entry)
{
$hoursRounded += ceil((float)$entry->{'hours'} * 60 / 15) * 0.25;
echo '<tr>
<td>' . $entry->{'spent-at'} . '</td>
<td>' . $myProjects[(int)$entry->{'project-id'}] . '</td>
<td class="hours">' . number_format(ceil( (float)$entry->{'hours'} * 60 / 15) * 0.25, 2) . '</td>
<td>' . $entry->{'notes'} . '</td>
</tr>';
}
}
echo '<tr>
<td> </td>
<td> </td>
<td class="hours">' . number_format($hoursRounded, 2) . '</td>
<td> </td>
</tr>';
?>
</table>
</div>
</body>
</html>