try {
    $query_tool = new DataAccessLayer();
    $sql = 'select ' . $time_to_slots_hash[$_POST['time']] . ', date, restaurant_id from time_slots_capacity where date = "' . $fields['date_of_reservation'] . '" and restaurant_id = "' . $fields['restaurant_id'] . '"';
    $results = $query_tool->query($sql);
    if ($results->num_rows > 0) {
        $row = $results->fetch_row();
        $previous_capacity = $row[0];
        if ($previous_capacity >= $fields['people_size']) {
            $new_reservation = new Reservation();
            $new_reservation->create($fields);
            $next_capacity = $previous_capacity - $fields['people_size'];
            $sql = 'update time_slots_capacity set ' . $time_to_slots_hash[$_POST['time']] . ' = ' . $next_capacity . ' where date = "' . $fields['date_of_reservation'] . '" and restaurant_id = "' . $fields['restaurant_id'] . '"';
            if ($query_tool->query($sql)) {
                // send email to user to confirm reservation
                $restaurant = new Restaurant();
                $restaurant->find($fields['restaurant_id']);
                $mail = Mail::getInstance();
                $mailto = $_POST['user_email'];
                $subject = 'FineTable - Restaurant Reservation Confirmation!';
                if (isset($_POST['guest_reservation']) && $_POST['guest_reservation'] == 'true') {
                    $body = '
                    <div class="mail-body" style="padding: 20px; border: 5px solid rgb(254, 127, 65); border-radius: 4px; margin: 0 auto; width: 90%;">
                        <p>Hello ' . $_POST['guest_fullname'] . ',</p>
                        <p>Congratulations!</p>
                        <p>You have made a reservation with restaurant: ' . $restaurant->get_restaurant_name() . '.</p>
                        <p>' . $restaurant->get_full_address() . '</p>
                        <p><b>Date: </b>' . $_POST['date'] . '</p>
                        <p><b>Time: </b>' . $_POST['time'] . '</p>
                        <p>If you need to make a change with the reservation, please contact the restaurant at: ' . $restaurant->get_phone() . '</p>
                        <p>Thank you!</p>
                        <p>FineTable team</p>
 function test_find()
 {
     //Arrange
     $name = "American";
     $id = null;
     $test_cuisine = new Cuisine($name, $id);
     $test_cuisine->save();
     $restaurant_name = "VQ";
     $phone = '5032277342';
     $address = "1220 SW 1st Ave, Portland, OR 97204";
     $website = "http://www.veritablequandary.com/";
     $cuisine_id = $test_cuisine->getId();
     $test_restaurant = new Restaurant($restaurant_name, $phone, $address, $website, $cuisine_id);
     $test_restaurant->save();
     $restaurant_name2 = "Hot Lips Pizza";
     $phone2 = '5035952342';
     $address2 = "721 NW 9th Ave #150, Portland, OR 97209";
     $website2 = "http://hotlipspizza.com/";
     $test_restaurant2 = new Restaurant($restaurant_name2, $phone2, $address2, $website2, $cuisine_id);
     $test_restaurant2->save();
     //Act
     $result = Restaurant::find($test_restaurant->getId());
     //Assert
     $this->assertEquals($test_restaurant, $result);
 }
 static function suitableRestaurants($option_ids)
 {
     // get array of all restaurant ids associated with any of the option ids (duplicates included)
     $restaurant_ids_with_duplicates = array();
     foreach ($option_ids as $option_id) {
         $returned_restaurants = $GLOBALS['DB']->query("SELECT restaurants.* FROM options JOIN restaurants_options ON (options.id = restaurants_options.option_id) JOIN restaurants ON (restaurants_options.restaurant_id = restaurants.id) WHERE options.id = {$option_id};");
         foreach ($returned_restaurants as $restaurant) {
             array_push($restaurant_ids_with_duplicates, $restaurant['id']);
         }
     }
     // count duplicates in $search_array_with_duplicates for values equal to the number of elements in the $option_ids array
     $suitable_restaurants = array();
     $options_count = count($option_ids);
     $restaurant_id_duplicates = array_count_values($restaurant_ids_with_duplicates);
     foreach ($restaurant_id_duplicates as $restaurant_id => $count) {
         if ($options_count == $count) {
             $restaurant = Restaurant::find($restaurant_id);
             array_push($suitable_restaurants, $restaurant);
         }
     }
     return $suitable_restaurants;
 }
 function test_find()
 {
     //arrange
     $name = "Taco Hell";
     $id = null;
     $test_restaurant = new Restaurant($name, $id);
     $test_restaurant->save();
     $name2 = "Burger Queen";
     $test_restaurant2 = new Restaurant($name2, $id);
     $test_restaurant2->save();
     //act
     $result = Restaurant::find($test_restaurant2->getId());
     //assert
     $this->assertEquals($test_restaurant2, $result);
 }
Esempio n. 5
0
 public function updateRestaurantInfo()
 {
     $user = \Auth::user();
     $id = $user->user_id;
     $restaurant = \Restaurant::all();
     foreach ($restaurant as $rest) {
         $restaurant_name = $rest->restaurant_name;
         $restaurant_street_1 = $rest->restaurant_street_1;
         $restaurant_street_2 = $rest->restaurant_street_2;
         $restaurant_phone = $rest->restaurant_phone;
         $restaurant_email = $rest->restaurant_email;
         $restaurant_id = $rest->restaurant_info_id;
     }
     \DB::beginTransaction();
     try {
         $statement = \Restaurant::find($restaurant_id);
         $statement->restaurant_name = \Input::get('name');
         $statement->restaurant_street_1 = \Input::get('address1');
         $statement->restaurant_street_2 = \Input::get('address2');
         $statement->restaurant_email = \Input::get('email');
         $statement->restaurant_phone = \Input::get('phone');
         $statement->user_id_fk = $id;
         $statement->save();
     } catch (ValidationException $e) {
         DB::rollback();
         throw $e;
     }
     \DB::commit();
     return \Redirect::to('admin/account/edit/restaurant')->withRestaurantName($restaurant_name)->withRestaurantStreet_1($restaurant_street_1)->withRestaurantStreet_2($restaurant_street_2)->withRestaurantPhone($restaurant_phone)->withRestaurantEmail($restaurant_email)->with('message', '<p class="alert alert-dismissible alert-success alert-link">Saved!' . '</p>');
 }
Esempio n. 6
0
 public function initialize($entity = null, $options = null)
 {
     $restaurant = new Select('restaurantid', Restaurant::find(), array('using' => array('id', 'name'), 'useEmpty' => TRUE, 'emptyText' => $this->di->get('translate')->_('Seleccione un Restaurante')));
     $restaurant->setLabel('Pais');
     $this->add($restaurant);
     $name = new Text('name');
     $name->setLabel('Name');
     $this->add($name);
     $active = new Select("active", array('Y' => $this->di->get('translate')->_('Yes'), 'N' => $this->di->get('translate')->_('No')), array('class' => 'form-control'));
     $active->setLabel('active');
     $this->add($active);
 }
 function test_find()
 {
     //Arrange
     $restaurant_name = "Antoons";
     $cuisine_type = 1;
     $restaurant_phone = "4128675309";
     $restaurant_address = "123 Atwood St";
     $test_Restaurant = new Restaurant($restaurant_name, $cuisine_type, $restaurant_phone, $restaurant_address);
     $test_Restaurant->save();
     //Act
     $result = Restaurant::find($test_Restaurant->getId());
     //Assert
     $this->assertEquals($test_Restaurant, $result);
 }
 public function addReview($data)
 {
     $this->user_id = $data['user_id'];
     $this->restaurant_id = $data['restaurant_id'];
     $this->content = $data['content'];
     $this->rating = $data['rating'];
     $this->created_at = $data['created_at'] = date('Y-m-d H:i:s');
     $this->updated_at = $data['updated_at'] = date('Y-m-d H:i:s');
     if ($this->create($data)) {
         $restaurants = new Restaurant();
         $restaurant = $restaurants->find('id', $this->restaurant_id);
         $review_count = intval($restaurant['review_count']);
         $rating = $review_count * intval($restaurant['rating']) + intval($this->rating);
         $review_count += 1;
         $rating /= $review_count;
         $restaurants->update('id', $this->restaurant_id, ['rating' => $rating, 'review_count' => $review_count]);
         $result['status'] = "success";
         $result['success_text'] = "review added";
     } else {
         $result['status'] = "error";
         $result['error_text'] = "review not added";
     }
     return json_encode($result);
 }
 function test_find()
 {
     //Arrange
     $name = "Drinks";
     $id = null;
     $test_Cuisine = new Cuisine($name, $id);
     $test_Cuisine->save();
     $restaurant = "Aalto";
     $address = "123 Belmont";
     $phone = "123-456-7890";
     $cuisine_id = $test_Cuisine->getId();
     $test_restaurant = new Restaurant($restaurant, $address, $phone, $cuisine_id, $id);
     $test_restaurant->save();
     $restaurant2 = "HobNob";
     $address2 = "999 somewhere";
     $phone2 = "234-555-5555";
     $cuisine_id2 = $test_Cuisine->getId();
     $test_restaurant2 = new Restaurant($restaurant, $address, $phone, $cuisine_id, $id);
     $test_restaurant2->save();
     //Act
     $result = Restaurant::find($test_restaurant->getId());
     //Assert
     $this->assertEquals($test_restaurant, $result);
 }
session_start();
if (empty($_POST)) {
    header('Location: index.php');
} else {
    require_once '../lib/Review.class.php';
    require_once '../lib/User.class.php';
    require_once '../lib/Restaurant.class.php';
    $user_id = $_POST['user_id'];
    $restaurant_id = $_POST['restaurant_id'];
    $rate = $_POST['rating'];
    $content = $_POST['content'];
    $fields = array('user_id' => $user_id, 'restaurant_id' => $restaurant_id, 'rating' => $rate, 'content' => $content);
    try {
        $new_review = new Review();
        $restaurant = new Restaurant();
        if ($restaurant->find($restaurant_id)) {
            $original_rating = $restaurant->get_rating();
            $new_rating = $rate;
            $all_reviews = Review::get_all_reviews_by_restaurant($restaurant_id);
            // var_dump($all_reviews);
            if ($all_reviews) {
                $overall_rate = 0;
                while ($a_review = $all_reviews->fetch_row()) {
                    $overall_rate += $a_review[4];
                }
                $new_rating = ($overall_rate + $rate) / ($all_reviews->num_rows + 1);
            }
            $new_review->create($fields);
            $restaurant->update_rating($new_rating);
            $success = true;
            $message = 'Adding review complete! Your review will be attached to the restaurant page shortly.';
Esempio n. 11
0
 function test_restaurant_find()
 {
     //Arrange
     $style = "Thai";
     $test_cuisine = new Cuisine($style);
     $test_cuisine->save();
     $style2 = "asian fusion";
     $test_cuisine2 = new Cuisine($style2);
     $test_cuisine2->save();
     $name = "Pok Pok";
     $category_id = $test_cuisine->getId();
     $test_restaurant = new Restaurant($name, $category_id);
     $test_restaurant->save();
     $name2 = "Mai Thai";
     $category_id2 = $test_cuisine2->getId();
     $test_restaurant2 = new Restaurant($name2, $category_id2);
     $test_restaurant2->save();
     //Act
     $id = $test_restaurant->getId();
     $result = Restaurant::find($id);
     //Assert
     $this->assertEquals($test_restaurant, $result);
 }
Esempio n. 12
0
<?php

require_once '../classes/session.php';
require_once '../classes/functions.php';
require __DIR__ . '/../vendor/autoload.php';
require_once '../classes/Restaurant.php';
require_once '../classes/User.php';
require_once '../classes/Item.php';
require '../config.php';
require '../classes/boot.php';
$session = new Session();
$session->forceLogin('../index.php');
$user = User::find($session->getUsername());
$rest_id = $_GET['id'];
$items = Item::where("restaurant_id", $rest_id)->get();
$restaurant = Restaurant::find($rest_id);
?>

<?php 
getTemplate(1, 'header', []);
?>

<body ng-app="app">
  <?php 
include './includes/nav.php';
?>
  <div class="customercontainer" ng-controller="PageController">
    <div class="">
      <div class="row">
        <div class="col s12 m6 offset-m1">
          <h4><?php 
Esempio n. 13
0
 function test_find()
 {
     //cuisine
     $name = "Japanese";
     $id = null;
     $test_cuisine = new Cuisine($name, $id);
     $test_cuisine->save();
     //restaurant1
     $name = "Good Fortune";
     $description = "very tasty.";
     $address = "1111 SW 11th Ave";
     $cuisine_id = $test_cuisine->getId();
     $test_restaurant = new Restaurant($name, $id, $cuisine_id, $description, $address);
     $test_restaurant->save();
     //restaurant2
     $name2 = "Good Luck";
     $description2 = "very yummy.";
     $address2 = "2222 SW 12th Ave";
     $cuisine_id = $test_cuisine->getId();
     $test_restaurant2 = new Restaurant($name2, $id, $cuisine_id, $description2, $address2);
     $test_restaurant2->save();
     $id = $test_restaurant->getId();
     $result = Restaurant::find($id);
     $this->assertEquals($test_restaurant, $result);
 }
Esempio n. 14
0
 function test_find()
 {
     //Arrange
     $restaurant_name = "Joes Burgers";
     $restaurant_name2 = "McDonalds";
     $test_Restaurant = new Restaurant($restaurant_name);
     $test_Restaurant->save();
     $test_Restaurant2 = new Restaurant($restaurant_name2);
     $test_Restaurant2->save();
     //Act
     $result = Restaurant::find($test_Restaurant->getId());
     //Assert
     $this->assertEquals($test_Restaurant, $result);
 }
Esempio n. 15
0
    $restaurant = new Restaurant($_POST['name'], $_POST['location'], $_POST['description'], $_POST['price'], $_POST['cuisine_id']);
    $restaurant->save();
    $cuisine = Cuisine::find($restaurant->getCuisineId());
    return $app['twig']->render('cuisine.html.twig', array('cuisine' => $cuisine, 'restaurants' => Restaurant::getAll()));
});
$app->get("/restaurants/{id}", function ($id) use($app) {
    $restaurant = Restaurant::find($id);
    return $app['twig']->render('restaurant.html.twig', array('restaurant' => $restaurant, 'reviews' => Review::getAll()));
});
$app->get("/restaurants/{id}/edit", function ($id) use($app) {
    $restaurant = Restaurant::find($id);
    return $app['twig']->render('restaurant_edit.html.twig', array('restaurant' => $restaurant));
});
$app->patch("/restaurants/{id}", function ($id) use($app) {
    $restaurant = Restaurant::find($id);
    $restaurant->update($_POST['name'], $_POST['location'], $_POST['description'], $_POST['price'], $_POST['cuisine_id']);
    return $app['twig']->render('restaurant.html.twig', array('restaurant' => $restaurant, 'reviews' => Review::getAll()));
});
$app->delete("/restaurants/{id}", function ($id) use($app) {
    $restaurant = Restaurant::find($id);
    $cuisine = Cuisine::find($restaurant->getCuisineId());
    $restaurant->delete();
    return $app['twig']->render('cuisine.html.twig', array('cuisine' => $cuisine, 'restaurants' => Restaurant::getAll()));
});
$app->post("/reviews", function () use($app) {
    $review = new Review($_POST['user'], $_POST['stars'], $_POST['headline'], $_POST['body'], $_POST['restaurant_id']);
    $review->save();
    $restaurant = Restaurant::find($review->getRestaurantId());
    return $app['twig']->render('restaurant.html.twig', array('restaurant' => $restaurant, 'reviews' => Review::getAll()));
});
return $app;
 function test_find()
 {
     //Arrange
     $flavor = "Burgers";
     $id = null;
     $test_cuisine = new Cuisine($flavor, $id);
     $test_cuisine->save();
     $name = "Burger Bash";
     $phone_number = "555-666-7777";
     $address = "8020 Ground Chuck";
     $cuisine_id = $test_cuisine->getId();
     $test_restaurant = new Restaurant($name, $phone_number, $address, $id, $cuisine_id);
     $test_restaurant->save();
     $name2 = "Pizza Party";
     $phone_number2 = "555-666-7747";
     $address2 = "1234 Pepperoni Lane";
     $cuisine_id = $test_cuisine->getId();
     $test_restaurant2 = new Restaurant($name2, $phone_number2, $address2, $id, $cuisine_id);
     $test_restaurant2->save();
     //Act
     $result = Restaurant::find($test_restaurant->getId());
     //Assert
     $this->assertEquals($test_restaurant, $result);
 }
 function testFind()
 {
     //Arrange
     $type = "Italian";
     $id = null;
     $test_cuisine = new Cuisine($type, $id);
     $test_cuisine->save();
     $name = "City Chinese";
     $description = "OK Chinese food";
     $cuisine_id = $test_cuisine->getId();
     $test_restaurant = new Restaurant($description, $id, $cuisine_id, $name);
     $test_restaurant->save();
     $name2 = "City Mexican";
     $description2 = "OK Mexican food";
     $test_restaurant2 = new Restaurant($description2, $id, $cuisine_id, $name2);
     $test_restaurant2->save();
     //Act
     $result = Restaurant::find($test_restaurant->getId());
     //Assert
     $this->assertEquals($test_restaurant, $result);
 }
Esempio n. 18
0
 /**
  * testBehaviorBelongsToFindCallbacks method
  *
  * @return void
  */
 public function testBehaviorBelongsToFindCallbacks()
 {
     $this->skipIf($this->db instanceof Sqlserver, 'This test is not compatible with SQL Server.');
     $conditions = array('order' => 'Apple.id ASC');
     $Apple = new Restaurant();
     $Apple->unbindModel(array('hasMany' => array('Child'), 'hasOne' => array('Sample')), false);
     $expected = $Apple->find('all', $conditions);
     $Apple->unbindModel(array('belongsTo' => array('Parent')));
     $wellBehaved = $Apple->find('all', $conditions);
     $Apple->Parent->Behaviors->load('Test');
     $Apple->unbindModel(array('belongsTo' => array('Parent')));
     $this->assertSame($Apple->find('all', $conditions), $wellBehaved);
     $Apple->Parent->Behaviors->load('Test', array('before' => 'off'));
     $this->assertSame($expected, $Apple->find('all', $conditions));
     $Apple->Parent->Behaviors->load('Test', array('before' => 'test'));
     $this->assertSame($expected, $Apple->find('all', $conditions));
     $Apple->Parent->Behaviors->load('Test', array('before' => 'modify'));
     $expected2 = array(array('Apple' => array('id' => 1), 'Parent' => array('id' => 2, 'name' => 'Bright Red Apple', 'mytime' => '22:57:17')), array('Apple' => array('id' => 2), 'Parent' => array('id' => 1, 'name' => 'Red Apple 1', 'mytime' => '22:57:17')), array('Apple' => array('id' => 3), 'Parent' => array('id' => 2, 'name' => 'Bright Red Apple', 'mytime' => '22:57:17')));
     $result2 = $Apple->find('all', array('fields' => array('Apple.id', 'Parent.id', 'Parent.name', 'Parent.mytime'), 'conditions' => array('Apple.id <' => '4'), 'order' => 'Apple.id ASC'));
     $this->assertEquals($expected2, $result2);
     $Apple->Parent->Behaviors->disable('Test');
     $result = $Apple->find('all', $conditions);
     $this->assertEquals($expected, $result);
     $Apple->Parent->Behaviors->load('Test', array('after' => 'off'));
     $this->assertEquals($expected, $Apple->find('all', $conditions));
     $Apple->Parent->Behaviors->load('Test', array('after' => 'test'));
     $this->assertEquals($expected, $Apple->find('all', $conditions));
     $Apple->Parent->Behaviors->load('Test', array('after' => 'test2'));
     $this->assertEquals($expected, $Apple->find('all', $conditions));
 }
<?php

require_once 'model/session.php';
require_once 'model/order.php';
require_once 'model/restaurant.php';
$session = new Session();
$order = new Order();
$restaurant = new Restaurant();
if (isset($_GET['order-id'])) {
    $getOrder = $order->find('id', $_GET['order-id']);
    $getRestaurant = $restaurant->find('id', $getOrder['restaurant_id']);
    if ($getRestaurant['owner_id'] == $session->get_session_data('id') && $session->get_session_data('user_type') == "restaurant_owner") {
        $status = intval($getOrder['status']) + 1;
        $order->update('id', $_GET['order-id'], ['status' => $status]);
        header('Location: owner-track-order.php');
    } else {
        print_r("Something went wrong");
    }
} else {
    print_r("Something went wrong");
}
 function test_find()
 {
     //Arrange
     $type = "french";
     $id = null;
     $test_cuisine = new Cuisine($type, $id);
     $test_cuisine->save();
     $name = "Petit Provence";
     $phone = "555-555-5555";
     $price = "\$\$";
     $cuisine_id = $test_cuisine->getId();
     $test_restaurant = new Restaurant($name, $phone, $price, $cuisine_id);
     $test_restaurant->save();
     $name2 = "Escargot";
     $phone2 = "666-666-6666";
     $price2 = "\$\$\$";
     $test_restaurant2 = new Restaurant($name2, $phone2, $price2, $cuisine_id);
     $test_restaurant2->save();
     //Act
     $result = Restaurant::find($test_restaurant->getId());
     //Assert
     $this->assertEquals($test_restaurant, $result);
 }
Esempio n. 21
0
    $restaurant = Restaurant::find($id);
    $restaurant->deleteOne();
    return $app['twig']->render('restaurants.html.twig', array('restaurants' => Restaurant::getAll()));
});
//Lists all cuisines and restaurants associated with the cuisines
//Comes from index.html.twig
//goes to post->/cuisine or post->/delete_cuisines or /cuisine/{id}/edit
$app->get("/cuisine", function () use($app) {
    return $app['twig']->render('cuisine.html.twig', array('cuisine' => Cuisine::getAll(), 'restaurants' => Restaurant::getAll()));
});
//Adding a new cuisine instance
//Comes from self, renders to self
$app->post("/cuisine", function () use($app) {
    $id = null;
    $restaurant_id = intval($_POST['restaurant_id']);
    $restaurant_name = Restaurant::find($restaurant_id);
    $cuisine = new Cuisine($_POST['cuisine_name'], $id, $restaurant_id);
    $cuisine->save();
    return $app['twig']->render('cuisine.html.twig', array('cuisine' => Cuisine::getAll(), 'restaurants' => Restaurant::getAll()));
});
//Deletes all cuisines
//Comes from cuisine.html.twig
//Goes to index.html.twig
$app->post("/delete_cuisine", function () use($app) {
    Cuisine::deleteAll();
    return $app['twig']->render('index.html.twig');
});
//Find and return a cuisine to edit
//Comes from cuisine.html.twig
//Goes to cuisine_edit.html.twig to allow for deleting or updating
$app->get("/cuisine/{id}/edit", function ($id) use($app) {
Esempio n. 22
0
    return $app['twig']->render('cuisines.html.twig', array('cuisines' => $cuisine, 'restaurants' => $cuisine->getRestaurants()));
});
//brings user to a page that allows a specific restaurant to be edited
$app->get('/restaurant/{id}/edit', function ($id) use($app) {
    $restaurant = Restaurant::find($id);
    return $app['twig']->render('restaurant_edit.html.twig', array('restaurants' => $restaurant));
});
//posts edited data to the database to update a property in the existing restaurant
$app->patch('/restaurant/{id}', function ($id) use($app) {
    $restaurant = Restaurant::find($id);
    $cuisine = Cuisine::find($_POST['cuisine_id']);
    foreach ($_POST as $key => $value) {
        if (!empty($value)) {
            $restaurant->update($key, $value);
        }
    }
    return $app['twig']->render('cuisines.html.twig', array('cuisines' => $cuisine, 'restaurants' => $cuisine->getRestaurants()));
});
//delete all restaurants in a specific cuisine
$app->post('/delete_restaurants', function () use($app) {
    Restaurant::deleteAll();
    return $app['twig']->render('index.html.twig', array('restaurants' => Restaurant::getAll()));
});
//deletes specific restaurant
$app->delete('/restaurant/{id}', function ($id) use($app) {
    $restaurant = Restaurant::find($id);
    $cuisine = Cuisine::find($_POST['cuisine_id']);
    $restaurant->delete();
    return $app['twig']->render('cuisines.html.twig', array('cuisines' => $cuisine, 'restaurants' => $cuisine->getRestaurants()));
});
return $app;
 function test_find()
 {
     $name = "Asian";
     $id = null;
     $test_cuisine = new Cuisine($name, $id);
     $test_cuisine->save();
     $restaurant_name = "The Golden Duck";
     $location = "898 SW 5th Ave, Portland, OR";
     $description = "A Chill Asian experince";
     $price = "\$\$";
     $cuisine_id = $test_cuisine->getId();
     $test_restaurant = new Restaurant($restaurant_name, $location, $description, $price, $cuisine_id);
     $test_restaurant->save();
     $restaurant_name2 = "The Red Dragon";
     $location2 = "899 SW 5th Ave, Portland, OR";
     $description2 = "A Intense Asian experince";
     $price2 = "\$\$\$";
     $cuisine_id2 = $test_cuisine->getId();
     $test_restaurant2 = new Restaurant($restaurant_name2, $location2, $description2, $price2, $cuisine_id2);
     $test_restaurant2->save();
     $result = Restaurant::find($test_restaurant->getId());
     $this->assertEquals($test_restaurant, $result);
 }
 function test_find()
 {
     //Arrange
     $cuisine_type = "Italian";
     $id = null;
     $test_cuisine = new Cuisine($cuisine_type, $id);
     $test_cuisine->save();
     $name = "Taco Restaurant";
     $phone = "(503) 777-9097";
     $address = "7000 Beaverton Hillsdale HWY, Portland, OR 97221";
     $hours = "7am - 2am";
     $cuisine_id = $test_cuisine->getId();
     $test_restaurant = new Restaurant($id, $name, $phone, $address, $hours, $cuisine_id);
     $test_restaurant->save();
     $name2 = "Olive Garden";
     $phone2 = "(403) 232-1091";
     $address2 = "101 Olive Garden Way, Portland, OR 97221";
     $hours2 = "8am - 10pm";
     $cuisine_id2 = $test_cuisine->getId();
     $test_restaurant2 = new Restaurant($id, $name2, $phone2, $address2, $hours2, $cuisine_id2);
     $test_restaurant2->save();
     //Act
     $result = Restaurant::find($test_restaurant->getId());
     //Assert
     $this->assertEquals($test_restaurant, $result);
 }
Esempio n. 25
0
 function test_find()
 {
     //Arrange
     $test_name = "Toms Tomatos ";
     $test_seats = 15;
     $test_location = "Farmville";
     $test_evenings = true;
     $test_cuisine = new Cuisine("Mexican", true, 1);
     $test_cuisine->save();
     $test_restaurant = new Restaurant($test_name, $test_seats, $test_location, $test_evenings, $test_cuisine->getId());
     $test_restaurant->save();
     //Act
     $result = Restaurant::find($test_restaurant->getId());
     //Assert
     $this->assertEquals($test_restaurant, $result);
 }
Esempio n. 26
0
<?php

if (empty($_GET['restaurant_id'])) {
    header('Location: index.php');
} else {
    require_once '../lib/Restaurant.class.php';
    require_once '../lib/User.class.php';
    require_once '../lib/Review.class.php';
    require_once '../lib/Image.class.php';
    require_once '../lib/helper.functions.php';
    $restaurant = new Restaurant();
    if ($restaurant->find($_GET['restaurant_id'])) {
        $restaurant_info = $restaurant->get_restaurant_info();
        $restaurant_raw_data = $restaurant->get_raw_data();
        $image = new Image();
        if ($image->find($restaurant_info['restaurant_id'])) {
            $image_path = $image->get_medium();
        }
        $review = new Review();
        if ($review->find_reviews_by_restaurant_id($_GET['restaurant_id'])) {
            $reviews_data = $review->get_reviews_raw_data();
        }
    } else {
        header('Location: index.php');
    }
}
require_once '../templates/header.php';
if (isset($_SESSION['login_user_id'])) {
    $current_user_id = $_SESSION['login_user_id'];
}
?>
Esempio n. 27
0
 /**
  * test find('list') method
  *
  * @return void
  */
 public function testFindList()
 {
     $this->loadFixtures('Article', 'Apple', 'Post', 'Author', 'User', 'Comment');
     $TestModel = new Article();
     $TestModel->displayField = 'title';
     $result = $TestModel->find('list', array('order' => 'Article.title ASC'));
     $expected = array(1 => 'First Article', 2 => 'Second Article', 3 => 'Third Article');
     $this->assertEquals($expected, $result);
     $db = ConnectionManager::getDataSource('test');
     if ($db instanceof Mysql) {
         $result = $TestModel->find('list', array('order' => array('FIELD(Article.id, 3, 2) ASC', 'Article.title ASC')));
         $expected = array(1 => 'First Article', 3 => 'Third Article', 2 => 'Second Article');
         $this->assertEquals($expected, $result);
     }
     $result = Hash::combine($TestModel->find('all', array('order' => 'Article.title ASC', 'fields' => array('id', 'title'))), '{n}.Article.id', '{n}.Article.title');
     $expected = array(1 => 'First Article', 2 => 'Second Article', 3 => 'Third Article');
     $this->assertEquals($expected, $result);
     $result = Hash::combine($TestModel->find('all', array('order' => 'Article.title ASC')), '{n}.Article.id', '{n}.Article');
     $expected = array(1 => array('id' => 1, 'user_id' => 1, 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31'), 2 => array('id' => 2, 'user_id' => 3, 'title' => 'Second Article', 'body' => 'Second Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31'), 3 => array('id' => 3, 'user_id' => 1, 'title' => 'Third Article', 'body' => 'Third Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31'));
     $this->assertEquals($expected, $result);
     $result = Hash::combine($TestModel->find('all', array('order' => 'Article.title ASC')), '{n}.Article.id', '{n}.Article', '{n}.Article.user_id');
     $expected = array(1 => array(1 => array('id' => 1, 'user_id' => 1, 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31'), 3 => array('id' => 3, 'user_id' => 1, 'title' => 'Third Article', 'body' => 'Third Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31')), 3 => array(2 => array('id' => 2, 'user_id' => 3, 'title' => 'Second Article', 'body' => 'Second Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31')));
     $this->assertEquals($expected, $result);
     $result = Hash::combine($TestModel->find('all', array('order' => 'Article.title ASC', 'fields' => array('id', 'title', 'user_id'))), '{n}.Article.id', '{n}.Article.title', '{n}.Article.user_id');
     $expected = array(1 => array(1 => 'First Article', 3 => 'Third Article'), 3 => array(2 => 'Second Article'));
     $this->assertEquals($expected, $result);
     $TestModel = new Restaurant();
     $expected = array(1 => 'Red Apple 1', 2 => 'Bright Red Apple', 3 => 'green blue', 4 => 'Test Name', 5 => 'Blue Green', 6 => 'My new apple', 7 => 'Some odd color');
     $this->assertEquals($expected, $TestModel->find('list'));
     $this->assertEquals($expected, $TestModel->Parent->find('list'));
     $TestModel = new Post();
     $result = $TestModel->find('list', array('fields' => 'Post.title'));
     $expected = array(1 => 'First Post', 2 => 'Second Post', 3 => 'Third Post');
     $this->assertEquals($expected, $result);
     $result = $TestModel->find('list', array('fields' => 'title'));
     $expected = array(1 => 'First Post', 2 => 'Second Post', 3 => 'Third Post');
     $this->assertEquals($expected, $result);
     $result = $TestModel->find('list', array('fields' => array('title', 'id')));
     $expected = array('First Post' => '1', 'Second Post' => '2', 'Third Post' => '3');
     $this->assertEquals($expected, $result);
     $result = $TestModel->find('list', array('fields' => array('title', 'id', 'created')));
     $expected = array('2007-03-18 10:39:23' => array('First Post' => '1'), '2007-03-18 10:41:23' => array('Second Post' => '2'), '2007-03-18 10:43:23' => array('Third Post' => '3'));
     $this->assertEquals($expected, $result);
     $result = $TestModel->find('list', array('fields' => array('Post.body')));
     $expected = array(1 => 'First Post Body', 2 => 'Second Post Body', 3 => 'Third Post Body');
     $this->assertEquals($expected, $result);
     $result = $TestModel->find('list', array('fields' => array('Post.title', 'Post.body')));
     $expected = array('First Post' => 'First Post Body', 'Second Post' => 'Second Post Body', 'Third Post' => 'Third Post Body');
     $this->assertEquals($expected, $result);
     $result = $TestModel->find('list', array('fields' => array('Post.id', 'Post.title', 'Author.user'), 'recursive' => 1));
     $expected = array('mariano' => array(1 => 'First Post', 3 => 'Third Post'), 'larry' => array(2 => 'Second Post'));
     $this->assertEquals($expected, $result);
     $TestModel = new User();
     $result = $TestModel->find('list', array('fields' => array('User.user', 'User.password')));
     $expected = array('mariano' => '5f4dcc3b5aa765d61d8327deb882cf99', 'nate' => '5f4dcc3b5aa765d61d8327deb882cf99', 'larry' => '5f4dcc3b5aa765d61d8327deb882cf99', 'garrett' => '5f4dcc3b5aa765d61d8327deb882cf99');
     $this->assertEquals($expected, $result);
     $TestModel = new ModifiedAuthor();
     $result = $TestModel->find('list', array('fields' => array('Author.id', 'Author.user')));
     $expected = array(1 => 'mariano (CakePHP)', 2 => 'nate (CakePHP)', 3 => 'larry (CakePHP)', 4 => 'garrett (CakePHP)');
     $this->assertEquals($expected, $result);
     $TestModel = new Article();
     $TestModel->displayField = 'title';
     $result = $TestModel->find('list', array('conditions' => array('User.user' => 'mariano'), 'recursive' => 0));
     $expected = array(1 => 'First Article', 3 => 'Third Article');
     $this->assertEquals($expected, $result);
 }
 function test_find()
 {
     //Arrange
     $name = "Italian";
     $id = null;
     $test_cuisine = new Cuisine($name, $id);
     $test_cuisine->save();
     $name = "Piazza Italia";
     $rating = 1;
     $cuisine_id = $test_cuisine->getId();
     $test_restaurant = new Restaurant($name, $id, $cuisine_id, $rating);
     $test_restaurant->save();
     $name2 = "Ristorante Roma";
     $rating = 1;
     $test_restaurant2 = new Restaurant($name2, $id, $cuisine_id, $rating);
     $test_restaurant2->save();
     //Act
     $result = Restaurant::find($test_restaurant->getId());
     //Assert
     $this->assertEquals($test_restaurant, $result);
 }
<?php

require_once 'model/session.php';
$session = new Session();
$data = NULL;
$menu_data = [];
if (isset($_GET['id'])) {
    require_once 'model/restaurant.php';
    require_once 'model/menu.php';
    require_once 'model/review.php';
    $restaurant = new Restaurant();
    $menu = new Menu($_GET['id']);
    $review = new Review();
    $data = $restaurant->find('id', $_GET['id']);
    $menu_data = $menu->multipleFind('restaurant_id', $_GET['id']);
    $reviews = $review->showReview($_GET['id']);
    $countReview = $review->find2('user_id', $session->get_session_data('id'), 'restaurant_id', $_GET['id']);
    $countReview = count($countReview);
}
?>

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="utf-8">
	<?php 
include "./include/header.php";
?>
	<title>Restaurant Finder</title>
</head>
<body>