Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

company-employee-manager.blade.php 18KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. <div>
  2. @if (Gate::check('addCompanyEmployee', $company))
  3. <x-filament-companies::section-border />
  4. <!-- Add Company Employee -->
  5. <x-filament-companies::grid-section>
  6. <x-slot name="title">
  7. {{ __('filament-companies::default.grid_section_titles.add_company_employee') }}
  8. </x-slot>
  9. <x-slot name="description">
  10. {{ __('filament-companies::default.grid_section_descriptions.add_company_employee') }}
  11. </x-slot>
  12. <form wire:submit.prevent="addCompanyEmployee" class="col-span-2 sm:col-span-1 mt-5 md:mt-0">
  13. <x-filament::card>
  14. <p class="text-sm text-gray-600 dark:text-gray-400">
  15. {{ __('filament-companies::default.subheadings.companies.company_employee_manager') }}
  16. </p>
  17. <!-- Employee Email -->
  18. <x-forms::field-wrapper id="email" statePath="email" required label="{{ __('filament-companies::default.fields.email') }}">
  19. <x-filament-companies::input id="email" type="email" wire:model.defer="addCompanyEmployeeForm.email" />
  20. </x-forms::field-wrapper>
  21. <!-- Role -->
  22. @if (count($this->roles) > 0)
  23. <x-forms::field-wrapper id="role" statePath="role" required label="{{ __('filament-companies::default.labels.role') }}">
  24. <div x-data="{ role: @entangle('addCompanyEmployeeForm.role').defer }" class="relative z-0 mt-1 cursor-pointer rounded-lg border border-gray-200 dark:border-gray-700">
  25. @foreach ($this->roles as $index => $role)
  26. <button type="button"
  27. @click="role = '{{ $role->key }}'"
  28. @class([
  29. 'relative inline-flex w-full rounded-lg px-4 py-3 transition focus:z-10 focus:outline-none focus:ring-2 focus:border-primary-500 focus:ring-primary-500 dark:focus:border-primary-600 dark:focus:ring-primary-600',
  30. 'border-t border-gray-200 dark:border-gray-700 rounded-t-none' => ($index > 0),
  31. 'rounded-b-none' => (! $loop->last),
  32. ])
  33. >
  34. <div :class="role === '{{ $role->key }}' || 'opacity-50'">
  35. <!-- Role Name -->
  36. <div class="flex items-center">
  37. <div class="text-sm text-gray-600 dark:text-gray-400" :class="{'font-semibold': role === '{{ $role->key }}'}">
  38. {{ $role->name }}
  39. </div>
  40. <svg class="text-primary-500 ml-2 h-5 w-5" x-cloak :class="{ 'hidden': role !== '{{ $role->key }}' }"
  41. xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor">
  42. <path fill-rule="evenodd" d="M8.603 3.799A4.49 4.49 0 0112 2.25c1.357 0 2.573.6 3.397 1.549a4.49 4.49 0 013.498 1.307 4.491 4.491 0 011.307 3.497A4.49 4.49 0 0121.75 12a4.49 4.49 0 01-1.549 3.397 4.491 4.491 0 01-1.307 3.497 4.491 4.491 0 01-3.497 1.307A4.49 4.49 0 0112 21.75a4.49 4.49 0 01-3.397-1.549 4.49 4.49 0 01-3.498-1.306 4.491 4.491 0 01-1.307-3.498A4.49 4.49 0 012.25 12c0-1.357.6-2.573 1.549-3.397a4.49 4.49 0 011.307-3.497 4.49 4.49 0 013.497-1.307zm7.007 6.387a.75.75 0 10-1.22-.872l-3.236 4.53L9.53 12.22a.75.75 0 00-1.06 1.06l2.25 2.25a.75.75 0 001.14-.094l3.75-5.25z" clip-rule="evenodd" />
  43. </svg>
  44. </div>
  45. <!-- Role Description -->
  46. <div class="mt-2 text-left text-sm text-gray-600 dark:text-gray-400">
  47. {{ $role->description }}
  48. </div>
  49. </div>
  50. </button>
  51. @endforeach
  52. </div>
  53. </x-forms::field-wrapper>
  54. @endif
  55. <x-slot name="footer">
  56. <div class="text-left">
  57. <x-filament::button type="submit">
  58. {{ __('filament-companies::default.buttons.add') }}
  59. </x-filament::button>
  60. </div>
  61. </x-slot>
  62. </x-filament::card>
  63. </form>
  64. </x-filament-companies::grid-section>
  65. @endif
  66. @if ($company->companyInvitations->isNotEmpty() && Gate::check('addCompanyEmployee', $company))
  67. <x-filament-companies::section-border />
  68. <!-- Pending Employee Invitations -->
  69. <x-filament-companies::grid-section class="mt-4">
  70. <x-slot name="title">
  71. {{ __('filament-companies::default.action_section_titles.pending_company_invitations') }}
  72. </x-slot>
  73. <x-slot name="description">
  74. {{ __('filament-companies::default.action_section_descriptions.pending_company_invitations') }}
  75. </x-slot>
  76. <div class="overflow-x-auto space-y-2 bg-moonlight rounded-xl shadow dark:border-gray-600 dark:bg-gray-800 col-span-2 mt-5 sm:col-span-1 md:col-start-2 md:mt-0">
  77. <table class="w-full divide-y divide-gray-200 dark:divide-gray-700">
  78. <thead class="bg-moonlight dark:bg-gray-800">
  79. <tr>
  80. <th colspan="3" class="px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider">
  81. {{ __('filament-companies::default.fields.email') }}
  82. </th>
  83. </tr>
  84. </thead>
  85. <tbody class="divide-y divide-gray-200 dark:divide-gray-700">
  86. @foreach ($company->companyInvitations as $invitation)
  87. <tr>
  88. <td class="px-6 py-4 whitespace-nowrap">
  89. <div class="flex items-center">
  90. <div class="text-gray-500 dark:text-gray-400">
  91. {{ $invitation->email }}
  92. </div>
  93. </div>
  94. </td>
  95. <td class="px-6 py-4 whitespace-nowrap">
  96. <div class="text-right">
  97. <!-- Manage Company Employee Role -->
  98. @if (Gate::check('removeCompanyEmployee', $company))
  99. <x-filament::button size="sm" color="danger" outlined="true" wire:click="cancelCompanyInvitation({{ $invitation->id }})">
  100. {{ __('filament-companies::default.buttons.cancel') }}
  101. </x-filament::button>
  102. @endif
  103. </div>
  104. </td>
  105. </tr>
  106. @endforeach
  107. </tbody>
  108. </table>
  109. </div>
  110. </x-filament-companies::grid-section>
  111. @endif
  112. @if ($company->users->isNotEmpty())
  113. <x-filament-companies::section-border />
  114. <!-- Manage Company Employees -->
  115. <x-filament-companies::grid-section class="mt-4">
  116. <x-slot name="title">
  117. {{ __('filament-companies::default.action_section_titles.company_employees') }}
  118. </x-slot>
  119. <x-slot name="description">
  120. {{ __('filament-companies::default.action_section_descriptions.company_employees') }}
  121. </x-slot>
  122. <!-- Company Employee List -->
  123. <div class="overflow-x-auto space-y-2 bg-moonlight rounded-xl shadow dark:border-gray-600 dark:bg-gray-800 col-span-2 mt-5 sm:col-span-1 md:col-start-2 md:mt-0">
  124. <table class="w-full divide-y divide-gray-200 dark:divide-gray-700">
  125. <thead class="bg-moonlight dark:bg-gray-800">
  126. <tr>
  127. <th scope="col" colspan="3" class="px-6 py-3 text-left text-xs font-medium text-gray-600 dark:text-gray-400 uppercase tracking-wider">
  128. {{ __('filament-companies::default.fields.name') }}
  129. </th>
  130. </tr>
  131. </thead>
  132. <tbody class="divide-y divide-gray-200 dark:divide-gray-700">
  133. @foreach ($company->users->sortBy('name') as $user)
  134. <tr>
  135. <td colspan="2" class="px-6 py-4 text-left whitespace-nowrap">
  136. <div class="flex items-center text-sm">
  137. <div class="flex-shrink-0">
  138. <img class="h-10 w-10 rounded-full object-cover" src="{{ $user->profile_photo_url }}" alt="{{ $user->name }}">
  139. </div>
  140. <div class="ml-4">
  141. <div class="font-medium text-gray-900 dark:text-gray-200">{{ $user->name }}</div>
  142. <div class="text-gray-600 dark:text-gray-400 hidden sm:block">{{ $user->email }}</div>
  143. </div>
  144. </div>
  145. </td>
  146. <td colspan="1" class="px-6 py-4 whitespace-nowrap">
  147. <div class="space-x-2 text-right">
  148. <!-- Manage Company Employee Role -->
  149. @if (Gate::check('updateCompanyEmployee', $company) && Wallo\FilamentCompanies\FilamentCompanies::hasRoles())
  150. <x-filament::button size="sm" outlined="true" :icon="(Wallo\FilamentCompanies\FilamentCompanies::findRole($user->employeeship->role)->key === 'admin') ? 'heroicon-o-shield-check' : 'heroicon-o-pencil'" :color="(Wallo\FilamentCompanies\FilamentCompanies::findRole($user->employeeship->role)->key === 'admin') ? 'primary' : 'warning'" wire:click="manageRole('{{ $user->id }}')">
  151. {{ Wallo\FilamentCompanies\FilamentCompanies::findRole($user->employeeship->role)->name }}
  152. </x-filament::button>
  153. @elseif (Wallo\FilamentCompanies\FilamentCompanies::hasRoles())
  154. <x-filament::button size="sm" disabled="true" outlined="true" :icon="(Wallo\FilamentCompanies\FilamentCompanies::findRole($user->employeeship->role)->key === 'admin') ? 'heroicon-o-shield-check' : 'heroicon-o-pencil'" color="secondary">
  155. {{ Wallo\FilamentCompanies\FilamentCompanies::findRole($user->employeeship->role)->name }}
  156. </x-filament::button>
  157. @endif
  158. <!-- Leave Company -->
  159. @if ($this->user->id === $user->id)
  160. <x-filament::button size="sm" color="danger" wire:click="$toggle('confirmingLeavingCompany')">
  161. {{ __('filament-companies::default.buttons.leave') }}
  162. </x-filament::button>
  163. <!-- Remove Company Employee -->
  164. @elseif (Gate::check('removeCompanyEmployee', $company))
  165. <x-filament::button size="sm" color="danger" wire:click="confirmCompanyEmployeeRemoval('{{ $user->id }}')">
  166. {{ __('filament-companies::default.buttons.remove') }}
  167. </x-filament::button>
  168. @endif
  169. </div>
  170. </td>
  171. </tr>
  172. @endforeach
  173. </tbody>
  174. </table>
  175. </div>
  176. </x-filament-companies::grid-section>
  177. @endif
  178. <!-- Role Management Modal -->
  179. <x-filament-companies::dialog-modal wire:model="currentlyManagingRole">
  180. <x-slot name="title">
  181. {{ __('filament-companies::default.modal_titles.manage_role') }}
  182. </x-slot>
  183. <x-slot name="content">
  184. <div x-data="{ role: @entangle('currentRole').defer }"
  185. class="relative z-0 mt-1 cursor-pointer rounded-lg border border-gray-200 dark:border-gray-700">
  186. @foreach ($this->roles as $index => $role)
  187. <button type="button"
  188. @click="role = '{{ $role->key }}'"
  189. @class([
  190. 'relative inline-flex w-full rounded-lg px-4 py-3 transition focus:z-10 focus:outline-none focus:ring-2 focus:border-primary-500 focus:ring-primary-500 dark:focus:border-primary-600 dark:focus:ring-primary-600',
  191. 'border-t border-gray-200 dark:border-gray-700 rounded-t-none' => ($index > 0),
  192. 'rounded-b-none' => (! $loop->last),
  193. ])
  194. >
  195. <div :class="role === '{{ $role->key }}' || 'opacity-50'">
  196. <!-- Role Name -->
  197. <div class="flex items-center">
  198. <div class="text-sm text-gray-600 dark:text-gray-100" :class="role === '{{ $role->key }}' ? 'font-semibold' : ''">
  199. {{ $role->name }}
  200. </div>
  201. <svg class="text-primary-500 ml-2 h-5 w-5" x-cloak :class="{ 'hidden': role !== '{{ $role->key }}' }"
  202. xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor">
  203. <path fill-rule="evenodd" d="M8.603 3.799A4.49 4.49 0 0112 2.25c1.357 0 2.573.6 3.397 1.549a4.49 4.49 0 013.498 1.307 4.491 4.491 0 011.307 3.497A4.49 4.49 0 0121.75 12a4.49 4.49 0 01-1.549 3.397 4.491 4.491 0 01-1.307 3.497 4.491 4.491 0 01-3.497 1.307A4.49 4.49 0 0112 21.75a4.49 4.49 0 01-3.397-1.549 4.49 4.49 0 01-3.498-1.306 4.491 4.491 0 01-1.307-3.498A4.49 4.49 0 012.25 12c0-1.357.6-2.573 1.549-3.397a4.49 4.49 0 011.307-3.497 4.49 4.49 0 013.497-1.307zm7.007 6.387a.75.75 0 10-1.22-.872l-3.236 4.53L9.53 12.22a.75.75 0 00-1.06 1.06l2.25 2.25a.75.75 0 001.14-.094l3.75-5.25z" clip-rule="evenodd" />
  204. </svg>
  205. </div>
  206. <!-- Role Description -->
  207. <div class="mt-2 text-xs text-gray-600 dark:text-gray-400">
  208. {{ $role->description }}
  209. </div>
  210. </div>
  211. </button>
  212. @endforeach
  213. </div>
  214. </x-slot>
  215. <x-slot name="footer">
  216. <x-filament::button color="secondary" wire:click="stopManagingRole" wire:loading.attr="disabled">
  217. {{ __('filament-companies::default.buttons.cancel') }}
  218. </x-filament::button>
  219. <x-filament::button wire:click="updateRole" wire:loading.attr="disabled">
  220. {{ __('filament-companies::default.buttons.save') }}
  221. </x-filament::button>
  222. </x-slot>
  223. </x-filament-companies::dialog-modal>
  224. <!-- Leave Company Confirmation Modal -->
  225. <x-filament-companies::dialog-modal wire:model="confirmingLeavingCompany">
  226. <x-slot name="title">
  227. {{ __('filament-companies::default.modal_titles.leave_company') }}
  228. </x-slot>
  229. <x-slot name="content">
  230. {{ __('filament-companies::default.modal_descriptions.leave_company') }}
  231. </x-slot>
  232. <x-slot name="footer">
  233. <x-filament::button color="secondary" wire:click="$toggle('confirmingLeavingCompany')" wire:loading.attr="disabled">
  234. {{ __('filament-companies::default.buttons.cancel') }}
  235. </x-filament::button>
  236. <x-filament::button color="danger" wire:click="leaveCompany" wire:loading.attr="disabled">
  237. {{ __('filament-companies::default.buttons.leave') }}
  238. </x-filament::button>
  239. </x-slot>
  240. </x-filament-companies::dialog-modal>
  241. <!-- Remove Company Employee Confirmation Modal -->
  242. <x-filament-companies::dialog-modal wire:model="confirmingCompanyEmployeeRemoval">
  243. <x-slot name="title">
  244. {{ __('filament-companies::default.modal_titles.remove_company_employee') }}
  245. </x-slot>
  246. <x-slot name="content">
  247. {{ __('filament-companies::default.modal_descriptions.remove_company_employee') }}
  248. </x-slot>
  249. <x-slot name="footer">
  250. <x-filament::button color="secondary" wire:click="$toggle('confirmingCompanyEmployeeRemoval')" wire:loading.attr="disabled">
  251. {{ __('filament-companies::default.buttons.cancel') }}
  252. </x-filament::button>
  253. <x-filament::button color="danger" wire:click="removeCompanyEmployee" wire:loading.attr="disabled">
  254. {{ __('filament-companies::default.buttons.remove') }}
  255. </x-filament::button>
  256. </x-slot>
  257. </x-filament-companies::dialog-modal>
  258. </div>