index.blade.php 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. <!--
  2. Copyright (C) 2021 Echedey López Romero <elr@disroot.org>
  3. This program is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation, either version 3 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. -->
  14. @extends('layouts.app')
  15. @section('content')
  16. <div class="container">
  17. <div class="row mb-3">
  18. <h1 class="col-12 mb-0 text-center">Loans list</h1>
  19. </div>
  20. @if (Session::get('success'))
  21. @php $message = Session::get('success'); @endphp
  22. <div class = "row mb-3">
  23. <span class="col-xl-6 col-lg-8 col-md-10 col-12 mx-auto mb-0 alert alert-success">{{ $message }}</span>
  24. </div>
  25. @endif
  26. @if (Session::get('danger'))
  27. @php $message = Session::get('danger'); @endphp
  28. <div class = "row mb-3">
  29. <span class="col-xl-6 col-lg-8 col-md-10 col-12 mx-auto mb-0 alert alert-danger">{{ $message }}</span>
  30. </div>
  31. @endif
  32. <div class="row">
  33. <div class="col-lg-10 col-12 mx-auto">
  34. <div class="container">
  35. <div class="row">
  36. <form class="col-xl-6 col-lg-8 col-md-10 col-12 mx-auto" action="{{ route('loans.search') }}" method="POST">
  37. @csrf
  38. @if (Auth::user()->hasRole('Administrator'))
  39. <input class="form-control" name="search" type="text" value="{{ isset($oldSearch) ? $oldSearch : '' }}" placeholder="Search by user name and email, or by book title, authors and editorial"/>
  40. @else
  41. <input class="form-control" name="search" type="text" value="{{ isset($oldSearch) ? $oldSearch : '' }}" placeholder="Search by book title, authors and editorial"/>
  42. @endif
  43. </form>
  44. </div>
  45. @if (count($loans) !== 0)
  46. <div class="row mt-3 p-3 d-md-flex d-none">
  47. <div class='col-2 my-auto text-center'>
  48. <span class="fs-5">User</span>
  49. </div>
  50. <div class='col-2 my-auto text-center'>
  51. <span class="fs-5">Book title</span>
  52. </div>
  53. <div class='col-2 my-auto text-center'>
  54. <span class="fs-5">Book authors</span>
  55. </div>
  56. <div class='col-2 my-auto text-center'>
  57. <span class="fs-5">Start</span>
  58. </div>
  59. <div class='col-2 my-auto text-center'>
  60. <span class="fs-5">End</span>
  61. </div>
  62. <div class='col-2 my-auto text-center'>
  63. <span class="fs-5">Actions</span>
  64. </div>
  65. </div>
  66. @foreach ($loans as $loan)
  67. <div class="row mt-3 p-3 border border-secondary rounded">
  68. <div class='col-md-2 col-12 my-md-auto mb-3 text-center'>
  69. <span class="fs-5">{{ $loan->user->name }}</span>
  70. </div>
  71. <div class='col-md-2 col-12 my-md-auto mb-3 text-center'>
  72. <span class="fs-5">{{ $loan->book->title }}</span>
  73. </div>
  74. <div class='col-md-2 col-12 my-md-auto mb-3 text-center'>
  75. <span>{{ $loan->book->authors }}</span>
  76. </div>
  77. <div class='col-md-2 col-12 my-md-auto mb-3 text-center'>
  78. <span>{{ \Carbon\Carbon::parse($loan->start)->format('d/m/Y') }}</span>
  79. </div>
  80. <div class='col-md-2 col-12 my-md-auto mb-3 text-center'>
  81. <span>{{ $loan->end ? \Carbon\Carbon::parse($loan->end)->format('d/m/Y') : 'Undelivered' }}</span>
  82. </div>
  83. <div class='col-md-2 col-12 px-0'>
  84. <div class="container px-0">
  85. <div class="row">
  86. <div class="col-12">
  87. <div class="d-grid gap-2">
  88. <a href="{{ route('loans.show', $loan->id) }}" class="btn btn-primary">Show</a>
  89. </div>
  90. </div>
  91. </div>
  92. @if (Auth::user()->hasRole('Administrator'))
  93. <div class="row mt-2">
  94. <div class="col-12">
  95. <div class="d-grid gap-2">
  96. <a href="{{ route('loans.edit', $loan->id) }}" class="btn btn-warning">Edit</a>
  97. </div>
  98. </div>
  99. </div>
  100. <div class="row mt-2">
  101. <form action="{{ route('loans.destroy', $loan->id) }}" method="POST" class="col-12" onsubmit="return window.confirm('Do you want to remove this loan?')">
  102. @csrf
  103. @method('DELETE')
  104. <div class="d-grid gap-2">
  105. <button type="submit" class="btn btn-danger">Delete</button>
  106. </div>
  107. </form>
  108. </div>
  109. @endif
  110. </div>
  111. </div>
  112. </div>
  113. @endforeach
  114. <div class="row mt-3">
  115. <div class="d-flex col-12 justify-content-center">
  116. {{ $loans->links() }}
  117. </div>
  118. </div>
  119. @else
  120. <div class="row mt-3">
  121. <div class='col-xl-6 col-lg-8 col-md-10 col-12 mx-auto text-center'>
  122. <span>There are not loans.</span>
  123. </div>
  124. </div>
  125. @endif
  126. </div>
  127. </div>
  128. </div>
  129. </div>
  130. @endsection