recipes.blade.php 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464
  1. @extends('layouts.app')
  2. @section('content')
  3. @php
  4. $resto = \App\Models\Restaurants::find(\App\Helpers\CommonMethods::getRestuarantID());
  5. $lang = $resto->default_lang;
  6. app()->setLocale($lang);
  7. if(session('app_lang') !==null){
  8. $lang = session('app_lang');
  9. app()->setLocale($lang);
  10. }
  11. $restuarant1 =$resto;
  12. $resto_meta = isset($restuarant1->resto_metas)?$restuarant1->resto_metas:null;
  13. //dump($resto_meta);
  14. $resto_metas = [];
  15. $billing = [];
  16. if(isset($resto_meta)){
  17. foreach($resto_meta as $meta){
  18. if($meta->outlet_id!=""){
  19. continue;
  20. }
  21. $index_name = isset($meta->resto_meta_defs->parents)?$meta->resto_meta_defs->parents->meta_def_name:$meta->resto_meta_defs->meta_def_name;
  22. // dump($meta->resto_meta_defs);
  23. if($index_name=="BILLING_GATEWAY"){
  24. // dump($meta->resto_meta_defs->meta_def_name);
  25. // $resto_metas['BILLING_GATEWAY'][] = $meta->meta_val;
  26. $billing[] = array('id'=>$meta->meta_id,'value'=>$meta->meta_val);
  27. }
  28. $resto_metas[$index_name] = $meta->meta_val;
  29. }
  30. }
  31. $resto_metas['BILLING_GATEWAY'] = $billing;
  32. $currency = isset($resto_metas['BUSSINESS_CCY'])?$resto_metas['BUSSINESS_CCY']:"IQD";
  33. $business_type = isset($resto_metas['BUSSINESS_TYPE'])?$resto_metas['BUSSINESS_TYPE']:"Restaurants";
  34. $is_allow_print_preview = isset($resto_metas['PRINT_PREVIEW_ON_ACCEPT_ORDER'])?$resto_metas['PRINT_PREVIEW_ON_ACCEPT_ORDER']:"Disabled";
  35. $imgix = isset($resto_metas['IMGIX_SOURCE'])?$resto_metas['IMGIX_SOURCE'].'/':"https://meemappaws.imgix.net";
  36. $allow_pre_order = isset($resto_metas['ALLOW_PRE_ORDERS'])?$resto_metas['ALLOW_PRE_ORDERS']:"No";
  37. @endphp
  38. <link href="{!! env('APP_ASSETS') !!}css/jquery-ui.min.css" rel="stylesheet" />
  39. <style>
  40. .pagination li.active a.page-link {
  41. color: white !important;
  42. background: #ffa505 !important;
  43. }
  44. .accordion-button{
  45. background-color: #ffab00 !important;
  46. color: #fff !important;
  47. }
  48. .page-link{
  49. padding: .5em 1em !important;
  50. border-radius: 2px;
  51. border: 0;
  52. margin: 0;
  53. min-width: 50px !important;
  54. text-align: center;
  55. }
  56. .page-item.active .page-link{
  57. background-color: #4c95dd;
  58. }
  59. table.dataTable {
  60. clear: both;
  61. margin-top: 6px !important;
  62. margin-bottom: 6px !important;
  63. max-width: none !important;
  64. border-collapse: collapse !important;
  65. font-family: 'Open Sans';
  66. }
  67. /*table.dataTable td{
  68. border-width: 1px;
  69. }*/
  70. .theme-primary .pagination li a:hover {
  71. background-color: #000 !important;
  72. }
  73. .table > :not(:last-child) > :last-child > * {
  74. border-bottom-color: transparent;
  75. }
  76. table.dataTable th{font-weight: 700 !important;}
  77. .dataTables_paginate {
  78. width: 100%;
  79. text-align: center;
  80. }
  81. div.dataTables_wrapper div.dataTables_paginate ul.pagination{
  82. justify-content: center !important;
  83. }
  84. </style>
  85. <div class="content-wrapper">
  86. <div class="container-full">
  87. <section class="content">
  88. <div class="card p-15 rounded-1">
  89. <div class="card-header">
  90. <div class="col-6"><h3 style="margin-left: 10px">{{__('label.items')}}</h3></div>
  91. <div class="col-6 text-end"><a href="{!! env('APP_URL') !!}recipe/new" class="btn btn-sm btn-danger float-right"><i class="glyphicon glyphicon-plus"></i> {{__('label.add_new')}} </a></div>
  92. </div>
  93. <div class="card-body">
  94. <div class="row mb-4">
  95. <div class="col-sm-12">
  96. </div>
  97. </div>
  98. <div class="jumbotron p-0">
  99. <div class="row">
  100. <div class="col-md-12">
  101. <div class="d-flex">
  102. <div>
  103. <button type="button" data-on-text="Open" data-off-text="Closed" class="btn mt-1 btn-toggle btn-sm btn-success switch-me" data-id="sorting" data-bs-toggle="button" aria-pressed="false" autocomplete="off">
  104. <div class="handle"></div>
  105. </button> <span class="mt-1">Sorting Enabled?</span>
  106. </div>
  107. {{-- <div class="ms-auto">--}}
  108. {{-- <button class="btn btn-primary save-pre-order" style="display: none">Save Pre Order Items</button>--}}
  109. {{-- </div>--}}
  110. </div>
  111. <div class="accordion" id="category-items">
  112. @if(isset($categories) && $categories->count() > 0)
  113. @foreach($categories as $k=>$category)
  114. <div class="accordion-item">
  115. {{-- <h2 class="accordion-header" id="category-{!! $category->id !!}-heading">--}}
  116. {{-- <div class="accordion-button">--}}
  117. {{-- <div>--}}
  118. {{-- <div class=" @if($k>0) collapsed @endif" type="button" data-bs-toggle="collapse" data-bs-target="#category-{!! $category->id !!}" aria-expanded="true" aria-controls="panelsStayOpen-collapseOne">--}}
  119. {{-- {!! $category->name !!}--}}
  120. {{-- </div>--}}
  121. {{-- </div>--}}
  122. {{-- @if( $allow_pre_order=="Yes")--}}
  123. {{-- <div class="ms-auto">--}}
  124. {{-- <input @if(isset($recipe) && $recipe->allow_pre_order=="Yes") checked @endif style="position: inherit; left: 0; opacity: 1; margin: 0 10px" id="allow_pre_order{!! $category->id !!}" name="allow_pre_order_category[]" class="allow_pre_order_category" value="{!! $category->id !!}" type="checkbox" />{{__('label.allow_pre_order')}}?--}}
  125. {{-- </div>--}}
  126. {{-- @endif--}}
  127. {{-- <div style="clear: both"></div>--}}
  128. {{-- </div>--}}
  129. {{-- </h2>--}}
  130. <h2 class="accordion-header" id="category-{!! $category->id !!}-heading">
  131. <button class="accordion-button @if($k>0) collapsed @endif" type="button" data-bs-toggle="collapse" data-bs-target="#category-{!! $category->id !!}" aria-expanded="true" aria-controls="panelsStayOpen-collapseOne">
  132. {!! $category->name !!}
  133. </button>
  134. </h2>
  135. <div id="category-{!! $category->id !!}" class="accordion-collapse collapse @if($k==0) show @endif" aria-labelledby="category-{!! $category->id !!}-heading">
  136. <div class="accordion-body">
  137. @if(isset($category->categories_has_recipes) && $category->categories_has_recipes->count() > 0)
  138. <ul class="list-group make-sortable">
  139. @foreach($category->categories_has_recipes as $item)
  140. @php
  141. $categories = isset($item->categories)?$item->categories->pluck('category_id'):NULL;
  142. $row_id = $item->id.'-'.(isset($categories[0])?$categories[0]:0);
  143. @endphp
  144. <li class="list-group-item" id="{!! $row_id !!}">
  145. <div class="d-flex align-content-start flex-wrap">
  146. <div class="flex-shrink-0 me-3">
  147. @php
  148. $img = isset($item->main_images)?$item->main_images->file_name:env('APP_ASSETS').'img/user/1.png';
  149. $img = str_replace(env('AWS_URL'),$imgix,$img).'?fm=webp&h=60&w=60&q=50&fit=center&crop=center';
  150. @endphp
  151. <img src="{!! $img !!}" alt="{!! $item->name !!}">
  152. </div>
  153. <div class="flex-grow-1">
  154. <div class="d-flex">
  155. <div>
  156. <p class="mt-1">{!! $item->name !!} @if(!empty($item->arabic_name)) (
  157. {!! $item->arabic_name !!} ) @endif </p>
  158. </div>
  159. <div class="ms-4 mt-1">( <strong> {!! number_format($item->price,2) !!} </strong>) </div>
  160. </div>
  161. <p>
  162. {!! ($item->status==1)?
  163. '<span class="badge badge-success m-1">Status: '.__('label.active').' </span>':'<span class="badge badge-danger m-1">Status: '.__('label.deactive').' </span>'
  164. !!}</span>
  165. {!! $item->is_customized?'<span class="badge badge-success">Customizable: '.__('label.yes').'</span>':'<span class="badge badge-danger">Customizable: '.__('label.no').'</span>' !!}
  166. </p>
  167. </div>
  168. @if( $allow_pre_order=="Yes")
  169. <div style="margin: 5px 20px">
  170. <input disabled @if(isset($item) && $item->allow_pre_order=="Yes") checked @endif style="position: inherit; left: 0; opacity: 1; margin: 0 10px" id="allow_pre_order{!! $item->id !!}" class="allow_pre_order_item" name="allow_pre_order_item[]" value="{!! $item->id !!}" type="checkbox" />{{__('label.allow_pre_order')}}?
  171. </div>
  172. @endif
  173. <div class=" ms-auto ">
  174. <a href="{!! env('APP_URL') !!}recipe/edit/{!! $item->id !!}" class="mr-2 badge badge-primary m-1" data-toggle="tooltip" data-placement="top" title="{{__('label.edit')}}"><i class="glyphicon glyphicon-edit"></i></a>
  175. <a href="javascript:;" data-id="{!! $item->id !!}" class="delete-recipe badge badge-danger m-1" data-toggle="tooltip" data-placement="top" title="{{__('label.delete')}}"> <i class="glyphicon glyphicon-trash"></i>
  176. </a>
  177. <a href="{!! env('QRCODE_HOST_ORDER') !!}{!! $item->restuarants->resto_unique_name !!}/item/{!! $item->unique_shared_key !!}" class="btn btn-sm btn-primary mb-1" target="_blank" data-toggle="tooltip" data-placement="top" title="Direct Link"><i class=" glyphicon glyphicon-paperclip"></i></a>
  178. <a href="{!! env('QRCODE_HOST_ORDER_SP') !!}/f/{!! $item->restuarants->resto_unique_name !!}?id={!! $item->unique_shared_key !!}" class="btn btn-sm btn-primary mb-1" target="_blank" data-toggle="tooltip" data-placement="top" title="Direct Link"><i class=" glyphicon glyphicon-paperclip"></i>&nbsp;FB&nbsp;</a>
  179. <a href="{!! env('QRCODE_HOST_ORDER_SP') !!}/t/{!! $item->restuarants->resto_unique_name !!}?id={!! $item->unique_shared_key !!}" class="btn btn-sm btn-primary mb-1" target="_blank" data-toggle="tooltip" data-placement="top" title="Direct Link"><i class=" glyphicon glyphicon-paperclip"></i>&nbsp;Ticktok&nbsp;</a>
  180. <a href="{!! env('QRCODE_HOST_ORDER_SP') !!}/i/{!! $item->restuarants->resto_unique_name !!}?id={!! $item->unique_shared_key !!}" class="btn btn-sm btn-primary mb-1" target="_blank" data-toggle="tooltip" data-placement="top" title="Direct Link"><i class=" glyphicon glyphicon-paperclip"></i>&nbsp;Insta&nbsp;</a>
  181. <a href="{!! env('QRCODE_HOST_ORDER_SP') !!}/g/{!! $item->restuarants->resto_unique_name !!}?id={!! $item->unique_shared_key !!}" class="btn btn-sm btn-primary mb-1" target="_blank" data-toggle="tooltip" data-placement="top" title="Direct Link"><i class=" glyphicon glyphicon-paperclip"></i>&nbsp;Google&nbsp;</a>
  182. </div>
  183. </div>
  184. </li>
  185. @endforeach
  186. </ul>
  187. @endif
  188. </div>
  189. </div>
  190. </div>
  191. @endforeach
  192. @endif
  193. </div>
  194. </div>
  195. </div>
  196. </div>
  197. </div>
  198. </div>
  199. </section>
  200. </div>
  201. </div>
  202. @endsection
  203. @section('js')
  204. <script src="{!! env('APP_ASSETS') !!}js/jquery-ui.min.js"></script>
  205. <script src="{!! env('APP_ASSETS') !!}js/jquery.ui.touch-punch.min.js"></script>
  206. <script>
  207. var resto_id = 0;
  208. $(function () {
  209. $("body").on("change",".allow_pre_order_category",function (){
  210. $(".save-pre-order").show();
  211. var _this = $(this);
  212. if(_this.is(":checked")){
  213. _this.parents(".accordion-item").find("input.allow_pre_order_item").prop("checked","checked");
  214. }else{
  215. _this.parents(".accordion-item").find("input.allow_pre_order_item").prop("checked",false);
  216. }
  217. });
  218. $("body").on("click",".save-pre-order",function(){
  219. var allow_selected_categories = $.map($('.allow_pre_order_category:checked'), function(c){return c.value; });
  220. var allow_selected_items = $.map($('.allow_pre_order_item:checked'), function(c){return c.value; });
  221. console.log(allow_selected_items);
  222. });
  223. $(window).resize(function(){
  224. if($(window).width() < 500){
  225. $("#captions").addClass('flex-column');
  226. }else{
  227. $("#captions").removeClass('flex-column');
  228. }
  229. });
  230. $("body").on("click",".switch-me",function (e) {
  231. var is_active = $(this).attr("aria-pressed");
  232. is_active = $.trim(is_active);
  233. if(is_active=="false"){
  234. $( ".make-sortable" ).sortable("disable");
  235. }else{
  236. $( ".make-sortable" ).each(function(){
  237. var _this = $(this);
  238. _this.sortable({
  239. olerance: 'pointer' ,
  240. disabled:false,
  241. items: "li",
  242. helper: fixHelper,
  243. cursor: 'move',
  244. start:function(event,ui){
  245. var data = _this.sortable('toArray');
  246. },
  247. update: function(event, ui) {
  248. //alert("New position: " + ui.item.index());
  249. // $('#dataTable').DataTable().destroy();
  250. // var table = data_table .draw();
  251. var data = _this.sortable('toArray');
  252. // $('#dataTable').DataTable();
  253. var recipe = [];
  254. var rows = _this.find('li');
  255. $(rows).each(function(index,element) {
  256. recipe.push({
  257. id: $(this).attr('id'),
  258. // id:element.DT_RowId,
  259. position: index+1
  260. });
  261. });
  262. // $
  263. console.log(recipe);
  264. $.ajax({
  265. url:'{!! env('APP_URL') !!}update/recipe/order',
  266. type:"POST",
  267. data:{
  268. ids:recipe,
  269. "_token":"{!! csrf_token() !!}"
  270. },
  271. success:function () {
  272. }
  273. });
  274. }
  275. });
  276. });
  277. $( "#sortable" ).disableSelection();
  278. }
  279. });
  280. var item_table = $('#example').DataTable({
  281. "bSort": false,
  282. "searching": true,
  283. "paging": true,
  284. "info": false,
  285. "bLengthChange": false,
  286. language: {
  287. @if($lang=='ar')
  288. url:`{{asset('public/assets/js/dataTablear.json')}}`,
  289. @endif
  290. paginate: {
  291. next: '<img src="{!! env("APP_ASSETS") !!}images/icons/next.png">', // or '→'
  292. previous: '<img src="{!! env("APP_ASSETS") !!}images/icons/preivew.png">' // or '←'
  293. }
  294. },
  295. });
  296. $("td nav").addClass('d-flex justify-content-center');
  297. var _item_categories = item_table.column(2, { search: 'applied' });
  298. // $("#category_list").html('<option value="">Choose category</option>');
  299. // _item_categories.data().unique().sort().each(function (d, j) {
  300. // $("#category_list").append('<option value="' + d + '">' + d + '</option>')
  301. //
  302. // });
  303. $("body").on("change","#category_list",function(){
  304. item_table = item_table.search($(this).val()).draw();
  305. // item_table.bPaginate = false;
  306. // item_table.draw;
  307. // var oSettings = item_table.settings();
  308. // oSettings.bPaginate = false;
  309. });
  310. var fixHelper = function(e, ui) {
  311. ui.children().each(function() {
  312. $(this).width($(this).width());
  313. });
  314. return ui;
  315. };
  316. $("body").on('click','.delete-recipe',function () {
  317. var id = $(this).data('id');
  318. //alert();
  319. swal({
  320. title: " Confirm?",
  321. text: "Do you want delete?",
  322. type: "error",
  323. showCancelButton: true,
  324. confirmButtonClass: "btn-danger",
  325. confirmButtonText: " Confirm, delete it!",
  326. cancelButtonText: "No, cancel please!",
  327. closeOnConfirm: true,
  328. closeOnCancel: true
  329. },
  330. function(isConfirm) {
  331. if (isConfirm) {
  332. $.ajax({
  333. url:"{!! env('APP_URL') !!}recipe/delete/"+id,
  334. success:function (response) {
  335. location.reload();
  336. }
  337. });
  338. }
  339. });
  340. });
  341. $("body").on('click','.save-credentails',function () {
  342. var password = $("#password").html();
  343. $.ajax({
  344. url:"{!! env('APP_URL') !!}update/password",
  345. type:"POST",
  346. data:{
  347. resto_id:resto_id,
  348. password:password,
  349. '_token':"{!! csrf_token() !!}"
  350. },
  351. success:function (response) {
  352. $("#create-credentials .alert").show();
  353. setTimeout(function () {
  354. location.reload();
  355. },1500)
  356. }
  357. });
  358. });
  359. })
  360. </script>
  361. @endsection