X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;ds=sidebyside;f=WEB-INF%2Flib%2FttTimeHelper.class.php;h=d7278c69e747f621c8b3deff9b2f194f97787cf0;hb=d18d90a3f3050def6c646eef7d5420c2d2091393;hp=2b5b39bcaf7b13dae36e4a98cec4628874948e1c;hpb=9819bb63bec83c13dd40ebb2ffc24df5fcfeda33;p=timetracker.git diff --git a/WEB-INF/lib/ttTimeHelper.class.php b/WEB-INF/lib/ttTimeHelper.class.php index 2b5b39bc..d7278c69 100644 --- a/WEB-INF/lib/ttTimeHelper.class.php +++ b/WEB-INF/lib/ttTimeHelper.class.php @@ -33,6 +33,11 @@ class ttTimeHelper { // isWeekend determines if $date falls on weekend. static function isWeekend($date) { + // NOTE: this does not work for subgroups with different WEEKEND_START_DAY + // as the setting is per server. Example: a parent group in USA, with a subgroup + // in Saudi Arabia. Their weekends are the same. + // Decided NOT to introduce a configurable WEEKEND_START_DAY for groups in UI + // to keep UI simple, for now. See also Calendar class with the same issue. $weekDay = date('w', strtotime($date)); return ($weekDay == WEEKEND_START_DAY || $weekDay == (WEEKEND_START_DAY + 1) % 7); } @@ -40,22 +45,6 @@ class ttTimeHelper { // isHoliday determines if $date falls on a holiday. static function isHoliday($date) { global $user; - global $i18n; - - if (!$user->show_holidays) return false; - - // $date is expected as string in DB_DATEFORMAT. - $month = date('m', strtotime($date)); - $day = date('d', strtotime($date)); - if (in_array($month.'/'.$day, $i18n->holidays)) - return true; - - return false; - } - - // isHoliday determines if $date falls on a holiday. - static function isHoliday2($date) { - global $user; $holidays = $user->getHolidays(); if (!$holidays) @@ -76,8 +65,10 @@ class ttTimeHelper { $holiDateSpecArray = explode('-', $holiDateSpec); // Check year. - if ($dateArray[0] != $holiDateSpecArray[0] && $holiDateSpecArray[0] != '****') // **** means all years. - return false; + for($i = 0; $i < 4; $i++) { + if ($dateArray[0][$i] != $holiDateSpecArray[0][$i] && $holiDateSpecArray[0][$i] != '*') // * means any digit matches + return false; + } // Check month. if ($dateArray[1] != $holiDateSpecArray[1]) return false; @@ -88,6 +79,16 @@ class ttTimeHelper { return true; } + // dateInDatabaseFormat prepares a date string in DB_DATEFORMAT out of year, month, and day. + static function dateInDatabaseFormat($year, $month, $day) { + $date = "$year-"; + if (strlen($month) == 1) $date .= '0'; + $date .= "$month-"; + if (strlen($day) == 1) $date .= '0'; + $date .= $day; + return $date; + } + // isValidTime validates a value as a time string. static function isValidTime($value) { if (strlen($value)==0 || !isset($value)) return false; @@ -648,8 +649,8 @@ class ttTimeHelper { static function getUncompleted($user_id) { $mdb2 = getConnection(); - $sql = "select id, start from tt_log - where user_id = $user_id and start is not null and time_to_sec(duration) = 0 and status = 1"; + $sql = "select id, start, date from tt_log". + " where user_id = $user_id and start is not null and time_to_sec(duration) = 0 and status = 1"; $res = $mdb2->query($sql); if (!is_a($res, 'PEAR_Error')) { if (!$res->numRows()) {