separate (Tracker.Report_Generator.Subsystem_Summary)

procedure Calc_Sumss_Totals is
    ----------------------------------------------------------------------
    --|  NAME:  CALC_SUMSS_TOTALS
    --|
    --|  OVERVIEW:
    --|    This procedure calculates the total amount of time left by
    --|    subsystem and by person.
    --|
    --|  EXCEPTIONS HANDLED:
    --|    none
    --|
    --|  HISTORY:
    --|    written by   Bonnie Burkhardt   March 1985
    ----------------------------------------------------------------------

    End_List : Boolean := False;
    Ele_Ptr : Element_Pointer;
    Pr_Index : Integer := 0;
    Pr_Ptr : Personnel_Pointer;

begin
    Time_Done := (others => 0.0);
    Ss_Time := 0.0;

    -- find the totals for each subsystem
    Pr_Index := 0;
    Start_Walk (Pr_List);

    loop
        Walk (Pr_List, Pr_Ptr, End_List);
        exit when End_List;
        Pr_Index := Pr_Index + 1;

        -- sum the time left to complete for each element that has
        -- this subsystem and this person
        Start_Walk (Pr_Ptr.Element_List);

        loop
            Walk (Pr_Ptr.Element_List, Ele_Ptr, End_List);
            exit when End_List;

            if Ele_Ptr.Subsystem_Name = Ss_Ptr.Name then
                if Ele_Ptr.More_Than_One_Person then
                    for Ac_Index in 1 .. Num_Of_Activities loop
                        Time_Done (Pr_Index) :=
                           Time_Done (Pr_Index) + Ele_Ptr.Hours_Left (Ac_Index);
                    end loop;
                else
                    Time_Done (Pr_Index) := Time_Done (Pr_Index) +
                                               Ele_Ptr.Hours_To_Complete;
                end if;
            end if;

        end loop;

        Tot_Time_Done (Pr_Index) :=
           Tot_Time_Done (Pr_Index) + Time_Done (Pr_Index);
        Ss_Time := Ss_Time + Time_Done (Pr_Index);
    end loop;

    Tot_Ss_Time := Tot_Ss_Time + Ss_Time;
end Calc_Sumss_Totals;
