categories.blade.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363
  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: 0px;
  59. }
  60. .cate_add_btn{
  61. margin-right: 13px;
  62. }
  63. .fixed .content-wrapper{
  64. padding-top: 0px;
  65. }
  66. @media (max-width:767px) {
  67. .category_title {
  68. padding-left: 0px;
  69. }
  70. .cate_add_btn{
  71. margin-right: 0px;
  72. }
  73. }
  74. @media (max-width:1024px) {
  75. .content {
  76. padding-top: 30px;
  77. }
  78. .cate_add_btn{
  79. margin-top: 10px;
  80. }
  81. }
  82. .category_title{
  83. font-size: 1.7142857142857142rem;
  84. margin-left: 15px;
  85. }
  86. html[dir="rtl"] .list-group{
  87. padding-right: 0;
  88. }
  89. html[dir="rtl"] .category_title{
  90. margin-right: 15px;
  91. }
  92. html[dir="rtl"] .ar-mr-0{
  93. margin-right: 0 !important;
  94. margin-left: 5px !important;
  95. }
  96. .ar-mr-0{
  97. margin-left: 0 !important;
  98. margin-right: 5px !important;
  99. }
  100. </style>
  101. @php
  102. $resto = \App\Models\Restaurants::find(\App\Helpers\CommonMethods::getRestuarantID());
  103. $lang = $resto->default_lang;
  104. app()->setLocale($lang);
  105. if(session('app_lang') !==null){
  106. $lang = session('app_lang');
  107. app()->setLocale($lang);
  108. }
  109. @endphp
  110. <div class="content-wrapper">
  111. <div class="container-full">
  112. <section class="content">
  113. <div class="row">
  114. <div class="col-6"><h2 class="category_titles page-top-title">{{__('label.categories')}}</h3></div>
  115. <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>
  116. </div>
  117. <div class=" p-15 rounded-1 sm-prl-15">
  118. <div class="row mb-4">
  119. <div class="col-sm-12">
  120. <button type="button" data-on-text="Open" data-off-text="Closed" class="btn ml-0 ar-mr-0 btn-toggle btn-sm btn-success switch-me" data-id="sorting" data-bs-toggle="button" aria-pressed="false" autocomplete="off">
  121. <div class="handle"></div>
  122. </button> Sorting Enabled?
  123. </div>
  124. </div>
  125. <div class="jumbotron p-0">
  126. <div class="row">
  127. <div class="col-md-12">
  128. <ul class="list-group" id="sortable">
  129. @if(isset($categories) && $categories->count() > 0)
  130. @foreach($categories as $k=>$category)
  131. <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 !!}">
  132. <div class="d-flex sm-justify-spacebetween">
  133. <div class="flex-column p-1">
  134. <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-list-ul" viewBox="0 0 16 16">
  135. <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"/>
  136. </svg>
  137. </div>
  138. <div class="flex-column p-1" style="width: 50%">{!! $category->name !!} ( {!! $category->arabic_name !!} )</div>
  139. <div class="flex-column p-1">
  140. @if(isset($category->parent_category))
  141. <span class="badge badge-dark">{!! $category->parent_category->name !!}</span>
  142. @endif
  143. </div>
  144. <div class="flex-column @if($lang=="en") ms-auto @else ml-auto @endif">
  145. @if(\Illuminate\Support\Facades\Auth::user()->role=="restaurant" && \Illuminate\Support\Facades\Auth::user()->restaurants->id==$category->resto_id)
  146. <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>
  147. <a href="javascript:;" data-id="{!! $category->id !!}" class="btn btn-sm btn-danger delete-category"><i class="glyphicon glyphicon-trash"></i></a>
  148. @elseif(\Illuminate\Support\Facades\Auth::user()->role=="restaurant")
  149. <span class="badge badge-info">{{__('label.not_editable_by_super_admin')}}</span>
  150. @else
  151. @if(\Illuminate\Support\Facades\Auth::user()->role=="administrator")
  152. <a href="{!! env('APP_URL') !!}category/edit/{!! $category->id !!}" class="btn btn-sm btn-primary"><i class="glyphicon glyphicon-edit"></i></a>
  153. <a href="javascript:;" data-id="{!! $category->id !!}" class="btn btn-sm btn-danger delete-category"><i class="glyphicon glyphicon-trash" ></i></a>
  154. @endif
  155. @endif
  156. </div>
  157. </div>
  158. </li>
  159. @endforeach
  160. @endif
  161. </ul>
  162. </div>
  163. </div>
  164. </div>
  165. </div>
  166. </section>
  167. </div>
  168. </div>
  169. @endsection
  170. @section('js')
  171. <script src="{!! env('APP_ASSETS') !!}js/jquery-ui.min.js"></script>
  172. <script src="{!! env('APP_ASSETS') !!}js/jquery.ui.touch-punch.min.js"></script>
  173. <script>
  174. $(function () {
  175. var fixHelper = function(e, ui) {
  176. ui.children().each(function() {
  177. $(this).width($(this).width());
  178. });
  179. return ui;
  180. };
  181. $("body").on("click",".switch-me",function (e) {
  182. var is_active = $(this).attr("aria-pressed");
  183. is_active = $.trim(is_active);
  184. if(is_active=="false"){
  185. $( "#sortable" ).sortable("disable");
  186. }else{
  187. $( "#sortable" ).sortable({
  188. placeholder: "ui-state-highlight",
  189. disabled:false,
  190. cursor: 'move',
  191. start:function(event,ui){
  192. var data = $("#sortable").sortable('toArray');
  193. console.log(data);
  194. },
  195. stop: function(event, ui) {
  196. //alert("New position: " + ui.item.index());
  197. var data = $("#sortable").sortable('toArray');
  198. var category = [];
  199. var rows = $(".list-group-item.data-row");
  200. console.log(rows);
  201. $(data).each(function(index,element) {
  202. category.push({
  203. id: element,
  204. // id:element.DT_RowId,
  205. position: index+1
  206. });
  207. });
  208. // $
  209. //console.log(category);
  210. //return false;
  211. $.ajax({
  212. url:'{!! env('APP_URL') !!}update/category/order',
  213. type:"POST",
  214. data:{
  215. ids:category,
  216. "_token":"{!! csrf_token() !!}"
  217. },
  218. success:function () {
  219. }
  220. });
  221. }
  222. });
  223. $( "#sortable" ).disableSelection();
  224. }
  225. });
  226. /*$( "#sortable" ).sortable({
  227. olerance: 'pointer' ,
  228. items: "tr",
  229. helper: fixHelper,
  230. cursor: 'move',
  231. start:function(event,ui){
  232. var data = $("#sortable").sortable('toArray');
  233. console.log(data);
  234. },
  235. stop: function(event, ui) {
  236. //alert("New position: " + ui.item.index());
  237. var data = $("tbody").sortable('toArray');
  238. var category = [];
  239. var rows = $("tbody tr.data-row");
  240. $(rows).each(function(index,element) {
  241. category.push({
  242. id: $(this).attr('id'),
  243. // id:element.DT_RowId,
  244. position: index+1
  245. });
  246. });
  247. // $
  248. // console.log(category);
  249. $.ajax({
  250. url:'{!! env('APP_URL') !!}update/category/order',
  251. type:"POST",
  252. data:{
  253. ids:category,
  254. "_token":"{!! csrf_token() !!}"
  255. },
  256. success:function () {
  257. }
  258. });
  259. }
  260. }); */
  261. $('#example').DataTable({
  262. "bSort": true,
  263. "searching": true,
  264. "paging": true,
  265. "info": false,
  266. "bLengthChange": false,
  267. language: {
  268. @if($lang=='ar')
  269. url:`{{asset('public/assets/js/dataTablear.json')}}`,
  270. @endif
  271. paginate: {
  272. next: '<img src="{!! env("APP_ASSETS") !!}images/icons/next.png">', // or '→'
  273. previous: '<img src="{!! env("APP_ASSETS") !!}images/icons/preivew.png">' // or '←'
  274. }
  275. },
  276. });
  277. $("td nav").addClass('d-flex justify-content-center');
  278. $("body").on('click','.delete-category',function () {
  279. var id = $(this).data('id');
  280. swal({
  281. title: " Confirm?",
  282. text: "Do you want delete?",
  283. type: "error",
  284. showCancelButton: true,
  285. confirmButtonClass: "btn-danger",
  286. confirmButtonText: " Confirm, delete it!",
  287. cancelButtonText: "No, cancel please!",
  288. closeOnConfirm: true,
  289. closeOnCancel: true
  290. },
  291. function(isConfirm) {
  292. if (isConfirm) {
  293. $.ajax({
  294. url:"{!! env('APP_URL') !!}category/delete/"+id,
  295. success:function (response) {
  296. location.reload();
  297. }
  298. });
  299. }
  300. });
  301. });
  302. })
  303. </script>
  304. @endsection