restaurant_form.blade.php 37 KB

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