OSDN Git Service

Added columns 'completedeffort' and 'remainingeffort' to reports.
[tjqt4port/tj2qt4.git] / taskjuggler / HTMLReportElement.cpp
index b76c34e..e247ea4 100644 (file)
 
 #include "HTMLReportElement.h"
 
-#include <config.h>
 #include <assert.h>
 
 #include "TjMessageHandler.h"
 #include "tjlib-internal.h"
 #include "Project.h"
-#include "Task.h"
 #include "Resource.h"
 #include "Account.h"
-#include "Report.h"
-#include "Booking.h"
 #include "BookingList.h"
 #include "Utility.h"
 #include "MacroTable.h"
-#include "TableColumnFormat.h"
 #include "TableLineInfo.h"
-#include "TableColumnInfo.h"
 #include "TableCellInfo.h"
 #include "ReferenceAttribute.h"
 #include "TextAttribute.h"
@@ -79,14 +73,14 @@ HTMLReportElement::generateTableHeader()
     // Header line 1
     s() << "<table align=\"center\" cellpadding=\"2\" "
         << "style=\"background-color:#000000\"";
-    if (((HTMLReport*) report)->hasStyleSheet())
+    if (static_cast<HTMLReport*>(report)->hasStyleSheet())
         s() << " class=\"tj_table\"";
     s() << ">" << endl;
     s() << " <thead>" << endl
         << "  <tr valign=\"middle\""
         << " style=\"background-color:" << colors.getColorName("header") << "; "
         << "font-size:110%; font-weight:bold; text-align:center\"";
-    if (((HTMLReport*) report)->hasStyleSheet())
+    if (static_cast<HTMLReport*>(report)->hasStyleSheet())
         s() << " class=\"tj_header_row\"";
     s() << ">" << endl;
     for (QPtrListIterator<TableColumnInfo> it(columns); it; ++it )
@@ -114,7 +108,7 @@ HTMLReportElement::generateTableHeader()
     s() << "  </tr>" << endl;
 
     // Header line 2
-    bool first = TRUE;
+    bool first = true;
     for (QPtrListIterator<TableColumnInfo> it(columns); it; ++it )
     {
         if (columnFormat[(*it)->getName()])
@@ -123,10 +117,10 @@ HTMLReportElement::generateTableHeader()
                 if (first)
                 {
                     s() << "  <tr";
-                    if (((HTMLReport*) report)->hasStyleSheet())
+                    if (static_cast<HTMLReport*>(report)->hasStyleSheet())
                         s() << " class=\"tj_header_row\"";
                     s() << ">" << endl;
-                    first = FALSE;
+                    first = false;
                 }
 
                 TableCellInfo tci(columnFormat[(*it)->getName()], 0, *it);
@@ -165,7 +159,7 @@ HTMLReportElement::generateLine(TableLineInfo* tli, int funcSel)
        }
        puts("\"");
     }
-    if (((HTMLReport*) report)->hasStyleSheet())
+    if (static_cast<HTMLReport*>(report)->hasStyleSheet())
         puts(" class=\"tj_row\"");
     puts(">\n");
 
