index.blade.php 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  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('produit.add')}}" class="btn btn-primary">+ Ajouter</a>
  15. <a href="javascript:window.location.href=window.location.href" class="btn btn-secondary"><i class="fa-solid fa-arrows-rotate"></i>Actualiser</a>
  16. </div>
  17. </div>
  18. </section>
  19. <div class="card">
  20. <div class="card-header">
  21. Catégories
  22. </div>
  23. <div class="card-body">
  24. <div class="table-responsive">
  25. <table class="table table-bordered">
  26. <thead>
  27. <tr>
  28. <th scope="col">Nom</th>
  29. <th scope="col">categorie</th>
  30. <th scope="col">Date</th>
  31. <th scope="col">Action</th>
  32. </tr>
  33. </thead>
  34. <tbody>
  35. @foreach($articles as $article)
  36. <tr>
  37. <th scope="row">
  38. <a href="{{ url('produit/'.$article->id) }}" >{{$article->nom}}</a>
  39. </th>
  40. <th scope="row">
  41. @foreach ($article->categories as $singleTag)
  42. <span class="label label-info label-many btn btn-secondary">{{ $singleTag->nom }}</span>
  43. @endforeach
  44. </th>
  45. <th scope="row">
  46. {{$article->created_at}}
  47. </th>
  48. <th scope="row" class="buttonOffOut">
  49. <div>
  50. <form action="{{url('produit/'.$article->id)}}" method="post">
  51. @csrf
  52. <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' : '' }}>
  53. <Tooltip title="Voir Plus"> <a href="{{ url('produit/'.$article->id) }}" class="btn btn-xs btn-primary"><i class="fa fa-sign-out" aria-hidden="true"></i></a></Tooltip>
  54. <input name="_method" type="hidden" value="DELETE">
  55. <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>
  56. </form>
  57. </div>
  58. </th>
  59. </tr>
  60. @endforeach
  61. </tbody>
  62. </table>
  63. <div>
  64. </div>
  65. </div>
  66. </section>
  67. </div>
  68. <script src="https://cdnjs.cloudflare.com/ajax/libs/sweetalert/2.1.2/sweetalert.min.js"></script>
  69. <script type="text/javascript">
  70. $('.show_confirm').click(function(event) {
  71. var form = $(this).closest("form");
  72. var name = $(this).data("name");
  73. event.preventDefault();
  74. swal({
  75. title: `Are you sure you want to delete this record?`
  76. , text: "If you delete this, it will be gone forever."
  77. , icon: "warning"
  78. , buttons: true
  79. , dangerMode: true
  80. , })
  81. .then((willDelete) => {
  82. if (willDelete) {
  83. form.submit();
  84. }
  85. });
  86. });
  87. function myFunction() {
  88. document.getElementById("demo").innerHTML = "Hello World";
  89. }
  90. var myModal = document.getElementById('myModal')
  91. var myInput = document.getElementById('myInput')
  92. myModal.addEventListener('shown.bs.modal', function() {
  93. myInput.focus()
  94. })
  95. $('form input').on('change', function() {
  96. $(this).closest('form').submit();
  97. });
  98. </script>
  99. <script>
  100. $(function() {
  101. $('.toggle-class').change(function() {
  102. var etat = $(this).prop('checked') == true ? 1 : 0;
  103. var Id = $(this).data('id');
  104. $.ajax({
  105. type: "GET"
  106. , dataType: "json"
  107. , url: '/changeStatusProduit'
  108. , data: {
  109. 'etat': etat
  110. , 'Id': Id
  111. }
  112. , success: function(data) {
  113. console.log(data.success)
  114. }
  115. });
  116. })
  117. });
  118. </script>
  119. @endsection