Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Table of Contents

Simultaneous User Layout Printing and Order Saving

Task: To create a script that will simultaneously print a user layout at the cash station and save an order. The script uses a function key that runs a user selector.

...

Code Block
procedure CheckViewOnAfterCheckViewEdit(Sender: TObject; AEditType: TEditType; AObjectBef, AObjectAft: TObject);
 
var i, j, numcateg, OrderTypeCode, GuestTypeIdent: integer;
 
DiscCode, HaveDisc: integer;
 
it, CurItem: TCheckItem;
 
SL: TStringList;
 
newsum, aftersum, beforesum, limitsum, topay, a, q, Price: double;
 
d: TDish;
 
CheckView: TCheckView;
 
Categ: TClassificatorGroup;
 
begin
 
CheckView := TCheckView(GUI.FindComponentByName('CheckView'));
 
if CheckView = Nil then Exit;
 
HaveDisc := 0;
 
// ******************************************************************
 
DiscCode := 11; // discount code for the special dish
 
numcateg := 8; // category code for the special dish
 
limitsum := 500; // min order amount with all discounts
 
OrderTypeCode := 1; // order type code
 
GuestTypeIdent := 1000087; // guest type id
 
// ******************************************************************
 
CurItem := RKCheck.CurrentCheckItem;
 
SL := TStringList.Create;
 
// if (RKCheck.CurrentOrder.OrderTypeCode = 2) then // for different OrderTypeCode
 
// if (RKCheck.CurrentOrder.OrderCategoryCode = 2) then // for different OrderCategoryCode
 
// if (RKCheck.CurrentOrder.Visit.GuestType = 0) then // for different GuestType
 
if (RKCheck.CurrentOrder.OrderTypeCode = OrderTypeCode) // for different OrderTypeCode
 
or(RKCheck.CurrentOrder.Visit.GuestType = GuestTypeIdent) // for different GuestType
 
then
 
try
 
// Create list of the dishes, sorted by price
 
SL.Sorted := False;
 
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), 'TDiscountItem') then
 
// if TDiscountItem(it).code = 11 then
 
// gui.showmessage('111111111');
 
// if TDiscountItem(it).CalcAmount > 0 then
 
// HaveDisc := HaveDisc + 1;
 
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
 
if TDish(it).Quantity > 0 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;
 
newsum := 0;
 
aftersum := 0;
 
beforesum := 0;
 
if SYS.ObjectInheritsFrom(AObjectAft, 'TDish') then
 
aftersum := TDish(AObjectAft).PRListSum
 
else
 
aftersum := 0;
 
if SYS.ObjectInheritsFrom(AObjectBef, 'TDish') then
 
beforesum := TDish(AObjectBef).PRListSum
 
else
 
beforesum := 0;
 
newsum := aftersum-beforesum;
 
for i:= 0 to SL.Count - 1 do
 
begin
 
a:= 0;
 
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;
 
 
// search special discount
 
for j := RKCheck.CheckItemCount(TObject(d.Discounts)) - 1 downto 0 do
 
begin
 
it := RKCheck.CheckItemByNumber(TObject(d.Discounts), j);
 
if (it.Code = DiscCode) then
 
HaveDisc := HaveDisc + 1;
 
end;
 
 
if HaveDisc > 0 then
 
topay := RKCheck.CurrentOrder.UnpaidSum + a
 
else
 
topay := RKCheck.CurrentOrder.UnpaidSum;
 
 
if topay-a+newsum >= limitsum then
 
begin
 
// 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).CalcAmount) = a then a := 0
 
else begin
 
RKCheck.DeleteCheckItem(it);
 
end;
 
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
 
else
 
begin
 
// 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
 
RKCheck.DeleteCheckItem(it);
 
break;
 
end;
 
end;
 
end;
 
end;
 
finally
 
SL.Free();
 
if CurItem <> Nil then CheckView.GotoItem(CurItem);
 
end;
 
RKCheck.CurrentOrder.Recalc();
 
