public function getReservation($id) { $reservation = Reservation::find($id); if (!$reservation) { return Redirect::to('admin/reservation'); } $this->layout->body = View::make('admin.reservation')->with('reservation', $reservation); }
public static function cancel_reservation($id) { $user = self::get_user_logged_in(); $reservation = Reservation::find($id); $date_limit = new DateTime(); $date_limit->add(new DateInterval('P1D')); if ($reservation) { if ($reservation->user->id != $user->id && !$user->manager) { Redirect::to(\Slim\Slim::getInstance()->urlFor('reservations_index'), array('message' => 'Varausta ei löydy!', 'error' => true)); } else { if ($reservation->reserved_to <= $date_limit) { Redirect::to(\Slim\Slim::getInstance()->urlFor('reservations_index'), array('message' => 'Varauksen voi peruuttaa viimeistään vuorokautta ennen varauksen ajankohtaa', 'error' => true)); } else { $reservation->delete(); Redirect::to(\Slim\Slim::getInstance()->urlFor('reservations_index'), array('message' => 'Varaus peruutettu!')); } } } else { Redirect::to(\Slim\Slim::getInstance()->urlFor('reservations_index'), array('message' => 'Varausta ei löydy!', 'error' => true)); } }
public function getReserveClose($id = null) { if (!isset($id) or is_null($id)) { return Redirect::to('/admin/reserve'); } $query = Reservation::find($id); if (is_null($query)) { return Redirect::to('/admin/reserve'); } $query->status = 2; $query->save(); return Redirect::to('admin/reserve/' . $id)->with('message', "The reservation has been closed!"); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function delete($id) { $this->reservation->find($id)->delete(); return Redirect::route('admin.reservations.index'); }
/** * Remove the specified resource from storage. * DELETE /reservations/{id} * * @param int $id * @return Response */ public function destroy($id) { Reservation::find($id)->delete(); return Response::json(['data' => 'Reservation deleted'], 200); }
public function updateMenuReservation() { $reservation = Reservation::find(Input::get('id')); if (!$reservation) { return Redirect::back()->withErrors('Could not find reservation.'); } //$reservation->menus()->detach(); //$reservation->items()->detach(); $date1 = new DateTime($reservation->reservation_start); $date2 = new DateTime($reservation->reservation_end); $diff = $date2->diff($date1)->format("%a"); $diff += 1; $date1 = date_format($date1, 'l, jS F Y'); $date2 = date_format($date2, 'l, jS F Y'); $id = Input::get('id'); $total_price = 0; $package_price = 0; $pricezs = 0; $qty = Input::get('quantity'); $model = Input::get('model'); $invid = Input::get('invId'); $pricey = Input::get('pricey'); foreach ($reservation->menu() as $value) { $total_price += $value->price; } foreach ($reservation->item as $value) { } for ($i = 0; $i < count($qty); $i++) { if ($qty[$i] > 0) { $reservation->items()->attach($invid[$i], ['qty' => $qty[$i]]); $pricezs = $pricezs + (int) $pricey[$i] * $qty[$i]; } } for ($index = 1; $index <= $diff; $index++) { if (count(Input::get('menu' . $index)) > 0) { foreach (Input::get('menu' . $index) as $menu) { $reservation->menus()->attach($menu, ['day' => $index]); $price = Menu::find($menu); $total_price += $price->price; } } if (count(Input::get('package' . $index)) > 0) { foreach (Input::get('package' . $index) as $package) { foreach (DB::table('menu_package')->where('package_id', '=', $package)->get() as $fuckage) { $reservation->menus()->attach($fuckage->menu_id, ['day' => $index, 'package' => $package]); } $price = Packages::find($package); $package_price += $price->price; } } } $reservation->net_total = $total_price * $reservation->pax + $package_price + $pricezs; if ($reservation->save()) { return Redirect::back()->with('flash_message', 'Reservation has been saved!'); } else { return Redirect::back()->withErrors('Could not update reservation'); } }
/** * Cancel the reservation with id $id by deleting it from database. * @param $clustername : the cluster's name * @param $id : the reservation's id */ public function deleteReservation(Cluster $cluster, $id) { //TODO cluster not used with a valid cluster anyone can delete any reservation $reservation = Reservation::find($id); if (isset($reservation)) { $reservation->delete(); } else { return $this->_sendErrorMessage(404, "Reservation.NotFound", "Reservation not found."); } }
$rsv_id = 0; $rsv = new Reservation(); try { $rsv_id = $rsv->create($fields); $success = true; $message = 'New reservation creation is complete.<br>'; echo $message; } catch (Exception $e) { $success = false; $message = $e->getMessage(); echo "Creating a new reservation Error: " . $message . "<br>"; } echo ($success == true ? "SUCCESS" : "FAILURE") . "<br>"; try { echo "<br>Testing find reservation:<br>"; $success = $rsv->find($rsv_id); print_r($rsv->get_reservation_info()); echo "<br>"; echo $rsv->get_reservation_info_json(); echo "<br>"; } catch (Exception $e) { $success = false; $message = $e->getMessage(); echo "Find reservation Error: " . $message . "<br>"; } echo ($success == true ? "SUCCESS" : "FAILURE") . "<br>"; try { echo "<br>Testing find reservation by restaurant_id and user_id:<br>"; $success = $rsv->find_by_restaurant_and_user(3, 1, '01-02-2015'); print_r($rsv->get_reservation_info()); echo "<br>";