Added Client case person address to segment tables and exports
This commit is contained in:
parent
8031501d25
commit
2ad24216ae
|
|
@ -34,6 +34,7 @@ class SegmentContractsExport extends DefaultValueBinder implements FromQuery, Sh
|
|||
public const COLUMN_METADATA = [
|
||||
'reference' => ['label' => 'Pogodba'],
|
||||
'client_case' => ['label' => 'Primer'],
|
||||
'address' => ['label' => 'Naslov'],
|
||||
'client' => ['label' => 'Stranka'],
|
||||
'type' => ['label' => 'Vrsta'],
|
||||
'start_date' => ['label' => 'Začetek'],
|
||||
|
|
@ -107,6 +108,7 @@ private function resolveValue(Contract $contract, string $column): mixed
|
|||
return match ($column) {
|
||||
'reference' => $contract->reference,
|
||||
'client_case' => optional($contract->clientCase?->person)->full_name,
|
||||
'address' => optional($contract->clientCase?->person?->address)->address,
|
||||
'client' => optional($contract->clientCase?->client?->person)->full_name,
|
||||
'type' => optional($contract->type)->name,
|
||||
'start_date' => $this->formatDate($contract->start_date),
|
||||
|
|
|
|||
|
|
@ -65,6 +65,12 @@ public function show(Segment $segment)
|
|||
|
||||
$contracts = $this->hydrateClientShortcut($contracts);
|
||||
|
||||
// Hide addresses array since we're using the singular address relationship
|
||||
$contracts->getCollection()->each(function ($contract) {
|
||||
$contract->clientCase?->person?->makeHidden('addresses');
|
||||
$contract->clientCase?->client?->person?->makeHidden('addresses');
|
||||
});
|
||||
|
||||
$clients = Client::query()
|
||||
->whereHas('clientCases.contracts.segments', function ($q) use ($segment) {
|
||||
$q->where('segments.id', $segment->id)
|
||||
|
|
@ -191,8 +197,7 @@ private function buildContractsQuery(Segment $segment, ?string $search, ?string
|
|||
->where('contract_segment.active', '=', 1);
|
||||
})
|
||||
->with([
|
||||
'clientCase.person',
|
||||
'clientCase.client.person',
|
||||
'clientCase.person.address',
|
||||
'type',
|
||||
'account',
|
||||
])
|
||||
|
|
|
|||
|
|
@ -112,6 +112,14 @@ public function addresses(): HasMany
|
|||
->orderBy('id');
|
||||
}
|
||||
|
||||
public function address(): HasOne
|
||||
{
|
||||
return $this->hasOne(\App\Models\Person\PersonAddress::class)
|
||||
->with(['type'])
|
||||
->where('active', '=', 1)
|
||||
->oldestOfMany('id');
|
||||
}
|
||||
|
||||
public function emails(): HasMany
|
||||
{
|
||||
return $this->hasMany(\App\Models\Email::class, 'person_id')
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ const selectedClient = ref(initialClient);
|
|||
const columns = [
|
||||
{ key: "reference", label: "Pogodba", sortable: true },
|
||||
{ key: "client_case", label: "Primer" },
|
||||
{ key: "address", label: "Naslov" },
|
||||
{ key: "client", label: "Stranka" },
|
||||
{ key: "type", label: "Vrsta" },
|
||||
{ key: "start_date", label: "Začetek", sortable: true },
|
||||
|
|
@ -43,7 +44,9 @@ const totalContracts = computed(
|
|||
const currentPageCount = computed(() => props.contracts?.data?.length ?? 0);
|
||||
|
||||
const allColumnsSelected = computed(() => exportColumns.value.length === columns.length);
|
||||
const exportDisabled = computed(() => exportColumns.value.length === 0 || isExporting.value);
|
||||
const exportDisabled = computed(
|
||||
() => exportColumns.value.length === 0 || isExporting.value
|
||||
);
|
||||
|
||||
function toggleAllColumns(checked) {
|
||||
exportColumns.value = checked ? columns.map((col) => col.key) : [];
|
||||
|
|
@ -281,6 +284,10 @@ function extractFilenameFromHeaders(headers) {
|
|||
<span v-else>{{ row.client_case?.person?.full_name || "-" }}</span>
|
||||
</template>
|
||||
|
||||
<!-- Client case address -->
|
||||
<template #cell-address="{ row }">
|
||||
{{ row.client_case?.person?.address?.address || "-" }}
|
||||
</template>
|
||||
<!-- Stranka (client) name -->
|
||||
<template #cell-client="{ row }">
|
||||
{{ row.client?.person?.full_name || "-" }}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user