Example #1
0
 /**
  * Returns data related to the scheduled items.
  *
  * @param  int  $p_prev
  * @param  int  $p_next
  * @return date
  */
 public static function GetPlayOrderRange($p_prev = 1, $p_next = 1)
 {
     if (!is_int($p_prev) || !is_int($p_next)) {
         //must enter integers to specify ranges
         Logging::info("Invalid range parameters: {$p_prev} or {$p_next}");
         return array();
     }
     $date = new Application_Common_DateHelper();
     $timeNow = $date->getTimestamp();
     $utcTimeNow = $date->getUtcTimestamp();
     $shows = Application_Model_Show::getPrevCurrentNext($utcTimeNow);
     $previousShowID = count($shows['previousShow']) > 0 ? $shows['previousShow'][0]['instance_id'] : null;
     $currentShowID = count($shows['currentShow']) > 0 ? $shows['currentShow'][0]['instance_id'] : null;
     $nextShowID = count($shows['nextShow']) > 0 ? $shows['nextShow'][0]['instance_id'] : null;
     $results = self::GetPrevCurrentNext($previousShowID, $currentShowID, $nextShowID, $utcTimeNow);
     $range = array("env" => APPLICATION_ENV, "schedulerTime" => $timeNow, "previous" => $results['previous'] != null ? $results['previous'] : (count($shows['previousShow']) > 0 ? $shows['previousShow'][0] : null), "current" => $results['current'] != null ? $results['current'] : (count($shows['currentShow']) > 0 && $shows['currentShow'][0]['record'] == 1 ? $shows['currentShow'][0] : null), "next" => $results['next'] != null ? $results['next'] : (count($shows['nextShow']) > 0 ? $shows['nextShow'][0] : null), "currentShow" => $shows['currentShow'], "nextShow" => $shows['nextShow'], "timezone" => date("T"), "timezoneOffset" => date("Z"));
     return $range;
 }
Example #2
0
 private function updateStartDateTime($p_data, $p_endDate)
 {
     //need to update cc_schedule, cc_show_instances, cc_show_days
     $con = Propel::getConnection();
     $date = new Application_Common_DateHelper();
     $timestamp = $date->getTimestamp();
     //TODO fix this from overwriting info.
     $sql = "UPDATE cc_show_days " . "SET start_time = TIME '{$p_data['add_show_start_time']}', " . "first_show = DATE '{$p_data['add_show_start_date']}', ";
     if (strlen($p_endDate) == 0) {
         $sql .= "last_show = NULL ";
     } else {
         $sql .= "last_show = DATE '{$p_endDate}' ";
     }
     $sql .= "WHERE show_id = {$p_data['add_show_id']}";
     $con->exec($sql);
     $dtOld = new DateTime($this->getStartDate() . " " . $this->getStartTime(), new DateTimeZone("UTC"));
     $dtNew = new DateTime($p_data['add_show_start_date'] . " " . $p_data['add_show_start_time'], new DateTimeZone(date_default_timezone_get()));
     $diff = $dtOld->getTimestamp() - $dtNew->getTimestamp();
     $sql = "UPDATE cc_show_instances " . "SET starts = starts + INTERVAL '{$diff} sec', " . "ends = ends + INTERVAL '{$diff} sec' " . "WHERE show_id = {$p_data['add_show_id']} " . "AND starts > TIMESTAMP '{$timestamp}'";
     $con->exec($sql);
     $showInstanceIds = $this->getAllFutureInstanceIds();
     if (count($showInstanceIds) > 0 && $diff != 0) {
         $showIdsImploded = implode(",", $showInstanceIds);
         $sql = "UPDATE cc_schedule " . "SET starts = starts + INTERVAL '{$diff} sec', " . "ends = ends + INTERVAL '{$diff} sec' " . "WHERE instance_id IN ({$showIdsImploded})";
         $con->exec($sql);
     }
 }