Table of Content
HAL Forum
function LongInt GlobalUsersMainCompany (
)
Description:
Returns the company code for the global user (where it has a record in the Persons register)
procedure DoNewActivity(Integer wn,string username,LongInt mother)
begin
  Integer nwn;
  record ActVc Actr;
  Date sd;
  Date ed;
  Date td;
  record RcVc RepSpec;
  string 255 tstr;
  Integer caltimeflag;
  Integer todoflag; 
  Integer AccessLevel; 
  Integer ProgramType;
  Integer oldcomp;
  
  oldcomp = CurrentCompany;
  if (GlobalUsersMainCompany>0) then begin // Only for Client code, is not set in the server
    if (GlobalUsersMainCompany!=CurrentCompany) then begin
      if (SetCompany(GlobalUsersMainCompany,false)) then begin
      end;
    end;
  end;

  caltimeflag = 0;
  todoflag = 1; 
  td = CurrentDate;
//  AccessLevel = UserRegisterAccess("ActVc");//VcAccessLevel("ActVc");
//  if ((AccessLevel==2) or (AccessLevel==5) or (AccessLevel==6)) then begin goto LDoNewActivity; end;
  if ((GetWindowClass(wn)=="MonthWClass") or
      (GetWindowClass(wn)=="HalfYearWClass")) then begin  
    GetWindowRecord(wn,RepSpec);
    sd = RepSpec.sStartDate;
    ed = RepSpec.sStartDate;
    tstr = RepSpec.f1;
    caltimeflag = 1;
    todoflag = 0;
  end;
  if (GetWindowClass(wn)=="WeekWClass") then begin
    GetWindowRecord(wn,RepSpec);
    sd = CurrentDate; // Why ???
    ed = CurrentDate;
    td = sd;
    tstr = RepSpec.f1;
    caltimeflag = 1;
    todoflag = 0;
  end;
  if (GetWindowClass(wn)=="DayWClass") then begin
    GetWindowRecord(wn,RepSpec);
    sd = RepSpec.sStartDate;
    ed = RepSpec.sStartDate;
    td = sd;
    tstr = RepSpec.f1;
    caltimeflag = 1;
    todoflag = 0;
  end;
  if (GetWindowClass(wn)=="ToDoWClass") then begin
    GetWindowRecord(wn,RepSpec);
    sd = RepSpec.sStartDate;
    ed = RepSpec.sStartDate;
    td = sd;
    td = CurrentDate;
    ed = CurrentDate;
    tstr = RepSpec.f1;
    caltimeflag = 0;
  end;
  ProgramType = GetProgramMode;
  if ((ProgramType==typFirstOffice) or 
      (ProgramType==typFirstOfficeSmall) or
      (ProgramType==typFirstOfficeCurrency) or
      (IsBooks)) then begin
    caltimeflag = 1;
  end;    
// this is how it should be 
//  nwn = OpenNamedView("ActDClass",0,NIL,true,0);
//  RecordNew(Actr);//that code is on server when server.hob in not present
  ActVcRecordDefClient(Actr);
  
  Actr.TodoFlag = todoflag;
  Actr.PrivateFlag = 0;
  Actr.Invalid = 0;
  Actr.TransDate = td;
  if (nonblankdate(ed)) then begin
    Actr.EndDate = ed;
  end;
  if (Actr.TransDate>Actr.EndDate) then begin Actr.EndDate = Actr.TransDate; end;
  Actr.CalTimeFlag = caltimeflag;
  if (nonblank(tstr)) then begin Actr.MainPersons = tstr; end;
  Actr.Mother = mother;
  
  nwn = OpenWindow("ActDClass",1,0,"","",Actr);

  WindowFieldGoto(nwn,Actr,-1,"Comment",true);
  //if (nwn!=0) then begin
  //  PutWindowRecord(nwn,Actr);
  //end;
  
LDoNewActivity:;
  ResetCompany(oldcomp);
  return;
end;
Related topics:
««