index.blade.php 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895
  1. @extends('layout.app')
  2. @section('content')
  3. <style type="text/css">
  4. .row{ margin-left: 0; margin-right: 0}
  5. .homepage-ads .item img
  6. {
  7. display: block;
  8. width: 100%;
  9. height:auto !important;
  10. }
  11. .quantity{
  12. background: #fff9ed;
  13. font-weight: bold;
  14. padding: 3px 13px;
  15. }
  16. .plus-minus-button{
  17. border: 1px solid #000;
  18. border-radius: 20px;
  19. width: 99px;
  20. width: 99px;
  21. margin-right: 32%;
  22. }
  23. .quantity-button{
  24. margin: 0 -4px;
  25. }
  26. .special-offer-tag{
  27. background: #fff;
  28. width: 40px;
  29. height: 40px;
  30. border: 1px solid;
  31. border-color: #f5f5f5;
  32. border-radius: 31px;
  33. position: absolute;
  34. top: 10px;
  35. bottom: 0;
  36. right: 0px;
  37. padding-left: 7px;
  38. padding-right: .5rem;
  39. padding-top: 7px;
  40. color: #ffa606;
  41. font-size: 26px;
  42. }
  43. .recipe-description{
  44. font-weight: 500; color:#000
  45. }
  46. .resto-basket-time{
  47. background: #fff9ed;
  48. width: 100px;
  49. margin-right: 15px;
  50. border-radius: 10px;
  51. padding: 1px 5px;
  52. }
  53. .section.special-offer{
  54. background: #ababab26; border-radius: 5px;min-height: 56px;
  55. }
  56. #recipe-detail .card-body{
  57. padding: 0 1rem;
  58. }
  59. #recipe-detail .card{ border: none; margin-bottom: 0}
  60. #out-of-order .modal-content{
  61. border-radius: 10px;
  62. }
  63. #out-of-order{
  64. top: 40%;
  65. }
  66. .recipe-img{
  67. background-position: center;
  68. background-size: cover;
  69. border-radius: 11px;
  70. margin-top: 10px;
  71. height: 200px;
  72. }
  73. #out-of-order h1{
  74. color:#ffa606;
  75. font-weight: 600;
  76. font-size: 21px;
  77. }
  78. .category-recipes{
  79. padding: 0 13px;
  80. }
  81. .today-tomorrow{
  82. width:100%
  83. }
  84. .today-tomorrow li{
  85. width: 100%;
  86. text-align: center;
  87. padding: 7px;
  88. font-size: 16px;
  89. }
  90. .today-tomorrow li.active{
  91. background: #fff9ed;
  92. }
  93. .time-slots a{ border: none}
  94. .recipe-overlay{
  95. background: rgb(255,255,255,0.5);
  96. position: absolute;
  97. right: 0;
  98. left: 0;
  99. top: 0;
  100. bottom: 0;
  101. }
  102. .img-div{
  103. max-height: 70px; overflow: hidden }
  104. @media (max-width: 575.98px)
  105. {
  106. .homepage-search-block {
  107. padding: 0rem 0 !important;
  108. }
  109. }
  110. @media (min-width: 360px)
  111. {
  112. .plus-minus-button{
  113. margin-right: 32%;
  114. }
  115. }
  116. </style>
  117. <div class="mobile-container">
  118. @php
  119. $opening_timing = $resto_info['opening_timing'];
  120. $closing_timing = $resto_info['closing_timing'];
  121. $is_resto_opened = false;
  122. if(!empty($opening_timing) && !empty($closing_timing)){
  123. // $opening_timing = "13:00";
  124. $opening_timing = date('H:i', strtotime($opening_timing));
  125. $closing_timing = date('H:i', strtotime($closing_timing));
  126. $current_time = date('H:i');
  127. if($current_time > $opening_timing && $current_time <= $closing_timing)
  128. $is_resto_opened = true;
  129. $opening_timing = strtotime($opening_timing);
  130. $closing_timing =strtotime($closing_timing);
  131. $tStart = $opening_timing;
  132. $tEnd = ($closing_timing);
  133. $tNow = $tStart;
  134. while($tNow <= $tEnd){
  135. $now = date("H:i",$tNow);
  136. $tNow = strtotime('+15 minutes',$tNow);
  137. $time_slots[] = $now;
  138. }
  139. }
  140. @endphp
  141. <div class="row d-flex align-items-center">
  142. <div class="col-md-12">
  143. <div class="homepage-search-title" style="padding: 10px">
  144. <div class="owl-carousel homepage-ads">
  145. @if(isset($resto_info['gallery']) && !empty($resto_info['gallery']))
  146. @foreach($resto_info['gallery'] as $key => $value)
  147. <div class="item text-center">
  148. <img src="{{$value}}" width="199" height="160" class="img-fluid">
  149. </div>
  150. @endforeach
  151. @endif
  152. </div>
  153. </div>
  154. </div>
  155. </div>
  156. <div class="p-3">
  157. <div class=" d-flex flex-column leading-normal mt-0 mb-0">
  158. <h3 class=""><span class="resto_title">{{$resto_info['name']}}</span></h3>
  159. <div class="address p-2" style="margin-right: 6px">
  160. {!! nl2br($resto_info['address']) !!}
  161. </div>
  162. </div>
  163. <div class=" text-sm leading-normal mt-3 mb-3 resto-time-basket">
  164. <div class="d-flex flex-row resto-basket-time">
  165. <div class="bd-highlight"> <i class="icofont-wall-clock fs-2"></i></div>
  166. <div class="bd-highlight">
  167. @if(!empty($resto_info['delivery_time_range']))
  168. &nbsp;{{ $resto_info['delivery_time_range'] }}
  169. @else
  170. No time available
  171. @endif
  172. </div>
  173. </div>
  174. <div class="d-flex flex-row resto-basket-time" style="width: 185px">
  175. <div class="bd-highlight">
  176. <i class="icofont-basket fs-2"></i>
  177. </div>
  178. <div class="bd-highlight">
  179. @if(!empty($resto_info['min_basket_price']))
  180. {!! number_format($resto_info['min_basket_price'],2) !!} د. ع اقل قيمة للطلب
  181. @else
  182. No minimum basket
  183. @endif</div>
  184. </div>
  185. </div>
  186. {{--<div class="section loyality-program">
  187. <p class="m-0"><img src="{!! env('APP_URL_ASSETS') !!}img/checkbox.png" style="margin-top: -3px; margin-right: 2px"> Loyality Program</p>
  188. <small>available</small>
  189. </div>--}}
  190. {{--@if($resto_info['special_offers'] && count($resto_info['special_offers']))
  191. <div class="section special-offer">
  192. <div class="d-flex">
  193. <div class="flex-shrink-0 position-relative mr-3" style="margin-left: 40px">
  194. <i class="icofont-tags special-offer-tag"></i>
  195. </div>
  196. <div class="flex-grow-1 ms-3">
  197. <p class="fw-bold">{!! $resto_info['special_offers']['offer_title'] !!}</p>
  198. <p>{!! $resto_info['special_offers']['offer_text'] !!}</p>
  199. </div>
  200. </div>
  201. </div>
  202. @endif--}}
  203. </div>
  204. <div class="row delivery-to">
  205. <div class="d-flex flex-row">
  206. <div class="mr-4">
  207. <img src="{!! env('APP_URL_ASSETS') !!}img/location.png" class="img-delivery" style=""><strong>التوصيل الى</strong>
  208. <ul class="list-inline adjust-location">
  209. <li class="list-inline-item"><span id="location"> Select Location</span></li>
  210. <li class="list-inline-item"><span id="time">(اقرب وقت)</span></li>
  211. <li class="list-inline-item"><i class="icofont-thin-down"></i></li>
  212. </ul>
  213. </div>
  214. <div class="text-end">
  215. <div class="btn-group" role="group" aria-label="Basic radio toggle button group">
  216. <input type="radio" class="btn-check" name="btnradio" id="btnradio1" autocomplete="off" checked>
  217. <label class="btn btn-secondary action-buttons" for="btnradio1">توصيل</label>
  218. <input type="radio" class="btn-check" name="btnradio" id="btnradio2" aut
  219. ocomplete="off">
  220. <label class="btn btn-secondary action-buttons" for="btnradio2">استلام</label>
  221. </div>
  222. </div>
  223. </div>
  224. </div>
  225. <div class="section">
  226. <section class="section bg-white">
  227. <div class="row">
  228. <div class="col-md-12 p-0 mt-3 ">
  229. <nav id="navbar-example2" class="navbar navbar-light bg-white scrollSpy-section p-0 filters button-group js-radio-button-group filters-button-group">
  230. <ul class="scrollSpy-elements scrollmenu">
  231. @if(isset($categories) && count($categories))
  232. @foreach($categories as $k=>$category)
  233. <li class="nav-item p-2">
  234. <a class="nav-link filter_btn @if($k==0) active @endif" href="#category-{!! $category['id'] !!}">
  235. <span class="scrollSpy-text">{!! $category['name'] !!}</span>
  236. </a>
  237. </li>
  238. @endforeach
  239. @endif
  240. </ul>
  241. </nav>
  242. <div data-spy="scroll" data-target="#navbar-example2" data-offset="0" data-method="position" tabindex="1" class="pt-4 pb-4 spy_div">
  243. @if(isset($categories) && count($categories))
  244. @foreach($categories as $category)
  245. <div class="row" style="background-color: #f3f3f3;padding: 10px 10px 3px 10px;">
  246. <div class="col-10">
  247. <h5 class="" id="category-{!! $category['id'] !!}"><strong>{!! $category['name'] !!}</strong></h5>
  248. </div>
  249. <div class="col-2 text-center">
  250. <p class="fs-3 fw-bold"><strong>{!! count($category['recipes']) !!}</strong> </p>
  251. </div>
  252. </div>
  253. @if(isset($category['recipes']) && count($category['recipes']))
  254. <div id="categorys-{!! $category['id'] !!}" class="category-recipes">
  255. @foreach ($category['recipes'] as $key => $value)
  256. <div class="food-items-wrap row mt-2 position-relative ">
  257. @if(!$is_resto_opened)
  258. <div class="recipe-overlay"></div>
  259. @endif
  260. <div class="col-8 d-flex justify-content-between @if($is_resto_opened) get-recipe_detail @endif p-0" data-recipe-id="{!! $value['shared_unique_id'] !!}">
  261. <div class="d-flex justify-content-end">
  262. <div>
  263. <img class="food-img food_img_list lazyload" data-iscustomize="<?php echo $value['is_customized'];?>" width="85px" height="85px" data-srcset="<?php echo $value['thumbnail'];?>">
  264. </div>
  265. <div class="food-item-name-category">
  266. <p class="food-name"><b><?php echo $value['name'];?></b></p>
  267. <p class="food-category custome_category">{!! mb_substr($value['description'],0,50,'utf-8') !!}</p>
  268. <p class="food-price" data-price="{!! str_replace(',','',$value['price'] ) !!}">{!! number_format(str_replace(',','',$value['price'] ),2) !!} د. ع </p>
  269. </div>
  270. </div>
  271. </div>
  272. </div>
  273. @endforeach
  274. </div>
  275. @endif
  276. @endforeach
  277. @endif
  278. </div>
  279. </div>
  280. </div>
  281. </section>
  282. </div>
  283. <div class="view-basket">
  284. <div class="view-cart-wrap">
  285. <div class="pl-3">
  286. <span class="cart-item total-recipe-selected"></span>
  287. <span class="t-price" id="basket-price" ></span>
  288. </div>
  289. <div class="vc-name-image">
  290. <p class="next-page">
  291. <span class="vc-name"> سلتي </span>
  292. <i class="icofont-swoosh-left"></i>
  293. </p>
  294. </div>
  295. </div>
  296. </div>
  297. </div>
  298. <div class="modal fade" id="delivery-options" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
  299. <div class="modal-dialog" role="document">
  300. <div class="modal-content">
  301. <div class="modal-body">
  302. <h4 class="font-black text-lg leading-normal m-2 mx-4 font-weight-bolder mb-5">
  303. التوصيل الى
  304. </h4>
  305. <div class="mx-4 d-flex">
  306. <div class="w-100">
  307. <ul class="list-inline">
  308. <li class="list-inline-item"><img src="{!! env('APP_URL_ASSETS') !!}img/location.png" > </li>
  309. <li class="list-inline-item"> <span id="pre-selected">Select Location</span></li>
  310. </ul>
  311. </div>
  312. <div class="ml-auto">
  313. <a href="#!" class="change-button" data-action="delivery">غير</a>
  314. </div>
  315. </div>
  316. <hr class="mt-5 mb-5" />
  317. <h4 class="font-black text-lg leading-normal m-2 mx-4 font-weight-bolder mb-5 mt-5">
  318. وقت التوصيل
  319. </h4>
  320. <div class="mx-4 d-flex mb-5">
  321. <div class="w-100">
  322. @if($is_resto_opened)
  323. <ul class="list-inline">
  324. <li class="list-inline-item"><i class="icofont-wall-clock"></i></li>
  325. <li class="list-inline-item"><span class="selected-time-slot">(اقرب وقت)</span></li>
  326. </ul>
  327. @else
  328. Closed
  329. @endif
  330. </div>
  331. <div class="ml-auto">
  332. <a href="#!" class="change-button" data-action="time">غير</a>
  333. </div>
  334. </div>
  335. </div>
  336. </div>
  337. </div>
  338. </div>
  339. <div class="modal fade" id="time-options" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
  340. <div class="modal-dialog" role="document">
  341. <div class="modal-content">
  342. <div class="modal-body" style=" padding: 0;">
  343. <ul class="list-inline today-tomorrow border-bottom">
  344. <li class="list-inline-item active">Today</li>
  345. </ul>
  346. @if(isset($time_slots) && count($time_slots))
  347. <div class="list-group list-group-flush time-slots" style="max-height: 250px; overflow: auto;">
  348. <a href="#" class="list-group-item list-group-item-action text-center">اقرب وقت</a>
  349. @foreach($time_slots as $slot)
  350. <a href="#" class="list-group-item list-group-item-action text-center">{!! $slot !!}</a>
  351. @endforeach
  352. </div>
  353. @endif
  354. </div>
  355. </div>
  356. </div>
  357. </div>
  358. <div class="modal fade" id="out-of-order" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
  359. <div class="modal-dialog" role="document">
  360. <div class="modal-content">
  361. <div class="modal-body text-center">
  362. <h1 class="text-center mt-5 mb-3">You order is out of Delivery</h1>
  363. <a class="btn btn-light">View Detail</a>
  364. </div>
  365. </div>
  366. </div>
  367. </div>
  368. <div class="modal fade" id="recipe-detail" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
  369. <div class="modal-dialog" role="document">
  370. <div class="modal-content">
  371. <div class="modal-body p-0">
  372. </div>
  373. <div class="modal-footer add-to-basket my-custom-buttom">
  374. <div class="row">
  375. <div class="col-9 text-center">أضف
  376. <span id="user-quantity" style="padding: 7px">1</span> الى سلتي </div>
  377. <div class="col-3 text-left "><small> <span id="user-price"></span> د. ع </small> </div>
  378. </div>
  379. </div>
  380. </div>
  381. </div>
  382. </div>
  383. @endsection
  384. @section('js')
  385. <script>
  386. var selected_city = localStorage.getItem('selected_city');
  387. if(selected_city && selected_city!=""){
  388. $("#location").text(selected_city);
  389. $("#pre-selected").text(selected_city);
  390. }else{
  391. // window.location = "{!! env('APP_URL')."delivery/".\Illuminate\Support\Str::slug($resto_info['name']) !!}";
  392. $("#location").text("Select Location");
  393. $("#pre-selected").text("Select Location");
  394. }
  395. $(function () {
  396. @if(!$is_resto_opened)
  397. $("#out-of-order").modal();
  398. @endif
  399. localStorage.setItem('site_url','{!! env('APP_URL').'?id='.request()->get('id') !!}');
  400. $("body").on("click",".time-slots a",function () {
  401. var time = $(this).text();
  402. $("#time").html(time);
  403. $(".selected-time-slot").html(time);
  404. localStorage.setItem('selected_time',time);
  405. $("#time-options").modal('hide');
  406. $("#delivery-options").modal('hide');
  407. });
  408. var selected_time = localStorage.getItem('selected_time');
  409. var recent_selected_recipe_id = 0;
  410. var selected_recipe_array = [];
  411. var total_price = 0;
  412. var selected_recipe_object_array = [];
  413. var is_require = true;
  414. var is_basket_has_items = localStorage.getItem('cart');
  415. var is_new_resto = "{!! $new_resto !!}";
  416. var _total_quantity = 0;
  417. if(is_new_resto=="Yes"){
  418. localStorage.removeItem('cart');
  419. localStorage.removeItem('total_price');
  420. localStorage.removeItem('customer_id');
  421. localStorage.removeItem('mobile_number');
  422. localStorage.removeItem('access_token');
  423. }
  424. if(is_basket_has_items){
  425. var a = $.parseJSON(is_basket_has_items);
  426. if(a.length > 0){
  427. var p_t = 0;
  428. $.each(a, function (b,c) {
  429. selected_recipe_array.push(c.id);
  430. selected_recipe_object_array.push(c);
  431. var tt = parseInt(c.quantity) * parseInt(c.price);
  432. _total_quantity+=parseInt(c.quantity);
  433. //console.log(_total_quantity);
  434. p_t+=tt;
  435. // var tt = parseInt(quantity) * parseInt(price);
  436. // console.log(recent_selected_recipe_id+":"+tt);
  437. });
  438. // selected_recipe_object_array.push(a);
  439. // var t = a.map(a => a.price).reduce((acc, a) => a + acc);
  440. // console.log(t);
  441. $("#basket-price").html(format(p_t.toFixed(2))+" د. ع ");
  442. // $(".total-recipe-selected").html(a.length);
  443. $(".total-recipe-selected").html(_total_quantity);
  444. $(".view-basket").show();
  445. }
  446. }
  447. $("body").on("click",".view-basket",function () {
  448. window.location = "{!! env('APP_URL')."basket/".\Illuminate\Support\Str::slug($resto_info['name']) !!}";
  449. })
  450. $("body").on("click",".get-recipe_detail",function () {
  451. var id = $(this).data('recipe-id');
  452. recent_selected_recipe_id = id;
  453. $("#recipe-detail").modal();
  454. $("#recipe-detail .modal-body").html(overlay);
  455. $("#recipe-detail .modal-footer").hide();
  456. $.ajax({
  457. url:"{!! env('APP_URL') !!}recipe",
  458. type:"POST",
  459. data:{
  460. id:id,
  461. "_token":"{!! csrf_token() !!}"
  462. },
  463. success:function (response) {
  464. response = $.parseJSON(response);
  465. var recipe = response.recipe;
  466. var data = recipe_detail(recipe);
  467. $("#recipe-detail .modal-body").html(data);
  468. $("#user-price").html(recipe.price);
  469. $("#user-quantity").html('1');
  470. $("#recipe-detail .modal-footer").show();
  471. }
  472. });
  473. });
  474. $("body").on("click",".add-to-basket",function () {
  475. var extra_single_options = null;
  476. is_require = true;
  477. $(".is_required").each(function (i,v) {
  478. var _this = $(this);
  479. var amount = parseInt(_this.data("amount"));
  480. var per_click = parseInt(_this.attr("per-click"));
  481. if(per_click < amount){
  482. is_require = false;
  483. _this.find('.require').addClass('error');
  484. }else{
  485. _this.find('.require').removeClass('error');
  486. }
  487. // console.log(amount+"|"+is_require+"|"+per_click);
  488. });
  489. if(is_require){
  490. if(!selected_recipe_array.includes(recent_selected_recipe_id)){
  491. selected_recipe_array.push(recent_selected_recipe_id);
  492. var quantity = $("#user-quantity").text();
  493. var price = $(".item-price").data('price');
  494. var tt = parseInt(quantity) * parseInt(price);
  495. total_price+=(parseInt(tt));
  496. var extra_single_options = $( ".single_options:checked" )
  497. .map(function() {
  498. return this.value;
  499. })
  500. .get()
  501. .join();
  502. var ex = [];
  503. var extra_multiple_options = $( ".selected-checkbox-counter.active" );
  504. if(extra_multiple_options){
  505. $.each(extra_multiple_options,function (i,v) {
  506. var _this_extra = $(this);
  507. var x = {id:$(this).data('item-id'),quantity:$(this).attr('selected-counter')};
  508. ex.push(x);
  509. });
  510. }
  511. _total_quantity+=parseInt(quantity);
  512. // console.log(_total_quantity);
  513. var recipe = {id:recent_selected_recipe_id,quantity:quantity,price:price,single_options:extra_single_options,multiple_option:ex};
  514. selected_recipe_object_array.push(recipe);
  515. }
  516. // console.log(selected_recipe_object_array.length);
  517. localStorage.removeItem('cart');
  518. localStorage.setItem('cart',JSON.stringify(selected_recipe_object_array));
  519. // console.log("Items in local storage");
  520. // console.log(localStorage.getItem('cart'));
  521. $("#recipe-detail").modal('hide');
  522. $("#basket-price").html(format(total_price.toFixed(2))+" د. ع ");
  523. // $(".total-recipe-selected").html(selected_recipe_object_array.length);
  524. $(".total-recipe-selected").html(_total_quantity);
  525. $(".view-basket").show();
  526. }
  527. });
  528. if(selected_time && selected_time!=""){
  529. $("#time").text(selected_time);
  530. $(".selected-time-slot").text(selected_time);
  531. }else{
  532. $("#time").text("(اقرب وقت)");
  533. $(".selected-time-slot").text("(اقرب وقت)");
  534. }
  535. $("body").on("click",".adjust-location",function () {
  536. $("#delivery-options").modal();
  537. });
  538. $("body").on("click",".change-button",function (e) {
  539. var action = $(this).data("action");
  540. if(action=="delivery"){
  541. // alert("d");
  542. window.location = "{!! env('APP_URL')."delivery/".\Illuminate\Support\Str::slug($resto_info['name']) !!}";
  543. }else if(action=="time"){
  544. // alert("t");
  545. $("#time-options").modal();
  546. }
  547. e.stopPropagation();
  548. e.preventDefault();
  549. });
  550. $("body").on("click",".multi-select",function () {
  551. var _this = $(this);
  552. var _current_counter = _this.find('.selected-checkbox-counter').text();
  553. var _parent = _this.parents('.is_required');
  554. var _maximum_selection = parseInt(_parent.data('amount'));
  555. var _per_click = parseInt(_parent.attr('per-click'));
  556. if(_per_click>=_maximum_selection)
  557. return false;
  558. _per_click = _per_click +1;
  559. _parent.attr('per-click',_per_click);
  560. var _total_selection = 0;
  561. if(_current_counter=="")
  562. _current_counter = 1;
  563. else{
  564. _current_counter = parseInt(_current_counter);
  565. _current_counter++;
  566. }
  567. _this.find('.selected-checkbox-counter').attr('selected-counter',_current_counter);
  568. _this.find('.selected-checkbox-counter').addClass('active');
  569. _this.find('.selected-checkbox-counter').text(_current_counter+"x");
  570. _this.find('.delete-selection').addClass('icofont-trash');
  571. });
  572. $("body").on("click",".single_options",function () {
  573. var _this = $(this);
  574. var _current_counter = _this.find('.selected-checkbox-counter').text();
  575. var _parent = _this.parents('.is_required');
  576. var _maximum_selection = parseInt(_parent.data('amount'));
  577. var _per_click = parseInt(_parent.attr('per-click'));
  578. if(_per_click>=_maximum_selection)
  579. return false;
  580. _per_click = _per_click +1;
  581. _parent.attr('per-click',_per_click);
  582. var _total_selection = 0;
  583. if(_current_counter=="")
  584. _current_counter = 1;
  585. else{
  586. _current_counter = parseInt(_current_counter);
  587. _current_counter++;
  588. }
  589. _this.find('.selected-checkbox-counter').attr('selected-counter',_current_counter);
  590. _this.find('.selected-checkbox-counter').addClass('active');
  591. _this.find('.selected-checkbox-counter').text(_current_counter+"x");
  592. _this.find('.delete-selection').addClass('icofont-trash');
  593. });
  594. $("body").on("click",".delete-selection",function (e) {
  595. var _this = $(this);
  596. _this.parents('.row-section').find(".selected-checkbox-counter").html('');
  597. _this.parents('.row-section').find(".selected-checkbox-counter").attr('selected-counter',"0");
  598. _this.find('.selected-checkbox-counter').removeClass('active');
  599. _this.removeClass('icofont-trash');
  600. var _parent = _this.parents('.is_required');
  601. _parent.attr('per-click',"0");
  602. e.preventDefault();
  603. e.stopPropagation();
  604. });
  605. $("body").on("click",".quantity-button",function () {
  606. var action = $(this).data('action');
  607. var current_quantity = parseInt($(".quantity").text());
  608. var current_price = parseInt($(".item-price").data('price'));
  609. if(action == "plus-button")
  610. current_quantity++;
  611. if(action == "minus-button" && current_quantity>1)
  612. current_quantity--;
  613. $(".quantity").html(current_quantity);
  614. $("#user-quantity").html(current_quantity);
  615. $("#user-price").html(format(current_quantity * current_price));
  616. });
  617. });
  618. function recipe_detail(recipe) {
  619. var str ='<div class="row mb-5">\n' +
  620. ' <div class="col-12">\n' +
  621. ' <button type="button" class="btn-close" data-dismiss="modal" aria-label="Close"></button>\n' +
  622. '<div class="recipe-img" style="background-image:url('+recipe.main_image+')">' +
  623. ''+'</div>\n' +
  624. ' </div>\n' +
  625. '\n' +
  626. ' <div class="row p-1">\n' +
  627. ' <div class="col-12">\n' +
  628. ' <h3 style="margin:0" class="resto-title mt-2">'+recipe.name+'</h3>\n' +
  629. ' </div>\n' +
  630. ' </div>\n' +
  631. '\n' +
  632. ' <div class="row p-1">\n' +
  633. ' <div class="col-12">\n' +
  634. ' <p class="h5 fs-5 mt-2 fw-bolder item-price primary-text-color" data-price="'+recipe.price.replace(",","")+'">AED '+recipe.price+'</p>\n' +
  635. ' </div>\n' +
  636. ' </div>\n' +
  637. '\n' +
  638. ' <div class="row p-1">\n' +
  639. ' <div class="col-12">\n' +
  640. ' <p class="recipe-description">'+recipe.description+'</p>\n' +
  641. ' </div>\n' +
  642. ' </div>\n' +
  643. '\n' +
  644. '\n';
  645. $.each(recipe.extra_options,function (i,v) {
  646. if(v.is_mandatory=="Yes") {
  647. str += '<div class="card is_required" data-card-id="'+v.id+'" per-click="0" data-amount="'+v.mandatory_amount+'">';
  648. }else{
  649. str += '<div class="card">';
  650. }
  651. str+= '<div class="card-body"><div class="card-header p-3">'+v.name;
  652. if(v.is_mandatory=="Yes"){
  653. str+='<span class="float-end require"> '+'Choose at least '+v.mandatory_amount+' </span><br /><small></small>';
  654. }
  655. str+='</div>';
  656. if(v.items){
  657. str+=' <div class="list-group list-group-flush">';
  658. $.each(v.items,function (j,k) {
  659. if(k.item_type=="option"){
  660. str+='<label class="list-group-item chk_container"><div class="row row-section"><div class="col-2 text-center"></div> <div class="col-8">'+k.name+'</div><div class="col-2 text-center"> ' +
  661. '<input class="form-check-input me-1 single_options" name="single_option_'+v.id+'" type="radio" value="'+v.id+'">' +
  662. '<span class="checkmark"></span></div></div>' +
  663. '</label>';
  664. }else{
  665. str+='<label class="list-group-item multi-select"><div class="row row-section"><div class="col-2 text-end"><span class="selected-checkbox-counter" data-item-id="'+k.id+'" selected-counter="0"></span> </div> <div class="col-8">'+k.name+'</div><div class="col-2 text-center"> ' +
  666. '<span class="delete-selection text-danger"></span> </div></div>' +
  667. '</label>';
  668. }
  669. });
  670. str+='</div >';
  671. }
  672. str+='</div></div>';
  673. })
  674. str+='\n' +
  675. ' <div class="d-flex justify-content-center bd-highlight mb-3 plus-minus-button">\n' +
  676. ' <div class="p-2 bd-highlight"><button class="quantity-button" data-action="plus-button"><i class="icofont-plus"></i> </button> </div>\n' +
  677. ' <div class="p-2 bd-highlight"><span class="quantity">1</span> </div>\n' +
  678. ' <div class="p-2 bd-highlight"><button class="quantity-button" data-action="minus-button"><i class="icofont-minus"></i></button> </div>\n' +
  679. ' </div>';
  680. return str;
  681. }
  682. var format = function(num){
  683. var str = num.toString().replace("$", ""), parts = false, output = [], i = 1, formatted = null;
  684. if(str.indexOf(".") > 0) {
  685. parts = str.split(".");
  686. str = parts[0];
  687. }
  688. str = str.split("").reverse();
  689. for(var j = 0, len = str.length; j < len; j++) {
  690. if(str[j] != ",") {
  691. output.push(str[j]);
  692. if(i%3 == 0 && j < (len - 1)) {
  693. output.push(",");
  694. }
  695. i++;
  696. }
  697. }
  698. formatted = output.reverse().join("");
  699. return("" + formatted + ((parts) ? "." + parts[1].substr(0, 2) : ""));
  700. };
  701. </script>
  702. @endsection