/** * Store a newly created resource in storage. * * @param Request $request * @return Response */ public function store(Request $request) { // $room_type = new RoomType($request->all()); $room_type->save(); return $room_type; }
public function setRoomType($roomType) { if (!RoomType::isValidRoomType($roomType)) { throw new Exception("Room type is not valid."); } $this->roomType = $roomType; }
public function actionIndex() { $criteria = new CDbCriteria(); $criteria->select = '*'; $criteria->order = 'name ASC'; $this->allRec = RoomType::model()->findAll($criteria); $this->render('index'); }
/** * Get the rows for the call sheet by querying the database * @return array ReserverationSheetRows */ private function populateRows() { $roomTypes = RoomType::model()->findAll(); $rows = array(); foreach ($roomTypes as $roomType) { $reservationSheetRow = new ReservationSheetRow(); $reservationSheetRow->populate($roomType, $this->dates); $this->rows[] = $reservationSheetRow; } }
public function testUpdate() { $this->resetRoomTypesTable(); $roomType = new RoomType(); $roomType->setAttributes(array('description' => 'Double Room', 'quantity' => 2)); $this->testAdd(); $roomType->setAttribute('description', 'Tripple Room'); $roomType->save(); $criteria = new CDbCriteria(); $criteria->condition = 'description=:description'; $criteria->params = array(':description' => 'Tripple Room'); $roomType = RoomType::model()->find($criteria); $this->assertNotNull($roomType); }
/** * @param model $reservation * @return boolean True if availble/ false if not */ public function isReservationAvailable($reservation) { $this->_connection = Yii::app()->db; /** * Find the type of room we're trying to reserve. */ $roomType = RoomType::model()->findByPk($reservation->getAttribute('roomid')); if ($roomType === null) { return false; } $this->dropTemporaryTable(); $this->createTemporaryTable(); $this->populateTemporaryTable($reservation->getAttribute('datefrom'), $reservation->getAttribute('dateto')); $this->updateRoomCounts($reservation); $roomCount = $this->findMaxRoomCount(); $reservation->setAttribute('roomsavailable', $roomType->getAttribute('quantity') - $this->findMaxRoomCount()); if ($roomCount >= $roomType->getAttribute('quantity')) { return false; } return true; }
/** * @param Request $request * @return mixed * @return Response */ public function setPriceInRangeForRoomType(Request $request) { $room_type = $request['room_type']; $price = $request['price']; $start_dt = $request['start_dt']; $end_dt = $request['end_dt']; $date = date("Y-m-d", strtotime($start_dt)); $base_room = RoomType::find($room_type); $i = 0; while (strtotime($date) <= strtotime($end_dt)) { $room_day = RoomCalendar::firstOrNew(array('room_type_id' => $room_type, 'day' => $date)); if (!$room_day->id) { $room_day->availability = $base_room->base_availability; } $room_day->rate = $price; $room_day->save(); $date = date("Y-m-d", strtotime("+1 day", strtotime($date))); $i++; } return response("Success updated " . $i . " dates", 200); }
}else{ /* if((!isset($_POST['room']) || (count(array_filter($_POST['room'])) < 1)) && (isset($_SESSION['step_03_completed']) && ($_SESSION['step_03_completed'] == true))){ die(header('Location: ' . DOMAIN . 'dashboard/add-hotel/step-04')); }else */ if(!isset($_POST['room']) || (count(array_filter($_POST['room'])) < 1)){ die(header('Location: ' . $_SESSION['page_url'])); } $room = $_POST['room']; $rType = $room['type']; $rFIds = implode(',', $room['feature']); $rQty = $room['qty']; $rQtyAssigned = $room['qtyAssigned']; $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'];
public function addToCart() { $hot_id = Input::get('hotel_id'); if (Input::has('room_refer_id')) { $room_identity = Input::get('room_refer_id'); $room_identity_array = explode("_", $room_identity); $hotel_id = $room_identity_array[0]; $room_id = $room_identity_array[1]; $room_specification_id = $room_identity_array[2]; $meal_basis_id = $room_identity_array[3]; $room_count = Session::get('room_count'); $hotel_name = Hotel::where('id', $hotel_id)->first()->name; $hotel_address = Hotel::where('id', $hotel_id)->first()->address; $room_name = RoomType::where('id', $room_id)->first()->room_type; $room_specification = RoomSpecification::where('id', $room_specification_id)->first()->room_specification; $meal_basis = MealBasis::where('id', $meal_basis_id)->first()->meal_basis_name; $adult = RoomSpecification::where('id', $room_specification_id)->first()->adults; $child = RoomSpecification::where('id', $room_specification_id)->first()->children; $nights = Session::get('date_gap'); $st_date = date('Y-m-d', strtotime(Session::get('st_date'))); $ed_date = date('Y-m-d', strtotime(Session::get('ed_date'))); $date_count = Voucher::getNights($st_date, $ed_date)->days; //dd($room_id.'/'.$room_specification_id.'/'.$meal_basis_id); $room_rate = Rate::lowestRoomRate($hotel_id, $room_id, $room_specification_id, $meal_basis_id, $st_date, $ed_date); $room_rate_with_tax = Rate::lowestRoomRateWithTax($hotel_id, $room_id, $room_specification_id, $meal_basis_id, $st_date, $ed_date); $room_cost = $room_rate_with_tax * $room_count * $date_count; if (Session::has('market')) { $market = Session::get('market'); } else { $market = 1; } $get_market_details = Market::where('id', $market)->first(); $tax_type = $get_market_details->tax_type; $tax = $get_market_details->tax; $handling_fee_type = $get_market_details->handling_fee_type; $handling_fee = $get_market_details->handling_fee; $supplement_rate = Rate::supplementRate($hotel_id, $room_id, $room_specification_id, $meal_basis_id, $st_date, $ed_date); if ($market == 1) { if ($tax_type == 0) { $total_tax = $room_rate_with_tax / 100 * $tax; } else { $total_tax = $tax; } if ($handling_fee_type == 0) { $total_handling_fee = $room_rate / 100 * $handling_fee; } else { $total_handling_fee = $handling_fee; } $hotel_handling_fee = $total_handling_fee; $hotel_tax = $total_tax; } else { $total_tax = 0; if ($handling_fee_type == 0) { $total_handling_fee = $room_rate / 100 * $handling_fee; } else { $total_handling_fee = $handling_fee; } $hotel_tax = $total_tax; $hotel_handling_fee = $total_handling_fee; } $rate_box_details = array('hotel_id' => $hotel_id, 'hotel_name' => $hotel_name, 'hotel_address' => $hotel_address, 'room_name' => $room_name, 'room_type_id' => $room_id, 'room_specification' => $room_specification, 'room_specification_id' => $room_specification_id, 'meal_basis' => $meal_basis, 'meal_basis_id' => $meal_basis_id, 'room_cost' => $room_cost, 'hotel_tax' => $hotel_tax, 'hotel_handling_fee' => $hotel_handling_fee, 'supplement_rate' => $supplement_rate, 'room_count' => $room_count, 'unit_price' => $room_rate_with_tax, 'hotel_room_price' => $room_rate, 'adult' => $adult, 'child' => $child, 'nights' => $nights, 'room_identity' => $room_identity, 'check_in' => $st_date, 'check_out' => $ed_date, 'unit_cost_price' => (double) $hotel_tax + (double) $room_cost); if (Session::has('rate_box_details_' . $hotel_id)) { $data = Session::get('rate_box_details_' . $hotel_id); $data[$room_identity] = $rate_box_details; } else { $data = []; $data[$room_identity] = $rate_box_details; } Session::put('rate_box_details_' . $hotel_id, $data); } //dd(Session::get('rate_box_details_'.$hotel_id)); return Response::json($hotel_id); }
<?php $category = new Category(); $accTypes = $category->all(); $mainCity = new MainCity(); $mCities = $mainCity->all(); $subCity = new SubCity(); $sCities = $subCity->all(); $hotelFeatureType = new HotelFeatureType(); $hFTypes = $hotelFeatureType->all(); $roomType = new RoomType(); $rTypes = $roomType->all(); $roomFeature = new RoomFeature(); $rFeatures = $roomFeature->all(); if(!isset($_SESSION['step_01_completed']) || $_SESSION['step_01_completed'] != true){ die(header('Location: ' . DOMAIN . 'dashboard/add-hotel/step-01')); } if(isset($_SESSION['hotel_step_error']) && (strlen($_SESSION['hotel_step_error']) > 0)){ ?> <div><?php echo $_SESSION['hotel_step_error']; $_SESSION['hotel_step_error'] = ''; ?></div> <?php } ?> <form action="<?php echo HTTP; ?>dashboard/get_step_02.php" method="post"> <input type="hidden" value="83620581b63ecf30c23cd5f97cc84939" name="csrf"/> <fieldset> <legend>Hotel Registration/Property-details</legend> <h3 class="h3">Hotel facilities</h3> <div class="row"> <div class="col-xs-12"> <h4>Hotel Facilities<span class="text-danger">*</span></h4>
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer the ID of the model to be loaded */ public function loadModel($id) { $model = RoomType::model()->findByPk((int) $id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
public function getType() { return RoomType::getById($this->type); }
<?php echo $form->textField($model, 'audio_zone'); ?> <?php echo $form->error($model, 'audio_zone'); ?> </div> <div class="row"> <?php echo $form->labelEx($model, 'room_type_id'); ?> <?php echo $form->error($model, 'room_type_id'); ?> <?php echo $form->dropDownList($model, 'room_type_id', RoomType::items()); ?> </div> <div class="row buttons"> <?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save'); ?> </div> <?php $this->endWidget(); ?> </div><!-- form -->
function addRoomForm() { //global all variables global $locationForm, $tool; $allRoom = Room::get_rooms(); $roomHeader = array("Room Information"); $roomTitle = array("Name", "Description", "Notes", "Room Number", "Room Type"); //THE CLIENT INFO $roomKey = array("name", "desc", "notes", "num", "type"); $fieldType = array(2 => "text_area", 4 => "drop_down"); $roomHeader = array("New Room Info"); $allRoomTypes = RoomType::get_room_types(); $locationForm->setTitles($roomTitle); $locationForm->setHeadings($roomHeader); $locationForm->setDatabase($roomKey); $locationForm->setAddValue("addRoom"); $locationForm->setType($allRoomTypes); $locationForm->setFieldType($fieldType); echo $locationForm->newLocationForm(); }
/** * Show the form for creating a new resource. * * @return Response */ public function create() { $room_type = new RoomType($request->all()); $room_type->save(); return $room_type; }
$_SESSION['hotel_step_error'] = 'Some error occurred with the submission, please try again.'; die(header('Location: ' . $_SESSION['page_url'])); }else{ $prop = $_POST['prop']; $hotel = new Hotel(); $hotel = $hotel->find($hotel_id); if(!$hotel){ die(header('Location: ' . DOMAIN . '404')); } $memberId = $hotel->member_id; if(!isset($_SESSION['user']['id']) || ($memberId != $_SESSION['user']['id'])){ die(header('Location: ' . DOMAIN . 'dashboard/add-hotel/step-01')); } $toRemove = new Room(); $roomType = new RoomType(); $roomImage = new RoomImage(); $toRemove = $toRemove->find($prop); if(!$toRemove){ die(header('Location: ' . $_SESSION['page_url'])); } if($toRemove->hotel_id != $hotel_id){ die(header('Location: ' . $_SESSION['page_url'])); } $remRoomType = $roomType->find($toRemove->room_type_id); $remRoomType->delete(); $remRoomImage = $roomImage->where('hotel_id', '=', $hotel_id) ->where('room_id', '=', $toRemove->id) ->get(); $delImageIds = []; $delImages = []; foreach($remRoomImage as $remImage){ $delImageIds[] = $remImage->id; $delImages[] = $remImage->image;
public function getRateData($hotelid) { $room_id = Input::get('room_type_id'); $roomspaces = RoomType::with('roomSpecification')->find($room_id); return Response::json(array($roomspaces, MealBasis::all())); }
$form = $this->beginWidget('CActiveForm', array('id' => 'reservation-form')); ?> <fieldset> <legend> <p class="note">Fields with <span class="required">*</span> are required.</p> </legend> <?php echo $form->errorSummary($model, "Sorry we were unable to reserve that room:"); ?> <div class="row"> <?php echo $form->labelEx($model, 'roomid'); ?> <?php echo $form->dropDownList($model, 'roomid', CHtml::listData(RoomType::model()->findAll(), 'id', 'description')); ?> <?php echo $form->error($model, 'roomid'); ?> </div> <div class="row"> <?php echo $form->labelEx($model, 'datefrom'); $this->widget('zii.widgets.jui.CJuiDatePicker', array('attribute' => 'datefrom', 'model' => $model, 'options' => array('dateFormat' => 'yy-mm-dd'), 'htmlOptions' => array('style' => 'height:20px;'))); ?> </div> <div class="row"> <?php $numberOfNights = array(); for ($i = 1; $i <= 30; $i++) {
public function getAdd() { $getHotel = \App\Hotels::orderBy('hotel_name', 'ASC')->where('owner_id', Auth::user()->id)->lists('hotel_name', 'id'); $getRoom = RoomType::orderBy('id', 'ASC')->lists('name', 'id'); return View::make('room.add', compact('getHotel', 'getRoom')); }