@@ -317,19 +311,15 @@ HTMLReportElement::genCell(const QString& text, TableCellInfo* tci,
         cellText = filter ? htmlFilter(text) : text;
         if (tci->tli->ca1 && !tci->tci->getCellText().isEmpty())
         {
-            QStringList* sl = new QStringList();
-            sl->append(text);
-            cellText = mt.expandReportVariable(tci->tci->getCellText(), sl);
-            delete sl;
+            QStringList sl(text);
+            cellText = mt.expandReportVariable(tci->tci->getCellText(), &sl);
         }
     }
     if (!tci->tci->getCellURL().isEmpty() && (tci->tli->ca1 == 0 ||
         !isHidden(tci->tli->ca1, tci->tci->getHideCellURL())))
     {
-        QStringList* sl = new QStringList();
-        sl->append(text);
-        QString cellURL = mt.expandReportVariable(tci->tci->getCellURL(), sl);
-        delete sl;
+        QStringList sl(text);
+        QString cellURL = mt.expandReportVariable(tci->tci->getCellURL(), &sl);
        if (!cellURL.isEmpty())
        {
            cellText = QString("<a href=\"") + cellURL
@@ -338,7 +328,7 @@ HTMLReportElement::genCell(const QString& text, TableCellInfo* tci,
     }
     if (cellText.isEmpty())
         cellText = "&#160;";
-    if (((HTMLReport*) report)->hasStyleSheet())
+    if (static_cast<HTMLReport*>(report)->hasStyleSheet())
         puts(" class=\"tj_cell\"");
     puts(">");
     if (!tci->getToolTipText().isEmpty())
@@ -419,7 +409,7 @@ HTMLReportElement::reportTaskLoad(double load, TableCellInfo* tci,
     {
         tci->setStatusText("");
     }
-    genCell(text, tci, FALSE);
+    genCell(text, tci, false);
 }
 
 void
@@ -442,7 +432,7 @@ HTMLReportElement::reportResourceLoad(double load, TableCellInfo* tci,
     {
         tci->setStatusText("");
     }
-    genCell(text, tci, FALSE);
+    genCell(text, tci, false);
 }
 
 void
@@ -452,22 +442,20 @@ HTMLReportElement::reportCurrency(double value, TableCellInfo* tci,
     tci->setStatusText(time2user(iv_start, "%Y-%m-%d / [") +
                        tci->tli->account->getId() + "] " +
                        htmlFilter(tci->tli->account->getName()));
-    genCell(tci->tcf->realFormat.format(value, tci), tci, FALSE);
+    genCell(tci->tcf->realFormat.format(value, tci), tci, false);
 }
 
 void
 HTMLReportElement::generateTitle(TableCellInfo* tci, const QString& str)
 {
-    QStringList* sl = new QStringList();
-    sl->append(str);
+    QStringList sl(str);
     QString cellText;
     if (!tci->tci->getTitle().isEmpty())
-        cellText = mt.expandReportVariable(tci->tci->getTitle(), sl);
+        cellText = mt.expandReportVariable(tci->tci->getTitle(), &sl);
     else
         cellText = str;
     cellText = htmlFilter(cellText);
-    QString cellURL = mt.expandReportVariable(tci->tci->getTitleURL(), sl);
-    delete sl;
+    QString cellURL = mt.expandReportVariable(tci->tci->getTitleURL(), &sl);
     if (!cellURL.isEmpty())
         cellText = QString("<a href=\"") + cellURL
             + "\">" + cellText + "</a>";
@@ -478,16 +466,14 @@ HTMLReportElement::generateTitle(TableCellInfo* tci, const QString& str)
 void
 HTMLReportElement::generateSubTitle(TableCellInfo* tci, const QString& str)
 {
-    QStringList* sl = new QStringList();
-    sl->append(str);
+    QStringList sl(str);
     QString cellText;
     if (!tci->tci->getSubTitle().isEmpty())
-        cellText = mt.expandReportVariable(tci->tci->getSubTitle(), sl);
+        cellText = mt.expandReportVariable(tci->tci->getSubTitle(), &sl);
     else
         cellText = str;
     cellText = htmlFilter(cellText);
-    QString cellURL = mt.expandReportVariable(tci->tci->getSubTitleURL(), sl);
-    delete sl;
+    QString cellURL = mt.expandReportVariable(tci->tci->getSubTitleURL(), &sl);
     if (!cellURL.isEmpty())
         cellText = QString("<a href=\"") + cellURL
             + "\">" + cellText + "</a>";
@@ -521,14 +507,14 @@ HTMLReportElement::generateRightIndented(TableCellInfo* tci, const QString& str)
     tci->setRightPadding(2 + topIndent +
                          (maxDepth - 1 - tci->tli->ca1->treeLevel()) *
                          subIndent);
-    genCell(str, tci, FALSE);
+    genCell(str, tci, false);
 }
 
 void
 HTMLReportElement::genHeadDefault(TableCellInfo* tci)
 {
     puts("   <td rowspan=\"2\"");
-    if (((HTMLReport*) report)->hasStyleSheet())
+    if (static_cast<HTMLReport*>(report)->hasStyleSheet())
         puts(" class=\"tj_header_cell\"");
     puts(">");
     generateTitle(tci, tci->tcf->getTitle());
@@ -539,7 +525,7 @@ void
 HTMLReportElement::genHeadCurrency(TableCellInfo* tci)
 {
     puts("   <td rowspan=\"2\"");
-    if (((HTMLReport*) report)->hasStyleSheet())
+    if (static_cast<HTMLReport*>(report)->hasStyleSheet())
         puts(" class=\"tj_header_cell\"");
     puts(">");
     generateTitle(tci, tci->tcf->getTitle() +
@@ -562,7 +548,7 @@ HTMLReportElement::genHeadDaily1(TableCellInfo* tci)
             left = daysBetween(day, end);
         s() << "   <td colspan=\""
             << QString().sprintf("%d", left) << "\"";
-        if (((HTMLReport*) report)->hasStyleSheet())
+        if (static_cast<HTMLReport*>(report)->hasStyleSheet())
             s() << " class=\"tj_header_cell\"";
         s() << ">";
         mt.setMacro(new Macro(KW("day"), "01",
@@ -602,7 +588,7 @@ HTMLReportElement::genHeadDaily2(TableCellInfo* tci)
             bgCol = colors.getColor("today");
         s() << "background-color:" << bgCol.name() << "; "
             << "font-size:80%; text-align:center\"";
-        if (((HTMLReport*) report)->hasStyleSheet())
+        if (static_cast<HTMLReport*>(report)->hasStyleSheet())
             s() << " class=\"tj_header_cell\"";
         s() << ">";
         mt.setMacro(new Macro(KW("day"), QString().sprintf("%02d", dom),
@@ -645,7 +631,7 @@ HTMLReportElement::genHeadWeekly1(TableCellInfo* tci)
 
         s() << "   <td colspan=\""
           << QString().sprintf("%d", left) << "\"";
-        if (((HTMLReport*) report)->hasStyleSheet())
+        if (static_cast<HTMLReport*>(report)->hasStyleSheet())
             s() << " class=\"tj_header_cell\"";
         s() << ">";
         mt.setMacro(new Macro(KW("day"), QString().sprintf
@@ -694,7 +680,7 @@ HTMLReportElement::genHeadWeekly2(TableCellInfo* tci)
             bgCol = colors.getColor("header");
         s() << "background-color:" << bgCol.name() << "; "
             << "font-size:80%; text-align:center\"";
-        if (((HTMLReport*) report)->hasStyleSheet())
+        if (static_cast<HTMLReport*>(report)->hasStyleSheet())
             s() << " class=\"tj_header_cell\"";
         s() << ">";
         if (woy < 10)
@@ -733,7 +719,7 @@ HTMLReportElement::genHeadMonthly1(TableCellInfo* tci)
             left = monthsBetween(year, end);
         s() << "   <td colspan=\""
           << QString().sprintf("%d", left) << "\"";
-        if (((HTMLReport*) report)->hasStyleSheet())
+        if (static_cast<HTMLReport*>(report)->hasStyleSheet())
             s() << " class=\"tj_header_cell\"";
         s() << ">";
         mt.setMacro(new Macro(KW("day"), "01",
@@ -769,7 +755,7 @@ HTMLReportElement::genHeadMonthly2(TableCellInfo* tci)
             bgCol = colors.getColor("header");
         s() << "background-color:" << bgCol.name() << "; "
             << "font-size:80%; text-align:center\"";
-        if (((HTMLReport*) report)->hasStyleSheet())
+        if (static_cast<HTMLReport*>(report)->hasStyleSheet())
             s() << " class=\"tj_header_cell\"";
         s() << ">";
         if (month < 10)
@@ -807,7 +793,7 @@ HTMLReportElement::genHeadQuarterly1(TableCellInfo* tci)
             left = quartersBetween(year, end);
         s() << "   <td colspan=\""
           << QString().sprintf("%d", left) << "\"";
-        if (((HTMLReport*) report)->hasStyleSheet())
+        if (static_cast<HTMLReport*>(report)->hasStyleSheet())
             s() << " class=\"tj_header_cell\"";
         s() << ">";
         mt.setMacro(new Macro(KW("day"), "01",
@@ -849,7 +835,7 @@ HTMLReportElement::genHeadQuarterly2(TableCellInfo* tci)
             bgCol = colors.getColor("header");
         s() << "background-color:" << bgCol.name() << "; "
             << "font-size:80%; text-align:center\"";
-        if (((HTMLReport*) report)->hasStyleSheet())
+        if (static_cast<HTMLReport*>(report)->hasStyleSheet())
             s() << " class=\"tj_header_cell\"";
         s() << ">";
         mt.setMacro(new Macro(KW("day"), QString().sprintf("%02d",
@@ -881,7 +867,7 @@ HTMLReportElement::genHeadYear(TableCellInfo* tci)
          year = sameTimeNextYear(year))
     {
         s() << "   <td rowspan=\"2\"";
-        if (((HTMLReport*) report)->hasStyleSheet())
+        if (static_cast<HTMLReport*>(report)->hasStyleSheet())
             s() << " class=\"tj_header_cell\"";
         s() << ">";
         mt.setMacro(new Macro(KW("day"), QString().sprintf("%02d",
@@ -905,7 +891,7 @@ HTMLReportElement::genHeadYear(TableCellInfo* tci)
 void
 HTMLReportElement::genCellEmpty(TableCellInfo* tci)
 {
-    genCell("", tci, TRUE);
+    genCell("", tci, true);
 }
 
 void
@@ -913,21 +899,21 @@ HTMLReportElement::genCellSequenceNo(TableCellInfo* tci)
 {
     genCell(tci->tli->ca2 == 0 ?
             QString().sprintf("%d.", tci->tli->ca1->getSequenceNo()) :
-            QString::null, tci, TRUE);
+            QString::null, tci, true);
 }
 
 void
 HTMLReportElement::genCellNo(TableCellInfo* tci)
 {
     genCell(tci->tli->ca2 == 0 ? QString().sprintf("%d.", tci->tli->idxNo) :
-            QString::null, tci, TRUE);
+            QString::null, tci, true);
 }
 
 void
 HTMLReportElement::genCellHierarchNo(TableCellInfo* tci)
 {
     genCell(tci->tli->ca2 == 0 ?
-            tci->tli->ca1->getHierarchNo() : QString::null, tci, TRUE);
+            tci->tli->ca1->getHierarchNo() : QString::null, tci, true);
 }
 
 void
@@ -935,20 +921,20 @@ HTMLReportElement::genCellIndex(TableCellInfo* tci)
 {
     genCell(tci->tli->ca2 == 0 ?
             QString().sprintf("%d.", tci->tli->ca1->getIndex()) :
-            QString::null, tci, TRUE);
+            QString::null, tci, true);
 }
 
 void
 HTMLReportElement::genCellHierarchIndex(TableCellInfo* tci)
 {
     genCell(tci->tli->ca2 == 0 ?
-            tci->tli->ca1->getHierarchIndex() : QString::null, tci, TRUE);
+            tci->tli->ca1->getHierarchIndex() : QString::null, tci, true);
 }
 
 void
 HTMLReportElement::genCellId(TableCellInfo* tci)
 {
-    genCell(tci->tli->ca1->getId(), tci, TRUE);
+    genCell(tci->tli->ca1->getId(), tci, true);
 }
 
 void
@@ -995,7 +981,7 @@ HTMLReportElement::genCellName(TableCellInfo* tci)
     }
     else
         text = tci->tli->specialName;
-    genCell(text, tci, TRUE);
+    genCell(text, tci, true);
 }
 
 void
@@ -1004,7 +990,7 @@ HTMLReportElement::genCellStart(TableCellInfo* tci)
     if (!tci->tli->task->isStartOk(tci->tli->sc))
         tci->setBgColor(colors.getColor("error"));
     genCell(time2user(tci->tli->task->getStart(tci->tli->sc), timeFormat),
-            tci, FALSE);
+            tci, false);
 }
 
 void
@@ -1013,7 +999,7 @@ HTMLReportElement::genCellEnd(TableCellInfo* tci)
     if (!tci->tli->task->isEndOk(tci->tli->sc))
         tci->setBgColor(colors.getColor("error"));
     genCell(time2user(tci->tli->task->getEnd(tci->tli->sc) + 1, timeFormat),
-            tci, FALSE);
+            tci, false);
 }
 
 #define GCMMSE(a, b) \
@@ -1022,7 +1008,7 @@ HTMLReportElement::genCell##a(TableCellInfo* tci) \
 { \
     genCell(tci->tli->task->get##a(tci->tli->sc) == 0 ? QString() : \
             time2user(tci->tli->task->get##a(tci->tli->sc) + b, timeFormat), \
-            tci, FALSE); \
+            tci, false); \
 }
 
 GCMMSE(MinStart, 0)
@@ -1036,7 +1022,7 @@ HTMLReportElement::genCell##a##Buffer(TableCellInfo* tci) \
 { \
     genCell(QString().sprintf \
             ("%3.0f", tci->tli->task->get##a##Buffer(tci->tli->sc)), \
-            tci, FALSE); \
+            tci, false); \
 }
 
 GCSEBUFFER(Start)
@@ -1046,14 +1032,14 @@ void
 HTMLReportElement::genCellStartBufferEnd(TableCellInfo* tci)
 {
     genCell(time2user(tci->tli->task->getStartBufferEnd
-                         (tci->tli->sc), timeFormat), tci, FALSE);
+                         (tci->tli->sc), timeFormat), tci, false);
 }
 
 void
 HTMLReportElement::genCellEndBufferStart(TableCellInfo* tci)
 {
     genCell(time2user(tci->tli->task->getStartBufferEnd
-                      (tci->tli->sc) + 1, timeFormat), tci, FALSE);
+                      (tci->tli->sc) + 1, timeFormat), tci, false);
 }
 
 void
@@ -1061,7 +1047,7 @@ HTMLReportElement::genCellDuration(TableCellInfo* tci)
 {
     genCell(scaledDuration(tci->tli->task->getCalcDuration(tci->tli->sc),
                            tci->tcf->realFormat),
-            tci, FALSE);
+            tci, false);
 }
 
 void
@@ -1075,8 +1061,8 @@ HTMLReportElement::genCellEffort(TableCellInfo* tci)
     }
     else if (tci->tli->ca1->getType() == CA_Resource)
     {
-        val = tci->tli->resource->getLoad(tci->tli->sc, Interval(start, end),
-                                          AllAccounts, tci->tli->task);
+        val = tci->tli->resource->getEffectiveLoad
+            (tci->tli->sc, Interval(start, end), AllAccounts, tci->tli->task);
     }
 
     generateRightIndented(tci, scaledLoad(val, tci->tcf->realFormat));
@@ -1088,7 +1074,7 @@ HTMLReportElement::genCellFreeLoad(TableCellInfo* tci)
     double val = 0.0;
     if (tci->tli->ca1->getType() == CA_Resource)
     {
-        val = tci->tli->resource->getAvailableWorkLoad
+        val = tci->tli->resource->getEffectiveFreeLoad
             (tci->tli->sc, Interval(start, end));
     }
 
@@ -1101,12 +1087,12 @@ HTMLReportElement::genCellUtilization(TableCellInfo* tci)
     double val = 0.0;
     if (tci->tli->ca1->getType() == CA_Resource)
     {
-        double load =
-            tci->tli->resource->getLoad(tci->tli->sc, Interval(start, end));
+        double load = tci->tli->resource->getEffectiveLoad
+            (tci->tli->sc, Interval(start, end));
         if (load > 0.0)
         {
             double availableLoad =
-                tci->tli->resource->getAvailableWorkLoad
+                tci->tli->resource->getEffectiveFreeLoad
                 (tci->tli->sc, Interval(start, end));
 
             val = 100.0 / (1.0 + availableLoad / load);
@@ -1138,14 +1124,14 @@ HTMLReportElement::genCellProjectId(TableCellInfo* tci)
     genCell(tci->tli->task->getProjectId() + " (" +
             report->getProject()->getIdIndex(tci->tli->task->
                                              getProjectId()) + ")", tci,
-            TRUE);
+            true);
 }
 
 void
 HTMLReportElement::genCellProjectIDs(TableCellInfo* tci)
 {
     genCell(tci->tli->resource->getProjectIDs(tci->tli->sc,
-                                              Interval(start, end)), tci, TRUE);
+                                              Interval(start, end)), tci, true);
 }
 
 void
@@ -1161,7 +1147,7 @@ HTMLReportElement::genCellResources(TableCellInfo* tci)
 
         text += (*rli)->getName();
     }
-    genCell(text, tci, FALSE);
+    genCell(text, tci, false);
 }
 
 void
@@ -1169,9 +1155,9 @@ HTMLReportElement::genCellResponsible(TableCellInfo* tci)
 {
     if (tci->tli->task->getResponsible())
         genCell(tci->tli->task->getResponsible()->getName(),
-                tci, TRUE);
+                tci, true);
     else
-        genCell("", tci, TRUE);
+        genCell("", tci, true);
 }
 
 void
@@ -1180,28 +1166,28 @@ HTMLReportElement::genCellText(TableCellInfo* tci)
     if (tci->tcf->getId() == "note")
     {
         if (tci->tli->task->getNote().isEmpty())
-            genCell("", tci, TRUE);
+            genCell("", tci, true);
         else
-            genCell(tci->tli->task->getNote(), tci, TRUE);
+            genCell(tci->tli->task->getNote(), tci, true);
         return;
     }
 
-    const TextAttribute* ta = (const TextAttribute*)
-        tci->tli->ca1->getCustomAttribute(tci->tcf->getId());
+    const TextAttribute* ta = static_cast<const TextAttribute*>
+        (tci->tli->ca1->getCustomAttribute(tci->tcf->getId()));
     if (!ta || ta->getText().isEmpty())
-        genCell("", tci, TRUE);
+        genCell("", tci, true);
     else
-        genCell(ta->getText(), tci, TRUE);
+        genCell(ta->getText(), tci, true);
 }
 
 void
 HTMLReportElement::genCellStatusNote(TableCellInfo* tci)
 {
     if (tci->tli->task->getStatusNote(tci->tli->sc).isEmpty())
-        genCell("", tci, TRUE);
+        genCell("", tci, true);
     else
         genCell(tci->tli->task->getStatusNote(tci->tli->sc),
-                tci, TRUE);
+                tci, true);
 }
 
 void
