2 * HTMLAccountReportElement.cpp - TaskJuggler
4 * Copyright (c) 2001, 2002, 2003, 2004 by Chris Schlaeger <cs@kde.org>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of version 2 of the GNU General Public License as
8 * published by the Free Software Foundation.
13 #include "HTMLAccountReportElement.h"
14 #include "TableLineInfo.h"
15 #include "tjlib-internal.h"
19 HTMLAccountReportElement::HTMLAccountReportElement(Report* r,
22 HTMLReportElement(r, df, dl)
24 uint sc = r->getProject()->getMaxScenarios();
25 columns.append(new TableColumnInfo(sc, "no"));
26 columns.append(new TableColumnInfo(sc, "name"));
27 columns.append(new TableColumnInfo(sc, "total"));
29 accountSortCriteria[0] = CoreAttributesList::TreeMode;
30 accountSortCriteria[1] = CoreAttributesList::NameUp;
34 HTMLAccountReportElement::generate()
38 generateTableHeader();
40 s() << "<tbody>" << endl;
42 AccountList filteredList;
43 if (!filterAccountList(filteredList, AllAccounts, hideAccount,
46 maxDepthAccountList = filteredList.maxDepth();
48 /* Generate table of cost accounts. */
49 if (!filterAccountList(filteredList, Cost, hideAccount, rollUpAccount))
51 sortAccountList(filteredList);
52 maxDepthAccountList = filteredList.maxDepth();
56 for (AccountListIterator ali(filteredList); *ali != 0; ++ali, ++aNo)
58 tli.ca1 = tli.account = *ali;
59 for (uint sc = 0; sc < scenarios.count(); ++sc)
63 tli.sc = scenarios[sc];
64 tli.bgCol = colors.getColor("default").dark(100 + sc * 10);
65 generateLine(&tli, sc == 0 ? 6 : 7);
69 /* Generate summary line for cost accounts. */
71 tli.specialName = i18n("Total Costs");
72 for (uint sc = 0; sc < scenarios.count(); ++sc)
76 tli.sc = scenarios[sc];
77 tli.bgCol = colors.getColor("header").dark(100 + sc * 10);
78 generateLine(&tli, sc == 0 ? 8 : 9);
81 for (QPtrListIterator<TableColumnInfo> ci(columns); *ci != 0; ++ci)
83 (*ci)->addSumToMemory(true);
87 /* Generate table of revenue accounts. */
88 if (!filterAccountList(filteredList, Revenue, hideAccount, rollUpAccount))
90 sortAccountList(filteredList);
91 maxDepthAccountList = filteredList.maxDepth();
94 tli.specialName = QString::null;
95 for (AccountListIterator ali(filteredList); *ali != 0; ++ali, ++aNo)
97 tli.ca1 = tli.account = *ali;
98 for (uint sc = 0; sc < scenarios.count(); ++sc)
102 tli.sc = scenarios[sc];
103 tli.bgCol = colors.getColor("default").dark(100 + sc * 10);
104 generateLine(&tli, sc == 0 ? 6 : 7);
108 /* Generate summary line for revenue accounts. */
110 tli.specialName = i18n("Total Revenues");
111 for (uint sc = 0; sc < scenarios.count(); ++sc)
115 tli.sc = scenarios[sc];
116 tli.bgCol = colors.getColor("header").dark(100 + sc * 10);
117 generateLine(&tli, sc == 0 ? 8 : 9);
120 for (QPtrListIterator<TableColumnInfo> ci(columns); *ci != 0; ++ci)
122 (*ci)->addSumToMemory(false);
123 (*ci)->recallMemory();
126 /* Generate total summary line. */
127 tli.specialName = i18n("Total");
128 for (uint sc = 0; sc < scenarios.count(); ++sc)
132 tli.sc = scenarios[sc];
133 tli.bgCol = colors.getColor("default").dark(100 + sc * 10);
134 generateLine(&tli, sc == 0 ? 8 : 9);
137 s() << "</tbody>" << endl;
138 s() << "</table>" << endl;