diff --git a/application/configs/airtime-conf.php b/application/configs/airtime-conf.php
index 1fe0ecb7e..144676b10 100644
--- a/application/configs/airtime-conf.php
+++ b/application/configs/airtime-conf.php
@@ -1,6 +1,6 @@
array (
diff --git a/application/forms/AddShowRepeats.php b/application/forms/AddShowRepeats.php
index 5d9c1af03..7744b35e9 100644
--- a/application/forms/AddShowRepeats.php
+++ b/application/forms/AddShowRepeats.php
@@ -5,6 +5,17 @@ class Application_Form_AddShowRepeats extends Zend_Form_SubForm
public function init()
{
+ //Add type select
+ $this->addElement('select', 'add_show_repeat_type', array(
+ 'required' => true,
+ 'label' => 'Repeat Type:',
+ 'multiOptions' => array(
+ "0" => "weekly",
+ "1" => "bi-weekly",
+ "2" => "monthly"
+ ),
+ ));
+
// Add days checkboxes
$this->addElement(
'multiCheckbox',
@@ -29,16 +40,6 @@ class Application_Form_AddShowRepeats extends Zend_Form_SubForm
'viewScript' => 'form/add-show-checkbox.phtml'
))));
- //Add type select
- $this->addElement('select', 'add_show_repeat_type', array(
- 'required' => true,
- 'label' => 'Repeat Type:',
- 'multiOptions' => array(
- "0" => "weekly",
- "1" => "bi-weekly"
- ),
- ));
-
// Add end date element
$this->addElement('text', 'add_show_end_date', array(
'label' => 'Date End:',
diff --git a/application/models/Shows.php b/application/models/Shows.php
index b0ebbfe29..6d6ee9356 100644
--- a/application/models/Shows.php
+++ b/application/models/Shows.php
@@ -71,37 +71,52 @@ class Show {
$showId = $show->getDbId();
- foreach ($data['add_show_day_check'] as $day) {
+ //don't set day for monthly repeat type, it's invalid.
+ if($data['add_show_repeats'] && $data["add_show_repeat_type"] == 2) {
+ $showDay = new CcShowDays();
+ $showDay->setDbFirstShow($data['add_show_start_date']);
+ $showDay->setDbLastShow($endDate);
+ $showDay->setDbStartTime($data['add_show_start_time']);
+ $showDay->setDbDuration($data['add_show_duration']);
+ $showDay->setDbRepeatType($repeat_type);
+ $showDay->setDbShowId($showId);
+ $showDay->save();
+ }
+ else {
- if($startDow !== $day){
+ foreach ($data['add_show_day_check'] as $day) {
+
+ if($startDow !== $day){
- if($startDow > $day)
- $daysAdd = 6 - $startDow + 1 + $day;
- else
- $daysAdd = $day - $startDow;
+ if($startDow > $day)
+ $daysAdd = 6 - $startDow + 1 + $day;
+ else
+ $daysAdd = $day - $startDow;
- $sql = "SELECT date '{$data['add_show_start_date']}' + INTERVAL '{$daysAdd} day' ";
- $r = $con->query($sql);
- $start = $r->fetchColumn(0);
- }
- else {
- $start = $data['add_show_start_date'];
- }
+ $sql = "SELECT date '{$data['add_show_start_date']}' + INTERVAL '{$daysAdd} day' ";
+ $r = $con->query($sql);
+ $start = $r->fetchColumn(0);
+ }
+ else {
+ $start = $data['add_show_start_date'];
+ }
- if(strtotime($start) < strtotime($endDate) || is_null($endDate)) {
+ if(strtotime($start) < strtotime($endDate) || is_null($endDate)) {
- $showDay = new CcShowDays();
- $showDay->setDbFirstShow($start);
- $showDay->setDbLastShow($endDate);
- $showDay->setDbStartTime($data['add_show_start_time']);
- $showDay->setDbDuration($data['add_show_duration']);
- $showDay->setDbDay($day);
- $showDay->setDbRepeatType($repeat_type);
- $showDay->setDbShowId($showId);
- $showDay->save();
- }
- }
+ $showDay = new CcShowDays();
+ $showDay->setDbFirstShow($start);
+ $showDay->setDbLastShow($endDate);
+ $showDay->setDbStartTime($data['add_show_start_time']);
+ $showDay->setDbDuration($data['add_show_duration']);
+ $showDay->setDbDay($day);
+ $showDay->setDbRepeatType($repeat_type);
+ $showDay->setDbShowId($showId);
+ $showDay->save();
+ }
+ }
+ }
+ //add selected hosts to cc_show_hosts table.
foreach ($data['add_show_hosts'] as $host) {
$showHost = new CcShowHosts();
$showHost->setDbShow($showId);
@@ -158,6 +173,19 @@ class Show {
}
}
+ private static function setNextPop($next_date, $show_id, $day) {
+
+ $nextInfo = explode(" ", $next_date);
+
+ $repeatInfo = CcShowDaysQuery::create()
+ ->filterByDbShowId($show_id)
+ ->filterByDbDay($day)
+ ->findOne();
+
+ $repeatInfo->setDbNextPopDate($nextInfo[0])
+ ->save();
+ }
+
//for a show with repeat_type == 0
private static function populateWeeklyShow($show_id, $next_pop_date, $first_show, $last_show, $start_time, $duration, $day, $end_timestamp) {
global $CC_DBC;
@@ -186,15 +214,7 @@ class Show {
$next_date = $CC_DBC->GetOne($sql);
}
- $nextInfo = explode(" ", $next_date);
-
- $repeatInfo = CcShowDaysQuery::create()
- ->filterByDbShowId($show_id)
- ->filterByDbDay($day)
- ->findOne();
-
- $repeatInfo->setDbNextPopDate($nextInfo[0])
- ->save();
+ Show::setNextPop($next_date, $show_id, $day);
}
//for a show with repeat_type == 1
@@ -225,15 +245,38 @@ class Show {
$next_date = $CC_DBC->GetOne($sql);
}
- $nextInfo = explode(" ", $next_date);
+ Show::setNextPop($next_date, $show_id, $day);
+ }
- $repeatInfo = CcShowDaysQuery::create()
- ->filterByDbShowId($show_id)
- ->filterByDbDay($day)
- ->findOne();
+ //for a show with repeat_type == 2
+ private static function populateMonthlyShow($show_id, $next_pop_date, $first_show, $last_show, $start_time, $duration, $day, $end_timestamp) {
+ global $CC_DBC;
- $repeatInfo->setDbNextPopDate($nextInfo[0])
- ->save();
+ if(isset($next_pop_date)) {
+ $next_date = $next_pop_date." ".$start_time;
+ }
+ else {
+ $next_date = $first_show." ".$start_time;
+ }
+
+ while(strtotime($next_date) < strtotime($end_timestamp) && (strtotime($last_show) > strtotime($next_date) || is_null($last_show))) {
+
+ $start = $next_date;
+
+ $sql = "SELECT timestamp '{$start}' + interval '{$duration}'";
+ $end = $CC_DBC->GetOne($sql);
+
+ $newShow = new CcShowInstances();
+ $newShow->setDbShowId($show_id);
+ $newShow->setDbStarts($start);
+ $newShow->setDbEnds($end);
+ $newShow->save();
+
+ $sql = "SELECT timestamp '{$start}' + interval '1 month'";
+ $next_date = $CC_DBC->GetOne($sql);
+ }
+
+ Show::setNextPop($next_date, $show_id, $day);
}
private static function populateShow($repeat_type, $show_id, $next_pop_date, $first_show, $last_show, $start_time, $duration, $day, $end_timestamp) {
@@ -247,6 +290,9 @@ class Show {
else if($repeat_type == 1) {
Show::populateBiWeeklyShow($show_id, $next_pop_date, $first_show, $last_show, $start_time, $duration, $day, $end_timestamp);
}
+ else if($repeat_type == 2) {
+ Show::populateMonthlyShow($show_id, $next_pop_date, $first_show, $last_show, $start_time, $duration, $day, $end_timestamp);
+ }
}
//used to catch up a newly added show
@@ -459,7 +505,7 @@ class ShowInstance {
$scheduledContentFits = $CC_DBC->GetOne($sql);
if($scheduledContentFits != "t") {
- return "Must removed some scheduled content.";
+ return "Must remove some scheduled content.";
}
}
diff --git a/application/models/airtime/map/CcShowDaysTableMap.php b/application/models/airtime/map/CcShowDaysTableMap.php
index de6a621bf..3a8535635 100644
--- a/application/models/airtime/map/CcShowDaysTableMap.php
+++ b/application/models/airtime/map/CcShowDaysTableMap.php
@@ -43,7 +43,7 @@ class CcShowDaysTableMap extends TableMap {
$this->addColumn('LAST_SHOW', 'DbLastShow', 'DATE', false, null, null);
$this->addColumn('START_TIME', 'DbStartTime', 'TIME', true, null, null);
$this->addColumn('DURATION', 'DbDuration', 'TIME', true, null, null);
- $this->addColumn('DAY', 'DbDay', 'TINYINT', true, null, null);
+ $this->addColumn('DAY', 'DbDay', 'TINYINT', false, null, null);
$this->addColumn('REPEAT_TYPE', 'DbRepeatType', 'TINYINT', true, null, null);
$this->addColumn('NEXT_POP_DATE', 'DbNextPopDate', 'DATE', false, null, null);
$this->addForeignKey('SHOW_ID', 'DbShowId', 'INTEGER', 'cc_show', 'ID', true, null, null);
diff --git a/build/build.properties b/build/build.properties
index 75a77da70..cd25e41b3 100644
--- a/build/build.properties
+++ b/build/build.properties
@@ -1,6 +1,6 @@
#Note: project.home is automatically generated by the propel-install script.
#Any manual changes to this value will be overwritten.
-project.home = /home/naomiaro/dev-campcaster/campcaster
+project.home = /home/naomi/dev-campcaster/campcaster
project.build = ${project.home}/build
#Database driver
diff --git a/build/schema.xml b/build/schema.xml
index 5b0bbd1b4..5757c7996 100644
--- a/build/schema.xml
+++ b/build/schema.xml
@@ -143,7 +143,7 @@
-
+
diff --git a/build/sql/schema.sql b/build/sql/schema.sql
index 26942a8be..a1ed0f9ca 100644
--- a/build/sql/schema.sql
+++ b/build/sql/schema.sql
@@ -206,7 +206,7 @@ CREATE TABLE "cc_show_days"
"last_show" DATE,
"start_time" TIME NOT NULL,
"duration" TIME NOT NULL,
- "day" INT2 NOT NULL,
+ "day" INT2,
"repeat_type" INT2 NOT NULL,
"next_pop_date" DATE,
"show_id" INTEGER NOT NULL,
diff --git a/public/js/airtime/schedule/add-show.js b/public/js/airtime/schedule/add-show.js
index 2a86084c1..e06090265 100644
--- a/public/js/airtime/schedule/add-show.js
+++ b/public/js/airtime/schedule/add-show.js
@@ -70,6 +70,20 @@ function setAddShowEvents() {
$("#schedule-show-when > fieldset:last").toggle();
});
+ $("#add_show_repeat_type").change(function(){
+ var x = $(this).val();
+ if($(this).val() == 2) {
+ $("#add_show_day_check-label, #add_show_day_check-element").hide();
+ }
+ else {
+ $("#add_show_day_check-label, #add_show_day_check-element").show();
+ }
+ });
+
+ $("#add_show_no_end").click(function(){
+ $("#add_show_end_date").toggle();
+ });
+
start = $("#add_show_start_date");
end = $("#add_show_end_date");