@@ -1263,7 +1249,7 @@ void
 HTMLReportElement::genCellPriority(TableCellInfo* tci)
 {
     genCell(QString().sprintf("%d", tci->tli->task->getPriority()),
-            tci, TRUE);
+            tci, true);
 }
 
 void
@@ -1278,7 +1264,7 @@ HTMLReportElement::genCellFlags(TableCellInfo* tci)
             flagStr += ", ";
         flagStr += *it;
     }
-    genCell(flagStr, tci, TRUE);
+    genCell(flagStr, tci, true);
 }
 
 void
@@ -1293,13 +1279,13 @@ HTMLReportElement::genCellCompleted(TableCellInfo* tci)
     {
         if (calcedCompletionDegree == providedCompletionDegree)
         {
-            genCell(QString(i18n("in progress")), tci, FALSE);
+            genCell(QString(i18n("in progress")), tci, false);
         }
         else
         {
             genCell(QString(i18n("%1% (in progress)"))
                     .arg((int) providedCompletionDegree),
-                    tci, FALSE);
+                    tci, false);
         }
     }
     else
@@ -1307,22 +1293,85 @@ HTMLReportElement::genCellCompleted(TableCellInfo* tci)
         if (calcedCompletionDegree == providedCompletionDegree)
         {
             genCell(QString("%1%").arg((int) providedCompletionDegree),
-                    tci, FALSE);
+                    tci, false);
         }
         else
         {
             genCell(QString("%1% (%2%)")
                     .arg((int) providedCompletionDegree)
                     .arg((int) calcedCompletionDegree),
-                    tci, FALSE);
+                    tci, false);
         }
     }
 }
 
 void
