当前位置: 首页>>代码示例>>PHP>>正文


PHP CDate::workingDaysInSpan方法代码示例

本文整理汇总了PHP中CDate::workingDaysInSpan方法的典型用法代码示例。如果您正苦于以下问题:PHP CDate::workingDaysInSpan方法的具体用法?PHP CDate::workingDaysInSpan怎么用?PHP CDate::workingDaysInSpan使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CDate的用法示例。


在下文中一共展示了CDate::workingDaysInSpan方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getTaskDurationPerWeek

 /**
  * Function that returns the amount of hours this
  * task consumes per user each week
  */
 function getTaskDurationPerWeek($use_percent_assigned = false)
 {
     $duration = ($this->task_duration_type == 24 ? dPgetConfig('daily_working_hours') : $this->task_duration_type) * $this->task_duration;
     $task_start_date = new CDate($this->task_start_date);
     $task_finish_date = new CDate($this->task_end_date);
     $assigned_users = $this->getAssignedUsers();
     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(',', dPgetConfig('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;
 }
开发者ID:hoodoogurus,项目名称:dotprojecteap,代码行数:29,代码来源:tasks.class.php

示例2: 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 CDate(Date_Calc::endOfWeek($end_date->day, $end_date->month, $end_date->year));
    $sd = new CDate(Date_Calc::beginOfWeek($start_date->day, $start_date->month, $start_date->year));
    $week_difference = ceil($ed->workingDaysInSpan($sd) / count(explode(",", dPgetConfig("cal_working_days"))));
    $actual_date = $sd;
    $table_header = "<tr><th>" . $AppUI->_("User") . "</th>";
    for ($i = 0; $i < $week_difference; $i++) {
        $table_header .= "<th>" . Date_Calc::weekOfYear($actual_date->day, $actual_date->month, $actual_date->year) . "<br><table><td style='font-weight:normal; font-size:70%'>" . $actual_date->format($df) . "</td></table></th>";
        $actual_date->addSeconds(168 * 3600);
        // + one week
    }
    $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["user_username"]);
        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;
            for ($i = 0; $i < $week_difference; $i++) {
                $awoy = $actual_date->year . Date_Calc::weekOfYear($actual_date->day, $actual_date->month, $actual_date->year);
                $table_rows .= "<td align='right'>";
                if (isset($user_usage[$user_id][$awoy])) {
                    $hours = number_format($user_usage[$user_id][$awoy], 2);
                    $table_rows .= $hours;
                    $percentage_used = round($hours / (dPgetConfig("daily_working_hours") * count(explode(",", dPgetConfig("cal_working_days")))) * 100);
                    $bar_color = "blue";
                    if ($percentage_used > 100) {
                        $bar_color = "red";
                        $percentage_used = 100;
                    }
                    $table_rows .= "<div style='height:2px;width:{$percentage_used}%; background-color:{$bar_color}'>&nbsp;</div>";
                } else {
                    $table_rows .= "&nbsp;";
                }
                $table_rows .= "</td>";
                $actual_date->addSeconds(168 * 3600);
                // + one week
            }
            $array_sum = array_sum($user_usage[$user_id]);
            $average_user_usage = number_format($array_sum / ($week_difference * count(explode(",", dPgetConfig("cal_working_days"))) * dPgetConfig("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 = $week_difference * count(explode(",", dPgetConfig("cal_working_days"))) * dPgetConfig("daily_working_hours") * count($user_usage);
    $total_hours_capacity_all = $week_difference * count(explode(",", dPgetConfig("cal_working_days"))) * dPgetConfig("daily_working_hours") * count($user_list);
}
开发者ID:n2i,项目名称:xvnkb,代码行数:59,代码来源:allocateduserhours.php

示例3: showWeeks

function showWeeks()
{
    global $allocated_hours_sum, $end_date, $start_date, $AppUI, $user_list, $user_names;
    global $user_usage, $hideNonWd, $table_header, $table_rows, $df, $working_days_count;
    global $total_hours_capacity, $total_hours_capacity_all;
    $working_days_count = 0;
    $allocated_hours_sum = 0;
    $AppUI->setBaseLocale();
    $ed = new CDate(Date_Calc::endOfWeek($end_date->day, $end_date->month, $end_date->year));
    $sd = new CDate(Date_Calc::beginOfWeek($start_date->day, $start_date->month, $start_date->year));
    setlocale(LC_ALL, $AppUI->user_lang);
    $week_difference = ceil($ed->workingDaysInSpan($sd) / count(explode(',', dPgetConfig('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(',', dPgetConfig('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['user_username']);
        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;
            /*
            			for ($i=0; $i<$week_difference; $i++) { 
            				setlocale(LC_ALL, 'en_AU'.(($locale_char_set)? ('.' . $locale_char_set) : '.utf8'));
            				$awoy = $actual_date->year.Date_Calc::weekOfYear($actual_date->day,$actual_date->month,$actual_date->year);
            				setlocale(LC_ALL, $AppUI->user_lang);
            
            				$table_rows .= '<td align="right">';
            				if (isset($user_usage[$user_id][$awoy])) {
            					$hours = number_format($user_usage[$user_id][$awoy],2);
            					$table_rows .= $hours;
            					$percentage_used = round(($hours/(dPgetConfig('daily_working_hours')*count(explode(',',dPgetConfig('cal_working_days')))))*100);
            					$bar_color = 'blue';
            					if ($percentage_used > 100) {
            						$bar_color = 'red';
            						$percentage_used = 100;
            					}
            					$table_rows .= '<div style="height:2px;width:' . $percentage_used . '%; background-color:' . $bar_color . '">&nbsp;</div>';
            				} else {
            					$table_rows .= '&nbsp;';
            				} 
            				$table_rows .= '</td>';
            
            				$actual_date->addSeconds(168*3600);	// + one week
            			}
            */
            $array_sum = array_sum($user_usage[$user_id]);
            $average_user_usage = number_format($array_sum / ($week_difference * count(explode(',', dPgetConfig('cal_working_days'))) * dPgetConfig('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 = $week_difference * count(explode(',',dPgetConfig('cal_working_days'))) * dPgetConfig('daily_working_hours') * count($user_usage);		
    	$total_hours_capacity_all = $week_difference * count(explode(',',dPgetConfig('cal_working_days'))) *dPgetConfig('daily_working_hours') * count($user_list);
    */
    $total_hours_capacity = $working_days_count / 2 * dPgetConfig('daily_working_hours') * count($user_usage);
    $total_hours_capacity_all = $working_days_count / 2 * dPgetConfig('daily_working_hours') * count($user_list);
}
开发者ID:srinivasulurao,项目名称:jonel,代码行数:72,代码来源:allocateduserhours.php


注:本文中的CDate::workingDaysInSpan方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。