public static function bookRoom(Room $room, Reservation $reservation)
 {
     try {
         $room->addReservation($reservation);
         $successMessage = "Room <strong>" . $room->getRoomNumber() . "</strong> successfully booked ";
         $successMessage .= "for <strong>" . $reservation->getGuest();
         $successMessage .= "</strong> from <time>" . $reservation->getStarDate()->format("d.m.Y") . "</time> ";
         $successMessage .= "to <time>" . $reservation->getEndDate()->format("d.m.Y") . "</time>!";
         $successMessage .= "</br>";
         echo $successMessage;
     } catch (EReservationException $ex) {
         echo "<strong>Operation failed.</strong> " . $ex->getMessage() . "</br>";
         return;
     }
 }
Example #2
0
 /**
  * Destroy user session
  */
 public function actionLogout()
 {
     try {
         // we might not be signed in actually
         $this->user = new User();
     } catch (UserNotAuthenticatedException $e) {
         $this->flashSuccess = 'You are already logged out';
     }
     // as we are logging out, leave us from all rooms
     if ($this->user != NULL) {
         $inRooms = $this->user->inRooms();
         if (!empty($inRooms)) {
             $time = mktime();
             foreach ($inRooms as $room) {
                 // message about it
                 $message = new MessageSpeak($room, $time);
                 $message->leave($room, $time, $this->user->getShortName());
             }
             // remove us from participants
             $room = new Room();
             $room->removeParticipant($this->user->getId());
         }
         $this->flashSuccess = 'You have been logged out';
         $this->user->signOut();
     }
     $this->bag->token = Fari_FormToken::create();
     $this->renderAction('login');
 }
Example #3
0
 /**
  * Internal function to return a Room object from a row.
  * @param $row array
  * @return Room
  */
 function &_returnRoomFromRow(&$row)
 {
     $room = new Room();
     $room->setId($row['room_id']);
     $room->setBuildingId($row['building_id']);
     $this->getDataObjectSettings('room_settings', 'room_id', $row['room_id'], $room);
     return $room;
 }
Example #4
0
 public function joinRoom(Room $room)
 {
     if ($room->isFull()) {
         return;
     }
     $this->room = $room;
     $room->addPlayer($this);
 }
Example #5
0
 public function select_group()
 {
     $group_id = $this->input->post('group_id');
     $this->_transaction_isolation();
     $this->db->trans_begin();
     $group = new Group();
     $group->get_by_id($group_id);
     if ($group->exists()) {
         $course = $group->course->get();
         if (is_null($course->groups_change_deadline) || date('U', strtotime($course->groups_change_deadline)) >= time()) {
             $student = new Student();
             $student->get_by_id($this->usermanager->get_student_id());
             if ($student->is_related_to('active_course', $course->id)) {
                 $participant = new Participant();
                 $participant->where_related($student);
                 $participant->where_related($course);
                 $participant->where('allowed', 1);
                 $participant->get();
                 if ($participant->exists()) {
                     if (!$participant->is_related_to($group)) {
                         $participant->save($group);
                         $participant->where_related($course);
                         $participant->where_related($group);
                         $participant->where('allowed', 1);
                         $participants_count = $participant->count();
                         $room = new Room();
                         $room->where_related($group)->order_by('capacity', 'asc')->limit(1)->get();
                         if ($participants_count > intval($room->capacity)) {
                             $this->db->trans_rollback();
                             $this->messages->add_message('lang:groups_message_group_is_full', Messages::MESSAGE_TYPE_ERROR);
                         } else {
                             $this->db->trans_commit();
                             $this->messages->add_message(sprintf($this->lang->line('groups_message_group_changed'), $this->lang->text($group->name)), Messages::MESSAGE_TYPE_SUCCESS);
                             $this->_action_success();
                             $this->output->set_internal_value('course_id', $participant->course_id);
                         }
                     } else {
                         $this->db->trans_rollback();
                         $this->messages->add_message('lang:groups_message_you_are_in_group', Messages::MESSAGE_TYPE_ERROR);
                     }
                 } else {
                     $this->db->trans_rollback();
                     $this->messages->add_message('lang:groups_message_cant_found_participant_record', Messages::MESSAGE_TYPE_ERROR);
                 }
             } else {
                 $this->db->trans_rollback();
                 $this->messages->add_message('lang:groups_message_cant_change_group_of_inactive_course', Messages::MESSAGE_TYPE_ERROR);
             }
         } else {
             $this->db->trans_rollback();
             $this->messages->add_message('lang:groups_message_groups_switching_disabled', Messages::MESSAGE_TYPE_ERROR);
         }
     } else {
         $this->db->trans_rollback();
         $this->messages->add_message('lang:groups_message_group_not_found', Messages::MESSAGE_TYPE_ERROR);
     }
     redirect(create_internal_url('groups'));
 }
 static function bookRoom(Room $room, Reservation $reservation)
 {
     $room->addReservation($reservation);
     $roomNumber = $room->getRoomInfo()->getRoomNumber();
     $guest = $reservation->getGuest()->getFullName();
     $start = $reservation->getStartDate();
     $end = $reservation->getEndDate();
     echo "Room <strong>{$roomNumber}</strong> successfully booked for <strong>{$guest}</strong> from <time>{$start}</time> to <time>{$end}</time>!";
 }
