outlet-address.blade.php 18 KB

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