示例#1
0
 private function _add()
 {
     use_helper('Validate');
     $data = $_POST['room'];
     Flash::set('room_postdata', $data);
     // Add pre-save checks here
     $errors = false;
     // CSRF checks
     if (isset($_POST['csrf_token'])) {
         $csrf_token = $_POST['csrf_token'];
         if (!SecureToken::validateToken($csrf_token, BASE_URL . 'room/add')) {
             Flash::set('error', __('Invalid CSRF token found!'));
             redirect(get_url('room/add'));
         }
     } else {
         Flash::set('error', __('No CSRF token found!'));
         redirect(get_url('room/add'));
     }
     if (empty($data['name'])) {
         Flash::set('error', __('You have to specify a room name!'));
         redirect(get_url('room/add'));
     }
     if ($errors !== false) {
         // Set the errors to be displayed.
         Flash::set('error', implode('<br/>', $errors));
         redirect(get_url('room/add'));
     }
     $new_room = new Room($data);
     $new_room->created_by_id = AuthUser::getId();
     $new_room->created_on = date('Y-m-d H:i:s');
     if ($new_room->save()) {
         if (isset($_FILES)) {
             if (strlen($_FILES['upload_file']['name']) > 0 || strlen($_FILES['upload_file_home']['name']) > 0) {
                 $room_id = $new_room->lastInsertId();
                 $overwrite = false;
                 if (strlen($_FILES['upload_file']['name']) > 0) {
                     $file = $this->upload_pdf_file($room_id, $_FILES['upload_file']['name'], FILES_DIR . '/room/images/', $_FILES['upload_file']['tmp_name'], $overwrite);
                 }
                 if (strlen($_FILES['upload_file_home']['name']) > 0) {
                     $file2 = $this->upload_pdf_file2($room_id, $_FILES['upload_file_home']['name'], FILES_DIR . '/room/images/', $_FILES['upload_file_home']['tmp_name'], $overwrite);
                 }
                 if ($file === false || $file2 === false) {
                     Flash::set('error', __('File has not been uploaded1!'));
                 }
                 redirect(get_url('room/edit/' . $new_room->id));
             }
         }
         Flash::set('success', __('Room has been added!'));
         Observer::notify('room_after_add', $new_room->name);
         // save and quit or save and continue editing?
         if (isset($_POST['commit'])) {
             redirect(get_url('room'));
         } else {
             redirect(get_url('room/edit/' . $new_room->id));
         }
     } else {
         Flash::set('error', __('Room has not been added!'));
         redirect(get_url('room/add'));
     }
 }