+HTMLReportElement::genCellCompletedEffort(TableCellInfo* tci)
+{
+    double val = 0.0;
+
+    if (!tci->tli->resource && tci->tli->task->isLeaf())
+    {
+        // Task line, no resource.
+        val = tci->tli->task->getCompletedLoad(tci->tli->sc);
+    }
+    else if (tci->tli->ca2->getType() == CA_Resource &&
+             tci->tli->task && tci->tli->task->isLeaf())
+    {
+        // Task line, nested into a resource
+        const Project* project = report->getProject();
+        time_t now = project->getNow();
+        if (now < project->getStart())
+            now = project->getStart();
+        if (now > project->getEnd())
+            now = project->getEnd();
+        Interval iv = Interval(project->getStart(), now);
+        val = tci->tli->task->getLoad(tci->tli->sc, iv, tci->tli->resource);
+    }
+    else
+    {
+        genCell("", tci, false);
+        return;
+    }
+    generateRightIndented(tci, scaledLoad(val, tci->tcf->realFormat));
+}
+
+void
+HTMLReportElement::genCellRemainingEffort(TableCellInfo* tci)
+{
+    double val = 0.0;
+
+    if (!tci->tli->resource && tci->tli->task->isLeaf())
+    {
+        // Task line, no resource.
+        val = tci->tli->task->getRemainingLoad(tci->tli->sc);
+    }
+    else if (tci->tli->ca2->getType() == CA_Resource &&
+             tci->tli->task && tci->tli->task->isLeaf())
+    {
+        // Task line, nested into a resource
+        const Project* project = report->getProject();
+        time_t now = project->getNow();
+        if (now < project->getStart())
+            now = project->getStart();
+        if (now > project->getEnd())
+            now = project->getEnd();
+        Interval iv = Interval(now, project->getEnd());
+        val = tci->tli->task->getLoad(tci->tli->sc, iv, tci->tli->resource);
+    }
+    else
+    {
+        genCell("", tci, false);
+        return;
+    }
+
+    generateRightIndented(tci, scaledLoad(val, tci->tcf->realFormat));
+}
+
+void
 HTMLReportElement::genCellStatus(TableCellInfo* tci)
 {
-    genCell(tci->tli->task->getStatusText(tci->tli->sc), tci, FALSE);
+    genCell(tci->tli->task->getStatusText(tci->tli->sc), tci, false);
 }
 
 void
