oCfg = $oCfg; $this->processRequestVariables(); } /***************************************************************************/ /** * @} * @name Initialization * @{ */ /** * Process the REQUEST variables and preset the some variables * @return void */ protected function processRequestVariables() { if(isset($_GET["mod_roomReservationTimesliceListBox"])) { // action if(isset($_GET["mod_roomReservationTimesliceListBox"]["action"])) { $ga = $_GET["mod_roomReservationTimesliceListBox"]["action"]; $this->setAction((($ga == "add") ? MOD_ROOM_RESERVATION_TLB_ACTION_ADD : (($ga == "delete") ? MOD_ROOM_RESERVATION_TLB_ACTION_DELETE : MOD_ROOM_RESERVATION_TLB_ACTION_SHOW))); } // new beginning and new ending $this->setNewBegin(isset( $_GET["mod_roomReservationTimesliceListBox"]["begin"]) ? $_GET["mod_roomReservationTimesliceListBox"]["begin"] : ""); $this->setNewEnd(isset( $_GET["mod_roomReservationTimesliceListBox"]["end"]) ? $_GET["mod_roomReservationTimesliceListBox"]["end"] : ""); } // perform the requested action if($this->getAction() == MOD_ROOM_RESERVATION_TLB_ACTION_ADD) { // add a timeslice to the configuration file $bErrors = false; // Note: we want to handle the timestamps in GMT format, hence the "+0000" if(strtotime($this->getNewBegin()." +0000") === false) { $this->asFormErrors[] = _c("room-reservation:The beginning time is ". "invalid."); $bErrors = true; } if(strtotime($this->getNewEnd()." +0000") === false) { $this->asFormErrors[] = _c("room-reservation:The ending time is ". "invalid."); $bErrors = true; } if(!$bErrors) { try { $this->oCfg->addTimeslice(new mod_roomReservationTimeslice( strtotime($this->getNewBegin()." +0000") % 86400, strtotime($this->getNewEnd()." +0000") % 86400)); $this->oCfg->writeConfig(); $this->setNewBegin(""); $this->setNewEnd(""); } catch(Exception $e) { $this->asFormErrors[] = $e->getMessage(); } } } elseif($this->getAction() == MOD_ROOM_RESERVATION_TLB_ACTION_DELETE) { // delete a timeslice from the configuration file if(isset($_POST["mod_roomReservationTimesliceListBox"])) { if(isset($_POST["mod_roomReservationTimesliceListBox"]["l"])) { $ao = $this->oCfg->getTimeslices(); foreach($_POST["mod_roomReservationTimesliceListBox"]["l"] as $n => $b) { if($b) { $this->oCfg->deleteTimeslice(new mod_roomReservationTimeslice( $ao[$n]->getBegin(), $ao[$n]->getEnd())); } } $this->oCfg->writeConfig(); } } } } /***************************************************************************/ /** * @} * @name Access to attributes * @{ */ /** * Set the action to be done (GET data) * @param $c (constant) Action. See @ref timeslicelistbox_actions. */ protected function setAction($c) { $this->cAction = intval($c); } /** * Set the beginning for a new timeslice (GET data) * @param $s (string) */ protected function setNewBegin($s) { $this->sNewBegin = $s; } /** * Set the beginning for a new timeslice (GET data) * @param $s (string) */ protected function setNewEnd($s) { $this->sNewEnd = $s; } /** * Get the action to be done (GET data). See @ref timeslicelistbox_actions. * @return constant */ function getAction() { return $this->cAction; } /** * Get the beginning for a new timeslice (GET data) * @return string */ public function getNewBegin() { return $this->sNewBegin; } /** * Get the beginning for a new timeslice (GET data) * @return string */ public function getNewEnd() { return $this->sNewEnd; } /***************************************************************************/ /** * @} * @name Output * @{ */ /** * Show the control * @return void */ public function show() { TreeView(array(_c("room-reservation:Begin"), _c("room-reservation:End"))); // addition form printf("
\n"; // deletion form TreeViewTitle(_c("room-reservation:Periods")); $aoTs = $this->oCfg->getTimeslices(); if(count($aoTs) > 0) { echo "\n"; _TreeView(); } /** @} */ } ?>