示例#2
0
 public function post_new()
 {
     $rules = array('title' => 'required|min:5|max:128', 'street' => 'required', 'postalcode' => 'required|match:#^[1-9][0-9]{3}\\h*[A-Z]{2}$#i', 'city' => 'required', 'type' => 'required', 'surface' => 'required|integer', 'price' => 'required|numeric|max:1500|min:100', 'date' => 'required|after:' . date('d-m-Y'), 'pictures' => 'required|image|max:3000', 'register' => 'required', 'email' => 'required|email|same:email2', 'description' => 'required|min:30', 'captchatest' => 'laracaptcha|required', 'terms' => 'accepted');
     $v = Validator::make(Input::all(), $rules, Room::$messages);
     if ($v->fails()) {
         return Redirect::to('kamer-verhuren')->with_errors($v)->with('msg', '<div class="alert alert-error"><strong>Verplichte velden zijn niet volledig ingevuld</strong><br />Loop het formulier nogmaals na.</div>')->with_input();
     } else {
         if (Auth::check()) {
             $status = 'publish';
         } else {
             $status = 'pending';
         }
         $new_room = array('title' => ucfirst(Input::get('title')), 'street' => ucwords(Input::get('street')), 'housenr' => Input::get('housenr'), 'postalcode' => Input::get('postalcode'), 'city' => ucwords(Input::get('city')), 'type' => Input::get('type'), 'surface' => Input::get('surface'), 'price' => Input::get('price'), 'available' => date("Y-m-d", strtotime(Input::get('date'))), 'gender' => Input::get('gender'), 'pets' => Input::get('pets'), 'smoking' => Input::get('smoking'), 'toilet' => Input::get('toilet'), 'shower' => Input::get('shower'), 'kitchen' => Input::get('kitchen'), 'register' => Input::get('register'), 'social' => Input::get('social'), 'email' => strtolower(Input::get('email')), 'description' => ucfirst(Input::get('description')), 'status' => $status, 'url' => Str::slug(Input::get('city')), 'delkey' => Str::random(32, 'alpha'), 'del_date' => date('y-m-d', strtotime('+2 months')));
         $room = new Room($new_room);
         if ($room->save()) {
             $upload_path = path('public') . Photo::$upload_path_room . $room->id;
             if (!File::exists($upload_path)) {
                 File::mkdir($upload_path);
                 chmod($upload_path, 0777);
             }
             $photos = Photo::getNormalizedFiles(Input::file('pictures'));
             foreach ($photos as $photo) {
                 $filename = md5(rand()) . '.jpg';
                 $path_to_file = $upload_path . '/' . $filename;
                 $dynamic_path = '/' . Photo::$upload_path_room . $room->id . '/' . $filename;
                 $success = Resizer::open($photo)->resize(800, 533, 'auto')->save($path_to_file, 80);
                 chmod($path_to_file, 0777);
                 if ($success) {
                     $new_photo = new Photo();
                     $new_photo->location = $dynamic_path;
                     $new_photo->room_id = $room->id;
                     $new_photo->save();
                 }
             }
             Message::send(function ($message) use($room) {
                 $message->to($room->email);
                 $message->from('*****@*****.**', 'Kamergenood');
                 $message->subject('In afwachting op acceptatie: "' . $room->title . '"');
                 $message->body('view: emails.submit');
                 $message->body->id = $room->id;
                 $message->body->title = $room->title;
                 $message->body->price = $room->price;
                 $message->body->type = $room->type;
                 $message->body->surface = $room->surface;
                 $message->body->available = $room->available;
                 $message->body->description = $room->description;
                 $message->body->url = $room->url;
                 $message->body->delkey = $room->delkey;
                 $message->html(true);
             });
             if (Message::was_sent()) {
                 return Redirect::to('kamer-verhuren')->with('msg', '<div class="alert alert-success"><strong>Hartelijk dank voor het vertrouwen in Kamergenood!</strong> De kameradvertentie zal binnen 24 uur worden gecontroleerd en geplaatst.</div>');
             }
         } else {
             return Redirect::to('kamer-verhuren')->with('msg', '<div class="alert alert-error"><strong>Er is iets mis gegaan bij het toevoegen.</strong> Probeer het later nog eens.</div>')->with_input();
         }
     }
 }
示例#3
0
 public function store()
 {
     $room = new Room();
     $room->location_id = Input::get('location');
     $room->name = Input::get('name');
     $room->capacity = Input::get('capacity');
     $room->save();
     Session::flash('message', 'Sukses menambahkan ruangan baru!');
 }
 /**
  * Создает новую модель Комнаты.
  * Если создание прошло успешно - перенаправляет на просмотр.
  *
  * @return void
  */
 public function actionCreate()
 {
     $model = new Room();
     if (Yii::app()->getRequest()->getPost('Room') !== null) {
         $model->setAttributes(Yii::app()->getRequest()->getPost('Room'));
         if ($model->save()) {
             Yii::app()->user->setFlash(yupe\widgets\YFlashMessages::SUCCESS_MESSAGE, Yii::t('BranchModule.branch', 'Запись добавлена!'));
             $this->redirect((array) Yii::app()->getRequest()->getPost('submit-type', ['update', 'id' => $model->id]));
         }
     }
     $this->render('create', ['model' => $model]);
 }
示例#5
0
 public function createRoom($data)
 {
     $result = new Room();
     $result->createTime = date('Y-m-d H:i:s', time());
     foreach ($data as $k => $v) {
         $result->{$k} = $v;
     }
     if ($result->save()) {
         $data = array('code' => 200, 'message' => 'SUCCESS');
     }
     return $data;
 }
示例#6
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Room();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Room'])) {
         $model->attributes = $_POST['Room'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->ID));
         }
     }
     $this->render('create', array('model' => $model));
 }
 public function createRoom($buildingid)
 {
     //count position
     $position = count(Room::where('building_id', '=', $buildingid)->get()) + 1;
     $room = new Room();
     $room->name = Input::get("roomname");
     $room->position = $position;
     $room->building_id = $buildingid;
     $room->save();
     //fetch created id
     $id = $room->id;
     return Redirect::to('/building/' . $buildingid . '/' . $id);
 }
示例#8
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
 }
