Пример #1
0
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;
}
 /**
  * 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));
 }
 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' => "*****@*****.**", 'city' => "City", 'county' => "County", 'country' => "UK", 'postcode' => "ab12 4cd", 'postaddress' => 'Test postal address', 'otherinfo' => "Test"));
     $this->assertTrue($reservationdetails->save());
     return $reservationdetails;
 }
 /**
  * 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('新增失敗');
     }
 }
 /**
  * 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;
 }
 /**
  * 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();
 }
 /**
  * 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
0
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;
}
 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
0
 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;
 }
 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
0
 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
0
 /**
  * Execute the console command.
  *
  * @return void
  */
 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;
 }
 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 s**t 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.');
     }
 }
 /**
  * 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());
 }
Пример #16
0
 /**
  * Add a new reservation
  *
  * @param array $data
  * @return int
  */
 public static function addReservation($data)
 {
     if (!empty($data)) {
         $r = new Reservation();
         $r->start_date = $data['startDate'];
         $r->end_date = $data['endDate'];
         $r->User = Doctrine::getTable("User")->find($data['user_id']);
         $r->Aircraft = Doctrine::getTable("Aircraft")->find($data['aircraft']);
         $r->status_id = 1;
         $r->save();
         $r->refresh();
         return $r->id;
     }
 }
<?php

require_once 'VenueDriver.php';
if ($_POST['event'] && $_POST['first'] && $_POST['last'] && $_POST['phone'] && $_POST['email']) {
    // create a new reservation
    $reservation = new Reservation(array('account' => $account_id, 'event' => $_POST['event'], 'first' => $_POST['first'], 'last' => $_POST['last'], 'phone' => $_POST['phone'], 'email' => $_POST['email']));
    $r = $reservation->save();
    ?>
	Thanks.  You're signed up.
<?php 
} else {
    if ($_POST['event']) {
        ?>
		Please provide all required fields.
<?php 
    }
    ?>
	<form action="#" method="post">
		Event: <?php 
    event_select_tag(new reservation(), $venue_id);
    ?>
<br/>
		First:  <input type="text" name="first" /><br />
		Last:  <input type="text" name="last" /><br />
		Phone: <input type="text" name="phone" /><br />
		Email: <input type="text" name="email" /><br />
		<input type="submit" name="submit" value="Make Reservation" />
	</form>
<?php 
}
Пример #18
0
 /**
  *  Gestion des creneaux Off
  *
  *
  */
 public function executeCreneauoff(sfWebRequest $request)
 {
     $this->param = "creneauoff";
     $this->salles = SalleTable::getInstance()->getAllSalles()->execute();
     $this->formDay = new CreneauDayForm();
     $this->formHour = new CreneauHourForm();
     if ($request->isMethod('POST')) {
         if ($request->getParameter('day')) {
             // Le bind ne foncionne pas, donc j'ai du faire les conditions à la main
             $this->errD = array();
             $params = $request->getParameter('CreneauDay');
             $date = date("Y-m-d", strtotime($params['date']));
             if (date("Y-m-d") > $date) {
                 $this->errD[] = "Impossible d'ajouter une journée Off dans le passé";
             }
             if (!isset($params['salles'])) {
                 $this->errD[] = "Aucune salle n'a été séléctionnée";
             }
             // Si il n'y a pas d'erreur
             if (count($this->errD) == 0) {
                 foreach ($params['salles'] as $salle) {
                     $reservation = new Reservation();
                     $reservation->setIdUserReserve($this->getUser()->getGuardUser()->getId());
                     $reservation->setIdAsso(1);
                     // BDE
                     $reservation->setDate($date);
                     $reservation->setHeuredebut('00:00');
                     $reservation->setHeurefin('00:00');
                     $reservation->setAllday(true);
                     $reservation->setActivite('Journée Interdite');
                     $reservation->setEstvalide(true);
                     //$reservation->setCommentaire('Creneau Interdit');
                     $reservation->setIdSalle($salle);
                     $reservation->save();
                 }
             }
         } else {
             if ($request->getParameter('hour')) {
                 if ($request->getParameter('hour')) {
                     $this->errH = array();
                     $params = $request->getParameter('CreneauHour');
                     $date = date("Y-m-d", strtotime($params['date']));
                     if (date("Y-m-d") > $date) {
                         $this->errH[] = "Impossible d'ajouter un horaire Off dans le passé";
                     }
                     if (!isset($params['salles'])) {
                         $this->errH[] = "Aucune salle n'a été séléctionnée";
                     }
                     if ($params['debut']['hour'] >= $params['fin']['hour']) {
                         if ($params['debut']['minute'] >= $params['fin']['hour']) {
                             $this->errH[] = "Horaire de début doit précéder l'horaire de fin";
                         }
                     }
                     if (count($this->errH) == 0) {
                         foreach ($params['salles'] as $salle) {
                             $reservation = new Reservation();
                             $reservation->setIdUserReserve($this->getUser()->getGuardUser()->getId());
                             $reservation->setIdAsso(1);
                             // BDE
                             $reservation->setDate($date);
                             $reservation->setHeuredebut($params['debut']['hour'] . ':' . $params['debut']['minute']);
                             $reservation->setHeurefin($params['fin']['hour'] . ':' . $params['fin']['minute']);
                             $reservation->setAllday(false);
                             $reservation->setActivite('Creneau Interdit');
                             $reservation->setEstvalide(true);
                             //$reservation->setCommentaire('Commentaire');
                             $reservation->setIdSalle($salle);
                             $reservation->save();
                         }
                     }
                 }
             }
         }
     }
 }
