edit.blade.php 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. @extends('layouts.app')
  2. @section('content')
  3. <div class="px-3">
  4. <div class="col-xxl-6 offset-xxl-2">
  5. <form action="{{ route('user.store', ['nav' => $nav ?? null]) }}" method="post">
  6. @csrf
  7. <input type="hidden" name="nav" value="{{ $nav ?? '' }}">
  8. @if($user)
  9. <input type="hidden" name="id" value="{{ $user->id }}">
  10. @endif
  11. <ul class="nav nav-tabs mb-3" role="tablist">
  12. <li class="nav-item" role="presentation">
  13. <button class="nav-link active" id="main-tab" data-bs-toggle="tab" data-bs-target="#main-pane" type="button" role="tab">Основное</button>
  14. </li>
  15. <li class="nav-item" role="presentation">
  16. <button class="nav-link" id="notifications-tab" data-bs-toggle="tab" data-bs-target="#notifications-pane" type="button" role="tab">Уведомления</button>
  17. </li>
  18. </ul>
  19. <div class="tab-content">
  20. <div class="tab-pane fade show active" id="main-pane" role="tabpanel" aria-labelledby="main-tab">
  21. @include('partials.input', ['name' => 'email',
  22. 'type' => 'text',
  23. 'title' => 'Логин/email',
  24. 'required' => true,
  25. 'value' => $user->email ?? '',
  26. 'disabled' => ($user && $user->email_verified_at),
  27. ])
  28. @include('partials.input', ['name' => 'notification_email',
  29. 'type' => 'email',
  30. 'title' => 'Email для уведомлений',
  31. 'value' => old('notification_email', $user->notification_email ?? '')])
  32. @include('partials.input', ['name' => 'name', 'title' => 'Имя', 'required' => true, 'value' => $user->name ?? ''])
  33. @include('partials.input', ['name' => 'phone', 'title' => 'Телефон', 'value' => $user->phone ?? ''])
  34. @include('partials.input', ['name' => 'password', 'type' => 'password', 'title' => 'Пароль'])
  35. @include('partials.select', ['name' => 'role', 'title' => 'Роль', 'options' => getRoles(), 'value' => $user->role ?? \App\Models\Role::MANAGER])
  36. @include('partials.input', ['name' => 'color', 'title' => 'Цвет', 'value' => $user->color ?? '#FFFFFF', 'type' => 'color'])
  37. @if($user)
  38. @include('partials.input', ['name' => 'token_fcm', 'title' => 'FCM Token', 'value' => $user->token_fcm ?? '', 'disabled' => true])
  39. @endif
  40. </div>
  41. <div class="tab-pane fade" id="notifications-pane" role="tabpanel" aria-labelledby="notifications-tab">
  42. @php($settings = $notificationSettings ?? [])
  43. @include('partials.notification-settings-table', [
  44. 'channels' => $notificationChannels,
  45. 'disabledChannels' => $disabledChannels ?? [],
  46. 'sections' => [
  47. ['title' => 'Площадки', 'settingsKey' => 'orders', 'options' => $orderStatusOptions, 'colors' => $orderStatusColors, 'settings' => $settings['order_settings'] ?? []],
  48. ['title' => 'Рекламации', 'settingsKey' => 'reclamations', 'options' => $reclamationStatusOptions, 'colors' => $reclamationStatusColors, 'settings' => $settings['reclamation_settings'] ?? []],
  49. ['title' => 'График монтажей', 'settingsKey' => 'schedule', 'options' => $scheduleSourceOptions, 'colors' => [], 'settings' => $settings['schedule_settings'] ?? []],
  50. ['title' => 'Чат', 'settingsKey' => 'chat', 'options' => $chatSourceOptions, 'colors' => [], 'settings' => $settings['chat_settings'] ?? []],
  51. ],
  52. ])
  53. </div>
  54. </div>
  55. @if($user && !is_null($user->deleted_at))
  56. <div class="col-12 text-center">
  57. <div class="text-danger">ПОЛЬЗОВАТЕЛЬ УДАЛЁН!!!</div>
  58. <a href="#" class="btn btn-sm btn-warning undelete">Восстановить</a>
  59. </div>
  60. @else
  61. @include('partials.submit', ['delete' => ['form_id' => 'delete-user'], 'back_url' => $back_url ?? route('user.index', session('gp_users', []))])
  62. @if($user && auth()->id() !== $user->id)
  63. <div class="text-center mt-2">
  64. <a href="#" class="btn btn-sm btn-outline-primary impersonate-user">Impersonate</a>
  65. </div>
  66. @endif
  67. @endif
  68. </form>
  69. @if($user)
  70. <form action="{{ route('user.undelete', ['user' => $user->id, 'nav' => $nav ?? null]) }}" method="post" class="d-none" id="undelete-user">
  71. @csrf
  72. </form>
  73. <form action="{{ route('user.destroy', ['user' => $user->id, 'nav' => $nav ?? null]) }}" method="post" class="d-none" id="delete-user">
  74. @method('DELETE')
  75. @csrf
  76. </form>
  77. <form action="{{ route('user.impersonate', $user->id) }}" method="post" class="d-none" id="impersonate-user">
  78. @csrf
  79. </form>
  80. @endif
  81. </div>
  82. </div>
  83. @endsection
  84. @push('scripts')
  85. <script type="module">
  86. $('.undelete').on('click', function (){
  87. customConfirm('Восстановить пользователя?', function () {
  88. $('#undelete-user').submit();
  89. });
  90. });
  91. $('.impersonate-user').on('click', function (){
  92. customConfirm('Войти от имени этого пользователя?', function () {
  93. $('#impersonate-user').submit();
  94. });
  95. });
  96. </script>
  97. @endpush