Ejemplo n.º 1
0
 protected function _render(Horde_Date $day = null)
 {
     $this->_start = new Horde_Date(Date_Calc::beginOfWeek($day->mday, $day->month, $day->year, '%Y%m%d000000'));
     $this->_end = new Horde_Date($this->_start);
     $this->_end->hour = 23;
     $this->_end->min = $this->_end->sec = 59;
     $this->_end->mday += $this->_days - 1;
 }
Ejemplo n.º 2
0
 /**
  * Find the month day of the beginning of week after given date,
  * using DATE_CALC_BEGIN_WEEKDAY
  *
  * Can return weekday of prev month.
  *
  * @param int    $day    the day of the month, default is current local day
  * @param int    $month  the month, default is current local month
  * @param int    $year   the year in four digit format, default is current
  *                        local year
  * @param string $format the string indicating how to format the output
  *
  * @return   string     the date in the desired format
  * @access   public
  * @static
  */
 function beginOfNextWeek($day = 0, $month = 0, $year = null, $format = DATE_CALC_FORMAT)
 {
     if (is_null($year)) {
         $year = Date_Calc::dateNow('%Y');
     }
     if (empty($month)) {
         $month = Date_Calc::dateNow('%m');
     }
     if (empty($day)) {
         $day = Date_Calc::dateNow('%d');
     }
     list($hn_pwyear, $hn_pwmonth, $hn_pwday) = explode(" ", Date_Calc::daysToDate(Date_Calc::dateToDays($day, $month, $year) + 7, '%Y %m %d'));
     return Date_Calc::beginOfWeek($hn_pwday, $hn_pwmonth, $hn_pwyear, $format);
 }
Ejemplo n.º 3
0
 /**
 * CMonthCalendar::_drawDays()
 *
 * { Description }
 *
 * @return string Returns table a row with the day names
 */
 function _drawDays()
 {
     global $locale_char_set;
     $bow = Date_Calc::beginOfWeek(null, null, null, null, LOCALE_FIRST_DAY);
     $y = substr($bow, 0, 4);
     $m = substr($bow, 4, 2);
     $d = substr($bow, 6, 2);
     $wk = Date_Calc::getCalendarWeek($d, $m, $y, "%a", LOCALE_FIRST_DAY);
     $s = $this->showWeek ? "\n\t\t<th>&nbsp;</th>" : "";
     foreach ($wk as $day) {
         $s .= "\n\t\t<th width=\"14%\">" . htmlentities(utf8_encode($day), ENT_COMPAT, $locale_char_set) . "</th>";
     }
     return "\n<tr>{$s}\n</tr>";
 }
Ejemplo n.º 4
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);
}
Ejemplo n.º 5
0
 /**
  * Find the month day of the beginning of week after given date,
  * using DATE_CALC_BEGIN_WEEKDAY
  *
  * Can return weekday of prev month.
  *
  * @param int    $day     the day of the month, default is current local day
  * @param int    $month   the month, default is current local month
  * @param int    $year    the year in four digit format, default is current local year
  * @param string $format  the string indicating how to format the output
  *
  * @return string  the date in the desired format
  *
  * @access public
  * @static
  */
 function beginOfNextWeek($day = 0, $month = 0, $year = 0, $format = DATE_CALC_FORMAT)
 {
     if (empty($year)) {
         $year = Date_Calc::dateNow('%Y');
     }
     if (empty($month)) {
         $month = Date_Calc::dateNow('%m');
     }
     if (empty($day)) {
         $day = Date_Calc::dateNow('%d');
     }
     $date = Date_Calc::daysToDate(Date_Calc::dateToDays($day + 7, $month, $year), '%Y%m%d');
     $next_week_year = substr($date, 0, 4);
     $next_week_month = substr($date, 4, 2);
     $next_week_day = substr($date, 6, 2);
     return Date_Calc::beginOfWeek($next_week_day, $next_week_month, $next_week_year, $format);
 }
