<%
crlf=CHR(13)+CHR(10)
SET CENTURY ON 
m_transid=orequest.form('thetransid')
if isnull(m_transid)
    m_transid=orequest.querystring('t') 
endif
theuser=orequest.querystring('user')
pagetype=upper(nvl(orequest.querystring('pw'),''))
*Pos Printer: 3 1/8" x 230' (approximately 80mm x 70m)
*Format	Width x Height (in mm)	Width x Height (in inches)
*A4	210 x 297	8.3 x 11.7
*A5	148 x 210	5.8 x 8.3
*A6	105 x 148	4.1 x 5.8
*A7	74 x 105	2.9 x 4.1
*<Option val="POS">POS Printer</Option>
*<Option val="A4">A4 (8.3 x 11.7 inches)</Option>
*<Option val="A5">A5 (5.8 x 8.3 inches)</Option>
*<Option val="A6">A6 (4.1 x 5.8 inches)</Option>
tpagewidth='210mm'
do CASE
    case pagetype=[LET]
        tpagewidth='210mm'
    case pagetype=[A4]
        tpagewidth='210mm'
    case pagetype=[A5]
        tpagewidth='148mm'
    case pagetype=[A6]
        tpagewidth='105mm'
    case pagetype=[POS]
        tpagewidth='80mm'
endcase
if isnull(m_transid)
    tsql=[select top 1 x.*,IIF(VAL(x.transid)=0,VAL(SUBSTR(x.transid,2)),VAL(x.transid)) AS VTR, ]
    tsql=tsql+[ padl(allt(x.transid),9) as ptransid, y.name as acname ]
    tsql=tsql+[ from ("]+dbclocation+'billpay.dbf'+[") x left join ("]+dbclocation+'accounts.dbf'+[") y ]
    tsql=tsql+[ on (x.vendor=y.accountid) order by vtr desc, ptransid desc into cursor xtmpcur]
    else
    tsql=[select top 1 x.*,IIF(VAL(x.transid)=0,VAL(SUBSTR(x.transid,2)),VAL(x.transid)) AS VTR, ]
    tsql=tsql+[ padl(allt(x.transid),9) as ptransid, y.name as acname ]
    tsql=tsql+[ from ("]+dbclocation+'billpay.dbf'+[") x left join ("]+dbclocation+'accounts.dbf'+[") y ]
    tsql=tsql+[ on (x.vendor=y.accountid) order by vtr desc, ptransid desc ]
    tsql=tsql+[ where allt(transid)==']+allt(m_transid)+[' into cursor xtmpcur]
endif

&tsql
SCATTER NAME SearchResults
if TYPE('SearchResults.fbrinv')='C' and not ALLTRIM(SearchResults.fbrinv)=='0' and not EMPTY(SearchResults.fbrinv)
  fbrnumberreceived=allt(searchresults.fbrinv)
else
  fbrnumberreceived=[]
endif
if empty(date)
  thedatestring=date() &&transform(date())
else
  thedatestring=date &&transform(dtoc(date))
endif
openingbalance=[Opening balance for this account is not appropriate]
if BETWEEN(val(left(SearchResults.vendor,2)),1,8) && and left(SearchResults.vendor,3)<>'019' 
    select sum(debit-credit) as dayopening from (dbclocation+[acctran]) where accountid=SearchResults.vendor and date<SearchResults.date INTO CURSOR opening
		select sum(debit) as debits, SUM(credit) as credits from (dbclocation+[acctran]) where accountid=SearchResults.vendor and date=SearchResults.date INTO CURSOR closing
		openingbalance=[Opening: ]+allt(transform(nvl(opening.dayopening,0)))+[ add debits: ]+allt(transform(closing.debits))+[ less credits: ]+;
		ALLTRIM(transform(closing.credits))+[ closing: ]+ALLTRIM(TRANSFORM(nvl(opening.dayopening,0)+closing.debits-closing.credits))+;
        [ as on ]+transform(DAY(SearchResults.date))+[ ]+LEFT(CMONTH(SearchResults.date),3)+[ ]+ALLTRIM(TRANSFORM(YEAR(SearchResults.date)))
       
ENDIF

*****
if not empty(openingbalance)
    tfile=addbs(oprop.appstartpath)+'images\receiptbarcode.bmp'
      SET PROCEDURE TO (addbs(oprop.appstartpath)+"FoxBarcodeQR.fxp") ADDITIVE
      set path to (addbs(oprop.appstartpath)) additive
      *--- Create FoxBarcodeQR object and QR Code barcode image
      LOCAL loFbc, lcQRImage
      m.loFbc = CREATEOBJECT("FoxBarcodeQR")
      *m.loFbc = NEWOBJECT("FoxBarcodeQR")
      m.lcString = allt(xtmpcur.vendor)+[: ]+allt(xtmpcur.acname)+[ balance: ]+ openingbalance
      ERASE (tfile)
      m.lcQRImage = loFbc.FullQRCodeImage(lcString, tfile  , 32*4)
      m.loFbc=.null.
endif
*****
USE (dbclocation+[accounts]) IN SELECT([accounts])
=SEEK(SearchResults.vendor,[accounts],[accountid])
ccreditor=[<option value=']+accounts.accountid+[' selected>]+ALLTRIM(accounts.name)+[</option>]
=SEEK(SearchResults.depositid,[accounts],[accountid])
cdebitor=[<option value=']+accounts.accountid+[' selected>]+ALLTRIM(accounts.name)+[</option>]
invnum=searchresults.transid
*************
    *=changeFieldStruc()
