Table of Content
HAL Forum
function val SquareRoot (
integer TargetNumber)
Description:
Applies a mathematical squareroot expression on specified value
Parameters:
TargetNumber The number on which to apply that mathematical expression.
procedure DrawRestPMOtherPay()
begin
  real h,v;
  record LocalMachineBlock LMb;
  record RestPMBlock RestPMb;
  row RestPMBlock RestPMbrw;
  Integer i,rwcnt,pmcnt;
  integer rows,cols,btnwidth,btnheight,hpad,vpad;
  string 255 label;
  Integer colnr;
//change RestPMOtherPayVClassOnOpenWindow when changing this

  btnwidth = 85;
  btnheight = 50;
  hpad = 5;
  vpad = 5;

  BlockLoad(RestPMb);
  BlockLoad(LMb);
  rwcnt = MatRowCnt(RestPMb);
  for (i=0;i<rwcnt;i=i+1) begin
    MatRowGet(RestPMb,i,RestPMbrw);
    if (RestPMbrw.MachineName==LMb.LocalMachineCode) then begin
      pmcnt = pmcnt + 1;
    end;
  end;

  cols = SquareRoot(pmcnt-1);
  cols = cols+1;
  rows = pmcnt/cols;
  if (mod(pmcnt,cols)!=0) then begin
    rows = rows + 1;
  end;

  SetWRect(20,80,20+(cols*btnwidth)+(cols+1)*hpad,80+(rows*btnheight)+(rows+1)*vpad);
  SoftEditField(20+(cols*btnwidth)+(cols+1)*hpad+100,v,20,"",Normal ,"Dummy",false,0,M4Str,2);

  h = hpad;
  v = vpad;
  pmcnt = 1;
  for (i=0;i<rwcnt;i=i+1) begin
    MatRowGet(RestPMb,i,RestPMbrw);
    if (RestPMbrw.MachineName==LMb.LocalMachineCode) then begin
      label = RestPMbrw.Label;
      colnr = RestPMbrw.colnr;
      if (colnr<=0) then begin colnr = 9; end;
      switch (RestPMbrw.rowstp) begin
        case kInvoiceRowTypeLoyaltyPointsPayment:
          if (blank(label)) then begin label = "Loy. Points"; end;            
        case kInvoiceRowTypeCashPayment:
          if (blank(label)) then begin label = "Cash"; end;            
        case kInvoiceRowTypeCreditCardPayment:
          if (blank(label)) then begin label = "Cred. Card"; end;            
        case kInvoiceRowTypeGiftVoucherPayment:
          if (blank(label)) then begin label = "Rcv. GV"; end;            
        case kInvoiceRowTypeChequePayment:
          if (blank(label)) then begin label = "Rcv. GV"; end;            
      end;
      SoftEditField(h+5,v+5,20,"",Normal ,"PMCode" & pmcnt,false,0,M4Str,2);
      SoftEditField(h+5,v+5,20,"",Normal ,"rowstp" & pmcnt,false,0,M4Str,2);
      ColourPushButton(h,v,h+btnwidth,v+btnheight,"RestPMOtherPayDsm" & pmcnt,label,colnr);
      h = h + btnwidth + hpad;
      if (Mod(pmcnt,cols)==0) then begin
        v = v + btnheight + vpad;
        h = hpad;
      end;
      pmcnt = pmcnt + 1;
    end;
  end;
  
  return;
end;
Related topics:
««