restaurant_form_marchent.blade.php 41 KB

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