fix: Update search functionality to use service_name for Rate Cards and improve invoice form script
This commit is contained in:
@@ -121,7 +121,7 @@ class SearchController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ── Rate Cards ───────────────────────────────────────────
|
// ── Rate Cards ───────────────────────────────────────────
|
||||||
$rateCards = RateCard::where('name', 'LIKE', $like)
|
$rateCards = RateCard::where('service_name', 'LIKE', $like)
|
||||||
->orWhere('description', 'LIKE', $like)
|
->orWhere('description', 'LIKE', $like)
|
||||||
->limit($limit)->get();
|
->limit($limit)->get();
|
||||||
|
|
||||||
@@ -131,7 +131,7 @@ class SearchController extends Controller
|
|||||||
'label' => '💰 Rate Cards',
|
'label' => '💰 Rate Cards',
|
||||||
'items' => $rateCards->map(fn ($r) => [
|
'items' => $rateCards->map(fn ($r) => [
|
||||||
'icon' => '💰',
|
'icon' => '💰',
|
||||||
'title' => $r->name,
|
'title' => $r->service_name,
|
||||||
'subtitle' => $r->description ?? '',
|
'subtitle' => $r->description ?? '',
|
||||||
'url' => route('rate-cards.edit', $r),
|
'url' => route('rate-cards.edit', $r),
|
||||||
])->values()->all(),
|
])->values()->all(),
|
||||||
|
|||||||
@@ -175,7 +175,7 @@
|
|||||||
<script>
|
<script>
|
||||||
function invoiceForm() {
|
function invoiceForm() {
|
||||||
return {
|
return {
|
||||||
items: [{ description: '{{ addslashes($invoiceSettings->default_service_description ?? '') }}', quantity: 1, unit_price: 0, is_taxable: true }],
|
items: [{ description: @json($invoiceSettings->default_service_description ?? ''), quantity: 1, unit_price: 0, is_taxable: true }],
|
||||||
taxRate: {{ $invoiceSettings->default_tax_rate ?? 11 }},
|
taxRate: {{ $invoiceSettings->default_tax_rate ?? 11 }},
|
||||||
get subtotal() {
|
get subtotal() {
|
||||||
return this.items.reduce((s, i) => s + (i.quantity * i.unit_price), 0);
|
return this.items.reduce((s, i) => s + (i.quantity * i.unit_price), 0);
|
||||||
|
|||||||
@@ -252,24 +252,8 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||||||
if (e.target === this) this.classList.add('hidden');
|
if (e.target === this) this.classList.add('hidden');
|
||||||
});
|
});
|
||||||
|
|
||||||
// Combine date + time inputs into hidden datetime fields before submit
|
// Note: datetime hidden fields are populated in contractCheck's submitIfClear()
|
||||||
document.getElementById('new-event-form').addEventListener('submit', function(e) {
|
// since @submit.prevent is used on the form (form.submit() bypasses native submit event)
|
||||||
const startDate = document.getElementById('start_date').value;
|
|
||||||
const startTime = document.getElementById('start_time_input').value || '00:00';
|
|
||||||
const endDate = document.getElementById('end_date').value;
|
|
||||||
const endTime = document.getElementById('end_time_input').value || '00:00';
|
|
||||||
|
|
||||||
if (!startDate) {
|
|
||||||
e.preventDefault();
|
|
||||||
alert('Please select a start date.');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
document.getElementById('start_time_hidden').value = startDate + 'T' + startTime;
|
|
||||||
if (endDate) {
|
|
||||||
document.getElementById('end_time_hidden').value = endDate + 'T' + endTime;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -299,6 +283,23 @@ function contractCheck(checkUrl) {
|
|||||||
if (this.contractWarning) {
|
if (this.contractWarning) {
|
||||||
if (!confirm('⚠️ An exclusive contract is active for this category.\n\nAre you sure you want to proceed?')) return;
|
if (!confirm('⚠️ An exclusive contract is active for this category.\n\nAre you sure you want to proceed?')) return;
|
||||||
}
|
}
|
||||||
|
// Combine date + time inputs into the hidden datetime fields
|
||||||
|
// (form.submit() bypasses native 'submit' event, so we do it here)
|
||||||
|
const startDate = document.getElementById('start_date').value;
|
||||||
|
const startTime = document.getElementById('start_time_input').value || '00:00';
|
||||||
|
const endDate = document.getElementById('end_date').value;
|
||||||
|
const endTime = document.getElementById('end_time_input').value || '00:00';
|
||||||
|
|
||||||
|
if (!startDate) {
|
||||||
|
alert('Please select a start date.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
document.getElementById('start_time_hidden').value = startDate + 'T' + startTime;
|
||||||
|
if (endDate) {
|
||||||
|
document.getElementById('end_time_hidden').value = endDate + 'T' + endTime;
|
||||||
|
}
|
||||||
|
|
||||||
form.submit();
|
form.submit();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user