Link to home
Start Free TrialLog in
Avatar of susan1978
susan1978Flag for United States of America

asked on

I would like to do client side batch printing of asp files.

I am creating a asp web based shopping cart and my client would like to be ale to print all invoices that need to be shipped. There could be up to 1000 invoices at a time and he needs to be able to do this on his web server. Different information is displayed on each invoice. I want for example invoice 1 to print and invoice2, 3 etc. with the push of one button. I dont want my client to have to push the print button for each invoice. I want the program to print all invoices from data taken in a table. the invoice generates based on the querystring. for example if the querystring is ?invoice=10010 than invocie 10010 will display. Please help i have no idea how to do this. A Sample code would be appreciated. Or edit the code that I have included below. I have used a printer component from vbgold and it did not work. If anybody knows anything about the vbgold component that woul dbe helpfull too.

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Invoice</title>
</head>

<body>
<table width=600 cellpadding="3" cellspacing="20" border=0>
<tr>
<td> <!--Main table-->
      <tr>
            <td colspan=2>
                  <br>
            </td>
      </tr>
      <TR><!--Main table-->
            <TD width="250">
                  <table><!--Address table-->
                        <tr>
                           <td>
                             <img src="images/img_top_01.gif" border="0" height="45" width="195"> <br>
                             <font face="Verdana, Arial, Helvetica, sans-serif" size=1>Cameraunlimited.com</font><br>
                               <font face="Verdana, Arial, Helvetica, sans-serif" size=1>3409 Avenue S</font><br>
                               <font face="Verdana, Arial, Helvetica, sans-serif" size=1>Brooklyn, NY 11234</font><br>
                           </td>
                        </tr>
                  </table><!--Address table-->

            </TD><!--Main table-->
            <TD width="250" align="right">
                  <table width=325><!--Invoice date table-->
                        <tr align="right">
                           <td align="right" colspan=2>
                             <font face="Verdana, Arial, Helvetica, sans-serif" size=5><b>Invoice</b></font><br>
                           </td>
                        </tr>
                        <tr align="right">
                           <td>
                              <table Border=1 cellspacing=0  cellpadding="2"  width="150" bordercolor="#999999"><!--date and invoice number table-->
                                    <tr align="right">
                                          <td align="center">
                                                <font face="Verdana, Arial, Helvetica, sans-serif" size=2>Date</font>
                                          </td>
                                          <td align="center">
                                                <font face="Verdana, Arial, Helvetica, sans-serif" size=2>Invoice#</font>
                                          </td>
                                    </tr>
                                     <%
                                     dim rs
      
                           set conn = server.createobject("adodb.connection")
                         conn.Open  Application("PlatformDSN")
                                     set rs= server.createobject("adodb.recordset")
                         rs.Open "select * from X_invoice where invoice='" & request.querystring("invoice") & "' and store_id='1'" , conn
                                     %>
                                    <tr>
                                          <td align="center">
                                                <font face="Verdana, Arial, Helvetica, sans-serif" size=1><%=left(rs("create_date"),10)%></font>
                                          </td>
                                          <td align="center">
                                                <font face="Verdana, Arial, Helvetica, sans-serif" size=1><%=rs("invoice")%></font>
                                          </td>
                                    </tr>
                              </table><!--date and invoice number table-->
                          </td>      
                        </tr>
            </table><!--Invoice date table-->
            
            </TD><!--Main table-->
      </TR><!--Main table-->
      <TR><!--Main table-->
            <TD><!--Main table-->
                  <table width=250 cellpadding="3" cellspacing="0" border="1" height="150" bordercolor="#999999"><!--Billto table-->
                             <%
                                     dim rs2
                                     set rs2= server.createobject("adodb.recordset")
                         rs2.Open "select * from X_accounts_addresses where Account='" & rs("account") & "' and TYPE='BILLING' and store_id='1'" , conn
                           %>
                        
                        <tr height="25">
                              <td>
                                    <font face="Verdana, Arial, Helvetica, sans-serif" size=2>Bill to</font>
                              </td>
                        </tr>
                        <tr>
                              <td valign="top">
                                  <font face="Verdana, Arial, Helvetica, sans-serif" size=1><%=rs2("fname")%>&nbsp;<%=rs2("lname")%></font><br>
                                     <font face="Verdana, Arial, Helvetica, sans-serif" size=1><%=rs2("address1")%></font><br>
                                    <%
                                    if rs2("address2") <> "" then
                                    %>
                                    <font face="Verdana, Arial, Helvetica, sans-serif" size=1><%=rs2("address2")%></font><br>
                                    <%end if%>
                                     <font face="Verdana, Arial, Helvetica, sans-serif" size=1><%=rs2("city")%>,&nbsp;<%=rs2("State")%>&nbsp;<%=rs2("zip")%></font><br>
                                     <%
                                     dim rs3
                                     set rs3= server.createobject("adodb.recordset")
                         rs3.Open "select description from X_countries where abreviation='" & rs2("country") & "' " , conn
                               %>
                                  <font face="Verdana, Arial, Helvetica, sans-serif" size=1><%=rs3("description")%></font><br>
                              </td>
                        </tr>
                  </table><!--Billto table-->
            </TD><!--Main table-->
            <TD width=325 align="right"><!--Main table-->
                  <table width=250 cellpadding="3" cellspacing="" border="1" bordercolor="#999999"  height="150" align="right"><!--shipto table-->
                             <%
                                     dim rs4
                                     set rs4= server.createobject("adodb.recordset")
                         rs4.Open "select * from X_accounts_addresses where Account='" & rs("account") & "' and TYPE='SHIPPING' and store_id='1'" , conn
                           %>
                        <tr height="25" >
                              <td>
                                    <font face="Verdana, Arial, Helvetica, sans-serif" size=2>Ship to</font>
                              </td>
                        </tr>
                        <tr >
                              <td valign="top">
                                  <font face="Verdana, Arial, Helvetica, sans-serif" size=1><%=rs4("fname")%>&nbsp;<%=rs4("lname")%></font><br>
                                     <font face="Verdana, Arial, Helvetica, sans-serif" size=1><%=rs4("address1")%></font><br>
                                     <%
                                    if rs4("address2") <> "" then
                                    %>
                                    <font face="Verdana, Arial, Helvetica, sans-serif" size=1><%=rs4("address2")%></font><br>
                                    <%end if%>
                                     <font face="Verdana, Arial, Helvetica, sans-serif" size=1><%=rs4("city")%>,&nbsp;<%=rs4("State")%>&nbsp;<%=rs4("zip")%></font><br>
                                   <%
                                     dim rs5
                                     set rs5= server.createobject("adodb.recordset")
                         rs5.Open "select description from X_countries where abreviation='" & rs4("country") & "'" , conn
                               %>
                                  <font face="Verdana, Arial, Helvetica, sans-serif" size=1><%=rs5("description")%></font><br>
                              
                              </td>
                        </tr>
                  </table><!--shipto table-->
            </TD><!--Main table-->
      </TR><!--Main table-->
      <TR><!--Main table-->
            <TD colspan=2><!--Main table-->
                  <table width=600 border=1  cellspacing="0" cellpadding="3" bordercolor="#999999"><!--detail table-->
                        <tr>
                              <td width=75>
                                    <font face="Verdana, Arial, Helvetica, sans-serif" size=2>Quantity</font><br>
                              </td>
                              <td width=75>
                                    <font face="Verdana, Arial, Helvetica, sans-serif" size=2>Item#</font><br>
                              </td>
                              <td width=300>
                                    <font face="Verdana, Arial, Helvetica, sans-serif" size=2>Description</font><br>
                              </td>
                              <td width=75>
                                    <font face="Verdana, Arial, Helvetica, sans-serif" size=2>Price</font><br>
                              </td>
                              <td width=75>
                                    <font face="Verdana, Arial, Helvetica, sans-serif" size=2>Amount</font><br>
                              </td>
                        </tr>
                        <tr height="300">
                         <td colspan="5" valign="top">
                          <table cellspacing="0" cellspacing="2">
                           <%
                                     dim rs6
                                     set rs6= server.createobject("adodb.recordset")
                         rs6.Open "select * from X_Items_On_order where Invoice_num='" & request.querystring("invoice") & "' and store_id='1'" , conn
                                     dim subtotal
                                     dim total
                                    
                                     do while not rs6.eof
                                    subtotal=(rs6("quantity")) * (rs6("price"))
                                    Total= total+subtotal
                           %>
                          <tr>      
                              <td valign="top" width=75>
                                    <font face="Verdana, Arial, Helvetica, sans-serif" size=1><%=formatnumber(rs6("quantity"),2)%></font><br>
                              </td>
                              <td valign="top" width=75>
                                    <font face="Verdana, Arial, Helvetica, sans-serif" size=1><%=rs6("product_num")%></font><br>
                              </td>
                               <%
                                     dim rs7
                                     set rs7= server.createobject("adodb.recordset")
                         rs7.Open "select short_description from X_products where item_count='" & rs6("product_num") & "' and store_id='1'" , conn
            
                             %>
                              <td valign="top" width=300>
                                    <font face="Verdana, Arial, Helvetica, sans-serif" size=1><%=rs7("short_description")%></font><br>
                              </td>
                              <td valign="top" width=75>
                                    <font face="Verdana, Arial, Helvetica, sans-serif" size=1><%=formatcurrency(rs6("price"),2)%></font><br>
                              </td>
                              <td valign="top" align="right" width=75>
                                    <font face="Verdana, Arial, Helvetica, sans-serif" size=1><%=formatcurrency(((rs6("quantity")) * (rs6("price"))),2)%></font><br>
                              </td>
                          </tr>
                          <%
                                rs6.movenext
                              loop
                          %>      
                         </table>      
                        </td>
                        </tr>
                        <tr>
                              <td colspan="3" align="left" valign="top">&nbsp;
                              
                              </td>
                              <td colspan="2">
                                    <table border="0" cellpadding="2" cellspacing="" width=150><!--subtotal table-->
                                          <tr>
                                                <td><font face="Verdana, Arial, Helvetica, sans-serif" size=1>Subtotal</font></td>
                                                <td align="right"><font face="Verdana, Arial, Helvetica, sans-serif" size=1><%=formatcurrency(trim(total),2)%></font></td>
                                          </tr>
                                          
                                          <%
                                        dim rs8
                                          dim shipping
                                        set rs8= server.createobject("adodb.recordset")
                            rs8.Open "select price from X_shipping_types where shipping_type_id='" & rs("shipping_method") & "' and store_id='1'" , conn
                                    shipping=rs8("price")
                                          %>
                                          <tr>
                                                <td><font face="Verdana, Arial, Helvetica, sans-serif" size=1>Shipping</font></td>
                                                <td align="right"><font face="Verdana, Arial, Helvetica, sans-serif" size=1><%=formatcurrency(rs8("price"),2)%></font></td>
                                          </tr>
                                          <tr>
                                                <td><font face="Verdana, Arial, Helvetica, sans-serif" size=1>Taxes</font></td>
                                          
                                          <%
                                          Dim taxes
                                          Dim taxamount
                                          set rs10 = server.createobject("adodb.recordset")
                                          rs10.Open "SELECT PERCENTAGE, STATE FROM X_TAXES WHERE (STORE_ID = 1) AND (STATE = '" & session("shipState") & "')" , conn  
                            %>
   
      
                                                <td align="right"><font face="Verdana, Arial, Helvetica, sans-serif" size=1><%=formatcurrency(((total+shipping)*rs10("percentage")),2)%></font></td>
                                          </tr>
                                          <tr>
                                              <td colspan=2>
                                                 <hr color="#999999">
                                                </td>
                                          </tr>
                                          <tr>
                                                <td><font face="Verdana, Arial, Helvetica, sans-serif" size=1><b>Total</b></font></td>
                                                <td align="right"><font face="Verdana, Arial, Helvetica, sans-serif" size=1><%=formatcurrency(((total)+((total+shipping)*rs10("percentage"))+(rs8("price"))),2)%></font></td>
                                          </tr>
                                    </table><!--subtotal table-->
                              </td>
                        </tr>
                  </table><!--detail table-->
            </TD><!--Main table-->
