Order Selection Form

To highlight the orders, whose execution time exceeds X minutes, at the cash register

Insert the script for the OrderPanel object in the AfterConnectObject event on the order selection form:

procedure OrderPanelAfterConnectObjectScript(Obj: TObject; Button: TGCustomButton);
var
  t: TDatetime;
begin
  t := StrToTime('0:05:00');  // hour:minutes:seconds
  if SYS.ObjectInheritsFrom(Obj, 'TOrder') then
    if TOrder(Obj).StartService < (now-t) then //  StartService
//    if TOrder(Obj).BillDateTime < (now-t) then // last bill print DateTime  70118
//    if TOrder(Obj).BillExists = true then //check bill printed?   70118
      Button.Color := $004646FF;  // colore of old orders
end;
CODE

To hide banquet orders after midnight

If the order start time exceeds Time2, the script in the order selection window for the set period will hide the orders for the current and future days.

procedure OrderPanelOnSuitableObjectScript(Sender: TBasePanel; Obj: TObject; var Suitable: boolean);
var lbl: TGLabel;
    CurrTime, Time1, Time2: TDateTime;
begin
  Time1 := EncodeTime(00,00,00,00);  // start of period
  Time2 := EncodeTime(03,00,00,00);  // end of period
  CurrTime := Time;
  lbl := TGLabel(gui.FindComponentByName('CaptionLabel'));
  if SYS.ObjectInheritsFrom(TObject(lbl), 'TGLabel') then
    if pos('резерв', TGLabel(lbl).Caption) <=0 then
      if SYS.ObjectInheritsFrom(Obj, 'TOrder') then
     //   if TOrder(Obj).Visit.Finished = vfReservation then
        if (StrToDate(DateToStr(TOrder(Obj).StartService))) >= (StrToDate(DateToStr(RK7.ShiftDate))) then //  StartService
          if (Time1<=CurrTime)and(CurrTime<=Time2) then
            if StrToTime(TimeToStr(TOrder(Obj).StartService))>Time1 then
              Suitable := false; // hide
end;
CODE

Cash Replenishment and Collection form

A script to confirm currency selected for replenishing the payment card

The script displays a dialog box with the «Currency X Selected» message and «OK» and «Cancel» buttons.

First of all, create the selOkCancel selector in the lower right-hand corner for the Cash Replenishment and Collection form, and then insert the following script in the «Miscellaneous – Cash Replenishment and Collection – Cash Replenishment/Collection» form in the selOkCancel object in the OnOnOperationScript event:

var amount :integer;
procedure selOkCancelOnOnOperationScript(Sender: TObject; fk: TReferentItem; var op: integer; var par: integer);
var
 ed: TBasePanel;
 s, s2: string;
 lbl: TGLabel;
 lbl2: TGButton;
begin
if op=rkoOK then
  lbl := TGLabel(GUI.findComponentByName('lblCurrency'));
  lbl2 := TGButton(GUI.findComponentByName('CaptionLabel'));
  s := lbl.caption;
  s2 := lbl2.text;
  if not(pos('087',s2)>1) then  // except cards like 087...
   if GUI.RKMessageDlg('Выбрана валюта ' +inttostr(Amount) + ' ' + s,0,12, 10000)=1
   then
    begin
      if GUI.RKMessageDlg('Вносится сумма ' +inttostr(Amount)+' '+s,0,3, 10000)=6
      then
        op:=rkoOK
      else
      begin
       op:=rkoEsc;
       ed:=TBasePanel(GUI.FindComponentByName('edtAmount'));
       TNumEditor(ed).SetFocus;
       exit;
      end 
    end
   else
     begin
       op:=rkoEsc;
       ed:=TBasePanel(GUI.FindComponentByName('edtAmount'));
       TNumEditor(ed).SetFocus;
       exit;
     end;
end;
procedure edtAmountOnChangeScript(Sender: TObject; var NewText: string; var Allow: boolean);
begin
  amount:=strtoint(newtext); 
end;
CODE

Main Waiter and New Order Form

Setting the focus in the text field

procedure userGTabelpicOnClickScript(Sender: TObject; XCoord, YCoord: integer);
var edt: TObject; 
begin
  edt := TObject(GUI.FindComponentByName('TableNumEditor'));
  if edt <> Nil then
    TCodeEditor(edt).SetFocus;
