recipes-sorted.blade.php 18 KB

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