Skip to content

Instantly share code, notes, and snippets.

@mhenke
Last active December 29, 2015 18:09
Show Gist options
  • Save mhenke/7709306 to your computer and use it in GitHub Desktop.
Save mhenke/7709306 to your computer and use it in GitHub Desktop.
<!---
STATUS: DEVELOPMENT
CREATED: 01/14/2012 MKL
DESC: Master Global Receipt
MODIFIED: 06/29/2013 MKL Added This Comment.
--->
<!--- Contains all the calls to the CSS and JQuery files --->
<cfinclude template="../../includes/header.cfm">
<cfinclude template="../../includes/masterinclude.cfm">
<cfparam name="url.tran_id" default=0>
<cfparam name="print" default="NO">
<cfparam name="email" default="NO">
<cfparam name="transaction_id" default=0>
<cfparam name="type" default=1>
<cfparam name="main" default=1>
<cfparam name="er_id" default=0>
<cfparam name="ed_id" default=0>
<cfparam name="credit_id" default=0>
<cfparam name="debit_id" default=0>
<cfparam name="event" default="NO">
<cfif isdefined('url.tran_id') AND url.tran_id NEQ 0>
<cfset transaction_id = #url.tran_id#>
</cfif>
<cfquery datasource="#datasource#" name="output">
<CFIF type EQ 1>
SELECT T.account_code,T.transaction_ID, T.cm_id, CM.name, CASE WHEN ISNULL(T.Invoice_Number,0) = 0 THEN TD.invoice_number ELSE T.invoice_number END AS invoice_number, T.bill_date,
T.due_date, T.amount, T.amount_paid, T.balance_due, RTRIM(ISNULL(T.ref,'')) +' - ' + RTRIM(ISNULL(T2.ref,'')) AS ref, ISNULL(T.paid_date,TL.pay_date) AS paid_date,
CASE WHEN A1.Address_ID IS NOT NULL THEN rtrim(A1.Address1) ELSE '' END as Address1,
CASE WHEN A1.Address_ID IS NOT NULL THEN rtrim(A1.Address2) ELSE '' END as Address2,
CASE WHEN A1.Address_ID IS NOT NULL THEN rtrim(A1.City)+', '+rtrim(A1.State)+' '+rtrim(A1.Zip) ELSE '' END as CSZ,
CASE WHEN A1.Address_ID IS NOT NULL THEN A1.Country ELSE '' END as Country,
N.Prefix, N.First, N.Last, N.Suffix,
E.Email,
TL.pay_date, Tl.amount as log_amount,
TD.description as tran_desc, TD.Trandetail_id, TD.quantity, TD.unit_price, TD.amount AS total_amount,
case when tl.item_number like '%tax%' THEN 1 ELSE 0 END as tax_item,
(select sum(amount) FROM Transaction_log WHERE tran_id_cr = #transaction_id# AND item_number like '%tax%') as tax_total
FROM Transactions T
LEFT JOIN Transaction_Log TL ON (T.transaction_id = TL.tran_id_cr)
LEFT JOIN Transaction_Detail TD ON (TD.trandetail_id = TL.trandetail_id)
LEFT OUTER JOIN transactions T2 ON (TD.transaction_id = T2.transaction_id)
LEFT JOIN IndividualCorporateLink ICL ON (ICL.cm_id = T.cm_id AND T.IM_ID = ICL.IM_ID)
LEFT JOIN Corporate_Members CM ON (cm.cm_id = ICL.cm_id)
LEFT JOIN Individual_Members IM ON (IM.im_id = ICL.im_id)
LEFT JOIN Names N ON (N.id = ICL.im_id)
LEFT JOIN Emails E ON (E.EMAIL_ID = ICL.EMAIL_ID)
LEFT JOIN [Address] A1 ON (A1.cm_id = CM.cm_id AND A1.[Type] = 9)
<!--- LEFT JOIN (SELECT TOP 1 * FROM [Address] ) A1 ON A1.cm_id = CM.cm_id AND A1.[Type] = 9 --->
WHERE T.transaction_id = #transaction_id#
ORDER BY TD.Trandetail_ID
<CFELSE>
SELECT T.account_code,T.transaction_ID, T.cm_id, CM.name, CASE WHEN ISNULL(T.Invoice_Number,0) = 0 THEN TD.invoice_number ELSE T.invoice_number END AS invoice_number, T.bill_date,
T.due_date, T.amount, T.amount_paid, T.balance_due, T.ref, '' AS paid_date,
CASE WHEN A1.Address_ID IS NOT NULL THEN rtrim(A1.Address1) ELSE '' END as Address1,
CASE WHEN A1.Address_ID IS NOT NULL THEN rtrim(A1.Address2) ELSE '' END as Address2,
CASE WHEN A1.Address_ID IS NOT NULL THEN rtrim(A1.City)+', '+rtrim(A1.State)+' '+rtrim(A1.Zip) ELSE '' END as CSZ,
CASE WHEN A1.Address_ID IS NOT NULL THEN A1.Country ELSE '' END as Country,
N.Prefix, N.First, N.Last, N.Suffix,
E.Email,
T.invoice_date, TD.amount as log_amount,
TD.description as tran_desc, TD.Trandetail_id, TD.quantity, TD.unit_price, TD.amount AS total_amount,
case when td.item_number like '%tax%' THEN 1 ELSE 0 END as tax_item,
(select sum(amount) FROM Transaction_Detail WHERE transaction_id = #transaction_id# AND item_number like '%tax%') as tax_total
FROM Transactions T
LEFT JOIN Transaction_Detail TD ON (TD.transaction_id = T.transaction_id)
LEFT JOIN IndividualCorporateLink ICL ON (ICL.cm_id = T.cm_id AND T.IM_ID = ICL.IM_ID)
LEFT JOIN Corporate_Members CM ON (cm.cm_id = ICL.cm_id)
LEFT JOIN Individual_Members IM ON (IM.im_id = ICL.im_id)
LEFT JOIN Names N ON (N.id = ICL.im_id)
LEFT JOIN Emails E ON (E.EMAIL_ID = ICL.EMAIL_ID)
LEFT JOIN [Address] A1 ON (A1.cm_id = CM.cm_id AND A1.[Type] = 9)
<!--- LEFT JOIN (SELECT TOP 1 * FROM [Address] ) A1 ON A1.cm_id = CM.cm_id AND A1.[Type] = 9 --->
WHERE T.transaction_id = #transaction_id#
ORDER BY TD.Trandetail_ID
</CFIF>
</cfquery>
<!--- <BR>***WE ARE HERE NOW***<BR><CFABORT> --->
<CFIF PRINT EQ "NO" AND Email EQ "YES">
<CFOUTPUT QUERY="output">
<cfset from = "[email protected]">
<cfset reply = "[email protected]">
<cfset subject = "Omaha Chamber Invoice - #output.invoice_number#">
<CFMAIL server="#EmailServer#" failto="#EmailFailToAddress#" from="#from#" to="#session.member.email#" subject="#subject#">
<cfmailpart type="html">
<CFIF type EQ 1>
<CFINCLUDE template="ReceiptHTML.cfm">
<CFELSE>
<CFINCLUDE template="InvoiceHTML.cfm">
</CFIF>
</cfmailpart>
</CFMAIL>
</CFOUTPUT>
<CFIF main EQ 0>
<!--- Contains top fixed toolbar with logout
<cfinclude template="includes/toptoolbar.cfm">--->
<!--- Contains logo header and large Navigation buttons
<cfinclude template="includes/logoheader.cfm"> --->
<!--- Contains the main header toolbar with the search
<cfinclude template="includes/mainheader.cfm"> --->
<!--- Contains the Side-Navigation Menu items
<cfinclude template="includes/sidenav.cfm">--->
</CFIF>
<section id="content" class="container_12 clearfix" data-sort=true>
<div class="grid_12" style="padding-left: 10px;">
<div class="header">
<h2 class="large center-elements"><CFIF type EQ 1>Payment Receipt Has Been Emailed<CFELSE>Invoice Has Been Emailed</CFIF>:&nbsp;<cfoutput>#output.invoice_number#</cfoutput>&nbsp;&nbsp;
</h2>
</div>
<p align="Center">
<a href="Receipt.cfm?transaction_id=<CFOUTPUT>#transaction_id#</CFOUTPUT>&type=<CFOUTPUT>#type#</CFOUTPUT>&print=NO&email=NO&main=<CFOUTPUT>#main#</CFOUTPUT>" target="_self"><i class="icon-envelope"></i>&nbsp;<strong style="font-size:14pt; color:blue">Return to Receipt.</strong></a>
</p>
</div><!-- End of .grid_12 -->
</section><!-- End of #content -->
<!--- Contains the footer section --->
<cfinclude template="../../includes/footer.cfm">
<cfelseif PRINT EQ "YES" AND email EQ "NO">
<cfdocument
format="pdf"
unit="in"
marginbottom="0.75"
marginleft="0.75"
marginright="0.75"
margintop="0.75"
pageHeight="11"
pageWidth="8.5"
mimeType="text/html"
fontembed="yes"
orientation="portrait">
<cfdocumentitem type="footer">
<p align="center" style="font-size: 10px;"><cfoutput>printed: #dateformat(NOW(),'mm/dd/yyyy')#</cfoutput></p>
</cfdocumentitem>
<cfdocumentsection>
<!--- <!DOCTYPE html> --->
<html>
<head>
<title>HTML Invoice Template</title>
</head>
<body>
<!--- <div id="content"> --->
<CFIF type EQ 1>
<CFINCLUDE template="ReceiptHTML.cfm">
<CFELSE>
<CFINCLUDE template="InvoiceHTML.cfm">
</CFIF>
<!--- </div><!--end page--> --->
</body>
</html>
<!--- BR>***WE ARE HERE NOW***<BR><CFABORT> --->
</cfdocumentsection>
</cfdocument>
<cfelse>
<!--- Main Content Section Starts Here --->
<body>
<CFIF main EQ 0>
<!--- Contains top fixed toolbar with logout
<cfinclude template="includes/toptoolbar.cfm"> --->
<!--- Contains logo header and large Navigation buttons
<cfinclude template="includes/logoheader.cfm"> --->
<!--- Contains the main header toolbar with the search
<cfinclude template="includes/mainheader.cfm"> --->
<!--- Contains the Side-Navigation Menu items
<cfinclude template="includes/sidenav.cfm"> --->
</CFIF>
<section <CFIF main EQ 0>id="content" </CFIF>class="container_12 clearfix" data-sort=true>
<div class="grid_12" style="margin-left: 10px;">
<cfif isdefined("session.member.message") and session.member.message NEQ "">
<table cellpadding="0" cellspacing="0">
<tr><td><br style="line-height:1.5"></td></tr>
<tr><td align="center" colspan="100%" style="font-family:Arial, Helvetica, sans-serif; font-size:14px; color:#CC0033; text-align:center"><cfoutput>#session.member.message#</cfoutput></td></tr>
</table>
<cflock timeout=20 scope="Session" type="Exclusive">
<cfset StructDelete(Session, "member.message")>
<cfset session.member.message = ''>
</cflock>
</cfif>
<p align="Right">
<!--- <a href="PrintTickets.cfm?" target="_blank"><i class="icon-print"></i>&nbsp;<strong style="font-size:10pt">Print Tickets</strong></a> --->
<CFSET EER_ID = ENCRYPT(url.er_id,EncryptKey,'AES','hex')>
<CFSET EED_ID = ENCRYPT(url.ed_id,EncryptKey,'AES','hex')>
<cfoutput><a target="_blank" href="printtickets.cfm?er_id=#EER_ID#&ed_id=#EED_ID#"><i class="icon-print"></i><strong style="font-size:10pt">Print Tickets</strong></a></cfoutput>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<!--- <CFIF event EQ "YES">
<a href="EventRegistrationPost2.cfm?er_id=<CFOUTPUT>#er_id#</CFOUTPUT>&ed_id=<CFOUTPUT>#ed_id#</CFOUTPUT>&credit_id=<CFOUTPUT>#credit_id#</CFOUTPUT>&debit_id=<CFOUTPUT>#debit_id#</CFOUTPUT>" target="_self"><i class="icon-print"></i>&nbsp;<strong style="font-size:10pt">Assign Participants</strong></a>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</CFIF> --->
<a href="Receipt.cfm?transaction_id=<CFOUTPUT>#transaction_id#</CFOUTPUT>&type=<CFOUTPUT>#type#</CFOUTPUT>&print=YES&email=NO&main=<CFOUTPUT>#main#</CFOUTPUT>" target="_blank"><i class="icon-print"></i>&nbsp;<strong style="font-size:10pt">Print <CFIF type EQ 1>Receipt<CFELSE>Invoice</CFIF></strong></a>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<a href="Receipt.cfm?transaction_id=<CFOUTPUT>#transaction_id#</CFOUTPUT>&type=<CFOUTPUT>#type#</CFOUTPUT>&print=NO&email=YES&main=<CFOUTPUT>#main#</CFOUTPUT>" target="_self"><i class="icon-envelope"></i>&nbsp;<strong style="font-size:10pt">Email <CFIF type EQ 1>Receipt<CFELSE>Invoice</CFIF></strong></a>
</p>
<div class="header">
<h2 class="large center-elements"><CFIF type EQ 1>Payment Receipt<CFELSE>Invoice</CFIF>:&nbsp;<cfoutput>#output.invoice_number#</cfoutput>&nbsp;&nbsp;
</h2>
</div>
<div class="content">
<CFIF type EQ 1>
<CFINCLUDE template="ReceiptHTML.cfm">
<CFELSE>
<CFINCLUDE template="InvoiceHTML.cfm">
</CFIF>
</div><!-- End of .content -->
</div><!-- End of .grid_12 -->
</section><!-- End of #content -->
<!--- <CFIF event EQ "YES">
<div id="message-dialog" title="REMINDER">
<form name="message" id="message" class="full validate">
<div class="rowAlt">
<div>
<label><BR><BR><strong style="color:red; font-size:12pt; text-align:center">Be sure to Assign Participants by using the link on this page.</strong></label>
</div>
</div><!-- End of .row -->
</form>
</div><!-- End of #non-member-dialog -->
<script>
$$.ready(function() {
// Non Member Dialog
$( "#message-dialog" ).dialog({
autoOpen: true,
modal: true,
width: 550,
open: function(){ $(this).parent().css('overflow', 'visible'); $$.utils.forms.resize() }
}).find('#MessageButton').click(function(){
var $el = $(this).parents('.ui-dialog-content');
if ($el.validate().form()) {
closeMessage();
$el.find('form')[0].reset();
$el.dialog('open');
}
// }).end().find('button.cancel').click(function(){
// var $el = $(this).parents('.ui-dialog-content');
// $el.find('form')[0].reset();
// $el.dialog('close');
});
// $( ".open-message-dialog" ).click(function() {
// $( "#message-dialog" ).dialog( "close" );
// return false;
// });
});
function closeMessage () {
$("#message-dialog").dialog("close");
}
</script>
</CFIF> --->
<!--- Main Content Section Ends Here --->
<CFIF main EQ 0>
<!--- Contains the footer section --->
<cfinclude template="../../includes/footer.cfm"></body>
</CFIF>
</cfif>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment