Normal Topic Printer to alternative Tray (Read 6244 times)
cbislander
Full Member
***
Offline



Posts: 103
Joined: Mar 22nd, 2018
Printer to alternative Tray
Feb 1st, 2022 at 2:01pm
Print Post Print Post  
We print 3 copies of each invoice - Customer, Store and Delivery.  Aside from the labels, they are identical.  In Q&A we used multi-part forms on impact printers.  The pages were different colors to make them easier to sort out.

Over the past 2 years, we have been using our copier to print invoices, but the pages are just white.

Our copier has 2 trays.  How do I tell the copier to print the Customer and Store copy to "Drawer 1" and the Delivery copy to "Drawer 2" which would have yellow paper?

If vMode <> 0 Then
{
     vCount = @FormResultSetTotal("Items1")
     PrintInvoice(" C U S T O M E R   C O P Y")
     PrintInvoice(" S T O R E   C O P Y")
     PrintInvoice(" D E L I V E R Y   C O P Y")
}
PRINTED = @TIME
  
Back to top
 
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2480
Joined: Aug 20th, 2003
Re: Printer to alternative Tray
Reply #1 - Feb 1st, 2022 at 3:00pm
Print Post Print Post  
What code is in the PrintInvoice() Subroutine?

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
cbislander
Full Member
***
Offline



Posts: 103
Joined: Mar 22nd, 2018
Re: Printer to alternative Tray
Reply #2 - Feb 1st, 2022 at 3:14pm
Print Post Print Post  
Here it is, Ray


//Indicator for Pretty or Normal Invoice
var vMode as Int = 0
Var vCount as Int
Var vEmail as String
SUBROUTINE PrintHeader(vCopy as String)
Var vInvDate as String
Var vShipDate as String
Var vLineX as Int
Var vLineXMax as Int
Var vFNLN as String
Var vFNLN2 as String
vLineXMax = 795
vLineX = 50

     NewPage(850, 1100)

     If vMode = 1 Then
     {
           //Normal Invoice
           //The next four lines make the address for J. R. Raheys. User Definable
           PrintString("J. R. Rahey's ", 50, 45, 0, "BArial", 33, 0)
           PrintString("Furniture & Appliances", 50, 80, 0, "BArial", 18, 0)
           PrintString("1095 King's Road", 50, 105, 0, "Arial", 14, 0)
           PrintString("Sydney River, NS, B1S 1C6", 50, 120, 0, "Arial", 14, 0)
           PrintString("Tel: 902-562-2500, Fax: 902-562-6384", 50, 135, 0, "Arial", 14, 0)
           PrintString(vCopy, 450, 105, 0, "Arial", 14, 0)
     }
     Else If vMode = 2 Then
     {
           //Pretty Invoice
           PrintImage("DATA\PICTURES\invoice-header2.png", 15, 15, -1, -1)

           IF LOCATION = "SYDNEY RIVER" THEN PrintString("X",55,170,0,"BArial",14,0)
           IF LOCATION = "SYDNEY MINES" THEN PrintString("X",180,170,0,"BArial",14,0)
           IF LOCATION = "ANTIGONISH" THEN PrintString("X",300,170,0,"BArial",14,0)
           IF LOCATION = "NEW GLASGOW" THEN PrintString("X",420,170,0,"BArial",14,0)

           //PrintBox(12, 50, 35, @PageExtentX()-50, @PageExtentY()-35)
           PrintString(vCopy, 550, 105, 0, "Arial", 14, 0)

     }

     PrintBox(12,540,25,285,25)
     PrintString("LOCATION:" , 550, 30, 0, "Arial", 14, 0)
     PrintString(LOCATION , 640, 30, 0, "Arial", 14, 0)
     PrintBox(12,540,50,155,20)
     PrintBox(12,695,50,130,20)
     PrintString("Invoice Number" , 550, 50, 0, "Arial", 16, 0)
     PrintString(@STR(Invoice) , 580, 75, 0, "Arial", 14, 0)
     PrintBox(12,540,70,155,25)
     PrintBox(12,695,70,130,25)
     PrintString("Invoice Date", 700, 50, 0, "Arial", 16, 0)
     vInvDate = @AsFormattedByLE(DATE10, 1, "")
     PrintString(vInvDate , 700, 75, 0, "Arial", 14, 0)

     //Create Bill To Section of Invoice
     PrintString("Bill To:", 100, 200, 0, "BArial", 16, 0)
     vFNLN = FNAME + " " + LNAME
     PrintString(VFNLN, 100, 220, 0, "Arial", 14, 0)
     PrintString(STREET, 100, 240, 0, "Arial", 14, 0)
     PrintString(City + " "  + Postal Code, 100, 260, 0, "Arial", 14, 0)
     PrintString("("+ @LEFT(PHONE1,3) +") "+@MID(PHONE1,4,3)+"-"+@RIGHT(PHONE1,4), 100, 280, 0, "Arial", 14, 0)
       
     //Create Ship To Section of Invoice
     PrintString("Delivery Date:", 555, 140, 0, "BArial", 16, 0)
     vShipDate = @AsFormattedByLE(DELIVERY DATE, 1, "")
     PrintString(vShipDate, 700, 140, 0, "Arial", 14, 0)
     PrintString("Ship To:", 500, 200, 0, "BArial", 16, 0)
     vFNLN2 = FN2 + " " + LN2

     PrintString(vFNLN2, 500, 220, 0, "Arial", 14, 0)
     PrintString(STREET2, 500, 240, 0, "Arial", 14, 0)
     PrintString(CITY0  + " " , 500, 260, 0, "Arial", 14, 0)
     PrintString("("+ @LEFT(PHONE2,3) +") "+@MID(PHONE2,4,3)+"-"+@RIGHT(PHONE2,4), 500, 280, 0, "Arial", 14, 0)
vEmail = @STR(EMAIL)
     vEmail = @Replace(vEmail, "@", "@@")
     PrintString("EMAIL:"+ vEMAIL, 65, 300, 0, "BArial", 14, 0)
     PrintString("DEL INFO:"+ COMMENT, 380, 300, 0, "BArial", 14, 0)
     //Make a line between Bill To/Shipping information and Line Items
     While vLineX <= vLineXMax
     {      
           PrintString("_", vLineX, 300, 0, "Arial", 14, 0)      
           vLineX += 5
     }

IF LE2 <> "POA" THEN

     {//Print Line Item Headers
     PrintString("Code", 45, 330, 0, "BArial", 12, 0)
     PrintString("Brand",120, 330, 0, "BArial", 12, 0)
     PrintString("Dept",190, 330, 0, "BArial", 12, 0)
     PrintString("Model",220, 330, 0, "BArial", 12, 0)
     PrintString("Description",380, 330, 0, "BArial", 12, 0)
     PrintString("Price", 585, 330, 100, "BArial", 12, 0, 1)
     PrintString("Qty", 630, 330, 100, "BArial", 12, 0, 1)
     PrintString("Total", 700, 330, 100, "BArial", 12, 0, 1)}

END SUBROUTINE


SUBROUTINE PrintFooter()
Var vLineX as Int
Var vPageY as Int
Var vLineXMax as Int
Var vTotal as String
Var vQty as String
Var vTax as String
Var vShipping as String
Var vEHF0 as String
Var vADMIN0 as String
Var vSubTotal as String
Var vBALFWD as String
Var vPOA0 as String
Var vNEWBAL as String
Var vTERMS0 as String
Var vPOATRM as String
Var vMESSAGE as String
Var vClerk as String

vLineX = 50
vLinexMax = 795

IF EHF0 > 0 THEN PrintString("AN ENVIRONMENTAL HANDLING FEE (EHF) HAS BEEN APPLIED TO THE INVOICE",75,830,0,"Arial",16,0)

     //Prints a line between Line Items and the Totals
     While vLineX <= vLineXMax
     {
           PrintString("_", vLineX, 840, 0, "Arial", 14, 0)      
           vLineX += 5
     }

IF LE2 = "POA" THEN

     {      //BALANCE FORWARD
     vPageY = 350
     PrintString("BALANCE FORWARD:",150, 450, 0, "BArial", 20, 0)
     vBALFWD = @AsFormattedByLE(BALFWD, 1, "")
     PrintString(vBALFWD, 450, 450, 100, "Arial", 20, 0, 1)

     //POA
     vPageY = @PageExtentY() + 1
     PrintString("PAID ON ACCOUNT:",150, 500, 0, "BArial", 20, 0)
     vPOA0 = @AsFormattedByLE(POA0, 1, "")
     PrintString(vPOA0, 450, 500, 100, "Arial", 20, 0, 1)

     //NEW BALANCE
     vPageY = @PageExtentY() + 1
     PrintString("NEW BALANCE:", 150, 550, 0, "BArial", 20, 0)
     vNEWBAL = @AsFormattedByLE(NEWBAL, 1, "")
     PrintString(vNEWBAL, 450, 550, 100, "Arial", 20, 0, 1)

     //POA TERMS
     vPageY = @PageExtentY() + 1
     PrintString("POA TERM:",150, 950, 0, "BArial", 16, 0)
     vPOATRM = @AsFormattedByLE(POATRM, 1, "")
     PrintString(vPOATRM, 250, 950, 200, "Arial", 16, 0, 1)


}


IF LE2 <> "POA" THEN

     {//Shipping
     vPageY = 855


        //Terms
     PrintString("Terms:", 50, vPageY, 0, "BArial", 16, 0)
     vTERMS0 = @AsFormattedByLE(TERMS0, 1, "")
     PrintString(vTERMS0, 125, vPageY, 150, "Arial", 16, 0, 0)

     PrintString("Shipping:", 550, vPageY, 0, "BArial", 16, 0)
     vShipping = @AsFormattedByLE(Delivery0, 1, "")
     PrintString(vShipping, 650, vPageY, 100, "Arial", 16, 0, 1)

     //EHF
     vPageY = @PageExtentY() + 5
     PrintString("EHF:", 550, vPageY, 0, "BArial", 16, 0)
     vEHF0 = @AsFormattedByLE(EHF0, 1, "")
     PrintString(vEHF0, 650, vPageY, 100, "Arial", 16, 0, 1)

        //Balance Forward

If TERMS0 = "LAYAWAY" THEN {
     PrintString("BALANCE FORWARD:",50,vPageY, 0, "BArial", 16, 0)
     vBALFWD = @AsFormattedByLE(BALFWD, 1, "")
     PrintString(vBALFWD, 275,vPageY, 100, "Arial", 16, 0, 1)}

     //ADMIN
     vPageY = @PageExtentY() + 5
     //PrintString("ADMIN:", 550, vPageY, 0, "BArial", 16, 0)
     vADMIN0 = @AsFormattedByLE(ADMIN0, 1, "")
     PrintString(vADMIN0, 650, vPageY, 100, "Arial", 16, 0, 1)

     //POA

If TERMS0 = "LAYAWAY" THEN {
     PrintString("PAID ON ACCOUNT:",50,vPageY, 0, "BArial", 16, 0)
     vPOA0 = @AsFormattedByLE(POA0, 1, "")
     PrintString(vPOA0, 275, vPageY, 100, "Arial", 16, 0, 1)}


     //Sub-Total
     vPageY = @PageExtentY() + 5
     PrintString("SubTotal:", 550, vPageY, 0, "BArial", 16, 0)
     vSubTotal = @AsFormattedByLE(Sub1, 1, "")
     PrintString(vSubTotal, 650, vPageY, 100, "Arial", 16, 0, 1)

     //NEW BALANCE

If TERMS0 = "LAYAWAY" THEN {
     PrintString("NEW BALANCE:", 50, vPageY, 0, "BArial", 16, 0)
     vNEWBAL = @AsFormattedByLE(NEWBAL, 1, "")
     PrintString(vNEWBAL, 275, vPageY, 100, "Arial", 16, 0, 1)}

     //Tax
     vPageY = @PageExtentY() + 5
     PrintString("HST:", 550, vPageY, 0, "BArial", 16, 0)
     vTax = @AsFormattedByLE(HST, 1, "")
     PrintString(vTax, 650, vPageY, 100, "Arial", 16, 0, 1)

     //POA TERMS

If TERMS0 = "LAYAWAY" THEN {
     PrintString("POA TERM:",50, vPageY, 0, "BArial", 16, 0)
     vPOATRM = @AsFormattedByLE(POATRM, 1, "")
     PrintString(vPOATRM, 75, vPageY, 200, "Arial", 16, 0, 1)}

     vPageY = @PageExtentY() + 5
     PrintString("CLERK:",50, vPageY, 0, "BArial", 16, 0)
     vCLERK = @AsFormattedByLE(CLERK, 1, "")
     PrintString(vCLERK, 125, vPageY, 200, "Arial", 16, 0, 0)

     //Total
     PrintString("Total:", 550, vPageY, 0, "BArial", 16, 0)
     vTotal = @AsFormattedByLE(Total,1,"")
     PrintString(vTotal, 650, vPageY, 100, "BArial", 16, 0, 1)}

     //Invoice footer
           PrintImage("DATA\PICTURES\invoicefooter.png", 5, 1005, -1, -1)

     PrintBox(33,530,856,275,146)

     //Notes
     //PrintString(Notes, 60, 950, 440, "Courier New", 16, 0)

     FinishPage()