Example #7
0
 public static function bookRoom(Room $room, Reservation $reservation)
 {
     try {
         $room->addReservation($reservation);
         echo "\nRoom " . $room->getRoomNumber() . " successfully booked for " . $reservation->getGuest()->getFullName() . " from " . $reservation->getStartDate()->format("d-m-y") . " to " . $reservation->getEndDate()->format("d-m-y");
     } catch (EReservationException $ex) {
         echo PHP_EOL . $ex->getMessage();
     }
 }
 public static function bookRoom(Room $room, Reservation $reservation)
 {
     try {
         $room->addReservation($reservation);
         $output = "Room <strong>{$room->getRoomNumber()}</strong> successfully booked for " . "<strong>{$reservation->getGuest()}</strong> from " . "<time>{$reservation->getStartDate()->format("d.m.Y")}</time> to " . "<time>{$reservation->getEndDate()->format("d.m.Y")}</time>!";
         echo $output;
     } catch (EReservationException $e) {
         echo $e->getMessage();
     }
 }
function isEmpty(Room $room)
{
    $quest = new Guest("G", "R", 89466466);
    $reservation = new Reservation("15-10-2014", "18-10-2014", $quest);
    try {
        $room->checkForValidReservation($reservation);
        return true;
    } catch (EReservationException $ex) {
        return false;
    }
}
function doDelete()
{
    @($id = $_POST['selector']);
    $key = count($id);
    //multi delete using checkbox as a selector
    for ($i = 0; $i < $key; $i++) {
        $room = new Room();
        $room->delete($id[$i]);
    }
    message("Room(s) already Deleted!", "info");
    redirect('index.php');
}
Example #11
0
 static function bookRoom(Room $room, Reservation $reservation)
 {
     try {
         $room->addReservation($reservation);
         $startDate = $reservation->getStartDate();
         $endDate = $reservation->getEndDate();
         $guestName = $reservation->getGuest()->getFistName() . " " . $reservation->getGuest()->getLastName();
         echo "\nRoom <strong>" . $room->getRoomId() . "</strong> successfully booked for <strong>" . $guestName . "</strong> from <time>" . date_format($startDate, "d-m-y") . "</time> to <time>" . date_format($endDate, "d-m-y") . "</time>!</br>";
     } catch (EReservationException $ex) {
         echo $ex->getMessage();
     }
 }
Example #12
0
 public function executeAdd(sfWebRequest $request)
 {
     if ($request->isMethod('Post')) {
         $room = new Room();
         $room->setTitle($this->getRequestParameter('title'));
         $room->setPrice($this->getRequestParameter('price'));
         $room->setStatus(Constant::BED_AVAILABLE);
         $room->save();
         $this->getUser()->setFlash('SUCCESS_MESSAGE', Constant::RECORD_ADDED_SUCCESSFULLY);
         $this->redirect('Room/list');
     }
     //end if
 }
 public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 10) as $index) {
         Room::create([]);
     }
 }
 public function deleteRoom($buildingid, $id)
 {
     //
     $room = Room::find($id);
     $room->delete();
     return Redirect::to('/building/' . $buildingid);
 }
