Created a new service for show days
Created a new user service Started refactoring edit show action
This commit is contained in:
parent
1cc823ef0e
commit
7347be35b1
8 changed files with 286 additions and 137 deletions
|
@ -27,84 +27,6 @@ class Application_Service_ShowService
|
|||
return $ccShow;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Sets the fields for a cc_show_days table row
|
||||
* @param $showData
|
||||
* @param $showId
|
||||
* @param $userId
|
||||
* @param $repeatType
|
||||
* @param $isRecorded
|
||||
*/
|
||||
public function createShowDays($showData, $showId, $userId, $repeatType, $isRecorded)
|
||||
{
|
||||
$startDateTime = new DateTime($showData['add_show_start_date']." ".$showData['add_show_start_time']);
|
||||
|
||||
if ($showData['add_show_no_end']) {
|
||||
$endDate = NULL;
|
||||
} elseif ($showData['add_show_repeats']) {
|
||||
$endDateTime = new DateTime($showData['add_show_end_date']);
|
||||
$endDateTime->add(new DateInterval("P1D"));
|
||||
$endDate = $endDateTime->format("Y-m-d");
|
||||
} else {
|
||||
$endDateTime = new DateTime($showData['add_show_start_date']);
|
||||
$endDateTime->add(new DateInterval("P1D"));
|
||||
$endDate = $endDateTime->format("Y-m-d");
|
||||
}
|
||||
|
||||
/* What we are doing here is checking if the show repeats or if
|
||||
* any repeating days have been checked. If not, then by default
|
||||
* the "selected" DOW is the initial day.
|
||||
* DOW in local time.
|
||||
*/
|
||||
$startDow = date("w", $startDateTime->getTimestamp());
|
||||
if (!$showData['add_show_repeats']) {
|
||||
$showData['add_show_day_check'] = array($startDow);
|
||||
} elseif ($showData['add_show_repeats'] && $showData['add_show_day_check'] == "") {
|
||||
$showData['add_show_day_check'] = array($startDow);
|
||||
}
|
||||
|
||||
// Don't set day for monthly repeat type, it's invalid
|
||||
if ($showData['add_show_repeats'] && $showData['add_show_repeat_type'] == 2) {
|
||||
$showDay = new CcShowDays();
|
||||
$showDay->setDbFirstShow($startDateTime->format("Y-m-d"));
|
||||
$showDay->setDbLastShow($endDate);
|
||||
$showDay->setDbStartTime($startDateTime->format("H:i:s"));
|
||||
$showDay->setDbTimezone(Application_Model_Preference::GetUserTimezone($userId));
|
||||
$showDay->setDbDuration($showData['add_show_duration']);
|
||||
$showDay->setDbRepeatType($repeatType);
|
||||
$showDay->setDbShowId($showId);
|
||||
$showDay->setDbRecord($isRecorded);
|
||||
$showDay->save();
|
||||
} else {
|
||||
foreach ($showData['add_show_day_check'] as $day) {
|
||||
$daysAdd=0;
|
||||
$startDateTimeClone = clone $startDateTime;
|
||||
if ($startDow !== $day) {
|
||||
if ($startDow > $day)
|
||||
$daysAdd = 6 - $startDow + 1 + $day;
|
||||
else
|
||||
$daysAdd = $day - $startDow;
|
||||
|
||||
$startDateTimeClone->add(new DateInterval("P".$daysAdd."D"));
|
||||
}
|
||||
if (is_null($endDate) || $startDateTimeClone->getTimestamp() <= $endDateTime->getTimestamp()) {
|
||||
$showDay = new CcShowDays();
|
||||
$showDay->setDbFirstShow($startDateTimeClone->format("Y-m-d"));
|
||||
$showDay->setDbLastShow($endDate);
|
||||
$showDay->setDbStartTime($startDateTimeClone->format("H:i"));
|
||||
$showDay->setDbTimezone(Application_Model_Preference::GetUserTimezone($userId));
|
||||
$showDay->setDbDuration($showData['add_show_duration']);
|
||||
$showDay->setDbDay($day);
|
||||
$showDay->setDbRepeatType($repeatType);
|
||||
$showDay->setDbShowId($showId);
|
||||
$showDay->setDbRecord($isRecorded);
|
||||
$showDay->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Sets the fields for a cc_show_rebroadcast table row
|
||||
|
@ -178,20 +100,6 @@ class Application_Service_ShowService
|
|||
return $populateUntil;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Gets the cc_show_days entries for a specific show
|
||||
*
|
||||
* @return array of ccShowDays objects
|
||||
*/
|
||||
public function getShowDays($showId)
|
||||
{
|
||||
$sql = "SELECT * FROM cc_show_days WHERE show_id = :show_id";
|
||||
|
||||
return Application_Common_Database::prepareAndExecute(
|
||||
$sql, array(":show_id" => $showId), 'all');
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Enter description here ...
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue