can add a show repeating or non repeating. need a better dialog though with more validation. Also added additional sql files to build directory.
This commit is contained in:
parent
184ee30775
commit
ac27a2f79c
20 changed files with 267 additions and 29 deletions
|
@ -53,6 +53,7 @@
|
|||
<actionMethod actionName="index"/>
|
||||
<actionMethod actionName="eventFeed"/>
|
||||
<actionMethod actionName="addShowDialog"/>
|
||||
<actionMethod actionName="addShow"/>
|
||||
</controllerFile>
|
||||
</controllersDirectory>
|
||||
<formsDirectory>
|
||||
|
@ -166,6 +167,9 @@
|
|||
<viewControllerScriptsDirectory forControllerName="Schedule">
|
||||
<viewScriptFile forActionName="addShowDialog"/>
|
||||
</viewControllerScriptsDirectory>
|
||||
<viewControllerScriptsDirectory forControllerName="Schedule">
|
||||
<viewScriptFile forActionName="addShow"/>
|
||||
</viewControllerScriptsDirectory>
|
||||
</viewScriptsDirectory>
|
||||
<viewHelpersDirectory/>
|
||||
<viewFiltersDirectory enabled="false"/>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
// This file generated by Propel 1.5.2 convert-conf target
|
||||
// from XML runtime conf file /home/naomiaro/campcaster-refactor/campcaster/build/runtime-conf.xml
|
||||
// from XML runtime conf file /home/naomiaro/dev-campcaster/campcaster/build/runtime-conf.xml
|
||||
$conf = array (
|
||||
'datasources' =>
|
||||
array (
|
||||
|
|
|
@ -13,6 +13,7 @@ class ScheduleController extends Zend_Controller_Action
|
|||
$ajaxContext = $this->_helper->getHelper('AjaxContext');
|
||||
$ajaxContext->addActionContext('event-feed', 'json')
|
||||
->addActionContext('add-show-dialog', 'json')
|
||||
->addActionContext('add-show', 'json')
|
||||
->initContext();
|
||||
}
|
||||
|
||||
|
@ -44,6 +45,33 @@ class ScheduleController extends Zend_Controller_Action
|
|||
$this->view->hosts = $user->getHosts();
|
||||
}
|
||||
|
||||
public function addShowAction()
|
||||
{
|
||||
//name, description, hosts, allDay, repeats,
|
||||
//start_time, duration, start_date, end_date, dofw
|
||||
|
||||
$name = $this->_getParam('name', 'Default Name');
|
||||
$description = $this->_getParam('description', '');
|
||||
$hosts = $this->_getParam('hosts');
|
||||
$allDay = $this->_getParam('all_day', false);
|
||||
$repeats = $this->_getParam('repeats', false);
|
||||
$startTime = $this->_getParam('start_time');
|
||||
$duration = $this->_getParam('duration');
|
||||
$startDate = $this->_getParam('start_date');
|
||||
$endDate = $this->_getParam('end_date', null);
|
||||
$dofw = $this->_getParam('dofw');
|
||||
|
||||
if($repeats === false)
|
||||
$endDate = $startDate;
|
||||
|
||||
$repeats = $repeats ? 1 : 0;
|
||||
|
||||
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
|
||||
|
||||
$show = new Show($userInfo->type);
|
||||
$show->addShow($name, $startDate, $endDate, $startTime, $duration, $repeats, $dofw, $description);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@ -51,3 +79,5 @@ class ScheduleController extends Zend_Controller_Action
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -35,12 +35,51 @@ class Show {
|
|||
return $event;
|
||||
}
|
||||
|
||||
public function addShow() {
|
||||
public function addShow($name, $startDate, $endDate, $startTime, $duration, $repeats, $days, $description) {
|
||||
|
||||
$sql = 'INSERT INTO cc_show
|
||||
("name", "first_show", "last_show", "start_time", "end_time",
|
||||
"repeats", "day", "description", "show_id")
|
||||
VALUES ()';
|
||||
$con = Propel::getConnection("campcaster");
|
||||
|
||||
$sql = "SELECT time '{$startTime}' + INTERVAL '{$duration} hour' ";
|
||||
$r = $con->query($sql);
|
||||
$endTime = $r->fetchColumn(0);
|
||||
|
||||
$sql = "SELECT nextval('schedule_group_id_seq')";
|
||||
$r = $con->query($sql);
|
||||
$showId = $r->fetchColumn(0);
|
||||
|
||||
$sql = "SELECT EXTRACT(DOW FROM TIMESTAMP '{$startDate} {$startTime}')";
|
||||
$r = $con->query($sql);
|
||||
$startDow = $r->fetchColumn(0);
|
||||
|
||||
foreach ($days as $day) {
|
||||
|
||||
if($startDow !== $day){
|
||||
|
||||
if($startDow > $day)
|
||||
$daysAdd = 6 - $startDow + 1 + $day;
|
||||
else
|
||||
$daysAdd = $day - $startDow;
|
||||
|
||||
$sql = "SELECT date '{$startDate}' + INTERVAL '{$daysAdd} day' ";
|
||||
$r = $con->query($sql);
|
||||
$start = $r->fetchColumn(0);
|
||||
}
|
||||
else {
|
||||
$start = $startDate;
|
||||
}
|
||||
|
||||
$show = new CcShow();
|
||||
$show->setDbName($name);
|
||||
$show->setDbFirstShow($start);
|
||||
$show->setDbLastShow($endDate);
|
||||
$show->setDbStartTime($startTime);
|
||||
$show->setDbEndTime($endTime);
|
||||
$show->setDbRepeats($repeats);
|
||||
$show->setDbDay($day);
|
||||
$show->setDbDescription($description);
|
||||
$show->setDbShowId($showId);
|
||||
$show->save();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -47,6 +47,7 @@ class CcShowTableMap extends TableMap {
|
|||
$this->addColumn('REPEATS', 'DbRepeats', 'TINYINT', true, null, null);
|
||||
$this->addColumn('DAY', 'DbDay', 'TINYINT', true, null, null);
|
||||
$this->addColumn('DESCRIPTION', 'DbDescription', 'VARCHAR', false, 512, null);
|
||||
$this->addColumn('SHOW_ID', 'DbShowId', 'INTEGER', true, null, null);
|
||||
// validators
|
||||
} // initialize()
|
||||
|
||||
|
|
|
@ -35,7 +35,8 @@ class CcSubjsTableMap extends TableMap {
|
|||
$this->setPhpName('CcSubjs');
|
||||
$this->setClassname('CcSubjs');
|
||||
$this->setPackage('campcaster');
|
||||
$this->setUseIdGenerator(false);
|
||||
$this->setUseIdGenerator(true);
|
||||
$this->setPrimaryKeyMethodInfo('cc_subjs_id_seq');
|
||||
// columns
|
||||
$this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
|
||||
$this->addColumn('LOGIN', 'Login', 'VARCHAR', true, 255, '');
|
||||
|
|
|
@ -79,6 +79,12 @@ abstract class BaseCcShow extends BaseObject implements Persistent
|
|||
*/
|
||||
protected $description;
|
||||
|
||||
/**
|
||||
* The value for the show_id field.
|
||||
* @var int
|
||||
*/
|
||||
protected $show_id;
|
||||
|
||||
/**
|
||||
* Flag to prevent endless save loop, if this object is referenced
|
||||
* by another object which falls in this transaction.
|
||||
|
@ -296,6 +302,16 @@ abstract class BaseCcShow extends BaseObject implements Persistent
|
|||
return $this->description;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the [show_id] column value.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getDbShowId()
|
||||
{
|
||||
return $this->show_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value of [id] column.
|
||||
*
|
||||
|
@ -592,6 +608,26 @@ abstract class BaseCcShow extends BaseObject implements Persistent
|
|||
return $this;
|
||||
} // setDbDescription()
|
||||
|
||||
/**
|
||||
* Set the value of [show_id] column.
|
||||
*
|
||||
* @param int $v new value
|
||||
* @return CcShow The current object (for fluent API support)
|
||||
*/
|
||||
public function setDbShowId($v)
|
||||
{
|
||||
if ($v !== null) {
|
||||
$v = (int) $v;
|
||||
}
|
||||
|
||||
if ($this->show_id !== $v) {
|
||||
$this->show_id = $v;
|
||||
$this->modifiedColumns[] = CcShowPeer::SHOW_ID;
|
||||
}
|
||||
|
||||
return $this;
|
||||
} // setDbShowId()
|
||||
|
||||
/**
|
||||
* Indicates whether the columns in this object are only set to default values.
|
||||
*
|
||||
|
@ -637,6 +673,7 @@ abstract class BaseCcShow extends BaseObject implements Persistent
|
|||
$this->repeats = ($row[$startcol + 6] !== null) ? (int) $row[$startcol + 6] : null;
|
||||
$this->day = ($row[$startcol + 7] !== null) ? (int) $row[$startcol + 7] : null;
|
||||
$this->description = ($row[$startcol + 8] !== null) ? (string) $row[$startcol + 8] : null;
|
||||
$this->show_id = ($row[$startcol + 9] !== null) ? (int) $row[$startcol + 9] : null;
|
||||
$this->resetModified();
|
||||
|
||||
$this->setNew(false);
|
||||
|
@ -645,7 +682,7 @@ abstract class BaseCcShow extends BaseObject implements Persistent
|
|||
$this->ensureConsistency();
|
||||
}
|
||||
|
||||
return $startcol + 9; // 9 = CcShowPeer::NUM_COLUMNS - CcShowPeer::NUM_LAZY_LOAD_COLUMNS).
|
||||
return $startcol + 10; // 10 = CcShowPeer::NUM_COLUMNS - CcShowPeer::NUM_LAZY_LOAD_COLUMNS).
|
||||
|
||||
} catch (Exception $e) {
|
||||
throw new PropelException("Error populating CcShow object", $e);
|
||||
|
@ -971,6 +1008,9 @@ abstract class BaseCcShow extends BaseObject implements Persistent
|
|||
case 8:
|
||||
return $this->getDbDescription();
|
||||
break;
|
||||
case 9:
|
||||
return $this->getDbShowId();
|
||||
break;
|
||||
default:
|
||||
return null;
|
||||
break;
|
||||
|
@ -1003,6 +1043,7 @@ abstract class BaseCcShow extends BaseObject implements Persistent
|
|||
$keys[6] => $this->getDbRepeats(),
|
||||
$keys[7] => $this->getDbDay(),
|
||||
$keys[8] => $this->getDbDescription(),
|
||||
$keys[9] => $this->getDbShowId(),
|
||||
);
|
||||
return $result;
|
||||
}
|
||||
|
@ -1061,6 +1102,9 @@ abstract class BaseCcShow extends BaseObject implements Persistent
|
|||
case 8:
|
||||
$this->setDbDescription($value);
|
||||
break;
|
||||
case 9:
|
||||
$this->setDbShowId($value);
|
||||
break;
|
||||
} // switch()
|
||||
}
|
||||
|
||||
|
@ -1094,6 +1138,7 @@ abstract class BaseCcShow extends BaseObject implements Persistent
|
|||
if (array_key_exists($keys[6], $arr)) $this->setDbRepeats($arr[$keys[6]]);
|
||||
if (array_key_exists($keys[7], $arr)) $this->setDbDay($arr[$keys[7]]);
|
||||
if (array_key_exists($keys[8], $arr)) $this->setDbDescription($arr[$keys[8]]);
|
||||
if (array_key_exists($keys[9], $arr)) $this->setDbShowId($arr[$keys[9]]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1114,6 +1159,7 @@ abstract class BaseCcShow extends BaseObject implements Persistent
|
|||
if ($this->isColumnModified(CcShowPeer::REPEATS)) $criteria->add(CcShowPeer::REPEATS, $this->repeats);
|
||||
if ($this->isColumnModified(CcShowPeer::DAY)) $criteria->add(CcShowPeer::DAY, $this->day);
|
||||
if ($this->isColumnModified(CcShowPeer::DESCRIPTION)) $criteria->add(CcShowPeer::DESCRIPTION, $this->description);
|
||||
if ($this->isColumnModified(CcShowPeer::SHOW_ID)) $criteria->add(CcShowPeer::SHOW_ID, $this->show_id);
|
||||
|
||||
return $criteria;
|
||||
}
|
||||
|
@ -1183,6 +1229,7 @@ abstract class BaseCcShow extends BaseObject implements Persistent
|
|||
$copyObj->setDbRepeats($this->repeats);
|
||||
$copyObj->setDbDay($this->day);
|
||||
$copyObj->setDbDescription($this->description);
|
||||
$copyObj->setDbShowId($this->show_id);
|
||||
|
||||
$copyObj->setNew(true);
|
||||
$copyObj->setDbId(NULL); // this is a auto-increment column, so set to default value
|
||||
|
@ -1240,6 +1287,7 @@ abstract class BaseCcShow extends BaseObject implements Persistent
|
|||
$this->repeats = null;
|
||||
$this->day = null;
|
||||
$this->description = null;
|
||||
$this->show_id = null;
|
||||
$this->alreadyInSave = false;
|
||||
$this->alreadyInValidation = false;
|
||||
$this->clearAllReferences();
|
||||
|
|
|
@ -26,7 +26,7 @@ abstract class BaseCcShowPeer {
|
|||
const TM_CLASS = 'CcShowTableMap';
|
||||
|
||||
/** The total number of columns. */
|
||||
const NUM_COLUMNS = 9;
|
||||
const NUM_COLUMNS = 10;
|
||||
|
||||
/** The number of lazy-loaded columns. */
|
||||
const NUM_LAZY_LOAD_COLUMNS = 0;
|
||||
|
@ -58,6 +58,9 @@ abstract class BaseCcShowPeer {
|
|||
/** the column name for the DESCRIPTION field */
|
||||
const DESCRIPTION = 'cc_show.DESCRIPTION';
|
||||
|
||||
/** the column name for the SHOW_ID field */
|
||||
const SHOW_ID = 'cc_show.SHOW_ID';
|
||||
|
||||
/**
|
||||
* An identiy map to hold any loaded instances of CcShow objects.
|
||||
* This must be public so that other peer classes can access this when hydrating from JOIN
|
||||
|
@ -74,12 +77,12 @@ abstract class BaseCcShowPeer {
|
|||
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
|
||||
*/
|
||||
private static $fieldNames = array (
|
||||
BasePeer::TYPE_PHPNAME => array ('DbId', 'DbName', 'DbFirstShow', 'DbLastShow', 'DbStartTime', 'DbEndTime', 'DbRepeats', 'DbDay', 'DbDescription', ),
|
||||
BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbName', 'dbFirstShow', 'dbLastShow', 'dbStartTime', 'dbEndTime', 'dbRepeats', 'dbDay', 'dbDescription', ),
|
||||
BasePeer::TYPE_COLNAME => array (self::ID, self::NAME, self::FIRST_SHOW, self::LAST_SHOW, self::START_TIME, self::END_TIME, self::REPEATS, self::DAY, self::DESCRIPTION, ),
|
||||
BasePeer::TYPE_RAW_COLNAME => array ('ID', 'NAME', 'FIRST_SHOW', 'LAST_SHOW', 'START_TIME', 'END_TIME', 'REPEATS', 'DAY', 'DESCRIPTION', ),
|
||||
BasePeer::TYPE_FIELDNAME => array ('id', 'name', 'first_show', 'last_show', 'start_time', 'end_time', 'repeats', 'day', 'description', ),
|
||||
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, )
|
||||
BasePeer::TYPE_PHPNAME => array ('DbId', 'DbName', 'DbFirstShow', 'DbLastShow', 'DbStartTime', 'DbEndTime', 'DbRepeats', 'DbDay', 'DbDescription', 'DbShowId', ),
|
||||
BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbName', 'dbFirstShow', 'dbLastShow', 'dbStartTime', 'dbEndTime', 'dbRepeats', 'dbDay', 'dbDescription', 'dbShowId', ),
|
||||
BasePeer::TYPE_COLNAME => array (self::ID, self::NAME, self::FIRST_SHOW, self::LAST_SHOW, self::START_TIME, self::END_TIME, self::REPEATS, self::DAY, self::DESCRIPTION, self::SHOW_ID, ),
|
||||
BasePeer::TYPE_RAW_COLNAME => array ('ID', 'NAME', 'FIRST_SHOW', 'LAST_SHOW', 'START_TIME', 'END_TIME', 'REPEATS', 'DAY', 'DESCRIPTION', 'SHOW_ID', ),
|
||||
BasePeer::TYPE_FIELDNAME => array ('id', 'name', 'first_show', 'last_show', 'start_time', 'end_time', 'repeats', 'day', 'description', 'show_id', ),
|
||||
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, )
|
||||
);
|
||||
|
||||
/**
|
||||
|
@ -89,12 +92,12 @@ abstract class BaseCcShowPeer {
|
|||
* e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
|
||||
*/
|
||||
private static $fieldKeys = array (
|
||||
BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbName' => 1, 'DbFirstShow' => 2, 'DbLastShow' => 3, 'DbStartTime' => 4, 'DbEndTime' => 5, 'DbRepeats' => 6, 'DbDay' => 7, 'DbDescription' => 8, ),
|
||||
BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbName' => 1, 'dbFirstShow' => 2, 'dbLastShow' => 3, 'dbStartTime' => 4, 'dbEndTime' => 5, 'dbRepeats' => 6, 'dbDay' => 7, 'dbDescription' => 8, ),
|
||||
BasePeer::TYPE_COLNAME => array (self::ID => 0, self::NAME => 1, self::FIRST_SHOW => 2, self::LAST_SHOW => 3, self::START_TIME => 4, self::END_TIME => 5, self::REPEATS => 6, self::DAY => 7, self::DESCRIPTION => 8, ),
|
||||
BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'NAME' => 1, 'FIRST_SHOW' => 2, 'LAST_SHOW' => 3, 'START_TIME' => 4, 'END_TIME' => 5, 'REPEATS' => 6, 'DAY' => 7, 'DESCRIPTION' => 8, ),
|
||||
BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'name' => 1, 'first_show' => 2, 'last_show' => 3, 'start_time' => 4, 'end_time' => 5, 'repeats' => 6, 'day' => 7, 'description' => 8, ),
|
||||
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, )
|
||||
BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbName' => 1, 'DbFirstShow' => 2, 'DbLastShow' => 3, 'DbStartTime' => 4, 'DbEndTime' => 5, 'DbRepeats' => 6, 'DbDay' => 7, 'DbDescription' => 8, 'DbShowId' => 9, ),
|
||||
BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbName' => 1, 'dbFirstShow' => 2, 'dbLastShow' => 3, 'dbStartTime' => 4, 'dbEndTime' => 5, 'dbRepeats' => 6, 'dbDay' => 7, 'dbDescription' => 8, 'dbShowId' => 9, ),
|
||||
BasePeer::TYPE_COLNAME => array (self::ID => 0, self::NAME => 1, self::FIRST_SHOW => 2, self::LAST_SHOW => 3, self::START_TIME => 4, self::END_TIME => 5, self::REPEATS => 6, self::DAY => 7, self::DESCRIPTION => 8, self::SHOW_ID => 9, ),
|
||||
BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'NAME' => 1, 'FIRST_SHOW' => 2, 'LAST_SHOW' => 3, 'START_TIME' => 4, 'END_TIME' => 5, 'REPEATS' => 6, 'DAY' => 7, 'DESCRIPTION' => 8, 'SHOW_ID' => 9, ),
|
||||
BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'name' => 1, 'first_show' => 2, 'last_show' => 3, 'start_time' => 4, 'end_time' => 5, 'repeats' => 6, 'day' => 7, 'description' => 8, 'show_id' => 9, ),
|
||||
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, )
|
||||
);
|
||||
|
||||
/**
|
||||
|
@ -175,6 +178,7 @@ abstract class BaseCcShowPeer {
|
|||
$criteria->addSelectColumn(CcShowPeer::REPEATS);
|
||||
$criteria->addSelectColumn(CcShowPeer::DAY);
|
||||
$criteria->addSelectColumn(CcShowPeer::DESCRIPTION);
|
||||
$criteria->addSelectColumn(CcShowPeer::SHOW_ID);
|
||||
} else {
|
||||
$criteria->addSelectColumn($alias . '.ID');
|
||||
$criteria->addSelectColumn($alias . '.NAME');
|
||||
|
@ -185,6 +189,7 @@ abstract class BaseCcShowPeer {
|
|||
$criteria->addSelectColumn($alias . '.REPEATS');
|
||||
$criteria->addSelectColumn($alias . '.DAY');
|
||||
$criteria->addSelectColumn($alias . '.DESCRIPTION');
|
||||
$criteria->addSelectColumn($alias . '.SHOW_ID');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
* @method CcShowQuery orderByDbRepeats($order = Criteria::ASC) Order by the repeats column
|
||||
* @method CcShowQuery orderByDbDay($order = Criteria::ASC) Order by the day column
|
||||
* @method CcShowQuery orderByDbDescription($order = Criteria::ASC) Order by the description column
|
||||
* @method CcShowQuery orderByDbShowId($order = Criteria::ASC) Order by the show_id column
|
||||
*
|
||||
* @method CcShowQuery groupByDbId() Group by the id column
|
||||
* @method CcShowQuery groupByDbName() Group by the name column
|
||||
|
@ -25,6 +26,7 @@
|
|||
* @method CcShowQuery groupByDbRepeats() Group by the repeats column
|
||||
* @method CcShowQuery groupByDbDay() Group by the day column
|
||||
* @method CcShowQuery groupByDbDescription() Group by the description column
|
||||
* @method CcShowQuery groupByDbShowId() Group by the show_id column
|
||||
*
|
||||
* @method CcShowQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
|
||||
* @method CcShowQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
|
||||
|
@ -42,6 +44,7 @@
|
|||
* @method CcShow findOneByDbRepeats(int $repeats) Return the first CcShow filtered by the repeats column
|
||||
* @method CcShow findOneByDbDay(int $day) Return the first CcShow filtered by the day column
|
||||
* @method CcShow findOneByDbDescription(string $description) Return the first CcShow filtered by the description column
|
||||
* @method CcShow findOneByDbShowId(int $show_id) Return the first CcShow filtered by the show_id column
|
||||
*
|
||||
* @method array findByDbId(int $id) Return CcShow objects filtered by the id column
|
||||
* @method array findByDbName(string $name) Return CcShow objects filtered by the name column
|
||||
|
@ -52,6 +55,7 @@
|
|||
* @method array findByDbRepeats(int $repeats) Return CcShow objects filtered by the repeats column
|
||||
* @method array findByDbDay(int $day) Return CcShow objects filtered by the day column
|
||||
* @method array findByDbDescription(string $description) Return CcShow objects filtered by the description column
|
||||
* @method array findByDbShowId(int $show_id) Return CcShow objects filtered by the show_id column
|
||||
*
|
||||
* @package propel.generator.campcaster.om
|
||||
*/
|
||||
|
@ -408,6 +412,37 @@ abstract class BaseCcShowQuery extends ModelCriteria
|
|||
return $this->addUsingAlias(CcShowPeer::DESCRIPTION, $dbDescription, $comparison);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query on the show_id column
|
||||
*
|
||||
* @param int|array $dbShowId The value to use as filter.
|
||||
* Accepts an associative array('min' => $minValue, 'max' => $maxValue)
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return CcShowQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByDbShowId($dbShowId = null, $comparison = null)
|
||||
{
|
||||
if (is_array($dbShowId)) {
|
||||
$useMinMax = false;
|
||||
if (isset($dbShowId['min'])) {
|
||||
$this->addUsingAlias(CcShowPeer::SHOW_ID, $dbShowId['min'], Criteria::GREATER_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if (isset($dbShowId['max'])) {
|
||||
$this->addUsingAlias(CcShowPeer::SHOW_ID, $dbShowId['max'], Criteria::LESS_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if ($useMinMax) {
|
||||
return $this;
|
||||
}
|
||||
if (null === $comparison) {
|
||||
$comparison = Criteria::IN;
|
||||
}
|
||||
}
|
||||
return $this->addUsingAlias(CcShowPeer::SHOW_ID, $dbShowId, $comparison);
|
||||
}
|
||||
|
||||
/**
|
||||
* Exclude object from result
|
||||
*
|
||||
|
|
|
@ -699,13 +699,21 @@ abstract class BaseCcSubjs extends BaseObject implements Persistent
|
|||
if (!$this->alreadyInSave) {
|
||||
$this->alreadyInSave = true;
|
||||
|
||||
if ($this->isNew() ) {
|
||||
$this->modifiedColumns[] = CcSubjsPeer::ID;
|
||||
}
|
||||
|
||||
// If this object has been modified, then save it to the database.
|
||||
if ($this->isModified()) {
|
||||
if ($this->isNew()) {
|
||||
$criteria = $this->buildCriteria();
|
||||
if ($criteria->keyContainsValue(CcSubjsPeer::ID) ) {
|
||||
throw new PropelException('Cannot insert a value for auto-increment primary key ('.CcSubjsPeer::ID.')');
|
||||
}
|
||||
|
||||
$pk = BasePeer::doInsert($criteria, $con);
|
||||
$affectedRows = 1;
|
||||
$this->setId($pk); //[IMV] update autoincrement primary key
|
||||
$this->setNew(false);
|
||||
} else {
|
||||
$affectedRows = CcSubjsPeer::doUpdate($this, $con);
|
||||
|
@ -1127,7 +1135,6 @@ abstract class BaseCcSubjs extends BaseObject implements Persistent
|
|||
*/
|
||||
public function copyInto($copyObj, $deepCopy = false)
|
||||
{
|
||||
$copyObj->setId($this->id);
|
||||
$copyObj->setLogin($this->login);
|
||||
$copyObj->setPass($this->pass);
|
||||
$copyObj->setType($this->type);
|
||||
|
@ -1180,6 +1187,7 @@ abstract class BaseCcSubjs extends BaseObject implements Persistent
|
|||
|
||||
|
||||
$copyObj->setNew(true);
|
||||
$copyObj->setId(NULL); // this is a auto-increment column, so set to default value
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -529,6 +529,10 @@ abstract class BaseCcSubjsPeer {
|
|||
$criteria = $values->buildCriteria(); // build Criteria from CcSubjs object
|
||||
}
|
||||
|
||||
if ($criteria->containsKey(CcSubjsPeer::ID) && $criteria->keyContainsValue(CcSubjsPeer::ID) ) {
|
||||
throw new PropelException('Cannot insert a value for auto-increment primary key ('.CcSubjsPeer::ID.')');
|
||||
}
|
||||
|
||||
|
||||
// Set the correct dbName
|
||||
$criteria->setDbName(self::DATABASE_NAME);
|
||||
|
|
1
application/views/scripts/schedule/add-show.phtml
Normal file
1
application/views/scripts/schedule/add-show.phtml
Normal file
|
@ -0,0 +1 @@
|
|||
<br /><br /><center>View script for controller <b>Schedule</b> and script/action name <b>addShow</b></center>
|
|
@ -1,4 +1,4 @@
|
|||
project.home = /home/naomiaro/campcaster-refactor/campcaster
|
||||
project.home = /home/naomiaro/dev-campcaster/campcaster
|
||||
project.build = ${project.home}/build
|
||||
|
||||
#Database driver
|
||||
|
|
1
build/sql/defaultdata.sql
Normal file
1
build/sql/defaultdata.sql
Normal file
|
@ -0,0 +1 @@
|
|||
INSERT INTO cc_subjs ("login", "type", "pass") VALUES ('admin', 'A', md5('admin'));
|
|
@ -169,6 +169,7 @@ CREATE TABLE "cc_show"
|
|||
"repeats" INT2 NOT NULL,
|
||||
"day" INT2 NOT NULL,
|
||||
"description" VARCHAR(512),
|
||||
"show_id" INTEGER NOT NULL,
|
||||
PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
|
@ -331,7 +332,7 @@ DROP TABLE "cc_subjs" CASCADE;
|
|||
|
||||
CREATE TABLE "cc_subjs"
|
||||
(
|
||||
"id" INTEGER NOT NULL,
|
||||
"id" serial NOT NULL,
|
||||
"login" VARCHAR(255) default '' NOT NULL,
|
||||
"pass" VARCHAR(255) default '' NOT NULL,
|
||||
"type" CHAR(1) default 'U' NOT NULL,
|
||||
|
|
7
build/sql/sequences.sql
Normal file
7
build/sql/sequences.sql
Normal file
|
@ -0,0 +1,7 @@
|
|||
DROP SEQUENCE schedule_group_id_seq CASCADE;
|
||||
|
||||
CREATE SEQUENCE schedule_group_id_seq;
|
||||
|
||||
DROP SEQUENCE show_group_id_seq CASCADE;
|
||||
|
||||
CREATE SEQUENCE show_group_id_seq;
|
|
@ -1,2 +1,6 @@
|
|||
# Sqlfile -> Database map
|
||||
schema.sql=campcaster
|
||||
sequences.sql=campcaster
|
||||
views.sql=campcaster
|
||||
triggers.sql=campcaster
|
||||
defaultdata.sql=campcaster
|
||||
|
|
23
build/sql/triggers.sql
Normal file
23
build/sql/triggers.sql
Normal file
|
@ -0,0 +1,23 @@
|
|||
----------------------------------------------------------------------------------
|
||||
--calculate_position()
|
||||
----------------------------------------------------------------------------------
|
||||
DROP FUNCTION calculate_position() CASCADE;
|
||||
|
||||
CREATE FUNCTION calculate_position() RETURNS trigger AS
|
||||
'
|
||||
BEGIN
|
||||
IF(TG_OP=''INSERT'') THEN
|
||||
UPDATE cc_playlistcontents SET position = (position + 1)
|
||||
WHERE (playlist_id = new.playlist_id AND position >= new.position AND id != new.id);
|
||||
END IF;
|
||||
IF(TG_OP=''DELETE'') THEN
|
||||
UPDATE cc_playlistcontents SET position = (position - 1)
|
||||
WHERE (playlist_id = old.playlist_id AND position > old.position);
|
||||
END IF;
|
||||
RETURN NULL;
|
||||
END;
|
||||
'
|
||||
LANGUAGE 'plpgsql';
|
||||
|
||||
CREATE TRIGGER calculate_position AFTER INSERT OR DELETE ON cc_playlistcontents
|
||||
FOR EACH ROW EXECUTE PROCEDURE calculate_position();
|
11
build/sql/views.sql
Normal file
11
build/sql/views.sql
Normal file
|
@ -0,0 +1,11 @@
|
|||
-------------------------------------------------------
|
||||
---cc_playlisttimes
|
||||
-------------------------------------------------------
|
||||
|
||||
CREATE VIEW cc_playlisttimes AS
|
||||
SELECT pl.id, COALESCE(t.length, '00:00:00'::time without time zone) AS length
|
||||
FROM cc_playlist pl
|
||||
LEFT JOIN ( SELECT cc_playlistcontents.playlist_id AS id,
|
||||
sum(cc_playlistcontents.cliplength::interval)::time without time zone AS length
|
||||
FROM cc_playlistcontents
|
||||
GROUP BY cc_playlistcontents.playlist_id) t ON pl.id = t.id;
|
|
@ -60,13 +60,13 @@ function createDateInput(name, label) {
|
|||
}
|
||||
|
||||
function submitShow() {
|
||||
var name, description, hosts, allDay, repeats,
|
||||
var name, description, hosts, all_day, repeats,
|
||||
start_time, duration, start_date, end_date, dofw;
|
||||
|
||||
name = $("#schedule_dialog_name").val();
|
||||
description = $("#schedule_dialog_description").val();
|
||||
hosts = $("#schedule_dialog_hosts").val();
|
||||
allDay = $("#schedule_dialog_all_day").attr("checked");
|
||||
all_day = $("#schedule_dialog_all_day").attr("checked");
|
||||
repeats = $("#schedule_dialog_repeats").attr("checked");
|
||||
start_time = $("#schedule_dialog_start_time").val();
|
||||
duration = $("#schedule_dialog_duration").val();
|
||||
|
@ -76,6 +76,21 @@ function submitShow() {
|
|||
return $(this).val();
|
||||
}).get();
|
||||
|
||||
if(dofw.length === 0) {
|
||||
var time, date;
|
||||
|
||||
time = start_date.split("-");
|
||||
date = new Date(time[0], time[1] - 1, time[2]);
|
||||
dofw.push(date.getDay());
|
||||
}
|
||||
|
||||
$.post("/Schedule/add-show/format/json",
|
||||
{ name: name, description: description, hosts: hosts, all_day: all_day, repeats: repeats,
|
||||
start_time: start_time, duration: duration, start_date: start_date, end_date: end_date, dofw: dofw },
|
||||
function(data){
|
||||
$('#schedule_calendar').fullCalendar( 'refetchEvents' );
|
||||
});
|
||||
|
||||
$(this).remove();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue