forked from joedanz/cf-project-tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinvoicePDF.cfm
153 lines (142 loc) · 4.26 KB
/
invoicePDF.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
<cfsetting enablecfoutputonly="true">
<cfprocessingdirective pageencoding="utf-8">
<!---
Filename: invoicePDF.cfm
Designers: Emilie McGregor
Created: 1/29/2009 10:30:41 AM
Description: File for generating pdfs.
--->
<cfparam name="form.c" default="">
<cfparam name="form.p" default="">
<cfparam name="url.f" default="">
<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 invoiceClient = application.client.get(clientID=projects.clientID) />
<cfelse>
<cfset clients = application.client.get() />
<cfif compare(form.Invoice,'') >
<cfset invoiceClient = application.client.get(clientID=form.c) />
<cfset projects = application.project.get(clientID=form.c) />
</cfif>
</cfif>
<cfif compare(form.Invoice,'') 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>Invoice</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>
<tr>
<td>
<table>
<tr>
<td class="b" style="width:30px;">TO:</td>
<td>#invoiceClient.name#</td>
</tr>
<tr>
<td></td>
<td>#invoiceClient.address#</td>
</tr>
<cfif invoiceClient.postal IS NOT "">
<tr>
<td></td>
<td>#invoiceClient.city#, #invoiceClient.locality# #invoiceClient.country# #invoiceClient.postal#</td>
</tr>
</cfif>
<tr>
<td></td>
<td>#invoiceClient.phone#</td>
</tr>
</table>
<br/>
</td>
<td></td>
</tr>
<tr>
<td colspan="2">
<h4>Summary</h4>
<br/>
<table class="clean full" id="time" style="border-top:2px solid ##000;">
<thead>
<tr>
<th>Project</th>
<th style="width:20%;">Hours</th>
<th style="width:20%;">Total</th>
</tr>
</thead>
<tbody>
<cfset allProjHours = 0>
<cfset allProjAmount = 0>
<cfloop query="projects">
<cfset timelines = application.timetrack.get(projectid=projectID,clientID=form.c,userID=form.u,startDate=form.startDate,endDate=form.endDate) />
<cfquery name="hours" dbtype="query">
SELECT SUM(CAST(hours as DECIMAL)) as totalHours
FROM timelines
</cfquery>
<cfset totalAmount = 0>
<cfloop query="timelines">
<cfif compare(category,'')><cfset totalAmount = totalAmount + (rate * hours)></cfif>
</cfloop>
<tr>
<td>#name#</td>
<td><cfif compare(hours.totalHours,'')>#hours.totalHours#<cfelse>0.0</cfif></td>
<td>#LSCurrencyFormat(totalAmount)#</td>
</tr>
<cfset allProjHours = allProjHours + hours.totalHours>
<cfset allProjAmount = allProjAmount + totalAmount>
</cfloop>
</tbody>
<tfoot>
<tr class="last">
<td class="tar b">TOTALS:</td>
<td class="b tar"><span id="totalhours">#NumberFormat(allProjHours,"0.00")#</span></td>
<td class="b tar"><span id="totalamount">#LSCurrencyFormat(allProjAmount)#</span></td>
</tr>
</tfoot>
</table>
</td>
</tr>
<tr>
<td colspan="2">
<cfloop query="projects">
<cfinclude template="invoice_detail.cfm">
</cfloop>
</td>
</tr>
</table>
</cfoutput>
</cfdocument>
<cfsetting enablecfoutputonly="false">