Solved

need help with creating a page breaking invoice.

Posted on 2004-09-17
2
191 Views
Last Modified: 2013-12-24
I am trying to create an invoice that will break at a specific time or recordcount.

here  is the format that I am looking for
------------------------------------------------------------------------------------------
                                              title
                                                                                                       image
name                                                                                   myconame and address
(membernumber hidden)
address1
city, state zip
( this info is for the parent co. this co can also have child companies assigned to it.)

<hr>

duedate
                                             subtitle

truememrnumber               company name                                   amountdue
ex:  1234 A                        fullname
                                        address1
                                        address2 (if not blank)
                                        city state zip

truememrnumber               company name                                   amountdue
ex:  1234 b                        fullname
                                        address1
                                        address2 (if not blank)
                                        city state zip

truememrnumber               company name                                   amountdue
ex:  1234 c                        fullname
                                        address1
                                        address2 (if not blank)
                                        city state zip

now after the last record has been found the following footer info would be shown
total amount due ..............................................totalsumof amounts due
some disclaimer legal mumbo jumbo
some disclaimer legal mumbo jumbo
some disclaimer legal mumbo jumbo
some disclaimer legal mumbo jumbo
some disclaimer legal mumbo jumbo
some disclaimer legal mumbo jumbo
some disclaimer legal mumbo jumbo

now the code that I have been using is the following but can't seem to get the the break and the looping right.:

<cfquery name="getParents" datasource="uspoultry">
SELECT     Contacts.Company, Contacts.FullName, Contacts.Address1, Contacts.Address2, Contacts.City, Contacts.State, Contacts.zip, Contacts.country,
                      members.membernumber, members.memberletter, members.TrueMemNumber, mem_Payments.Amount, mem_Payments.memyear,
                      members.RecordType
FROM         Contacts INNER JOIN
                      members ON Contacts.Cid = members.Cid INNER JOIN
                      mem_Payments ON Contacts.Cid = mem_Payments.CID
WHERE     (mem_Payments.memyear = '2004') AND (members.memberletter = N'a') AND (members.RecordType = N'm')
ORDER BY members.TrueMemNumber, Contacts.Company
</cfquery>
<table width="100%"  border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td colspan="4" align="center"><strong>INVOICE</strong></td>
      </tr>
  <tr>
 
    <td align="center" COLSPAN="2">&nbsp;</td>
    <td width="12%" align="center">&nbsp;</td>
    <td width="29%" align="center"><img src="../images/1L4nowords.gif" width="50" height="50"></td>
  </tr><!--- Loop for the primary Records A --->
  <cfloop query="getparents">
  <cfoutput><tr>
    <td width="32%" align="left" valign="top">#Company#<br>
#FullName#<br>
#Address1#<br>
<cfif Address2 neq ''>#address2#<br></cfif>
#City#, #Ucase(State)# #zip#<cfif Country NEQ 'USA'><br> #Ucase(Country)#</cfif>
</cfoutput>
</td>
    <td width="27%">&nbsp;</td>
    <td colspan="2" align="right" valign="top"><div align="right" class="style1">U.S. Poultry &amp; Egg Association <br>
        1530 Cooledge Road<br>
        Tucker, GA 30084-7303<br>
        770.493.9401<br>
        Fax: 770.493.9257<br>
        www.poultryegg.org<br>
        EIN:  58-0704657
      </div></td>
  </tr>
  <tr><td colspan="6"><hr color="000000" ></td></tr>
  <!--- Query for the child records of the parents --->
  <cfquery name="getchild" datasource="uspoultry">
  SELECT     Contacts.Company, Contacts.FullName, Contacts.Address1, Contacts.Address2, Contacts.City, Contacts.State, Contacts.zip, Contacts.country,
                      members.membernumber, members.memberletter, members.TrueMemNumber, mem_Payments.Amount, mem_Payments.memyear,
                      members.RecordType
FROM         Contacts INNER JOIN
                      members ON Contacts.Cid = members.Cid INNER JOIN
                      mem_Payments ON Contacts.Cid = mem_Payments.CID
WHERE     (mem_Payments.memyear = '2004') AND (members.memberletter = N'a') AND (members.RecordType = N'm') and (members.membernumber = '#getparents.membernumber#')
ORDER BY members.TrueMemNumber, Contacts.Company
    </cfquery>
      <cfloop query="getchild">
      <cfoutput>
      <tr>
      <td colspan="2">
      #truememnumber#
      </td>
      <td width="32%" align="left" valign="top">#Company#<br>
