/** * @todo Search city by name * * @param \Illuminate\Http\Request $request * * @return \Illuminate\Http\JsonResponse */ public function ajaxSearchLocation(Request $request) { //Only accept ajax request if ($request->ajax()) { $city_name = $request->get('location_keyword'); $results = locations(trim($city_name)); return pong(1, ['data' => $results]); } }
<?php // locations.php // allows the user to add a new site if (!isset($inIndex) || !$inIndex) { include "../../redirect.php"; } elseif (!$loggedUser) { throw new Exception(LangException002); } else { locations(); } function locations() { global $baseURL, $loggedUser, $loggedUserName, $sites, $objLocation, $objObserver, $objPresentations, $objUtil; $sort = $objUtil->checkRequestKey('sort', 'name'); $sites = $objLocation->getSortedLocations($sort, $loggedUser); echo "<div id=\"main\">"; echo "<h4>" . LangOverviewSiteTitle . " " . $loggedUserName . "</h4>"; echo "<hr />"; echo "<form role=\"form\" action=\"" . $baseURL . "index.php\" method=\"post\"><div>"; echo "<input type=\"hidden\" name=\"indexAction\" value=\"add_location\" />"; echo "<input type=\"submit\" class=\"btn btn-success pull-right tour4\" name=\"add\" value=\"" . LangAddSiteButton . "\" /> "; echo "</form>"; $objLocation->showLocationsObserver(); echo "<br /><br />"; echo "</div></form>"; echo "</div>"; }
function province($id) { $locations = locations(); foreach ($locations['province'] as $province) { if ($province['id'] == $id) { return $province['name']; } } return null; }
public function province_and_city() { return ss(locations()); }