MainSelectorOnSuitableItem
A script to hide modifier selectors
The «sandwich» dish has a scheme of modifiers from several groups (types of bread, types of cheese, toppings, sauces). An additional group of «Diet Bans» modifiers is introduced with modifiers: Soy, Fish, Gluten, Egg.
When selecting modifiers from this group, some modifiers from other groups should not be available for selection.
Example #1: Choose Gluten — Teriyaki sauce becomes unavailable in the sauces group, and in the bread group, White bread becomes unavailable.
Example #2: Choose Gluten and Egg — Mayonnaise becomes unavailable.
A script to hide the modifiers specified in the script. Insert it in the OnSuitableItem event on the order editing form of the MainSelector object:
procedure MainSelectorOnSuitableItemScript(Sender: TBasePanel; item: TReferentItem; var Suitable: boolean); var i, j, p, z, ModifCode1: integer; it, CurItem: TCheckItem; DishCode, CntDish1, CntDish2, AddDishCode: integer; CheckView: TCheckView; DishesCode,ModifDenyList: TStringList; ModifDenied: boolean; s,s1:string; ii:Integer; begin if SYS.ObjectInheritsFrom(item, 'TModifier') then begin ModifDenied := false; DishesCode := TStringList.Create; ModifDenyList := TStringList.Create; //********** Set parameters ***********// DishesCode.Add('1002016=1002017;45'); // modifier code = hidden modifier code ; DishesCode.Add('20=21;46'); DishesCode.Add('17=18;43'); //********** Set parameters ***********// begin for i := 0 to RKCheck.CurrentOrder.Sessions.LinesCount - 1 do begin it := RKCheck.CurrentOrder.Sessions.Lines[i]; if SYS.ObjectInheritsFrom(it, 'TDish') then begin for j := 0 to TDish(it).Modifiers.Count - 1 do // checking by modifier begin for z := 0 to DishesCode.Count-1 do begin p:=pos('=',DishesCode.Strings[z]); ModifCode1 := StrToInt(copy(DishesCode.Strings[z],1,p-1)); // key modifier code if TDish(it).Modifiers.Items[j].Code = ModifCode1 then begin s:=copy(DishesCode.Strings[z],p+1,length(DishesCode.Strings[z])); while length(s)<>0 do begin ii:=pos(';',s); if ii=0 then begin s1:=s; delete(s,1,length(s1)); ModifDenyList.Add(s1); end else begin s1:=copy(s,1,ii-1); delete(s,1,ii); ModifDenyList.Add(s1) end; end; end; end; end; end; end; end; for i := 0 to ModifDenyList.Count - 1 do begin if TModifier(item).code = StrToInt(ModifDenyList.Strings[i]) then ModifDenied := True; end; ModifDenyList.Free(); DishesCode.Free(); Suitable := Suitable and not(ModifDenied); // hide forbidden modifiers end; end;
A script to select the print layout from 2 available, depending on the currency used in the «Top up PDS card balance» dialog
On the «Cash replenishment/collection» form of the MainSelector object, insert the script in the OnSuitableItem event:
procedure MainSelectorOnSuitableItemScript(Sender: TBasePanel; item: TReferentItem; var Suitable: boolean); var ed: TBasePanel; begin ed := TBasePanel(GUI.FindComponentByName('edtCurrency')); if StrToInt(TCodeEditor(ed).Text) = 1 then // if currency with code 1 begin // write layouts codes here to hide them Suitable := Suitable and (item.code <> 12062); end else begin // write layouts codes here to hide them Suitable := Suitable and (item.code <> 1002364); end; end;
Tested on 7.5.6.049 version
A script for time limits of deletion reasons
On the order editing form of the MainSelector object, insert the script in the OnSuitableItem event:
procedure MainSelectorOnSuitableItemScript(Sender: TBasePanel; item: TReferentItem; var Suitable: boolean); var i: integer; it: TCheckItem; CurrTime, Time1: TDateTime; Allow:Boolean; begin if SYS.ObjectInheritsFrom(item, 'TOrderVoid') then if not(TOrderVoid(item).WriteOffOnStore) then begin Allow := False; Time1 := EncodeTime(00,05,00,00); // critical time CurrTime := now; it := RKCheck.CurrentCheckItem; if it <> Nil then if SYS.ObjectInheritsFrom(TObject(it), 'TDish') then if (CurrTime < (TDish(it).Session.StartService+Time1)) then begin Allow := True; end else Suitable := Suitable and (Allow); // show write-off reasons end; end;
OpenPrice script for dishes with the AllowPurchase attribute
On the order editing form of the OperSelector object, insert the script in the OnSuitableItem event:
procedure OperSelectorOnSuitableItemScript(Sender: TBasePanel; item: TReferentItem; var Suitable: boolean); begin try if (item.code = 16) then Suitable := Suitable and (SYS.ObjectInheritsFrom(RKCheck.CurrentCheckItem, 'TPurchaseDish')); except end; end;
A script for the CurItemChanged event for the CheckView object:
procedure CheckViewCurItemChangedScript(Sender: TObject); var MainSelector: TSelectorPanel; begin MainSelector := TSelectorPanel(GUI.FindComponentByName('OperSelector')); MainSelector.RedrawLevel; end;
A script to divide the receipt into two fiscal printers depending on the category of dishes, and send payment from a credit card only to one of them
procedure MainSelectorOnSuitableItemScript(Sender: TBasePanel; item: TReferentItem; var Suitable: boolean); var i: integer; it: TcheckItem; begin for i := RKCheck.CurrentOrder.Sessions.LinesCount - 1 downto 0 do begin it := RKCheck.CurrentOrder.Sessions.Lines[i]; if SYS.ObjectInheritsFrom(TObject(it), 'TPayLine') then Begin if ((TPayLine(it).code = 1) or (TPayLine(it).code = 4)) then // Cash begin // write layouts codes here to hide them Suitable := Suitable and (item.code <> 1014); Suitable := Suitable and (item.code <> 1017); break; end if ((TPayLine(it).code = 95) or (TPayLine(it).code = 96)) then // credit cards begin // write layouts codes here to hide them Suitable := Suitable and (item.code <> 1010); Suitable := Suitable and (item.code <> 1017); break; end if ((TPayLine(it).code = 380) or (TPayLine(it).code = 3003) or (TPayLine(it).code = 3002) or (TPayLine(it).code = 380) or (TPayLine(it).code = 3004) or (TPayLine(it).code = 551)) then //non-fiscal currency begin // write layouts codes here to hide them Suitable := Suitable and (item.code <> 1010); Suitable := Suitable and (item.code <> 1014); break; end End; end; end;
A script to hide a specific selector when entering payment mode
On the order editing form for the OperSelector object, insert the script in the OnSuitableItem event:
procedure OperSelectorOnSuitableItemScript(Sender: TBasePanel; item: TReferentItem; var Suitable: boolean); begin if GUI.CheckFormInPayMode then // if payment mode is on Suitable := Suitable and (item.code <> 9110); // specify the selector code to hide end;
A script to hide the dish when the order amount is less than specified
procedure MainSelectorOnSuitableItemScript(Sender: TBasePanel; item: TReferentItem; var Suitable: boolean); begin if RKCheck.CurrentOrder.ToPaySum < 300 then // the check amount below which the dish selector is hidden Suitable := Suitable and (item.code <> 46); // hide the dish with code 46 end;
A script to show the currency only for prepayment
procedure MainSelectorOnSuitableItemScript(Sender: TBasePanel; item: TReferentItem; var Suitable: boolean); var SB: TGStatusBar; begin if GUI.CheckFormInPayMode then // if payment mode is on begin SB := TGStatusBar(GUI.findComponentByName('StatusBar')); if SYS.ObjectInheritsFrom(item, 'TCurrency') then Suitable := Suitable and (pos('Предоплаты',SB.DefCaption)>0); // show in case of prepayment end; end;
A script to hide currencies in the payment list if the number of guests is greater than or equal to 10
On the order editing form, insert the script for the MainSelector object in the OnSuitableItem event:
procedure MainSelectorOnSuitableItemScript(Sender: TBasePanel; item: TReferentItem; var Suitable: boolean); begin if GUI.CheckFormInPayMode then // if payment mode is on if SYS.ObjectInheritsFrom(item, 'TCurrency') then if RKCheck.CurrentOrder.GuestsCount < 10 then begin Suitable := Suitable and ((TCurrency(item).code = 1)or(TCurrency(item).code = 2)or(TCurrency(item).code = 3)or(TCurrency(item).code = 4)or(TCurrency(item).code = 5)); // show currencies end else begin Suitable := Suitable and ((TCurrency(item).code = 6)or(TCurrency(item).code = 7)or(TCurrency(item).code = 8)or(TCurrency(item).code = 9)or(TCurrency(item).code = 10)); // show currencies end; end;
MainSelectorOnSuitableObject
A script to restrict discount coupons addition to an order of less than a certain amount
On the OnSuitableObject event of the MainSelector object, insert the script on the receipt editing form.
procedure MainSelectorOnSuitableObjectScript(Sender: TBasePanel; Obj: TObject; var Suitable: boolean); begin if SYS.ObjectInheritsFrom(Obj, 'TMcrCoupon') then begin if (RKCheck.CurrentOrder.ToPaySum < 300) and (TMcrCoupon(Obj).GroupUNI = 0) then if (Pos('CARDS', TMcrCoupon(Obj).CouponName) > 0) then Suitable := True else Suitable := False; end;
A script to limit the number of coupons in the order
Insert the script in the OnSuitableObject event of the MainSelector object on the receipt editing form.
procedure MainSelectorOnSuitableObjectScript(Sender: TBasePanel; Obj: TObject; var Suitable: boolean); var i, j, DiscountCode, CntDish1, cntDiscount, AllowCntCoupon, TableGroupCode1, TableGroupCode2: integer; minOrderSum: double; it, it2: TCheckItem; begin //************************* Set parameter *************************// minOrderSum := 300; // minimum order amount DiscountCode := 70; // discount code (coupon code) AllowCntCoupon := 1; // maximum number of coupons in the order TableGroupCode1 := 1001119; // table type code TableGroupCode2 := 1005168; // table type code //************************* Set parameter *************************// if (TRk7Table(RK7.FindItemBySifr(rkrefTables, RKCheck.CurrentOrder.TableID)).TableGroup = TableGroupCode1) or(TRk7Table(RK7.FindItemBySifr(rkrefTables, RKCheck.CurrentOrder.TableID)).TableGroup = TableGroupCode2) then // check tables type if SYS.ObjectInheritsFrom(Obj, 'TMcrCoupon') then begin begin CntDish1 := 0; cntDiscount := 0; for i := 0 to RKCheck.CurrentOrder.Sessions.LinesCount - 1 do begin it := RKCheck.CurrentOrder.Sessions.Lines[i]; if SYS.ObjectInheritsFrom(it, 'TDish') then if (TDish(it).Quantity) > 0 then begin CntDish1 := CntDish1 + trunc(TDish(it).Quantity); for j := RKCheck.CheckItemCount(TObject(TDish(it).Discounts)) - 1 downto 0 do begin it2 := RKCheck.CheckItemByNumber(TObject(TDish(it).Discounts), j); if (it2.Code = DiscountCode) then // if abs(TDiscountItem(it2).SrcAmount)>0 then begin cntDiscount := cntDiscount + 1; end; end; end; end; end; Suitable := Suitable and ((RKCheck.CurrentOrder.ToPaySum > minOrderSum) and (CntDish1 > 0) and (cntDiscount < AllowCntCoupon)); end; end;
Check the script on versions not lower than 7.5.4.237, 7.5.5.081, 7.5.6.024, 7.5.7.003
MainSelectorAfterConnectObject
A script to show the change amount only after printing the receipt
The script hides the change on selectors with currency denominations. Insert it on the quick receipt editing form in the AfterConnectObject event of the MainSelector object:
procedure MainSelectorAfterConnectObjectScript(Obj: TObject; Button: TGCustomButton); begin if SYS.ObjectInheritsFrom(TObject(Obj), 'TCurrencyFaceValue') then Button.text := TCurrencyFaceValue(Obj).RightLangName + #10;// + IntToStr(TCurrencyFaceValue(Obj).Tag); end;
A script for the color of the main selector buttons
On the form of editing the receipt of the MainSelector object, insert the script in the AfterConnectObjectScript event:
procedure MainSelectorAfterConnectObjectScript(Obj: TObject; Button: TGCustomButton); var Categ: TClassificatorGroup; midserv, CategCode: integer; begin CategCode := 8; // code of category midserv := 15001; // ident of midserver Categ := TClassificatorGroup(getitemBycodeNum('ClassificatorGroups', CategCode)); if RK7.CashGroup.Ident = midserv then if SYS.ObjectInheritsFrom(TObject(Obj), 'TRK7MenuItem') then if Categ.IsChild(TRK7MenuItem(Obj)) then Button.Color := clred; end;
userGOperationButton
A script to change the button color
Place the button on the form. Insert the script in its OnClick event:
procedure userGOperationButton1OnClickScript(Sender: TObject; XCoord, YCoord: integer); begin If RKCheck.CurrentOrder.BillExists=false then begin RK7.PerformOperation(RkoPrintBill,0) TGOperationButton(Sender).Text := 'cancel bill'; TGOperationButton(Sender).Color := clRed; end else begin RK7.PerformOperation(RkoUnlockBill,0); TGOperationButton(Sender).Text := 'bill'; TGOperationButton(Sender).Color := clBlue; end; end;
And in the OnShow event, insert the script for drawing the button according to the current state of the order:
procedure userGOperationButton1OnShowScript(Sender: TObject); begin If RKCheck.CurrentOrder.BillExists=false then begin TGOperationButton(Sender).Text := 'bill'; TGOperationButton(Sender).Color := clBlue; end else begin TGOperationButton(Sender).Text := 'cancel bill'; TGOperationButton(Sender).Color := clRed; end; end;