<%
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=lower(transform(orequest.querystring('pw')))
*<Option val="POS">POS English</Option> 80mm
*<Option val="posmix">POS MIX</Option>
*<Option val="poslocal">POS Local Language</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>
*@page {size: <length> | auto | [ <page-size> || [ landscape | portrait ] ]}
do case 
    case [mix] $ pagetype
        isurdu=2
    case [local] $ pagetype
        isurdu=1
    OTHER
        isurdu=0
endcase
    
do case
    case pagetype='pos'
        pagewidth='80mm'
        pageheight='3276mm'
    case pagetype='a4'
        pagewidth='8.3inch'
        pageheight='11.7inch'
    case pagetype='a5'
        pagewidth='5.8inch'
        pageheight='8.3inch'
    case pagetype='a6'
        pagewidth='4.1inch'
        pageheight='5.8inch'
    OTHER
        pagewidth='8.3inch'
        pageheight='11.7inch'
endcase 
theuser=[]
if isnull(m_transid)
    tsql=[select top 1 *,IIF(VAL(transid)=0,VAL(SUBSTR(transid,2)),VAL(transid)) AS VTR, ]
    tsql=tsql+[ padl(allt(transid),9) as ptransid ]
    tsql=tsql+[ from ("]+dbclocation+'cashsale.dbf'+[") order by vtr desc, ptransid desc ]
    else
    tsql=[select top 1 *,IIF(VAL(transid)=0,VAL(SUBSTR(transid,2)),VAL(transid)) AS VTR, ]
    tsql=tsql+[ padl(allt(transid),9) as ptransid ]
    tsql=tsql+[ from ("]+dbclocation+'cashsale.dbf'+[") order by vtr desc, ptransid desc where allt(transid)==']+allt(m_transid)+[']
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=[]
if BETWEEN(val(left(SearchResults.depositid,2)),1,8) and left(SearchResults.depositid,3)<>'019' 
    select sum(debit-credit) as dayopening from (dbclocation+[acctran]) where accountid=SearchResults.depositid and date<SearchResults.date INTO CURSOR opening
		select sum(debit) as debits, SUM(credit) as credits from (dbclocation+[acctran]) where accountid=SearchResults.depositid and date=SearchResults.date INTO CURSOR closing
		openingbalance=[Opening: ]+allt(transform(opening.dayopening))+[ add debits: ]+allt(transform(closing.debits))+[ less credits: ]+;
		ALLTRIM(transform(closing.credits))+[ closing: ]+ALLTRIM(TRANSFORM(opening.dayopening+closing.debits-closing.credits))+[ as on ]+transform(DAY(SearchResults.date))+[ ]+LEFT(CMONTH(SearchResults.date),3)+[ ]+ALLTRIM(TRANSFORM(YEAR(SearchResults.date)))
ENDIF
*****
if not empty(fbrnumberreceived)
    tfile=addbs(oprop.appstartpath)+'images\'+fbrnumberreceived+'.bmp'
    if not file(tfile)
      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 = fbrnumberreceived
      ERASE (tfile)
      m.lcQRImage = loFbc.FullQRCodeImage(lcString, tfile , 32*4)
      m.loFbc=.null.
    endif
endif
*****
USE (dbclocation+[accounts]) IN SELECT([accounts])
=SEEK(SearchResults.customer,[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
CLOSE TABLES 
CLOSE DATABASES 
*************
USE IN SELECT('printinvoice')
lgetunit=iif(xcompany.zunit or xcompany.usekglibs,.t.,.f.)
haskglibs=xcompany.usekglibs 

	IF NOT EMPTY(xcompany.fbrposid)
        tsql=[Select d.name as deposited,x.depositid, x.Total As PrdTotal,x.opt, x.fbrinv, x.fbrPOST, x.daysrno, x.discount As prdDisc, x.memdisc, ]
        tsql=tsql+[a.TAXPRATE, a.TAXRATE,a.extra, x.Payment, x.EXPAMT, x.transid, x.name As Memo,Space(9) As bill, ]
        tsql=tsql+[x.Date,x.ddate,x.address1,x.address2,x.SaleMan,x.customer, ]+ iif(lgetunit=.t.,'z.unit','0')+[ as zunit, ] + iif(xcompany.zctn=.t.,'z.ctn','space(2)')+[ as zctn, ]
        tsql=tsql+[z.saleman as ySaleman, Y.ac,Y.Name,Y.phone, Y.fax,y.accountid, ]
        tsql=tsql+[z.ItemID, z.Batch, z.Desc, z.sr_no, z.packing, z.qty,]+iif(haskglibs,'a.kgs','0')+[ as kgs,]+iif(haskglibs,'a.libs','0')+[ as libs,z.bonus,z.rate,IIF(EMPTY(z.purchase),a.cost,z.purchase) as cost, a.trade ,x.dtime,x.srvchgs, z.discount, z.Total, z.expiry ] 
        tsql=tsql+[FROM (']+dbclocation+[cashsale') x LEFT join (']+dbclocation+[ACCOUNTS') Y ON (x.customer=y.accountid) ]   
        tsql=tsql+[LEFT JOIN (']+dbclocation+[cashdata') z ON (x.transid=z.transid) LEFT join (']+dbclocation+[itemmast') a ON (z.itemid=a.itemid) ]
        tsql=tsql+[LEFT JOIN (']+dbclocation+[accounts') d ON (x.customer=d.accountid) ]
        tsql=tsql+[WHERE x.transid==']+invnum+[' Order By z.transid, x.Date, z.sr_no INTO cursor ('printinvoice') readwrite ]
        &tsql
	ELSE
		tsql=[Select d.name as deposited,x.depositid, x.Total As PrdTotal,x.opt, space(9) as fbrinv, space(9) as fbrPOST, x.daysrno, x.discount As prdDisc, x.memdisc, ]
        tsql=tsql+[a.TAXPRATE, a.TAXRATE,a.extra, x.Payment, x.EXPAMT, x.transid, x.name As Memo,Space(9) As bill, ]
        tsql=tsql+[x.Date,x.ddate,x.address1,x.address2,x.SaleMan,x.customer, ]+ iif(lgetunit=.t.,'z.unit','0')+[ as zunit, ] + iif(xcompany.zctn=.t.,'z.ctn','space(2)')+[ as zctn, ]
        tsql=tsql+[z.saleman as ySaleman, Y.ac,Y.Name,Y.phone, Y.fax,y.accountid, ]
        tsql=tsql+[z.ItemID, z.Batch, z.Desc, z.sr_no, z.packing, z.qty,]+iif(haskglibs,'a.kgs','0')+[ as kgs,]+iif(haskglibs,'a.libs','0')+[ as libs,z.bonus,z.rate,IIF(EMPTY(z.purchase),a.cost,z.purchase) as cost, a.trade ,x.dtime,x.srvchgs, z.discount, z.Total, z.expiry ] 
        tsql=tsql+[FROM (']+dbclocation+[cashsale') x LEFT join (']+dbclocation+[ACCOUNTS') Y ON (x.customer=y.accountid) ]   
        tsql=tsql+[LEFT JOIN (']+dbclocation+[cashdata') z ON (x.transid=z.transid) LEFT join (']+dbclocation+[itemmast') a ON (z.itemid=a.itemid) ]
        tsql=tsql+[LEFT JOIN (']+dbclocation+[accounts') d ON (x.customer=d.accountid) ]
        tsql=tsql+[WHERE x.transid==']+invnum+[' Order By z.transid, x.Date, z.sr_no INTO cursor ('printinvoice') readwrite ]
        &tsql
	endif
    thedeposited=deposited
    =changeFieldStruc()
	IF EMPTY(memo) AND depositid<>[019]
		replace ALL memo WITH thedeposited
	ENDIF
	XDISCLABEL=[]
	rept_saleman=[]
    hastax=.f.
    hasdiscount=.f.
    haszunit = .f. 
    haszctn = .f.
    haskglibs=xcompany.usekglibs
    SCAN
        if not empty(kgs) or not empty(libs)
            haskglibs=xcompany.usekglibs
        endif
        if not empty(zunit)
            haszunit= .t.
        endif
        if not empty(zctn)
            haszctn= .t.
        endif
        if not empty(taxprate) or not empty(taxrate)
            hastax=.t. 
        endif
        if not empty(discount)
            hasdiscount=.t. 
        endif
        replace cost WITH NVL(cost,0), trade WITH NVL(trade,0), sr_no WITH RECNO()
		IF discount<>0
			XDISCLABEL=[DISC]
		ENDIF
		IF NOT EMPTY(saleman)
			rept_saleman=IIF(SEEK(saleman,[accounts],[accountid]),accounts.name,[])
		endif
        theuser=allt(opt)
	endscan
	If xcompany.haspart
		PartsValue=0
		partsQty=0
		Select 'printinvoice'
		Go Top
		Scan
			If Seek(ItemID,'itemmast','itemid') And itemmast.ispart
				PartsValue=PartsValue+(rate*qty-discount)
				partsQty=partsQty+qty
				Scatter Name saveit
				Delete
			ENDIF
			IF discount<>0
				XDISCLABEL=[DISC]
			endif
		Endscan
		If PartsValue<>0
			Append Blank
			Gather Name saveit
			Replace Desc With 'REPAIR CHARGES',;
				qty With partsQty,;
				rate With  (PartsValue)/partsQty,;
				total With PartsValue
		Endif
	Endif
    go top
    STORE 0 TO TOTALTAX, fbrservice, SERVICECHARGES, TOTALAMOUNT, PRODUCTDISCOUNT,;
     MEMBERDISCOUNT, NETAMOUNT, RECEIVEDAMOUNT, BALANCEAMOUNT
    IF type([searchresults.fbrinv])=[C] and not empty(searchresults.fbrinv)
        fbrservice=1
    endif
    SERVICECHARGES=srvchgs
    TOTALAMOUNT=ROUND(Printinvoice.prdtotal+printinvoice.srvchgs,0)
    PRODUCTDISCOUNT=prdDisc
    MEMBERDISCOUNT=memdisc
    netamount=ROUND(Printinvoice.prdtotal+fbrservice-Printinvoice.prdDISC-PRINTINVOICE.MEMDISC+printinvoice.srvchgs,0)
    RECEIVEDAMOUNT=iif(empty(payment),netamount,payment) 
    BALANCEAMOUNT=RECEIVEDAMOUNT-netamount 
    cspan=1
*************
%>
<!DocType HTML>
<html>
<html 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">
       <link href="bootstrap/bootstrap.min.css" rel="stylesheet" />
     <link rel="stylesheet" href="bootstrap/web-fonts-with-css/css/all.min.css">
  
    <style>
        
      body {
            font-family: 'Calibri', 'Gill Sans', 'Gill Sans MT', Calibri, 'Trebuchet MS', sans-serif;
           
       }
        @media print {
            .printnoshow {
                display: none;

            }
        }

        @media screen {
            .screennoshow {
                display: none;
            }
        }

        @media screen,
        print {
            .noshowall {
                display: none;
            }
        }
        @media print {
        #wrapper {
            position: absolute;
           /* left: 0;*/
            top: 0;
        }
    }
        #wrapper {
            width: <%=pagewidth%>;
            text-align: center;
            margin: auto;
        }
        @page {
         size: <%=pagewidth%> <%=pageheight%>;  /* width height */
      }
    h1, p, table {
        margin:auto;
    }
    TD {
        font-size: 10PT;
        padding-left: 2px;
        padding-right: 4px;
    }

    </style>