示例#9
0
 /**
  * Performs the work of inserting or updating the row in the database.
  *
  * If the object is new, it inserts it; otherwise an update is performed.
  * All related objects are also updated in this method.
  *
  * @param      PropelPDO $con
  * @return     int The number of rows affected by this insert/update and any referring fk objects' save() operations.
  * @throws     PropelException
  * @see        save()
  */
 protected function doSave(PropelPDO $con)
 {
     $affectedRows = 0;
     // initialize var to track total num of affected rows
     if (!$this->alreadyInSave) {
         $this->alreadyInSave = true;
         // We call the save method on the following object(s) if they
         // were passed to this object by their coresponding set
         // method.  This object relates to these object(s) by a
         // foreign key reference.
         if ($this->aRoom !== null) {
             if ($this->aRoom->isModified() || $this->aRoom->isNew()) {
                 $affectedRows += $this->aRoom->save($con);
             }
             $this->setRoom($this->aRoom);
         }
         if ($this->isNew()) {
             $this->modifiedColumns[] = RoomprofilePeer::ID;
         }
         // If this object has been modified, then save it to the database.
         if ($this->isModified()) {
             if ($this->isNew()) {
                 $pk = RoomprofilePeer::doInsert($this, $con);
                 $affectedRows += 1;
                 // we are assuming that there is only 1 row per doInsert() which
                 // should always be true here (even though technically
                 // BasePeer::doInsert() can insert multiple rows).
                 $this->setId($pk);
                 //[IMV] update autoincrement primary key
                 $this->setNew(false);
             } else {
                 $affectedRows += RoomprofilePeer::doUpdate($this, $con);
             }
             $this->resetModified();
             // [HL] After being saved an object is no longer 'modified'
         }
         if ($this->collReservations !== null) {
             foreach ($this->collReservations as $referrerFK) {
                 if (!$referrerFK->isDeleted()) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }
 private function showCreateRoomPage()
 {
     if (WebRequest::wasPosted()) {
         try {
             // get variables
             $rname = WebRequest::post("rname");
             $rtype = WebRequest::postInt("rtype");
             $rmin = WebRequest::postInt("rmin");
             $rmax = WebRequest::postInt("rmax");
             $rprice = WebRequest::postFloat("rprice");
             // data validation
             if ($rname == "") {
                 throw new CreateRoomException("blank-roomname");
             }
             if ($rtype == 0) {
                 throw new CreateRoomException("blank-roomtype");
             }
             if ($rmax < 1 || $rmin < 0) {
                 throw new CreateRoomException("room-capacity-too-small");
             }
             if ($rmin > $rmax) {
                 throw new CreateRoomException("room-capacity-min-gt-max");
             }
             if ($rprice != abs($rprice)) {
                 throw new CreateRoomException("room-price-negative");
             }
             $room = new Room();
             // set values
             $room->setName($rname);
             $room->setType($rtype);
             $room->setMinPeople($rmin);
             $room->setMaxPeople($rmax);
             $room->setPrice($rprice);
             $room->save();
             global $cScriptPath;
             $this->mHeaders[] = "Location: {$cScriptPath}/Rooms";
         } catch (CreateRoomException $ex) {
             $this->mBasePage = "mgmt/roomCreate.tpl";
             $this->error($ex->getMessage());
         }
     } else {
         $this->mBasePage = "mgmt/roomCreate.tpl";
     }
     $this->mSmarty->assign("rtlist", RoomType::$data);
 }
示例#11
0
 public function actionAdd_room()
 {
     $room = new Room();
     $room->style = $_POST['style'];
     $room->content = $_POST['content'];
     $room->company = $_POST['company'];
     if (isset($_POST['source'])) {
         $room->source = $_POST['source'];
     }
     if (isset($_POST['thumb'])) {
         $room->thumb = $_POST['thumb'];
     }
     $room->boat = $_POST['boat'];
     $room->save();
     //$this->redirect(Yii::app()->request->urlReferrer);
     echo 1;
     //                        echo CJSON::encode(array('title'=>$_POST['title'], 'area'=>$_POST['area'], 'port'=>$_POST['port']));//Yii 的方法将数组处理成json数据
 }
 /**
  * Создает новую модель Аудитории.
  * Если создание прошло успешно - перенаправляет на просмотр.
  *
  * @return void
  */
 public function actionCreate()
 {
     $roles = ['1'];
     $role = \Yii::app()->user->role;
     if (array_intersect($role, $roles)) {
         $model = new Room();
         if (Yii::app()->getRequest()->getPost('Room') !== null) {
             $model->setAttributes(Yii::app()->getRequest()->getPost('Room'));
             if ($model->save()) {
                 Yii::app()->user->setFlash(yupe\widgets\YFlashMessages::SUCCESS_MESSAGE, Yii::t('BranchModule.branch', 'Запись добавлена!'));
                 $this->redirect((array) Yii::app()->getRequest()->getPost('submit-type', ['update', 'id' => $model->id]));
             }
         }
         $this->render('create', ['model' => $model]);
     } else {
         throw new CHttpException(403, 'Ошибка прав доступа.');
     }
 }
示例#13
0
 protected function setup()
 {
     $loggedUser = LoggedUser::whoIsLogged();
     if (Utils::post('create_room') && $loggedUser['admin']) {
         $params = array('title' => Utils::post('title'), 'alias' => Utils::createAlias(Utils::post('title'), 'room'), 'description' => Utils::post('description'));
         $room = new Room($params);
         $room->save();
     }
     $roomRepository = new RoomRepository();
     $rooms = $roomRepository->getAll();
     $gameRepository = new GameRepository();
     $games = $gameRepository->getGamesByRooms(array_keys($rooms));
     foreach ($games as $game) {
         $rooms[$game['room']]['game'] = TRUE;
         $rooms[$game['room']]['status'] = Localize::getMessage('room_status_' . $game['status']);
     }
     MySmarty::assign('loggedUser', $loggedUser);
     MySmarty::assign('rooms', $rooms);
 }
 public function run()
 {
     $faker = Faker\Factory::create();
     DB::table('groups')->delete();
     DB::table('rooms')->delete();
     DB::table('users')->delete();
     $group = new Group();
     $group->name = "Admin";
     $group->permission = "1,2,3,4,5,6";
     $group->admin = true;
     $group->save();
     $group = new Group();
     $group->name = "Customer";
     $group->permission = "10";
     $group->admin = false;
     $group->save();
     for ($i = 1; $i < 10; $i++) {
         $room = new Room();
         $room->room_code = sprintf("%03dS", $i);
         $room->save();
     }
     $admin_group = Group::where('name', '=', 'Admin')->first();
     $customer_group = Group::where('name', '=', 'Customer')->first();
     $user = new User();
     $user->username = "******";
     $user->password = Hash::make("passnhulon");
     $user->group_id = $admin_group->id;
     $user->realname = "Sairen Nguyen";
     $user->birthday = "1993-04-05";
     $user->email = "*****@*****.**";
     $user->save();
     for ($i = 1; $i < 10; $i++) {
         $user = new User();
         $user->username = sprintf("%03dS", $i);
         $user->password = Hash::make("passnhulon");
         $user->group_id = $customer_group->id;
         $user->room_id = Room::all()->first()->id + $i - 1;
         $user->realname = $faker->name();
         $user->email = $faker->email;
         $user->save();
     }
 }
 /**
  * Stores the object in the database.
  *
  * If the object is new, it inserts it; otherwise an update is performed.
  * All related objects are also updated in this method.
  *
  * @param      Connection $con
  * @return     int The number of rows affected by this insert/update and any referring fk objects' save() operations.
  * @throws     PropelException
  * @see        save()
  */
 protected function doSave($con)
 {
     $affectedRows = 0;
     // initialize var to track total num of affected rows
     if (!$this->alreadyInSave) {
         $this->alreadyInSave = true;
         // We call the save method on the following object(s) if they
         // were passed to this object by their coresponding set
         // method.  This object relates to these object(s) by a
         // foreign key reference.
         if ($this->aUser !== null) {
             if ($this->aUser->isModified()) {
                 $affectedRows += $this->aUser->save($con);
             }
             $this->setUser($this->aUser);
         }
         if ($this->aRoom !== null) {
             if ($this->aRoom->isModified()) {
                 $affectedRows += $this->aRoom->save($con);
             }
             $this->setRoom($this->aRoom);
         }
         // If this object has been modified, then save it to the database.
         if ($this->isModified()) {
             if ($this->isNew()) {
                 $pk = PermissionPeer::doInsert($this, $con);
                 $affectedRows += 1;
                 // we are assuming that there is only 1 row per doInsert() which
                 // should always be true here (even though technically
                 // BasePeer::doInsert() can insert multiple rows).
                 $this->setNew(false);
             } else {
                 $affectedRows += PermissionPeer::doUpdate($this, $con);
             }
             $this->resetModified();
             // [HL] After being saved an object is no longer 'modified'
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }
示例#16
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Room();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Room'])) {
         //print_r($_POST['Room']);
         //exit;
         //$roomdetails=Room::model()->findByAttributes(array('room_no'=>$_POST['Room']['room_no']));
         //if($roomdetails==NULL)
         //{
         $model->attributes = $_POST['Room'];
         $list = $_POST['Room'];
         //echo $list['floor'];exit;
         $cnt = count($list['room_no']);
         for ($i = 0; $i < $cnt; $i++) {
             $model = new Room();
             $model->room_no = $list['room_no'][$i];
             $model->no_of_bed = $list['no_of_bed'][$i];
             $model->created = date('Y-m-d');
             $model->floor = $list['floor'];
             $count = $list['no_of_bed'][$i];
             $letter = 'a';
             $model->save();
             for ($j = 1; $j <= $count; $j++) {
                 $model_1 = new Allotment();
                 $model_1->room_no = $model->id;
                 $model_1->bed_no = $letter;
                 $model_1->floor = $list['floor'][$i];
                 $model_1->status = 'C';
                 $model_1->save();
                 $letter++;
             }
         }
         $this->redirect(array('/hostel/room/manage'));
         //$this->redirect(array('/RoomDetails/create/','id'=>$_POST['Room']['room_no']));
         //}
     }
     $this->render('create', array('model' => $model));
 }
示例#17
0
 public function getSave()
 {
     $id = Input::get('id');
     if ($id) {
         $room = Room::find($id);
         $room->type_id = Input::get('type_id');
         $room->number = Input::get('number');
         $room->floor = Input::get('floor');
         $room->name = Input::get('name');
         $room->save();
         Session::flash('message', 'The records are updated successfully');
     } else {
         $room = new Room();
         $room->type_id = Input::get('type_id');
         $room->number = Input::get('number');
         $room->floor = Input::get('floor');
         $room->name = Input::get('name');
         $room->save();
         Session::flash('message', 'The records are inserted successfully');
     }
     return Redirect::to('rooms');
 }
示例#18
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     // validate
     // read more on validation at http://laravel.com/docs/validation
     $rules = array('room_admin' => 'required', 'room_name' => 'required', 'room_location' => 'required', 'room_capacity' => 'required|numeric', 'room_type');
     $validator = Validator::make(Input::all(), $rules);
     // process the login
     if ($validator->fails()) {
         return Redirect::to('rooms/create')->withErrors($validator)->withInput(Input::except('password'));
     } else {
         // store
         $room = new Room();
         $room->room_admin = Input::get('room_admin');
         $room->room_name = Input::get('room_name');
         $room->room_location = Input::get('room_location');
         $room->room_capacity = Input::get('room_capacity');
         $room->room_type = Input::get('room_type');
         $room->save();
         // redirect
         Session::flash('message', 'Successfully created room!');
         return Redirect::to('rooms');
     }
 }
 public function store()
 {
     /*VARIABLES
     		$r = room
     		$i = all inputs
     		$rq = Room Quantity
     		***************/
     $r = new Room();
     $i = Input::all();
     $r->name = $i['name'];
     $r->short_desc = $i['short_desc'];
     $r->full_desc = $i['full_desc'];
     $r->max_adults = $i['max_adults'];
     $r->max_children = $i['max_children'];
     $r->beds = $i['beds'];
     $r->bathrooms = $i['bathrooms'];
     $r->area = $i['area'];
     $r->price = $i['price'];
     if ($r->save()) {
         $a = new Activity();
         $a->location = 2;
         $a->actor = Auth::id();
         $a->logs = 'Created a room: ' . $r->name;
         $a->save();
         $x = $i['no_of_rooms'];
         while ($x != 0) {
             $x--;
             $rq = new RoomQty();
             $rq->room_id = $r->id;
             $rq->save();
         }
         if (isset($i['images']) || !empty($i['images'])) {
             if (is_array($i['images'])) {
                 foreach ($i['images'] as $image) {
                     $upload = new RoomImage();
                     $upload->room_id = $r->id;
                     $upload->image_id = $image['photo']['id'];
                     $upload->save();
                 }
             } else {
             }
         }
         return $r;
     } else {
         return '0';
     }
 }
示例#20
0
 public function update($group_id)
 {
     $this->load->library('form_validation');
     $this->form_validation->set_rules('room[name]', 'lang:admin_rooms_form_field_name', 'required');
     $this->form_validation->set_rules('room[time_begin]', 'lang:admin_rooms_form_field_time_begin', 'required|callback__is_time');
     $this->form_validation->set_rules('room[time_end]', 'lang:admin_rooms_form_field_time_end', 'required|callback__is_time|callback__is_later_time');
     $this->form_validation->set_rules('room[time_day]', 'lang:admin_rooms_form_field_time_day', 'required|callback__is_day');
     $this->form_validation->set_rules('room[capacity]', 'lang:admin_rooms_form_field_capacity', 'required|integer|greater_than[0]');
     $this->form_validation->set_rules('room_id', 'room_id', 'required');
     $this->form_validation->set_message('_is_time', $this->lang->line('admin_rooms_form_error_message_is_time'));
     $this->form_validation->set_message('_is_day', $this->lang->line('admin_rooms_form_error_message_is_day'));
     $this->form_validation->set_message('_is_later_time', $this->lang->line('admin_rooms_form_error_message_is_later_time'));
     if ($this->form_validation->run()) {
         $room_id = intval($this->input->post('room_id'));
         $room = new Room();
         $room->get_by_id($room_id);
         if ($room->exists()) {
             $room_data = $this->input->post('room');
             $room->from_array($room_data, array('name', 'time_day'));
             $room->time_begin = $this->time_to_int($room_data['time_begin']);
             $room->time_end = $this->time_to_int($room_data['time_end']);
             $room->capacity = intval($room_data['capacity']);
             $this->_transaction_isolation();
             $this->db->trans_begin();
             if (trim($room_data['teachers_plain']) != '') {
                 $room->teachers_plain = trim($room_data['teachers_plain']);
             } else {
                 $room->teachers_plain = NULL;
             }
             $current_teachers = $room->teacher->get();
             $room->delete($current_teachers->all);
             $teachers = new Teacher();
             if (is_array($room_data['teachers']) && count($room_data['teachers'])) {
                 foreach ($room_data['teachers'] as $teacher_id) {
                     $teachers->or_where('id', $teacher_id);
                 }
                 $teachers->get();
             }
             if ($room->save(array($teachers->all)) && $this->db->trans_status()) {
                 $this->db->trans_commit();
                 $this->messages->add_message('lang:admin_rooms_flash_message_save_successful', Messages::MESSAGE_TYPE_SUCCESS);
                 $this->_action_success();
                 $room->group->get();
                 $this->output->set_internal_value('course_id', $room->group->course_id);
             } else {
                 $this->db->trans_rollback();
                 $this->messages->add_message('lang:admin_rooms_flash_message_save_failed', Messages::MESSAGE_TYPE_ERROR);
             }
         } else {
             $this->messages->add_message('lang:admin_rooms_error_room_not_found', Messages::MESSAGE_TYPE_ERROR);
         }
         redirect(create_internal_url('admin_rooms/index/' . $group_id));
     } else {
         $this->edit($group_id);
     }
 }
示例#21
0
$r1 = new Right();
$r1->setSection($s1->getId());
$r1->setRead('1');
$r1->setDelete('1');
$r1->setCreate('1');
$r1->setUpdate('1');
$r1->setRank('1');
$r1->save();
$conf = new Configuration();
$conf->put('plugin_kodiCmd_api_url_kodi', 'http://192.168.1.107:85/jsonrpc');
$conf->put('plugin_kodiCmd_api_timeout_kodi', 5);
$conf->put('plugin_kodiCmd_api_recognition_status', '');
$ro = new Room();
$ro->setName('KODI');
$ro->setDescription('De la bonne zic, un bon p\'tit film....');
$ro->save();
$roomManager = new Room();
$rooms = $roomManager->populate();
foreach ($rooms as $room) {
    if ($room->getName() == "KODI") {
        $kodiRoomId = $room->getId();
    }
}
$id = 0;
$kodi = new KodiCmd();
$kodi->setName('à droite');
$kodi->setDescription('se déplacer à droite');
$kodi->setJson('"method":"Input.Right","id":"1"');
$kodi->setConfidence('0.8');
$kodi->setRoom($kodiRoomId);
$kodi->save();
示例#22
0
function list_import_lamsfet_excercise_groups(&$excercise_groups, $courses_terms)
{
    echo 'Starting groups import (' . count($excercise_groups) . ') ';
    $days = array(1 => 'Pondelok', 'Utorok', 'Streda', 'Štvrtok', 'Piatok', 'Sobora', 'Nedeľa');
    if (count($excercise_groups)) {
        foreach ($excercise_groups as $id => $excercise_group) {
            $course_id = $courses_terms[$excercise_group->course_term_id]->_list_id;
            $course = new Course();
            $course->get_by_id(intval($course_id));
            if ($course->exists()) {
                $group = new Group();
                list($h, $m, $s) = explode(':', $excercise_group->time);
                $time_begin = (int) $s + (int) $m * 60 + (int) $h * 3600;
                if ($time_begin >= 86400) {
                    $excercise_group->time = '00:00:00';
                    $time_begin = 0;
                }
                $group->name = 'Skupina ' . $excercise_group->place . ' ' . $days[$excercise_group->day] . ' ' . $excercise_group->time;
                $group->save($course);
                $excercise_groups[$id]->_list_id = $group->id;
                $room = new Room();
                $room->name = $excercise_group->place;
                $room->time_day = $excercise_group->day;
                $room->time_begin = $time_begin;
                $room->time_end = $room->time_begin + 5400;
                $room->capacity = $excercise_group->capacity;
                $room->teachers_plain = trim($excercise_group->teacher) != '' ? trim($excercise_group->teacher) : NULL;
                $room->save($group);
                $course->capacity += $room->capacity;
                $course->save();
                echo '.';
            } else {
                echo ' ( COURSE NOT FOUND ' . $course_id . '(' . $excercise_group->course_term_id . ') ) ';
            }
        }
    }
    echo '] ... done' . "\n";
}
示例#23
0
 protected function processCopyForm(sfWebRequest $request, sfForm $form, Room $room)
 {
     $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
     if ($form->isValid()) {
         $this->forward404Unless($copyRoom = RoomPeer::retrieveByPk($form->getValue('copyRoom_id')), sprintf('Object room does not exist (%s).', $form->getValue('copyRoom_id')));
         if ($copyRoom->getId() != $room->getId()) {
             $room->copyDayperiodsFromRoom($copyRoom);
             $room->save();
         }
         $this->redirect('dayperiod/index?roomId=' . $room->getId());
     }
 }
示例#24
0
		$rMaxPersons = $room['maxPersons'];
		$rMaxExtraBeds = $room['maxExtraBeds'];

		$rTypeObj = new RoomType();
		$rTypeObj->name = $rType;
		$rTypeObj->save();

		$rObj = new Room();
		$rObj->room_type_id = $rTypeObj->id;
		$rObj->room_feature_ids = $rFIds;
		$rObj->no_of_rooms = $rQty;
		$rObj->assigned_rooms = $rQtyAssigned;
		$rObj->max_persons = $rMaxPersons;
		$rObj->max_extra_beds = $rMaxExtraBeds;
		$rObj->hotel_id = $hotel_id;
		$rObj->save();

		$roomImages = $_FILES['roomImg'];
		$images = $roomImages['name'];
		$prefix = hash('md5', $hotel_id) . '_' . hash('md5', $rObj->id) . '_';
		$uploadDir = DOC_ROOT . 'uploads/room-photos/';

		foreach($images as $iK => $image){
			$nIType = $roomImages['type'][$iK];
			$nIType = explode('/', $nIType);
			$nIType1 = $nIType[0];
			$nIType2 = $nIType[1];
			if($nIType1 == 'image'){
				if($nIType2 == 'jpeg' || $nIType2 == 'pjpeg'){ $ext = '.jpg'; }
				else if($nIType2 == 'png'){ $ext = '.png'; }
				else{ $ext = '.noExt_'; }
示例#25
0
 /**
  * create a new room
  *
  * @param array $model
  * @param object $connection
  * @param string $id
  * @param object $topic
  */
 private function newRoom($model, $connection, $id, $topic)
 {
     $user = $connection->WhatUp->user;
     $newRoom = new Room();
     $newRoom->name = strtolower(Str::random(10));
     if ($newRoom->save()) {
         $connection->callResult($id, $newRoom->toArray());
     } else {
         $connection->callError($id, $topic, $newRoom->validationErrors->first('name'));
     }
 }