end;
 
 
procedure CheckViewOnBeforeCheckViewEdit(Sender: TObject; AEditType: TEditType; AObjectBef, AObjectAft: TObject; var AAllow: boolean; var AMessage: string);
 
var i, j, numcateg, OrderTypeCode, GuestTypeIdent: integer;
 
DiscCode, HaveDisc: integer;
 
it, CurItem: TCheckItem;
 
SL: TStringList;
 
newsum, aftersum, beforesum, limitsum, topay, a, q, Price: double;
 
d: TDish;
 
CheckView: TCheckView;
 
Categ: TClassificatorGroup;
 
begin
 
CheckView := TCheckView(GUI.FindComponentByName('CheckView'));
 
if CheckView = Nil then Exit;
 
HaveDisc := 0;
 
// ******************************************************************
 
DiscCode := 11; // discount code for the special dish
 
numcateg := 8; // category code for the special dish
 
limitsum := 500; // min order amount with all the discounts
 
OrderTypeCode := 1; // order type code
 
GuestTypeIdent := 1000087; // guest type id
 
// ******************************************************************
 
CurItem := RKCheck.CurrentCheckItem;
 
SL := TStringList.Create;
 
// if (RKCheck.CurrentOrder.OrderTypeCode = 2) then // for different OrderTypeCode
 
// if (RKCheck.CurrentOrder.OrderCategoryCode = 2) then // for different OrderCategoryCode
 
// if (RKCheck.CurrentOrder.Visit.GuestType = 0) then // for different GuestType
 
if (RKCheck.CurrentOrder.OrderTypeCode = OrderTypeCode) // for different OrderTypeCode
 
or(RKCheck.CurrentOrder.Visit.GuestType = GuestTypeIdent) // for different GuestType
 
then
 
if AEditType = etRemove then
 
try
 
// Create list of the dishes, sorted by price
 
SL.Sorted := False;
 
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
 
if TDish(it).Quantity > 0 then
 
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;
 
//Magic
 
q:=0;
 
newsum := 0;
 
aftersum := 0;
 
beforesum := 0;
 
if SYS.ObjectInheritsFrom(AObjectAft, 'TDish') then
 
aftersum := TDish(AObjectAft).PRListSum
 
else
 
aftersum := 0;
 
if SYS.ObjectInheritsFrom(AObjectBef, 'TDish') then
 
beforesum := TDish(AObjectBef).PRListSum
 
else
 
beforesum := 0;
 
// newsum := aftersum-beforesum;
 
newsum := -beforesum;
 
for i:= 0 to SL.Count - 1 do
 
begin
 
a:= 0;
 
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;
 
 
// search special discount
 
for j := RKCheck.CheckItemCount(TObject(d.Discounts)) - 1 downto 0 do
 
begin
 
it := RKCheck.CheckItemByNumber(TObject(d.Discounts), j);
 
if (it.Code = DiscCode) then
 
HaveDisc := HaveDisc + 1;
 
end;
 
 
if HaveDisc > 0 then
 
topay := RKCheck.CurrentOrder.UnpaidSum + a
 
else
 
topay := RKCheck.CurrentOrder.UnpaidSum;
 
if topay-a+newsum >= limitsum then
 
// if RKCheck.CurrentOrder.UnpaidSum-a+newsum >= limitsum then
 
begin
 
// 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).CalcAmount) = a then a := 0
 
else begin
 
RKCheck.DeleteCheckItem(it);
 
end;
 
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
 
else
 
begin
 
// 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
 
RKCheck.DeleteCheckItem(it);
 
break;
 
end;
 
end;
 
end;
 
end;
 
finally
 
SL.Free();
 
if CurItem <> Nil then CheckView.GotoItem(CurItem);
 
end;
 
RKCheck.CurrentOrder.Recalc();
 
end;

Creating a special offer "Children's Birthdays: 10% Discount + Free pizza"

Mission: it is required to arrange a special offer Task: To arrange the "Children's Birthdays: 10% Discount + Free pizza" special offer.

