/**
  * Perform any actions for the page.
  * @return boolean
  */
 public function action()
 {
     if (!parent::action()) {
         return false;
     }
     if (!$this->hasPermission('role(admin)')) {
         return false;
     }
     $this->template->setAttribute("class", "active", "menuConfigure", "a[@href='configure']");
     $this->template->appendFileById("menu_configure.html", "ul", "menuConfigure");
     $this->template->setAttribute("class", "active", "menuUserStatistics", "a[@href='UserStatistics']");
     $displayObj = new iHRIS_CustomReport_Display_UserStatistics($this, "UserStatistics");
     $contentNode = $this->template->getElementById('siteContent');
     if (!$contentNode instanceof DOMNode) {
         I2CE::raiseError("Couldn't find siteContent node.");
         return false;
     }
     $this->template->addHeaderLink("customReports_display_Default.css");
     $this->template->setDisplayData("limit_description", false);
     return $displayObj->display($contentNode);
 }
 /**
  * Perform any actions for the page.
  * @return boolean
  */
 public function action()
 {
     if (count($this->request_remainder) > 0) {
         $cacheControl = array_shift($this->request_remainder);
         $usModule = I2CE_ModuleFactory::instance()->getClass("UserStatistics");
         switch ($cacheControl) {
             case "updateCacheForce":
                 if ($usModule->cacheUserStatistics(false, true)) {
                     I2CE::raiseMessage("Updated user statistics.");
                 } else {
                     I2CE::raiseError("Failed to force cache user statistics.");
                 }
                 break;
             case "updateCache":
                 if ($usModule->cacheUserStatistics()) {
                     I2CE::raiseMessage("Updated user statistics.");
                 } else {
                     I2CE::raiseError("Failed to cache user statistics.");
                 }
         }
     }
     if (!parent::action()) {
         return false;
     }
     if ((array_key_exists('admin_only', $this->args) ? $this->args['admin_only'] : true) && !$this->hasPermission('role(admin)')) {
         return false;
     }
     $this->template->setAttribute("class", "active", "menuConfigure", "a[@href='configure']");
     $this->template->appendFileById("menu_configure.html", "ul", "menuConfigure");
     $this->template->setAttribute("class", "active", "menuUserStatistics", "a[@href='UserStatistics']");
     $displayObj = new iHRIS_CustomReport_Display_UserStatistics($this, "UserStatistics");
     $contentNode = $this->template->getElementById('siteContent');
     if (!$contentNode instanceof DOMNode) {
         I2CE::raiseError("Couldn't find siteContent node.");
         return false;
     }
     $this->template->addHeaderLink("customReports_display_Default.css");
     $this->template->setDisplayData("limit_description", false);
     if ($displayObj->display($contentNode)) {
         //$cacheControl = $this->template->appendFileById( "user_statistics_cache_control.html", "div", "report_results", 0, null, true );
         $limitNode = $this->template->getElementByName("report_view_limit_description", 0);
         $cacheNode = $this->template->createElement("div", array("id" => "user_statistics_cache_control"));
         $limitNode->parentNode->insertBefore($cacheNode, $limitNode->nextSibling);
         $cacheControl = $this->template->appendFileById("user_statistics_cache_control.html", "div", "user_statistics_cache_control");
         $config = I2CE::getConfig()->modules->UserStatistics->cache;
         $config->volatile(true);
         $start = 0;
         $end = 0;
         $failed = 0;
         $config->setIfIsSet($start, "start");
         $config->setIfIsSet($end, "end");
         $config->setIfIsSet($failed, "failed");
         $st_date = I2CE_Date::now(I2CE_DATE::DATE_TIME, $start);
         //I2CE::raiseMessage("last started on " . $st_date->displayDate() );
         if ($start == 0) {
             $this->launchBackgroundPage("/UserStatistics/cache");
         } else {
             if ($end != 0) {
                 $end_date = I2CE_Date::now(I2CE_Date::DATE_TIME, $end);
                 $this->setDisplayDataImmediate("last_cache_end", $end_date->displayDate(), $cacheControl);
             } else {
                 $this->setDisplayDataImmediate("last_cache_end", "Never Cached", $cacheControl);
             }
             if ($end >= $start) {
                 $this->template->addFile("user_statistics_cache_status_done.html", "p");
             } elseif ($failed >= $start) {
                 $this->template->addFile("user_statistics_cache_status_failed.html", "p");
             } else {
                 $this->template->addFile("user_statistics_cache_status_running.html", "p");
             }
         }
         return true;
     } else {
         return false;
     }
 }