Ejemplo n.º 6
0
$endDates = array();
$order = array(array('key' => 'valutaDate', 'dir' => 'asc'));
foreach ($accountIds as $currentAccountId) {
    $currentAccount = $accountManager->getAccountById($currentAccountId);
    $filter = getDataGridFilter($currentAccount);
    $currentAccount->setFilter($filter);
    $currentAccount->setOrder($order);
    while ($currentTransaction = $currentAccount->getNextTransaction()) {
        $date = $currentTransaction->getValutaDate();
        if (is_null($date)) {
            continue;
        }
        switch ($type) {
            case 'w':
                $dateKey = $date->getYear() . '-' . sprintf('%02d', $date->getWeekOfYear());
                $beginDate = new Date(Date_Calc::beginOfWeek($date->getDay(), $date->getMonth(), $date->getYear(), '%Y-%m-%d'));
                $endDate = new Date(Date_Calc::endOfWeek($date->getDay(), $date->getMonth(), $date->getYear(), '%Y-%m-%d'));
                break;
            case 'm':
                $dateKey = $date->getYear() . '-' . sprintf('%02d', $date->getMonth());
                $beginDate = new Date(Date_Calc::beginOfMonth($date->getMonth(), $date->getYear(), '%Y-%m-%d'));
                $endDate = new Date(Date_Calc::endOfMonthBySpan(0, $date->getMonth(), $date->getYear(), '%Y-%m-%d'));
                break;
            case 'q':
                $dateKey = $date->getYear() . '-' . $date->getQuarterOfYear();
                switch ($date->getQuarterOfYear()) {
                    case 1:
                        $beginDate = new Date($date->getYear() . '-01-01');
                        $endDate = new Date($date->getYear() . '-03-31');
                        break;
                    case 2:
 /**
  * Return an array with days in week
  *
  * @param string day in format DD, default is current local day
  * @param string month in format MM, default is current local month
  * @param string year in format CCYY, default is current local year
  * @param string format for returned date
  *
  * @access public
  *
  * @return array $week[$weekday]
  */
 function getCalendarWeek($day = '', $month = '', $year = '', $format = '%Y%m%d')
 {
     if (empty($year)) {
         $year = Date_Calc::dateNow('%Y');
     }
     if (empty($month)) {
         $month = Date_Calc::dateNow('%m');
     }
     if (empty($day)) {
         $day = Date_Calc::dateNow('%d');
     }
     $week_array = array();
     // date for the column of week
     $curr_day = Date_Calc::beginOfWeek($day, $month, $year, '%E');
     for ($counter = 0; $counter <= 6; $counter++) {
         $week_array[$counter] = Date_Calc::daysToDate($curr_day, $format);
         $curr_day++;
     }
     return $week_array;
 }
Ejemplo n.º 8
0
}
$company_id = $AppUI->getState('CalIdxCompany') !== null ? $AppUI->getState('CalIdxCompany') : $AppUI->user_company;
// Using simplified set/get semantics. Doesn't need as much code in the module.
$event_filter = $AppUI->checkPrefState('CalIdxFilter', w2PgetParam($_REQUEST, 'event_filter', 'my'), 'EVENTFILTER', 'my');
// get the passed timestamp (today if none)
$date = w2PgetParam($_GET, 'date', null);
$today = new w2p_Utilities_Date();
$today->convertTZ($AppUI->getPref('TIMEZONE'));
$today = $today->format(FMT_TIMESTAMP_DATE);
// establish the focus 'date'
$this_week = new w2p_Utilities_Date($date);
$dd = $this_week->getDay();
$mm = $this_week->getMonth();
$yy = $this_week->getYear();
// prepare time period for 'events'
$first_time = new w2p_Utilities_Date(Date_Calc::beginOfWeek($dd, $mm, $yy, FMT_TIMESTAMP_DATE, LOCALE_FIRST_DAY));
$first_time->setTime(0, 0, 0);
$last_time = new w2p_Utilities_Date(Date_Calc::endOfWeek($dd, $mm, $yy, FMT_TIMESTAMP_DATE, LOCALE_FIRST_DAY));
$last_time->setTime(23, 59, 59);
$prev_week = new w2p_Utilities_Date(Date_Calc::beginOfPrevWeek($dd, $mm, $yy, FMT_TIMESTAMP_DATE, LOCALE_FIRST_DAY));
$next_week = new w2p_Utilities_Date(Date_Calc::beginOfNextWeek($dd, $mm, $yy, FMT_TIMESTAMP_DATE, LOCALE_FIRST_DAY));
$links = array();
// assemble the links for the tasks
$links = getTaskLinks($first_time, $last_time, $links, 50, $company_id);
// assemble the links for the events
$links += getEventLinks($first_time, $last_time, $links, 50);
$hooks = new w2p_System_HookHandler($AppUI);
$hooks->links = $links;
$links = $hooks->calendar_links();
// get the list of visible companies
$company = new CCompany();
Ejemplo n.º 9
0
$company_id = $AppUI->processIntState('CalIdxCompany', $_REQUEST, 'company_id', $AppUI->user_company);
$event_filter = $AppUI->checkPrefState('CalIdxFilter', w2PgetParam($_REQUEST, 'event_filter', ''), 'EVENTFILTER', 'my');
$tab = $AppUI->processIntState('CalDayViewTab', $_GET, 'tab', isset($tab) ? $tab : 0);
// get the prefered date format
$df = $AppUI->getPref('SHDATEFORMAT');
// get the passed timestamp (today if none)
$ctoday = new w2p_Utilities_Date();
$today = $ctoday->format(FMT_TIMESTAMP_DATE);
$date = (int) w2PgetParam($_GET, 'date', $today);
// establish the focus 'date'
$this_day = new w2p_Utilities_Date($date);
$dd = $this_day->getDay();
$mm = $this_day->getMonth();
$yy = $this_day->getYear();
// get current week
$this_week = Date_Calc::beginOfWeek($dd, $mm, $yy, FMT_TIMESTAMP_DATE, LOCALE_FIRST_DAY);
// prepare time period for 'events'
$first_time = clone $this_day;
$first_time->setTime(0, 0, 0);
$last_time = clone $this_day;
$last_time->setTime(23, 59, 59);
$prev_day = new w2p_Utilities_Date(Date_Calc::prevDay($dd, $mm, $yy, FMT_TIMESTAMP_DATE));
$next_day = new w2p_Utilities_Date(Date_Calc::nextDay($dd, $mm, $yy, FMT_TIMESTAMP_DATE));
// get the list of visible companies
$company = new CCompany();
global $companies;
$companies = $company->getAllowedRecords($AppUI->user_id, 'company_id,company_name', 'company_name');
$companies = arrayMerge(array('0' => $AppUI->_('All')), $companies);
// setup the title block
$titleBlock = new w2p_Theme_TitleBlock('Day View', 'icon.png', $m);
$titleBlock->addCrumb('?m=events&a=year_view&date=' . $this_day->format(FMT_TIMESTAMP_DATE), 'year view');
Ejemplo n.º 10
0
<?php

require_once 'Date.php';
$error = false;
$dates = array(array(array(2003, 3, 17), '20030323', '20030317', '20030324', '20030310'), array(array(2003, 3, 20), '20030323', '20030317', '20030324', '20030310'), array(array(2003, 3, 23), '20030323', '20030317', '20030324', '20030310'));
foreach ($dates as $d) {
    $date = $d[0];
    $res = Date_Calc::endOfWeek($date[2], $date[1], $date[0]);
    if ($res != $d[1]) {
        echo "Bug 674 eow: " . $date[0] . $date[1] . $date[2] . " failed\n";
        $error = true;
    }
}
foreach ($dates as $d) {
    $date = $d[0];
    $res = Date_Calc::beginOfWeek($date[2], $date[1], $date[0]);
    if ($res != $d[2]) {
        echo "Bug 674 bow: " . $date[0] . $date[1] . $date[2] . " failed\n";
        $error = true;
    }
}
foreach ($dates as $d) {
    $date = $d[0];
    $res = Date_Calc::beginOfNextWeek($date[2], $date[1], $date[0]);
    if ($res != $d[3]) {
        echo "Bug 674 bonw: " . $date[0] . $date[1] . $date[2] . " failed\n";
        $error = true;
    }
}
foreach ($dates as $d) {
    $date = $d[0];
Ejemplo n.º 11
0
 /**
  * A private method that returns the start and end dates
  * that bound the span, based based on a pre-defined 'friendly'
  * value.
  *
  * See the {@link OA_Admin_DaySpan::setSpanPresetValue()} method
  * for the pre-defined values.
  *
  * @param string $presetValue The preset value string.
  * @return array An array of two elements, "start" and "end",
  *               representing the start and end dates of
  *               the span, respectively.
  */
 function _getSpanDates($presetValue)
 {
     switch ($presetValue) {
         case 'today':
             $oDateStart = new Date($this->oNowDate->format('%Y-%m-%d'));
             $oDateEnd = new Date($this->oNowDate->format('%Y-%m-%d'));
             break;
         case 'yesterday':
             $oDateStart = new Date(Date_Calc::prevDay($this->oNowDate->format('%d'), $this->oNowDate->format('%m'), $this->oNowDate->format('%Y')));
             $oDateEnd = new Date(Date_Calc::prevDay($this->oNowDate->format('%d'), $this->oNowDate->format('%m'), $this->oNowDate->format('%Y')));
             break;
         case 'this_week':
             $oDateStart = new Date(Date_Calc::beginOfWeek($this->oNowDate->format('%d'), $this->oNowDate->format('%m'), $this->oNowDate->format('%Y')));
             $oSixDaySpan = new Date_Span();
             $oSixDaySpan->setFromDays(6);
             $oSevenDaySpan = new Date_Span();
             $oSevenDaySpan->setFromDays(7);
             // Now have week start and end when week starts on Sunday
             // Does the user want to start on a different day?
             $beginOfWeek = OA_Admin_DaySpan::getBeginOfWeek();
             if ($beginOfWeek > 0) {
                 $oRequiredDaysSpan = new Date_Span();
                 $oRequiredDaysSpan->setFromDays($beginOfWeek);
                 $oDateStart->addSpan($oRequiredDaysSpan);
                 $oDateToday = new Date($this->oNowDate->format('%Y-%m-%d'));
                 if ($oDateToday->getDayOfWeek() < $beginOfWeek) {
                     $oDateStart->subtractSpan($oSevenDaySpan);
                 }
             }
             $oDateEnd = new Date($this->oNowDate->format('%Y-%m-%d'));
             break;
         case 'last_week':
             $oDateStart = new Date(Date_Calc::beginOfPrevWeek($this->oNowDate->format('%d'), $this->oNowDate->format('%m'), $this->oNowDate->format('%Y')));
             $oSixDaySpan = new Date_Span();
             $oSixDaySpan->setFromDays(6);
             $oSevenDaySpan = new Date_Span();
             $oSevenDaySpan->setFromDays(7);
             // Now have week start and end when week starts on Sunday
             // Does the user want to start on a different day?
             $beginOfWeek = OA_Admin_DaySpan::getBeginOfWeek();
             if ($beginOfWeek > 0) {
                 $oRequiredDaysSpan = new Date_Span();
                 $oRequiredDaysSpan->setFromDays($beginOfWeek);
                 $oDateStart->addSpan($oRequiredDaysSpan);
                 $oDateToday = new Date($this->oNowDate->format('%Y-%m-%d'));
                 if ($oDateToday->getDayOfWeek() < $beginOfWeek) {
                     $oDateStart->subtractSpan($oSevenDaySpan);
                 }
             }
             $oDateEnd = new Date($this->oNowDate->format('%Y-%m-%d'));
             $oDateEnd->copy($oDateStart);
             $oDateEnd->addSpan($oSixDaySpan);
             break;
         case 'last_7_days':
             $oDateStart = new Date($this->oNowDate->format('%Y-%m-%d'));
             $oDateEnd = new Date($this->oNowDate->format('%Y-%m-%d'));
             $oOneDaySpan = new Date_Span();
             $oOneDaySpan->setFromDays(1);
             $oSevenDaySpan = new Date_Span();
             $oSevenDaySpan->setFromDays(7);
             $oDateStart->subtractSpan($oSevenDaySpan);
             $oDateEnd->subtractSpan($oOneDaySpan);
             break;
         case 'this_month':
             $oDateStart = new Date(Date_Calc::beginOfMonth($this->oNowDate->format('%m'), $this->oNowDate->format('%Y')));
             $oDateEnd = new Date($this->oNowDate->format('%Y-%m-%d'));
             break;
         case 'this_month_full':
             $oDateStart = new Date(Date_Calc::beginOfMonth($this->oNowDate->format('%m'), $this->oNowDate->format('%Y')));
             $oDateEnd = new Date(Date_Calc::beginOfNextMonth($this->oNowDate->format('%d'), $this->oNowDate->format('%m'), $this->oNowDate->format('%Y')));
             $oOneDaySpan = new Date_Span();
             $oOneDaySpan->setFromDays(1);
             $oDateEnd->subtractSpan($oOneDaySpan);
             break;
         case 'this_month_remainder':
             $oDateStart = new Date($this->oNowDate->format('%Y-%m-%d'));
             $oDateEnd = new Date(Date_Calc::beginOfNextMonth($this->oNowDate->format('%d'), $this->oNowDate->format('%m'), $this->oNowDate->format('%Y')));
             $oOneDaySpan = new Date_Span();
             $oOneDaySpan->setFromDays(1);
             $oDateEnd->subtractSpan($oOneDaySpan);
             break;
         case 'next_month':
             $oDateStart = new Date(Date_Calc::beginOfNextMonth($this->oNowDate->format('%d'), $this->oNowDate->format('%m'), $this->oNowDate->format('%Y')));
             $oDateEnd = new Date(Date_Calc::endOfNextMonth($this->oNowDate->format('%d'), $this->oNowDate->format('%m'), $this->oNowDate->format('%Y')));
             break;
         case 'last_month':
             $oDateStart = new Date(Date_Calc::beginOfPrevMonth($this->oNowDate->format('%d'), $this->oNowDate->format('%m'), $this->oNowDate->format('%Y')));
             $oDateEnd = new Date(Date_Calc::beginOfMonth($this->oNowDate->format('%m'), $this->oNowDate->format('%Y')));
             $oOneDaySpan = new Date_Span();
             $oOneDaySpan->setFromDays(1);
             $oDateEnd->subtractSpan($oOneDaySpan);
             break;
         case 'all_stats':
             $oDateStart = null;
             $oDateEnd = null;
             break;
         case 'specific':
             $startDate = MAX_getStoredValue('startDate', date('Y-m-d'));
             $oDateStart = new Date($startDate);
             $endDate = MAX_getStoredValue('endDate', date('Y-m-d'));
             $oDateEnd = new Date($endDate);
             break;
     }
     $this->_setStartDate($oDateStart);
     $this->_setEndDate($oDateEnd);
     $aDates = array('start' => $oDateStart, 'end' => $oDateEnd);
     return $aDates;
 }
Ejemplo n.º 12
0
 public function MakeRecurrences()
 {
     global $_EV_CONF;
     $days_on = $this->event->rec_data['listdays'];
     $occurrence = $this->dt_start;
     $num_intervals = count($days_on);
     $last_interval = $days_on[$num_intervals - 1];
     // Start by reducing the starting date by one day. Then the for
     // loop can handle all the events.
     list($y, $m, $d) = explode('-', $occurrence);
     $occurrence = Date_Calc::prevDay($d, $m, $y);
     $count = 1;
     while ($occurrence <= $this->event->rec_data['stop'] && $occurrence >= '1971-01-01' && $count < $_EV_CONF['max_repeats']) {
         foreach ($days_on as $dow) {
             list($y, $m, $d) = explode('-', $occurrence);
             $occurrence = Date_Calc::nextDayOfWeek($dow - 1, $d, $m, $y);
             // Stop when we hit the stop date
             if ($occurrence > $this->event->rec_data['stop']) {
                 break;
             }
             $this->storeEvent($occurrence);
             $count++;
             if ($count > $_EV_CONF['max_repeats']) {
                 break;
             }
         }
         // foreach days_on
         if ($this->freq > 1) {
             // Get the beginning of this week, and add $freq weeks to it
             $occurrence = Date_Calc::beginOfWeek($d + 7 * $this->freq, $m, $y);
         }
     }
     // while not at stop date
     return $this->events;
 }
Ejemplo n.º 13
0
 /**
  * Return an array with days in week
  *
  * @param string year in format CCYY, default current local year
  * @param string month in format MM, default current local month
  * @param string day in format DD, default current local day
  * @param string format for returned date
  *
  * @access public
  *
  * @return array $week[$weekday]
  */
 public static function getCalendarWeek($day = "", $month = "", $year = "", $format = "%Y%m%d", $fdow = null)
 {
     if (empty($year)) {
         $year = Date_Calc::dateNow("%Y");
     }
     if (empty($month)) {
         $month = Date_Calc::dateNow("%m");
     }
     if (empty($day)) {
         $day = Date_Calc::dateNow("%d");
     }
     if ($fdow === null) {
         $fdow = DATE_CALC_BEGIN_WEEKDAY;
     }
     $week_array = array();
     // date for the column of week
     $curr_day = Date_Calc::beginOfWeek($day, $month, $year, "%E", $fdow);
     for ($counter = 0; $counter <= 6; $counter++) {
         $week_array[$counter] = Date_Calc::daysToDate($curr_day, $format);
         $curr_day++;
     }
     return $week_array;
 }
Ejemplo n.º 14
0
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);
}
Ejemplo n.º 15
0
 /**
  * Return an array with days in week
  *
  * @param string year in format CCYY, default current local year
  * @param string month in format MM, default current local month
  * @param string day in format DD, default current local day
  * @param string format for returned date
  *
  * @access public
  *
  * @return array $week[$weekday]
  */
 function getCalendarWeek($day = "", $month = "", $year = "", $format = "%Y%m%d")
 {
     if (empty($year)) {
         $year = Date_Calc::dateNow("%Y");
     }
     if (empty($month)) {
         $month = Date_Calc::dateNow("%m");
     }
     if (empty($day)) {
         $day = Date_Calc::dateNow("%d");
     }
     $week_array = array();
     // date for the column of week
     $curr_day = Date_Calc::beginOfWeek($day, $month, $year, "%E");
     for ($counter = 0; $counter <= 6; $counter++) {
         $week_array[$counter] = Date_Calc::daysToDate($curr_day, $format);
         $curr_day++;
     }
     return $week_array;
 }
Ejemplo n.º 16
0
 /**
  * A method to convert a Date into an array containing the start
  * and end Dates of the operation interval that the date is in.
  *
  * @static
  * @param Date $oDate The date to convert.
  * @param integer $operation_interval Optional length of the operation interval
  *                                    in minutes. If not given, will use the
  *                                    currently defined operation interval.
  * @param boolean $cacheResult  If true the data should be cached
  * @return array An array of the start and end Dates of the operation interval.
  */
 function convertDateToOperationIntervalStartAndEndDates($oDate, $operationInterval = 0, $cacheResult = true)
 {
     // Convert to UTC
     $oDateCopy = new Date($oDate);
     $oDateCopy->toUTC();
     // Check cache
     static $aCache;
     if ($cacheResult && isset($aCache[$oDateCopy->getDate()][$operationInterval])) {
         $cachedDates = $aCache[$oDateCopy->getDate()][$operationInterval];
         $oStart = new Date($cachedDates['start']);
         $oStart->setTZbyID('UTC');
         $oEnd = new Date($cachedDates['end']);
         $oEnd->setTZbyID('UTC');
         return array('start' => $oStart, 'end' => $oEnd);
     }
     if ($operationInterval < 1) {
         $operationInterval = OX_OperationInterval::getOperationInterval();
     }
     // Get the date representing the start of the week
     $oStartOfWeek = new Date(Date_Calc::beginOfWeek($oDateCopy->getDay(), $oDateCopy->getMonth(), $oDateCopy->getYear(), '%Y-%m-%d 00:00:00'));
     $oStartOfWeek->setTZbyID('UTC');
     // Get the operation interval ID of the date
     $operationIntervalID = OX_OperationInterval::convertDateToOperationIntervalID($oDateCopy, $operationInterval);
     // The start of the operation interval is the start of the week plus the
     // operation interval ID multiplied by the operation interval
     $oStart = new Date();
     $oStart->copy($oStartOfWeek);
     $oStart->addSeconds($operationIntervalID * $operationInterval * 60);
     // The end of the operation interval is the start of the week plus the
     // operation interval ID + 1 multiplied by the operation interval
     $oEnd = new Date();
     $oEnd->copy($oStart);
     $oEnd->addSeconds($operationInterval * 60 - 1);
     // Cache result - cache as string to save memory
     if ($cacheResult) {
         $aCache[$oDate->getDate()][$operationInterval] = array('start' => $oStart->getDate(), 'end' => $oEnd->getDate());
     }
     // Return the result
     return array('start' => $oStart, 'end' => $oEnd);
 }
Ejemplo n.º 17
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 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);
}
Ejemplo n.º 18
0
compare('20001121', Date_Calc::prevDayOfWeek('2', '22', '11', '2000'), 'prevDayOfWeek 1 str');
compare('20001121', Date_Calc::prevDayOfWeek(2, 22, 11, 2000), 'prevDayOfWeek 1');
compare('20001115', Date_Calc::prevDayOfWeek(3, 22, 11, 2000), 'prevDayOfWeek 2');
compare('20001122', Date_Calc::prevDayOfWeek(3, 22, 11, 2000, '%Y%m%d', true), 'prevDayOfWeek 3');
compare('20001122', Date_Calc::nextDayOfWeek(3, 22, 11, 2000, '%Y%m%d', true), 'nextDayOfWeek 1');
compare('20001129', Date_Calc::nextDayOfWeek(3, 22, 11, 2000), 'nextDayOfWeek 2');
compare('20001123', Date_Calc::nextDayOfWeek(4, 22, 11, 2000), 'nextDayOfWeek 3');
compare('20001123', Date_Calc::nextDayOfWeek('4', '22', '11', '2000'), 'nextDayOfWeek 3 str');
compare('20001121', Date_Calc::prevDayOfWeekOnOrBefore('2', '22', '11', '2000'), 'prevDayOfWeekOnOrBefore 1 str');
compare('20001121', Date_Calc::prevDayOfWeekOnOrBefore(2, 22, 11, 2000), 'prevDayOfWeekOnOrBefore 1');
compare('20001122', Date_Calc::prevDayOfWeekOnOrBefore(3, 22, 11, 2000), 'prevDayOfWeekOnOrBefore 2');
compare('20001122', Date_Calc::nextDayOfWeekOnOrAfter(3, 22, 11, 2000), 'nextDayOfWeekOnOrAfter 1');
compare('20001123', Date_Calc::nextDayOfWeekOnOrAfter(4, 22, 11, 2000), 'nextDayOfWeekOnOrAfter 2');
compare('20001123', Date_Calc::nextDayOfWeekOnOrAfter('4', '22', '11', '2000'), 'nextDayOfWeekOnOrAfter 2 str');
compare('20001120', Date_Calc::beginOfWeek('22', '11', '2000'), 'beginOfWeek str');
compare('20001120', Date_Calc::beginOfWeek(22, 11, 2000), 'beginOfWeek');
compare('20001126', Date_Calc::endOfWeek(22, 11, 2000), 'endOfWeek');
compare('20001126', Date_Calc::endOfWeek('22', '11', '2000'), 'endOfWeek str');
compare('20001113', Date_Calc::beginOfPrevWeek(22, 11, 2000), 'beginOfPrevWeek');
compare('20001127', Date_Calc::beginOfNextWeek(22, 11, 2000), 'beginOfNextWeek');
compare('20001113', Date_Calc::beginOfPrevWeek('22', '11', '2000'), 'beginOfPrevWeek str');
compare('20001127', Date_Calc::beginOfNextWeek('22', '11', '2000'), 'beginOfNextWeek str');
compare('20001101', Date_Calc::beginOfMonth(11, 2000), 'beginOfMonth');
compare('20001101', Date_Calc::beginOfMonth('11', '2000'), 'beginOfMonth str');
compare('20001001', Date_Calc::beginOfPrevMonth(22, 11, 2000), 'beginOfPrevMonth');
compare('20001031', Date_Calc::endOfPrevMonth(22, 11, 2000), 'endOfPrevMonth');
compare('20001001', Date_Calc::beginOfPrevMonth('22', '11', '2000'), 'beginOfPrevMonth str');
compare('20001031', Date_Calc::endOfPrevMonth('22', '11', '2000'), 'endOfPrevMonth str');
compare('20001201', Date_Calc::beginOfNextMonth(22, 11, 2000), 'beginOfNextMonth');
compare('20001231', Date_Calc::endOfNextMonth(22, 11, 2000), 'endOfNextMonth');
compare('20001201', Date_Calc::beginOfNextMonth('22', '11', '2000'), 'beginOfNextMonth str');