Ejemplo n.º 1
0
 public function testSameDay()
 {
     $objDate = new class_date();
     $this->assertTrue($objDate->isSameDay(new class_date()));
     $objDate->setNextDay();
     $this->assertTrue(!$objDate->isSameDay(new class_date()));
 }
Ejemplo n.º 2
0
 public function testReports()
 {
     if (!defined("_skinwebpath_")) {
         define("_skinwebpath_", "1");
     }
     echo "processing reports...\n";
     $arrReportsInFs = class_resourceloader::getInstance()->getFolderContent("/admin/statsreports", array(".php"), false, function ($strOneFile) {
         if (uniStripos($strOneFile, "class_stats_report") === false) {
             return false;
         }
         return true;
     }, function (&$strOneFile) {
         $strOneFile = uniSubstr($strOneFile, 0, -4);
         $strOneFile = new $strOneFile(class_carrier::getInstance()->getObjDB(), class_carrier::getInstance()->getObjToolkit("admin"), class_carrier::getInstance()->getObjLang());
     });
     $arrReports = array();
     foreach ($arrReportsInFs as $objReport) {
         if ($objReport instanceof interface_admin_statsreports) {
             $arrReports[$objReport->getTitle()] = $objReport;
         }
         $objStartDate = new class_date();
         $objStartDate->setPreviousDay();
         $objEndDate = new class_date();
         $objEndDate->setNextDay();
         $intStartDate = mktime(0, 0, 0, $objStartDate->getIntMonth(), $objStartDate->getIntDay(), $objStartDate->getIntYear());
         $intEndDate = mktime(0, 0, 0, $objEndDate->getIntMonth(), $objEndDate->getIntDay(), $objEndDate->getIntYear());
         $objReport->setEndDate($intEndDate);
         $objReport->setStartDate($intStartDate);
         $objReport->setInterval(2);
     }
     /** @var interface_admin_statsreports $objReport */
     foreach ($arrReports as $objReport) {
         ob_start();
         echo "processing report " . $objReport->getTitle() . "\n";
         $objReport->getReport();
         $objReport->getReportGraph();
     }
 }
 /**
  * @return string
  * @permissions view
  */
 protected function actionRenderCalendar()
 {
     $strReturn = "";
     $strContent = "";
     $arrJsHighlights = array();
     $strReturn .= "<content><![CDATA[";
     /** @var interface_calendarsource_admin[] $arrRelevantModules  */
     $arrRelevantModules = array();
     //fetch modules relevant for processing
     $arrModules = class_module_system_module::getAllModules();
     foreach ($arrModules as $objSingleModule) {
         if ($objSingleModule->getIntRecordStatus() == 1 && $objSingleModule->getAdminInstanceOfConcreteModule() instanceof interface_calendarsource_admin) {
             $arrRelevantModules[] = $objSingleModule->getAdminInstanceOfConcreteModule();
         }
     }
     //the header row
     $arrWeekdays = explode(",", $this->getLang("calendar_weekday"));
     foreach ($arrWeekdays as $intKey => $strValue) {
         $arrWeekdays[$intKey] = trim(uniStrReplace("\"", "", $strValue));
     }
     $strContent .= $this->objToolkit->getCalendarHeaderRow($arrWeekdays);
     //render the single rows. calculate the first day of the row
     $objDate = new class_date();
     $objDate->setIntDay(1);
     //set to interval stored in session
     if ($this->objSession->getSession($this->strStartMonthKey) != "") {
         $objDate->setIntMonth($this->objSession->getSession($this->strStartMonthKey));
     }
     if ($this->objSession->getSession($this->strStartYearKey) != "") {
         $objDate->setIntYear($this->objSession->getSession($this->strStartYearKey));
     }
     $intCurMonth = $objDate->getIntMonth();
     $intCurYear = $objDate->getIntYear();
     $objToday = new class_date();
     //start by monday
     while ($objDate->getIntDayOfWeek() != 1) {
         $objDate->setPreviousDay();
     }
     $strEntries = "";
     $intRowEntryCount = 0;
     while ($objDate->getIntMonth() <= $intCurMonth && $objDate->getIntYear() <= $intCurYear || $objDate->getIntMonth() == 12 && $objDate->getIntYear() < $intCurYear || $intRowEntryCount % 7 != 0) {
         $intRowEntryCount++;
         $strDate = $objDate->getIntDay();
         $arrEvents = array();
         if ($objDate->getIntMonth() == $intCurMonth) {
             //Query modules for dates
             $objStartDate = clone $objDate;
             $objStartDate->setIntHour(0)->setIntMin(0)->setIntSec(0);
             $objEndDate = clone $objDate;
             $objEndDate->setIntHour(23)->setIntMin(59)->setIntSec(59);
             foreach ($arrRelevantModules as $objOneModule) {
                 $arrEvents = array_merge($objOneModule->getArrCalendarEntries($objStartDate, $objEndDate), $arrEvents);
             }
         }
         while (count($arrEvents) <= 3) {
             $objDummy = new class_calendarentry();
             $objDummy->setStrClass("spacer");
             $objDummy->setStrName("&nbsp;");
             $arrEvents[] = $objDummy;
         }
         $strEvents = "";
         /** @var class_calendarentry $objOneEvent */
         foreach ($arrEvents as $objOneEvent) {
             $strName = $objOneEvent->getStrName();
             $strSecondLine = $objOneEvent->getStrSecondLine();
             if ($strSecondLine != "") {
                 $strSecondLine = "<br />" . $strSecondLine;
             }
             //register mouse-over highlight relations
             if ($objOneEvent->getStrHighlightId() != "" && $objOneEvent->getStrSystemid() != "") {
                 if (!isset($arrJsHighlights[$objOneEvent->getStrHighlightId()])) {
                     $arrJsHighlights[$objOneEvent->getStrHighlightId()] = array();
                 }
                 $arrJsHighlights[$objOneEvent->getStrHighlightId()][] = $objOneEvent->getStrSystemid();
             }
             $strEvents .= $this->objToolkit->getCalendarEvent($strName . $strSecondLine, $objOneEvent->getStrSystemid(), $objOneEvent->getStrHighlightId(), $objOneEvent->getStrClass());
         }
         $bitBlocked = false;
         if ($objDate->getIntDayOfWeek() == 0 || $objDate->getIntDayOfWeek() == 6) {
             $bitBlocked = true;
         }
         $strToday = "";
         if ($objToday->getIntYear() == $objDate->getIntYear() && $objToday->getIntMonth() == $objDate->getIntMonth() && $objToday->getIntDay() == $objDate->getIntDay()) {
             $strToday = " calendarDateToday";
         }
         if ($objDate->getIntMonth() != $intCurMonth) {
             $strEntries .= $this->objToolkit->getCalendarEntry($strEvents, $strDate, "calendarEntryOutOfRange" . $strToday);
         } else {
             if ($bitBlocked) {
                 $strEntries .= $this->objToolkit->getCalendarEntry($strEvents, $strDate, "calendarEntryBlocked" . $strToday);
             } else {
                 $strEntries .= $this->objToolkit->getCalendarEntry($strEvents, $strDate, "calendarEntry" . $strToday);
             }
         }
         if ($intRowEntryCount % 7 == 0) {
             $strContent .= $this->objToolkit->getCalendarRow($strEntries);
             $strEntries = "";
         }
         $objDate->setNextDay();
     }
     if ($strEntries != "") {
         $strContent .= $this->objToolkit->getCalendarRow($strEntries);
     }
     $strReturn .= $this->objToolkit->getCalendarWrapper($strContent);
     //build js-arrays
     $strJs = "<script type=\"text/javascript\">";
     foreach ($arrJsHighlights as $strCommonId => $arrEntries) {
         $strJs .= " var kj_cal_" . $strCommonId . " = new Array();";
         foreach ($arrEntries as $strOneIdentifier) {
             $strJs .= "kj_cal_" . $strCommonId . ".push('" . $strOneIdentifier . "');";
         }
     }
     $strJs .= "</script>";
     $strReturn .= $strJs;
     $strReturn .= "]]></content>";
     return $strReturn;
 }
 /**
  * @return void
  */
 public function schedule()
 {
     $objDate = clone $this->objWorkflow->getObjTriggerdate();
     //reschedule
     for ($intI = 0; $intI < $this->intIntervalDays; $intI++) {
         $objDate->setNextDay();
     }
     $objDate->setIntHour($this->intSendTime)->setIntMin(0)->setIntSec(0);
     if ($objDate->getLongTimestamp() < class_date::getCurrentTimestamp()) {
         $objDate = new class_date();
         $objDate->setNextDay()->setIntHour($this->intSendTime)->setIntMin(0)->setIntSec(0);
     }
     $this->objWorkflow->setObjTriggerdate($objDate);
 }