</head>
<body >
<div id='wrapper'>
         <div>
    <button type="button" class="btn btn-primary printnoshow" id="search" href="#" onclick="window.print();">Print
            <i class="fas fa-print"></i></button>
    <button type="button" class="btn btn-primary printnoshow" onclick="window.close()">
        <i class="fas fa-stop-circle"></i> Close
    </button>
    </div>
    <div style="margin:auto" class="screennoshow"><img src='images/logo.bmp'></div>
    <h1 style="margin:auto;font-stretch: ultra-expanded	"><%=xcompany.name%></h1>
  
        <p><%=allt(allt(xcompany.address1)+[ ]+allt(xcompany.address2))%></p>
        <%if not empty(xcompany.ntn)%>
        <p><span style="font-family: 'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif;font-size: large;font-weight: bold;text-decoration: underline;" ><%=iif(left(searchresults.depositid,3)=[019],[CASH SALE],[DEBIT SALE])%></span><br/>
        <%=xcompany.ntn%>
        </p>
        <%else%>
        <p><span style="font-family: 'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif;font-size: large;font-weight: bold;text-decoration: underline;" ><p><span style="font-family: 'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif;font-size: large;font-weight: bold;text-decoration: underline;" ><%=iif(left(searchresults.depositid,3)=[019],[CASH SALE],[DEBIT SALE])%></span><br/></span></p>
        <%endif%>
        <%if not empty(xcompany.fbrposid) or not empty(fbrnumberreceived)%>
            <p>
            <%if not empty(xcompany.fbrposid) %>
            <img src="bootstrap/images/fbr.png" style="height:1in;width:1.5in"/>
            <%endif%>
            <%if not empty(fbrnumberreceived)%>
            <img src="images/<%=fbrnumberreceived%>.bmp" style="height:0.75in"/> 
            <%endif%>
            </p>
            <%endif%>
            <%if type([searchresults.fbrinv])=[C] and not empty(searchresults.fbrinv)%>
            <p><%=[POSID# ]+ALLT(xcompany.fbrposid)%> <%=[FBR# ]+ALLT(fbrinv)%></p>
            <%endif%>
            <%if not empty(memo)%>
            <p><%=allt(memo)%></p>
            <%endif%>
            <p><%=[INV# ]+ALLT(TRANSID)+[ ]+ttoc(dtime)%></p>
            <table width="100%" BORDER="1PX" STYLE="border-collapse:collapse">
                <tr STYLE="font-weight: bold;">
                    <td>#</td>
                    <td>DETAILS</td>
                    <%if haskglibs%>
                        <TD >KGs</TD>
                        <TD >LIBs</TD>
                        <TD >CTNs</TD>
                        <TD >RATE/LIB</TD>
                        <TD >RATE/KG</TD>
                    <%else%>
                        <%if haszctn%>
                            <td>UNIT</td>    
                        <%endif%>
                        <%if haszunit%>
                            <td>PCS</td>    
                        <%endif%>
                        <TD >QTY</TD>
                        <TD >RATE</TD>
                    <%endif haskglibs%>
                    <%if hastax=.t.%>
                    <TD >TAX%</TD>
                    <TD >VAT</TD>
                    <%endif%>
                    <TD >TOTAL</TD>
                    <%if hasdiscount%>
                        <td>DISC</td>    
                        <TD>NET AMOUNT</TD>
                    <%endif%>
                </tr>
               
                <%SCAN%>
                <%
                  
                    ITEMTX=round(iif(empty(taxprate),taxrate*qty,(qty*rate)-(qty*rate)/(1+taxprate/100)),2)
                    if empty(taxprate)
                        thetaxprate=round((taxrate/(rate-taxrate))*100,2)
                        else
                        thetaxprate=taxprate
                    endif
                    SALEINCLUDINGTAX=qty*rate
                    saleexcludingtax=saleincludingtax-itemtx
                    totaltax=totaltax+itemtx
                    thechars=[]
                    textra=allt(nvl(extra,''))
                    for i=1 to len(textra)
                        thechars=thechars+[ | ]+subst(textra,i,1)+[ : ]+transform(asc(subst(textra,i,1)))
                    endfor
                    testunits=nvl(zunit,0)
                    kgqty=QTY*iif(empty(KGS),1,kgs)
                    libsqty=QTY*iif(empty(libs),2.20462,libs)
                    kgqty=icase(kgqty=round(kgqty,0),round(kgqty,0),kgqty=round(kgqty,2),round(kgqty,2),kgqty=round(kgqty,3),round(kgqty,3),round(kgqty,4))
                    libsqty=icase(libsqty=round(libsqty,0),round(libsqty,0),libsqty=round(libsqty,2),round(libsqty,2),libsqty=round(libsqty,3),round(libsqty,3),round(libsqty,4))
                    rateperlib=saleexcludingtax/libsqty
                    
                    if haskglibs
                        if empty(kgs) 
                            thectnqty=iif(empty(testunits),qty,testunits)
                        else
                            thectnqty=qty
                        endif
                        rateperkg=saleexcludingtax/kgqty
                        else
                        thectnqty=qty
                        rateperkg=saleexcludingtax/qty
                    endif
                    rateperkg=icase(rateperkg=round(rateperkg,0),round(rateperkg,0),round(rateperkg,2))
                    rateperlib=icase(rateperlib=round(rateperlib,0),round(rateperlib,0),round(rateperlib,2))
                %>
                   <TR>
                    <td STYLE="VERTICAL-ALIGN:TOP"><%=RECNO()%></td>
                    <td title="<%=thechars%>"><%=icase(isurdu=2,allt(DESC)+iif(empty(textra),[],[<br/>]+allt(textra)),isurdu=1,iif(empty(textra),allt(desc),allt(textra)),allt(desc))%></td>
                    
                    <%if haskglibs%>
                        <TD ALIGN="RIGHT" STYLE="VERTICAL-ALIGN:TOP"><%=iif(empty(KGQTY),'&nbsp;',KGQTY)%></TD>
                        <TD ALIGN="RIGHT" STYLE="VERTICAL-ALIGN:TOP"><%=iif(empty(libsQTY),'&nbsp;',libsQTY)%></TD>
                        <TD ALIGN="RIGHT" STYLE="VERTICAL-ALIGN:TOP"><%=iif(empty(thectnqty),'&nbsp;',thectnqty)%></TD>
                        <TD ALIGN="RIGHT" STYLE="VERTICAL-ALIGN:TOP"><%=iif(empty(rateperlib),'&nbsp;',rateperlib)%></TD>
                        <TD ALIGN="RIGHT" STYLE="VERTICAL-ALIGN:TOP"><%=iif(empty(rateperkg),'&nbsp;',rateperkg)%></TD>
                    <%else%>
                        <%if haszctn%>
                            <TD ALIGN="RIGHT" STYLE="VERTICAL-ALIGN:TOP"><%=zctn%></TD>    
                        <%endif%>
                        <%if haszunit%>
                            <TD ALIGN="RIGHT" STYLE="VERTICAL-ALIGN:TOP"><%=iif(empty(thectnqty),'&nbsp;',thectnqty)%></TD>    
                        <%endif%>
                        <TD ALIGN="RIGHT" STYLE="VERTICAL-ALIGN:TOP"><%=thectnqty%></TD>
                        <TD ALIGN="RIGHT" STYLE="VERTICAL-ALIGN:TOP"><%=rateperkg%></TD>
                    <%endif haskglibs%>
                    <%if hastax=.t.%>
                    <TD ALIGN="center" STYLE="VERTICAL-ALIGN:TOP"><%=iif(empty(thetaxprate),'&nbsp;',transform(thetaxprate)+[%])%></TD>
                    <TD ALIGN="RIGHT" STYLE="VERTICAL-ALIGN:TOP"><%=iif(empty(itemtx),'&nbsp;',transform(itemtx,'999999999.99'))%></TD>
                    <%endif%>
                     <TD ALIGN="RIGHT" STYLE="VERTICAL-ALIGN:TOP"><%=ROUND(qty*rate,0)%></TD>
                    <%
                        roundeddisc=icase(discount=round(discount,0),round(discount,0),round(discount,2))
                    %>
                    <%if hasdiscount%>
                        <td ALIGN="RIGHT" STYLE="VERTICAL-ALIGN:TOP"><%=iif(empty(roundeddisc),'&nbsp;',transform(roundeddisc))%></td>
                         <TD ALIGN="RIGHT" STYLE="VERTICAL-ALIGN:TOP"><%=ROUND(qty*rate-roundeddisc,0)%></TD>    
                    <%endif%>
                   </tr>
                <%ENDSCAN%>
               <tr>
                <td colspan='12' style="text-align:right;border-left-style:hidden;border-bottom-style:hidden;border-right-style:hidden;">
                <table align="right"> 
                    <%if hastax=.t.%> 
                    <%if totaltax<>0 %>
                        <tr><td colspan="<%=cspan%>" align='right' STYLE="FONT-WEIGHT:BOLD;FONT-STYLE:ITALIC;border-bottom-style: hidden;border-left-style: hidden;">TOTAL TAX</td><TD colspan="2" ALIGN='RIGHT' STYLE="FONT-WEIGHT:BOLD;padding-left: 20px;"><%=TOTALTAX%></TD></tr>
                    <%endif%>
                    <%endif%>
                    <%if fbrservice<>0 %>
                    <tr><td colspan="<%=cspan%>" align='right' STYLE="FONT-WEIGHT:BOLD;FONT-STYLE:ITALIC;border-bottom-style: hidden;border-left-style: hidden;">POS SERVICE CHARGES</td><TD colspan="2" ALIGN='RIGHT' STYLE="FONT-WEIGHT:BOLD;padding-left: 20px;"><%=fbrservice%></TD></tr>
                    <%endif%>
                    <%if SERVICECHARGES<>0 %>
                    <tr><td colspan="<%=cspan%>" align='right' STYLE="FONT-WEIGHT:BOLD;FONT-STYLE:ITALIC;border-bottom-style: hidden;border-left-style: hidden;">SERVICE CHARGES</td><TD colspan="2" ALIGN='RIGHT' STYLE="FONT-WEIGHT:BOLD;padding-left: 20px;"><%=SERVICECHARGES%></TD></tr>
                    <%endif%>
                    <tr ><td colspan="<%=cspan%>" align='right' STYLE="FONT-WEIGHT:BOLD;border-bottom-style: hidden;border-left-style: hidden;">TOTAL AMOUNT</td><TD colspan="2" ALIGN='RIGHT' STYLE="FONT-WEIGHT:BOLD;padding-left: 20px;"><%=TOTALAMOUNT+fbrservice+SERVICECHARGES%></TD></tr>
                    <%if round(PRODUCTDISCOUNT+MEMBERDISCOUNT,2)<>0 %>
                    <tr ><td colspan="<%=cspan%>" align='right' STYLE="FONT-WEIGHT:BOLD;border-bottom-style: hidden;border-left-style: hidden;">DISCOUNT</td><TD colspan="2" ALIGN='RIGHT' STYLE="FONT-WEIGHT:BOLD;padding-left: 20px;"><%=PRODUCTDISCOUNT+MEMBERDISCOUNT%></TD></tr>
                    <tr ><td colspan="<%=cspan%>" align='right' STYLE="FONT-WEIGHT:BOLD;border-bottom-style: hidden;border-left-style: hidden;">NET AMOUNT</td><TD colspan="2" ALIGN='RIGHT' STYLE="FONT-WEIGHT:BOLD;padding-left: 20px;"><%=TOTALAMOUNT+fbrservice+SERVICECHARGES-PRODUCTDISCOUNT-MEMBERDISCOUNT%></TD></tr>
                   <%endif%>
                </table>
                </td>
                </tr>
                </table>
           
            <DIV>
             <%
            LASTMESSAGE=[]
                IF NOT EMPTY(XCOMPANY.CUSTMSG1)
                    LASTMESSAGE=LASTMESSAGE+ALLT(XCOMPANY.CUSTMSG1)+[ ]
                ENDIF
                IF NOT EMPTY(XCOMPANY.CUSTMSG2)
                    LASTMESSAGE=LASTMESSAGE+ALLT(XCOMPANY.CUSTMSG2)+[ ]
                ENDIF
                IF NOT EMPTY(XCOMPANY.CUSTMSG3)
                    LASTMESSAGE=LASTMESSAGE+ALLT(XCOMPANY.CUSTMSG3)+[ ]
                ENDIF
                IF NOT EMPTY(XCOMPANY.CUSTMSG4)
                    LASTMESSAGE=LASTMESSAGE+ALLT(XCOMPANY.CUSTMSG4)+[ ]
                ENDIF
               
            %>
            <P STYLE="FONT-WEIGHT:BOLD;FONT-STYLE:ITALIC"><%='OPERATOR '+ALLT(theuser)+' '+IIF(EMPTY(REPT_SALEMAN),'','SOLD BY: '+REPT_SALEMAN)%></P>
            <%if NOT EMPTY(LASTMESSAGE) %>
                <P STYLE="FONT-WEIGHT:BOLD;FONT-STYLE:ITALIC"><%=LASTMESSAGE%></P>
            <%endif%>
        </DIV>
</div>

</body>
</html>
<%
CLOSE TABLES 
CLOSE DATABASES
USE IN SELECT([printinvoice])
%>