restaurant_form.blade.php_11 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818
  1. @extends('layouts.app')
  2. @section('css')
  3. <style>
  4. .card-header{
  5. padding:10px 15px; border-radius: 3px
  6. }
  7. .select2-container{width:100% !important}
  8. </style>
  9. @endsection
  10. @php
  11. $resto = \App\Restaurants::find(\App\Helpers\CommonMethods::getRestuarantID());
  12. $lang = $resto->default_lang;
  13. app()->setLocale($lang);
  14. @endphp
  15. @section('content')
  16. <link href="{!! env('APP_ASSETS') !!}vendor_components/spectrum/spectrum.css" rel="stylesheet">
  17. <link href="{!! env('APP_ASSETS') !!}vendor_components/select2/dist/css/select2.min.css" rel="stylesheet">
  18. <link href="{!! env('APP_ASSETS') !!}/vendor_components/bootstrap-tagsinput/dist/bootstrap-tagsinput.css" rel="stylesheet"/>
  19. <style>
  20. .alert {
  21. display: none;
  22. }
  23. .border-red {
  24. border: 1px solid #F00 !important;
  25. }
  26. .tab-pane{}
  27. .container-full,.content-wrapper{
  28. background-color: transparent !important;
  29. }
  30. #image-preview {
  31. width: 700px;
  32. border-radius: 20px;
  33. height: 341px;
  34. position: relative;
  35. overflow: hidden;
  36. background-color: #f9f9f9;
  37. color: #ecf0f1;
  38. background-position: center !important;
  39. background-size: cover !important;
  40. }
  41. #image-preview input {
  42. line-height: 200px;
  43. font-size: 200px;
  44. position: absolute;
  45. opacity: 0;
  46. z-index: 10;
  47. }
  48. #image-preview label {
  49. position: absolute;
  50. z-index: 5;
  51. opacity: 0.8;
  52. cursor: pointer;
  53. background-color: #bdc3c7;
  54. width: 200px;
  55. height: 50px;
  56. font-size: 20px;
  57. line-height: 50px;
  58. text-transform: uppercase;
  59. top: 0;
  60. left: 0;
  61. right: 0;
  62. bottom: 0;
  63. margin: auto;
  64. text-align: center;
  65. }
  66. .select2-container .select2-selection--multiple{
  67. min-height: 46px;
  68. }
  69. .form-control, .form-select {
  70. height: 46px !important;
  71. border-color: #E4E6EB !important;
  72. border-radius: 7px !important;
  73. }
  74. .select2-container--default .select2-selection--single{
  75. height: 40px !important;
  76. border-color: #E4E6EB !important;
  77. border-radius: 7px !important;
  78. padding: 9px 12px;
  79. }
  80. </style>
  81. <div class="content-wrapper">
  82. <div class="container-full">
  83. <section class="content">
  84. @if(isset($restaurant))
  85. <h3 style="margin-left: 10px">{!! $restaurant->name !!}</h3>
  86. @endif
  87. <form id="restaurant-form" method="POST" action="{!! env('APP_URL') !!}restaurant/save"
  88. enctype="multipart/form-data">
  89. @csrf
  90. <input type="hidden" name="id" value="{!! isset($restaurant)?$restaurant->id:'' !!}"/>
  91. <div class="row">
  92. <div class="col-xl-9">
  93. <div class="card mb-4">
  94. <div class="card-header bg-warning"><h4 class="card-title">{{__('label.busniess_information')}}</h4></div>
  95. <div class="card-body">
  96. @if(\Illuminate\Support\Facades\Auth::user()->role=="restaurant")
  97. <div class="row mb-4">
  98. <div class="col-sm-12">
  99. <p style="font-size: 14px">{{__('label.cover_image')}}</p>
  100. <div id="image-preview" @if(isset($restaurant) && isset($restaurant->home_images) && !empty($restaurant->home_images->file_name)) style="background: url({!! $restaurant->home_images->file_name !!})" @endif>
  101. <label for="image-upload" id="image-label">{{__('label.choose_file')}}</label>
  102. <input type="file" name="home_image" id="image-upload" />
  103. </div>
  104. </div>
  105. </div>
  106. @endif
  107. <div class="row">
  108. <div class="col-sm-4 col-md-6">
  109. <div class="form-group">
  110. <label style="font-weight: bold">{{__('label.name_english')}}</label>
  111. <input type="text" class="form-control" placeholder="" name="name"
  112. value="{!! isset($restaurant)?$restaurant->name:'' !!}" required>
  113. </div>
  114. </div>
  115. <div class="col-sm-4 col-md-6">
  116. <div class="form-group">
  117. <label style="font-weight: bold">{{__('label.name_arabic')}}</label>
  118. <input type="text" class="form-control" placeholder="" name="arabic_name"
  119. value="{!! isset($restaurant)?$restaurant->arabic_name:'' !!}" required>
  120. </div>
  121. </div>
  122. </div>
  123. @if(\Illuminate\Support\Facades\Auth::user()->role=="restaurant")
  124. <div class="row">
  125. <div class="col-sm-4 col-md-6">
  126. <div class="form-group">
  127. <label style="font-weight: bold">{{__('label.short_description')}}</label>
  128. <textarea class="form-control" placeholder=""
  129. name="short_description">{!! isset($restaurant)?$restaurant->short_description:'' !!}</textarea>
  130. </div>
  131. </div>
  132. <div class="col-sm-4 col-md-6">
  133. <div class="form-group">
  134. <label style="font-weight: bold">{{__('label.address')}}</label>
  135. <textarea class="form-control" placeholder="" name="address"
  136. required>{!! isset($restaurant)?$restaurant->address:'' !!}</textarea>
  137. </div>
  138. </div>
  139. </div>
  140. @endif
  141. <div class="row">
  142. <div class="col-sm-3 col-md-3">
  143. <div class="form-group">
  144. <label style="font-weight: bold">{{__('label.default_language')}}</label>
  145. <select class="form-select" required name="default_lang">
  146. <option value="">{{__('label.default_language')}}</option>
  147. <option value="ar" @if(isset($restaurant) && $restaurant->default_lang=='ar') selected @endif>{{__('label.arabic')}}</option>
  148. <option value="en" @if(isset($restaurant) && $restaurant->default_lang=='en') selected @endif>{{__('label.english')}}</option>
  149. </select>
  150. </div>
  151. </div>
  152. <div class="col-sm-12 col-md-6">
  153. @php
  154. $multiple_langs = !empty($restaurant->multiple_langs)?explode(',',$restaurant->multiple_langs):[];
  155. $countries = \App\Countries::whereNull('deleted_at')->get();
  156. $outlet_countries = !empty($restaurant->outlet_countries)?explode(',',$restaurant->outlet_countries):[];
  157. @endphp
  158. <label style="font-weight: bold">{{__('label.choose_languages')}}</label> <small><i>({{__('label.languages_supported_in_order_page')}})</i></small><br />
  159. <select class="form-control multiple_langs" multiple required name="multiple_langs[]">
  160. <option @if(isset($restaurant) && in_array('en',$multiple_langs))) selected @endif value="en">{{__('label.arabic')}}</option>
  161. <option @if(isset($restaurant) && in_array('ar',$multiple_langs))) selected @endif value="ar">{{__('label.english')}}</option>
  162. </select>
  163. </div>
  164. <div class="col-sm-12 col-md-3">
  165. <div class="form-group">
  166. <label style="font-weight: bold">{{__('label.country')}}</label>
  167. <select class="form-select" required name="country_id">
  168. <option value="">{{__('label.select_country')}}</option>
  169. @if(isset($countries) && $countries->count() > 0)
  170. @foreach($countries as $country)
  171. <option value="{!! $country->id !!}" @if(isset($restaurant) && $restaurant->country_id==$country->id) selected @endif>{!! $country->country_name !!}</option>
  172. @endforeach
  173. @endif
  174. </select>
  175. </div>
  176. </div>
  177. </div>
  178. @php
  179. @endphp
  180. @if(\Illuminate\Support\Facades\Auth::user()->role=="administrator")
  181. <div class="row">
  182. <div class="col-sm-3 col-md-3">
  183. @if(\Illuminate\Support\Facades\Auth::User()->role=="administrator")
  184. <div class="form-group">
  185. <label style="visibility: hidden; margin-bottom: 15px">{{__('label.default_color_for_order')}}</label><br />
  186. <div class="custom-control custom-checkbox">
  187. <input class="custom-control-input" id="active"
  188. @if(isset($restaurant) && $restaurant->active=="1") checked
  189. @endif name="active" type="checkbox"/>
  190. <label class="custom-control-label" for="active">{{__('label.active')}}</label>
  191. </div>
  192. </div>
  193. @endif
  194. </div>
  195. <div class="col-sm-3 col-md-3">
  196. @if(\Illuminate\Support\Facades\Auth::User()->role=="administrator")
  197. <div class="form-group">
  198. <label style="visibility: hidden; margin-bottom: 15px">{{__('label.default_color_for_order')}}</label><br />
  199. <div class="custom-control custom-checkbox">
  200. <input class="custom-control-input" id="allow_whatsapp_notifications"
  201. @if(isset($restaurant) && $restaurant->allow_whatsapp_notifications=="1") checked
  202. @endif name="allow_whatsapp_notifications" type="checkbox"/>
  203. <label class="custom-control-label" for="allow_whatsapp_notifications">{{__('label.allow_whatsapp_notifications')}}</label>
  204. </div>
  205. </div>
  206. @endif
  207. </div>
  208. </div>
  209. @endif
  210. </div>
  211. </div>
  212. <div class="card mb-4">
  213. <div class="card-header bg-warning"><h4 class="card-title">{{__('label.busniess_meta')}}</h4></div>
  214. <div class="card-body">
  215. <div class="row">
  216. @php
  217. $resto_metas = \App\RestoMetaDefs::where('parent_meta_def_id',0)->get();
  218. //dump($resto_metas);
  219. $existing_resto_meta = [];
  220. if(isset($restaurant))
  221. $existing_resto_meta = \App\RestoMetas::where('bussiness_id',$restaurant->id)->whereNull('outlet_id')->pluck('meta_def_id')->toArray();
  222. $existing_resto_meta = isset($existing_resto_meta )?$existing_resto_meta:[];
  223. $existing_resto_meta_value = null;
  224. if(isset($restaurant))
  225. $existing_resto_meta_value = \App\RestoMetas::where('bussiness_id',$restaurant->id)->whereNull('outlet_id')->get();
  226. $v = [];
  227. if(isset($existing_resto_meta_value) && $existing_resto_meta_value->count() > 0){
  228. foreach($existing_resto_meta_value as $value){
  229. $v[$value->meta_def_id] = $value->meta_val;
  230. }
  231. }
  232. $multiple_options = ['BILLING_GATEWAY'];
  233. @endphp
  234. @if(isset($resto_metas) && $resto_metas->count() > 0)
  235. @foreach($resto_metas as $meta)
  236. @if($meta->for_role==\Illuminate\Support\Facades\Auth::user()->role)
  237. @if(($meta->meta_def_name=="DISPLAY_TAX_INFO" || $meta->meta_def_name=="TERM_AND_CONDITIONS" ) && $restaurant->countries->country_name=="Iraq" ) @continue @endif
  238. <div class="col-md-6">
  239. <div class="form-group">
  240. <label style="font-weight:;font-size:12px">{!! ucwords(str_replace('_',' ',$meta->meta_def_name)) !!}</label>
  241. @if(isset($meta->childern) && $meta->childern->count() > 0)
  242. <select @if(in_array($meta->meta_def_name, $multiple_options)) multiple rel="multiple-option" @endif class="form-control" name="resto_meta[]" @if($meta->is_required=="Yes") required @endif>
  243. <option value="">{{__('label.choose')}} {!! ucwords(strtolower(str_replace('_',' ',$meta->meta_def_name))) !!}</option>
  244. @foreach($meta->childern as $childern)
  245. <option value="{!! $childern->meta_def_id !!}" @if(in_array($childern->meta_def_id,$existing_resto_meta)) selected @endif>{!! $childern->meta_def_name !!}</option>
  246. @endforeach
  247. </select>
  248. @else
  249. <input type="hidden" name="resto_meta[]" value="{!! $meta->meta_def_id !!}">
  250. @if($meta->input_type=="text-field")
  251. <input type="text" class="form-control" name="resto_meta_value[{!! $meta->meta_def_id !!}]" @if(isset($restaurant) && isset($v[$meta->meta_def_id])) value="{!! $v[$meta->meta_def_id] !!}" @endif @if($meta->is_required=="Yes") required @endif placeholder="">
  252. @endif
  253. @if($meta->input_type=="text-area")
  254. <textarea style="height:40px !important" class="form-control" placeholder="{!! $meta->meta_def_desc !!}" name="resto_meta_value[{!! $meta->meta_def_id !!}]" @if($meta->is_required=="Yes") required @endif>{!! isset($v[$meta->meta_def_id])?$v[$meta->meta_def_id]:"" !!}</textarea>
  255. @endif
  256. @endif
  257. </div>
  258. </div>
  259. @endif
  260. @endforeach
  261. @endif
  262. </div>
  263. </div>
  264. </div>
  265. </div>
  266. <div class="col-xl-3">
  267. <div class="card mb-4">
  268. <div class="card-header bg-warning"><h4 class="card-title">{{__('label.business_qr_code')}}</h4></div>
  269. <div class="card-body">
  270. <div class="row">
  271. @if(isset($restaurant))
  272. <div class="col-md-12">
  273. <div class="text-center">
  274. <p>{{__('label.order_qr_code')}}</p>
  275. <div id="output-order"></div>
  276. <div id="download-order" style="display: none"></div>
  277. <a style="position: relative; top: 13px; font-size: 13px" href="#!"
  278. class="download-image-order mt-4"><i style="font-size: 20px"
  279. class="fa fa-download"></i> </a>
  280. <p class="mt-4"><a href="{!! env('QRCODE_HOST_ORDER') !!}d/{!! $restaurant->resto_unique_name !!}"
  281. target="_blank">{!! env('QRCODE_HOST_ORDER') !!}d/{!! $restaurant->resto_unique_name !!}</a></p>
  282. </div>
  283. </div>
  284. @endif
  285. </div>
  286. </div>
  287. </div>
  288. <div class="card mb-4">
  289. <div class="card-header bg-warning"><h4 class="card-title">{{__('label.logo')}}</h4></div>
  290. <div class="card-body">
  291. <div class="row">
  292. <div class="col-sm-12">
  293. <div class="form-group">
  294. <label style="font-weight: bold">{{__('label.logo')}}</label>
  295. <input type="file" class="form-control" placeholder=""
  296. accept="image/x-png,image/jpeg" name="logo">
  297. <span class="text-danger m-1">{{__('label.note_please_use_jpg_or_png_images')}}</span>
  298. </div>
  299. @if(isset($restaurant) && isset($restaurant->photos))
  300. <div class="col-2">
  301. <img src="{!! $restaurant->photos->file_name !!}"
  302. class="img-fluid mb-2" alt="{!! $restaurant->name !!}">
  303. </div>
  304. @endif
  305. </div>
  306. </div>
  307. </div>
  308. </div>
  309. <div class="card card-body mb-4">
  310. <div class="row">
  311. <div class="col-sm-12">
  312. <a href="#!" class="btn btn-primary save" style="width: 100% !important"><i class="feather-save mr-1"></i> {{__('label.save')}}</a>
  313. <!-- @if( isset($restaurant))
  314. <a href="#!" class="btn btn-primary upload-gallery"><i
  315. class="feather-image mr-1"></i> Upload Gallery</a>
  316. @endif -->
  317. </div>
  318. </div>
  319. <div class="row mt-2">
  320. <div class="col-md-12">
  321. <div class="alert alert-success success"></div>
  322. <div class="alert alert-danger error"></div>
  323. </div>
  324. </div>
  325. </div>
  326. </div>
  327. </div>
  328. </div>
  329. </form>
  330. </section>
  331. </div>
  332. </div>
  333. @if( isset($restaurant))
  334. <div class="modal" id="upload-gallery" tabindex="-1" role="dialog">
  335. <div class="modal-dialog modal-lg" role="document">
  336. <div class="modal-content">
  337. <div class="modal-header">
  338. <h5 class="modal-title">{{__('label.resto_gallery')}}</h5>
  339. <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  340. <span aria-hidden="true">&times;</span>
  341. </button>
  342. </div>
  343. <div class="modal-body">
  344. <div class="row">
  345. <div class="col-sm-12 col-md-12">
  346. <div class="form-group">
  347. <label style="font-weight: bold">{{__('label.gallery')}}</label>
  348. <div class="dropzone dz-clickable" id="gallery">
  349. <div class="dz-default dz-message" data-dz-message="">
  350. <span>{{__('label.drop_files_here_to_upload')}}</span>
  351. </div>
  352. </div>
  353. </div>
  354. </div>
  355. </div>
  356. </div>
  357. <div class="modal-footer">
  358. <button type="button" class="btn btn-primary upload">{{__('label.upload')}}</button>
  359. <button type="button" class="btn btn-secondary" data-dismiss="modal">{{__('label.close')}}</button>
  360. </div>
  361. </div>
  362. </div>
  363. </div>
  364. @endif
  365. @endsection
  366. @section('js')
  367. <script src="{!! env('APP_ASSETS') !!}vendor_components/spectrum/spectrum.js"></script>
  368. <script src="{!! env('APP_ASSETS') !!}vendor_components/select2/dist/js/select2.min.js"></script>
  369. <script src="{!! env('APP_ASSETS') !!}js/jquery.qrcode.min.js"></script>
  370. <script src="{!! env('APP_ASSETS') !!}/vendor_components/bootstrap-tagsinput/dist/bootstrap-tagsinput.min.js"></script>
  371. <script>
  372. $(function () {
  373. $("select[name=time_zone]").select2();
  374. $(".multiple_langs").select2();
  375. $(".outlet_countries").select2();
  376. $("select[rel=multiple-option]").select2();
  377. $("#color").spectrum({
  378. preferredFormat: "hex",
  379. color: "{!! isset($restaurant->default_color)?$restaurant->default_color:"#F00" !!}",
  380. showInput: true,
  381. });
  382. $.uploadPreview({
  383. input_field: "#image-upload", // Default: .image-upload
  384. preview_box: "#image-preview", // Default: .image-preview
  385. label_field: "#image-label", // Default: .image-label
  386. label_default: "Choose File", // Default: Choose File
  387. label_selected: "Change File", // Default: Change File
  388. no_label: true ,
  389. success_callback: function() {
  390. }// Default: false
  391. });
  392. $("body").on("click",".delete-delivery-fee",function () {
  393. var id = $(this).data('id');
  394. var _this = $(this);
  395. $.ajax({
  396. url:"{!! env('APP_URL') !!}delete/save/delivery/fee/"+id,
  397. success:function () {
  398. //_this.parents('tr').remove();
  399. location.reload();
  400. }
  401. });
  402. });
  403. $("body").on("change","select[name=country_id]",function () {
  404. var id = $(this).val();
  405. $("select[name=city_id]").html('');
  406. $.ajax({
  407. url:"{!! env('APP_URL') !!}get/city/by/country/"+id,
  408. success:function (response) {
  409. response = $.parseJSON(response);
  410. var str = "";
  411. $.each(response,function (i,v) {
  412. str+='<option value="'+v.id+'">'+v.name+'</option>'
  413. });
  414. $("select[name=city]").append(str);
  415. @if(isset($restaurant))
  416. $( "select[name=city]" ).val("{!! $restaurant->city !!}");
  417. @endif
  418. }
  419. });
  420. });
  421. setTimeout(function () {
  422. $("body").on("change","select[name=city]",function () {
  423. var id = $(this).val();
  424. $("select[name=place]").html('');
  425. $.ajax({
  426. url:"{!! env('APP_URL') !!}get/place/by/city/"+id,
  427. success:function (response) {
  428. response = $.parseJSON(response);
  429. var str = '<option value="">{{__("label.choose_place")}}</option>';
  430. $.each(response,function (i,v) {
  431. str+='<option value="'+v.id+'">'+v.place_name+'</option>'
  432. });
  433. $("select[name=place]").append(str);
  434. @if(isset($restaurant))
  435. $( "select[name=place]" ).val("{!! $restaurant->place !!}");
  436. @endif
  437. }
  438. });
  439. });
  440. },1000);
  441. @if(isset($restaurant))
  442. $('#output-order').qrcode({
  443. render: "canvas",
  444. text: "{!! env('QRCODE_HOST_ORDER') !!}d/{!! $restaurant->resto_unique_name !!}",
  445. width: 200,
  446. height: 200,
  447. background: "#ffffff",
  448. foreground: "#000000",
  449. src: "{!! isset($restaurant) && isset($restaurant->photos)?env('APP_URL').'public/uploads/logo/'.$restaurant->photos->file_name:env('APP_URL').'public/layout/img/favicon.png' !!}",
  450. imgWidth: 50,
  451. imgHeight: 50
  452. });
  453. $('#download-order').qrcode({
  454. render: "canvas",
  455. text: "{!! env('QRCODE_HOST_ORDER') !!}d/{!! $restaurant->resto_unique_name !!}",
  456. width: 2000,
  457. height: 2000,
  458. background: "#ffffff",
  459. foreground: "#000000",
  460. src: "{!! isset($restaurant) && isset($restaurant->photos)?env('APP_URL').'public/uploads/logo/'.$restaurant->photos->file_name:env('APP_URL').'public/layout/img/favicon.png' !!}",
  461. imgWidth: 500,
  462. imgHeight: 500
  463. });
  464. $(".download-image-order").click(function () {
  465. var canvas = $('#download-order canvas')[0];
  466. var _this = $(this);
  467. // Change here
  468. $.ajax({
  469. url: "{!! env('APP_URL') !!}download/qrcode",
  470. type: "POST",
  471. data: {
  472. resto:"{!! $restaurant->resto_unique_name !!}-{!! $restaurant->id !!}",
  473. data: canvas.toDataURL(),
  474. '_token': "{!! csrf_token() !!}"
  475. },
  476. success: function (response) {
  477. console.log(response);
  478. var link = document.createElement('a');
  479. link.href = response;
  480. link.download = "{!! $restaurant->resto_unique_name !!}-qrcode.png";
  481. link.click();
  482. }
  483. });
  484. });
  485. $( "select[name=country_id]" ).trigger( "change" );
  486. setTimeout(function () {
  487. $("select[name=city]").trigger("change");
  488. },1000);
  489. $("body").on("click", ".map-category-resto", function () {
  490. var categories = $(".default-category");
  491. var price_array = [];
  492. var category_array = [];
  493. var price = $(".default-price");
  494. $.each(categories, function () {
  495. category_array.push($(this).val());
  496. });
  497. $.each(price, function () {
  498. price_array.push($(this).val());
  499. });
  500. $.ajax({
  501. url: "{!! env('APP_URL') !!}map/category/resto",
  502. type: "POST",
  503. data: {
  504. price: price_array,
  505. categories: category_array,
  506. resto_id: "{!! $restaurant->id !!}",
  507. "_token": "{!! csrf_token() !!}"
  508. },
  509. success: function (response) {
  510. }
  511. });
  512. });
  513. @endif
  514. $("#choose-categories").select2().on("change", function () {
  515. var data = ($('#choose-categories').select2('data'));
  516. if (data) {
  517. var str = "";
  518. $.each(data, function (i, v) {
  519. str += "<tr>";
  520. str += "<td>" + v.text + "</td>";
  521. str += '<td><input type="hidden" name="category[]" class="default-category" value="' + v.id + '" /><input type="text" class="form-control default-price" name="price[]" /> </td>';
  522. str += "</tr>"
  523. });
  524. $("#table-default-price tbody").html(str);
  525. }
  526. });
  527. $("body").on("click", ".edit-fee", function () {
  528. var id = $(this).data('id');
  529. });
  530. $("body").on("click", ".save-delivery-fee", function () {
  531. $(this).parents('.tab-pane').find("form").ajaxForm(function (response) {
  532. response = $.parseJSON(response);
  533. if (response) {
  534. if (response.type == "success") {
  535. $('#delivery-fee-modal .alert.success').html(response.message);
  536. $('#delivery-fee-modal .alert.success').show();
  537. setTimeout(function () {
  538. location.reload();
  539. }, 2000)
  540. } else {
  541. $('#special-offers .alert.error').html(response.message);
  542. $('#special-offers .alert.error').show();
  543. }
  544. }
  545. }).submit();
  546. });
  547. $("body").on("click", ".add-delivery-fee", function () {
  548. $("#delivery-fee-modal").modal();
  549. });
  550. $("body").on("change", ".country_id", function () {
  551. var _this = $(this);
  552. var code = $(this).val();
  553. _this.parents('.delivery-fee-item').find('.city').html('');
  554. $.ajax({
  555. url: "{!! env('APP_URL') !!}get/cities/by/country/" + code,
  556. success: function (response) {
  557. response = $.parseJSON(response);
  558. var str = '<option value="">{{__("label.choose_city")}}</option>';
  559. _this.parents('.delivery-fee-item').find(".city").html(str);
  560. if (response) {
  561. $.each(response, function (i, v) {
  562. str += '<option value="' + v.city + '">' + v.city + '</option>';
  563. });
  564. _this.parents('.delivery-fee-item').find(".city").html(str);
  565. }
  566. }
  567. });
  568. });
  569. $("body").on("change", ".city", function () {
  570. var name = $(this).val();
  571. var _this = $(this);
  572. $.ajax({
  573. url: "{!! env('APP_URL') !!}get/places/by/city/" + name,
  574. success: function (response) {
  575. response = $.parseJSON(response);
  576. var str = '<option value="">{{__("label.choose_city")}}</option>';
  577. _this.parents('.delivery-fee-item').find(".place").html(str);
  578. if (response) {
  579. $.each(response, function (i, v) {
  580. str += '<option value="' + v.city_unique_id + '" data-category="' + v.category + '">' + v.city_name + '</option>';
  581. });
  582. _this.parents('.delivery-fee-item').find(".place").html(str);
  583. }
  584. }
  585. });
  586. });
  587. $("body").on("change", ".make_active", function () {
  588. var value = $(this).val();
  589. var resto_id = $(this).data('resto-id');
  590. if ($(this).is(":checked")) {
  591. $.ajax({
  592. url: "{!! env('APP_URL') !!}offer/make/active",
  593. type: "POST",
  594. data: {
  595. id: value,
  596. resto_id: resto_id,
  597. "_token": "{!! csrf_token() !!}"
  598. },
  599. success: function (response) {
  600. }
  601. });
  602. }
  603. });
  604. $("body").on('click', '.save', function () {
  605. $(".alert").hide();
  606. if ($("#restaurant-form").valid()) {
  607. $("#restaurant-form").ajaxForm(function (response) {
  608. response = $.parseJSON(response);
  609. if (response) {
  610. if (response.type == "success") {
  611. $('#restaurant-form .alert.success').html(response.message);
  612. $('#restaurant-form .alert.success').show();
  613. setTimeout(function () {
  614. @if(\Illuminate\Support\Facades\Auth::user()->role=="administrator" )
  615. window.location = '{!! env('APP_URL') !!}businesses';
  616. @else
  617. location.reload();
  618. @endif
  619. }, 2000)
  620. } else {
  621. $('#restaurant-form .alert.error').html(response.message);
  622. $('#restaurant-form .alert.error').show();
  623. }
  624. }
  625. }).submit();
  626. }
  627. });
  628. })
  629. </script>
  630. @endsection