recipes.blade.php 24 KB

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