To do so, you should set a 100% discount on the ' pizza ' category comprising two pizza types, Home Style Pizza and Children's Pizza. If an order contains two pizzas of items from the ' pizza ' category, the 100% discount is applied only to the first one and the second one has the 10% discount.

Solution: Create a script for the Special Offer selector:

Code Block
procedure ProcessOperation1002452(Parameter: integer);

...



var i, j, numcateg: integer;

...



DiscCode: integer;

...



it, CurItem: TCheckItem;

...



SL: TStringList;

...



a, q, Price: double;

...



d: TDish;

...



CheckView: TCheckView;

...



Categ: TClassificatorGroup;

...



skip: boolean;

...



begin

...



CheckView := TCheckView(GUI.FindComponentByName('CheckView'));

...



if CheckView = Nil then Exit;

...



CurItem := RKCheck.CurrentCheckItem;

...



SL := TStringList.Create;

...



try

...



// Create list of the dishes, sorted by price

...



SL.Sorted := False;

...



DiscCode := 12; // the changeable fixed amount discount on a dish

...



numcateg := 8; // category code for discount

...



for i := 0 to RKCheck.CurrentOrder.Sessions.LinesCount - 1 do

...



begin

...



it := RKCheck.CurrentOrder.Sessions.Lines[i];

...



Categ := TClassificatorGroup(getitemBycodeNum('ClassificatorGroups', numcateg));

...



if SYS.ObjectInheritsFrom(TObject(it), 'TDish') then //Check dish lines only

...



if Categ.IsChild(it.RefItem) then //Check category of the dish

...



if ((it.State = disOpened) or (it.State = disPrinted)) then

...



if TDish(it).Quantity > 0 then

...



begin

...



if SL.Count<2 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;

...




q:=0;

...



for i:= 0 to SL.Count - 1 do

...



begin

...



a:= 0;

...



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;

...



if i=0 then

...



a:= a + Price; // discount 100 %

...



if i=1 then

...



a:= a + Price*0.1; // discount 10 %

...

begin




begin

// Delete discount if the 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).CalcAmount) = a then a := 0

...



else begin

...



RKCheck.DeleteCheckItem(it);

...



end;

...



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;

...



end;

...



finally

...



SL.Free();

...



if CurItem <> Nil then CheckView.GotoItem(CurItem);

...



end;

...



RKCheck.CurrentOrder.Recalc();

end;

...


Note

The dish

...

must have the property Adding to the Order – Separate Line for Each Serving.


The script for automatically applying a 10% discount if another category dish in the order has the 100% discount:

Code Block
procedure DiscountUsage1002444(UsageParameters: TDiscountUsageParameters);

...



var i,j,cntDiscount, DiscountCode: integer;

...



it,it2: TCheckItem;

...



Categ: TClassificatorGroup;

...



begin

...



dbg.dbgprint('script_disc');

...



// if not RKCheck.Valid then exit;

...



DiscountCode := 12; // code of the discount "100% on a dish"

...



cntDiscount := 0;

...



Categ := TClassificatorGroup(getitemBycodeNum('ClassificatorGroups', 8)); // category code

...



for i := 0 to RKCheck.CurrentOrder.Sessions.LinesCount - 1 do

...



begin

...



it := RKCheck.CurrentOrder.Sessions.Lines[i];

...



if SYS.ObjectInheritsFrom(TObject(it), 'TDish') then

...



if TDish(it).Quantity > 0 then

...



if Categ.IsChild(it.RefItem) then //Check category of the dish

...



Begin

...



dbg.dbgprint('script_disc 1_');

...



dbg.dbgprint('cnt = '+inttostr(RKCheck.CheckItemCount(TObject(TDish(it).Discounts))));

...



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

...



dbg.dbgprint('script_disc 2');

...



cntDiscount := cntDiscount + 1;

...



break;

...



end;

...



end;

...



End;

...



end;

...