Example #15
0
 public function getDelete($id)
 {
     $room = Room::find($id);
     $room->delete();
     Session::flash('message', 'The records are deleted successfully');
     return Redirect::to('rooms');
 }
Example #16
0
 public function run()
 {
     Bundle::start('messages');
     $twoweeks = date('Y-m-d', strtotime('+2 weeks'));
     $week = date('Y-m-d', strtotime('+1 weeks'));
     $tomorrow = date('Y-m-d', strtotime('+1 day'));
     $rooms = Room::where_del_date($tomorrow)->or_where('del_date', '=', $week)->or_where('del_date', '=', $twoweeks)->get();
     foreach ($rooms as $room) {
         switch ($room->del_date) {
             case $twoweeks:
                 $expire_date = "over twee weken";
                 break;
             case $week:
                 $expire_date = "over een week";
                 break;
             case $tomorrow:
                 $expire_date = "morgen";
                 break;
         }
         Message::send(function ($message) use($room, $expire_date) {
             $message->to($room->email);
             $message->from('*****@*****.**', 'Kamergenood');
             $message->subject('Verleng de kameradvertentie: "' . $room->title . '"');
             $message->body('view: emails.extend');
             $message->body->id = $room->id;
             $message->body->title = $room->title;
             $message->body->url = $room->url;
             $message->body->delkey = $room->delkey;
             $message->body->expire_date = $expire_date;
             $message->html(true);
         });
     }
 }
 /**
  * Generate the HTML of the receipt print
  */
 public function buildDepositReceipt()
 {
     $html = '<div id="outerHTML">';
     $html .= '<div id="printArea">';
     $html .= '<h2 align="center">Salesforce</h2>';
     $html .= '<h3 align="center">Official Receipt: ELDOWAS Deposit</h3>';
     $html .= '<div id="receipt-header">';
     $html .= '<p align="center">';
     $html .= 'Kenyatta Street, New Muya House<br />';
     $html .= '2<sup>nd</sup> Flr, Room 105.<br />';
     $html .= 'Tel: + 254 721 156 315 &nbsp; / &nbsp; + 254 720 711 115<br />';
     $html .= 'www.salesforce.co.ke &nbsp; Email: info@salesforce.co.ke';
     $html .= '</p></div>';
     $html .= '<hr align="center" />';
     $html .= '<div id="receipt-body">';
     $html .= '<p>';
     $html .= '<strong>Receipt No:</strong> &nbsp;<span style="color:#F00;">';
     $html .= $this->_receipt_no;
     $html .= '</span></p>';
     $html .= '<p><strong>Tenant:</strong> &nbsp;';
     $html .= $this->_tenant_name . '</p>';
     $html .= '<p><strong>Room No:</strong> &nbsp;';
     $html .= Room::findById($this->_rid)->getRoomLabel();
     $html .= '<p><strong>Payment Amount:</strong> &nbsp;';
     $html .= number_format($this->_amount);
     $html .= '</p><p><strong>Company Agent:</strong> &nbsp;';
     $html .= $this->_agent . '</p>';
     $html .= '<p><strong>Date:</strong> &nbsp;';
     $html .= $this->_date_paid . " &nbsp;&nbsp;" . strftime("%H:%I:%S");
     $html .= '</p></div>';
     $html .= '</div></div>';
     print $html;
 }
