本文整理汇总了PHP中w2p_Utilities_Date::workingDaysInSpan方法的典型用法代码示例。如果您正苦于以下问题:PHP w2p_Utilities_Date::workingDaysInSpan方法的具体用法?PHP w2p_Utilities_Date::workingDaysInSpan怎么用?PHP w2p_Utilities_Date::workingDaysInSpan使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类w2p_Utilities_Date
的用法示例。
在下文中一共展示了w2p_Utilities_Date::workingDaysInSpan方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: showWeeks
function showWeeks()
{
global $allocated_hours_sum, $end_date, $start_date, $AppUI, $user_list, $user_names, $user_usage, $hideNonWd, $table_header, $table_rows, $df, $working_days_count, $total_hours_capacity, $total_hours_capacity_all;
$working_days_count = 0;
$allocated_hours_sum = 0;
$ed = new w2p_Utilities_Date(Date_Calc::endOfWeek($end_date->day, $end_date->month, $end_date->year));
$sd = new w2p_Utilities_Date(Date_Calc::beginOfWeek($start_date->day, $start_date->month, $start_date->year));
$week_difference = ceil($ed->workingDaysInSpan($sd) / count(explode(',', w2PgetConfig('cal_working_days'))));
$actual_date = $sd;
$table_header = '<tr><th>' . $AppUI->_('User') . '</th>';
for ($i = 0; $i < $week_difference; $i++) {
$actual_date->addSeconds(168 * 3600);
// + one week
$working_days_count = $working_days_count + count(explode(',', w2PgetConfig('cal_working_days')));
}
$table_header .= '<th nowrap="nowrap" colspan="2">' . $AppUI->_('Allocated') . '</th></tr>';
$table_rows = '';
foreach ($user_list as $user_id => $user_data) {
$user_names[$user_id] = $user_data['contact_first_name'] . ' ' . $user_data['contact_last_name'];
if (isset($user_usage[$user_id])) {
$table_rows .= '<tr><td nowrap="nowrap">(' . $user_data['user_username'] . ') ' . $user_data['contact_first_name'] . ' ' . $user_data['contact_last_name'] . '</td>';
$actual_date = $sd;
$array_sum = array_sum($user_usage[$user_id]);
$average_user_usage = number_format($array_sum / ($week_difference * count(explode(',', w2PgetConfig('cal_working_days'))) * w2PgetConfig('daily_working_hours')) * 100, 2);
$allocated_hours_sum += $array_sum;
$bar_color = 'blue';
if ($average_user_usage > 100) {
$bar_color = 'red';
$average_user_usage = 100;
}
$table_rows .= '<td ><div align="left">' . round($array_sum, 2) . ' ' . $AppUI->_('hours') . '</td> <td align="right"> ' . $average_user_usage;
$table_rows .= '%</div>';
$table_rows .= '<div align="left" style="height:2px;width:' . $average_user_usage . '%; background-color:' . $bar_color . '"> </div></td>';
$table_rows .= '</tr>';
}
}
$total_hours_capacity = $working_days_count / 2 * w2PgetConfig('daily_working_hours') * count($user_usage);
$total_hours_capacity_all = $working_days_count / 2 * w2PgetConfig('daily_working_hours') * count($user_list);
}
示例2: getTaskDurationPerWeek
/**
* Function that returns the amount of hours this
* task consumes per user each week
*/
public function getTaskDurationPerWeek($use_percent_assigned = false)
{
$duration = $this->task_duration * ($this->task_duration_type == 24 ? w2PgetConfig('daily_working_hours') : $this->task_duration_type);
$task_start_date = new w2p_Utilities_Date($this->task_start_date);
$task_finish_date = new w2p_Utilities_Date($this->task_end_date);
$assigned_users = $this->getAssignedUsers($this->task_id);
if ($use_percent_assigned) {
$number_assigned_users = 0;
foreach ($assigned_users as $u) {
$number_assigned_users += $u['perc_assignment'] / 100;
}
} else {
$number_assigned_users = count($assigned_users);
}
$number_of_weeks_worked = $task_finish_date->workingDaysInSpan($task_start_date) / count(explode(',', w2PgetConfig('cal_working_days')));
$number_of_weeks_worked = $number_of_weeks_worked < 1 ? ceil($number_of_weeks_worked) : $number_of_weeks_worked;
// zero adjustment
if ($number_of_weeks_worked == 0) {
$number_of_weeks_worked = 1;
}
if ($number_assigned_users == 0) {
$number_assigned_users = 1;
}
return $duration / $number_assigned_users / $number_of_weeks_worked;
}
示例3: testWorkingDaysInSpanMultiDaysNegativeWithNonWorking
/**
* Test workingDaysInSpan with multiple negative days including non
* working days
*/
public function testWorkingDaysInSpanMultiDaysNegativeWithNonWorking()
{
$date = new w2p_Utilities_Date('2010-09-14 10:00:00');
$this->assertEquals(3, $date->workingDaysInSpan(new w2p_Utilities_Date('2010-09-10 10:00:00')));
}