dbg.dbgprint('cntDiscount = '+inttostr(cntDiscount));

...



if cntDiscount>0 then

...



UsageParameters.UsageMode := umAuto

...



else

...



UsageParameters.UsageMode := umDeny;

...



end;

Result at the POS:

Creating a Happy Receipt

MissionTask: To create a script for a ' happy receipt ' limited by1) the

  1. The minimal receipt amount

...

...

  1. The total possible number of receipts. The number of receipts depends on the revenue amount at a given moment, i. e. if the revenue is, for example, 50 000 rubles, the maximum number of happy receipts should be five.

Solution:1)

  1. Create a print layout in the user reports

...

  1. and a print

...

  1. view for this layout
    Image Added
  2. In the Options > User Interface > Forms, add

...

  1. the TReportPanel component to the

...

  1. cash form in the Form editor:
    Image Added

...

  1. Specify the previously created print layout in the

...

  1. Behavior

...

  1. > Document

...

  1. property

...

  1. Enter the script:

    Code Block
    procedure ProcessOperation1001035(Parameter: integer);

...

  1. 
    
    var t1, t2: TdateTime;

...

  1. 
    
    i,QntHO, MaxQntHappyOrd, DiscCode, DiscId: integer;

...

  1. 
    
    it: TCheckItem;

...

  1. 
    
    a,b,MinOrderSum,MaxOrderSum, KasSum: double;

...

  1. 
    
    c: TVisualComponent;

...

  1. 
    
    str: string;

...

  1. 
    
    begin

...

  1. 
    
    DiscCode := 5; // code discount

...

  1. 
    
    DiscId := 1001029; // id discount

...

  1. 
    
    KasSum := 0;

...

  1. 
    
    c := gui.FindComponentByName('UserReportPanel1');

...

  1. 
    
    str := TReportPanel(TObject(c)).Text;

...

  1. 
    
    // dbg.dbgprint('str = '+str);

...

  1. 
    
    i:=pos('revenue=',str);

...

  1. 
    
    if i>0 then

...

  1. 
    
    begin

...

  1. 
    
    KasSum := StrToFloat(copy(str,i+8,length(str)-(i+8)));

...

  1. 
    
    //dbg.dbgprint('KasSum = '+FloatToStr(KasSum));

...

  1. 
    
    end;

...

  1. 
    
    
    t1:=StrToTime('10:01:00'); // start lottery

...

  1. 
    
    t2:=StrToTime('23:59:00'); // end lottery

...

  1. 
    
    MaxOrderSum := 15000; // max sum of order the maximum order amount eligible for a happy receipt

...

  1. 
    
    MinOrderSum := 1; // min sum of order the minimum order amount eligible for a happy receipt

...

  1. 
    
    MaxQntHappyOrd := trunc(KasSum / 10); // quantity of happy ordets at shift

...

  1. 
    
    
    //dbg.dbgprint('QntHO = '+FloatToStr(QntHO));

...

  1. 
    
    //dbg.dbgprint('MaxQntHappyOrd = '+FloatToStr(MaxQntHappyOrd));

...

  1. 
    
    QntHO:=RKCheck.GetDiscountCount(DiscId, 0, ''); // id discount

...

  1. 
    
    if QntHO<MaxQntHappyOrd then

...

  1. 
    
    if (t1<=Time)and(Time<=t2) then

...

  1. 
    
    begin

...

  1. 
    
    // calc sum of order START

...

  1. 
    
    for i := 0 to RKCheck.CurrentOrder.Sessions.LinesCount - 1 do begin

...

  1. 
    
    it := RKCheck.CurrentOrder.Sessions.Lines[i];

...

  1. 
    
    if SYS.ObjectInheritsFrom(TObject(it), 'TDish') then

...

  1. 
    
    a := a + TDish(it).PRListSum

...

  1. 
    
    else if SYS.ObjectInheritsFrom(TObject(it), 'TChargeLine') then

...

  1. 
    
    a := a + TChargeLine(it).CalcAmount;

