Table of Content
HAL Forum
function boolean OpenForm (
string Name)
Description:
Opens a form with a specified code for filling the fields. Returns true if the form opening is successful.
Parameters:
Name Name of the form to open
global
procedure DoActDocForm(record RcVc RepSpec,record ActVc Actr)
BEGIN
  record DocVc Docr;
  record CUVc CUr;
  record SVOVc SVOr;
  record INVc INr;
  record FormDefVc FDr;
  row FormDefVc FDrw;
  Integer i,rwcnt;
  string 255 tstr;
  Boolean printf,langf;
  Integer intdocnr;
  string 30 formcode,langcode;
  record UserVc Userr;
    
  langcode = Actr.LangCode;
  FDr.repname = RepSpec.repname;
  FDr.shortname = RepSpec.shortname;
  if (ReadFirstMain(FDr,1,true)==false) then begin
    MessageBox(1624, " " & USetStr(1623));
    goto LDoActDocForm;
  end;
  rwcnt = MatRowCnt(FDr);
  for (i=rwcnt-1;i>=0;i=i-1) begin
    MatRowGet(FDr,i,FDrw);
    if (FDrw.LangCode==langcode) then begin
      i = -1;
      langf = true;
    end;
  end;
  if (langf==false) then begin langcode = ""; end;

  intdocnr = 1;
  printf = true;
  while (printf) begin  
    formcode = "";
    for (i=rwcnt-1;i>=0;i=i-1) begin
      MatRowGet(FDr,i,FDrw);
      if (FindFormcode(Actr.OKFlag,FDrw.Typ)) then begin 
        if (Getformcode(i,FDrw.intdocnr,FDrw.FPCode,FDrw.UserGroup,FDrw.LangCode,FDrw.SerNr,Actr.SerNr,FDrw.PrintGroupCode,
                        langcode,intdocnr,"ActVc",formcode)) then
        begin
          goto LBREAK;
        end;
      end;
    end;
