예제 #1
0
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 . '">&nbsp;</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
0
 /**
  * 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
0
 /**
  * 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')));
 }