index.blade.php 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. @extends('layouts.idara.panel')
  2. @section('content')
  3. <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.3/jquery.min.js" integrity="sha512-STof4xm1wgkfm7heWqFJVn58Hm3EtS31XFaagaa8VMReCXAkQnJZ+jEy8PCC/iT18dFy95WcExNHFTqLyp72eQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
  4. <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-toggle/2.2.2/js/bootstrap-toggle.min.js" integrity="sha512-F636MAkMAhtTplahL9F6KmTfxTmYcAcjcCkyu0f0voT3N/6vzAuJ4Num55a0gEJ+hRLHhdz3vDvZpf6kqgEa5w==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
  5. <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-toggle/2.2.2/css/bootstrap-toggle.min.css" integrity="sha512-hievggED+/IcfxhYRSr4Auo1jbiOczpqpLZwfTVL/6hFACdbI3WQ8S9NCX50gsM9QVE+zLk/8wb9TlgriFbX+Q==" crossorigin="anonymous" referrerpolicy="no-referrer" />
  6. @include('backend.partials.import')
  7. <div class="container">
  8. <section style="margin-bottom: 44px;">
  9. <div class="card">
  10. <div class="card-header">
  11. Vos catégories
  12. </div>
  13. <div class="card-body">
  14. <a href="{{route('promotion.add')}}" class="btn btn-primary">+ Ajouter un produit</a>
  15. <a href="{{route('promotionPack.add')}}" class="btn btn-primary">+ Ajouter un pack</a>
  16. <a href="javascript:window.location.href=window.location.href" class="btn btn-secondary"><i class="fa-solid fa-arrows-rotate"></i>Actualiser</a>
  17. </div>
  18. </div>
  19. </section>
  20. <div class="card">
  21. <div class="card-header">
  22. Catégories
  23. </div>
  24. <div class="card-body">
  25. <div class="table-responsive">
  26. <table class="table table-bordered">
  27. <thead>
  28. <tr>
  29. <th scope="col">Promotion</th>
  30. <th scope="col">Debut</th>
  31. <th scope="col">Fin</th>
  32. <th scope="col">Date</th>
  33. <th scope="col">Action</th>
  34. </tr>
  35. </thead>
  36. <tbody>
  37. @foreach($articles as $article)
  38. <tr>
  39. <th scope="row">
  40. <a class="title" href="{{ route('promotion.show',['id'=>$article]) }}" >{{$article->titre}}</a>
  41. </th>
  42. <th scope="row">
  43. {{$article->debut}}
  44. </th>
  45. <th scope="row">
  46. {{$article->fin}}
  47. </th>
  48. <th scope="row">
  49. {{$article->created_at}}
  50. </th>
  51. <th scope="row" class="buttonOffOut">
  52. <div>
  53. <form action="{{url('promotion/'.$article->id)}}" method="post">
  54. @csrf
  55. <input data-id="{{$article->id}}" class="toggle-class" type="checkbox" data-onstyle="success" data-offstyle="danger" data-toggle="toggle" data-on="✔" data-off="⊘" {{ $article->etat ? 'checked' : '' }}>
  56. <Tooltip title="Voir Plus"> <a href="{{ route('promotion.show',['id'=>$article]) }}" class="btn btn-xs btn-primary"><i class="fa fa-sign-out" aria-hidden="true"></i></a></Tooltip>
  57. <input name="_method" type="hidden" value="DELETE">
  58. <Tooltip title="Supprimer"> <button type="submit" class="btn btn-xs btn-danger btn-flat show_confirm" data-toggle="tooltip" ref="{{ url('produit/'.$article->id) }}"><i class="fa-solid fa-trash" aria-hidden="true"></i></button></Tooltip>
  59. </form>
  60. </div>
  61. </th>
  62. </tr>
  63. @endforeach
  64. </tbody>
  65. </table>
  66. <div>
  67. </div>
  68. </div>
  69. </section>
  70. </div>
  71. <script src="https://cdnjs.cloudflare.com/ajax/libs/sweetalert/2.1.2/sweetalert.min.js"></script>
  72. <script type="text/javascript">
  73. $('.show_confirm').click(function(event) {
  74. var form = $(this).closest("form");
  75. var name = $(this).data("name");
  76. event.preventDefault();
  77. swal({
  78. title: `Are you sure you want to delete this record?`
  79. , text: "If you delete this, it will be gone forever."
  80. , icon: "warning"
  81. , buttons: true
  82. , dangerMode: true
  83. , })
  84. .then((willDelete) => {
  85. if (willDelete) {
  86. form.submit();
  87. }
  88. });
  89. });
  90. </script>
  91. <script>
  92. $(function() {
  93. $('.toggle-class').change(function() {
  94. var etat = $(this).prop('checked') == true ? 1 : 0;
  95. var Id = $(this).data('id');
  96. $.ajax({
  97. type: "GET"
  98. , dataType: "json"
  99. , url: '/changeStatusPromotion'
  100. , data: {
  101. 'etat': etat
  102. , 'Id': Id
  103. }
  104. , success: function(data) {
  105. console.log(data.success)
  106. }
  107. });
  108. })
  109. });
  110. $(function() {
  111. $('.toggle-class-home').change(function() {
  112. var home = $(this).prop('checked') == true ? 1 : 0;
  113. var Id = $(this).data('id');
  114. $.ajax({
  115. type: "GET"
  116. , dataType: "json"
  117. , url: '/changeStatusProduitHome'
  118. , data: {
  119. 'home': home
  120. , 'Id': Id
  121. }
  122. , success: function(data) {
  123. console.log(data.success)
  124. }
  125. });
  126. })
  127. });
  128. </script>
  129. @endsection