function fest_allRestaurantsInCuisine() { //Arrange $cuisine = "Pizza"; $test_cuisine = new Cuisine($cuisine); $test_cuisine->save(); $cuisine = "Burgers"; $test_cuisine2 = new Cuisine($cuisine); $test_cuisine2->save(); $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(); $restaurant_name = "Spankys"; $cuisine_type = 2; $restaurant_phone = "8015715713"; $restaurant_address = "379 E 3333 S"; $test_next_Restaurant = new Restaurant($restaurant_name, $cuisine_type, $restaurant_phone, $restaurant_address); $test_next_Restaurant->save(); $restaurant_name = "Dave & Busters"; $cuisine_type = 1; $restaurant_phone = "44444444"; $restaurant_address = "HELL"; $test_third_restaurant = new Restaurant($restaurant_name, $cuisine_type, $restaurant_phone, $restaurant_address); $test_third_restaurant->save(); //Act $result = Cuisine::getRestaurants(); //Assert $this->assertEquals([$test_Restaurant, $test_third_restaurant], $result); }
function test_GetRestaurants() { //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(); $id = 1; $test_restaurant = new Restaurant($restaurant, $address, $phone, $cuisine_id, $id); $test_restaurant->save(); $restaurant2 = "Aalto"; $address2 = "123 Belmont"; $phone2 = "123-456-7890"; $cuisine_id2 = $test_cuisine->getId(); $id = 2; $test_restaurant2 = new Restaurant($restaurant, $address, $phone, $cuisine_id, $id); $test_restaurant2->save(); //Act $result = $test_cuisine->getRestaurants(); //Assert $this->assertEquals([$test_restaurant, $test_restaurant2], $result); }
function createTableRow(Restaurant $rest) { print "<tr>\n"; print "<td>" . $rest->getRestName() . "</td>\n"; print "<td>" . $rest->getCuisName() . "</td>\n"; print "<td>" . $rest->getCityName() . "</td>\n"; print "<td>" . $rest->getPrngName() . "</td>\n"; print "</tr>\n"; }
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 run() { $faker = Faker::create(); foreach (range(1, 10) as $index) { Restaurant::create(['name' => $faker->company, 'latitude' => $faker->randomFloat(5, -90, 90), 'longitude' => $faker->randomFloat(5, -180, 180)]); } }
public function testAddRestaurant() { $myRest = new Restaurant("23", "12", true, "Rue du test unitaire", "AGILE", "Superbe resto qui s'emmerde a faire des tests unitaire.", "Unit tests", "32456", "http://www.facebook.com"); $objectId = $myRest->add(); $query = new ParseQuery("Restaurant"); $query->equalTo("objectId", $objectId); $results = $query->find(); $this->assertEquals(1, count($results)); $resto = $results[0]; $this->assertEquals("Rue du test unitaire", $resto->get("address")); $this->assertEquals("AGILE", $resto->get("city")); $this->assertEquals("Superbe resto qui s'emmerde a faire des tests unitaire.", $resto->get("description")); $this->assertEquals("Unit tests", $resto->get("name")); $this->assertEquals("32456", $resto->get("postal")); $this->assertEquals("http://www.facebook.com", $resto->get("website")); }
public function productos($mozos = null) { $recordFinder = new AsyncRecordFinder('Buscar Producto', Restaurant::getInstance()->productos()); $recordFinder->addSearchFieldFree('codigo', 'Codigo'); $recordFinder->addSearchFieldFree('nombre', 'Nombre'); $recordFinder->addTitleField('codigo', 'Codigo'); $recordFinder->addTitleField('nombre', 'Nombre'); return $recordFinder->generateXmlConfiguration(); }
function delete() { $restaurants = Restaurant::getAll(); foreach ($restaurants as $restaurant) { if ($restaurant->getCuisineId() == $this->getId()) { $restaurant->delete(); } } $GLOBALS['DB']->exec("DELETE FROM cuisines WHERE id = {$this->getId()};"); }
static function find($search_id) { $found_restaurant = null; $restaurants = Restaurant::getAll(); foreach ($restaurants as $restaurant) { $restaurant_id = $restaurant->getId(); if ($restaurant_id == $search_id) { $found_restaurant = $restaurant; } } return $found_restaurant; }
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); }
public function restaurantInfo() { $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; } return \View::make('restaurant.edit')->withRestaurantName($restaurant_name)->withRestaurantStreet_1($restaurant_street_1)->withRestaurantStreet_2($restaurant_street_2)->withRestaurantPhone($restaurant_phone)->withRestaurantEmail($restaurant_email); }
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); }
public function buildAtms($xml) { $pageOffset = (string) $xml->PageOffset; $totalCount = (string) $xml->TotalCount; $restaurantArray = array(); foreach ($xml->Restaurant as $restaurant) { $tmpRestaurant = new Restaurant(); $tmpRestaurant->setId((string) $restaurant->Id); $tmpRestaurant->setName((string) $restaurant->Name); $tmpRestaurant->setWebsiteUrl((string) $restaurant->WebsiteUrl); $tmpRestaurant->setPhoneNumber((string) $restaurant->PhoneNumber); $tmpRestaurant->setCategory((string) $restaurant->Category); $tmpRestaurant->setLocalFavoriteInd((string) $restaurant->LocalFavoriteInd); $tmpRestaurant->setHiddenGemInd((string) $restaurant->HiddenGemInd); $tmpLocation = new Location(); $location = $restaurant->Location; $tmpLocation->setName((string) $location->Name); $tmpLocation->setDistance((string) $location->Distance); $tmpLocation->setDistanceUnit((string) $location->DistanceUnit); $tmpAddress = new Address(); $address = $location->Address; $tmpAddress->setLine1((string) $address->Line1); $tmpAddress->setLine2((string) $address->Line2); $tmpAddress->setCity((string) $address->City); $tmpAddress->setPostalCode((string) $address->PostCode); $tmpCountry = new Country(); $tmpCountry->setName((string) $address->Country->Name); $tmpCountry->setCode((string) $address->Country->Code); $tmpCountrySubdivision = new CountrySubdivision(); $tmpCountrySubdivision->setName((string) $address->CountrySubdivision->Name); $tmpCountrySubdivision->setCode((string) $address->CountrySubdivision->Code); $tmpAddress->setCountry($tmpCountry); $tmpAddress->setCountrySubdivision($tmpCountrySubdivision); $tmpPoint = new Point(); $point = $location->Point; $tmpPoint->setLatitude((string) $point->Latitude); $tmpPoint->setLongitude((string) $point->Longitude); $tmpLocation->setPoint($tmpPoint); $tmpLocation->setAddress($tmpAddress); $tmpRestaurant->setLocation($tmpLocation); array_push($restaurantArray, $tmpRestaurant); } $restaurants = new Restaurants($pageOffset, $totalCount, $restaurantArray); return $restaurants; }
/** * abre la mesa y setea el mozo * @param Mozo $mozo */ public function abrir($mozo) { //$this->getPedido()->vaciar(); if (!$this->getEstado()->equals(EstadoMesa::abierta())) { $this->setFechaAbierta(DateUtil::formatAsTimeStamp(time())); $this->setearMozoYEstado($mozo, EstadoMesa::abierta()); $pedido = new Pedido(); //$pedido->setNumero(21);//clase aca //$pedido->setFecha($this->getFechaAbierta()); $restaurant = Restaurant::getInstance()->agregarPedido($pedido); $pedido->save(); $this->setPedido($pedido); return true; } return false; }
public function construct() { if ($this->isNew()) { try { parent::construct(); $this->setEstado(EstadoPedido::pendiente()); $this->setFecha(DateUtil::formatAsTimeStamp(time())); $this->setNumero(Restaurant::getInstance()->pedidos()->count() + 1); } catch (Exception $e) { /** * This try/catch clause is necessary to prevent the Doctrine data loader command from * failing. * */ } } }
<?php global $global_params; global $page_params; $page_params['page_title'] = "Feedback"; $pageArgs = $global_params['page_arguments']; $users = new Users(); $restObj = new Restaurant(); $restId = $_SESSION[SESSION_REST_ID]; $seatedCusts = $restObj->getSeatedCustsHtml($restId);
function testDeleteCuisineRestaurants() { //Arrange $flavor = "Pizza"; $id = null; $test_cuisine = new Cuisine($flavor, $id); $test_cuisine->save(); $name = "Pizza Party"; $phone_number = "123-123-1234"; $address = "1234 Pepporoni Lane"; $cuisine_id = $test_cuisine->getId(); $test_restaurant = new Restaurant($name, $phone_number, $address, $id, $cuisine_id); $test_restaurant->save(); //Act $test_cuisine->delete(); //Assert $this->assertEquals([], Restaurant::getAll()); }
public function getOffTimes($request) { if ($this->checkDetails($request)) { $restObject = new Restaurant(); $array = $restObject->getOfficialTime($request["restaurantID"]); return $array; } }
} catch (Exception $e) { $errormessage = $e->getMessage(); trigger_error($errormessage, E_USER_WARNING); $formmessage = $errormessage; $formmessageclass = 'red'; break; } } else { header("Location: logout"); exit; } } } while (1 == 0); try { include "common/token.php"; $restaurant = Restaurant::get($restaurantid, $userid); $publish = $restaurant->getProperty('publish'); $restaurantname = $restaurant->getProperty('name'); $restaurantwebsite = $restaurant->getProperty('website'); $cuisineid = $restaurant->getProperty('cuisineid'); } catch (Exception $e) { trigger_error($e->getMessage(), E_USER_WARNING); header("Location: restaurants"); exit; } ?> <body> <?php include "topnavbar.php"; include "restohierarchy.php"; $hierarchy[RESTAURANT] = array('id' => $restaurantid, 'name' => $restaurantname);
function test_deleteReviews() { $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(); $user = "******"; $stars = 3; $headline = "It is aight."; $body = "Yeah, pretty aight bro"; $restaurant_id = $test_restaurant->getId(); $test_review = new Review($user, $stars, $headline, $body, $restaurant_id); $test_review->save(); $user2 = "6969babygirl"; $stars2 = 3; $headline2 = "XOXO"; $body2 = "I cant even"; $restaurant_id2 = $test_restaurant->getId(); $test_review2 = new Review($user2, $stars2, $headline2, $body2, $restaurant_id2); $test_review2->save(); $test_restaurant->delete(); $result = Review::getAll(); //var_dump($result); $this->assertEquals([], $result); }
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); }
/** * @Route("/edit/{id}", methods={"GET"}, name="restaurantedit") */ public function editAction($id) { $entity = Restaurant::findFirstByid($id); $address_entity = Address::findFirstByid($entity->getAddressid()); $this->get_assets(); $this->view->id = $entity->id; $this->view->title = $this->crud_params['edit_title']; $this->view->routeform = $this->crud_params['save_route'] . $id; $addressobj = new AddressController(); $this->view->countries_data = $addressobj->get_country_data(); $this->view->logo_path = $entity->logo_path; $this->view->mode = 'edit'; $this->tag->setDefault("name", $entity->getName()); $this->tag->setDefault("rest_address", $address_entity->getDescription()); $this->view->pick('restaurant/addedit'); $address_data = '{ "countryid":"' . $address_entity->getCountryid() . '"' . ',"cityid":"' . $address_entity->getCityid() . '"' . ',"stateid":"' . $address_entity->getStateid() . '"' . ',"townshipid":"' . $address_entity->getTownshipid() . '"' . ',"neighborhoodid":"' . $address_entity->getNeighborhoodid() . '"' . ',"address":"' . $address_entity->getAddress() . '"' . '}'; $this->tag->setDefault("addressid", $address_data); $this->tag->setDefault("phone", $entity->getPhone()); $this->tag->setDefault("email", $entity->getEmail()); $this->tag->setDefault("website", $entity->getWebsite()); $this->tag->setDefault("logo", $entity->getLogoPath()); $this->view->images = $this->get_logo_images(); }
function test_cuisine_delete() { $style = "Thai"; $test_cuisine = new Cuisine($style); $test_cuisine->save(); $style2 = "burgers"; $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 = "Dicks"; $category_id2 = $test_cuisine2->getId(); $test_restaurant2 = new Restaurant($name2, $category_id2); $test_restaurant2->save(); //Act $test_cuisine->delete(); //Assert $this->assertEquals([$test_restaurant2], Restaurant::getAll()); }
function test_save() { $restaurant = new Restaurant("Pok Pok", 2, "5", "1", "website", 2); $name = "Bob"; $id = null; $rating = 3; $review_text = "B"; $review_date = "2015-10-10"; $restaurant_id = $restaurant->getId(); $test_Review = new Review($name, $id, $rating, $review_text, $review_date, $restaurant_id); $test_Review->save(); $result = Review::getAll(); $this->assertEquals($test_Review, $result[0]); }
</div> </div> <div> <div class="checkbox-wrapper"><input type="checkbox" name="delievery" value="true" /> Home Delievery</div> <div class="checkbox-wrapper"><input type="checkbox" name="pureveg" value="true" /> Pure Vegetarian</div> <div class="checkbox-wrapper"><input type="checkbox" name="reservation" value="true" /> Takes Reservations</div> </div> <div class="single-block"> <a href="#" class="button black">Filter</a> </div> </div> </div> <?php while ($reco = mysql_fetch_array($results)) { $restaurant = new Restaurant($reco['resId']); $cuisines = $restaurant->getCuisines(); $categories = $restaurant->getCategories(); ?> <div class="item normal" data-order='1'> <!--BEGIN .hentry --> <div class="hentry"> <!--BEGIN .featured-image --> <div class="featured-image"> <a href="#"><img src="http://demo.designerthemes.com/construct/files/2011/04/3995799932_8fed63e2fc_o1-300x180.jpg" width="300" height="180" alt="" /></a> <!--END .featured-image --> </div>
static function search($search_name) { $found_restaurants = array(); $restaurants = Restaurant::getAll(); foreach ($restaurants as $restaurant) { $restaurant_name = $restaurant->getName(); if ($restaurant_name == $search_name) { array_push($found_restaurants, $restaurant); } } return $found_restaurants; }
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 testGetRestaurants() { $type = "Thai"; $id = null; $test_Cuisine = new Cuisine($type, $id); $test_Cuisine->save(); $test_Restaurant = new Restaurant("Pok Pok", $id, "555-456-2345", "123 abcd street", "http://www.helloworld.com", $test_Cuisine->getId()); $test_Restaurant->save(); $test_Restaurant2 = new Restaurant("Whiskey Soda Lounge", $id, "555-555-5555", "678 DEF street", "http://www.pokpok.com", $test_Cuisine->getId()); $test_Restaurant2->save(); $result = $test_Cuisine->getRestaurants(); $this->assertEquals([$test_Restaurant, $test_Restaurant2], $result); }
require_once "classes/Restaurant.class.php"; require_once "classes/DBUtils.class.php"; $restaurant_id = isValidID($_GET['restaurant_id']) ? $_GET['restaurant_id'] : 0; if ($restaurant_id && !$SMObj->checkAccessLevel("EDITOR")) { // Figure out who the owner of this restaurant is, Editors can edit anyones items $sql = "SELECT restaurant_user FROM {$db_table_restaurants} WHERE restaurant_id = " . $DB_LINK->addq($restaurant_id, get_magic_quotes_gpc()); $rc = $DB_LINK->Execute($sql); // If the recipe is owned by someone else then do not allow editing if ($rc->fields['restaurant_user'] != "" && $rc->fields['restaurant_user'] != $SMObj->getUserID()) { die($LangUI->_('You are not the owner of this restaurant, you are not allowed to delete it')); } } // clean up the old picture if we are suppose to if ($g_rb_database_type == "postgres") { $sql = "SELECT restaurant_picture FROM {$db_table_restaurants} WHERE restaurant_id=" . $DB_LINK->addq($restaurant_id, get_magic_quotes_gpc()); $rc = $DB_LINK->Execute($sql); if (trim($rc->fields['restaurant_picture']) != "") { $rc = $DB_LINK->BlobDelete($rc->fields['restaurant_picture']); DBUtils::checkResult($rc, $LangUI->_('Picture successfully deleted'), NULL, $sql); } } // In Postgres everything will be cleaned up with one delete $RestaurantObj = new Restaurant($restaurant_id); $RestaurantObj->delete(); ?> <I><?php echo $LangUI->_('Restaurant Deleted'); ?> </I> <P>
$server = 'mysql:host=localhost;dbname=best_restaurants'; $username = '******'; $password = '******'; //setting up connection to our database $DB = new PDO($server, $username, $password); $app->register(new Silex\Provider\TwigServiceProvider(), array('twig.path' => __DIR__ . '/../views')); use Symfony\Component\HttpFoundation\Request; Request::enableHttpMethodParameterOverride(); $app->get("/", function () use($app) { return $app['twig']->render('index.html.twig', array('cuisines' => Cuisine::getAll())); }); $app->post("/restaurants", function () use($app) { $name = $_POST['name']; $cuisine_id = $_POST['cuisine_id']; $rating = $_POST['rating']; $restaurant = new Restaurant($_POST['name'], $id = null, $cuisine_id, $_POST['rating']); $restaurant->save(); $cuisine = Cuisine::find($cuisine_id); return $app['twig']->render('cuisine.html.twig', array('cuisine' => $cuisine, 'restaurants' => $cuisine->getRestaurants())); }); $app->post("/delete_restaurants", function () use($app) { Restaurant::deleteAll(); return $app['twig']->render('index.html.twig', array('cuisines' => Cuisine::getAll())); }); $app->get("/cuisines/{id}", function ($id) use($app) { $cuisine = Cuisine::find($id); return $app['twig']->render('cuisine.html.twig', array('cuisine' => $cuisine, 'restaurants' => $cuisine->getRestaurants())); }); $app->post("/cuisines", function () use($app) { $cuisine = new Cuisine($_POST['name']); $cuisine->save();