...

  1. 
    
    // if it.CODE in [5502, 1003] then

...

  1. 
    
    // b := b + TDish(it).PRListSum;

...

  1. 
    
    end;

...

  1. 
    
    // calc sum of order END

...

  1. 
    
    // dbg.dbgprint('a = '+floattostr(a));

...

  1. 
    
    // dbg.dbgprint('random(100) = '+floattostr(random(100)));

...

  1. 
    
    if a>MinOrderSum then // check condition of minimum ordersum

...

  1. 
    
    if a<MaxOrderSum then // check condition of maximum ordersum

...

  1. 
    
    begin

...

  1. 
    
    if (random(100)>1) then // set the probability of drawing a happy receipt here: 1 is the maximum probability; 99 is the minimum probability

...

  1. 
    
    begin

...

  1. 
    
    RKCheck.CreateCheckItem(rkrefDiscounts, IntToStr(DiscCode), FloatToStr(100)); // add discount indicate the discount amount instead of 100

...

  1. 
    
    // dbg.dbgprint('Congratulations!!! Happy Order!!! var1');

...

  1. 
    
    gui.ShowMessage('Congratulations!!! Happy Order!!!'); // RkCheck.GetDiscountCount

...

  1. 
    
    end

...

  1. 
    
    else if (QntHO=0) and (StrToInt(FormatDateTime('n',t2-Time))<=10) then // lottery at last time(minutes) when no winners

...

  1. 
    
    begin

...

  1. 
    
    if (random(100)>1) then // set the probability of drawing a happy receipt here: 1 is the maximum probability; 99 is the minimum probability

...

  1. 
    
    begin

...

  1. 
    
    RKCheck.CreateCheckItem(rkrefDiscounts, IntToStr(DiscCode), FloatToStr(100)); // add discount indicate the discount amount instead of 100

...

  1. 
    
    // dbg.dbgprint('Congratulations!!! Happy Order!!! var2');

...

  1. 
    
    gui.ShowMessage('Congratulations!!! Happy Order!!!'); // RkCheck.GetDiscountCount

...

  1. 
    
    end;

...

  1. 
    
    end;

...

  1. 
    
    end;

...

  1. 
    
    end;

...

  1. 
    
    RK7.PostOperation(rkoBalanceReceipt,0);

...

  1. 
    
    end;


Adding a Dish to the Order When

...

Switching to the Payment Mode

MissionTask: To create a script adding a dish to the order at moment of switching to the payment mode. The process is should be as follows: in the Fast Receipt mode, the system checks the order amount once the Order Payment button is pressed. If the order amount is more than or equal to a certain specified amount, the system displays a message with Yes and No buttons.

If Yes is clicked, the system adds a dish having the NNN code to the order and switches to the payment mode.

If No is clicked, the system switches right away to the payment mode right away.

Solution: Instead of the standard oneselector, add the Payment user selector to the fast receipt. Bind the following user operation script to this selector:

Code Block
procedure ProcessOperation1001304(Parameter: integer);

...



begin

...



if not RKCheck.Valid then

...



exit //important checking

...



else

...



begin

...



if RKCheck.CurrentOrder.UnpaidSum >= 300 then // Order sum checking

...



if GUI.RKMessageDlg('Do You want add bonus dish?', 0, 3, 10000) = 6 then

...



RKCheck.CreateCheckItem(rkrefMenuItems, IntToStr(39), '1'); // add dish with code 39

...



end;

...



RK7.PostOperation(rkoBalanceReceipt, 0);

...



end;

In this script, change 300 to the required amount and replace the 39 code 39 of the added dish with a relevant value.

Dish Locking

Mission: It is required to Task: To replace the standard Dishes selector so that when a dish code is entered and this selector is pressed, some dishes get locked.

Solution:

Code Block
procedure ProcessOperation1038483(Parameter: integer);

...


var ed: TObject;

...



begin

...



if not RKCheck.Valid then

...



exit //important checking

...



else

...



begin

