forked from joedanz/cf-project-tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreportPDF.cfm
272 lines (257 loc) · 7.42 KB
/
reportPDF.cfm
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
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
<cfsetting enablecfoutputonly="true">
<cfprocessingdirective pageencoding="utf-8">
<!---
Filename: reportsPDF.cfm
Designers: Emilie McGregor
Created: 2/3/2009 14:31:28 PM
Description: PDF for displaying reports
--->
<cfparam name="form.c" default="">
<cfparam name="form.u" default="">
<cfparam name="form.p" default="">
<cfparam name="url.f" default="">
<cfparam name="form.report" default="all">
<cfparam name="form.Invoice" default="">
<cfparam name="form.startDate" default="">
<cfparam name="form.endDate" default="">
<cfparam name="form.invoiceType" default="full">
<cfif compare(form.p,'')>
<cfset projects = application.project.get(projectID=form.p) />
<cfset project = projects />
<cfelseif form.report IS 'client'>
<cfset clients = application.client.get() />
<cfif compare(form.Invoice,'') >
<cfset projects = application.project.get(clientID=form.c) />
</cfif>
<cfelseif form.report IS 'programmer'>
<cfset users = application.user.get() />
<cfif compare(form.Invoice,'') >
<cfset projects = application.project.get(userID=form.u) />
</cfif>
<cfelseif form.report IS 'all'>
<cfset projects = application.project.get() />
</cfif>
<cfif compare(form.startDate,'') AND NOT compare(form.endDate,'')>
<cfset form.endDate = #LSDateFormat(Now(), "mm/dd/yyyy")#>
</cfif>
<cfdocument format="pdf">
<cfoutput>
<link rel="stylesheet" href="#application.settings.mapping#/css/all_styles.css" media="all" type="text/css" />
<style type="text/css">
body{ background:##fff; }
</style>
<table style="width:100%;">
<tr>
<td style="text-align:left; vertical-align:top;">
<cfif compare(application.settings.invoice_logo,'')>
<img src="#application.settings.userFilesMapping#/company/#application.settings.invoice_logo#" alt="#application.settings.company_name# Company Logo" />
<cfelse>
<h1>#application.settings.company_name#</h1>
</cfif>
<br/><br/>
</td>
<td style="text-align:right; vertical-align:top;">
<h2>Report</h2>
<cfif compare(form.startDate,'') AND compare(form.endDate,'') >
<h4>Services Rendered</h4>
<h4>#startDate# - #endDate#</h4>
</cfif>
</td>
</tr>
<tr>
<td style="text-align:left; vertical-align:top;">
<h4>#application.settings.company_name#</h4>
<br/>
</td>
<td style="text-align:right; vertical-align:top;">
Date: #LSDateFormat(Now(), "mmmm dd, yyyy")#
</td>
</tr>
<cfset timelines = application.timetrack.get(projectID=form.p,userID=form.u,clientID=form.c,startDate=form.startDate,endDate=form.endDate) />
<cfquery name="byClient" dbtype="query">
SELECT SUM(CAST(hours as DECIMAL)) as totalHours, client
FROM timelines
GROUP BY client
</cfquery>
<tr>
<td colspan="2">
<h3>Breakdown of Hours by Client</h3>
</td>
</tr>
<tr>
<td>
<cfchart format="png" showBorder = "no" chartheight=300 chartwidth=300 xaxisTitle="" yaxisTitle="Total"
dataBackgroundColor="FFFFFF" backgroundColor="FFFFFF" foregroundColor="000000">
<cfchartseries type="pie" paintStyle="light" colorlist="##660099, ##9999FF">
<cfloop index="i" from="1" to="#byClient.recordcount#" >
<cfif byClient.client[i] IS "">
<cfset label = "Miscellaneous" />
<cfelse>
<cfset label = byClient.client[i] />
</cfif>
<cfchartdata item="#label#" value="#byClient.totalHours[i]# ">
</cfloop>
</cfchartseries>
</cfchart>
</td>
<td>
<table class="clean full" id="time" style="border-top:2px solid ##000;">
<thead>
<tr>
<th>Client</th>
<th>Hours</th>
</tr>
</thead>
<tbody>
<cfloop query="byClient">
<tr>
<td>#client#</td>
<td>#totalHours#</td>
</tr>
</cfloop>
</tbody>
</table>
</td>
</tr>
<cfquery name="byProject" dbtype="query">
SELECT SUM(CAST(hours as DECIMAL)) as totalHours, name
FROM timelines
GROUP BY name
</cfquery>
<tr>
<td colspan="2">
<h3>Breakdown of Hours by Project</h3>
</td>
</tr>
<tr>
<td>
<cfchart format="png" showBorder="no" chartheight=300 chartwidth=300 xaxisTitle="" yaxisTitle="Total"
dataBackgroundColor="FFFFFF" backgroundColor="FFFFFF" foregroundColor="000000">
<cfchartseries type="pie" paintStyle="light" colorlist="##660099, ##9999FF">
<cfloop index="i" from="1" to="#byProject.recordcount#">
<cfchartdata item="#byProject.name[i]#" value="#byProject.totalHours[i]# ">
</cfloop>
</cfchartseries>
</cfchart>
</td>
<td>
<table class="clean full" id="time" style="border-top:2px solid ##000;">
<thead>
<tr>
<th>Project</th>
<th>Hours</th>
</tr>
</thead>
<tbody>
<cfloop query="byProject">
<tr>
<td>#name#</td>
<td>#totalHours#</td>
</tr>
</cfloop>
</tbody>
</table>
</td>
</tr>
<tr>
<td colspan="2">
<cfdocumentitem type="pagebreak" />
</td>
</tr>
<cfquery name="byUser" dbtype="query">
SELECT SUM(CAST(hours as DECIMAL)) as totalHours, firstName, lastName
FROM timelines
GROUP BY firstName, lastName
</cfquery>
<tr>
<td colspan="2">
<h3>Breakdown of Hours by Programmer</h3>
</td>
</tr>
<tr>
<cfif byUser.RecordCount>
<td>
<cfchart format="png" showBorder="no" chartheight=300 chartwidth=300 xaxisTitle="" yaxisTitle="Total"
dataBackgroundColor="FFFFFF" backgroundColor="FFFFFF" foregroundColor="000000">
<cfchartseries type="pie" paintStyle="light" colorlist="##660099, ##9999FF">
<cfloop index="i" from="1" to="#byUser.recordcount#" >
<cfchartdata item="#byUser.firstName[i]# #byUser.lastName[i]#" value="#byUser.totalHours[i]# ">
</cfloop>
</cfchartseries>
</cfchart>
</td>
<td>
<table class="clean full" id="time" style="border-top:2px solid ##000;">
<thead>
<tr>
<th>Programmer</th>
<th>Hours</th>
</tr>
</thead>
<tbody>
<cfloop query="byUser">
<tr>
<td>#firstName# #lastName#</td>
<td>#totalHours#</td>
</tr>
</cfloop>
</tbody>
</table>
</td>
<cfelse>
<td colspan="2">
<br/>
<div class="alert">No time tracking records found for that <cfif StructKeyExists(form,"startDay")>period<cfelse>item</cfif>.</div>
<br/>
</td>
</cfif>
</tr>
<cfquery name="byCategory" dbtype="query">
SELECT SUM(CAST(hours as DECIMAL)) as totalHours, category
FROM timelines
GROUP BY category
</cfquery>
<tr>
<td colspan="2">
<h3>Breakdown of Hours by Category of Work</h3>
</td>
</tr>
<tr>
<td>
<cfchart format="png" showBorder="no" chartheight=300 chartwidth=300 xaxisTitle="" yaxisTitle="Total"
dataBackgroundColor="FFFFFF" backgroundColor="FFFFFF" foregroundColor="000000">
<cfchartseries type="pie" paintStyle="light" colorlist="##660099, ##9999FF">
<cfloop index="i" from="1" to="#byCategory.recordcount#">
<cfif byCategory.category[i] IS "">
<cfset label = "Miscellaneous" />
<cfelse>
<cfset label = byCategory.category[i] />
</cfif>
<cfchartdata item="#label#" value="#byCategory.totalHours[i]# ">
</cfloop>
</cfchartseries>
</cfchart>
</td>
<td>
<table class="clean full" id="time" style="border-top:2px solid ##000;">
<thead>
<tr>
<th>Category</th>
<th>Hours</th>
</tr>
</thead>
<tbody>
<cfloop query="byCategory">
<tr>
<td><cfif category IS NOT "">#category#<cfelse>Miscellaneous</cfif></td>
<td>#totalHours#</td>
</tr>
</cfloop>
</tbody>
</table>
</td>
</tr>
</table>
</cfoutput>
</cfdocument>
<cfsetting enablecfoutputonly="false">