File: /home/posscale/public_html/printmanager/resources/views/tenant/customers/list.blade.php
<x-app-layout>
<x-slot name="header">
<h1 class="mb-0 uppercase text-3xl ">
{{ __('Manage Customers') }}
</h1>
</x-slot>
<div class="py-12">
<div class="">
@if(session()->has('message'))
<div class="alert alert-success text-white p-4 bg-green-900 font-semibold text-l mb-8">
{{ session()->get('message') }}
</div>
@endif
<div class="card mb-lg mt-0">
<div class="card-header flex">
<h3 class="card-title uppercase">
<i class="fas fa-users"></i>
Customers
</h3>
<div class="flex w-full items-center justify-end gap-2">
<form action="{{ route('customers.index') }}" method="GET">
<div class="flex flex-1 items-center justify-end">
<label class="group relative flex items-center">
<input placeholder="Search" value="{{$search}}" name="search" type="search" autocomplete="off" class="form-input mr-2">
<button type="submit" class="btn-primary inline-flex items-center px-4 py-3 bg-gray-800 dark:bg-gray-200 border border-transparent rounded-md font-semibold text-xs text-white dark:text-gray-800 uppercase tracking-widest hover:bg-gray-700 dark:hover:bg-white focus:bg-gray-700 dark:focus:bg-white active:bg-gray-900 dark:active:bg-gray-300 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 dark:focus:ring-offset-gray-800 transition ease-in-out duration-150">Search</button>
</label>
</div>
</form>
<a href="{{ route('customers.create') }}" class="btn-primary inline-flex items-center px-4 py-3 bg-gray-800 dark:bg-gray-200 border border-transparent rounded-md font-semibold text-xs text-white dark:text-gray-800 uppercase tracking-widest hover:bg-gray-700 dark:hover:bg-white focus:bg-gray-700 dark:focus:bg-white active:bg-gray-900 dark:active:bg-gray-300 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 dark:focus:ring-offset-gray-800 transition ease-in-out duration-150">Add New</a>
</div>
</div>
<div class="card-body ">
<div class="">
<div>
<table class="table">
<thead class="overflow-visible">
<tr class="uppercase text-sm font-medium text-gray-900 text-slate-700 font-semibold overflow-visible">
<th class="border-b pb-4 truncate text-left"></th>
@if(in_array('customer',$column_choise))
<th class="border-b pb-4 truncate text-left">
<a href="?sort_by=name&sort={{ ($sort_by =='name' && $sort=='asc')?'desc':'asc'}}">Customer</a>
</th>
@endif
@if(in_array('primary_contact',$column_choise))
<th class="border-b pb-4 truncate text-left"><a href="?sort_by=email&sort={{ ($sort_by =='email' && $sort=='asc')?'desc':'asc'}}">Primary Contact</a></th>
@endif
@if(in_array('number',$column_choise))
<th class="border-b pb-4 truncate text-left"><a href="?sort_by=phone&sort={{ ($sort_by =='phone' && $sort=='asc')?'desc':'asc'}}">Number</a></th>
@endif
<th class="border-b pb-4 text-center flex justify-between items-center overflow-visible">
<p class="text-white p-0 m-0">Action</p>
<div x-data="{ open: false }" class="relative inline-block text-left flex-row" width="48">
<!-- Trigger -->
<button @click="open = !open"
class="inline-flex items-center px-3 py-0 border border-transparent text-sm leading-4 font-medium rounded-md text-gray-500 bg-transparent hover:text-gray-700">
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24">
<path fill="#fff" d="M24 13.616v-3.232c-1.651-.587-2.694-.752-3.219-2.019v-.001c-.527-1.271.1-2.134.847-3.707l-2.285-2.285c-1.561.742-2.433 1.375-3.707.847h-.001c-1.269-.526-1.435-1.576-2.019-3.219h-3.232c-.582 1.635-.749 2.692-2.019 3.219h-.001c-1.271.528-2.132-.098-3.707-.847l-2.285 2.285c.745 1.568 1.375 2.434.847 3.707-.527 1.271-1.584 1.438-3.219 2.02v3.232c1.632.58 2.692.749 3.219 2.019.53 1.282-.114 2.166-.847 3.707l2.285 2.286c1.562-.743 2.434-1.375 3.707-.847h.001c1.27.526 1.436 1.579 2.019 3.219h3.232c.582-1.636.75-2.69 2.027-3.222h.001c1.262-.524 2.12.101 3.698.851l2.285-2.286c-.744-1.563-1.375-2.433-.848-3.706.527-1.271 1.588-1.44 3.221-2.021zm-12 2.384c-2.209 0-4-1.791-4-4s1.791-4 4-4 4 1.791 4 4-1.791 4-4 4z" />
</svg>
</button>
<!-- Dropdown -->
<div x-show="open" @click.outside="open = false"
x-transition
class="absolute right-0 mt-2 w-[250px] rounded-md shadow-lg bg-white ring-2 ring-black ring-opacity-5 z-100">
<form method="POST" action="{{ route('user_column_choise') }}" @submit.prevent="$event.target.submit(); open = false">
@csrf
<div class="px-4 py-3">
<label class="flex items-center">
<input {{is_array(old('user_column_choise',$column_choise??[]))&&in_array('customer',old('user_column_choise',$column_choise??[]))?'checked':null}} type="checkbox" name="user_column_choise[]" value="customer" class="form-checkbox">
<span class="ml-2 text-normal font-normal text-black">Customer</span>
</label>
<label class="flex items-center mt-2">
<input {{is_array(old('user_column_choise',$column_choise??[]))&&in_array('primary_contact',old('user_column_choise',$column_choise??[]))?'checked':null}} type="checkbox" name="user_column_choise[]" value="primary_contact" class="form-checkbox">
<span class="ml-2 text-normal font-normal text-black">Primary Contact</span>
</label>
<label class="flex items-center mt-2">
<input {{is_array(old('user_column_choise',$column_choise??[]))&&in_array('number',old('user_column_choise',$column_choise??[]))?'checked':null}} type="checkbox" name="user_column_choise[]" value="number" class="form-checkbox">
<span class="ml-2 text-normal font-normal text-black">Number</span>
</label>
<div class="mt-4">
<button type="submit"
class="text-[#28166f] w-[100px] border rounded border-[#3b82f6] inline-block mr-2 font-medium p-2 hover:bg-[#3b82f6] hover:text-white">
Apply
</button>
</div>
</div>
</form>
</div>
</div>
</th>
</tr>
</thead>
<tbody class="">
@forelse($customers as $customer)
<tr class="border-b border-slate-100 dark:border-slate-700 p-4 pl-8">
<td>
<label class="inline-flex items-center cursor-pointer text-white p-2 rounded border-black">
<input type="checkbox" value="" data-id="{{ $customer->id }}" class="sr-only peer printer_toggle">
<svg class="w-2.5 h-2.5 ms-3" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 10 6">
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m1 1 4 4 4-4" />
</svg>
</div>
<span class="ms-3 text-sm font-medium "></span>
</label>
</td>
@if(in_array('customer',$column_choise))
<td class="py-4">{{ $customer->name }}</td>
@endif
@if(in_array('primary_contact',$column_choise))
<td class="py-4">{{ $customer->email }}</td>
@endif
@if(in_array('number',$column_choise))
<td class="py-4">{{ $customer->phone }}</td>
@endif
<td class="py-4 w-80 text-white">
<a href="{{ route('customers.edit', $customer->id)}}" class="text-[#ffffff] border rounded border-[#ffffff] inline-block mr-2 font-medium p-2 hover:bg-[#3b82f6] hover:text-white">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" class="w-4 h-4 inline-block mr-1">
<path d="M21.731 2.269a2.625 2.625 0 0 0-3.712 0l-1.157 1.157 3.712 3.712 1.157-1.157a2.625 2.625 0 0 0 0-3.712ZM19.513 8.199l-3.712-3.712-12.15 12.15a5.25 5.25 0 0 0-1.32 2.214l-.8 2.685a.75.75 0 0 0 .933.933l2.685-.8a5.25 5.25 0 0 0 2.214-1.32L19.513 8.2Z" />
</svg>
EDIT
</a>
<a href="{{ route('customers.show', $customer->id)}}" class="text-[#ffffff] border rounded border-[#ffffff] inline-block mr-2 font-medium p-2 hover:bg-[#3b82f6] hover:text-white">
<svg class="w-4 h-4 inline-block mr-1 " fill="currentColor" version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="24" height="24" viewBox="0 0 442.04 442.04" xml:space="preserve">
<g>
<g>
<path d="M221.02,341.304c-49.708,0-103.206-19.44-154.71-56.22C27.808,257.59,4.044,230.351,3.051,229.203 c-4.068-4.697-4.068-11.669,0-16.367c0.993-1.146,24.756-28.387,63.259-55.881c51.505-36.777,105.003-56.219,154.71-56.219 c49.708,0,103.207,19.441,154.71,56.219c38.502,27.494,62.266,54.734,63.259,55.881c4.068,4.697,4.068,11.669,0,16.367 c-0.993,1.146-24.756,28.387-63.259,55.881C324.227,321.863,270.729,341.304,221.02,341.304z M29.638,221.021c9.61,9.799,27.747,27.03,51.694,44.071c32.83,23.361,83.714,51.212,139.688,51.212s106.859-27.851,139.688-51.212 c23.944-17.038,42.082-34.271,51.694-44.071c-9.609-9.799-27.747-27.03-51.694-44.071 c-32.829-23.362-83.714-51.212-139.688-51.212s-106.858,27.85-139.688,51.212C57.388,193.988,39.25,211.219,29.638,221.021z" />
</g>
<g>
<path d="M221.02,298.521c-42.734,0-77.5-34.767-77.5-77.5c0-42.733,34.766-77.5,77.5-77.5c18.794,0,36.924,6.814,51.048,19.188 c5.193,4.549,5.715,12.446,1.166,17.639c-4.549,5.193-12.447,5.714-17.639,1.166c-9.564-8.379-21.844-12.993-34.576-12.993 c-28.949,0-52.5,23.552-52.5,52.5s23.551,52.5,52.5,52.5c28.95,0,52.5-23.552,52.5-52.5c0-6.903,5.597-12.5,12.5-12.5 s12.5,5.597,12.5,12.5C298.521,263.754,263.754,298.521,221.02,298.521z" />
</g>
<g>
<path d="M221.02,246.021c-13.785,0-25-11.215-25-25s11.215-25,25-25c13.786,0,25,11.215,25,25S234.806,246.021,221.02,246.021z" />
</g>
</g>
</svg>
VIEW
</a>
<a x-data href="javascript:void(0);" class="text-[#ffffff] border rounded border-[#ffffff] inline-block mr-2 font-medium p-2 hover:bg-[#3b82f6] hover:text-white" @click="$dispatch('open-delete', { url: '{{route('customers.destroy', $customer->id)}}' })">
<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24" class="w-4 h-4 inline-block">
<path fill-rule="evenodd" d="M16.5 4.478v.227a48.816 48.816 0 0 1 3.878.512.75.75 0 1 1-.256 1.478l-.209-.035-1.005 13.07a3 3 0 0 1-2.991 2.77H8.084a3 3 0 0 1-2.991-2.77L4.087 6.66l-.209.035a.75.75 0 0 1-.256-1.478A48.567 48.567 0 0 1 7.5 4.705v-.227c0-1.564 1.213-2.9 2.816-2.951a52.662 52.662 0 0 1 3.369 0c1.603.051 2.815 1.387 2.815 2.951Zm-6.136-1.452a51.196 51.196 0 0 1 3.273 0C14.39 3.05 15 3.684 15 4.478v.113a49.488 49.488 0 0 0-6 0v-.113c0-.794.609-1.428 1.364-1.452Zm-.355 5.945a.75.75 0 1 0-1.5.058l.347 9a.75.75 0 1 0 1.499-.058l-.346-9Zm5.48.058a.75.75 0 1 0-1.498-.058l-.347 9a.75.75 0 0 0 1.5.058l.345-9Z" clip-rule="evenodd" />
</svg>
DELETE
</a>
</td>
</tr>
<tr class="hidden cus_printer cus_printer{{$customer->id}}">
<td colspan="5">
<table class="table">
<thead class="text-xs text-white uppercase bg-gray-600 dark:text-white">
<tr class="uppercase text-sm font-medium text-white text-slate-700 font-semibold">
<th class="px-6 py-3">Equipment ID</th>
<th class="px-6 py-3">Name</th>
<th class="px-6 py-3">Serial Number</th>
<th class="px-6 py-3 text-center">Action</th>
</tr>
</thead>
@forelse($customer->printer()->get() as $printer)
<tr class="border-b border-slate-100 dark:border-slate-700 p-4 pl-8">
<td class="px-6 py-4 ">{{ $printer->equipment_id }}</td>
<td class="px-6 py-4 ">{{ $printer->model_name }}</td>
<td class="px-6 py-4 ">{{ $printer->serial_number }}</td>
<td class="py-4 w-80 text-white text-center">
<a href="{{ route('printers.show', $printer->id)}}" class="text-[#ffffff] border rounded border-[#ffffff] inline-block mr-2 font-medium p-2 hover:bg-[#3b82f6] hover:text-white">
<svg class="w-4 h-4 inline-block mr-1 " fill="currentColor" version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="24" height="24" viewBox="0 0 442.04 442.04" xml:space="preserve">
<g>
<g>
<path d="M221.02,341.304c-49.708,0-103.206-19.44-154.71-56.22C27.808,257.59,4.044,230.351,3.051,229.203 c-4.068-4.697-4.068-11.669,0-16.367c0.993-1.146,24.756-28.387,63.259-55.881c51.505-36.777,105.003-56.219,154.71-56.219 c49.708,0,103.207,19.441,154.71,56.219c38.502,27.494,62.266,54.734,63.259,55.881c4.068,4.697,4.068,11.669,0,16.367 c-0.993,1.146-24.756,28.387-63.259,55.881C324.227,321.863,270.729,341.304,221.02,341.304z M29.638,221.021c9.61,9.799,27.747,27.03,51.694,44.071c32.83,23.361,83.714,51.212,139.688,51.212s106.859-27.851,139.688-51.212 c23.944-17.038,42.082-34.271,51.694-44.071c-9.609-9.799-27.747-27.03-51.694-44.071 c-32.829-23.362-83.714-51.212-139.688-51.212s-106.858,27.85-139.688,51.212C57.388,193.988,39.25,211.219,29.638,221.021z" />
</g>
<g>
<path d="M221.02,298.521c-42.734,0-77.5-34.767-77.5-77.5c0-42.733,34.766-77.5,77.5-77.5c18.794,0,36.924,6.814,51.048,19.188 c5.193,4.549,5.715,12.446,1.166,17.639c-4.549,5.193-12.447,5.714-17.639,1.166c-9.564-8.379-21.844-12.993-34.576-12.993 c-28.949,0-52.5,23.552-52.5,52.5s23.551,52.5,52.5,52.5c28.95,0,52.5-23.552,52.5-52.5c0-6.903,5.597-12.5,12.5-12.5 s12.5,5.597,12.5,12.5C298.521,263.754,263.754,298.521,221.02,298.521z" />
</g>
<g>
<path d="M221.02,246.021c-13.785,0-25-11.215-25-25s11.215-25,25-25c13.786,0,25,11.215,25,25S234.806,246.021,221.02,246.021z" />
</g>
</g>
</svg>
VIEW
</a>
</td>
</tr>
@empty
<tr>
<td class="border-b border-slate-100 dark:border-gray-700 p-4 pl-8 text-white" colspan="4">No printer found</td>
</tr>
@endforelse
</table>
</td>
</tr>
@empty
<tr>
<td class="border-b border-slate-100 dark:border-slate-700 p-4 pl-8 text-slate-500" colspan="4">No printer found</td>
</tr>
@endforelse
</tbody>
</table>
<div x-data="{ open: false, url:'' }">
<div @open-delete.window="url=$event.detail.url;open=true;" @keydown.escape.window="open = false" class="fixed inset-0 bg-gray-500 bg-opacity-75 transition-opacity" x-show="open" style="display: none" x-cloak>
<!-- Modal -->
<div class="flex items-center justify-center min-h-screen">
<div class="bg-white p-6 rounded-lg overflow-hidden shadow-xl transform transition-all sm:max-w-lg sm:w-full" @click.away="open = false" x-transition:enter="ease-out duration-100" x-transition:enter-start="opacity-0" x-transition:enter-end="opacity-100 scale-100" x-transition:leave="ease-in duration-200" x-transition:leave-start="opacity-100 scale-100" x-transition:leave-end="opacity-0">
<!-- Modal header -->
<div class="flex items-start justify-between">
<div class="text-left">
<h3 class="text-lg leading-6 font-medium text-black">Are you sure, Want to delete the customer?</h3>
</div>
<span class="cursor-pointer text-black text-xl" @click="open = false">✕</span>
</div>
<div class="mt-0 mb-10">
<p class="text-sm text-red-700">
After deleting customer, You will not able to restore it.
</p>
</div>
<!-- Modal footer -->
<div class="flex items-center justify-start gap-2 mt-10">
<button type="button" class="w-full btn btn-primary sm:w-auto uppercase" @click="open = false">
Cancel
</button>
<form x-bind:action="url" method="POST">
@csrf
@method('DELETE')
<button type="submit" class="w-full btn btn-error uppercase">
Delete
</button>
</form>
</div>
</div>
</div>
</div>
</div>
{{ $customers->links() }}
</div>
</div>
</div>
</div>
</div>
</x-app-layout>
<script>
document.querySelectorAll('.printer_toggle').forEach(toggle => {
toggle.addEventListener('click', () => {
const targetId = toggle.getAttribute('data-id');
const targetDiv = document.getElementsByClassName('cus_printer' + targetId)[0];
console.log(targetId);
console.log(targetDiv);
if (targetDiv) {
if (targetDiv.classList.contains('hidden')) {
targetDiv.classList.remove('hidden');
} else {
targetDiv.classList.add('hidden');
}
}
});
});
</script>