outlet-address.blade.php11 18 KB

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