@@ -1331,7 +1380,7 @@ HTMLReportElement::genCellReference(TableCellInfo* tci)
     if (tci->tcf->getId() == "reference")
     {
         if (tci->tli->task->getReference().isEmpty())
-            genCell("", tci, TRUE);
+            genCell("", tci, true);
         else
         {
             QString text ="<a href=\"" + tci->tli->task->getReference() + "\">";
@@ -1340,15 +1389,15 @@ HTMLReportElement::genCellReference(TableCellInfo* tci)
             else
                 text += htmlFilter(tci->tli->task->getReferenceLabel());
             text += "</a>";
-            genCell(text, tci, TRUE, FALSE);
+            genCell(text, tci, true, false);
         }
         return;
     }
 
-    const ReferenceAttribute* ra =  (const ReferenceAttribute*)
-        tci->tli->ca1->getCustomAttribute(tci->tcf->getId());
+    const ReferenceAttribute* ra = static_cast<const ReferenceAttribute*>
+        (tci->tli->ca1->getCustomAttribute(tci->tcf->getId()));
     if (!ra || ra->getURL().isEmpty())
-        genCell("", tci, TRUE);
+        genCell("", tci, true);
     else
     {
         QString text ="<a href=\"" + ra->getURL() + "\">";
@@ -1357,14 +1406,14 @@ HTMLReportElement::genCellReference(TableCellInfo* tci)
         else
             text += htmlFilter(ra->getLabel());
         text += "</a>";
-        genCell(text, tci, TRUE, FALSE);
+        genCell(text, tci, true, false);
     }
 }
 
 void
 HTMLReportElement::genCellScenario(TableCellInfo* tci)
 {
-    genCell(report->getProject()->getScenarioName(tci->tli->sc), tci, FALSE);
+    genCell(report->getProject()->getScenarioName(tci->tli->sc), tci, false);
 }
 
 #define GCDEPFOL(a, b) \
@@ -1379,7 +1428,7 @@ HTMLReportElement::genCell##a(TableCellInfo* tci) \
             text += ", "; \
         text += (*it)->getId(); \
     } \
-    genCell(text, tci, TRUE); \
+    genCell(text, tci, true); \
 }
 
 GCDEPFOL(Depends, Previous)