END SUBROUTINE

Subroutine PrintInvoice(vCopy as String)
Var vRecord as Int
Var vPageY as Int
Var vPrice as String
Var vTotal as String
Var vQty as String
Var vPage as Int

     vRecord = 1
     vPage = 1

     PrintHeader(vCopy)

     If vCount > 0 Then
     {
           While vRecord <= vCount
           {
                 vPageY = @PageExtentY() + 2
                 If vPageY > 900
                 {
                       //If page is full
                       PrintString("Continued On Next Page...." , 322, 1000, 0, "BArial", 16, 0)
                       FinishPage()
                       vPage += 1
                       VPageY = 338

                       PrintHeader(vCopy)
                       PrintString("Page Number" , 519, 100, 0, "BArial", 16, 0)
                       PrintString(@STR(vPage) , 570, 120, 0, "Arial", 14, 0)
                 }

                 //Product Code
                 PrintString(@FormFieldValue("Items1", "C1", vRecord), 45, vPageY, 300, "Arial", 10, 0)

                 //Product Brand
                 PrintString(@FormFieldValue("Items1", "B1", vRecord), 120, vPageY, 300, "Arial", 10, 0)


                 //Product DEPT
                 PrintString(@FormFieldValue("Items1", "D1", vRecord), 190, vPageY, 300, "Arial", 10, 0)

                 //Product Model
                 PrintString(@FormFieldValue("Items1", "M1", vRecord), 220, vPageY, 300, "Arial", 10, 0)

                 //Product Descritption
                 PrintString(@FormFieldValue("Items1", "DESC1", vRecord), 380, vPageY, 300, "Arial", 10, 0)
     
                 //Product Price
                 vPrice = @STR(@TN(@FormFieldValue("Items1", "UP1", vRecord)))
                 PrintString(vPrice, 585, vPageY, 100, "Arial", 10, 0, 1)
     
                 //Product Qty
                 vQty = @STR(@TN(@FormFieldValue("Items1", "Qty0", vRecord)))
                 PrintString(vQty, 635, vPageY, 100, "Arial", 10, 0, 1)
     
                 //Product(s) Total
                 vTotal = @STR(@DECIMALS(@FormFieldValue("Items1", "TPRICE0", vRecord),2))
                 PrintString(vTotal, 700, vPageY, 100, "Arial", 10, 0, 1)
     
                 vRecord = vRecord + 1
           }
     }
     PrintFooter()


