categories.blade.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343
  1. @extends('layouts.app')
  2. @section('content')
  3. <style>
  4. /*.pagination li.active a.page-link {
  5. color: white !important;
  6. background: #ffa505 !important;
  7. }*/
  8. .category_title{
  9. margin-top: 17px;
  10. margin-bottom: 17px;
  11. }
  12. .add_btn_div{
  13. display: flex;
  14. align-items: center;
  15. justify-content: end;
  16. }
  17. .dataTables_filter input[type='search']
  18. {
  19. margin-right: 0;
  20. }
  21. .page-link{
  22. padding: .5em 1em !important;
  23. border-radius: 2px;
  24. border: 0;
  25. margin: 0;
  26. min-width: 50px !important;
  27. text-align: center;
  28. }
  29. .page-item.active .page-link{
  30. background-color: #4c95dd;
  31. }
  32. table.dataTable {
  33. clear: both;
  34. margin-top: 6px !important;
  35. margin-bottom: 6px !important;
  36. max-width: none !important;
  37. border-collapse: collapse !important;
  38. font-family: 'Open Sans';
  39. }
  40. /*table.dataTable td{
  41. border-width: 1px;
  42. }*/
  43. .theme-primary .pagination li a:hover {
  44. background-color: #000 !important;
  45. }
  46. .table > :not(:last-child) > :last-child > * {
  47. border-bottom-color: transparent;
  48. }
  49. table.dataTable th{font-weight: 700 !important;}
  50. .dataTables_paginate {
  51. width: 100%;
  52. text-align: center;
  53. }
  54. div.dataTables_wrapper div.dataTables_paginate ul.pagination{
  55. justify-content: center !important;
  56. }
  57. .category_title {
  58. padding-left: 36px;
  59. }
  60. .cate_add_btn{
  61. margin-right: 36px;
  62. }
  63. @media (max-width:767px) {
  64. .category_title {
  65. padding-left: 0px;
  66. }
  67. .cate_add_btn{
  68. margin-right: 0px;
  69. }
  70. }
  71. @media (max-width:1024px) {
  72. .content {
  73. padding-top: 30px;
  74. }
  75. .cate_add_btn{
  76. margin-top: 10px;
  77. }
  78. }
  79. </style>
  80. @php
  81. $resto = \App\Models\Restaurants::find(\App\Helpers\CommonMethods::getRestuarantID());
  82. $lang = $resto->default_lang;
  83. app()->setLocale($lang);
  84. if(session('app_lang') !==null){
  85. $lang = session('app_lang');
  86. app()->setLocale($lang);
  87. }
  88. @endphp
  89. <div class="content-wrapper">
  90. <div class="container-full">
  91. <section class="content">
  92. <div class="row">
  93. <div class="col-6"><h3 class="category_title" style="margin-left: 10px">{{__('label.categories')}}</h3></div>
  94. <div class="col-6 text-end add_btn_div"><a href="{!! env('APP_URL') !!}category/new{{ isset($_GET['menu'])?'?menu=tablet':''}}" class="btn btn-sm btn-danger float-right cate_add_btn"><i class="glyphicon glyphicon-plus"></i> {{__('label.add_new')}} </a></div>
  95. </div>
  96. <div class="card p-15 rounded-1">
  97. <div class="row mb-4">
  98. <div class="col-sm-12">
  99. <button type="button" data-on-text="Open" data-off-text="Closed" class="btn btn-toggle btn-sm btn-success switch-me" data-id="sorting" data-bs-toggle="button" aria-pressed="false" autocomplete="off">
  100. <div class="handle"></div>
  101. </button> Sorting Enabled?
  102. </div>
  103. </div>
  104. <div class="jumbotron p-0">
  105. <div class="row">
  106. <div class="col-md-12">
  107. <ul class="list-group" id="sortable">
  108. @if(isset($categories) && $categories->count() > 0)
  109. @foreach($categories as $k=>$category)
  110. <li class="list-group-item" @if(\Illuminate\Support\Facades\Auth::user()->role=="restaurant" && \Illuminate\Support\Facades\Auth::user()->restaurants->id==$category->resto_id) class="data-row" @endif id="{!! $category->id !!}">
  111. <div class="d-flex">
  112. <div class="flex-column p-1">
  113. <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-list-ul" viewBox="0 0 16 16">
  114. <path fill-rule="evenodd" d="M5 11.5a.5.5 0 0 1 .5-.5h9a.5.5 0 0 1 0 1h-9a.5.5 0 0 1-.5-.5zm0-4a.5.5 0 0 1 .5-.5h9a.5.5 0 0 1 0 1h-9a.5.5 0 0 1-.5-.5zm0-4a.5.5 0 0 1 .5-.5h9a.5.5 0 0 1 0 1h-9a.5.5 0 0 1-.5-.5zm-3 1a1 1 0 1 0 0-2 1 1 0 0 0 0 2zm0 4a1 1 0 1 0 0-2 1 1 0 0 0 0 2zm0 4a1 1 0 1 0 0-2 1 1 0 0 0 0 2z"/>
  115. </svg>
  116. </div>
  117. <div class="flex-column p-1" style="width: 50%">{!! $category->name !!} ( {!! $category->arabic_name !!} )</div>
  118. <div class="flex-column p-1">
  119. @if(isset($category->parent_category))
  120. <span class="badge badge-dark">{!! $category->parent_category->name !!}</span>
  121. @endif
  122. </div>
  123. <div class="flex-column @if($lang=="en") ms-auto @else ml-auto @endif">
  124. @if(\Illuminate\Support\Facades\Auth::user()->role=="restaurant" && \Illuminate\Support\Facades\Auth::user()->restaurants->id==$category->resto_id)
  125. <a href="{!! env('APP_URL') !!}category/edit/{!! $category->id !!}{{ isset($_GET['menu'])?'?menu=tablet':''}}" class="btn btn-sm btn-primary" ><i class="glyphicon glyphicon-edit"></i></a>
  126. <a href="javascript:;" data-id="{!! $category->id !!}" class="btn btn-sm btn-danger delete-category"><i class="glyphicon glyphicon-trash"></i></a>
  127. @elseif(\Illuminate\Support\Facades\Auth::user()->role=="restaurant")
  128. <span class="badge badge-info">{{__('label.not_editable_by_super_admin')}}</span>
  129. @else
  130. @if(\Illuminate\Support\Facades\Auth::user()->role=="administrator")
  131. <a href="{!! env('APP_URL') !!}category/edit/{!! $category->id !!}" class="btn btn-sm btn-primary"><i class="glyphicon glyphicon-edit"></i></a>
  132. <a href="javascript:;" data-id="{!! $category->id !!}" class="btn btn-sm btn-danger delete-category"><i class="glyphicon glyphicon-trash" ></i></a>
  133. @endif
  134. @endif
  135. </div>
  136. </div>
  137. </li>
  138. @endforeach
  139. @endif
  140. </ul>
  141. </div>
  142. </div>
  143. </div>
  144. </div>
  145. </section>
  146. </div>
  147. </div>
  148. @endsection
  149. @section('js')
  150. <script src="{!! env('APP_ASSETS') !!}js/jquery-ui.min.js"></script>
  151. <script src="{!! env('APP_ASSETS') !!}js/jquery.ui.touch-punch.min.js"></script>
  152. <script>
  153. $(function () {
  154. var fixHelper = function(e, ui) {
  155. ui.children().each(function() {
  156. $(this).width($(this).width());
  157. });
  158. return ui;
  159. };
  160. $("body").on("click",".switch-me",function (e) {
  161. var is_active = $(this).attr("aria-pressed");
  162. is_active = $.trim(is_active);
  163. if(is_active=="false"){
  164. $( "#sortable" ).sortable("disable");
  165. }else{
  166. $( "#sortable" ).sortable({
  167. placeholder: "ui-state-highlight",
  168. disabled:false,
  169. cursor: 'move',
  170. start:function(event,ui){
  171. var data = $("#sortable").sortable('toArray');
  172. console.log(data);
  173. },
  174. stop: function(event, ui) {
  175. //alert("New position: " + ui.item.index());
  176. var data = $("#sortable").sortable('toArray');
  177. var category = [];
  178. var rows = $(".list-group-item.data-row");
  179. console.log(rows);
  180. $(data).each(function(index,element) {
  181. category.push({
  182. id: element,
  183. // id:element.DT_RowId,
  184. position: index+1
  185. });
  186. });
  187. // $
  188. //console.log(category);
  189. //return false;
  190. $.ajax({
  191. url:'{!! env('APP_URL') !!}update/category/order',
  192. type:"POST",
  193. data:{
  194. ids:category,
  195. "_token":"{!! csrf_token() !!}"
  196. },
  197. success:function () {
  198. }
  199. });
  200. }
  201. });
  202. $( "#sortable" ).disableSelection();
  203. }
  204. });
  205. /*$( "#sortable" ).sortable({
  206. olerance: 'pointer' ,
  207. items: "tr",
  208. helper: fixHelper,
  209. cursor: 'move',
  210. start:function(event,ui){
  211. var data = $("#sortable").sortable('toArray');
  212. console.log(data);
  213. },
  214. stop: function(event, ui) {
  215. //alert("New position: " + ui.item.index());
  216. var data = $("tbody").sortable('toArray');
  217. var category = [];
  218. var rows = $("tbody tr.data-row");
  219. $(rows).each(function(index,element) {
  220. category.push({
  221. id: $(this).attr('id'),
  222. // id:element.DT_RowId,
  223. position: index+1
  224. });
  225. });
  226. // $
  227. // console.log(category);
  228. $.ajax({
  229. url:'{!! env('APP_URL') !!}update/category/order',
  230. type:"POST",
  231. data:{
  232. ids:category,
  233. "_token":"{!! csrf_token() !!}"
  234. },
  235. success:function () {
  236. }
  237. });
  238. }
  239. }); */
  240. $('#example').DataTable({
  241. "bSort": true,
  242. "searching": true,
  243. "paging": true,
  244. "info": false,
  245. "bLengthChange": false,
  246. language: {
  247. @if($lang=='ar')
  248. url:`{{asset('public/assets/js/dataTablear.json')}}`,
  249. @endif
  250. paginate: {
  251. next: '<img src="{!! env("APP_ASSETS") !!}images/icons/next.png">', // or '→'
  252. previous: '<img src="{!! env("APP_ASSETS") !!}images/icons/preivew.png">' // or '←'
  253. }
  254. },
  255. });
  256. $("td nav").addClass('d-flex justify-content-center');
  257. $("body").on('click','.delete-category',function () {
  258. var id = $(this).data('id');
  259. swal({
  260. title: " Confirm?",
  261. text: "Do you want delete?",
  262. type: "error",
  263. showCancelButton: true,
  264. confirmButtonClass: "btn-danger",
  265. confirmButtonText: " Confirm, delete it!",
  266. cancelButtonText: "No, cancel please!",
  267. closeOnConfirm: true,
  268. closeOnCancel: true
  269. },
  270. function(isConfirm) {
  271. if (isConfirm) {
  272. $.ajax({
  273. url:"{!! env('APP_URL') !!}category/delete/"+id,
  274. success:function (response) {
  275. location.reload();
  276. }
  277. });
  278. }
  279. });
  280. });
  281. })
  282. </script>
  283. @endsection