Fixed holidays display for subgroups.
[timetracker.git] / WEB-INF / lib / form / Calendar.class.php
index a64a035..a8455a8 100644 (file)
@@ -44,25 +44,24 @@ class Calendar extends FormElement {
 
     var $controlName = "";
     var $highlight = "time"; // Determines what type of active days to highlight ("time" or "expenses"). 
-    // var $mAllDays       = true;
-    var $cClassName    = "Calendar";
 
     function __construct($name) {
-        $this->controlName = $name;
-        $this->mMonthNames = array('January','February','March','April','May','June','July','August','September','October','November','December');
-        $this->mWeekDayShortNames = array('Su','Mo','Tu','We','Th','Fr','Sa');
+      $this->class = 'Calendar';
+      $this->controlName = $name; // TODO: why controlName? Other classes have "name".
+      $this->mMonthNames = array('January','February','March','April','May','June','July','August','September','October','November','December');
+      $this->mWeekDayShortNames = array('Su','Mo','Tu','We','Th','Fr','Sa');
     }
-    
+
     function setHighlight($highlight) {
        if ($highlight && $highlight != 'time')
          $this->highlight = $highlight;
     }
 
-    function setLocalization($i18n) {
+    function localize() {
       global $user;
+      global $i18n;
       
-      FormElement::setLocalization($i18n);
-      $this->mMonthNames    = $i18n->monthNames;
+      $this->mMonthNames = $i18n->monthNames;
       $this->mWeekDayShortNames = $i18n->weekdayShortNames;
       if (is_array($i18n->holidays)) {
         foreach ($i18n->holidays as $fday) {
@@ -73,7 +72,7 @@ class Calendar extends FormElement {
       $this->weekStartDay = $user->week_start;
     }
 
-    function setStyle($style) { $this->mStyle = $style; }
+    function setStyle($style) { $this->style = $style; }
     function setCellStyle($style) { $this->mCellStyle = $style; }
     function setACellStyle($style) { $this->mACellStyle = $style; }
     function setLinkStyle($style) { $this->mLinkStyle = $style; }
@@ -93,8 +92,6 @@ class Calendar extends FormElement {
       $indate = $this->value;
       if (!$indate) $indate = strftime(DB_DATEFORMAT);
 
-      if (!$this->isRenderable()) return "";
-
       //current year and month
       if ( strlen ( $indate ) > 0 ) {
         $indateObj = new DateAndTime(DB_DATEFORMAT, $indate);
@@ -175,7 +172,8 @@ class Calendar extends FormElement {
             }
 
               // holidays
-              if ($this->showHolidays) {
+              global $user;
+              if ($user->isOptionEnabled('show_holidays')) {
               foreach ($this->holidays as $day) {
                 if($day == $date) {
                   $stl_cell = ' class="CalendarDayHoliday"';
@@ -208,7 +206,7 @@ class Calendar extends FormElement {
         $str .= "</TR>\n";
       }
 
-      $str .= "<tr><td colspan=\"7\" align=\"center\"><a id=\"today_link\" href=\"?".$this->controlName."=".strftime(DB_DATEFORMAT)."\" tabindex=\"-1\">".$i18n->getKey('label.today')."</a></td></tr>\n";
+      $str .= "<tr><td colspan=\"7\" align=\"center\"><a id=\"today_link\" href=\"?".$this->controlName."=".strftime(DB_DATEFORMAT)."\" tabindex=\"-1\">".$i18n->get('label.today')."</a></td></tr>\n";
       $str .= "</table>\n";
 
       $str .= "<input type=\"hidden\" name=\"$this->controlName\" value=\"$indate\">\n";
@@ -225,7 +223,7 @@ class Calendar extends FormElement {
       return $str;
     }
 
-    function toStringControl() {
+    function getHtml() {
         return $this->toString();
     }
 
@@ -261,7 +259,7 @@ class Calendar extends FormElement {
     function _getActiveDates($start, $end) {
       
       global $user;
-      $user_id = $user->getActiveUser();
+      $user_id = $user->getUser();
       
       $table = ($this->highlight == 'expenses') ? 'tt_expense_items' : 'tt_log';