restaurant_form.blade.php 39 KB

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