Example #18
0
 /**
  * make shure the username is valid for this room
  *
  * @param $newName string
  * @param $roomName string
  * @return bool
  */
 public function isUnique($newName, $roomName)
 {
     $room = Room::where('name', '=', $roomName)->first();
     $count = User::where('room_id', '=', $room->id)->where('connected', '=', 1)->where('name', '=', $newName)->count();
     $this->validationErrors->add('name', 'This name has already been taken :(');
     return $count === 0 ? true : false;
 }
 public function editAction()
 {
     $personId = (int) $this->_getParam('personId');
     if (isset($this->_session->messages)) {
         $this->view->messages = $this->_session->messages;
     }
     $this->_form = new WebVista_Form(array('name' => 'provider-detail'));
     $this->_form->setAction(Zend_Registry::get('baseUrl') . "admin-providers.raw/edit-process");
     $this->_provider = new Provider();
     $this->_provider->person_id = $personId;
     if (!$this->_provider->populate()) {
         if ($personId > 0) {
             //handle case where person exists but no provider record
             $this->view->noProvider = true;
         }
         //do nothing if personId is 0, no person selected yet
     }
     $this->_form->loadORM($this->_provider, 'provider');
     //var_dump($this->_form);
     $this->view->form = $this->_form;
     $this->view->person = $this->_provider;
     $stations = Enumeration::getEnumArray(Routing::ENUM_PARENT_NAME);
     $stations = array_merge(array('' => ''), $stations);
     $this->view->stations = $stations;
     $specialties = array('' => '');
     $listSpecialties = Provider::getListSpecialties();
     // temporarily use AM = American Medical Association
     foreach ($listSpecialties['AM'] as $specialty) {
         $specialties[$specialty['code']] = $specialty['description'];
     }
     $this->view->specialties = $specialties;
     $this->view->colors = Room::getColorList();
     $this->render('edit');
 }
Example #20
0
 public function open($db)
 {
     $this->id = Room::getUniqueId('r');
     $this->start_time = Room::getCurrentTime();
     $this->channel_token = Room::getUniqueId('h');
     $this->add($db);
 }
 public function getRoom()
 {
     $date = date('Y-m-d', strtotime(Input::get('date')));
     $rtype_id = Input::get('rtype_id');
     $reserves = CottageReservation::where('reservation_date', '=', $date)->where('reservation_type', '=', $rtype_id)->get();
     if (!empty($reserves)) {
         $id = array();
         foreach ($reserves as $reserve) {
             if (!in_array($reserve['room_id'], $id)) {
                 $id[count($id)] = $reserve['room_id'];
             }
         }
         $response = array();
         $rooms = Room::all();
         foreach ($rooms as $room) {
             if (!in_array($room['rnid'], $id)) {
                 $response[] = array("id" => $room['rnid'], "name" => $room['roomname']);
             }
         }
         return $response;
     } else {
         $rooms = Room::all();
         foreach ($rooms as $room) {
             $response[] = array("id" => $room['rnid'], "name" => $room['roomname']);
         }
         return $response;
     }
 }
Example #22
0
 public static function createIfExists($room)
 {
     if (Room::exists($room)) {
         return new Room($room);
     }
     return null;
 }
Example #23
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $rooms = [['name' => 'UB10103', 'building' => 1, 'floor' => 1, 'seats' => 40], ['name' => 'UB10102', 'building' => 1, 'floor' => 1, 'seats' => 40], ['name' => 'UB10101', 'building' => 1, 'floor' => 1, 'seats' => 40], ['name' => 'UB10201', 'building' => 1, 'floor' => 2, 'seats' => 40], ['name' => 'UB10202', 'building' => 1, 'floor' => 2, 'seats' => 40], ['name' => 'UB10203', 'building' => 1, 'floor' => 2, 'seats' => 40], ['name' => 'UB20301', 'building' => 2, 'floor' => 3, 'seats' => 40], ['name' => 'UB20302', 'building' => 2, 'floor' => 3, 'seats' => 40], ['name' => 'UB20303', 'building' => 2, 'floor' => 3, 'seats' => 40], ['name' => 'UB40701', 'building' => 4, 'floor' => 7, 'seats' => 40], ['name' => 'UB40702', 'building' => 4, 'floor' => 7, 'seats' => 40], ['name' => 'UB40703', 'building' => 4, 'floor' => 7, 'seats' => 40], ['name' => 'UB30501', 'building' => 3, 'floor' => 5, 'seats' => 40], ['name' => 'UB30502', 'building' => 3, 'floor' => 5, 'seats' => 40], ['name' => 'UB30503', 'building' => 3, 'floor' => 5, 'seats' => 40], ['name' => 'UB21310', 'building' => 2, 'floor' => 13, 'seats' => 40], ['name' => 'UB21311', 'building' => 2, 'floor' => 13, 'seats' => 40], ['name' => 'UB21312', 'building' => 2, 'floor' => 13, 'seats' => 40]];
     foreach ($rooms as $key => $room) {
         Room::create($room);
     }
 }
