categories.blade.php02-05 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  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. .page-link{
  9. padding: .5em 1em !important;
  10. border-radius: 2px;
  11. border: 0;
  12. margin: 0;
  13. min-width: 50px !important;
  14. text-align: center;
  15. }
  16. .page-item.active .page-link{
  17. background-color: #4c95dd;
  18. }
  19. table.dataTable {
  20. clear: both;
  21. margin-top: 6px !important;
  22. margin-bottom: 6px !important;
  23. max-width: none !important;
  24. border-collapse: collapse !important;
  25. font-family: 'Open Sans';
  26. }
  27. /*table.dataTable td{
  28. border-width: 1px;
  29. }*/
  30. .theme-primary .pagination li a:hover {
  31. background-color: #000 !important;
  32. }
  33. .table > :not(:last-child) > :last-child > * {
  34. border-bottom-color: transparent;
  35. }
  36. table.dataTable th{font-weight: 700 !important;}
  37. .dataTables_paginate {
  38. width: 100%;
  39. text-align: center;
  40. }
  41. div.dataTables_wrapper div.dataTables_paginate ul.pagination{
  42. justify-content: center !important;
  43. }
  44. </style>
  45. @php
  46. $resto = \App\Restaurants::find(\App\Helpers\CommonMethods::getRestuarantID());
  47. $lang = $resto->default_lang;
  48. app()->setLocale($lang);
  49. if(session('app_lang') !==null){
  50. $lang = session('app_lang');
  51. app()->setLocale($lang);
  52. }
  53. @endphp
  54. <div class="content-wrapper">
  55. <div class="container-full">
  56. <section class="content">
  57. <div class="row">
  58. <div class="col-6"><h3 style="margin-left: 10px">{{__('label.categories')}}</h3></div>
  59. <div class="col-6 text-end"><a href="{!! env('APP_URL') !!}category/new" class="btn btn-sm btn-danger float-right"><i class="glyphicon glyphicon-plus"></i> {{__('label.add_new')}} </a></div>
  60. </div>
  61. <div class="card p-15 rounded-1">
  62. <div class="jumbotron p-0">
  63. <div class="row">
  64. <div class="col-md-12">
  65. <div class="table-responsive">
  66. <table class="table table-bordered" id="example" width="100%" cellspacing="0">
  67. <thead>
  68. <tr class="text-uppercase">
  69. <!-- <th></th> -->
  70. <!-- <th>Display Order</th>-->
  71. <th>{{__('label.id')}}</th>
  72. <th>{{__('label.category_name')}}</th>
  73. <th>{{__('label.category_name_arabic')}}</th>
  74. <th>{{__('label.actions')}}</th>
  75. </tr>
  76. </thead>
  77. <tbody>
  78. <!----><!---->
  79. @if(isset($categories) && $categories->count() > 0)
  80. @foreach($categories as $k=>$category)
  81. <tr @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 !!}">
  82. <!-- <td>
  83. <div style="height: 48px; width: 48px; background-image: url(@if(isset($category->main_images)) {!! $category->main_images->file_name !!} @else {!! env('APP_ASSETS') !!}img/user/1.png @endif); background-size: cover; background-position: center;"></div>
  84. </td> -->
  85. <!-- <td>{!! $category->display_order !!}</td>-->
  86. <td>{!! $category->id !!}</td>
  87. <td> {!! $category->name !!}
  88. </td>
  89. <td> {!! $category->arabic_name !!}</td>
  90. <td>
  91. @if(\Illuminate\Support\Facades\Auth::user()->role=="restaurant" && \Illuminate\Support\Facades\Auth::user()->restaurants->id==$category->resto_id)
  92. <a href="{!! env('APP_URL') !!}category/edit/{!! $category->id !!}" class="btn btn-sm btn-primary" title="Edit"><i class="glyphicon glyphicon-edit"></i></a>
  93. <a href="javascript:;" data-id="{!! $category->id !!}" class="btn btn-sm btn-danger delete-category" ><i class="glyphicon glyphicon-trash"></i></a>
  94. @elseif(\Illuminate\Support\Facades\Auth::user()->role=="restaurant")
  95. <span class="badge badge-info">{{__('label.not_editable_by_super_admin')}}</span>
  96. @else
  97. @if(\Illuminate\Support\Facades\Auth::user()->role=="administrator")
  98. <a href="{!! env('APP_URL') !!}category/edit/{!! $category->id !!}" class="btn btn-sm btn-primary" ><i class="glyphicon glyphicon-edit"></i></a>
  99. <a href="javascript:;" data-id="{!! $category->id !!}" class="btn btn-sm btn-danger delete-category"><i class="glyphicon glyphicon-trash" ></i></a>
  100. @endif
  101. @endif
  102. </td>
  103. </tr>
  104. @endforeach
  105. @endif
  106. </tbody>
  107. </table>
  108. </div>
  109. </div>
  110. </div>
  111. </div>
  112. </div>
  113. </section>
  114. </div>
  115. </div>
  116. @endsection
  117. @section('js')
  118. <script src="{!! env('APP_ASSETS') !!}js/jquery-ui.min.js"></script>
  119. <script>
  120. $(function () {
  121. var fixHelper = function(e, ui) {
  122. ui.children().each(function() {
  123. $(this).width($(this).width());
  124. });
  125. return ui;
  126. };
  127. /* $( "tbody" ).sortable({
  128. olerance: 'pointer' ,
  129. items: "tr",
  130. helper: fixHelper,
  131. cursor: 'move',
  132. start:function(event,ui){
  133. var data = $("tbody").sortable('toArray');
  134. console.log(data);
  135. },
  136. stop: function(event, ui) {
  137. //alert("New position: " + ui.item.index());
  138. var data = $("tbody").sortable('toArray');
  139. var category = [];
  140. var rows = $("tbody tr.data-row");
  141. $(rows).each(function(index,element) {
  142. category.push({
  143. id: $(this).attr('id'),
  144. // id:element.DT_RowId,
  145. position: index+1
  146. });
  147. });
  148. // $
  149. // console.log(category);
  150. $.ajax({
  151. url:'{!! env('APP_URL') !!}update/category/order',
  152. type:"POST",
  153. data:{
  154. ids:category,
  155. "_token":"{!! csrf_token() !!}"
  156. },
  157. success:function () {
  158. }
  159. });
  160. }
  161. });*/
  162. $('#example').DataTable({
  163. "bSort": true,
  164. "searching": true,
  165. "paging": true,
  166. "info": false,
  167. "bLengthChange": false,
  168. language: {
  169. @if($lang=='ar')
  170. url:`{{asset('public/assets/js/dataTablear.json')}}`,
  171. @endif
  172. paginate: {
  173. next: '<img src="{!! env("APP_ASSETS") !!}images/icons/next.png">', // or '→'
  174. previous: '<img src="{!! env("APP_ASSETS") !!}images/icons/preivew.png">' // or '←'
  175. }
  176. },
  177. });
  178. $("td nav").addClass('d-flex justify-content-center');
  179. $("body").on('click','.delete-category',function () {
  180. var id = $(this).data('id');
  181. $.ajax({
  182. url:"{!! env('APP_URL') !!}category/delete/"+id,
  183. success:function (response) {
  184. location.reload();
  185. }
  186. });
  187. });
  188. })
  189. </script>
  190. @endsection