End Subroutine

Var vInvoice as String

//Offer User Choice of Invoices Popup is over Print button
PopupSelectPosition(4, @XPos(PRININV) + 11, @YPos(PRININV) + 15)
vInvoice = @PopupMenu("Normal;Pretty", "Which Invoice would you like to print?")


If vInvoice = "Normal" Then
{
     vMode = 1
}
Else If vInvoice = "Pretty" Then
{
     vMode = 2
}


If vMode <> 0 Then
{
     vCount = @FormResultSetTotal("Items1")
     PrintInvoice(" C U S T O M E R   C O P Y")
     PrintInvoice(" S T O R E   C O P Y")
     PrintPageTray("Drawer 2")
     PrintInvoice(" D E L I V E R Y   C O P Y")
}
PRINTED = @TIME

     If (@Mode() = 0) Or (@Mode() = 1)
     {
           FormCommit("")
           
     }
  
Back to top
 
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2480
Joined: Aug 20th, 2003
Re: Printer to alternative Tray
Reply #3 - Feb 1st, 2022 at 3:50pm
Print Post Print Post  
Okay Perfect.  If your printer supports it you should be able to use PrintPageTray() so your code would look something like.

In global code
Code
Select All
#include "sbasic_include.sbas" 



and then

Code
Select All
If vMode <> 0 Then
{
     vCount = @FormResultSetTotal("Items1")
     PrintPageTray(-1)//Reset to default
     PrintInvoice(" C U S T O M E R   C O P Y")
     PrintInvoice(" S T O R E   C O P Y")
     PrintPageTray(PRINTER_TRAY_MIDDLE)//Set to Different Tray
     PrintInvoice(" D E L I V E R Y   C O P Y")
}
PRINTED = @TIME 



You may have to use a different one just using PRINTER_TRAY_MIDDLE as the example. You can see them all on page 337 of the Sesame 2 Programming Guide.

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
cbislander
Full Member
***
Offline



Posts: 103
Joined: Mar 22nd, 2018
Re: Printer to alternative Tray
Reply #4 - Feb 1st, 2022 at 4:26pm
Print Post Print Post  
Hi Ray,

Thanks, that seemed to work without any changes.
  
Back to top
 
IP Logged
 
cbislander
Full Member
***
Offline



Posts: 103
Joined: Mar 22nd, 2018
Re: Printer to alternative Tray
Reply #5 - Feb 3rd, 2022 at 7:25pm
Print Post Print Post  
Hi Ray,

When we do Finance sales, we print an extra invoice which goes with our sales copies.

When I printed a Finance sale, I use the command to print the 3 copies, the last one is from the lower tray.  Then, I use the command button to print the extra page, but it also came from the lower tray.

What do I do to direct the printer to print from the upper tray?
  
Back to top
 
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2480
Joined: Aug 20th, 2003
Re: Printer to alternative Tray
Reply #6 - Feb 3rd, 2022 at 7:29pm
Print Post Print Post  
the line below resets to the default tray. You can place this after your print invoice call that goes to the 3rd tray.

Code
Select All
PrintPageTray(-1)//Reset to default 



-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
cbislander
Full Member
***
Offline



Posts: 103
Joined: Mar 22nd, 2018
Re: Printer to alternative Tray
Reply #7 - Feb 3rd, 2022 at 8:21pm
Print Post Print Post  
Got it.

I realized it after I sent the message.

Made the fix and it works fine.

The only remaining issue is doing the day end reports.

The reports print to HTML and our secretary wants to print  them from the lower tray, but all other reports from the top tray. 

Since the print job is not actually in Sesame, I have to go through the Printer Dialog which is a little tedious.

Right now, we would pop open the top tray so the copier prints from the lower tray.
  
Back to top
 
IP Logged