Пример #19
0
 public function storeRes()
 {
     $paxMin = Maintenance::where(['name' => 'pax', 'type' => 'min'])->first();
     $paxMax = Maintenance::where(['name' => 'pax', 'type' => 'max'])->first();
     $format = date_format(Carbon::now()->addDays(13), "Y/m/d");
     $dateFromForm = date('Y/m/d', strtotime(Input::get('reservation_start') . ' -1 days'));
     $validator = Validator::make(Input::all(), ['pax' => "max:{$paxMax->value}|min:{$paxMin->value}|integer", 'reservation_start' => 'after:' . $format, 'reservation_end' => 'after:' . $dateFromForm]);
     if ($validator->fails()) {
         //return $validator->messages()->toJson();
         return Redirect::back()->withInput()->withErrors($validator->messages());
     }
     $reservation = new Reservation();
     $reservation->fill(Input::all());
     $reservation->status = 'Payment Pending';
     if ($reservation->save()) {
         $date1 = new DateTime(Input::get('reservation_start'));
         $date2 = new DateTime(Input::get('reservation_end'));
         $diff = $date2->diff($date1)->format("%a");
         $diff += 1;
         $id = Input::get('id');
         $pasta = Menu::where('scat', '=', 'pasta')->get();
         $dessert = Menu::where('scat', '=', 'dessert')->get();
         $bread = Menu::where('scat', '=', 'bread')->get();
         $drink = Menu::where('scat', '=', 'drinks')->get();
         $salad = Menu::where('scat', '=', 'salad')->get();
         $soup = Menu::where('scat', '=', 'soup')->get();
         $vegetable = Menu::where('scat', '=', 'vegetables')->get();
         $chicken = Menu::where('scat', '=', 'chicken')->get();
         $beef = Menu::where('scat', '=', 'beef')->get();
         $fish = Menu::where('scat', '=', 'fish')->get();
         $pork = Menu::where('scat', '=', 'pork')->get();
         $packages = Packages::get();
         $item = Item::all();
         return View::make('admin.reservation_continuation', compact('item', 'packages', 'id', 'diff', 'chicken', 'pork', 'fish', 'beef', 'dessert', 'pasta', 'bread', 'drink', 'salad', 'soup', 'vegetable'));
     }
 }
Пример #20
0
 public function executeValidate(sfWebRequest $request)
 {
     $id = $request->getParameter('id');
     if ($id) {
         $this->forward404Unless($reservation = Doctrine::getTable('Reservation')->find(array($id)), sprintf('Object reservation does not exist (%s).', $id));
     }
     $d = array();
     $d['designation'] = $request->getParameter('designation');
     $d['description'] = $request->getParameter('description');
     $d['type'] = $request->getParameter('type');
     if ($d['type'] == "") {
         $d['type'] = "group";
     }
     $d['public_designation'] = '';
     $d['public_description'] = '';
     $d['public'] = $request->getParameter('public') ? 1 : 0;
     if ($d['public']) {
         $d['public_designation'] = $request->getParameter('public_designation');
         $d['public_description'] = $request->getParameter('public_description');
     }
     switch ($d['type']) {
         case 'group':
             $d['type_id'] = $request->getParameter('type_group');
             break;
         case 'event':
             $d['type_id'] = $request->getParameter('type_event');
             break;
         default:
             $d['type_id'] = $request->getParameter('type_user');
             break;
     }
     // create group if new reservation
     if ($d['type_id'] == "" && $d['type'] == "group") {
         $g = new Groups();
         $g->setName($d['designation']);
         $g->save();
         $d['type_id'] = $g->getId();
     }
     if ($id) {
         $this->update('Reservation', $d, $id);
     } else {
         //$this->insert('Reservation', $d);
         $r = new Reservation();
         $r->setDesignation($d['designation']);
         $r->setDescription($d['description']);
         $r->setType($d['type']);
         $r->setTypeId($d['type_id']);
         $r->setPublic($d['public']);
         $r->setPublicDesignation($d['public_designation']);
         $r->setPublicDescription($d['public_description']);
         $r->save();
         $request->setParameter('id', $r->getId());
     }
     $this->startdate = $request->getParameter('startdate');
     $this->stopdate = $request->getParameter('stopdate');
     if (!$request->getParameter('ajax')) {
         $this->redirect('reservation/list');
     } else {
         if ($id) {
             $this->executeAjaxDetailedReservation($request);
         } else {
             $this->executeAjaxAddPeriod($request);
         }
     }
 }