#FullName#<br>
#Address1#<br>
<cfif Address2 neq ''>#address2#<br></cfif>
#City#, #Ucase(State)# #zip#
<cfif Country NEQ 'USA'>
<br> #Ucase(Country)#</cfif></td>
      </tr>
      </cfoutput>
      
      
      </cfloop>
  </cfloop>
</table>

Please EE come to the rescue again.

0
Comment
Question by:jriver12
2 Comments
 
LVL 25

Accepted Solution

by:
James Rodgers earned 500 total points
ID: 12088881
1) the code loks ok except that you don't need the second query, you are pulling the exact same info as you pulled in teh fisrt what you should do is run one query

<cfquery name="getDetails" datasource="uspoultry">
  SELECT     Contacts.Company, Contacts.FullName, Contacts.Address1, Contacts.Address2, Contacts.City, Contacts.State, Contacts.zip, Contacts.country,
                      members.membernumber, members.memberletter, members.TrueMemNumber, mem_Payments.Amount, mem_Payments.memyear,
                      members.RecordType
FROM         Contacts INNER JOIN
                      members ON Contacts.Cid = members.Cid INNER JOIN
                      mem_Payments ON Contacts.Cid = mem_Payments.CID
WHERE     (mem_Payments.memyear = '2004') AND (members.memberletter = N'a') AND (members.RecordType = N'm') and (members.membernumber = '#getparents.membernumber#')
ORDER BY members.TrueMemNumber, Contacts.Company
    </cfquery>
 and then in a cfouptut group by the top level fields
<table width="100%"  border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td colspan="4" align="center"><strong>INVOICE</strong></td>
      </tr>
  <tr>
 
    <td align="center" COLSPAN="2">&nbsp;</td>
    <td width="12%" align="center">&nbsp;</td>
    <td width="29%" align="center"><img src="../images/1L4nowords.gif" width="50" height="50"></td>
  </tr>
<cfoutput query="getDetails" group="field1.field2,filed3">
    ><tr>
    <td width="32%" align="left" valign="top">#Company#<br>
#FullName#<br>
#Address1#<br>
<cfif Address2 neq ''>#address2#<br></cfif>
#City#, #Ucase(State)# #zip#<cfif Country NEQ 'USA'><br> #Ucase(Country)#</cfif>
</cfoutput>
</td>
    <td width="27%">&nbsp;</td>
    <td colspan="2" align="right" valign="top"><div align="right" class="style1">U.S. Poultry &amp; Egg Association <br>
        1530 Cooledge Road<br>
        Tucker, GA 30084-7303<br>
        770.493.9401<br>
        Fax: 770.493.9257<br>
        www.poultryegg.org<br>
        EIN:  58-0704657
      </div></td>
  </tr>
  <tr><td colspan="6"><hr color="000000" ></td></tr>
       
   <cfouput query="getDetails">
               <tr>
     <td colspan="2">
     #truememnumber#
     </td>
     <td width="32%" align="left" valign="top">#Company#<br>
#FullName#<br>
#Address1#<br>
<cfif Address2 neq ''>#address2#<br></cfif>
#City#, #Ucase(State)# #zip#
<cfif Country NEQ 'USA'>
<br> #Ucase(Country)#</cfif></td>
     </tr>
   </cfoutput>
</cfoutput>

</table>

2) page breaks are determined by the users local printer setting; if a user has a 1" margin their page breaks will be different than a user with a 1/2" margin look at teh css attribute pageBreakBefore and pageBreakAfter, they might be of use

3) you need an if inside the output to determine when to insert the css from 2 above and this will be dependant upon the page/invoice header for page one and how many llines still need to be printed, you can use queryName.currentRow to determine this
0
 
LVL 17

Expert Comment

by:anandkp
ID: 12092182
0

Featured Post

Connect further...control easier

With the ATEN CE624, you can now enjoy a high-quality visual experience powered by HDBaseT technology and the convenience of a single Cat6 cable to transmit uncompressed video with zero latency and multi-streaming for dual-view applications where remote access is required.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Tool to email me when a website changes 29 133
AWS Advice on using WHM/cPanel 1 79
spamming  on Hosted svrs? 6 98
app server have enough resources... 2 52
One of the typical problems I have experienced is when you have to move a web server from one hosting site to another. You normally prepare all on the new host, transfer the site, change DNS and cross your fingers hoping all will be ok on new server…
Introduction This article explores the design of a cache system that can improve the performance of a web site or web application.  The assumption is that the web site has many more “read” operations than “write” operations (this is commonly the ca…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question