</tr></table><!--Main table-->
</body>
</html>
Avatar of mrichmon
mrichmon

I did something like this in cold fusion where we needed around 2000 printed.

Problem:  All must spool to the printer so that even though they are rendered to screen printing of each single page took over 30 min.

This was unacceptable.

So what we did was made them have to hit a button for every 100 invoices.  Yes it meant 20 presses of the button, but then again, the paper had to be handled every so many sheets anyway (we had multiple paper trays for input paper, but the output tray only held 250 sheets).

Anyway the point was that we found taht we had to do it in batches of 100 to get no noticable decrease in normal print speed of the printer.  (And this printer had a lot of memory)

Just something to consider....
Avatar of susan1978

ASKER

Ok 100 at a time is acceptable I just need to go about this in asp. Do you have a asp solution?
ASKER CERTIFIED SOLUTION
Avatar of mrichmon
mrichmon

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
i can do a do while loop .... rs.movenext loop but i am not sure i want to print the invoices in a browser with a page break between each invoice and then push print button. I think it woul dtake a really long time to display 100 invoices in a browser. I woul dlike to do it so that the 100 invoices print at one without displaying in a browser. Is that possible. I would like to just send the 100 invoices to the clints printer. If thats not possible i will try youe method.



I looked and looked and never found a way to do that....
Avatar of James Rodgers
why do you need to print teh invoices from the web?
have you considered this...

place an Access app on teh clinets machine
link the access app to teh DB server using ODBC
create an invoice report
use the app to allow the client to print all invoices created since last print - store teh last print date time and reference it on the next print call
loop through teh data and create teh invoices
 
Jester,
There are needs to print invoices from the web.  For example, in one instance the invoice was dynamically created based on how many items were actually available to ship and the charge to the credit card and then printing of invoice happened in one button press. (well if the CC was successful)  :o)

But access is an alternative for huge batches in some cases.
>>There are needs to print invoices from the web.  For example, in one instance the invoice was dynamically created based on how many items were actually available to ship and the charge to the credit card and then printing of invoice happened in one button press. (well if the CC was successful)  :o)

agreed, if it was a single invoice, web printing would be acceptable, but if you want to do dozens or hundreds without user interaction to confirm each print i would move it to a different method
I used the <br style="page-break-before:always"> Its not exactley what I wanted but it works and it does the job.

Thank you!