categories.blade.php_09-05 9.0 KB

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