@@ -1451,8 +1500,9 @@ HTMLReportElement::selectResourceBgColor(TableCellInfo* tci, double load,
     {
         bgCol = colors.getColor("today");
     }
-    else if (tci->tli->resource->getLoad(tci->tli->sc, period) == 0.0 &&
-             tci->tli->resource->getAvailableWorkLoad(tci->tli->sc, period) ==
+    else if (tci->tli->resource->getEffectiveLoad
+             (tci->tli->sc, period) == 0.0 &&
+             tci->tli->resource->getEffectiveFreeLoad(tci->tli->sc, period) ==
              0.0)
     {
             bgCol = colors.getColor("vacation");
@@ -1508,8 +1558,8 @@ HTMLReportElement::genCellResourceFunc(TableCellInfo* tci, bool daily,
     for (time_t t = beginOfT(start); t < end; t = sameTimeNextT(t))
     {
         Interval period = Interval(t, sameTimeNextT(t) - 1);
-        double load = tci->tli->resource->getLoad(tci->tli->sc, period,
-                                                  AllAccounts, tci->tli->task);
+        double load = tci->tli->resource->getEffectiveLoad
+            (tci->tli->sc, period, AllAccounts, tci->tli->task);
         QColor bgCol = selectResourceBgColor(tci, load, period, daily);
 
         int runLength = 1;
@@ -1520,9 +1570,8 @@ HTMLReportElement::genCellResourceFunc(TableCellInfo* tci, bool daily,
                  endT = sameTimeNextT(endT))
             {
                 Interval periodProbe = Interval(endT, sameTimeNextT(endT) - 1);
-                double loadProbe =
-                    tci->tli->resource->getLoad(tci->tli->sc, periodProbe,
-                                                AllAccounts, tci->tli->task);
+                double loadProbe = tci->tli->resource->getEffectiveLoad
+                    (tci->tli->sc, periodProbe, AllAccounts, tci->tli->task);
                 QColor bgColProbe = selectResourceBgColor(tci, loadProbe,
                                                           periodProbe, daily);
 
@@ -1561,13 +1610,13 @@ HTMLReportElement::genCellAccountFunc(TableCellInfo* tci,
 void
 HTMLReportElement::genCellDailyTask(TableCellInfo* tci)
 {
-    genCellTaskFunc(tci, TRUE, midnight, sameTimeNextDay);
+    genCellTaskFunc(tci, true, midnight, sameTimeNextDay);
 }
 
 void
 HTMLReportElement::genCellDailyResource(TableCellInfo* tci)
 {
-    genCellResourceFunc(tci, TRUE, midnight, sameTimeNextDay);
+    genCellResourceFunc(tci, true, midnight, sameTimeNextDay);
 }
 
 void
@@ -1586,7 +1635,7 @@ HTMLReportElement::genCellWeeklyTask(TableCellInfo* tci)
         Interval period = Interval(week, sameTimeNextWeek(week) - 1);
         double load = tci->tli->task->getLoad(tci->tli->sc, period,
                                               tci->tli->resource);
-        QColor bgCol = selectTaskBgColor(tci, load, period, FALSE);
+        QColor bgCol = selectTaskBgColor(tci, load, period, false);
 
         int runLength = 1;
         if (!tci->tli->task->isActive(tci->tli->sc, period))
@@ -1601,7 +1650,7 @@ HTMLReportElement::genCellWeeklyTask(TableCellInfo* tci)
                                                            periodProbe,
                                                            tci->tli->resource);
                 QColor bgColProbe = selectTaskBgColor(tci, loadProbe,
-                                                      periodProbe, FALSE);
+                                                      periodProbe, false);
                 if (load != loadProbe || bgCol != bgColProbe)
                     break;
                 lastEndWeek = endWeek;
@@ -1624,9 +1673,9 @@ HTMLReportElement::genCellWeeklyResource(TableCellInfo* tci)
          week = sameTimeNextWeek(week))
     {
         Interval period = Interval(week, sameTimeNextWeek(week) - 1);
-        double load = tci->tli->resource->getLoad(tci->tli->sc, period,
-                                                  AllAccounts, tci->tli->task);
-        QColor bgCol = selectResourceBgColor(tci, load, period, FALSE);
+        double load = tci->tli->resource->getEffectiveLoad
+            (tci->tli->sc, period, AllAccounts, tci->tli->task);
+        QColor bgCol = selectResourceBgColor(tci, load, period, false);
 
         int runLength = 1;
         if (load == 0.0)
@@ -1637,11 +1686,10 @@ HTMLReportElement::genCellWeeklyResource(TableCellInfo* tci)
             {
                 Interval periodProbe = Interval(endWeek)
                     .firstWeek(weekStartsMonday);
-                double loadProbe =
-                    tci->tli->resource->getLoad(tci->tli->sc, periodProbe,
-                                                AllAccounts, tci->tli->task);
+                double loadProbe = tci->tli->resource->getEffectiveLoad
+                    (tci->tli->sc, periodProbe, AllAccounts, tci->tli->task);
                 QColor bgColProbe = selectResourceBgColor(tci, loadProbe,
-                                                          periodProbe, FALSE);
+                                                          periodProbe, false);
                 if (load != loadProbe || bgCol != bgColProbe)
                     break;
                 lastEndWeek = endWeek;
@@ -1676,13 +1724,13 @@ HTMLReportElement::genCellWeeklyAccount(TableCellInfo* tci)
 void
 HTMLReportElement::genCellMonthlyTask(TableCellInfo* tci)
 {
-    genCellTaskFunc(tci, FALSE, beginOfMonth, sameTimeNextMonth);
+    genCellTaskFunc(tci, false, beginOfMonth, sameTimeNextMonth);
 }
 
 void
 HTMLReportElement::genCellMonthlyResource(TableCellInfo* tci)
 {
-    genCellResourceFunc(tci, FALSE, beginOfMonth, sameTimeNextMonth);
+    genCellResourceFunc(tci, false, beginOfMonth, sameTimeNextMonth);
 }
 
 void
@@ -1694,13 +1742,13 @@ HTMLReportElement::genCellMonthlyAccount(TableCellInfo* tci)
 void
 HTMLReportElement::genCellQuarterlyTask(TableCellInfo* tci)
 {
-    genCellTaskFunc(tci, FALSE, beginOfQuarter, sameTimeNextQuarter);
+    genCellTaskFunc(tci, false, beginOfQuarter, sameTimeNextQuarter);
 }
 
 void
 HTMLReportElement::genCellQuarterlyResource(TableCellInfo* tci)
 {
-    genCellResourceFunc(tci, FALSE, beginOfQuarter, sameTimeNextQuarter);
+    genCellResourceFunc(tci, false, beginOfQuarter, sameTimeNextQuarter);
 }
 
 void
@@ -1712,13 +1760,13 @@ HTMLReportElement::genCellQuarterlyAccount(TableCellInfo* tci)
 void
 HTMLReportElement::genCellYearlyTask(TableCellInfo* tci)
 {
-    genCellTaskFunc(tci, FALSE, beginOfYear, sameTimeNextYear);
+    genCellTaskFunc(tci, false, beginOfYear, sameTimeNextYear);
 }
 
 void
 HTMLReportElement::genCellYearlyResource(TableCellInfo* tci)
 {
-    genCellResourceFunc(tci, FALSE, beginOfYear, sameTimeNextYear);
+    genCellResourceFunc(tci, false, beginOfYear, sameTimeNextYear);
 }
 
 void
@@ -1741,7 +1789,13 @@ HTMLReportElement::genCellResponsibilities(TableCellInfo* tci)
             text += (*it)->getId();
         }
     }
-    genCell(text, tci, TRUE);
+    genCell(text, tci, true);
+}
+
+void
+HTMLReportElement::genCellScheduling(TableCellInfo* tci)
+{
+    genCell(tci->tli->task->getSchedulingText(), tci, true);
 }
 
 void
@@ -1752,7 +1806,7 @@ HTMLReportElement::genCellSchedule(TableCellInfo* tci)
     if (tci->tli->resource)
     {
         BookingList jobs = tci->tli->resource->getJobs(tci->tli->sc);
-        jobs.setAutoDelete(TRUE);
+        jobs.setAutoDelete(true);
         time_t prevTime = 0;
         Interval reportPeriod(start, end);
         s() << "    <table style=\"width:150px; font-size:100%; "
@@ -1809,8 +1863,8 @@ void \
 HTMLReportElement::genCell##a##Effort(TableCellInfo* tci) \
 { \
     genCell(tci->tcf->realFormat.format \
-            (tci->tli->resource->get##a##Effort(), FALSE), \
-            tci, TRUE); \
+            (tci->tli->resource->get##a##Effort(), false), \
+            tci, true); \
 }
 
 GCEFFORT(Min)
@@ -1820,28 +1874,22 @@ HTMLReportElement::genCellMaxEffort(TableCellInfo* tci)
 {
     genCell(tci->tcf->realFormat.format
             (tci->tli->resource->getLimits() ?
-             tci->tli->resource->getLimits()->getDailyMax() : 0, FALSE),
-            tci, TRUE);
+             tci->tli->resource->getLimits()->getDailyMax() : 0, false),
+            tci, true);
 }
 
 void
 HTMLReportElement::genCellEfficiency(TableCellInfo* tci)
 {
     genCell(tci->tcf->realFormat.format(tci->tli->resource->getEfficiency(),
-                                        tci), tci, TRUE);
+                                        tci), tci, true);
 }
 
 void
 HTMLReportElement::genCellRate(TableCellInfo* tci)
 {
     genCell(tci->tcf->realFormat.format(tci->tli->resource->getRate(), tci),
-            tci, TRUE);
-}
-
-void
-HTMLReportElement::genCellKotrusId(TableCellInfo* tci)
-{
-    genCell(tci->tli->resource->getKotrusId(), tci, TRUE);
+            tci, true);
 }
 
 void
