protected $timesChx = array();
protected $timesBvi = array();
protected $dates = array();
-
+
/**
* For the Ajax call to add a departure set create the html and exit
*/
'html' => $tpl->bufferedOutputObject($page)
);
}
-
+
/**
* addSchedule
- *
+ *
* Creates a new empty schedule record
* return the new id
- *
+ *
* @param type $registry
- * @return type
+ * @return type
*/
public function addSchedule($registry)
{
Toolkit_Common::handleError($e);
}
}
-
+
/**
* add times to the timesBvi array
- *
+ *
* @param type $times array of times
*/
protected function addTimesBvi($times)
}
}
}
-
+
/**
* add times to the timesChx array
- *
+ *
* @param type $times array of times
*/
protected function addTimesChx($times)
}
}
}
-
+
/**
* get the departure times for dock 1 for a departureId
*
Toolkit_Common::handleError($e);
}
}
-
+
/**
* get the departure dates for a departureId
*
Toolkit_Common::handleError($e);
}
}
-
+
/**
* get the departure times for dock 2 for a departureId
*
Toolkit_Common::handleError($e);
}
}
-
+
/**
* get all departures for a schedule
- *
+ *
* @param type $registry Registry Obj
* @param type $scheduleId schedule id
* @return type array of data
Toolkit_Common::handleError($e);
}
}
-
+
public function getDeparturesForSchedules($registry, $scheduleId)
{
return $this->getDepartures($registry, $scheduleId);
}
-
+
/**
* Get the schedule name from and scheduleId
- *
+ *
* @param PDO $dbh PDO obj
* @param type $scheduleId id for schedule record
* @return type string name of schedule
Toolkit_Common::handleError($e);
}
}
-
+
/**
* removeDeparturesById
- *
+ *
* Removes the departures record by id
- *
+ *
* @param PDO $dbh PDO object
* @param type $departureId id to delete
- * @return type
+ * @return type
*/
public function removeDeparturesById(PDO $dbh, $departureId)
{
return false;
}
}
-
+
/**
* removeDepartureDatesById
- *
+ *
* Removes all the departure dates record by id
- *
+ *
* @param PDO $dbh PDO object
* @param type $departureId id to delete
- * @return type
+ * @return type
*/
public function removeDepartureDatesById(PDO $dbh, $departureId)
{
return false;
}
}
-
+
/**
* removeDepartureTimesById
- *
+ *
* Removes all the departure times record by id
- *
+ *
* @param PDO $dbh PDO object
* @param type $departureId id to delete
- * @return type
+ * @return type
*/
public function removeDepartureTimesById(PDO $dbh, $departureId)
{
return false;
}
}
-
+
+
+ /**
+ * sort_by_parent
+ *
+ * @param mixed $data
+ * @access public
+ * @return void
+ */
+ private function _sort_by_parent($data)
+ {
+ if (!is_array($data)) {
+ return false;
+ }
+ foreach($data as $key=>$value) {
+ $data_new[$value["parent"]][$value["id"]] = $value;
+ }
+ return $data_new;
+ }
+
+ /**
+ * convertParent
+ *
+ * @param mixed $threads
+ * @param mixed $thread
+ * @access public
+ * @return void
+ */
+ private function _convertParent($threads, $thread)
+ {
+ static $select,$count;
+ if (!$count) {
+ $count = 0;
+ }
+ $bgcolor[] = '#ccc';
+ $bgcolor[] = '#ddd';
+ if (is_array($thread)) {
+ foreach($thread as $parent=>$value) {
+ $color = $bgcolor[$count];
+ $select[$value["id"]]["color"] = $color;
+ $select[$value["id"]]["category"] = $value["navigation_name"];
+ $select[$value["id"]]["count"] = $count;
+
+ if (isset($threads[$parent])) {
+ $count++;
+ $this->_convertParent($threads, $threads[$parent]);
+ }
+ }
+ }
+ $count--;
+ return $select;
+ }
+
+ private function _parentSelect($catid = null)
+ {
+ // select catid portion
+ $qs = "
+ SELECT id,navigation_name,parent
+ FROM toolbox.pages
+ ORDER BY parent,pos";
+
+ $data = $this->dbh->query($qs)->fetchAll(PDO::FETCH_ASSOC);
+ $data1 = $this->_sort_by_parent($data);
+ $select = '<select name="page"><option value=""></option>';
+ $parts = $this->_convertParent($data1, $data1[0]);
+ if (is_array($parts)) {
+ foreach($parts as $key => $value) {
+ if (isset($backcount) && $value['count'] <= $backcount) {
+ unset($backcount);
+ }
+ if ($key == $id && $sel_name = "parent") {
+ $backcount = $value['count'];
+ }
+
+ if ( (!isset($backcount)
+ && ($value['count'] < (self::LEVELS_DEEP - 1))
+ || $sel_name == "catid[]")
+ ) {
+ $bkg = $value["color"];
+ $indent = (int)$value["count"] * 10;
+ $cc = (int)$value["count"] * 2;
+ $paddman = ($cc > 0) ? str_repeat(" ", $cc) : '';
+ $select .= '<option value="' . $key . '"';
+ if ($catid == $key) {
+ $select .= ' selected';
+ }
+ $select .= ' style="background-color:' . $bkg . ';"';
+ $select .= '>'.$paddman . $value["category"] . '</option>';
+ }
+ }
+ }
+ $select .= "</select>";
+ return $select;
+ }
+
+
/**
* Return the html for the edit form
- *
+ *
* @param type $registry Registry obj
* @return type string HTML
*/
public function toHtml($registry)
{
$GLOBALS['styleSheets'][]
- = GLM_APP_BASE_URL .
+ = GLM_APP_BASE_URL .
'libjs/jqueryui/1.8.13/development-bundle/themes/cupertino/jquery.ui.all.css';
$GLOBALS['bottomScripts'][]
= GLM_APP_BASE_URL .
= BASE_URL . 'css/colorPicker.css';
$GLOBALS['bottomScripts'][]
= BASE_URL . 'libjs/jquery.colorPicker.js';
-
+
// javascript for the edit schedule page
$GLOBALS['bottomScripts'][]
= BASE_URL . 'Toolkit/Schedule/js/editSchedule.js';
if ($scheduleId) {
$page->departures = $this->getDepartures($registry, $scheduleId);
}
+ $page->pageSelect = $this->_parentSelect($image->getPage());
$page->colors = $this->colors;
$page->timesChx = $this->timesChx;
$page->timesBvi = $this->timesBvi;