unit p_touchinv;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  cxGridCardView, cxGridDBCardView, Buttons, cxGridLevel,
  cxGridCustomTableView, cxGridTableView, cxGridDBTableView, cxClasses,
  cxControls, cxGridCustomView, cxGrid, ExtCtrls, RzPanel, StdCtrls, Mask,
  DBCtrls, Db, DBTables, RzButton, OoMisc, AdPort, cxStyles, Grids, DBGrids,
  SUIDlg, cxContainer,frxBDEComponents, cxEdit, cxLabel, cxDBLabel, RzLabel, RzDBLbl, Menus,
  IvDictio, IvMulti, cxPropertiesStore, cxInplaceContainer, cxVGrid, cxOI,
  ImgList, DBCGrids, EnJpgGr, frxpngimage, ComCtrls, RzEdit, RzDBEdit,
  RzStatus;

type
  Tf_touchinv = class(TForm)
    RzPanel2: TRzPanel;
    tttt: TcxGrid;
    ttttDBTableView1: TcxGridDBTableView;
    ttttDBTableView1DESCR: TcxGridDBColumn;
    ttttDBTableView1FRAC: TcxGridDBColumn;
    ttttDBTableView1TOTAL: TcxGridDBColumn;
    ttttLevel1: TcxGridLevel;
    RzPanel3: TRzPanel;
    RzPanel4: TRzPanel;
    cxGrid1: TcxGrid;
    cxGrid1DBCardView1: TcxGridDBCardView;
    cxGrid1DBCardView1Row1: TcxGridDBCardViewRow;
    cxGrid1DBCardView1Row2: TcxGridDBCardViewRow;
    cxGrid1Level1: TcxGridLevel;
    RzPanel5: TRzPanel;
    categ: TQuery;
    dcateg: TDataSource;
    stock: TQuery;
    dstock: TDataSource;
    stockITEM: TStringField;
    stockDESCR1: TStringField;
    stockDESCR2: TStringField;
    stockCATEGORY: TStringField;
    stockSUBCAT1: TStringField;
    stockSUBCAT2: TStringField;
    stockWHEREIS: TStringField;
    stockSUPPLIER: TStringField;
    stockMASDAR: TStringField;
    stockPACK: TFloatField;
    stockBCOSTUS: TFloatField;
    stockBCOSTLC: TFloatField;
    stockPOSPRICE1: TFloatField;
    stockSALESCURRID: TIntegerField;
    stockPRICEA: TFloatField;
    stockPRICEB: TFloatField;
    stockPRICEC: TFloatField;
    stockPRICED: TFloatField;
    stockPRICEE: TFloatField;
    stockPRICEF: TFloatField;
    stockBARCODE1: TStringField;
    stockBARCODE2: TStringField;
    stockBARCODE3: TStringField;
    stockBARCODE4: TStringField;
    stockPACK1: TFloatField;
    stockPACK2: TFloatField;
    stockPACK3: TFloatField;
    stockPACK4: TFloatField;
    stockPRICE1: TFloatField;
    stockPRICE2: TFloatField;
    stockPRICE3: TFloatField;
    stockPRICE4: TFloatField;
    stockMINSTOCK: TFloatField;
    stockMAXSTOCK: TFloatField;
    stockGWEIGHT: TFloatField;
    stockNWEIGHT: TFloatField;
    stockVOLUME: TFloatField;
    stockSALESDISC: TFloatField;
    stockPURCHDISC: TFloatField;
    stockSUNIT: TStringField;
    stockVAT: TFloatField;
    stockBQTY: TFloatField;
    stockQTY: TFloatField;
    stockCDATE: TDateTimeField;
    stockYESNO: TStringField;
    stockCOSTUS: TFloatField;
    stockCOSTLC: TFloatField;
    stockLCOST: TFloatField;
    stockSTYPE: TIntegerField;
    stockBUY: TFloatField;
    stockPAY: TFloatField;
    stockRBUY: TFloatField;
    stockRPAY: TFloatField;
    stockADJUSTIN: TFloatField;
    stockADJUSTOUT: TFloatField;
    stockPRODIN: TFloatField;
    stockPRODOUT: TFloatField;
    stockPROFORMAQTY: TFloatField;
    stockORDERQTY: TFloatField;
    stockOQTY: TFloatField;
    stockJQTY: TFloatField;
    stockUSER_: TStringField;
    stockMIZANE: TIntegerField;
    stockMIZANE1: TIntegerField;
    stockMIZANE2: TIntegerField;
    stockMIZANE3: TIntegerField;
    stockMIZANE4: TIntegerField;
    stockOFRE: TIntegerField;
    stockCARTOON: TFloatField;
    locstock: TTable;
    dlocstock: TDataSource;
    ccc: TApdComPort;
    cxStyleRepository1: TcxStyleRepository;
    cxStyle1: TcxStyle;
    cxStyle2: TcxStyle;
    cxStyle3: TcxStyle;
    cxStyle4: TcxStyle;
    RzBitBtn5: TRzBitBtn;
    RzBitBtn7: TRzBitBtn;
    RzBitBtn9: TRzBitBtn;
    RzBitBtn10: TRzBitBtn;
    RzBitBtn11: TRzBitBtn;
    RzBitBtn12: TRzBitBtn;
    RzBitBtn13: TRzBitBtn;
    RzBitBtn14: TRzBitBtn;
    RzBitBtn15: TRzBitBtn;
    RzBitBtn16: TRzBitBtn;
    RzBitBtn2: TRzBitBtn;
    RzPanel6: TRzPanel;
    RzPanel7: TRzPanel;
    mypass: TsuiInputDialog;
    RzPanel8: TRzPanel;
    cxDBLabel2: TcxDBLabel;
    cxLabel1: TcxLabel;
    cxDBLabel3: TcxDBLabel;
    RzBitBtn23: TRzBitBtn;
    RzLabel1: TRzLabel;
    RzLabel2: TRzLabel;
    cxGrid1DBCardView1Row3: TcxGridDBCardViewRow;
    cxGrid1DBCardView1Row4: TcxGridDBCardViewRow;
    loccateg: TQuery;
    dloccateg: TDataSource;
    cxStyle5: TcxStyle;
    ttttDBTableView1Column1: TcxGridDBColumn;
    cxStyle6: TcxStyle;
    cxStyle7: TcxStyle;
    PopupMenu1: TPopupMenu;
    OpenInvoiceAfterPrint1: TMenuItem;
    RzLabel3: TRzLabel;
    stockMYPRN: TStringField;
    DataSource1: TDataSource;
    IvTranslator1: TIvTranslator;
    toushview: TcxPropertiesStore;
    PopupMenu2: TPopupMenu;
    Design1: TMenuItem;
    OpenDrawer1: TMenuItem;
    STOCK2: TQuery;
    STOCK2ITEM: TStringField;
    STOCK2DESCR1: TStringField;
    STOCK2DESCR2: TStringField;
    STOCK2CATEGORY: TStringField;
    STOCK2SUBCAT1: TStringField;
    STOCK2SUBCAT2: TStringField;
    STOCK2WHEREIS: TStringField;
    STOCK2SUPPLIER: TStringField;
    STOCK2MASDAR: TStringField;
    STOCK2PACK: TFloatField;
    STOCK2BCOSTUS: TFloatField;
    STOCK2BCOSTLC: TFloatField;
    STOCK2POSPRICE1: TFloatField;
    STOCK2SALESCURRID: TIntegerField;
    STOCK2PRICEA: TFloatField;
    STOCK2PRICEB: TFloatField;
    STOCK2PRICEC: TFloatField;
    STOCK2PRICED: TFloatField;
    STOCK2PRICEE: TFloatField;
    STOCK2PRICEF: TFloatField;
    STOCK2BARCODE1: TStringField;
    STOCK2BARCODE2: TStringField;
    STOCK2BARCODE3: TStringField;
    STOCK2BARCODE4: TStringField;
    STOCK2PACK1: TFloatField;
    STOCK2PACK2: TFloatField;
    STOCK2PACK3: TFloatField;
    STOCK2PACK4: TFloatField;
    STOCK2PRICE1: TFloatField;
    STOCK2PRICE2: TFloatField;
    STOCK2PRICE3: TFloatField;
    STOCK2PRICE4: TFloatField;
    STOCK2MINSTOCK: TFloatField;
    STOCK2MAXSTOCK: TFloatField;
    STOCK2GWEIGHT: TFloatField;
    STOCK2NWEIGHT: TFloatField;
    STOCK2VOLUME: TFloatField;
    STOCK2SALESDISC: TFloatField;
    STOCK2PURCHDISC: TFloatField;
    STOCK2SUNIT: TStringField;
    STOCK2VAT: TFloatField;
    STOCK2BQTY: TFloatField;
    STOCK2QTY: TFloatField;
    STOCK2CDATE: TDateTimeField;
    STOCK2YESNO: TStringField;
    STOCK2COSTUS: TFloatField;
    STOCK2COSTLC: TFloatField;
    STOCK2LCOST: TFloatField;
    STOCK2STYPE: TIntegerField;
    STOCK2BUY: TFloatField;
    STOCK2PAY: TFloatField;
    STOCK2RBUY: TFloatField;
    STOCK2RPAY: TFloatField;
    STOCK2ADJUSTIN: TFloatField;
    STOCK2ADJUSTOUT: TFloatField;
    STOCK2PRODIN: TFloatField;
    STOCK2PRODOUT: TFloatField;
    STOCK2PROFORMAQTY: TFloatField;
    STOCK2ORDERQTY: TFloatField;
    STOCK2OQTY: TFloatField;
    STOCK2JQTY: TFloatField;
    STOCK2USER_: TStringField;
    STOCK2MIZANE: TIntegerField;
    STOCK2MIZANE1: TIntegerField;
    STOCK2MIZANE2: TIntegerField;
    STOCK2MIZANE3: TIntegerField;
    STOCK2MIZANE4: TIntegerField;
    STOCK2OFRE: TIntegerField;
    STOCK2CARTOON: TFloatField;
    STOCK2LCOST1: TFloatField;
    STOCK2LCOST2: TFloatField;
    STOCK2LCOST3: TFloatField;
    STOCK2LCOST4: TFloatField;
    STOCK2MYPRN: TStringField;
    STOCK2MYCOSTUS: TFloatField;
    STOCK2MYCOSTLC: TFloatField;
    STOCK2POSORDER: TIntegerField;
    STOCK2OLDPRICE: TFloatField;
    STOCK2DISC2: TFloatField;
    ttttDBTableView1Column2: TcxGridDBColumn;
    RzBitBtn17: TRzBitBtn;
    cxDBLabel1: TcxDBLabel;
    RzBitBtn18: TRzBitBtn;
    HardwareCashopen1: TMenuItem;
    ChandeChef1: TMenuItem;
    cxStyle8: TcxStyle;
    DBNavigator1: TDBNavigator;
    cxStyle9: TcxStyle;
    categID: TIntegerField;
    categMID: TIntegerField;
    categDESCR: TStringField;
    categMYRATE: TFloatField;
    categMYRATE2: TFloatField;
    categABREV: TStringField;
    categSITE: TStringField;
    categSID: TStringField;
    DBCtrlGrid1: TDBCtrlGrid;
    RzDBLabel2: TRzDBLabel;
    RzPanel9: TRzPanel;
    RzBitBtn3: TRzBitBtn;
    RzBitBtn4: TRzBitBtn;
    RzBitBtn6: TRzBitBtn;
    RzBitBtn1: TRzBitBtn;
    rzcedit: TRzBitBtn;
    btnclose: TRzBitBtn;
    RzBitBtn8: TRzBitBtn;
    RzBitBtn19: TRzBitBtn;
    RzStatusBar1: TRzStatusBar;
    RzDBLabel1: TRzDBLabel;
    RzStatusPane1: TRzStatusPane;
    RzFieldStatus2: TRzFieldStatus;
    RzDBEdit2: TRzDBEdit;
    RzDBLabel3: TRzDBLabel;
    RzDBGrid1: TDBGrid;
    RzBitBtn20: TRzBitBtn;
    cxDBLabel4: TcxDBLabel;
    procedure FormShow(Sender: TObject);
    procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
    procedure cxGrid1DBCardView1CellClick(Sender: TcxCustomGridTableView;
      ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton;
      AShift: TShiftState; var AHandled: Boolean);
    procedure RzDBGrid1Exit(Sender: TObject);
    procedure RzBitBtn8Click(Sender: TObject);
    procedure btncloseClick(Sender: TObject);
    procedure RzBitBtn15Click(Sender: TObject);
    procedure RzBitBtn1Click(Sender: TObject);
    procedure RzBitBtn16Click(Sender: TObject);
    procedure RzBitBtn4Click(Sender: TObject);
    procedure RzBitBtn3Click(Sender: TObject);
    procedure RzBitBtn23Click(Sender: TObject);
    procedure RzBitBtn6Click(Sender: TObject);
    procedure RzBitBtn2Click(Sender: TObject);
    procedure cxGrid1DBCardView1StylesGetContentStyle(
      Sender: TcxCustomGridTableView; ARecord: TcxCustomGridRecord;
      AItem: TcxCustomGridTableItem; out AStyle: TcxStyle);
    procedure RzLabel2Click(Sender: TObject);
    procedure ttttDBTableView1StylesGetContentStyle(
      Sender: TcxCustomGridTableView; ARecord: TcxCustomGridRecord;
      AItem: TcxCustomGridTableItem; out AStyle: TcxStyle);
    procedure RzBitBtn22Click(Sender: TObject);
    procedure OpenInvoiceAfterPrint1Click(Sender: TObject);
    procedure RzLabel3Click(Sender: TObject);
    procedure RzLabel1Click(Sender: TObject);
    procedure rzceditClick(Sender: TObject);
    procedure categBeforeOpen(DataSet: TDataSet);
    procedure Design1Click(Sender: TObject);
    procedure cxLabel1Click(Sender: TObject);
    procedure ttttDBTableView1DblClick(Sender: TObject);
    procedure OpenDrawer1Click(Sender: TObject);
    procedure RzBitBtn18Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure HardwareCashopen1Click(Sender: TObject);
    procedure ChandeChef1Click(Sender: TObject);
    procedure stockBeforeOpen(DataSet: TDataSet);
    procedure cxGridDBCardView1StylesGetContentStyle(
      Sender: TcxCustomGridTableView; ARecord: TcxCustomGridRecord;
      AItem: TcxCustomGridTableItem; out AStyle: TcxStyle);
    procedure RzBitBtn19Click(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure RzBitBtn20Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  f_touchinv: Tf_touchinv; iii,myprn:integer;

implementation

uses p_posmodule,  p_repmodule, p_helpdesk, p_tableno, p_mynotes,
  p_closeing, P_pasdlg, p_barcode, p_item, p_tablenoC, p_mychef, p_mytoush,
  p_selbar, p_telep;

{$R *.DFM}

procedure Tf_touchinv.FormShow(Sender: TObject);
begin
 try
if posmodule.CONFIGSCLOSINGREST.AsString='True' then
begin
  RzBitBtn3.Visible:=false;
    RzBitBtn19.Visible:=false;
   RzBitBtn16.Visible:=false;
   Rzcedit.Visible:=false;
   OpenInvoiceAfterPrint1.Visible:=false;

  end;


 if posmodule.CONFIGSWHEREIS.AsInteger=0 then
stock.SQL.Strings[1]:='where category=:category and STYPE=26'
else
stock.SQL.Strings[1]:='where category=:category and STYPE=26 and whereis='''+posmodule.CONFIGSWHEREIS.AsString+'''';


categ.open;
stock.open;
locstock.open;
loccateg.open;

if posmodule.CURRFACPRN.AsString='True' then
begin
btnclose.enabled:=true;
rzcedit.enabled:=true;
end;

//cxGridDBCardView1.RowCount:=posmodule.CONFIGSCATCOL.AsInteger;
toushview.active:=posmodule.touser.FieldByName('UDESIGN').AsBoolean;
//cxGridDBCardView1.OptionsView.CardIndent:=posmodule.CONFIGSCATCOL.AsInteger;
posmodule.items.last;

if iii=1 then
RzBitBtn23Click(RzBitBtn23);


  except
  end;

end;

procedure Tf_touchinv.FormCloseQuery(Sender: TObject;
  var CanClose: Boolean);
begin
try
stock.close;
categ.close;
loccateg.close;
locstock.close;
//modalResult:=mrok;
 except
 end;
 end;

procedure Tf_touchinv.cxGrid1DBCardView1CellClick(
  Sender: TcxCustomGridTableView;
  ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton;
  AShift: TShiftState; var AHandled: Boolean);
begin
inherited;
AHandled:=true ;
if (posmodule.CURRFACPRN.AsString='True') or
   (posmodule.CURRFACPAID.AsString='True') then
exit;

if abutton=mbRight then exit;

if stoCK.IsEmpty=false then
begin
if posmodule.CONFIGSMYDEL.AsInteger=1 then
begin
if posmodule.items.Locate('item',stoCKITEM.AsString,[]) then
begin

posmodule.items.edit;
posmodule.itemsqty.AsCurrency:=posmodule.itemsqty.AsCurrency+1;

end
else
begin

posmodule.items.append;
posmodule.itemsmid.AsString:=posmodule.invoiceid.AsString;
posmodule.itemssite.AsString:=posmodule.invoicesite.AsString;
posmodule.itemsfdate.AsString:=posmodule.invoicefdate.AsString;

posmodule.itemssid.AsString:=posmodule.invoicesid.AsString;
posmodule.itemscontact.AsString:=posmodule.invoicecontact.AsString;
posmodule.itemssalesman.AsString:=posmodule.invoicesalesman.AsString;

posmodule.itemsdiscount.AsCurrency :=stockSALESDISC.AsCurrency;
posmodule.itemsvat.AsCurrency:=stockvat.AsCurrency;
posmodule.itemsdescr.AsString:=stockdescr1.AsString;
posmodule.itemsstqty.AsCurrency:=stockQTY.AsCurrency;
posmodule.itemsMYPRN.AsString:=stockMYPRN.AsString;
posmodule.itemsitem.AsString:=stockitem.AsString;
posmodule.itemsPACK.AsCurrency:=1;
posmodule.itemsqty.AsCurrency:=1;
posmodule.itemsfrac.AsCurrency:=0;

posmodule.itemscostus.AsCurrency:=stockcostus.AsCurrency;
posmodule.itemscostlc.AsCurrency:=stockcostlc.AsCurrency;
//posmodule.itemssttype.AsString:=posmodule.detstocksttype.AsString;
posmodule.itemsyesno.AsString:=stockyesno.AsString;
posmodule.itemsbarcode.AsString:=stockitem.AsString;
posmodule.itemsqty.AsCurrency:=1;
IF POSMODULE.CONFIGSPRICE.AsInteger=5 THEN
begin
if stockPRICEE.AsCurrency<>0 then
posmodule.itemsprice.AsCurrency:=stockPRICEE.AsCurrency
else
posmodule.itemsprice.AsCurrency:=stockPOSPRICE1.AsCurrency;
end
ELSE
posmodule.itemsprice.AsCurrency:=stockPOSPRICE1.AsCurrency;
posmodule.itemsCATREGORYID.AsInteger:=stockCATEGORY.AsInteger;

end;


end
else
begin


posmodule.items.append;
posmodule.itemsmid.AsString:=posmodule.invoiceid.AsString;
posmodule.itemssite.AsString:=posmodule.invoicesite.AsString;
posmodule.itemsfdate.AsString:=posmodule.invoicefdate.AsString;

posmodule.itemssid.AsString:=posmodule.invoicesid.AsString;
posmodule.itemscontact.AsString:=posmodule.invoicecontact.AsString;
posmodule.itemssalesman.AsString:=posmodule.invoicesalesman.AsString;

posmodule.itemsdiscount.AsCurrency :=stockSALESDISC.AsCurrency;
posmodule.itemsvat.AsCurrency:=stockvat.AsCurrency;
posmodule.itemsdescr.AsString:=stockdescr1.AsString;
posmodule.itemsstqty.AsCurrency:=stockQTY.AsCurrency;
posmodule.itemsMYPRN.AsString:=stockMYPRN.AsString;
posmodule.itemsitem.AsString:=stockitem.AsString;
posmodule.itemsPACK.AsCurrency:=1;
posmodule.itemsqty.AsCurrency:=1;
posmodule.itemsfrac.AsCurrency:=0;

posmodule.itemscostus.AsCurrency:=stockcostus.AsCurrency;
posmodule.itemscostlc.AsCurrency:=stockcostlc.AsCurrency;
//posmodule.itemssttype.AsString:=posmodule.detstocksttype.AsString;
posmodule.itemsyesno.AsString:=stockyesno.AsString;
posmodule.itemsbarcode.AsString:=stockitem.AsString;
posmodule.itemsqty.AsCurrency:=1;
IF POSMODULE.CONFIGSPRICE.AsInteger=5 THEN
begin
if stockPRICEE.AsCurrency<>0 then
posmodule.itemsprice.AsCurrency:=stockPRICEE.AsCurrency
else
posmodule.itemsprice.AsCurrency:=stockPOSPRICE1.AsCurrency;
end
ELSE
posmodule.itemsprice.AsCurrency:=stockPOSPRICE1.AsCurrency;
 if stockBARCODE1.AsString<>'' then
begin
//Application.CreateForm(Tf_selbar,f_selbar);
  if not assigned(f_selbar) then
f_selbar:=tf_selbar.create(self);
f_selbar.DataSource1.DataSet:=stock;
f_selbar.ShowModal  ;
try
if p_selbar.mysel=0 then
begin
posmodule.itemsqty.AsCurrency:=1;
posmodule.itemspack.AsCurrency:=1;
posmodule.itemsPRICE.AsCurrency:=stockPOSPRICE1.AsCurrency;


end
else
if p_selbar.mysel=1 then
begin
posmodule.itemsqty.AsCurrency:=1;
posmodule.itemspack.AsCurrency:=stockPACK1.AsCurrency;
posmodule.itemsPRICE.AsCurrency:=stockPRICE1.AsCurrency;


end
else
if p_selbar.mysel=2 then
begin
posmodule.itemsqty.AsCurrency:=1;
posmodule.itemspack.AsCurrency:=stockPACK2.AsCurrency;
posmodule.itemsPRICE.AsCurrency:=stockPRICE2.AsCurrency;


end
else
if p_selbar.mysel=3 then
begin
posmodule.itemsqty.AsCurrency:=1;
posmodule.itemspack.AsCurrency:=stockPACK3.AsCurrency;
posmodule.itemsPRICE.AsCurrency:=stockPRICE3.AsCurrency;


end
else
if p_selbar.mysel=4 then
begin
posmodule.itemsqty.AsCurrency:=1;
posmodule.itemspack.AsCurrency:=stockPACK4.AsCurrency;
posmodule.itemsPRICE.AsCurrency:=stockPRICE4.AsCurrency;
end;








except
end;
 if  assigned(f_selbar) then
freeandnil(f_selbar);

end;



posmodule.itemsCATREGORYID.AsInteger:=stockCATEGORY.AsInteger;
 end;
posmodule.items.post;

try
RzDBGrid1.OnExit(RzDBGrid1);
except
end;
END;

AHandled:=true ;

end;


procedure Tf_touchinv.RzDBGrid1Exit(Sender: TObject);

var cc,i,II:integer;c1,cvat,CDISC,cpro:currency;mycomp:string[20];
   s:string;
begin

cvat:=0;
cc:=0;
c1:=0;
cpro:=0;
CDISC:=0;
posmodulE.items.DisableControls;
try
posmodulE.items.First;

FOR II:=1 TO posmodulE.items.RecordCount do
begin
posmodulE.items.edit;
posmodulE.itemsqty.AsCurrency:=posmodulE.itemsqty.AsCurrency+1-1;
posmodulE.items.post;
c1:=c1+posmodulE.itemstotal.AsCurrency;
cc:=cc+1;

cvat:=cvat+posmodulE.itemsvatamount.ascurrency;


posmodulE.items.Next;
end;
posmodulE.CURRFAC.edit;
posmodulE.CURRFACvat.AsCurrency:=cvat;

if (POSmodule.CONFIGSVATTYPE.AsString = 'TTC' )  then
posmodulE.CURRFACSUBTOTAL.AsCurrency:=c1-cvat
else
posmodulE.CURRFACSUBTOTAL.AsCurrency:=c1;

 posmodule.CURRFACtotal.AsCurrency:=posmodulE.CURRFACSUBTOTAL.AsCurrency+
posmodulE.CURRFACvat.AsCurrency-posmodulE.CURRFACdiscount.AsCurrency ;






posmodulE.CURRFAC.post;

  except
  end;
posmodulE.items.EnableControls;





 try
         mycomp:=posmodule.tocomp.fieldbyname('NAME1').AsString;
         mycomp:=mycomp+'....................';

         if posmodule.CONFIGSMYCOM.AsInteger<>0 then
         begin
         ccc.PutString(#$1b#$40);

  ccc.PutString(mycomp+'Your amount = '+posmodule.CURRFACtotal.AsString);

       end;
        except
        end;

end;

procedure Tf_touchinv.RzBitBtn8Click(Sender: TObject);
var s:string;
begin
try
RzBitBtn8.Enabled:=FALSE;

 try
RzDBGrid1.OnExit(RzDBGrid1);
except
end;

s:=repmodule.frxReport1.PrintOptions.Printer;
  try

 if FileExists(extractfilepath(application.exename)+'orderchef.fr3') then
begin


repmodule.frxReport1.LoadFromFile(extractfilepath(application.exename)+'orderchef.fr3') ;

if posmodule.CONFIGSORDERCHEF.AsString<>'' then
repmodule.frxReport1.PrintOptions.Printer:=posmodule.CONFIGSORDERCHEF.AsString;

repmodule.frxReport1.PrintOptions.ShowDialog:=false;
repmodule.frxReport1.PrepareReport;
//repmodule.frxReport1.PrintOptions.Printer:='Default';

(repmodule.frxReport1.GetDataset('BDEtable1') as tfrxbdeQUERY ).Query.OPEN;
IF (repmodule.frxReport1.GetDataset('BDEtable1') as tfrxbdeQUERY ).Query.IsEmpty=FALSE THEN

repmodule.frxReport1.print;


end;
except
end;

 try

 if FileExists(extractfilepath(application.exename)+'orderchef2.fr3') then
begin


repmodule.frxReport1.LoadFromFile(extractfilepath(application.exename)+'orderchef2.fr3') ;

if posmodule.CONFIGSORDERCHEF.AsString<>'' then
repmodule.frxReport1.PrintOptions.Printer:=posmodule.CONFIGSORDERCHEF.AsString;

repmodule.frxReport1.PrintOptions.ShowDialog:=false;
repmodule.frxReport1.PrepareReport;
//repmodule.frxReport1.PrintOptions.Printer:='Default';

(repmodule.frxReport1.GetDataset('BDEtable1') as tfrxbdeQUERY ).Query.OPEN;
IF (repmodule.frxReport1.GetDataset('BDEtable1') as tfrxbdeQUERY ).Query.IsEmpty=FALSE THEN

repmodule.frxReport1.print;


end;
except
end;



 try

 if FileExists(extractfilepath(application.exename)+'orderchef3.fr3') then
begin


repmodule.frxReport1.LoadFromFile(extractfilepath(application.exename)+'orderchef3.fr3') ;

if posmodule.CONFIGSORDERCHEF.AsString<>'' then
repmodule.frxReport1.PrintOptions.Printer:=posmodule.CONFIGSORDERCHEF.AsString;

repmodule.frxReport1.PrintOptions.ShowDialog:=false;
repmodule.frxReport1.PrepareReport;
//repmodule.frxReport1.PrintOptions.Printer:='Default';

(repmodule.frxReport1.GetDataset('BDEtable1') as tfrxbdeQUERY ).Query.OPEN;
IF (repmodule.frxReport1.GetDataset('BDEtable1') as tfrxbdeQUERY ).Query.IsEmpty=FALSE THEN

repmodule.frxReport1.print;


end;
except
end;









try
//repmodule.frxReport1.LoadFromFile(extractfilepath(application.exename)+'touchinv.fr3') ;




repmodule.frxReport1.LoadFromFile(extractfilepath(application.exename)+'touchorder.fr3') ;
repmodule.frxReport1.PrintOptions.ShowDialog:=false;

repmodule.frxReport1.ShowProgress:=false;
if posmodule.CONFIGSKITCHEN.AsString<>'' then
begin
(repmodule.frxReport1.GetDataset('BDEtable1') as tfrxbdeQUERY ).filter:='myprn=''KITCHEN''';


repmodule.frxReport1.PrintOptions.Printer:=posmodule.CONFIGSKITCHEN.AsString;


repmodule.frxReport1.PrepareReport;
(repmodule.frxReport1.GetDataset('BDEtable1') as tfrxbdeQUERY ).Query.OPEN;
IF (repmodule.frxReport1.GetDataset('BDEtable1') as tfrxbdeQUERY ).Query.IsEmpty=FALSE THEN

repmodule.frxReport1.print;
end;
if posmodule.CONFIGSBAR.AsString<>'' then
begin
(repmodule.frxReport1.GetDataset('BDEtable1') as tfrxbdeQUERY ).filter:='myprn=''BAR''';

repmodule.frxReport1.PrintOptions.Printer:=posmodule.CONFIGSBAR.AsString;

repmodule.frxReport1.PrepareReport;
(repmodule.frxReport1.GetDataset('BDEtable1') as tfrxbdeQUERY ).Query.OPEN;
IF (repmodule.frxReport1.GetDataset('BDEtable1') as tfrxbdeQUERY ).Query.IsEmpty=FALSE THEN
repmodule.frxReport1.print;
end;
if posmodule.CONFIGSCOCKTAIL.AsString<>'' then
begin
(repmodule.frxReport1.GetDataset('BDEtable1') as tfrxbdeQUERY ).filter:='myprn=''COCKTAIL''';
repmodule.frxReport1.PrintOptions.Printer:=posmodule.CONFIGSCOCKTAIL.AsString;
repmodule.frxReport1.PrepareReport;
(repmodule.frxReport1.GetDataset('BDEtable1') as tfrxbdeQUERY ).Query.OPEN;
IF (repmodule.frxReport1.GetDataset('BDEtable1') as tfrxbdeQUERY ).Query.IsEmpty=FALSE THEN
repmodule.frxReport1.print;
end;
if posmodule.CONFIGSFASTFOOD.AsString<>'' then
begin
(repmodule.frxReport1.GetDataset('BDEtable1') as tfrxbdeQUERY ).filter:='myprn=''FAST FOOD''';
repmodule.frxReport1.PrintOptions.Printer:=posmodule.CONFIGSFASTFOOD.AsString;
repmodule.frxReport1.PrepareReport;
(repmodule.frxReport1.GetDataset('BDEtable1') as tfrxbdeQUERY ).Query.OPEN;
IF (repmodule.frxReport1.GetDataset('BDEtable1') as tfrxbdeQUERY ).Query.IsEmpty=FALSE THEN
repmodule.frxReport1.print;
end;
if posmodule.CONFIGSOVEN.AsString<>'' then
begin
(repmodule.frxReport1.GetDataset('BDEtable1') as tfrxbdeQUERY ).filter:='myprn=''OVEN''';
repmodule.frxReport1.PrintOptions.Printer:=posmodule.CONFIGSOVEN.AsString;
repmodule.frxReport1.PrepareReport;
(repmodule.frxReport1.GetDataset('BDEtable1') as tfrxbdeQUERY ).Query.OPEN;
IF (repmodule.frxReport1.GetDataset('BDEtable1') as tfrxbdeQUERY ).Query.IsEmpty=FALSE THEN
repmodule.frxReport1.print;
end;
if posmodule.CONFIGSBOUCHERY.AsString<>'' then
begin
(repmodule.frxReport1.GetDataset('BDEtable1') as tfrxbdeQUERY ).filter:='myprn=''BOUCHERY''';
repmodule.frxReport1.PrintOptions.Printer:=posmodule.CONFIGSBOUCHERY.AsString;
repmodule.frxReport1.PrepareReport;
(repmodule.frxReport1.GetDataset('BDEtable1') as tfrxbdeQUERY ).Query.OPEN;
IF (repmodule.frxReport1.GetDataset('BDEtable1') as tfrxbdeQUERY ).Query.IsEmpty=FALSE THEN
repmodule.frxReport1.print;
end;
if posmodule.CONFIGSSNACK.AsString<>'' then
begin
(repmodule.frxReport1.GetDataset('BDEtable1') as tfrxbdeQUERY ).filter:='myprn=''SNACK''';
repmodule.frxReport1.PrintOptions.Printer:=posmodule.CONFIGSSNACK.AsString;
repmodule.frxReport1.PrepareReport;
(repmodule.frxReport1.GetDataset('BDEtable1') as tfrxbdeQUERY ).Query.OPEN;
IF (repmodule.frxReport1.GetDataset('BDEtable1') as tfrxbdeQUERY ).Query.IsEmpty=FALSE THEN
repmodule.frxReport1.print;
end;
if posmodule.CONFIGSCAFETERIA.AsString<>'' then
begin
(repmodule.frxReport1.GetDataset('BDEtable1') as tfrxbdeQUERY ).filter:='myprn=''CAFETERIA''';
repmodule.frxReport1.PrintOptions.Printer:=posmodule.CONFIGSCAFETERIA.AsString;
repmodule.frxReport1.PrepareReport;
(repmodule.frxReport1.GetDataset('BDEtable1') as tfrxbdeQUERY ).Query.OPEN;
IF (repmodule.frxReport1.GetDataset('BDEtable1') as tfrxbdeQUERY ).Query.IsEmpty=FALSE THEN
repmodule.frxReport1.print;
end;
if posmodule.CONFIGSPATESSERIE.AsString<>'' then
begin
(repmodule.frxReport1.GetDataset('BDEtable1') as tfrxbdeQUERY ).filter:='myprn=''PATESSERIE''';
repmodule.frxReport1.PrintOptions.Printer:=posmodule.CONFIGSPATESSERIE.AsString;
repmodule.frxReport1.PrepareReport;
(repmodule.frxReport1.GetDataset('BDEtable1') as tfrxbdeQUERY ).Query.OPEN;
IF (repmodule.frxReport1.GetDataset('BDEtable1') as tfrxbdeQUERY ).Query.IsEmpty=FALSE THEN
repmodule.frxReport1.print;
end;
if posmodule.CONFIGSPIZZA.AsString<>'' then
begin
(repmodule.frxReport1.GetDataset('BDEtable1') as tfrxbdeQUERY ).filter:='myprn=''PIZZA''';
repmodule.frxReport1.PrintOptions.Printer:=posmodule.CONFIGSPIZZA.AsString;
repmodule.frxReport1.PrepareReport;
(repmodule.frxReport1.GetDataset('BDEtable1') as tfrxbdeQUERY ).Query.OPEN;
IF (repmodule.frxReport1.GetDataset('BDEtable1') as tfrxbdeQUERY ).Query.IsEmpty=FALSE THEN
repmodule.frxReport1.print;
end;
if posmodule.CONFIGSSHISHAZ.AsString<>'' then
begin
(repmodule.frxReport1.GetDataset('BDEtable1') as tfrxbdeQUERY ).filter:='myprn=''SHISHAZ''';
repmodule.frxReport1.PrintOptions.Printer:=posmodule.CONFIGSSHISHAZ.AsString;
repmodule.frxReport1.PrepareReport;
(repmodule.frxReport1.GetDataset('BDEtable1') as tfrxbdeQUERY ).Query.OPEN;
IF (repmodule.frxReport1.GetDataset('BDEtable1') as tfrxbdeQUERY ).Query.IsEmpty=FALSE THEN
repmodule.frxReport1.print;
end;





except
end;

try
if myprn=1 then
RzBitBtn1Click(RzBitBtn1);
except
end;




try
  repmodule.frxReport1.PrintOptions.Printer:=s;
 except
 end;
  {try
repmodule.frxReport1.LoadFromFile(extractfilepath(application.exename)+'touchorder.fr3') ;
(repmodule.frxReport1.GetDataset('BDEtable2') as tfrxbdetable ).filter:='myprn=''BAR''';
repmodule.frxReport1.PrintOptions.Printer:=posmodule.LOCCONFIGSBAR.AsString;

repmodule.frxReport1.PrepareReport;
repmodule.frxReport1.PrintOptions.ShowDialog:=false;

repmodule.frxReport1.ShowProgress:=false;
repmodule.frxReport1.print;
except
end;
try
repmodule.frxReport1.LoadFromFile(extractfilepath(application.exename)+'touchorder.fr3') ;

(repmodule.frxReport1.GetDataset('BDEtable2') as tfrxbdetable ).filter:='myprn=''COCKTAIL''';
repmodule.frxReport1.PrintOptions.Printer:=posmodule.LOCCONFIGSCOCKTAIL.AsString;
repmodule.frxReport1.PrepareReport;
repmodule.frxReport1.PrintOptions.ShowDialog:=false;

repmodule.frxReport1.ShowProgress:=false;
repmodule.frxReport1.print;
except
end;
try
repmodule.frxReport1.LoadFromFile(extractfilepath(application.exename)+'touchorder.fr3') ;
 (repmodule.frxReport1.GetDataset('BDEtable2') as tfrxbdetable ).filter:='myprn=''FAST FOOD''';
repmodule.frxReport1.PrintOptions.Printer:=posmodule.LOCCONFIGSFASTFOOD.AsString;
 repmodule.frxReport1.PrepareReport;
repmodule.frxReport1.PrintOptions.ShowDialog:=false;

repmodule.frxReport1.ShowProgress:=false;
repmodule.frxReport1.print;
except
end;
try
repmodule.frxReport1.LoadFromFile(extractfilepath(application.exename)+'touchorder.fr3') ;
 (repmodule.frxReport1.GetDataset('BDEtable2') as tfrxbdetable ).filter:='myprn=''OVEN''';
 repmodule.frxReport1.PrintOptions.Printer:=posmodule.LOCCONFIGSOVEN.AsString;
 repmodule.frxReport1.PrepareReport;
repmodule.frxReport1.PrintOptions.ShowDialog:=false;

repmodule.frxReport1.ShowProgress:=false;
repmodule.frxReport1.print;
except
end;
try
repmodule.frxReport1.LoadFromFile(extractfilepath(application.exename)+'touchorder.fr3') ;
 (repmodule.frxReport1.GetDataset('BDEtable2') as tfrxbdetable ).filter:='myprn=''BOUCHERY''';
 repmodule.frxReport1.PrintOptions.Printer:=posmodule.LOCCONFIGSBOUCHERY.AsString;
 repmodule.frxReport1.PrepareReport;
repmodule.frxReport1.PrintOptions.ShowDialog:=false;

repmodule.frxReport1.ShowProgress:=false;
repmodule.frxReport1.print;
except
end;

try
repmodule.frxReport1.LoadFromFile(extractfilepath(application.exename)+'touchorder.fr3') ;
  (repmodule.frxReport1.GetDataset('BDEtable2') as tfrxbdetable ).filter:='myprn=''SNACK''';
  repmodule.frxReport1.PrintOptions.Printer:=posmodule.LOCCONFIGSSNACK.AsString;
  repmodule.frxReport1.PrepareReport;
repmodule.frxReport1.PrintOptions.ShowDialog:=false;

repmodule.frxReport1.ShowProgress:=false;
repmodule.frxReport1.print;
except
end;


 }
posmodule.items.DisableControls;




try
posmodule.items.first;
while not posmodule.items.Eof do
begin
if  posmodule.itemsprn.AsString<>'BOOK' then
begin
posmodule.items.edit;

posmodule.itemsprn.AsString:='True';
posmodule.items.post;
end;
posmodule.items.next;
end;
except
end;

posmodule.items.enableControls;

except
end;

MODALRESULT:=MROK;

end;

procedure Tf_touchinv.btncloseClick(Sender: TObject);
begin

if posmodule.touser.fieldbyname('closetable').AsString='False' then
exit;

f_touchinv.enabled:=False;
try
//Application.CreateForm(Tf_closetable,f_closetable);
  if not assigned(f_closetable) then
f_closetable:=tf_closetable.create(self);
f_closetable.query1.open;
f_closetable.Query1.Locate('sid',posmodule.CURRFACSID.AsString,[]);
try
if f_closetable.ShowModal=mrok then
begin
posmodule.CURRFAC.edit;
posmodule.CURRFACSID.AsString:=f_closetable.Query1SID.AsString;
posmodule.CURRFACUSER_.AsString:=p_posmodule.myuser;


posmodule.CURRFAC.post;


end
else
begin
f_touchinv.enabled:=true;
f_closetable.query1.close;
 if  assigned(f_closetable) then
freeandnil(f_closetable);
exit;
end;

except
f_touchinv.enabled:=true;
f_closetable.query1.close;
 if  assigned(f_closetable) then
freeandnil(f_closetable);
exit;

end;
f_closetable.query1.close;
 if  assigned(f_closetable) then
freeandnil(f_closetable);


posmodule.CURRFAC.edit;
posmodule.CURRFACIACTIVE.AsString:='False';
posmodule.CURRFAC.post;
except
end;
f_touchinv.Enabled:=true;
modalresult:=mrok;
end;

procedure Tf_touchinv.RzBitBtn15Click(Sender: TObject);
begin
if posmodule.items.IsEmpty then exit;
if (posmodule.CURRFACPRN.AsString='True') or
   (posmodule.CURRFACPAID.AsString='True') then
exit;
if posmodule.itemsprn.AsString='True' then exit;

posmodule.items.edit;
//if  length(posmodule.itemsqty.AsString)<>1 then

posmodule.itemsqty.AsCurrency:=strtoint((Sender as tRzBitBtn ).caption);
//else
//posmodule.itemsqty.AsString:=posmodule.itemsqty.AsString+(Sender as tRzBitBtn ).caption;

 try
RzDBGrid1.OnExit(RzDBGrid1);
except
end;


end;


procedure Tf_touchinv.RzBitBtn1Click(Sender: TObject);
var s:string;
begin

 try
RzDBGrid1.OnExit(RzDBGrid1);
except
end;


try
//if posmodule.CONFIGSTOUCHNOPRN.AsString='YES' then
//exit;

repmodule.frxReport1.LoadFromFile(extractfilepath(application.exename)+'touchinv.fr3') ;
if trim(posmodule.CONFIGSPINVOICE.AsString)<>'' then
repmodule.frxReport1.PrintOptions.Printer:=posmodule.CONFIGSPINVOICE.AsString;
repmodule.frxReport1.PrintOptions.ShowDialog:=false;

repmodule.frxReport1.PrepareReport;

//repmodule.frxReport1.PrintOptions.Printer:='Default';
s:=posmodule.CURRFACsid.AsString;
try
if s='' then s:='5310001';
if s[1]='4' then
repmodule.frxReport1.PrintOptions.Copies:=2
else
repmodule.frxReport1.PrintOptions.Copies:=1;
except
end;

repmodule.frxReport1.print;

except
end;
try
posmodule.CURRFAC.edit;
posmodule.CURRFACprn.AsString:='True';
posmodule.CURRFACdoprn.AsString:='False';
posmodule.CURRFAC.post;
btnclose.enabled:=true;
rzcedit.enabled:=true;

except
end;
end;

procedure Tf_touchinv.RzBitBtn16Click(Sender: TObject);
var s:string;qty,disc:currency;
begin
if posmodule.items.IsEmpty then exit;
if (posmodule.CURRFACPRN.AsString='True') or
   (posmodule.CURRFACPAID.AsString='True') then
exit;

if (posmodule.itemsPRN.AsString<>'True') then
posmodule.items.delete
else
begin
if posmodule.CONFIGSMYDEL.AsInteger=1 then
begin
posmodule.passdlg.ValueText:='';
if posmodule.passdlg.ShowModal=mrok then
begin
posmodule.touser.Locate('pass',posmodule.passdlg.ValueText,[]);
if posmodule.touser.FieldByName('posdelete').asstring='True' then
begin


posmodule.items.delete;
end;
end;
try
RzDBGrid1.OnExit(RzDBGrid1);
except
end;


exit;
end;
stock2.close;



stock2.sql.Strings[1]:='where item='''+posmodule.itemsITEM.AsString+'''';


stock2.open;


qty:=posmodule.itemsqty.AsCurrency;
disc:=posmodule.itemsDISCOUNT.AsCurrency;
posmodule.items.append;
posmodule.itemsmid.AsString:=posmodule.invoiceid.AsString;
posmodule.itemssite.AsString:=posmodule.invoicesite.AsString;
posmodule.itemsfdate.AsString:=posmodule.invoicefdate.AsString;

posmodule.itemssid.AsString:=posmodule.invoicesid.AsString;
posmodule.itemscontact.AsString:=posmodule.invoicecontact.AsString;
posmodule.itemssalesman.AsString:=posmodule.invoicesalesman.AsString;
 posmodule.itemsPRN.AsString:='False';
posmodule.itemsdiscount.AsCurrency :=STOCK2SALESDISC.AsCurrency;
posmodule.itemsvat.AsCurrency:=STOCK2vat.AsCurrency;
posmodule.itemsdescr.AsString:=STOCK2descr1.AsString;
posmodule.itemsstqty.AsCurrency:=STOCK2QTY.AsCurrency;

posmodule.itemsMYPRN.AsString:=STOCK2MYPRN.AsString;
posmodule.itemsitem.AsString:=STOCK2item.AsString;
posmodule.itemsPACK.AsCurrency:=1;
posmodule.itemsqty.AsCurrency:=-QTY;
posmodule.itemsDISCOUNT.AsCurrency:=disc;
posmodule.itemsfrac.AsCurrency:=0;

posmodule.itemscostus.AsCurrency:=STOCK2costus.AsCurrency;
posmodule.itemscostlc.AsCurrency:=STOCK2costlc.AsCurrency;
//posmodule.itemssttype.AsString:=posmodule.detSTOCK2sttype.AsString;
posmodule.itemsyesno.AsString:=STOCK2yesno.AsString;
posmodule.itemsbarcode.AsString:=STOCK2item.AsString;
posmodule.itemsqty.AsCurrency:=-qty;

posmodule.itemsprice.AsCurrency:=STOCK2POSPRICE1.AsCurrency;
posmodule.items.post;

try
RzDBGrid1.OnExit(RzDBGrid1);
except
end;


stock2.close;



end;


 try
RzDBGrid1.OnExit(RzDBGrid1);
except
end;


end;

procedure Tf_touchinv.RzBitBtn4Click(Sender: TObject);
begin

//Application.CreateForm(Tf_telep,f_telep);
    if not assigned(f_telep) then
f_telep:=tf_telep.create(self);
try
if f_telep.ShowModal=mrok then
begin




posmodule.CURRFAC.edit;

posmodule.CURRFACNAME.AsString:=f_telep.Query1name.AsString;
posmodule.CURRFACCONTACT.AsString:=f_telep.Query1id.AsString;
//posmodule.CURRFACTABLENO.AsString:='Delivery';
//posmodule.CURRFACIACTIVE.AsString:='D';
posmodule.CURRFACNAME.AsString:=f_telep.Query1NAME.AsString;
posmodule.CURrFAC.POST;
end;
except
end;
 if  assigned(f_telep) then
freeandnil(f_telep);



end;

procedure Tf_touchinv.RzBitBtn3Click(Sender: TObject);
var s:string;
begin
if   (posmodule.CURRFACPRN.AsString='True') then exit;


if posmodule.items.IsEmpty=true then
exit;

if posmodule.touser.fieldbyname('posdiscount').AsBoolean=false then

exit;
//Application.CreateForm(Tf_tableno,f_tableno);
  if not assigned(f_tableno) then
f_tableno:=tf_tableno.create(self);
try
if f_tableno.ShowModal=mrok then
begin
posmodule.items.First;
while not posmodule.items.Eof do
begin
posmodule.items.edit;
if strtofloat(f_tableno.Edit1.Text)<101 then
posmodule.itemsDISCOUNT.AsCurrency:=strtofloat(f_tableno.Edit1.Text)
else
posmodule.itemsDISCOUNT.AsCurrency:=strtofloat(f_tableno.Edit1.Text)/posmodule.CURRFACTOTAL.AsCurrency*100;
posmodule.items.post;
posmodule.items.Next;
end;


end;


except
end;
  if  assigned(f_tableno) then
 freeandnil(f_tableno);
 try
RzDBGrid1.OnExit(RzDBGrid1);
except
end;


end;

procedure Tf_touchinv.RzBitBtn23Click(Sender: TObject);
begin
if posmodule.CURRFACPRN.AsString='True' then
exit;
if posmodule.touser.fieldbyname('alltable').AsString='NO' then
exit;
//Application.CreateForm(Tf_mychef,f_mychef);
  if not assigned(f_mychef) then
f_mychef:=tf_mychef.create(self);
try
if f_mychef.ShowModal=mrok then
begin
posmodule.CURRFAC.edit;
posmodule.CURRFACCHEF.AsString:=p_mychef.mys;
end;
except

end;
  if  assigned(f_mychef) then
freeandnil(f_mychef);

end;

procedure Tf_touchinv.RzBitBtn6Click(Sender: TObject);
begin
//Application.CreateForm(Tf_helpdesk,f_helpdesk);
  if not assigned(f_helpdesk) then
f_helpdesk:=tf_helpdesk.create(self);
try
f_helpdesk.ShowModal;
except
end;
  if  assigned(f_helpdesk) then
freeandnil(f_helpdesk);
end;

procedure Tf_touchinv.RzBitBtn2Click(Sender: TObject);
begin
if posmodule.items.IsEmpty then exit;
if posmodule.CURRFACPRN.AsString='True' then
exit;
if posmodule.itemsprn.AsString='True' then exit;
//Application.CreateForm(Tf_tableno,f_tableno);
  if not assigned(f_tableno) then
f_tableno:=tf_tableno.create(self);
try
if f_tableno.ShowModal=mrok then
begin


if (strtofloat(f_tableno.Edit1.text)>0)
 or (posmodule.CONFIGSCLOSINGREST.AsString<>'True') then
begin
if (posmodule.touser.FieldByName('NADJUST').AsString<>'True')

   and (strtofloat(f_tableno.Edit1.text)<0) then

begin
 try
showmessage('No Priviligies!!!');
except
end;

end
else
begin
posmodule.items.edit;


posmodule.itemsqty.AsCurrency:=strtofloat(f_tableno.Edit1.text);
end;

 try
RzDBGrid1.OnExit(RzDBGrid1);
except
end;


end
end


except
end;
  if  assigned(f_tableno) then
freeandnil(f_tableno);
end;

procedure Tf_touchinv.cxGrid1DBCardView1StylesGetContentStyle(
  Sender: TcxCustomGridTableView; ARecord: TcxCustomGridRecord;
  AItem: TcxCustomGridTableItem; out AStyle: TcxStyle);
begin
inherited;
try
astyle:=cxStyle8;

if ((arecord.Values[0]<>null) and (arecord.Values[0]<>0)) then
astyle.Color:=arecord.Values[0]
else
astyle.Color:=cxStyle8.Color;
except
astyle:=cxStyle1;
astyle.Color:=cxStyle8.Color;
end;
astyle.Font:= cxStyle8.Font;
end;

procedure Tf_touchinv.RzLabel2Click(Sender: TObject);
begin
if posmodule.items.IsEmpty then exit;
if posmodule.CURRFACPRN.AsString='True' then
exit;



posmodule.items.edit;
if posmodule.itemsprn.AsString='BOOK' then
begin
posmodule.itemsprn.AsString:='False'
end


else
begin
if posmodule.itemsprn.AsString='False' then
posmodule.itemsprn.AsString:='BOOK';
end;

 try
RzDBGrid1.OnExit(RzDBGrid1);
except
end;

end;

procedure Tf_touchinv.ttttDBTableView1StylesGetContentStyle(
  Sender: TcxCustomGridTableView; ARecord: TcxCustomGridRecord;
  AItem: TcxCustomGridTableItem; out AStyle: TcxStyle);
begin
inherited;
try

if arecord.Values[0]='BOOK' then

astyle:=cxStyle7

else
begin
if posmodule.CURRFACPRN.AsString='True' then
astyle:=cxStyle7
else
astyle:=cxStyle6;

end;


except
astyle:=cxStyle6;
end;
end;

procedure Tf_touchinv.RzBitBtn22Click(Sender: TObject);
begin
if posmodule.CURRFACPRN.AsString='True' then
exit;
end;

procedure Tf_touchinv.OpenInvoiceAfterPrint1Click(Sender: TObject);
begin
//Application.CreateForm(Tf_passdlg,f_passdlg);
  if not assigned(f_passdlg) then
f_passdlg:=tf_passdlg.create(self);
try
if f_passdlg.ShowModal=mrok then
begin
if posmodule.touser.Locate('pass',f_passdlg.Password.Text,[]) then
if posmodule.touser.FieldByName('esinv').asstring='True' then
begin
posmodule.CURRFAC.edit;
posmodule.CURRFACprn.AsString:='False';
posmodule.CURRFAC.post;
btnclose.enabled:=false;
{
try
f_mytoush.RzBitBtn6Click(f_mytoush.RzBitBtn6);
except
end;
}
end;

end;
except
end;
   if  assigned(f_passdlg) then
 freeandnil(f_passdlg);
end;

procedure Tf_touchinv.RzLabel3Click(Sender: TObject);
begin
if posmodule.items.IsEmpty then exit;
if posmodule.CURRFACPRN.AsString='True' then
exit;
//Application.CreateForm(Tf_mynotes,f_mynotes);
  if not assigned(f_mynotes) then
f_mynotes:=tf_mynotes.create(self);
try
f_mynotes.ShowModal;
except

end;
   if  assigned(f_mynotes) then
freeandnil(f_mynotes);
end;

procedure Tf_touchinv.RzLabel1Click(Sender: TObject);
var s:string;
begin
if posmodule.items.IsEmpty then exit;
s:=posmodule.touser.fieldbyname('pass').AsString;
if posmodule.CURRFACPRN.AsString='True' then
exit;
//Application.CreateForm(Tf_passdlg,f_passdlg);
  if not assigned(f_passdlg) then
f_passdlg:=tf_passdlg.Create(self);


repeat
f_passdlg.ShowModal;

until posmodule.touser.Locate('pass',f_passdlg.Password.Text,[]);
//p_posmodule.myuser:=posmodule.touser.fieldbyname('username').AsString;
   if  assigned(f_passdlg) then
freeandnil(f_passdlg);

if posmodule.touser.fieldbyname('CHANGEPRICE').AsBoolean then
begin
posmodule.items.edit;
posmodule.itemsprice.AsCurrency:=0;
posmodule.items.post;
end;
 try
RzDBGrid1.OnExit(RzDBGrid1);
except
end;
posmodule.touser.Locate('pass',s,[])



end;

procedure Tf_touchinv.rzceditClick(Sender: TObject);
begin
//Application.CreateForm(Tf_barcode,f_barcode);
if posmodule.touser.fieldbyname('closetable').AsString='False' then
exit;


  if not assigned(f_barcode) then
f_barcode:=tf_barcode.create(self);

try
if f_barcode.ShowModal=mrok then
begin
posmodule.CURRFAC.edit;
posmodule.CURRFACsid.AsString:=f_barcode.RzButtonEdit1.text;
posmodule.CURRFACSDISC.AsCurrency:=F_BARCODE.Query1.FIELDBYNAME('DISCOUNT').ASCURRENCY;
posmodule.CURRFACname.AsString:=F_BARCODE.Query1.FIELDBYNAME('sname').AsString;

posmodule.CURRFAC.post;
posmodule.items.first;
while not posmodule.items.Eof do
begin
posmodule.items.edit;
posmodule.itemssid.AsString:=f_barcode.RzButtonEdit1.text;
TRY
POSMODULE.itemsDISCOUNT.AsCurrency:=F_BARCODE.Query1.FIELDBYNAME('DISCOUNT').ASCURRENCY;
EXCEPT
END;

posmodule.items.post;
posmodule.items.next;
end;

end
else
exit;

except
end;
f_barcode.query1.close;
   if  assigned(f_barcode) then
freeandnil(f_barcode);

posmodule.CURRFAC.edit;
posmodule.CURRFACIACTIVE.AsString:='False';
posmodule.CURRFAC.post;
modalresult:=mrok;
end;

procedure Tf_touchinv.categBeforeOpen(DataSet: TDataSet);
begin
if posmodule.CONFIGSWHEREIS.AsInteger=0 then
categ.SQL.Strings[1]:='where  STYPE in (19,26)  '
else
categ.SQL.Strings[1]:='where  STYPE in (19,26)   and cast(whereis as integer)='+posmodule.CONFIGSWHEREIS.AsString+'';

end;

procedure Tf_touchinv.Design1Click(Sender: TObject);
begin
if posmodule.CONFIGSEXTYESNO.AsString='YES' then
exit;

if posmodule.touser.FieldByName('UDESIGN').AsBoolean=true then
begin
//Application.CreateForm(Tf_item,f_item);
  if not assigned(f_item) then
f_item:=tf_item.Create(self);

f_item.query1.ParamByName('myitem').AsString:=stockitem.AsString;
f_item.query1.open;
try
f_item.ShowModal;
except
end;
f_item.Query1.close;
   if  assigned(f_item) then
freeandnil(f_item);

end;
end;

procedure Tf_touchinv.cxLabel1Click(Sender: TObject);
var s:string;
begin
//Application.CreateForm(Tf_tablenoc,f_tablenoc);
  if not assigned(f_tablenoc) then
f_tablenoc:=tf_tablenoc.create(self);
f_tablenoc.Edit1.Text:=posmodule.CURRFACTABLENO.AsString;
if f_tablenoc.ShowModal=mrok then
begin
if trim(f_tablenoc.Edit1.Text)<>'' then
s:=trim(f_tablenoc.Edit1.Text)
else
begin
   if  assigned(f_tablenoc) then
freeandnil(f_tablenoc);
exit;
end;


end
else
begin
   if  assigned(f_tablenoc) then
freeandnil(f_tablenoc);
exit;
end;
posmodule.CURRFAC.EDIT;
posmodule.CURRFACTABLENO.AsString:=s;
posmodule.CURRFAC.POST;


end;

procedure Tf_touchinv.ttttDBTableView1DblClick(Sender: TObject);
var s:string;
begin
if posmodule.items.IsEmpty then exit;
s:=posmodule.touser.fieldbyname('pass').AsString;




if posmodule.CURRFACPRN.AsString='True' then
exit;

if posmodule.touser.fieldbyname('CHANGEPRICE').AsBoolean<>True
then
begin
//Application.CreateForm(Tf_passdlg,f_passdlg);
  if not assigned(f_passdlg) then
f_passdlg:=tf_passdlg.Create(self);


repeat
f_passdlg.ShowModal;

until posmodule.touser.Locate('pass',f_passdlg.Password.Text,[]);
//p_posmodule.myuser:=posmodule.touser.fieldbyname('username').AsString;
   if  assigned(f_passdlg) then
freeandnil(f_passdlg);


if posmodule.touser.fieldbyname('CHANGEPRICE').AsBoolean<>True
then exit;


end;


//Application.CreateForm(Tf_tableno,f_tableno);
  if not assigned(f_tableno) then
f_tableno:=tf_tableno.create(self);
f_tableno.Caption:='Change Current Price:';
try
if f_tableno.ShowModal=mrok then
begin
posmodule.items.edit;
posmodule.itemsprice.AsCurrency:=strtofloat(f_tableno.Edit1.text);

 try
RzDBGrid1.OnExit(RzDBGrid1);
except
end;


end



except
end;
   if  assigned(f_tableno) then
freeandnil(f_tableno);
end;

procedure Tf_touchinv.OpenDrawer1Click(Sender: TObject);
var f:textfile;
     i:integer;
begin

try
assignfile(f,'prn');
rewrite(f);
writeln(f,#$07+#$50+#$00);
writeln(f,#$1B+#$70+#$00);

//p_modul.oc:=p_modul.oc+1;
except
end;
try
closefile(f);
except
end;


 repmodule.frxReport1.LoadFromFile(extractfilepath(application.exename)+'drawer.fr3') ;
 repmodule.frxReport1.PrepareReport;
repmodule.frxReport1.PrintOptions.ShowDialog:=false;
repmodule.frxReport1.ShowProgress:=false;
repmodule.frxReport1.print;




end;

procedure Tf_touchinv.RzBitBtn18Click(Sender: TObject);
begin

if posmodule.CURRFACPRN.AsString='True' then
exit;
//Application.CreateForm(Tf_tableno,f_tableno);
  if not assigned(f_tableno) then
f_tableno:=tf_tableno.create(self);
try
if f_tableno.ShowModal=mrok then
begin
posmodule.CURRFAC.edit;
posmodule.CURRFACCOVER.AsCurrency:=strtofloat(f_tableno.Edit1.text);

end;
except
end;
   if  assigned(f_tableno) then
freeandnil(f_tableno);
  end;
procedure Tf_touchinv.FormCreate(Sender: TObject);
begin
try
ccc.ComNumber:=posmodule.CONFIGSMYCOM.AsInteger;
except
end;

iii:=0;
myprn:=0;
end;

procedure Tf_touchinv.HardwareCashopen1Click(Sender: TObject);
var f:textfile;
     i:integer;
begin
if  posmodule.CONFIGSMYPRN.AsString='ON' then
begin
try
assignfile(f,'prn');
rewrite(f);
writeln(f,#$07+#$50+#$00);
writeln(f,#$1B+#$70+#$00);

//p_modul.oc:=p_modul.oc+1;
except
end;
try
closefile(f);
except
end;
END;


end;

procedure Tf_touchinv.ChandeChef1Click(Sender: TObject);
begin
posmodule.passdlg.ShowModal;
posmodule.touser.Locate('pass',posmodule.passdlg.ValueText,[]);
if posmodule.touser.FieldByName('esinv').asstring='True' then
begin
//Application.CreateForm(Tf_mychef,f_mychef);
  if not assigned(f_mychef) then
f_mychef:=tf_mychef.create(self);
try
f_mychef.ShowModal;
posmodule.CURRFAC.edit;
posmodule.CURRFACCHEF.AsString:=p_mychef.mys;
except

end;
if  assigned(f_mychef) then
freeandnil(f_mychef);
end;

end;

procedure Tf_touchinv.stockBeforeOpen(DataSet: TDataSet);
begin
if posmodule.CONFIGSWHEREIS.AsInteger=0 then
stock.SQL.Strings[1]:='where cast(category as integer)=:id and STYPE in (19,26)'
else
stock.SQL.Strings[1]:='where cast(category as integer)=:id and STYPE in (19,26) and whereis='''+posmodule.CONFIGSWHEREIS.AsString+'''';

end;

procedure Tf_touchinv.cxGridDBCardView1StylesGetContentStyle(
  Sender: TcxCustomGridTableView; ARecord: TcxCustomGridRecord;
  AItem: TcxCustomGridTableItem; out AStyle: TcxStyle);
begin
inherited;
try
astyle:=cxStyle9;

if ((arecord.Values[0]<>null) and (arecord.Values[0]<>0)) then
astyle.Color:=arecord.Values[0]
else
astyle.Color:=cxStyle9.Color;
except
astyle:=cxStyle1;
astyle.Color:=cxStyle9.Color;
end;
astyle.Font:= cxStyle9.Font;
end;

procedure Tf_touchinv.RzBitBtn19Click(Sender: TObject);
begin
OpenInvoiceAfterPrint1Click(OpenInvoiceAfterPrint1);
end;

procedure Tf_touchinv.FormClose(Sender: TObject; var Action: TCloseAction);
begin
action:=caFree;
end;

procedure Tf_touchinv.RzBitBtn20Click(Sender: TObject);
begin
if posmodule.CURRFACPRN.AsString='True' then
exit;


if posmodule.touser.fieldbyname('closetable').AsString='False' then
exit;

if posmodule.touser.fieldbyname('alltable').AsString='NO' then
exit;

 if not assigned(f_mychef) then
f_mychef:=tf_mychef.create(self);
f_mychef.query2.open;
f_mychef.DataSource1.DataSet:=f_mychef.query2;
try
if f_mychef.ShowModal=mrok then
begin
posmodule.CURRFAC.edit;
posmodule.CURRFACUSER_.AsString:=p_mychef.mys;
end;
f_mychef.query2.close;

except

end;
  if  assigned(f_mychef) then
freeandnil(f_mychef);


end;

end.
