本文整理汇总了PHP中Reservation::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Reservation::save方法的具体用法?PHP Reservation::save怎么用?PHP Reservation::save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Reservation
的用法示例。
在下文中一共展示了Reservation::save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generate_vars
function generate_vars($section, &$vars)
{
$vars['ok'] = false;
$vars['full'] = false;
if (!isset($_GET['match_id']) || !isset($_GET['nombre_billet'])) {
return;
}
$nombre_billet = $_GET['nombre_billet'];
$match = Match::get($_GET['match_id']);
if ($match == null || $nombre_billet <= 0) {
return;
}
if ($match->places < $nombre_billet) {
$vars['full'] = true;
return;
}
$match->places = $match->places - $nombre_billet;
$match->save();
$reservation = new Reservation();
$reservation->utilisateur = $vars['userid'];
$reservation->match_id = $match->id;
$reservation->qte = $nombre_billet;
$reservation->expiration = 'now()';
$reservation->save();
$vars['ok'] = true;
}
示例2: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate()
{
$model = new Reservation();
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if (isset($_POST['Reservation'])) {
$model->attributes = $_POST['Reservation'];
$model->setAttribute('confirmreservation', true);
if ($model->save()) {
Yii::app()->session['reservationid'] = $model->id;
$this->redirect(array('reservationDetails/create'));
}
}
$this->render('create', array('model' => $model));
}
示例3: testCreate
public function testCreate()
{
$connection = Yii::app()->db;
$sql = "delete from reservation";
$command = $connection->createCommand($sql);
$command->execute();
$dateOverlapFromObj = new DateTime();
$dateOverlapFrom = $dateOverlapFromObj->format('Y-m-d');
$reservation = new Reservation();
$reservation->setAttributes(array('roomid' => 1, 'datefrom' => $dateOverlapFrom, 'numberofnights' => 10, 'confirmreservation' => true));
$id = $reservation->save();
$reservationdetails = new Reservationdetails();
$reservationdetails->setAttributes(array('reservationid' => $reservation->getAttribute('id'), 'title' => "Mr", 'firstname' => "John", 'lastname' => "Smith", 'contactnumber' => "0123456789", 'emailaddress' => "john.smith@blankemailaddress.blanky.co.uk", 'city' => "City", 'county' => "County", 'country' => "UK", 'postcode' => "ab12 4cd", 'postaddress' => 'Test postal address', 'otherinfo' => "Test"));
$this->assertTrue($reservationdetails->save());
return $reservationdetails;
}
示例4: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store()
{
//
try {
$reservation = new Reservation();
$reservation->name = Input::get('name');
$reservation->sex = Input::get('sex');
$reservation->phone = Input::get('phone');
$reservation->email = Input::get('email');
$reservation->note = Input::get('note');
$reservation->save();
return View::make('aesthetics.reservations.ok');
} catch (Exception $e) {
return Redirect::back()->withInput()->withErrors('新增失敗');
}
}
示例5: doSave
/**
* 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->aReservation !== null) {
if ($this->aReservation->isModified() || $this->aReservation->isNew()) {
$affectedRows += $this->aReservation->save($con);
}
$this->setReservation($this->aReservation);
}
if ($this->aUser !== null) {
if ($this->aUser->isModified() || $this->aUser->isNew()) {
$affectedRows += $this->aUser->save($con);
}
$this->setUser($this->aUser);
}
if ($this->isNew()) {
$this->modifiedColumns[] = ReservationOtherMembersPeer::ID;
}
// If this object has been modified, then save it to the database.
if ($this->isModified()) {
if ($this->isNew()) {
$pk = ReservationOtherMembersPeer::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 += ReservationOtherMembersPeer::doUpdate($this, $con);
}
$this->resetModified();
// [HL] After being saved an object is no longer 'modified'
}
$this->alreadyInSave = false;
}
return $affectedRows;
}
示例6: store
/**
* Store a newly created resource in storage.
* POST /reservations
*
* @return Response
*/
public function store()
{
$userId = Auth::user()->id;
$tableId = Input::get('table_id');
$day = Input::get('day');
$month = Input::get('month');
$year = Input::get('year');
$time = explode(':', Input::get('time'));
$hour = $time[0];
$minute = $time[1];
$date = Carbon::create($year, $month, $day, $hour, $minute, 0);
$reservation = new Reservation();
$reservation->user_id = $userId;
$reservation->table_id = $tableId;
$reservation->reservation_start = $date;
$reservation->reservation_end = $date->addHours(3);
$reservation->active = 1;
$reservation->save();
}
示例7: postForm
/**
* this method is used to handle AJAX request for form submit
*/
public function postForm()
{
try {
if (!isset($_POST)) {
throw new Exception('Error request [10]');
}
$name = \Arr::get($_POST, 'name', false);
$sex = \Arr::get($_POST, 'sex', 'female');
$phone = \Arr::get($_POST, 'phone', false);
$email = \Arr::get($_POST, 'email', false);
$note = \Arr::get($_POST, 'note', false);
if (empty($name)) {
throw new Exception('Error request [1100]');
}
if (empty($phone)) {
throw new Exception('Error request [1101]');
}
if (empty($email)) {
throw new Exception('Error request [1110]');
} else {
$reg = '/^[_a-z0-9-]+(\\.[_a-z0-9-]+)*@[a-z0-9-]+(\\.[a-z0-9-]+)*(\\.[a-z]{2,4})$/';
if (preg_match($reg, $email) == false) {
throw new Exception('Error request [11101]');
}
}
if (empty($note)) {
throw new Exception('Error request [1101]');
}
$model = new \Reservation();
$model->name = $name;
$model->sex = $sex;
$model->phone = $phone;
$model->email = $email;
$model->note = $note;
if (!$model->save()) {
throw new Exception("Error request [110]");
}
return \Response::json(array('status' => 'ok'));
} catch (Exception $e) {
return \Response::json(array('status' => 'error', 'message' => $e->getMessage()));
}
}
示例8: generate_vars
function generate_vars($section, &$vars)
{
$vars['success'] = false;
if (!$vars['is_logged']) {
return;
}
if (!isset($_GET['id']) || !isset($_GET['i']) || !isset($_GET['j'])) {
return;
}
$id_match = $_GET['id'];
$rangee = $_GET['i'];
$siege = $_GET['j'];
$userid = $vars['userid'];
$reservation = new Reservation();
$reservation->utilisateur = $userid;
$reservation->id_match = $id_match;
$reservation->expiration = 'now()';
$reservation->rangee = $rangee;
$reservation->siege = $siege;
$reservation->save();
$vars['success'] = true;
}
示例9: postCreateReservation
public function postCreateReservation()
{
// $today = date("Y-m-d");
/* validate input */
$validator = Validator::make(Input::all(), array('date' => 'required|date_format:Y-m-d', 'time' => 'required|date_format:H:i', 'numbers' => 'required|integer|between:1,64', 'phonenumber' => 'required'), array('required' => 'The :attribute is required.', 'date.date_format:Y-m-d' => 'The date need to be formatted "dd-mm-yyyy".', 'date.after' => 'You date is invalid.', 'time.date_format:H:i' => 'The time need to be formatted "hh:mm".', 'numbers.integer' => 'We need to know number of people in your reservation.', 'numbers.between:1,64' => 'We can only serve maximum 64 people.'));
/* if validated */
if ($validator->passes()) {
/* get input */
$reservation = new Reservation();
$reservation->user_id = Input::get('user_id');
$reservation->date = Input::get('date');
$reservation->time = Input::get('time');
$reservation->numbers = Input::get('numbers');
$reservation->phonenumber = Input::get('phonenumber');
$reservation->requirements = Input::has('requirements') ? Input::get('requirements') : '';
$reservation->save();
return Response::json(array('message' => array('Your reservation is sent successfully. We will contact with you soon to confirm. Thank you!')), 200);
} else {
$messages = $validator->messages()->all();
return Response::json(array('message' => $messages), 400);
}
// end validation
}
示例10: successAction
public function successAction()
{
$availableid = $this->request->get('availableid', 'int');
$this->view->disable();
$this->response->setContentType('application/Json', 'UTF-8');
$available = Available::findFirst(array('conditions' => 'id=?1', 'bind' => array(1 => $availableid)));
$user = User::findFirst(array('conditions' => 'id=?1', 'bind' => array(1 => $this->session->get('userid'))));
$this->response->setJsonContent($user->toArray());
$reservations = $user->getReservation(array('a_id=:a_id:', 'bind' => array('a_id' => $available->id)));
$count = $reservations->count();
$return = array();
$return['string'] = '不能重复预约';
if ($count != 0) {
$this->response->setJsonContent($return);
} else {
$return['string'] = '预约成功';
$return['availableid'] = $available->id;
$this->response->setJsonContent($return);
$reservation = new Reservation();
$reservation->a_id = $available->id;
$reservation->u_id = $this->session->get('userid');
$reservation->status = '待就诊';
$reservation->borntime = date('Y-m-d H:i:s');
$reservation->save();
}
$this->response->send();
return;
}
示例11: reserve_post
public function reserve_post($id)
{
$property = Property::find($id);
$admin_email = User::find(1)->email;
$developer_email = $property->developer->email;
if (is_null($property)) {
return App::abort(404);
}
$validator = Validator::make(Input::all(), Reservation::$rules);
if ($validator->passes()) {
// REMOVE PROPERTY FROM THE LIST BECAUSE ITS ALREADY BEEN RESERVED
$property->status = 0;
$property->save();
// EMAIL DEVELOPER
$reservation = new Reservation();
$reservation->property_id = $id;
$reservation->firstname = Input::get('firstname');
$reservation->lastname = Input::get('lastname');
$reservation->phone = Input::get('phone');
$reservation->mobile = Input::get('mobile');
$reservation->home_address = Input::get('home_address');
$reservation->work_address = Input::get('work_address');
$reservation->work = Input::get('work');
$reservation->company = Input::get('company');
$reservation->tin_number = Input::get('tin_number');
$reservation->terms = Input::get('terms');
$reservation->email = Input::get('email');
$reservation->unit_type = Input::get('unit_type');
$reservation->save();
// CREATE NEW TRANSACTION
$transaction = new Transaction();
$transaction->reference_number = date('Ymd') . '-' . str_random(5);
$transaction->property_id = $id;
$transaction->reservation_id = $reservation->id;
$transaction->status = 'Pending';
$transaction->amount = $property->reservation_fee;
$transaction->firstname = $reservation->firstname;
$transaction->lastname = $reservation->lastname;
$transaction->contact_number = $reservation->mobile;
$transaction->address = $reservation->home_address;
$transaction->email = $reservation->email;
$transaction->remarks = "Reservation Fee";
$transaction->save();
// GENERATE INVOICE
$html = View::make('admin.transactions.show', compact('transaction'));
$pdf = storage_path() . '/invoices/' . $transaction->reference_number . '.pdf';
$dompdf = new DOMPDF();
$dompdf->load_html($html);
$dompdf->render();
$output = $dompdf->output();
file_put_contents($pdf, $output);
// EMAIL THE INVOICE
$data['transaction'] = $transaction;
Mail::send('mails.default', $data, function ($message) use($transaction, $pdf) {
$message->to($transaction->email)->subject("Your Invoice");
$message->attach($pdf);
});
// EMAIL DEVELOPER AND ADMINISTRATOR
$data['property'] = $property;
$data['firstname'] = Input::get('firstname');
$data['lastname'] = Input::get('lastname');
$data['phone'] = Input::get('phone');
$data['mobile'] = Input::get('mobile');
$data['tin_number'] = Input::get('tin_number');
$data['home_address'] = Input::get('home_address');
$data['work_address'] = Input::get('work_address');
$data['work'] = Input::get('work');
$data['company'] = Input::get('company');
$data['terms'] = Input::get('terms');
$data['email'] = Input::get('email');
$data['unit_type'] = Input::get('unit_type');
Mail::send('mails.reservation', $data, function ($message) use($admin_email, $developer_email) {
$message->to($admin_email, 'Live and Love')->subject('Property Reservation');
if ($developer_email) {
$message->to($developer_email, 'Live and Love')->subject('Property Reservation');
}
});
return Redirect::to('properties/reserve/' . $id)->with('success', 'Email has been sent to administrator. Well send you an invoice for billing the reservation fee.');
} else {
return Redirect::to('properties/reserve/' . $id)->withErrors($validator)->withInput();
}
}
示例12: actionBook
public function actionBook()
{
if (isset($_POST['llegada']) && isset($_POST['salida']) && isset($_POST['maxPersonas']) && isset($_POST['habitaciones']) && isset($_POST['habitacion']) && isset($_POST['total']) && isset($_POST['room']) && floatval($_POST['total']) > 0) {
Yii::app()->session['llegada'] = $_POST['llegada'];
Yii::app()->session['salida'] = $_POST['salida'];
Yii::app()->session['maxPersonas'] = $_POST['maxPersonas'];
Yii::app()->session['habitaciones'] = $_POST['habitaciones'];
Yii::app()->session['habitacion'] = $_POST['habitacion'];
Yii::app()->session['total'] = $_POST['total'];
Yii::app()->session['room'] = $_POST['room'];
if (isset(Yii::app()->user->id)) {
$error = false;
$errors = [];
$roomsToBook = [];
$roomsAvailable = [];
foreach (TypeRoom::model()->findAllByAttributes(array('status' => 'ACTIVE')) as $i => $type) {
$roomsToBook[$type->id] = 0;
$roomsAvailable[$type->id] = Room::model()->countByAttributes(array('type_id' => $type->id, 'status' => 'VACANT'));
}
foreach ($_POST['room'] as $i => $room) {
$roomsToBook[$room]++;
}
foreach ($roomsToBook as $i => $roomToBook) {
if ($roomToBook > 0 && $roomsAvailable[$i] < $roomToBook) {
$errors[$i] = 'no available';
$error = true;
}
}
if ($error) {
Yii::app()->session['noAvailable'] = $errors;
$this->redirect(Yii::app()->request->getBaseUrl(true) . '#reservar');
} else {
$reservation = new Reservation();
$reservation->user_id = Yii::app()->user->id;
$reservation->arrival_date = date('Y-m-d', strtotime($_POST['llegada']));
$reservation->departure_date = date('Y-m-d', strtotime($_POST['salida']));
$reservation->number_people = $_POST['maxPersonas'];
$reservation->booked_date = date('Y-m-d H:i:s');
$reservation->status = 'CREATED';
$reservation->total = $_POST['total'];
if ($reservation->save()) {
foreach ($roomsToBook as $i => $roomToBook) {
if ($roomToBook > 0) {
$rooms_booked = new RoomsBooked();
$rooms_booked->reservation_id = $reservation->id;
$rooms_booked->type_room_id = $i;
$rooms_booked->quantity = $roomToBook;
if (!$rooms_booked->save()) {
$error = true;
break;
}
}
}
if (!$error) {
$this->redirect(Yii::app()->request->getBaseUrl(true) . '/site/pay/' . $reservation->id);
} else {
$this->redirect(Yii::app()->request->getBaseUrl(true) . '#reservar');
}
} else {
$this->redirect(Yii::app()->request->getBaseUrl(true) . '#reservar');
}
}
} else {
$this->redirect(Yii::app()->request->getBaseUrl(true) . '#login/rp');
}
} else {
$this->redirect(Yii::app()->request->getBaseUrl(true) . '#reservar');
}
}
示例13: fire
//.........这里部分代码省略.........
public function fire()
{
$user = User::where('username', '=', $this->option('user'))->first();
if (!isset($user)) {
$this->comment("This user don't exist.");
return;
}
//get things available for reservation and display them
$things = Entity::where('type', '!=', 'amenity')->where('user_id', '=', $user->id)->get();
if (!count($things)) {
$this->comment("There is nothing to be reserved.");
return;
}
foreach ($things as $thing) {
$this->info("{$thing->name} [{$thing->id}]");
}
do {
$present = false;
// ask user which thing he wants to book
$thing_id = $this->ask("Thing id : ");
if (empty($thing_id)) {
$this->comment("Your thing id is invalid");
} else {
for ($i = 0; $i < count($things); $i++) {
if ($things[$i]->id == $thing_id) {
$present = true;
$thing = $things[$i];
}
}
if (!$present) {
$this->comment("Your thing id is invalid");
}
}
} while (empty($thing_id) || !$present);
// get reservation's subject
do {
$subject = $this->ask("Subject : ");
if (empty($subject)) {
$this->comment("Your subject is invalid");
}
} while (empty($subject));
// get reservation's comment
do {
$comment = $this->ask("Comment : ");
if (empty($comment)) {
$this->comment("Your comment is invalid.");
}
} while (empty($comment));
//get reservation's timing
do {
$available = 1;
do {
$valid = true;
$from = strtotime($this->ask("From (d-m-Y H:m) : "));
if (empty($from)) {
$valid = false;
$this->comment("Your value is empty.");
}
if ($from < time()) {
$valid = false;
$this->comment("Your reservation can't start before now.");
}
} while (!$valid);
do {
$valid = true;
$to = strtotime($this->ask("To (d-m-Y H:m) : "));
if (empty($to)) {
$valid = false;
$this->comment("Your value is empty.");
}
if ($to < $from) {
$valid = false;
$this->comment("Your reservation can't end before it start.");
}
$thing_body = json_decode($thing->body);
} while (!$valid);
if (!$this->isAvailable($thing_body->opening_hours, array('from' => $from, 'to' => $to))) {
$available = 0;
$this->comment('The thing is not available at that time');
}
} while (!$available);
//TODO(qkaiser) : verify if room is available
// get reservation's announcement
$announce = explode(",", $this->ask("Announce (names separated by a comma) : "));
// create reservation object and save it to database
$reservation = new Reservation();
$reservation->user_id = $user->id;
$reservation->entity_id = $thing_id;
$reservation->subject = $subject;
$reservation->comment = $comment;
$reservation->from = $from;
$reservation->to = $to;
if (!count($announce[0])) {
$announce = array();
}
$reservation->announce = json_encode($announce);
$reservation->save();
$this->info("Reservation successfully saved");
return;
}
示例14: reserve_post
public function reserve_post($id)
{
// GET THE LAST RESERVATION
$last_user_reservation = Reservation::where('user_id', Sentry::getUser()->id)->orderBy('created_at', 'desc')->first();
if (!is_null($last_user_reservation)) {
$current_time = time();
$last_user_reservation_time = strtotime($last_user_reservation->created_at);
$interval = abs($current_time - $last_user_reservation_time) / 3600;
if ($interval < 15) {
return Redirect::to('clients')->with('info', 'You must wait 15 hours before you can reserve again.');
}
}
if (is_null(Property::find($id))) {
return Redirect::to('properties');
}
$monitoring = Monitoring::where('block', Input::get('block'))->where('lot', Input::get('lot')) - first();
if (!is_null($monitoring) && $monitoring->status == false) {
return Redirect::to('clients')->with('info', 'This slut is not available sorry.');
}
$rules = array('total_contract_price' => 'required', 'reservation_fee' => 'required', 'downpayment' => 'required', 'equity' => 'required', 'total_months' => 'required', 'monthly_fee' => 'required', 'agent_id' => 'required', 'terms' => 'required', 'block' => 'required|numeric', 'lot' => 'required|numeric');
$validator = Validator::make(Input::all(), $rules);
if ($validator->fails()) {
return Redirect::to('clients/reserve/' . $id)->withInput()->withErrors($validator);
} else {
$property = Property::find($id);
$user = $this->user;
// 0. CHANGE PROPERTY STATUS TO 0
$downpayment = intval(Input::get('downpayment')) / 100 * $property->price;
$equity = $property->price - $downpayment - $property->reservation_fee;
$total_months = intval(Input::get('total_months'));
// 1. SAVE TO THE DATABASE
$reservation = new Reservation();
$reservation->property_id = $id;
$reservation->user_id = $this->user->id;
$reservation->agent_id = Input::get('agent_id');
$reservation->total_contract_price = intval(Input::get('total_contract_price'));
$reservation->downpayment = $downpayment;
$reservation->reservation_fee = $property->reservation_fee;
$reservation->block = Input::get('block');
$reservation->lot = Input::get('lot');
// LOANABLE AMOUNT
$reservation->equity = $equity;
$reservation->total_months = $total_months;
$reservation->monthly_fee = $equity / $total_months;
$reservation->terms = Input::get('terms');
//$reservation->unit_type = Input::get('unit_type');
$reservation->save();
// 2. NEW TRANSACTION
$transaction = new Transaction();
$transaction->reference_number = date('Ymd') . '-' . strtoupper(str_random(5));
$transaction->property_id = $id;
$transaction->user_id = $this->user->id;
$transaction->reservation_id = $reservation->id;
$transaction->status = 'Pending';
$transaction->amount = $property->reservation_fee;
$transaction->remarks = "Property Reservation";
$transaction->save();
// UPDATE MONITORING
DB::table('monitorings')->where('block', Input::get('block'))->where('lot', Input::get('lot'))->update(array('status' => false));
// 3.GENERATE INVOICE
$x = View::make('admin.transactions.show', compact('transaction', 'user', 'property'));
$pdf = storage_path() . '/invoices/' . $transaction->reference_number . '.pdf';
$dompdf = new DOMPDF();
$dompdf->load_html($x);
$dompdf->render();
$output = $dompdf->output();
@file_put_contents($pdf, $output);
// 3.1 GENERATE RESERVATION INFORMATION PDF
$y = View::make('admin.reservations.pdf', compact('transaction', 'user', 'reservation', 'property'));
$res = storage_path() . '/reservations/reservation-' . $transaction->reference_number . '.pdf';
$dompdf = new DOMPDF();
$dompdf->load_html($y);
$dompdf->render();
$output = $dompdf->output();
@file_put_contents($res, $output);
// 4. EMAIL DEVELOPER,ADMIN AND BUYER
$admin = User::find(1);
$developer = $property->developer;
$data['transaction'] = $transaction;
Mail::send('mails.default', $data, function ($message) use($transaction, $pdf, $developer, $admin, $res) {
$user = Sentry::getUser();
$message->to($user->email)->subject("Property Reservation Notification");
$message->to($developer->email)->subject("Property Reservation Notification");
$message->to($admin->email)->subject("Property Reservation Notification");
$message->attach($pdf);
$message->attach($res);
});
return Redirect::to('clients')->with('success', 'Your reservation has been sent to administrator for approval.');
}
}
示例15: noReservationsAvailableCase5
/**
* Test to make sure a reservation with a datefrom greater than our existing reservation
* and dateto after our existing reservations dateto cannot be made.
*
* Original Reservation |---------------|
* Case 5 |------------------|
*
* @param Reservation $reservation
* @depends testNoReservationsAvailable
*/
public function noReservationsAvailableCase5($reservation)
{
$newDateFrom = new DateTime();
$newDateFrom = DateTime::createFromFormat('Y-m-d', $this->_dateOverlapFromObj->format('Y-m-d'));
$newDateFrom->add(new DateInterval('P1D'));
$reservation = new Reservation();
$reservation->setAttributes(array('roomid' => 1, 'datefrom' => $newDateFrom->format('Y-m-d'), 'numberofnights' => $this->_numberofnights + 1));
$this->assertFalse($reservation->save());
}