175 lines
10 KiB
PHP
Executable File
175 lines
10 KiB
PHP
Executable File
<x-layouts::app :title="__('Companies')">
|
||
<div class="space-y-6">
|
||
<x-wms.page-hero
|
||
eyebrow="Platform Administration"
|
||
title="Companies"
|
||
description="Manage tenant companies and keep every company’s users, warehouses and records isolated."
|
||
icon="fa-solid fa-building"
|
||
/>
|
||
|
||
@if (session('status'))
|
||
<div class="rounded-2xl bg-green-50 p-4 text-sm font-semibold text-green-700 ring-1 ring-green-200 dark:bg-green-950 dark:text-green-300 dark:ring-green-900">
|
||
{{ session('status') }}
|
||
</div>
|
||
@endif
|
||
|
||
<div class="rounded-3xl bg-white p-6 shadow-sm ring-1 ring-zinc-200 dark:bg-zinc-900 dark:ring-zinc-800">
|
||
<div class="flex flex-wrap items-start justify-between gap-4">
|
||
<div>
|
||
<h2 class="text-lg font-bold text-zinc-900 dark:text-white">Create company</h2>
|
||
<p class="mt-1 text-sm text-zinc-500 dark:text-zinc-400">Add a new tenant without leaving the administration index.</p>
|
||
</div>
|
||
|
||
<a
|
||
href="{{ route('platform.companies.create') }}"
|
||
class="rounded-xl border border-zinc-300 px-4 py-2 text-sm font-semibold text-zinc-700 hover:bg-zinc-50 dark:border-zinc-700 dark:text-zinc-200 dark:hover:bg-zinc-800"
|
||
>
|
||
Open full form
|
||
</a>
|
||
</div>
|
||
|
||
<form method="POST" action="{{ route('platform.companies.store') }}" class="mt-6">
|
||
@csrf
|
||
|
||
<div class="grid gap-5 xl:grid-cols-[minmax(0,1.15fr)_minmax(0,1.15fr)_minmax(12rem,.75fr)_minmax(18rem,1.15fr)_auto] xl:items-end">
|
||
<div>
|
||
<label for="quick_company_name" class="block text-xs font-bold uppercase tracking-wide text-zinc-500 dark:text-zinc-400">Company</label>
|
||
<input
|
||
id="quick_company_name"
|
||
name="name"
|
||
value="{{ old('name') }}"
|
||
placeholder="Company name"
|
||
class="mt-2 h-12 w-full rounded-xl border-zinc-300 bg-white px-4 text-sm text-zinc-900 shadow-sm outline-none transition focus:border-blue-500 focus:ring-2 focus:ring-blue-500/30 dark:border-zinc-700 dark:bg-zinc-950 dark:text-white"
|
||
required
|
||
>
|
||
@error('name')
|
||
<p class="mt-1 text-sm text-red-600 dark:text-red-400">{{ $message }}</p>
|
||
@enderror
|
||
</div>
|
||
|
||
<div>
|
||
<label for="quick_billing_email" class="block text-xs font-bold uppercase tracking-wide text-zinc-500 dark:text-zinc-400">Billing email</label>
|
||
<input
|
||
id="quick_billing_email"
|
||
name="billing_email"
|
||
value="{{ old('billing_email') }}"
|
||
placeholder="billing@example.com"
|
||
type="email"
|
||
class="mt-2 h-12 w-full rounded-xl border-zinc-300 bg-white px-4 text-sm text-zinc-900 shadow-sm outline-none transition focus:border-blue-500 focus:ring-2 focus:ring-blue-500/30 dark:border-zinc-700 dark:bg-zinc-950 dark:text-white"
|
||
>
|
||
@error('billing_email')
|
||
<p class="mt-1 text-sm text-red-600 dark:text-red-400">{{ $message }}</p>
|
||
@enderror
|
||
</div>
|
||
|
||
<div>
|
||
<label for="quick_status" class="block text-xs font-bold uppercase tracking-wide text-zinc-500 dark:text-zinc-400">Status</label>
|
||
<select
|
||
id="quick_status"
|
||
name="status"
|
||
class="mt-2 h-12 w-full rounded-xl border-zinc-300 bg-white px-4 text-sm text-zinc-900 shadow-sm outline-none transition focus:border-blue-500 focus:ring-2 focus:ring-blue-500/30 dark:border-zinc-700 dark:bg-zinc-950 dark:text-white"
|
||
required
|
||
>
|
||
<option value="active" @selected(old('status', 'active') === 'active')>Active</option>
|
||
<option value="suspended" @selected(old('status') === 'suspended')>Suspended</option>
|
||
<option value="inactive" @selected(old('status') === 'inactive')>Inactive</option>
|
||
</select>
|
||
@error('status')
|
||
<p class="mt-1 text-sm text-red-600 dark:text-red-400">{{ $message }}</p>
|
||
@enderror
|
||
</div>
|
||
|
||
<div class="wms-select2-field">
|
||
<label for="quick_country_id" class="block text-xs font-bold uppercase tracking-wide text-zinc-500 dark:text-zinc-400">Country</label>
|
||
<select
|
||
id="quick_country_id"
|
||
name="country_id"
|
||
data-wms-select2
|
||
data-placeholder="Search and select country"
|
||
class="w-full"
|
||
>
|
||
<option value=""></option>
|
||
@foreach($countries as $country)
|
||
<option value="{{ $country->id }}" @selected(old('country_id') == $country->id)>
|
||
{{ $country->display_name ?: $country->common_name ?: $country->name }}
|
||
</option>
|
||
@endforeach
|
||
</select>
|
||
@error('country_id')
|
||
<p class="mt-1 text-sm text-red-600 dark:text-red-400">{{ $message }}</p>
|
||
@enderror
|
||
</div>
|
||
|
||
<button class="h-12 rounded-xl bg-green-600 px-6 text-sm font-bold text-white shadow-sm shadow-green-950/20 transition hover:bg-green-500 focus:outline-none focus:ring-2 focus:ring-green-500/40">
|
||
Create
|
||
</button>
|
||
</div>
|
||
</form>
|
||
</div>
|
||
|
||
<div class="overflow-x-auto rounded-2xl bg-white shadow-sm ring-1 ring-zinc-200 dark:bg-zinc-900 dark:ring-zinc-800">
|
||
<table class="min-w-full text-sm">
|
||
<caption class="sr-only">Data table</caption>
|
||
<thead>
|
||
<tr class="border-b border-zinc-200 dark:border-zinc-800">
|
||
<th class="p-4 text-left">Name</th>
|
||
<th class="p-4 text-left">Users</th>
|
||
<th class="p-4 text-left">Divisions</th>
|
||
<th class="p-4 text-left">Warehouses</th>
|
||
<th class="p-4 text-left">Licences</th>
|
||
<th class="p-4 text-left">Status</th>
|
||
<th class="p-4 text-right">Actions</th>
|
||
</tr>
|
||
</thead>
|
||
|
||
<tbody>
|
||
@forelse ($companies as $company)
|
||
<tr class="border-b border-zinc-100 dark:border-zinc-800">
|
||
<td class="p-4 font-semibold text-zinc-900 dark:text-white">
|
||
{{ $company->name }}
|
||
</td>
|
||
<td class="p-4 text-zinc-700 dark:text-zinc-300">{{ $company->users_count }}</td>
|
||
<td class="p-4 text-zinc-700 dark:text-zinc-300">{{ $company->divisions_count ?? 0 }}</td>
|
||
<td class="p-4 text-zinc-700 dark:text-zinc-300">{{ $company->warehouses_count }}</td>
|
||
<td class="p-4 text-zinc-700 dark:text-zinc-300">{{ $company->license_keys_count }}</td>
|
||
<td class="p-4">
|
||
<span class="inline-flex rounded-full px-2.5 py-1 text-xs font-semibold
|
||
@if ($company->is_system_company)
|
||
bg-blue-100 text-blue-700 dark:bg-blue-950 dark:text-blue-300
|
||
@elseif ($company->status === 'active')
|
||
bg-green-100 text-green-700 dark:bg-green-950 dark:text-green-300
|
||
@else
|
||
bg-red-100 text-red-700 dark:bg-red-950 dark:text-red-300
|
||
@endif
|
||
">
|
||
{{ $company->is_system_company ? 'System' : ucfirst($company->status) }}
|
||
</span>
|
||
</td>
|
||
<td class="p-4">
|
||
<div class="flex justify-end gap-2">
|
||
<a href="{{ route('platform.companies.show', $company) }}" class="rounded-lg border border-zinc-300 px-3 py-1.5 text-xs font-semibold text-zinc-700 hover:bg-zinc-50 dark:border-zinc-700 dark:text-zinc-200 dark:hover:bg-zinc-800">View</a>
|
||
<a href="{{ route('platform.companies.edit', $company) }}" class="rounded-lg bg-blue-600 px-3 py-1.5 text-xs font-semibold text-white hover:bg-blue-700">Edit</a>
|
||
|
||
@unless ($company->is_system_company)
|
||
<form method="POST" action="{{ route('platform.companies.destroy', $company) }}" onsubmit="return confirm('Delete this company? This cannot be undone.');">
|
||
@csrf
|
||
@method('DELETE')
|
||
<button type="submit" class="rounded-lg bg-red-600 px-3 py-1.5 text-xs font-semibold text-white hover:bg-red-700">Delete</button>
|
||
</form>
|
||
@endunless
|
||
</div>
|
||
</td>
|
||
</tr>
|
||
@empty
|
||
<tr>
|
||
<td colspan="7" class="p-8 text-center text-zinc-500 dark:text-zinc-400">No companies found.</td>
|
||
</tr>
|
||
@endforelse
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
|
||
{{ $companies->links() }}
|
||
</div>
|
||
</x-layouts::app>
|