source: resources/views/dashboard/users/index.blade.php@ 79aa35c

Last change on this file since 79aa35c was 0a1fb54, checked in by beratkjufliju <kufliju@…>, 3 years ago

bug fixes

  • Property mode set to 100644
File size: 26.6 KB
RevLine 
[194a359]1@extends('layouts.app')
2
[d795fa6]3@section("title", "SaveSpace - Users")
[194a359]4
5@section('head')
[24a616f]6
[194a359]7@endsection
8
9@section('content')
10
11 <div class="page-header justify-content-between">
12 <nav aria-label="breadcrumb" class="d-flex align-items-start">
13 <ol class="breadcrumb">
14 <li class="breadcrumb-item">
[c6b84df]15 <a href="{{ url('/') }}">Dashboard</a>
[194a359]16 </li>
[c6b84df]17 <li class="breadcrumb-item active" aria-current="page">Users</li>
[194a359]18 </ol>
19 </nav>
20 <div class="dropdown">
[0df7a93]21 @if(auth()->user()->hasPermission('manage_all_users'))
[5d1a1f3]22 <a href="javascript:void(0)" data-toggle="modal" data-target="#createModal" class="btn btn-primary text-white">
[aab55f4]23 New
[0208bbd]24 </a>
[0df7a93]25 @endif
26 @if(auth()->user()->hasPermission('export_data'))
[0208bbd]27 <a href="{{ route('dashboard.users.export') }}" class="btn btn-success text-white">
[aab55f4]28 Export
[194a359]29 </a>
[0df7a93]30 @endif
[194a359]31 </div>
32 </div>
33
[65fafc4]34 <div class="row">
[194a359]35 <div class="col-md-12">
[9b4689a]36 <div class="card">
37 <div class="card-body">
[194a359]38 <div class="table-responsive">
[e651d0d]39 <table id="user-list" class="table">
[194a359]40 <thead>
41 <tr>
[d795fa6]42 <th></th>
[24a616f]43 <th>State</th>
[194a359]44 <th>Username</th>
45 <th>Name</th>
[678747f]46 <th>Created by</th>
[d795fa6]47 <th>Updated at</th>
[24a616f]48 <th>Status</th>
[194a359]49 <th>Actions</th>
50 </tr>
51 </thead>
52 <tbody>
53 @foreach($users as $user)
54 <tr>
[24a616f]55 <td></td>
[194a359]56 <td>
57 @if($user->is_confirmed)
58 @if ($user->is_active)
59 <span class="badge bg-success-bright text-success">Active</span>
60 @else
61 <span class="badge bg-danger-bright text-danger">Blocked</span>
62 @endif
63 @else
64 <span class="badge bg-warning-bright text-warning">New user</span>
65 @endif
66 </td>
67 <td>
[0208bbd]68 <figure class="avatar avatar-sm mr-2">
69 @if($user->avatar==NULL)
70 <img src="{{ url('assets/media/images/user.png') }}" class="rounded-circle" alt="avatar">
71 @else
72 <img src="{{url('uploads/users/' . $user->avatar)}}" class="rounded-circle" alt="avatar">
73 @endif
74 </figure>
[24a616f]75 {{$user->username}}
[194a359]76 </td>
[4b7e2d3]77 <td>{{$user->name .' '. $user->surname}}
78 <div class="font-weight-light p-1">{{$user->role->name}}</div>
79 <div class="font-weight-light p-1">{{$user->email}}</div>
80 <div class="font-weight-light p-1">{{$user->phone_number}}</div>
81 </td>
[0a1fb54]82 <td>{{ $user->getCreatedByUsername() }}
83 <div class="font-weight-light p-1">{{$user->getCreatedByName()}}</div>
84 <div class="font-weight-light p-1">{{ date('d.m.Y - H:i', strtotime($user->created_at)) }}</div>
85 </td>
86
[d795fa6]87 @if($user->updated_at==NULL)
88 <td>/</td>
89 @else
90 <td>{{ date('d.m.Y - H:i', strtotime($user->updated_at)) }}</td>
91 @endif
[0a1fb54]92
[24a616f]93 <td>
94 @if(Cache::has('is_online' . $user->id))
[1f7c934]95 <span data-toggle="tooltip" data-placement="bottom" title="{{ \Carbon\Carbon::parse($user->last_seen)->format('d.m.Y - H:i') }}" class="text-success">Online</span>
[24a616f]96 @else
[1f7c934]97 @if($user->last_seen == null)
[c6b84df]98 <span data-toggle="tooltip" data-placement="bottom" title="{{ $user->last_seen }}" class="text-secondary">Offline</span>
[1f7c934]99 @else
100 <span data-toggle="tooltip" data-placement="bottom" title="{{ \Carbon\Carbon::parse($user->last_seen)->format('d.m.Y - H:i') }}" class="text-secondary">Offline</span>
101 @endif
[24a616f]102 @endif
103 </td>
[0a1fb54]104 @if(auth()->user()->hasPermission('manage_all_users') && auth()->user()->id != $user->id)
[1c25bcf]105 @if($user->hasRole("Referent") || $user->hasRole("Viewer") && $user->is_confirmed)
[194a359]106 <td>
[c6b84df]107 <a href="javascript:void(0)" class="text-secondary" data-toggle="modal" data-target="#editModal_{{$user->id}}" title="Edit">
[194a359]108 <i class="ti-pencil"></i>
109 </a>
[0a1fb54]110 @if ($user->is_active)
111 <a href="javascript:void(0)" data-toggle="modal" data-target="#blockModal_{{$user->id}}" class="text-warning ml-2" title="Block">
112 <i class="ti-lock"></i>
113 </a>
114 @else
115 <a href="javascript:void(0)" data-toggle="modal" data-target="#unBlockModal_{{$user->id}}" class="text-warning ml-2" title="Unblock">
116 <i class="ti-unlock"></i>
117 </a>
118 @endif
[0df7a93]119 <a href="javascript:void(0)" class="text-danger ml-2" data-toggle="modal" data-target="#deleteModal_{{$user->id}}" title="Delete">
[194a359]120 <i class="ti-trash"></i>
121 </a>
[0a1fb54]122
[194a359]123 </td>
124 @else
[4b7e2d3]125 <td>/</td>
[194a359]126 @endif
[0df7a93]127 @else
128 <td></td>
129 @endif
[7614db3]130 </tr>
[194a359]131
[7614db3]132 <div class="modal fade" id="editModal_{{$user->id}}" tabindex="-1" role="dialog" aria-hidden="true">
133 <div class="modal-dialog modal-dialog-centered modal-lg" role="document">
134 <div class="modal-content">
135 <div class="modal-header">
136 <h5 class="modal-title" id="exampleModalCenterTitle">Edit user</h5>
137 <button type="button" class="close" data-dismiss="modal" aria-label="Close">
138 <i class="ti-close"></i>
139 </button>
140 </div>
141 <div class="modal-body">
142 <form action="{{ route("dashboard.users.edit", ["id" =>$user->id]) }}" method="post" accept-charset="utf-8" enctype='multipart/form-data'>
143 @method("patch")
144 @csrf
145 <div class="row">
146 <div class="col-md-6">
147 <div class="form-group">
148 <label>Name</label>
149 <input type="text" name="name" value="{{ $user->name }}" minlength="2" maxlength="30" pattern="[a-zA-Zа-шА-Ш._\s]+" class="form-control" placeholder="Name" required>
[c6b84df]150 </div>
[7614db3]151 </div>
152 <div class="col-md-6">
153 <div class="form-group">
154 <label>Surname</label>
155 <input type="text" name="surname" value="{{$user->surname}}" minlength="2" maxlength="30" pattern="[a-zA-Zа-шА-Ш._\s]+" class="form-control" placeholder="Surname" required>
[c6b84df]156 </div>
157 </div>
[7614db3]158 </div>
159 <div class="row">
160 <div class="col-md-6">
161 <div class="form-group">
162 <label class="form-label">Username</label>
163 <input type="text" name="username" value="{{ $user->username }}" minlength="5" maxlength="30" class="form-control" placeholder="Username" required>
[c6b84df]164 </div>
[7614db3]165 </div>
166 <div class="col-md-6">
167 <div class="form-group">
168 <label class="form-label">Role</label>
[c6b84df]169
[7614db3]170 <select class="form-control" name="userRole" required>
171 @foreach($roles as $role)
172 <option value="{{ $role->id }}" {{ $user->role_id == $role->id ? "selected" : "" }}>{{ $role->name }}</option>
173 @endforeach
174 </select>
[c6b84df]175 </div>
176 </div>
[7614db3]177 </div>
178 <div class="row">
179 <div class="col-md-6">
180 <div class="form-group">
181 <label>Email</label>
182 <input type="email" name="email" value="{{ $user->email }}" maxlength="50" class="form-control" placeholder="E-mail" required>
[c6b84df]183 </div>
184 </div>
[7614db3]185 <div class="col-md-6">
186 <div class="form-group">
187 <label class="form-label">Phone Number</label>
188 <input type="text" name="phone_number" value="{{ $user->phone_number }}" class="form-control" placeholder="Phone number" autocomplete="off" required>
[c6b84df]189 </div>
[7614db3]190 </div>
191 </div>
192 <div class="row">
193 <div class="col-md-5">
194 <div class="form-group">
195 <label>Avatar</label>
196 <input type="file" name="avatar" value="{{ $user->avatar }}" class="form-control" accept="image/*">
[c6b84df]197 </div>
198 </div>
[7614db3]199 <div class="col-md-1">
200 <div class="form-group">
[0a1fb54]201 <label></label>
[7614db3]202 <figure class="avatar avatar-sm mr-2">
203 @if($user->avatar==NULL)
204 <img src="{{ url('assets/media/images/user.png') }}" class="rounded-circle" alt="avatar">
205 @else
206 <img src="{{url('uploads/users/' . $user->avatar)}}" class="rounded-circle" alt="avatar">
207 @endif
208 </figure>
209 </div>
[e651d0d]210 </div>
[7614db3]211 </div>
212 <div class="modal-footer">
213 <button type="button" class="btn btn-secondary" data-dismiss="modal">Close
214 </button>
215 <button type="submit" class="btn btn-primary">Save changes</button>
216 </div>
217 </form>
218 </div>
219
220 </div>
221 </div>
222 </div>
[678747f]223
[7614db3]224 <div class="modal fade" id="deleteModal_{{$user->id}}" tabindex="-1" role="dialog" aria-hidden="true">
225 <div class="modal-dialog modal-dialog-centered" role="document">
226 <div class="modal-content">
227 <div class="modal-header">
228 <h5 class="modal-title" id="exampleModalCenterTitle">Delete confirmation</h5>
229 <button type="button" class="close" data-dismiss="modal" aria-label="Close">
230 <i class="ti-close"></i>
231 </button>
[e651d0d]232 </div>
[7614db3]233 <div class="modal-body">
234 <form action="{{ route("dashboard.users.destroy", $user->id) }}" method="POST">
235 @csrf
236 @method('DELETE')
237 <p>Are you sure you want to delete user {{$user->username}} ?</p>
238 <p>Number of folders created: <a href="{{ route("dashboard.folders.index", ['id' => $user->id]) }}" class="text-linkedin">{{\App\Models\Folder::where('user_id', $user->id)->count()}}</a></p>
239 <div class="modal-footer">
240 <button type="button" class="btn btn-secondary" data-dismiss="modal">Close
241 </button>
242 <button type="submit" class="btn btn-primary">Save changes</button>
243 </div>
244 </form>
245 </div>
246
[c6b84df]247 </div>
248 </div>
[0a1fb54]249 </div>
250
251 <div class="modal fade" id="blockModal_{{$user->id}}" tabindex="-1" role="dialog" aria-hidden="true">
252 <div class="modal-dialog modal-dialog-centered" role="document">
253 <div class="modal-content">
254 <div class="modal-header">
255 <h5 class="modal-title" id="exampleModalCenterTitle">Block confirmation</h5>
256 <button type="button" class="close" data-dismiss="modal" aria-label="Close">
257 <i class="ti-close"></i>
258 </button>
259 </div>
260 <div class="modal-body">
261 <form action="{{ route("dashboard.users.block", $user->id) }}" method="POST">
262 @csrf
263 @method('patch')
264 <p>Are you sure you want to block user {{$user->username}} ?</p>
265 <p>Number of folders created: <a href="{{ route("dashboard.folders.index", ['id' => $user->id]) }}" class="text-linkedin">{{\App\Models\Folder::where('user_id', $user->id)->count()}}</a></p>
266 <div class="modal-footer">
267 <button type="button" class="btn btn-secondary" data-dismiss="modal">Close
268 </button>
269 <button type="submit" class="btn btn-primary">Save changes</button>
270 </div>
271 </form>
272 </div>
273
274 </div>
275 </div>
276 </div>
277
278
279 <div class="modal fade" id="unBlockModal_{{$user->id}}" tabindex="-1" role="dialog" aria-hidden="true">
280 <div class="modal-dialog modal-dialog-centered" role="document">
281 <div class="modal-content">
282 <div class="modal-header">
283 <h5 class="modal-title" id="exampleModalCenterTitle">Unblock confirmation</h5>
284 <button type="button" class="close" data-dismiss="modal" aria-label="Close">
285 <i class="ti-close"></i>
286 </button>
287 </div>
288 <div class="modal-body">
289 <form action="{{ route("dashboard.users.unblock", $user->id) }}" method="POST">
290 @csrf
291 @method('patch')
292 <p>Are you sure you want to block user {{$user->username}} ?</p>
293 <p>Number of folders created: <a href="{{ route("dashboard.folders.index", ['id' => $user->id]) }}" class="text-linkedin">{{\App\Models\Folder::where('user_id', $user->id)->count()}}</a></p>
294 <div class="modal-footer">
295 <button type="button" class="btn btn-secondary" data-dismiss="modal">Close
296 </button>
297 <button type="submit" class="btn btn-primary">Save changes</button>
298 </div>
299 </form>
300 </div>
301
302 </div>
303 </div>
[7614db3]304 </div>
[678747f]305
[c6b84df]306 @endforeach
[194a359]307 </tbody>
308 </table>
[c6b84df]309
[ac3f217]310 </div>
311 </div>
[9b4689a]312 </div>
313 </div>
314 </div>
[65fafc4]315
316
317 <div class="modal fade" id="createModal" tabindex="-1" role="dialog" aria-hidden="true">
318 <div class="modal-dialog modal-dialog-centered modal-lg" role="document">
319 <div class="modal-content">
320 <div class="modal-header">
321 <h5 class="modal-title" id="exampleModalCenterTitle">Create user</h5>
322 <button type="button" class="close" data-dismiss="modal" aria-label="Close">
323 <i class="ti-close"></i>
324 </button>
325 </div>
326 <div class="modal-body">
327 <form action="{{ route("dashboard.users.store") }}" method="post" accept-charset="utf-8" enctype='multipart/form-data'>
328 @csrf
329 <div class="row">
330 <div class="col-md-6">
331 <div class="form-group">
332 <label>Name</label>
333 <input type="text" name="name" value="{{ old('name') }}" minlength="2" maxlength="25" pattern="[a-zA-Zа-шА-Ш._\s]+" class="form-control" placeholder="Name" required>
334 </div>
335 </div>
336 <div class="col-md-6">
337 <div class="form-group">
338 <label>Surname</label>
339 <input type="text" name="surname" value="{{ old('surname') }}" minlength="2" maxlength="25" pattern="[a-zA-Zа-шА-Ш._\s]+" class="form-control" placeholder="Surname" required>
340 </div>
341 </div>
342 </div>
343 <div class="row">
344 <div class="col-md-6">
345 <div class="form-group">
346 <label class="form-label">Username</label>
347 <input type="text" name="username" value="{{ old('username') }}" minlength="5" maxlength="30" class="form-control" placeholder="Username" required>
348 </div>
349 </div>
350 <div class="col-md-6">
351 <div class="form-group">
352 <label class="form-label">Role</label>
353 <select class="form-control" name="userRole" required>
354 @foreach ($roles as $role)
355 <option value="{{ $role->id }}" {{ (old("userRole") == $role->id ? "selected" : "" ) }}>{{ $role->name }}</option>
356 @endforeach
357 </select>
358 </div>
359 </div>
360 </div>
361 <div class="row">
362 <div class="col-md-6">
363 <div class="form-group">
364 <label>Email</label>
365 <input type="email" name="email" value="{{ old('email') }}" class="form-control" placeholder="E-mail" required>
366 </div>
367 </div>
368 <div class="col-md-6">
369 <div class="form-group">
370 <label class="form-label">Phone Number</label>
371 <input type="text" name="phone_number" value="{{ old('phone_number') }}" class="form-control" placeholder="Phone number" autocomplete="off" required>
372 </div>
373 </div>
374 </div>
375 <div class="row">
376 <div class="col-md-6">
377 <div class="form-group">
378 <label>Avatar</label>
379 <input type="file" name="avatar" value="{{ old('avatar') }}" class="form-control" accept="image/*">
380 </div>
381 </div>
382 </div>
383 <div class="modal-footer">
384 <button type="button" class="btn btn-secondary" data-dismiss="modal">Close
385 </button>
386 <button type="submit" class="btn btn-primary">Save changes</button>
387 </div>
388 </form>
389 </div>
390 </div>
391 </div>
392 </div>
[7614db3]393
[194a359]394@endsection
395
396@section('script')
[f5097b2]397 @yield('script')
[24a616f]398 <script src="{{ url('assets/js/examples/pages/user-list.js') }}"></script>
[194a359]399@endsection
Note: See TracBrowser for help on using the repository browser.