00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifdef HAVE_CONFIG_H
00019 #include <config.h>
00020 #endif
00021
00022 using namespace std;
00023
00024 #include "project.h"
00025 #include "reporter.h"
00026
00027 void Reporter::SlippageReport( Project *project )
00028 {
00029 TASK *t;
00030 char buf1[500], buf2[500];
00031 FILE *ftxt = NULL;
00032 FILE *ftex = NULL;
00033 FILE *fhtml = NULL;
00034
00035 int early;
00036 int nFinishedTasksOnTime = 0;
00037 int nFinishedTasksEarly = 0;
00038 int nFinishedTasksLate = 0;
00039 int nFinishedDaysEarly = 0;
00040 int nFinishedDaysLate = 0;
00041
00042 int nOngoingTasksOnTime = 0;
00043 int nOngoingTasksEarly = 0;
00044 int nOngoingTasksLate = 0;
00045 int nOngoingDaysEarly = 0;
00046 int nOngoingDaysLate = 0;
00047
00048 if ( slippage_txt_report != NULL )
00049 ftxt = OpenOutputFile(slippage_txt_report);
00050
00051 if ( slippage_tex_report != NULL )
00052 ftex = OpenOutputFile(slippage_tex_report);
00053
00054 if ( slippage_html_report != NULL )
00055 {
00056 fhtml = OpenOutputFile(slippage_html_report);
00057 fprintf(fhtml, "<html>\n<body>\n\n");
00058 }
00059
00060
00061
00062
00063 if ( ftxt != NULL )
00064 {
00065 fprintf(ftxt, "Schedule changes:\n");
00066 fprintf(ftxt, "=================\n\n");
00067 fprintf(ftxt, "%-40s %4s %4s %4s %s %9s\n","Task", "Done", "Old",
00068 "New", "Chg?", "Remaining");
00069 fprintf(ftxt, "%-40s %4s %4s %4s %s %9s\n","----", "----", "---",
00070 "---", "----", "---------");
00071 }
00072 if ( ftex != NULL )
00073 {
00074 fprintf(ftex, "\\subsection{Schedule changes}\n");
00075 fprintf(ftex, "\\begin{supertabular}{|l|r|r|r|l|r|}\n");
00076 fprintf(ftex, "\\hline\n");
00077 fprintf(ftex, "{\\bf %s} & {\\bf %s} & {\\bf %s} & {\\bf %s} & {\\bf %s} & {\\bf %s} \\\\\n",
00078 "Task", "\\% Done", "Old", "New", "Chg?", "Remaining");
00079 fprintf(ftex, "\\hline\n");
00080 fprintf(ftex, "\\hline\n");
00081 }
00082 if ( fhtml != NULL )
00083 {
00084 fprintf(fhtml, "<h1>Schedule changes</h1>\n");
00085 fprintf(fhtml, "<p><table cellpadding=2 border=1>\n");
00086 fprintf(fhtml, "<tr><th>Task</th><th>%% Done</th><th>Old</th><th>New</th><th>Chg?</th><th>Remaining</th></tr>\n");
00087 }
00088
00089 for ( Project::TPLCI pt = project->beginTaskList() ;
00090 pt != project->endTaskList() ; pt++ )
00091 {
00092 t = *pt;
00093 if ( t->percent_complete() == 0 )
00094 continue;
00095 #if 0
00096 if ( ( t->when == NULL ) && ( t->nDays == 0 ) )
00097 continue;
00098 #endif
00099
00100
00101 if ( t->nDays() == 0 )
00102 continue;
00103
00104
00105 if ( t->percent_complete() > 99 )
00106 {
00107 if ( t->origfullduration() > t->fullduration() )
00108 {
00109 nFinishedTasksEarly += 1;
00110 nFinishedDaysEarly += (t->origfullduration() - t->fullduration() );
00111 }
00112 else if ( t->origfullduration() == t->fullduration() )
00113 {
00114 nFinishedTasksOnTime += 1;
00115 }
00116 else if ( t->origfullduration() < t->fullduration() )
00117 {
00118 nFinishedTasksLate += 1;
00119 nFinishedDaysLate += (t->fullduration() - t->origfullduration() );
00120 }
00121 }
00122 else
00123 {
00124 if ( t->origfullduration() > t->fullduration() )
00125 {
00126 nOngoingTasksEarly += 1;
00127 nOngoingDaysEarly += (t->origfullduration() - t->fullduration() );
00128 }
00129 else if ( t->origfullduration() == t->fullduration() )
00130 {
00131 nOngoingTasksOnTime += 1;
00132 }
00133 else if ( t->origfullduration() < t->fullduration() )
00134 {
00135 nOngoingTasksLate += 1;
00136 nOngoingDaysLate += (t->fullduration() - t->origfullduration() );
00137 }
00138 }
00139
00140
00141 if ( t->fullduration() != t->origfullduration() )
00142 {
00143 if ( ftxt != NULL )
00144 {
00145 char buf[128];
00146 if ( task_ids )
00147 sprintf(buf, "%s %s", t->id(), t->name() );
00148 else
00149 sprintf(buf, "%s", t->name() );
00150 fprintf(ftxt, "%-40s %4g %4d %4d %-5s %8d\n",
00151 buf, t->percent_complete(),
00152 t->origfullduration(), t->fullduration(),
00153 t->fullduration()<t->origfullduration() ? "Early":"Late",
00154 t->fullduration() - t->nDays() );
00155 }
00156 if ( ftex != NULL )
00157 {
00158 if ( task_ids )
00159 fprintf(ftex, "%s %s",
00160 TeXFix(buf1,t->id()),
00161 TeXFix(buf2,t->name()));
00162 else
00163 fprintf(ftex, "%s",
00164 TeXFix(buf2,t->name()));
00165 fprintf(ftex," & %g & %d & %d & %s & %d\\\\ \n",
00166 t->percent_complete(),
00167 t->origfullduration(), t->fullduration(),
00168 t->fullduration()<t->origfullduration() ? "Early":"Late",
00169 t->fullduration() - t->nDays());
00170 }
00171 if ( fhtml != NULL )
00172 {
00173 fprintf(fhtml, "<tr>");
00174 if ( task_ids )
00175 fprintf(fhtml, "<td>%s %s</td>",
00176 HTMLFix(buf1,t->id()),
00177 HTMLFix(buf2,t->name()));
00178 else
00179 fprintf(fhtml, "<td>%s</td>",
00180 HTMLFix(buf2,t->name()));
00181 fprintf(fhtml, " <td align=right>%g</td> <td align=right>%d</td> <td align=right>%d</td> <td>%s</td> <td align=right>%d</td></tr>\n",
00182 t->percent_complete(),
00183 t->origfullduration(), t->fullduration(),
00184 t->fullduration()<t->origfullduration() ? "Early":"Late",
00185 t->fullduration() - t->nDays());
00186 }
00187 }
00188 else
00189 {
00190 if ( ftxt != NULL )
00191 {
00192 fprintf(ftxt, "%-40s %4g %4d %4d %s\n",
00193 t->id(), t->percent_complete(), t->origfullduration(),
00194 t->fullduration(), "-");
00195 }
00196 if ( ftex != NULL )
00197 {
00198 if ( task_ids )
00199 fprintf(ftex, "%s %s",
00200 TeXFix(buf1,t->id()),
00201 TeXFix(buf2,t->name()));
00202 else
00203 fprintf(ftex, "%s",
00204 TeXFix(buf2,t->name()));
00205 fprintf(ftex, " & %g & %d & %d & & \\\\ \n",
00206 t->percent_complete(),
00207 t->origfullduration(), t->fullduration());
00208 }
00209 if ( fhtml != NULL )
00210 {
00211 fprintf(fhtml, "<tr>");
00212 if ( task_ids )
00213 fprintf(fhtml, "<td>%s %s</td>",
00214 HTMLFix(buf1,t->id()),
00215 HTMLFix(buf2,t->name()));
00216 else
00217 fprintf(fhtml, "<td>%s</td>",
00218 HTMLFix(buf2,t->name()));
00219 fprintf(fhtml,
00220 "<td align=right>%g</td> <td align=right>%d</td> <td align=right>%d</td> <td> </td> <td> </td></tr>\n",
00221 t->percent_complete(),
00222 t->origfullduration(), t->fullduration());
00223 }
00224 }
00225 }
00226
00227 early = nOngoingDaysEarly + nFinishedDaysEarly -
00228 (nOngoingDaysLate + nFinishedDaysLate);
00229
00230 if ( ftxt != NULL )
00231 {
00232 fprintf(ftxt,"\nSUMMARY:\n\n");
00233 fprintf(ftxt,"Completed tasks:\n");
00234 fprintf(ftxt,
00235 " On time: %d Early: %d (%d days) Late: %d (%d days)\n",
00236 nFinishedTasksOnTime,
00237 nFinishedTasksEarly, nFinishedDaysEarly,
00238 nFinishedTasksLate, nFinishedDaysLate);
00239
00240 fprintf(ftxt,"Ongoing tasks:\n");
00241 fprintf(ftxt,
00242 " On time: %d Early: %d (%d days) Late: %d (%d days)\n",
00243 nOngoingTasksOnTime,
00244 nOngoingTasksEarly, nOngoingDaysEarly,
00245 nOngoingTasksLate, nOngoingDaysLate);
00246
00247 fprintf(ftxt,"The project is %d days %s schedule.\n",
00248 abs(early), early>0 ? "ahead of":"behind");
00249 }
00250 if ( ftex != NULL )
00251 {
00252 fprintf(ftex,"\\hline\n");
00253 fprintf(ftex,"\\end{supertabular}\n\n");
00254 fprintf(ftex,"\n{\\bf Summary:} \\\\ \n");
00255 fprintf(ftex,"Completed tasks: \\\\ \n");
00256 fprintf(ftex,
00257 "\\mbox{} \\hspace{0.5in} On time: %d Early: %d (%d days) Late: %d (%d days) \\\\ \n",
00258 nFinishedTasksOnTime,
00259 nFinishedTasksEarly, nFinishedDaysEarly,
00260 nFinishedTasksLate, nFinishedDaysLate);
00261
00262 fprintf(ftex,"Ongoing tasks: \\\\ \n");
00263 fprintf(ftex,"\\mbox{} \\hspace{0.5in} On time: %d Early: %d (%d days) Late: %d (%d days) \\\\ \n",
00264 nOngoingTasksOnTime,
00265 nOngoingTasksEarly, nOngoingDaysEarly,
00266 nOngoingTasksLate, nOngoingDaysLate);
00267
00268 fprintf(ftex,"The project is %d days %s schedule.\n",
00269 abs(early), early>0 ? "ahead of":"behind");
00270 }
00271 if ( fhtml != NULL )
00272 {
00273 fprintf(fhtml,"</table></p>\n\n");
00274 fprintf(fhtml,"<h2>Summary:</h2>\n");
00275 fprintf(fhtml,"<p>Completed tasks:</p>\n");
00276 fprintf(fhtml,"<p> On time: %d Early: %d (%d days) Late: %d (%d days)</p>\n",
00277 nFinishedTasksOnTime,
00278 nFinishedTasksEarly, nFinishedDaysEarly,
00279 nFinishedTasksLate, nFinishedDaysLate);
00280
00281 fprintf(fhtml,"<p>Ongoing tasks:<p>\n");
00282 fprintf(fhtml,"<p> On time: %d Early: %d (%d days) Late: %d (%d days)</p>\n",
00283 nOngoingTasksOnTime,
00284 nOngoingTasksEarly, nOngoingDaysEarly,
00285 nOngoingTasksLate, nOngoingDaysLate);
00286
00287 fprintf(fhtml,"<p>The project is %d days %s schedule.</p>\n",
00288 abs(early), early>0 ? "ahead of":"behind");
00289 }
00290
00291
00292 if ( ( ftxt != NULL ) && ( ftxt != stdout ) )
00293 fclose(ftxt);
00294 if ( ftex != NULL )
00295 fclose(ftex);
00296 if ( fhtml != NULL )
00297 {
00298 fprintf(fhtml, "\n\n</body>\n</html>\n");
00299 fclose(fhtml);
00300 }
00301 }