Exemplo n.º 1
0
 /**
  * Return the {@link SQLQuery} that provides your report data.
  */
 function sourceQuery($params)
 {
     $sqlQuery = new SQLQuery();
     $sqlQuery->setFrom('CalendarEvent');
     $sqlQuery->selectField('Date');
     $sqlQuery->selectField('CalendarEvent.Title', 'Event');
     $sqlQuery->selectField('StartTime');
     $sqlQuery->selectField('EndTime');
     $sqlQuery->addInnerJoin('CalendarEventDate', '"CalendarEventDate"."CalendarEventID" = "CalendarEvent"."ID"');
     if (isset($params['DateFrom'])) {
         $fromDate = new SS_DateTime('FromDate');
         $fromDate->setValue($params['DateFrom']);
         $sqlQuery->addWhere(array('Date >= ?' => $fromDate->Format("Y-m-d")));
     }
     if (isset($params['DateTo'])) {
         $toDate = new SS_DateTime('ToDate');
         $toDate->setValue($params['DateTo']);
         $sqlQuery->addWhere(array('Date <= ?' => $toDate->Format("Y-m-d")));
     }
     if (isset($params['PrivateBookings'])) {
         if ($params['PrivateBookings'] == 'Private') {
             $sqlQuery->addWhere('Private = 1');
         } elseif ($params['PrivateBookings'] == 'Public') {
             $sqlQuery->addWhere('Private = 0');
         }
     }
     $sqlQuery->addOrderBy('Date');
     $sqlQuery->addOrderBy('Event');
     $sqlQuery->addOrderBy('StartTime');
     $sqlQuery->addOrderBy('EndTime');
     return $sqlQuery;
 }
Exemplo n.º 2
0
 public function Meetings()
 {
     $meetings = new ArrayList();
     $year = date('Y');
     $month = date('n');
     $months = array(1 => 'January', 2 => 'February', 3 => 'March', 4 => 'April', 5 => 'May', 6 => 'June', 7 => 'July', 8 => 'August', 9 => 'September', 10 => 'October', 11 => 'November', 12 => 'December');
     for ($i = 0; $i < 12; $i++) {
         // Get the second and fourth Saturdays and add them to the array.
         $firstSaturday = strtotime($months[$month] . ' ' . $year . ' Saturday');
         $meeting = $firstSaturday + 7.5 * 24 * 60 * 60;
         for ($j = 0; $j < 2; $j++) {
             // Hack - this should be done with a modeladmin for removed and
             // added dates.
             $skipDay = false;
             if ($year == 2013 && $month == 8 && $j == 0) {
                 $skipDay = true;
             }
             $meetingTime = $meeting;
             if ($skipDay) {
                 $meetingTime += 24 * 60 * 60;
             }
             $date = new SS_DateTime();
             $date->setValue(date('d/m/Y', $meetingTime));
             $meetings->push(new ArrayData(array('StartDate' => $date, 'Title' => 'Club Meeting', 'Location' => 'club')));
             $meeting += 14 * 24 * 60 * 60;
         }
         // Increment the month
         $month++;
         if ($month > 12) {
             $month = 1;
             $year++;
         }
     }
     return $meetings;
 }
 /**
  * A user formatted date
  * @return string
  */
 public function getDateTime()
 {
     $date = new SS_DateTime();
     $date->setValue($this->ts);
     return Convert::raw2xml($date->FormatFromSettings());
 }
Exemplo n.º 4
0
 /**
  * Called by responseSave function
  * Saves any client script errors to the database
  * @param $saved set to true if data is saved
  */
 private function responseSaveScript(&$saved)
 {
     $this->log("TenonAjax.responseSaveScript", "count=" . count($this->tenon_response->clientScriptErrors));
     if (count($this->tenon_response->clientScriptErrors) > 0) {
         foreach ($this->tenon_response->clientScriptErrors as $csError) {
             $result = new TenonResult();
             $timestamp = new SS_DateTime();
             $timestamp->setValue(date('Y-m-d H:i:s'));
             $result->setField('PageURL', $this->tenon_page);
             $result->setField('ResultType', 'Script');
             $result->setField('Timestamp', $timestamp);
             if (isset($this->tenon_response->resultSummary->errorDensity)) {
                 $result->setField('PageDensity', $this->tenon_response->resultSummary->errorDensity / 100);
             }
             $result->setField('Title', $this->tenon_page . 'script error');
             $result->setField('ErrorTitle', 'Script error');
             $result->setField('Description', $csError->message);
             if (isset($csError->stacktrace)) {
                 $stFiles = $this->responseSaveScriptCollate($csError->stacktrace, 'file');
                 $stFunctions = $this->responseSaveScriptCollate($csError->stacktrace, 'function');
                 $stLines = $this->responseSaveScriptCollate($csError->stacktrace, 'line');
                 $result->setField('Snippet', "{$stFiles}<br />{$stFunctions}");
                 $result->setField('Location', "{$stLines}");
             }
             $result->write();
         }
         $saved = true;
     }
     $this->log("TenonAjax.responseSaveScript", "count=" . count($this->tenon_response->clientScriptErrors));
 }
Exemplo n.º 5
0
 public function getNextDate()
 {
     $date = $this->getDate();
     if ($date->isToday()) {
         return;
     }
     $endDate = $this->obj('EndDate');
     if ($date->format('Y') > $endDate->format('Y') || $date->format('n') > $endDate->format('n') || $date->format('j') >= $endDate->format('j')) {
         return;
     }
     $nextDate = new SS_DateTime('NextDate');
     $nextDate->setValue($date->getValue());
     do {
         $nextDate->setValue($nextDate->next_day($nextDate->format('Y'), $nextDate->format('n'), $nextDate->format('j')));
     } while ($nextDate->format('N') >= 6);
     // Skip past weekends.
     // If, after we skipped the weekend, we've shot past the current day or the end of sprint,
     // then return.
     if ($nextDate->inFuture()) {
         return;
     }
     if ($nextDate->format('Y') > $endDate->format('Y') || $nextDate->format('n') > $endDate->format('n') || $nextDate->format('j') > $endDate->format('j')) {
         return;
     }
     return $nextDate;
 }