LBREAK:;
    if (nonblank(formcode)) then begin  
      if (OpenForm(formcode)) then begin
        CommonDocumentFields(RepSpec);
        NumberofDocumentPages(formcode,MatRowCnt(Actr));
        CUr.Code = Actr.CUCode;
        if (ReadFirstMain(CUr,1,true)) then begin
        end;
        Docr.Code = formcode;
        if (ReadFirstMain(Docr,1,true)) then begin
        end;
        GetDateMonthInWords(Actr.TransDate,tstr);
        OUTFORMFIELD("F_DATEMONTHINWORDS",tstr);
        OutAddress("F_ADRESS",CUr.Name,CUr.InvAddr0,CUr.InvAddr1,CUr.InvAddr2,CUr.InvAddr3,CUr.InvAddr4);
        OUTFORMFIELD("F_KUNDTEL",CUr.Phone);
        OUTFORMFIELD("F_KUNDFAX",CUr.Fax);
        OUTFORMFIELD("F_ADDR1",CUr.Name);
        OUTFORMFIELD("F_ADDR2",CUr.InvAddr0);
        OUTFORMFIELD("F_ADDR3",CUr.InvAddr1);
        OUTFORMFIELD("F_ADDR4",CUr.InvAddr2);
        OUTFORMFIELD("F_INVADDR3",CUr.InvAddr3);
        OUTFORMFIELD("F_INVADDR4",CUr.InvAddr4);
        OUTFORMFIELD("F_EMAIL",CUr.eMail);
        OUTFORMFIELD("F_MOBILE",CUr.Mobile);
        OUTFORMFIELD("F_WWW",CUr.wwwAddr);
        OUTFORMFIELD("F_SEARCHKEY",CUr.SearchKey);
        OUTFORMFIELD("F_SORT",CUr.Sorting);
        OUTFORMFIELD("F_THEIRCODE",CUr.TheirCode);
        OUTFORMFIELD("F_COMMENT",CUr.Comment);
        OUTFORMFIELD("F_OBJECT",CUr.Objects); 
        OUTFORMFIELD("F_CLAS",CUr.Classification); 
        OUTFORMFIELD("F_CUSTCAT",CUr.CustCat);

        OUTFORMFIELD("F_KONTAKT",Actr.Contact);
        OUTFORMFIELD("F_KUNDNR",Actr.CUCode);
        OUTFORMFIELD("F_KUNDNAMN",Actr.CUName);
        OUTFORMFIELD("F_PERSON",Actr.MainPersons);
        OUTFORMFIELD("F_KOMMENTAR",Actr.Comment);
        OUTFORMFIELD("F_TRANSTID",Actr.StartTime);
        OUTFORMFIELD("F_ACTRESULT",Actr.ActResult);
        OUTFORMFIELD("F_ENDTIME",Actr.EndTime);
        OUTFORMFIELD("F_SUMTIME",Actr.CostTime);
        OUTFORMFIELD("F_KUNDMOMSNR",CUr.VATNr);
        OUTFORMFIELD("F_TRANSDATE",Actr.TransDate);
        OUTFORMFIELD("F_TRANSDATUM",Actr.TransDate);
        OUTFORMFIELD("F_SUPERVISOR",Actr.Supervisor);
        OUTFORMFIELD("F_PRIOLEVEL",Actr.PrioLevel);
        OUTFORMFIELD("F_SLUTDATUM",Actr.EndDate);
        OUTFORMFIELD("F_ACTTYPE",Actr.ActType);
        OUTFORMFIELD("F_PROJECT",Actr.PRCode);
        OUTFORMFIELD("F_SERNR",Actr.SerNr);
        OUTFORMFIELD("F_LANGUAGE",Actr.LangCode);
        PrintUserDefinedFields(Actr.UserStr1,Actr.UserStr2,Actr.UserStr3,Actr.UserStr4,Actr.UserStr5,Actr.UserDate1,Actr.UserDate2,Actr.UserDate3,Actr.UserVal1,Actr.UserVal2,Actr.UserVal3);
        PrintUserDefinedCustomerFields(CUr.UserStr1,CUr.UserStr2,CUr.UserStr3,CUr.UserStr4,CUr.UserStr5,CUr.UserDate1,CUr.UserDate2,CUr.UserDate3,CUr.UserVal1,CUr.UserVal2,CUr.UserVal3);
        OUTFORMFIELD("F_SERIENR",Actr.SerialNr);
        OUTFORMFIELD("F_SERVICEORDER",Actr.SVOSerNr);
        OUTFORMFIELD ("F_ITEMCODE",Actr.ArtCode);
        OUTFORMFIELD("F_PLANNEDPICKUP",Actr.UserDate1);
        OUTFORMFIELD("F_PLANNEDRETURN",Actr.UserDate2);
        if (FIELDINFORM("F_ORDERNO")) then begin
          SVOr.SerNr = Actr.SVOSerNr;
          if (ReadFirstMain(SVOr,1,true)) then begin
            OUTFORMFIELD("F_ORDERNO",SVOr.CustOrdNr);      
          end;
        end;
        IF (FIELDINFORM("F_BESKRIVNING")) then begin
          INr.Code = Actr.ArtCode;
          if (ReadFirstMain(INr,1,true)) then begin
            OUTFORMFIELD("F_BESKRIVNING",INr.Name);  
          end;
        end;
        tstr = GetMainPerson(Actr.MainPersons,1);
        if (nonblank(tstr)) then begin
          Userr.Code = tstr;
          if (ReadFirstMain(Userr,1,true)) then begin
          end;
          OUTFORMFIELD("F_USEREMAIL",Userr.emailAddr);
          OUTFORMFIELD("F_EMPLOYEENAME",Userr.Name);
        end;
        if (FIELDINFORM("F_ACTTYPECOMMENT")) then begin
          GetActTypeComment(Actr.ActType,tstr);
          OUTFORMFIELD("F_ACTTYPECOMMENT",tstr);
        end;
        if (FIELDINFORM("F_NOTE")) then begin
          GetFieldArgument(Docr,F_NOTE,tstr);
          ActPrintNote(Actr,tstr);
        end;
        PrintActRows(RepSpec,Actr);
        ActSetFax(CUr,Actr);
        CloseForm;        
      end else begin
        printf = false;
        MessageBox(1546,formcode);
      end;
    end else begin
      printf = false;
      if (intdocnr==1) then begin
        MessageBox(1624, " " & USetStr(1623));
      end;
    end;
    intdocnr = intdocnr + 1;
  end;
LDoActDocForm:;  
  RETURN;  
END;     
 
Related topics:
««