end;
procedure userGWaiterpicOnClickScript(Sender: TObject; XCoord, YCoord: integer);
var edt: TObject; 
begin
  edt := TObject(GUI.FindComponentByName('MainWaiterEdit'));
  if edt <> Nil then
    TCodeEditor(edt).SetFocus;
end;
CODE

Editing the Order Form

A free dish for the order of over 150 rubles

procedure AddEveryOtherDiscount(DiscCode: integer);
var i, j, numcateg: integer;
    it, CurItem: TCheckItem;
    SL: TStringList;
    a, q,  Price: double;
    d: TDish;
    CheckView: TCheckView;
    Categ: TClassificatorGroup;
begin
CheckView := TCheckView(GUI.FindComponentByName('CheckView'));
if CheckView = Nil then Exit;
CurItem   := RKCheck.CurrentCheckItem;
SL        := TStringList.Create;
if RKCheck.CurrentOrder.UnpaidSum >= 500 then  // receipt total limit
try
  // Create list of the dishes, sorted by price
  SL.Sorted := False;
  numcateg := 8;    //5 - category code
  for i     := 0 to RKCheck.CurrentOrder.Sessions.LinesCount - 1 do
    begin
      it      := RKCheck.CurrentOrder.Sessions.Lines[i];
      Categ   := TClassificatorGroup(getitemBycodeNum('ClassificatorGroups', numcateg));   //5 - category code
      if SYS.ObjectInheritsFrom(TObject(it), 'TDish') then //Check dish lines only
      if Categ.IsChild(it.RefItem) then //Check category of the dish
//      if (it.RefItem.MainParent.code =11 ) then    // if dish from categore of menu and have same code
      if ((it.State = disOpened) or (it.State = disPrinted)) then
      begin
        if SL.Count<1 then
        begin
          if (TDish(it).Quantity = 0) or (TDish(it).PRListSum = 0) then Price := TDish(it).Price
          else Price := TDish(it).PRListSum/TDish(it).Quantity;
          SL.AddObject(FormatFloat('00000000.00', Price) + IntToStr(TDish(it).UNI), TObject(it));
        end;       
      end;
    end;
  //Magic
  q:=0;
      a:= 0;
  for i:= 0 to SL.Count - 1 do
    begin
      d:= TDish(SL.Objects[i]);
      q:= d.Quantity;
      if (d.Quantity = 0) or (d.PRListSum = 0) then Price := d.Price
      else Price := d.PRListSum/d.Quantity;
      a:= a + Price;
    // Delete discount, if a sum changed
    for j     := RKCheck.CheckItemCount(TObject(d.Discounts)) - 1 downto 0 do
      begin
        it      := RKCheck.CheckItemByNumber(TObject(d.Discounts), j);
        if (it.Code = DiscCode) then
          begin
            if abs(TDiscountItem(it).SrcAmount) = a then a := 0
            else RKCheck.DeleteCheckItem(it);
            break;
          end;
      end;
    // Create discount to a dish
    if a > 0 then
      begin
        CheckView.GotoItem(TObject(d));
        RKCheck.CreateCheckItem(rkrefDiscounts, IntToStr(DiscCode), FloatToStr(a));
      end;
    end;
finally
  SL.Free();
  if CurItem <> Nil then CheckView.GotoItem(CurItem);
  end;
RKCheck.CurrentOrder.Recalc();
end;
CODE

On the receipt editing form in the OnOperation event:

procedure DesignFormOnOperation(Sender: TBasePanel; Operation, Param: integer; var res: integer);
begin
  if (operation = 420)  // 420 - Calculate the receipt
   or(operation = 455)  // 455 - Pay the receipt
   then
  begin
    AddEveryOtherDiscount(11);  //  Amount discount code
  end;   
end;
CODE

Place the timer with the following script on the order editing form:

procedure userTimer1OnTimer(Sender: TObject);
begin
// Проверка на корректный чек
  if not RKCheck.Valid then Exit;
  if (GUI.CheckFormInPayMode) then exit;
  if SYS.ObjectInheritsFrom(RKCheck.CurrentCheckItem, 'TPrintCheckItem') then Exit;
  if RKCheck.CurrentOrder.ToPaySum >= 150 then
    if RKCheck.CurrentOrder.UserTag1 = 0 then
    begin
      RKCheck.CurrentOrder.UserTag1 := 1;
      gui.showmessage('show');
    end;
  if RKCheck.CurrentOrder.ToPaySum < 150 then
    if RKCheck.CurrentOrder.UserTag1 = 1 then
      RKCheck.CurrentOrder.UserTag1 := 0;  
end;
CODE