recipes-sorted.blade.php 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405
  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. @endphp
  37. <link href="{!! env('APP_ASSETS') !!}css/jquery-ui.min.css" rel="stylesheet" />
  38. <style>
  39. .pagination li.active a.page-link {
  40. color: white !important;
  41. background: #ffa505 !important;
  42. }
  43. .accordion-button{
  44. background-color: #ffab00 !important;
  45. color: #fff !important;
  46. }
  47. .page-link{
  48. padding: .5em 1em !important;
  49. border-radius: 2px;
  50. border: 0;
  51. margin: 0;
  52. min-width: 50px !important;
  53. text-align: center;
  54. }
  55. .page-item.active .page-link{
  56. background-color: #4c95dd;
  57. }
  58. table.dataTable {
  59. clear: both;
  60. margin-top: 6px !important;
  61. margin-bottom: 6px !important;
  62. max-width: none !important;
  63. border-collapse: collapse !important;
  64. font-family: 'Open Sans';
  65. }
  66. /*table.dataTable td{
  67. border-width: 1px;
  68. }*/
  69. .theme-primary .pagination li a:hover {
  70. background-color: #000 !important;
  71. }
  72. .table > :not(:last-child) > :last-child > * {
  73. border-bottom-color: transparent;
  74. }
  75. table.dataTable th{font-weight: 700 !important;}
  76. .dataTables_paginate {
  77. width: 100%;
  78. text-align: center;
  79. }
  80. div.dataTables_wrapper div.dataTables_paginate ul.pagination{
  81. justify-content: center !important;
  82. }
  83. </style>
  84. <div class="content-wrapper">
  85. <div class="container-full">
  86. <section class="content">
  87. <div class="card p-15 rounded-1">
  88. <div class="card-header">
  89. <div class="col-6"><h3 style="margin-left: 10px">{{__('label.items')}}</h3></div>
  90. <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>
  91. </div>
  92. <div class="card-body">
  93. <div class="row mb-4">
  94. <div class="col-sm-12">
  95. </div>
  96. </div>
  97. <div class="jumbotron p-0">
  98. <div class="row">
  99. <div class="col-md-12">
  100. <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">
  101. <div class="handle"></div>
  102. </button> <span class="mt-1">Sorting Enabled?</span>
  103. <div class="accordion" id="category-items">
  104. @if(isset($categories) && $categories->count() > 0)
  105. @foreach($categories as $k=>$category)
  106. <div class="accordion-item">
  107. <h2 class="accordion-header" id="category-{!! $category->id !!}-heading">
  108. <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">
  109. {!! $category->name !!}
  110. </button>
  111. </h2>
  112. <div id="category-{!! $category->id !!}" class="accordion-collapse collapse @if($k==0) show @endif" aria-labelledby="category-{!! $category->id !!}-heading">
  113. <div class="accordion-body">
  114. @if(isset($category->categories_has_recipes) && $category->categories_has_recipes->count() > 0)
  115. <ul class="list-group make-sortable">
  116. @foreach($category->categories_has_recipes as $item)
  117. @php
  118. $categories = isset($item->categories)?$item->categories->pluck('category_id'):NULL;
  119. $row_id = $item->id.'-'.(isset($categories[0])?$categories[0]:0);
  120. @endphp
  121. <li class="list-group-item" id="{!! $row_id !!}">
  122. <div class="d-flex align-content-start flex-wrap">
  123. <div class="flex-shrink-0 me-3">
  124. @php
  125. $img = isset($item->main_images)?$item->main_images->file_name:env('APP_ASSETS').'img/user/1.png';
  126. $img = str_replace(env('AWS_URL'),$imgix,$img).'?fm=webp&h=60&w=60&q=50&fit=center&crop=center';
  127. @endphp
  128. <img src="{!! $img !!}" alt="{!! $item->name !!}">
  129. </div>
  130. <div class="flex-grow-1">
  131. <div class="d-flex">
  132. <div>
  133. <p class="mt-1">{!! $item->name !!} @if(!empty($item->arabic_name)) (
  134. {!! $item->arabic_name !!} ) @endif </p>
  135. </div>
  136. <div class="ms-4 mt-1">( <strong> {!! number_format($item->price,2) !!} </strong>) </div>
  137. </div>
  138. <p>
  139. {!! ($item->status==1)?
  140. '<span class="badge badge-success m-1">Status: '.__('label.active').' </span>':'<span class="badge badge-danger m-1">Status: '.__('label.deactive').' </span>'
  141. !!}</span>
  142. {!! $item->is_customized?'<span class="badge badge-success">Customizable: '.__('label.yes').'</span>':'<span class="badge badge-danger">Customizable: '.__('label.no').'</span>' !!}
  143. </p>
  144. </div>
  145. <div class=" ms-auto ">
  146. <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>
  147. <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>
  148. </a>
  149. <a href="{!! env('QRCODE_HOST_ORDER') !!}{!! $item->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>
  150. <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>
  151. <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>
  152. <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>
  153. <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>
  154. </div>
  155. </div>
  156. </li>
  157. @endforeach
  158. </ul>
  159. @endif
  160. </div>
  161. </div>
  162. </div>
  163. @endforeach
  164. @endif
  165. </div>
  166. </div>
  167. </div>
  168. </div>
  169. </div>
  170. </div>
  171. </section>
  172. </div>
  173. </div>
  174. @endsection
  175. @section('js')
  176. <script src="{!! env('APP_ASSETS') !!}js/jquery-ui.min.js"></script>
  177. <script src="{!! env('APP_ASSETS') !!}js/jquery.ui.touch-punch.min.js"></script>
  178. <script>
  179. var resto_id = 0;
  180. $(function () {
  181. $(window).resize(function(){
  182. if($(window).width() < 500){
  183. $("#captions").addClass('flex-column');
  184. }else{
  185. $("#captions").removeClass('flex-column');
  186. }
  187. });
  188. $("body").on("click",".switch-me",function (e) {
  189. var is_active = $(this).attr("aria-pressed");
  190. is_active = $.trim(is_active);
  191. if(is_active=="false"){
  192. $( ".make-sortable" ).sortable("disable");
  193. }else{
  194. $( ".make-sortable" ).each(function(){
  195. var _this = $(this);
  196. _this.sortable({
  197. olerance: 'pointer' ,
  198. disabled:false,
  199. items: "li",
  200. helper: fixHelper,
  201. cursor: 'move',
  202. start:function(event,ui){
  203. var data = _this.sortable('toArray');
  204. },
  205. update: function(event, ui) {
  206. //alert("New position: " + ui.item.index());
  207. // $('#dataTable').DataTable().destroy();
  208. // var table = data_table .draw();
  209. var data = _this.sortable('toArray');
  210. // $('#dataTable').DataTable();
  211. var recipe = [];
  212. var rows = _this.find('li');
  213. $(rows).each(function(index,element) {
  214. recipe.push({
  215. id: $(this).attr('id'),
  216. // id:element.DT_RowId,
  217. position: index+1
  218. });
  219. });
  220. // $
  221. console.log(recipe);
  222. $.ajax({
  223. url:'{!! env('APP_URL') !!}update/recipe/order',
  224. type:"POST",
  225. data:{
  226. ids:recipe,
  227. "_token":"{!! csrf_token() !!}"
  228. },
  229. success:function () {
  230. }
  231. });
  232. }
  233. });
  234. });
  235. $( "#sortable" ).disableSelection();
  236. }
  237. });
  238. var item_table = $('#example').DataTable({
  239. "bSort": false,
  240. "searching": true,
  241. "paging": true,
  242. "info": false,
  243. "bLengthChange": false,
  244. language: {
  245. @if($lang=='ar')
  246. url:`{{asset('public/assets/js/dataTablear.json')}}`,
  247. @endif
  248. paginate: {
  249. next: '<img src="{!! env("APP_ASSETS") !!}images/icons/next.png">', // or '→'
  250. previous: '<img src="{!! env("APP_ASSETS") !!}images/icons/preivew.png">' // or '←'
  251. }
  252. },
  253. });
  254. $("td nav").addClass('d-flex justify-content-center');
  255. var _item_categories = item_table.column(2, { search: 'applied' });
  256. $("#category_list").html('<option value="">Choose category</option>');
  257. _item_categories.data().unique().sort().each(function (d, j) {
  258. $("#category_list").append('<option value="' + d + '">' + d + '</option>')
  259. });
  260. $("body").on("change","#category_list",function(){
  261. item_table = item_table.search($(this).val()).draw();
  262. // item_table.bPaginate = false;
  263. // item_table.draw;
  264. // var oSettings = item_table.settings();
  265. // oSettings.bPaginate = false;
  266. });
  267. var fixHelper = function(e, ui) {
  268. ui.children().each(function() {
  269. $(this).width($(this).width());
  270. });
  271. return ui;
  272. };
  273. $("body").on('click','.delete-recipe',function () {
  274. var id = $(this).data('id');
  275. swal({
  276. title: " Confirm?",
  277. text: "Do you want delete?",
  278. type: "error",
  279. showCancelButton: true,
  280. confirmButtonClass: "btn-danger",
  281. confirmButtonText: " Confirm, delete it!",
  282. cancelButtonText: "No, cancel please!",
  283. closeOnConfirm: true,
  284. closeOnCancel: true
  285. },
  286. function(isConfirm) {
  287. if (isConfirm) {
  288. $.ajax({
  289. url:"{!! env('APP_URL') !!}recipe/delete/"+id,
  290. success:function (response) {
  291. location.reload();
  292. }
  293. });
  294. }
  295. });
  296. });
  297. $("body").on('click','.save-credentails',function () {
  298. var password = $("#password").html();
  299. $.ajax({
  300. url:"{!! env('APP_URL') !!}update/password",
  301. type:"POST",
  302. data:{
  303. resto_id:resto_id,
  304. password:password,
  305. '_token':"{!! csrf_token() !!}"
  306. },
  307. success:function (response) {
  308. $("#create-credentials .alert").show();
  309. setTimeout(function () {
  310. location.reload();
  311. },1500)
  312. }
  313. });
  314. });
  315. })
  316. </script>
  317. @endsection