categories.blade.php_111-05 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  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\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="jumbotron p-0">
  98. <div class="row">
  99. <div class="col-md-12">
  100. <ul class="list-group" id="sortable">
  101. @if(isset($categories) && $categories->count() > 0)
  102. @foreach($categories as $k=>$category)
  103. <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 !!}">
  104. <div class="d-flex">
  105. <div class="flex-column p-1">
  106. <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-list-ul" viewBox="0 0 16 16">
  107. <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"/>
  108. </svg>
  109. </div>
  110. <div class="flex-column p-1">{!! $category->name !!} ( {!! $category->arabic_name !!} )</div>
  111. <div class="flex-column ms-auto">
  112. @if(\Illuminate\Support\Facades\Auth::user()->role=="restaurant" && \Illuminate\Support\Facades\Auth::user()->restaurants->id==$category->resto_id)
  113. <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>
  114. <a href="javascript:;" data-id="{!! $category->id !!}" class="btn btn-sm btn-danger delete-category"><i class="glyphicon glyphicon-trash"></i></a>
  115. @elseif(\Illuminate\Support\Facades\Auth::user()->role=="restaurant")
  116. <span class="badge badge-info">{{__('label.not_editable_by_super_admin')}}</span>
  117. @else
  118. @if(\Illuminate\Support\Facades\Auth::user()->role=="administrator")
  119. <a href="{!! env('APP_URL') !!}category/edit/{!! $category->id !!}" class="btn btn-sm btn-primary"><i class="glyphicon glyphicon-edit"></i></a>
  120. <a href="javascript:;" data-id="{!! $category->id !!}" class="btn btn-sm btn-danger delete-category"><i class="glyphicon glyphicon-trash" ></i></a>
  121. @endif
  122. @endif
  123. </div>
  124. </div>
  125. </li>
  126. @endforeach
  127. @endif
  128. </ul>
  129. </div>
  130. </div>
  131. </div>
  132. </div>
  133. </section>
  134. </div>
  135. </div>
  136. @endsection
  137. @section('js')
  138. <script src="{!! env('APP_ASSETS') !!}js/jquery-ui.min.js"></script>
  139. <script>
  140. $(function () {
  141. var fixHelper = function(e, ui) {
  142. ui.children().each(function() {
  143. $(this).width($(this).width());
  144. });
  145. return ui;
  146. };
  147. $( "#sortable" ).sortable({
  148. placeholder: "ui-state-highlight",
  149. cursor: 'move',
  150. start:function(event,ui){
  151. var data = $("#sortable").sortable('toArray');
  152. console.log(data);
  153. },
  154. stop: function(event, ui) {
  155. //alert("New position: " + ui.item.index());
  156. var data = $("#sortable").sortable('toArray');
  157. var category = [];
  158. var rows = $(".list-group-item.data-row");
  159. console.log(rows);
  160. $(data).each(function(index,element) {
  161. category.push({
  162. id: element,
  163. // id:element.DT_RowId,
  164. position: index+1
  165. });
  166. });
  167. // $
  168. //console.log(category);
  169. //return false;
  170. $.ajax({
  171. url:'{!! env('APP_URL') !!}update/category/order',
  172. type:"POST",
  173. data:{
  174. ids:category,
  175. "_token":"{!! csrf_token() !!}"
  176. },
  177. success:function () {
  178. }
  179. });
  180. }
  181. });
  182. $( "#sortable" ).disableSelection();
  183. /*$( "#sortable" ).sortable({
  184. olerance: 'pointer' ,
  185. items: "tr",
  186. helper: fixHelper,
  187. cursor: 'move',
  188. start:function(event,ui){
  189. var data = $("#sortable").sortable('toArray');
  190. console.log(data);
  191. },
  192. stop: function(event, ui) {
  193. //alert("New position: " + ui.item.index());
  194. var data = $("tbody").sortable('toArray');
  195. var category = [];
  196. var rows = $("tbody tr.data-row");
  197. $(rows).each(function(index,element) {
  198. category.push({
  199. id: $(this).attr('id'),
  200. // id:element.DT_RowId,
  201. position: index+1
  202. });
  203. });
  204. // $
  205. // console.log(category);
  206. $.ajax({
  207. url:'{!! env('APP_URL') !!}update/category/order',
  208. type:"POST",
  209. data:{
  210. ids:category,
  211. "_token":"{!! csrf_token() !!}"
  212. },
  213. success:function () {
  214. }
  215. });
  216. }
  217. }); */
  218. $('#example').DataTable({
  219. "bSort": true,
  220. "searching": true,
  221. "paging": true,
  222. "info": false,
  223. "bLengthChange": false,
  224. language: {
  225. @if($lang=='ar')
  226. url:`{{asset('public/assets/js/dataTablear.json')}}`,
  227. @endif
  228. paginate: {
  229. next: '<img src="{!! env("APP_ASSETS") !!}images/icons/next.png">', // or '→'
  230. previous: '<img src="{!! env("APP_ASSETS") !!}images/icons/preivew.png">' // or '←'
  231. }
  232. },
  233. });
  234. $("td nav").addClass('d-flex justify-content-center');
  235. $("body").on('click','.delete-category',function () {
  236. var id = $(this).data('id');
  237. $.ajax({
  238. url:"{!! env('APP_URL') !!}category/delete/"+id,
  239. success:function (response) {
  240. location.reload();
  241. }
  242. });
  243. });
  244. })
  245. </script>
  246. @endsection