@@ -1851,7 +1899,7 @@ HTMLReportElement::genCellTotal(TableCellInfo* tci)
                                                 Interval(start, end));
     if (tci->tli->account->isLeaf())
         tci->tci->addToSum(tci->tli->sc, "total", value);
-    genCell(tci->tcf->realFormat.format(value, tci), tci, FALSE);
+    genCell(tci->tcf->realFormat.format(value, tci), tci, false);
 }
 
 void
@@ -1871,7 +1919,7 @@ HTMLReportElement::genCellSummary(TableCellInfo* tci)
                 val += *it;
             else
                 val = *it;
-            genCell(tci->tcf->realFormat.format(val, tci), tci, FALSE);
+            genCell(tci->tcf->realFormat.format(val, tci), tci, false);
         }
     }
     else
@@ -1880,9 +1928,9 @@ HTMLReportElement::genCellSummary(TableCellInfo* tci)
         // column cases.
         if (tci->tci->getSubColumns() > 0)
             for (uint col = 0; col < tci->tci->getSubColumns(); ++col)
-                genCell(tci->tcf->realFormat.format(0.0, tci), tci, FALSE);
+                genCell(tci->tcf->realFormat.format(0.0, tci), tci, false);
         else
-            genCell(tci->tcf->realFormat.format(0.0, tci), tci, FALSE);
+            genCell(tci->tcf->realFormat.format(0.0, tci), tci, false);
     }
 }