Example #24
0
 public function join()
 {
     $data = Input::only(['name', 'room_id']);
     print_r($data);
     $room = Room::find($data['room_id']);
     if (!$room) {
         return Redirect::action('PrepareController@room');
     }
     if ($room->state !== 'open') {
         throw new BadRequestHttpException('既にゲームは開始しています。');
     }
     if ($room->mates->count() >= $room->member_number) {
         throw new BadRequestHttpException('全ユーザーが揃っています');
     }
     if (!isset($data['name']) || $data['name'] == '') {
         //名前指定していない場合
         return Redirect::action('PrepareController@rooms');
     }
     $i = 0;
     do {
         $hash = sha1(date("Y/m/d H:i:s.u") . 'zCeZu12X' . $data['name'] . $data['room_id']);
         $hashed_mate = Mate::where('hash', $hash)->select('hash')->first();
         $i++;
         if ($i > 50) {
             throw new InternalErrorException('ユーザー作成に失敗しました hash衝突しまくり');
         }
     } while ($hashed_mate && $i < 100);
     $mate = Mate::create(['name' => $data['name'], 'last_state' => 'open', 'hash' => $hash, 'cast_id' => 0, 'room_id' => $data['room_id'], 'select_user_id' => '', 'is_alive' => 1]);
     if (!$mate) {
         throw new InternalErrorException('ユーザー作成に失敗しました');
     }
     $room->touch();
     return Redirect::action('PlayController@index', ['hash' => $hash]);
 }
Example #25
0
 public function main()
 {
     $room = intval($_POST['room']);
     $loggedUser = LoggedUser::whoIsLogged();
     $GLOBALS['smarty']->assign('users', Room::getUsers($room));
     echo $GLOBALS['smarty']->fetch('users-box.tpl');
 }
Example #26
0
 public function editEvent($id)
 {
     $rooms = Room::where('id', '>', 0)->get();
     View::share('rooms', $rooms);
     $squeeb = Lecture::where('id', '=', $id)->first();
     View::share('squeeb', $squeeb);
     return View::make('organiser.edit');
 }
 /**
  * On rebuild of the search index, rebuild all space records
  *
  * @param type $event
  */
 public static function onSearchRebuild($event)
 {
     foreach (Room::model()->findAll() as $obj) {
         if ($obj->visibility != Space::VISIBILITY_NONE) {
             Yii::app()->search->add($obj);
         }
     }
 }
 function __construct($roomNumber, $price)
 {
     if (!empty($roomNumber) && ctype_digit($roomNumber) && !empty($price) && is_numeric($price)) {
         parent::__construct(intval($roomNumber), doubleval($price), self::BED_COUNT, self::HAS_BALCONY, new RoomType(RoomType::DIAMOND), self::EXTRAS, self::HAS_RESTROOM);
     } else {
         throw new InvalidArgumentException("Invalid parameters provided.");
     }
 }
 public function render()
 {
     $this->smarty = new RoomGeneratorSmarty();
     $this->smarty->assign('title', 'OpenTok Room Generator - PHP');
     $rooms = Room::getAllPublicRooms();
     $this->smarty->assign('rooms', $rooms);
     $this->smarty->display($_SERVER['DOCUMENT_ROOT'] . '/php_generator/app/view/index.tpl');
 }
 function __construct($roomNumber, $price)
 {
     parent::__construct($roomNumber, Bedroom::BED_COUNT, $price, true, true, RoomType::GOLD);
     $this->addExtras(Extra::TV);
     $this->addExtras(Extra::AIR_CONDITIONER);
     $this->addExtras(Extra::REFRIGERATOR);
     $this->addExtras(Extra::MINI_BAR);
     $this->addExtras(Extra::BATHTUB);
 }