-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
217 lines (163 loc) · 7.53 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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
<?php
require_once( "./lib/MyHarvest.php");
$api = new MyHarvest();
//query all clients
$clientResult = $api->getClients();
if( !$clientResult->isSuccess() ) {
//print clients
//foreach( $clientResult->data as $client ) {
//echo "Client: " . $client->name . "<br/>";
//}
echo "something went wrong :( <br/>";
die();
}
?>
<!DOCTYPE html>
<!--[if lt IE 7]> <html lang="en" class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html lang="en" class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html lang="en" class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html lang="en" class="no-js"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title></title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" href="css/bootstrap.min.css">
<style>
body {
padding-top: 50px;
padding-bottom: 20px;
}
</style>
<link rel="stylesheet" href="css/bootstrap-theme.min.css">
<link rel="stylesheet" href="css/main.css">
<script src="js/vendor/modernizr-2.6.2-respond-1.1.0.min.js"></script>
</head>
<body>
<!--[if lt IE 7]>
<p class="chromeframe">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> or <a href="http://www.google.com/chromeframe/?redirect=true">activate Google Chrome Frame</a> to improve your experience.</p>
<![endif]-->
<!-- Main jumbotron for a primary marketing message or call to action -->
<div class="jumbotron">
<div class="container">
<h1>Hello, world!</h1>
<p>Now lets see what you tracked there =)!</p>
</div>
</div>
<div class="container">
<div class="row">
<div class="span8">
<form action="<?=$_SERVER['PHP_SELF']?>" method="post" class="form-horizontal" id="billingform" accept-charset="utf-8">
<div class="control-group">
<label for="country" class="control-label">
Country
</label>
<div class="controls">
<select name="client_id" id="country">
<option value=""></option>
<?php
foreach( $clientResult->data as $client ) {
echo '<option value="' . $client->id. '">'. $client->name . '</option>';
}
?>
</select>
</div>
</div>
<div class="form-actions">
<button type="submit" name="run-report" class="btn btn-large btn-primary">Get report! Go!</button>
</div>
</form>
</div> <!-- .span8 -->
</div>
</div>
<hr>
<?php if( isset($_POST["run-report"]) && isset($_POST["client_id"]) && $_POST['client_id'] != "" ) {
//grab clients
$clientProjects = $api->getClientProjects( (int)$_POST['client_id'] );
$projectsTimes = array();
if( $clientProjects->isSuccess() ) {
//aktueller Monat
$timerange = new Harvest_Range( date('Ym01'), date('Ymd') );
foreach( $clientProjects->data as $project ) {
$tmpProjectData = array();
$tmpProjectData["name"] = $project->name;
$tmpProjectData["id"] = $project->id;
$tmpProjectData["tracks"] = array();
$entries = $api->getProjectEntries( $project->id, $timerange );
// echo $entries->code;
//var_dump($entries);
//break;
if( $entries->isSuccess() ) {
foreach( $entries->data as $projectTimetrack ) {
$tmpProjectData["tracks"][] = $projectTimetrack;
}
}else{
echo "failure";
}
$projectsTimes[] = (object)$tmpProjectData;
//break;
}
}
//display data
?>
<div class="container">
<div class="row">
<div class="span12">
<div class="menu">
<div class="accordion">
<div class="accordion-group">
<?php
$counter = 0;
foreach( $projectsTimes as $project ) {
$counter++;
?>
<div class="accordion-heading project clearfix ">
<img src="http://placehold.it/100x30" alt="project flag" style="float:left; margin: 3px 10px 0 3px; text-align:center;"/>
<a class="accordion-toggle" data-toggle="collapse" href="#project_<?=$counter?>"><?=$project->name?></a>
</div>
<div id="project_<?=$counter?>" class="accordion-body collapse">
<div class="accordion-inner">
<table class="table table-striped table-condensed">
<thead>
<tr>
<th>Date</th>
<th>Time spent</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<?php foreach( $project->tracks as $track ) { ?>
<tr>
<td><?=$track->get("spent-at")?></td>
<td><?=$track->get("hours")?></td>
<td><?=$track->get("notes")?></td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
</div>
<?php } ?>
</div>
</div>
</div>
</div>
</div>
</div>
<?php } ?>
<footer>
<p>© Company 2013</p>
</footer>
</div> <!-- /container --> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="js/vendor/jquery-1.10.1.min.js"><\/script>')</script>
<script src="js/vendor/bootstrap.min.js"></script>
<script src="js/main.js"></script>
<script>
var _gaq=[['_setAccount','UA-XXXXX-X'],['_trackPageview']];
(function(d,t){var g=d.createElement(t),s=d.getElementsByTagName(t)[0];
g.src='//www.google-analytics.com/ga.js';
s.parentNode.insertBefore(g,s)}(document,'script'));
</script>
</body>
</html>