我正在计算项目中每个任务的暂定截止日期,我计算出第一个任务的截止日期就好了,即项目开始日期后的 5 个工作日,但现在我想根据以前的任务计算每个新任务的截止日期截止日期。
项目开始日期为 7-15-13 任务一的工期为 5 天,应将截止日期设置为 7-22-13 任务二的工期为 5 天,应将截止日期设置为 7-19-13任务三的持续时间为 3 天,这应该将我的截止日期设置为 7-24-13。
每个项目可以有可变数量的任务。
//Format the Start Date
$startDate = date("Y-m-d", strtotime($projectStart));
//Subtract one day to project length to include the starting date in the count.
$projectLengthMinusOne = ($projectLength - 1);
//Calculate estimated deadline date based off of out of office, absence, holidays, and weekdays.
$deadlineDate = date("Y-m-d", strtotime($projectLengthMinusOne . ' weekdays', strtotime($startDate)));
//Check for holidays
$checkHolidays = mysql_query("SELECT id FROM fm_calendar_holidays WHERE fromDate BETWEEN '".$startDate."' AND '".$deadlineDate."'") or die("Check Holidays: " . mysql_error());
$numHolidays = mysql_num_rows($checkHolidays);
//Check for Absences
$checkAbsences = mysql_query("SELECT numDays FROM fm_calendar_absenceRequest WHERE startDate BETWEEN '".$startDate."' AND '".$deadlineDate."' and respid = '".$taskData['assignedTo']."'") or die("Check Absences: " . mysql_error());
if(mysql_num_rows($checkAbsences) > 0)
{
$totalAbsences = 0;
while($abData = mysql_fetch_array($checkAbsences))
{
$numDays = $abData['numDays'];
$totalAbsences += $numDays;
}
}
$numAbsences = $totalAbsences;
//Check for out of office
$checkOutOffice = mysql_query("SELECT startDate, endDate FROM fm_calendar_outofOffice WHERE startDate BETWEEN '".$startDate."' AND '".$deadlineDate."' and requesterId = '".$taskData['assignedTo']."'") or die("Check Out of Office: " . mysql_error());
if(mysql_num_rows($checkOutOffice) > 0)
{
$totalOutOffice = 0;
while($oooData = mysql_fetch_array($checkOutOffice))
{
$oooStart = $oooData['startDate'];
$oooEnd = $oooData['endDate'];
$numWorkingDays = getWorkingDays($oooStart, $oooEnd);
$totalOutOffice += $numWorkingDays;
}
}
$numOutOffice = $totalOutOffice;
//Add up all days off from the calendar
$totalDaysAdded = ($numHolidays + $numAbsences + $numOutOffice);
//Recalculate the deadline date based off of the new days off information
$deadlineDate = date("Y-m-d", strtotime($totalDaysAdded . ' weekdays', strtotime($deadlineDate)));
$deadlineDate = date("Y-m-d", strtotime($taskData['taskLength'] . ' weekdays', strtotime($deadlineDate)));
echo '<div class="page_collapsible" id="body-section1">'.$taskData['taskName'] . '<span></span></div>';
echo '<div class="container">
<div class="collapseContainer">';
echo '<table width = "900px" cellspacing = "5" cellpadding = "5" border = "0">
<tr>
<td width = "125px" align="right"><strong>Description:</strong></td>
<td width = "775px" align="left">'.$taskData['taskDescription'] . '</td>
</tr>
<tr>
<td width = "125px" align="right"><strong>Programmer:</strong></td>
<td width = "775px" align="left">'.getCkname($taskData['assignedTo']). '</td>
</tr>
<tr>
<td width = "125px" align="right"><strong>Task Status:</strong></td>
<td width = "775px" align="left">'.$taskData['taskStatus'] . '</td>
</tr>
<tr>
<td width = "125px" align="right"><strong>Task Duration:</strong></td>
<td width = "775px" align="left">'.$taskData['taskLength'] . ' days</td>
</tr>
<tr>
<td width = "125px" align="right"><strong>Tentative Due Date:</strong></td>
<td width = "775px" align="left">'.$deadlineDate . '</td>
</tr>
</table>
</div>
</div>';
}
}