*************
%>
<!DocType HTML>
<html>
<html lang="ar" lang="ar" translate="no">

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="google" content="notranslate">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <link rel="icon" href="images/logo.bmp" type="image/x-icon">
    <style>
      body {
            font-family: 'Calibri', 'Gill Sans', 'Gill Sans MT', Calibri, 'Trebuchet MS', sans-serif;
           
       }
        @media print {
            .printnoshow {
                display: none;
            }
        }
        #companytitle {
            width: 100%;
            margin: 4px 0 2px 0;
            font-family: Arial, Helvetica, sans-serif;
            font-size: 16px;
            font-weight: bold;
        }
        
        #companyadd {
            width: 100%;
            font-family: "Calibri", sans-serif, Arial, Helvetica;
            font-size: 12px;
        }
        .bold{
            font-weight: bold;
        }
        #agtinfo {
            width: 100%;
            height: 26px;
            background: #666;
            color: #FFF;
            text-align: center;
            line-height: 26px;
            margin-bottom: 6px;
            border-color: black;
            border-style: solid;
            border-width: 2px;
            font-family: "Calibri", sans-serif, Arial, Helvetica;
            font-size: 14px;
            font-weight: bold;
        }
        @media screen {
            .screennoshow {
                display: none;
            }
        }

        @media screen,
        print {
            .noshowall {
                display: none;
            }
        }

        #wrapper {
            width: <<tpagewidth>>;
            text-align: center;
            margin: auto;
            border: 2mm ridge rgba(211, 220, 50, .6);
        }
       
        @media print{
            #wrapper {
            border: none;
        } 
        }
        @page {
         size: 8.5in 11in;  /* width height */
      }
    h1, p, table {
        margin:auto;
    }
    TD{
        font-size: 10PT;
    }
    </style>
</head>
<body onload="window.print();">
<div id='wrapper'>

 <%if pagetype=[POS]%>
    <%= include("poshead.html")%>
 <%endif%>
 <%if pagetype=[A4]%>
    <%= include("A4head.html")%>
 <%endif%>      
 <%if pagetype=[A5]%>
    <%= include("p5head.html")%>
 <%endif%>      
 <%if pagetype=[LE]%>
    <%= include("A4head.html")%>
 <%endif%>
           
       <div margin="auto" id="agtinfo" float="center">Payment Voucher</div>
        <table align="center" border="0px" width="100%">
            <tr>
                <td align="left" class="bold">Payment#: <<searchresults.transid>></td><td align="right" class="bold">Date: <<searchresults.date>></td>
            </tr>
            </table>
            
              <table align="center" border="1px" width="100%" style="border-collapse: collapse;">
                <tr>
                    <td class="bold">Received</td><td colspan="3"><<xcompany.currency>> <<iif(searchresults.amount<>int(searchresults.amount),round(searchresults.amount,2),round(searchresults.amount,0))>> (<<num2word(searchresults.amount)>>)</td>
                </tr>                
                <tr>
                    <td class="bold">From</td><td colspan="3">AC: <<searchresults.vendor>> Name <<searchresults.acname>></td>
                </tr>
                <%if not empty(searchresults.checkno)%>
                <tr>
                    <td class="bold">Cheaque#</td><td><<searchresults.checkno>></td><td class="bold">Date</td><td><<searchresults.chkdate>></td>
                </tr>
                <%endif%>
                <%if not empty(searchresults.name)%>
                <tr>
                    <td class="bold">Payer</td><td colspan="3"><<searchresults.name>></td>
                </tr>
                <%endif%>
                <%if not empty(searchresults.desc) and not (allt(searchresults.desc)==allt(searchresults.name)) and not (allt(searchresults.desc)==[FROM ]+allt(searchresults.name))%>
                <tr>
                    <td class="bold">details</td><td colspan="3"><<searchresults.desc>></td>
                </tr>
                <%endif%>

              </table>  
                       
        <%if not empty(openingbalance) and empty(xcompany.hideopbill)%>
                <table align="center" border="0px" width="AUTO">
                    <tr>
                        <td align="left" class="bold">Opening</td><td align="right"><<nvl(opening.dayopening,0.00)>></td>
                    </tr>
                    <%if not empty(nvl(closing.debits,0))%>
                    <tr>
                        <td align="left" class="bold">Add Debits</td><td align="right"><<closing.debits>></td>
                        
                    </tr>
                    <%endif%>
                    <%if not empty(nvl(closing.Credits,0))%>
                    <tr>
                        <td align="left" class="bold">Less Credits</td><td align="right"><<closing.Credits>></td>
                    </tr>
                    <%endif%>
                    <tr>
                        <td align="left" class="bold">Closing Balance</td><td align="right"><<nvl(opening.dayopening,0)+nvl(closing.debits,0)-nvl(closing.credits,0)>></td>
                    </tr>
                    <tr><td style="text-align: center;" colspan="2"><img src="images/receiptbarcode.bmp" width="96px"/></td></tr>
                </table>
            <%else%>
            <br/>
            <br/>
            <p align="center">This computer genated document needs no signatures</p>    
        <%endif%>
</div>

</body>
</html>