outlet-address.blade.php_27april 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439
  1. @extends('layouts.app')
  2. @section('page-title')| Outlet - Address @endsection
  3. @section('content')
  4. <link href="{!! env('APP_ASSETS') !!}/vendor_components/dropzone/dropzone.css" rel="stylesheet"/>
  5. <link href="{!! env('APP_ASSETS') !!}/vendor_components/bootstrap-tagsinput/dist/bootstrap-tagsinput.css" rel="stylesheet"/>
  6. <style>
  7. .content{
  8. padding: 0;
  9. }
  10. .bootstrap-tagsinput {
  11. min-height: 60px; width: 100%;
  12. }
  13. h4{ margin-top: 40px}
  14. #map{
  15. width: 100%; height: 500px;
  16. }
  17. .form-control, .form-select {
  18. height: 46px !important;
  19. border-color: #E4E6EB !important;
  20. border-radius: 7px !important;
  21. }
  22. .vtabs .tab-content {
  23. display: block;}
  24. #pac-input{
  25. position: absolute;
  26. z-index: 9;
  27. top: 26px !important;
  28. right: 0px;
  29. left: 20px !important;
  30. width: 95%;
  31. }
  32. .search-location{
  33. position: absolute;
  34. right: -79px !important;
  35. top: 48px;
  36. z-index: 88;
  37. font-size: 20px;
  38. }
  39. .centerMarker{
  40. position:absolute;
  41. /*url of the marker*/
  42. background:url({!! env('APP_ASSETS') !!}images/marker.png) no-repeat;
  43. /*center the marker*/
  44. top:49%;left:47%;
  45. z-index:1;
  46. /*fix offset when needed*/
  47. margin-left:-10px;
  48. margin-top:-34px;
  49. /*size of the image*/
  50. height:40px;
  51. width:37px;
  52. cursor:pointer;
  53. }
  54. </style>
  55. <!-- Content Wrapper. Contains page content -->
  56. @php
  57. $resto = \Illuminate\Support\Facades\Auth::user()->restaurants;
  58. $lang = $resto->default_lang;
  59. app()->setLocale($lang);
  60. if(session('app_lang') !==null){
  61. $lang = session('app_lang');
  62. app()->setLocale($lang);
  63. }
  64. $address = isset($resto->places)?$resto->places->place_name:"Baghdad";
  65. if(!empty($outlet->address))
  66. $address = $outlet->address.', '.$outlet->place;
  67. // dd($resto->places->place_name);
  68. @endphp
  69. <div class="content-wrapper">
  70. <div class="container-full">
  71. <!-- Content Header (Page header) -->
  72. {{-- <div class="content-header">
  73. <div class="d-flex align-items-center">
  74. <div class="me-auto">
  75. <h4 class="page-title">Outlets</h4>
  76. <div class="d-inline-block align-items-center">
  77. <nav>
  78. <ol class="breadcrumb">
  79. <li class="breadcrumb-item"><a href="{!! env('APP_URL') !!}dashboard"><i
  80. class="mdi mdi-home-outline"></i></a></li>
  81. <li class="breadcrumb-item active" aria-current="page">Outlets</li>
  82. </ol>
  83. </nav>
  84. </div>
  85. </div>
  86. </div>
  87. </div>--}}
  88. <!-- Main content -->
  89. <section class="content">
  90. <div class="row">
  91. <div class="col-4" style="padding-right: 0;background-color: #F5F5F5">
  92. @include('outlets.outlet-sidebar')
  93. </div>
  94. <div class="col-8">
  95. <form id="save-outlet" method="POST" action="{!! env('APP_URL') !!}save/addrss/outlet" enctype="multipart/form-data">
  96. <input type="hidden" name="lat" value="" />
  97. <input type="hidden" name="lng" value="" />
  98. @csrf
  99. <input type="hidden" value="{!! request()->get('o') !!}" name="unique_id" />
  100. <div class="p-15">
  101. <h4 style="margin-top: 0">Address</h4>
  102. <div class="row position-relative">
  103. <div class="col-10">
  104. <div class="form-group position-relative">
  105. <a href="#!" class="search-location"><i class="fa fa-location-arrow"></i> </a>
  106. <input id="pac-input" class="form-control" type="text" placeholder="Search Box" />
  107. </div>
  108. </div>
  109. <div class="col-12">
  110. <div id="map"></div>
  111. </div>
  112. </div>
  113. <div class="row mt-4">
  114. <div class="col-12">
  115. <div class="form-group">
  116. <label>Address</label>
  117. <input type="text" class="form-control" name="address" value="{!! $outlet->address !!}"
  118. required/>
  119. </div>
  120. </div>
  121. </div>
  122. <div class="row mt-4">
  123. <div class="col-12">
  124. <div class="form-group">
  125. <label>Address (Arabic)</label>
  126. <input type="text" class="form-control" name="address_arabic" value="{!! $outlet->address_arabic !!}"
  127. required/>
  128. </div>
  129. </div>
  130. </div>
  131. <div class="row">
  132. <div class="col-12">
  133. <div class="form-group">
  134. <label>Address Area</label>
  135. <input type="text" class="form-control" value="{!! empty($outlet->place)?(isset($resto->places)?$resto->places->place_name:"Baghdad"):$outlet->place !!}" name="area"
  136. required/>
  137. </div>
  138. </div>
  139. </div>
  140. <a href="#!" class="btn btn-primary save-changes mt-4">Save Changes</a>
  141. </div>
  142. </form>
  143. </div>
  144. </div>
  145. </section>
  146. <!-- /.content -->
  147. </div>
  148. </div>
  149. <!-- /.content-wrapper -->
  150. @endsection
  151. @section('js')
  152. <script>
  153. let map;
  154. var marker_icon = "{!! env('APP_ASSETS') !!}images/marker.png";
  155. var uluru = null;
  156. var address = "{!! $address !!}";
  157. var marker = null;
  158. function initMapMeem() {
  159. geocoder = new google.maps.Geocoder();
  160. //codeAddress(address);
  161. geocoder.geocode({ 'address': address }, function (results, status) {
  162. // console.log(results);
  163. uluru = {lat: results[0].geometry.location.lat (), lng: results[0].geometry.location.lng ()};
  164. // console.log (latLng);
  165. if (status == 'OK') {
  166. map = new google.maps.Map(document.getElementById("map"), {
  167. center: uluru,
  168. zoom: 14,
  169. overviewMapControl: false,
  170. mapTypeControl: false,
  171. streetViewControl: false,
  172. fullScreenControl:false,
  173. disableDefaultUI: true,
  174. });
  175. $('<div/>').addClass('centerMarker').appendTo(map.getDiv())
  176. /*marker = new google.maps.Marker({
  177. position: uluru,
  178. map: map,
  179. icon:marker_icon,
  180. draggable:true
  181. });*/
  182. map_center = map.getCenter();
  183. google.maps.event.addListener(map, 'dragend', function(e) {
  184. map_center = map.getCenter();
  185. geocodePosition(map.getCenter());
  186. var lat = map.getCenter().lat();
  187. var lng = map.getCenter().lng();
  188. $("input[name=lat]").val(lat);
  189. $("input[name=lng]").val(lng);
  190. } );
  191. const input = document.getElementById("pac-input");
  192. const searchBox = new google.maps.places.SearchBox(input);
  193. map.controls[google.maps.ControlPosition.TOP_RIGHT].push(input);
  194. map.addListener("bounds_changed", () => {
  195. searchBox.setBounds(map.getBounds());
  196. });
  197. let markers = [];
  198. searchBox.addListener("places_changed", () => {
  199. const places = searchBox.getPlaces();
  200. if (places.length == 0) {
  201. return;
  202. }
  203. // Clear out the old markers.
  204. markers.forEach((marker) => {
  205. marker.setMap(null);
  206. });
  207. markers = [];
  208. // For each place, get the icon, name and location.
  209. const bounds = new google.maps.LatLngBounds();
  210. places.forEach((place) => {
  211. if (!place.geometry || !place.geometry.location) {
  212. console.log("Returned place contains no geometry");
  213. return;
  214. }
  215. const icon = {
  216. url: place.icon,
  217. size: new google.maps.Size(71, 71),
  218. origin: new google.maps.Point(0, 0),
  219. anchor: new google.maps.Point(17, 34),
  220. scaledSize: new google.maps.Size(25, 25),
  221. };
  222. // Create a marker for each place.
  223. /*marker.setMap(null);
  224. marker = new google.maps.Marker({
  225. map,
  226. marker_icon,
  227. title: place.name,
  228. position: place.geometry.location,
  229. draggable:true
  230. });
  231. markers.push(
  232. marker
  233. );
  234. */
  235. if (place.geometry.viewport) {
  236. // Only geocodes have viewport.
  237. bounds.union(place.geometry.viewport);
  238. } else {
  239. bounds.extend(place.geometry.location);
  240. }
  241. });
  242. google.maps.event.addListener(map, 'dragend', function(e) {
  243. map_center = map.getCenter();
  244. geocodePosition(map.getCenter());
  245. var lat = map.getCenter().lat();
  246. var lng = map.getCenter().lng();
  247. $("input[name=lat]").val(lat);
  248. $("input[name=lng]").val(lng);
  249. } );
  250. map.fitBounds(bounds);
  251. map.setZoom(12);
  252. });
  253. } else {
  254. // alert('Geocode was not successful for the following reason: ' + status);
  255. }
  256. });
  257. console.log(uluru);
  258. }
  259. function geocodePosition(pos) {
  260. geocoder.geocode({
  261. latLng: pos
  262. }, function(responses,status) {
  263. if (responses && responses.length > 0) {
  264. console.log(responses[0]);
  265. var address = (responses[0].formatted_address);
  266. var area = (responses[0].address_components[1].long_name);
  267. $("input[name=address]").val(address);
  268. $("input[name=area]").val(area);
  269. } else {
  270. // alert('Cannot determine address at this location.');
  271. }
  272. });
  273. }
  274. function codeAddress(address) {
  275. geocoder.geocode({ 'address': address }, function (results, status) {
  276. // console.log(results);
  277. uluru = {lat: results[0].geometry.location.lat (), lng: results[0].geometry.location.lng ()};
  278. // console.log (latLng);
  279. if (status == 'OK') {
  280. marker = new google.maps.Marker({
  281. position: uluru,
  282. icon:marker_icon,
  283. animation: google.maps.Animation.DROP,
  284. map: map
  285. });
  286. marker.setMap(map);
  287. // console.log (map);
  288. } else {
  289. // alert('Geocode was not successful for the following reason: ' + status);
  290. }
  291. });
  292. }
  293. $(document).on('pageshow', '#tab-content', function(e, data){
  294. initMap();
  295. });
  296. $(function () {
  297. $("body").on("click",".search-location",function () {
  298. if (navigator.geolocation) {
  299. navigator.geolocation.getCurrentPosition(
  300. (position) => {
  301. const pos = {
  302. lat: position.coords.latitude,
  303. lng: position.coords.longitude,
  304. };
  305. marker.setMap(null);
  306. marker = new google.maps.Marker({
  307. position: pos,
  308. map: map,
  309. icon:marker_icon,
  310. draggable:true
  311. });
  312. map.setCenter(pos);
  313. map_center = map.getCenter();
  314. google.maps.event.addListener(map, 'dragend', function(e) {
  315. geocodePosition(map.getCenter());
  316. var lat = map.getCenter().lat();
  317. var lng = map.getCenter().lng();
  318. $("input[name=lat]").val(lat);
  319. $("input[name=lng]").val(lng);
  320. } );
  321. },
  322. () => {
  323. handleLocationError(true, infoWindow, map.getCenter());
  324. }
  325. );
  326. } else {
  327. // Browser doesn't support Geolocation
  328. handleLocationError(false, infoWindow, map.getCenter());
  329. }
  330. });
  331. $("body").on("click",".save-changes",function () {
  332. /*$.toast({
  333. heading: 'Welcome to my Riday Admin',
  334. text: 'Use the predefined ones, or specify a custom position object.',
  335. position: 'top-right',
  336. loaderBg: '#ff6849',
  337. icon: 'info',
  338. hideAfter: 3000,
  339. stack: 6
  340. });*/
  341. if($("#save-outlet").valid()){
  342. $("#save-outlet").ajaxForm(function (response) {
  343. response = $.parseJSON(response);
  344. if(response.type=="success"){
  345. $.toast({
  346. heading: 'Outlet Update.',
  347. text: response.message,
  348. position: 'top-right',
  349. loaderBg: '#ff6849',
  350. icon: 'success',
  351. hideAfter: 3000,
  352. stack: 1
  353. });
  354. setTimeout(function () {
  355. location.href.reload();
  356. },2000);
  357. }else{
  358. $.toast({
  359. heading: 'Outlet Update.',
  360. text: response.message,
  361. position: 'top-right',
  362. loaderBg: '#ff6849',
  363. icon: 'error',
  364. hideAfter: 3000,
  365. stack: 1
  366. });
  367. }
  368. }).submit();
  369. }
  370. });
  371. })
  372. </script>
  373. <script async defer src="https://maps.googleapis.com/maps/api/js?key=AIzaSyBFh6fzq8G7dgWLfz8kccvTlmPCSI_uWXQ&callback=initMapMeem&language=ar&libraries=places"></script>
  374. @endsection