...



ed := TObject(gui.FindComponentByName('Editor'));

...



if SYS.ObjectInheritsFrom(TObject(ed), 'TNumEditor') then

...



if (Pos('1001',TNumEditor(ed).Text)>0)

...



or (Pos('1002',TNumEditor(ed).Text)>0)

...



then

...



gui.showmessage('Zapreshennij simvol!!!')

...



else

...



RK7.PerformOperation(rkoCreateDish, StrToInt(TNumEditor(ed).Text));

...



end;

...



end;


Statuses

Code Block
TDrawItemState = (disNone, disOpened, disLocked, disFixed, disPrinted, disPartClosed, disClosed, disDeleted);

How to Get the Parent of a Combo Element Parent in the Script

Take the ComboDishUNI property from of a dish and find a dish having that UNI.

In Rr_Keeper 7.5.5.035 this can be done as follows:

Code Block
RKCheck.CurrentOrder.Sessions.FindByUNI(TDish(it).ComboDishUNI).

Older versions don't have the FindByUNI function so to find the dish having the required UNI you have to search through all the dishes in the order.

Code Block
If ((TDish(it).Quantity <> 0) and (TDish(it).IsComboComp)) then //and (Categ5.IsChild(it.RefItem)))

...


begin

...



for j := 0 to RKCheck.CurrentOrder.Sessions.LinesCount - 1 do begin

...



it2 := RKCheck.CurrentOrder.Sessions.Lines[j];

...



if SYS.ObjectInheritsFrom(TObject(it2), 'TDish') then

...



begin

...



If ((TDish(it).ComboDishUNI = TDish(it2).UNI) and (Categ5.IsChild(it2.RefItem))) then

...



begin

...



end;

...



end;

...



end;

...



//TDish(it).ComboDishUNI

...



end;

Adding a Modifier to All Dishes in the Order

MissionTask: To write a script for the selector to add a modifier to all dishes in the order.

Solution:

Code Block
procedure ProcessOperation1002489(Parameter: integer);

...


var i,j,CntModif:integer;

...



it, CurItem: TCheckItem;

...



CheckView: TCheckView;

...



begin

...



CheckView := TCheckView(GUI.FindComponentByName('CheckView'));

...



if CheckView = Nil then Exit;

...



CurItem := RKCheck.CurrentCheckItem;

...



if Parameter > 0 then

...



try

...



RK7.PerformOperation(rkoHome, 0);

...



while True do begin

...



it := RKCheck.CurrentCheckItem;

...



if TObject(it) = Nil then break;

...



if SYS.ObjectInheritsFrom(TObject(it), 'TPrintCheckItem') then break;

...



if SYS.ObjectInheritsFrom(TObject(it), 'TDish') then

...



begin

...



CntModif := 0;

...



for j := 0 to TDish(it).Modifiers.Count - 1 do // checking by modifier

...



begin

...



if (TDish(it).Modifiers.Items[j].Code=Parameter) then

...



CntModif := CntModif + 1;

...



end;

...



if CntModif = 0 then

...



RKCheck.CreateCheckItem(rkrefModifiers, IntToStr(Parameter), '1'); // add modificator

...



end;

...



RK7.PerformOperation(rkoDown, 0);

...



end;

...

finally

...




finally

if CurItem <> Nil then CheckView.GotoItem(CurItem);

...



end;

...



end;

Assign the user operation with the above-mentioned script to selectors and be sure to indicate the code of a relevant modifier in the

...

Parameter for Empty

...

and

...

Parameter

...

properties.

Adding a new dish item to the order by pressing the saved dish line and the Quantity button

Mission: When a saved dish item is selected and the Quantity button is pressed, it is required to add a new item to the bottom of item list. (This function was available in R-keeper_6). When the saved dish item is pressed now, the Quantity button is disabled.

Solution:

  1. Add a script to operation scripts.
  2. Assign the script to the specific user operation.
  3. Bind the operation to a function button and assign the button to a new selector.

...