Compare commits
No commits in common. "b1c531bb701c22ee175d5c178c92ec460a262bb6" and "2968bcf3f825ac930712d367ba1fa95d4626bca5" have entirely different histories.
b1c531bb70
...
2968bcf3f8
|
|
@ -12,7 +12,6 @@
|
||||||
use App\Models\SmsTemplate;
|
use App\Models\SmsTemplate;
|
||||||
use App\Services\Contact\PhoneSelector;
|
use App\Services\Contact\PhoneSelector;
|
||||||
use App\Services\Sms\SmsService;
|
use App\Services\Sms\SmsService;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
use Illuminate\Http\RedirectResponse;
|
use Illuminate\Http\RedirectResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\Bus;
|
use Illuminate\Support\Facades\Bus;
|
||||||
|
|
@ -51,7 +50,6 @@ public function create(Request $request): Response
|
||||||
->get(['id', 'name', 'content']);
|
->get(['id', 'name', 'content']);
|
||||||
$segments = \App\Models\Segment::query()
|
$segments = \App\Models\Segment::query()
|
||||||
->where('active', true)
|
->where('active', true)
|
||||||
->where('exclude', false)
|
|
||||||
->orderBy('name')
|
->orderBy('name')
|
||||||
->get(['id', 'name']);
|
->get(['id', 'name']);
|
||||||
// Provide a lightweight list of recent clients with person names for filtering
|
// Provide a lightweight list of recent clients with person names for filtering
|
||||||
|
|
@ -323,6 +321,7 @@ public function contracts(Request $request, PhoneSelector $selector): \Illuminat
|
||||||
$request->validate([
|
$request->validate([
|
||||||
'segment_id' => ['nullable', 'integer', 'exists:segments,id'],
|
'segment_id' => ['nullable', 'integer', 'exists:segments,id'],
|
||||||
'q' => ['nullable', 'string'],
|
'q' => ['nullable', 'string'],
|
||||||
|
|
||||||
'client_id' => ['nullable', 'integer', 'exists:clients,id'],
|
'client_id' => ['nullable', 'integer', 'exists:clients,id'],
|
||||||
'only_mobile' => ['nullable', 'boolean'],
|
'only_mobile' => ['nullable', 'boolean'],
|
||||||
'only_validated' => ['nullable', 'boolean'],
|
'only_validated' => ['nullable', 'boolean'],
|
||||||
|
|
@ -334,12 +333,12 @@ public function contracts(Request $request, PhoneSelector $selector): \Illuminat
|
||||||
|
|
||||||
$segmentId = $request->input('segment_id') ? (int) $request->input('segment_id') : null;
|
$segmentId = $request->input('segment_id') ? (int) $request->input('segment_id') : null;
|
||||||
|
|
||||||
|
|
||||||
$query = Contract::query()
|
$query = Contract::query()
|
||||||
->with([
|
->with([
|
||||||
'clientCase.person.phones',
|
'clientCase.person.phones',
|
||||||
'clientCase.client.person',
|
'clientCase.client.person',
|
||||||
'account',
|
'account',
|
||||||
'segments:id,name',
|
|
||||||
])
|
])
|
||||||
->select('contracts.*')
|
->select('contracts.*')
|
||||||
->latest('contracts.id');
|
->latest('contracts.id');
|
||||||
|
|
@ -351,15 +350,6 @@ public function contracts(Request $request, PhoneSelector $selector): \Illuminat
|
||||||
->where('contract_segment.segment_id', '=', $segmentId)
|
->where('contract_segment.segment_id', '=', $segmentId)
|
||||||
->where('contract_segment.active', true);
|
->where('contract_segment.active', true);
|
||||||
});
|
});
|
||||||
} else {
|
|
||||||
// Only include contracts that have at least one active, non-excluded segment
|
|
||||||
$query->whereExists(fn ($exist) => $exist->select(\DB::raw(1))
|
|
||||||
->from('contract_segment')
|
|
||||||
->join('segments', 'segments.id', '=', 'contract_segment.segment_id')
|
|
||||||
->where('contract_segment.active', true)
|
|
||||||
->where('segments.exclude', false)
|
|
||||||
->whereColumn('contract_segment.contract_id', 'contracts.id')
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($q = trim((string) $request->input('q'))) {
|
if ($q = trim((string) $request->input('q'))) {
|
||||||
|
|
@ -409,14 +399,13 @@ public function contracts(Request $request, PhoneSelector $selector): \Illuminat
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
$contracts = $query->limit(500)->get();
|
$contracts = $query->get();
|
||||||
|
|
||||||
$data = collect($contracts)->map(function (Contract $contract) use ($selector) {
|
$data = collect($contracts)->map(function (Contract $contract) use ($selector) {
|
||||||
$person = $contract->clientCase?->person;
|
$person = $contract->clientCase?->person;
|
||||||
$selected = $person ? $selector->selectForPerson($person) : ['phone' => null, 'reason' => 'no_person'];
|
$selected = $person ? $selector->selectForPerson($person) : ['phone' => null, 'reason' => 'no_person'];
|
||||||
$phone = $selected['phone'];
|
$phone = $selected['phone'];
|
||||||
$clientPerson = $contract->clientCase?->client?->person;
|
$clientPerson = $contract->clientCase?->client?->person;
|
||||||
$segment = collect($contract->segments)->last();
|
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'id' => $contract->id,
|
'id' => $contract->id,
|
||||||
|
|
@ -434,7 +423,6 @@ public function contracts(Request $request, PhoneSelector $selector): \Illuminat
|
||||||
'uuid' => $person?->uuid,
|
'uuid' => $person?->uuid,
|
||||||
'full_name' => $person?->full_name,
|
'full_name' => $person?->full_name,
|
||||||
],
|
],
|
||||||
'segment' => $segment,
|
|
||||||
// Stranka: the client person
|
// Stranka: the client person
|
||||||
'client' => $clientPerson ? [
|
'client' => $clientPerson ? [
|
||||||
'id' => $contract->clientCase?->client?->id,
|
'id' => $contract->clientCase?->client?->id,
|
||||||
|
|
@ -452,7 +440,7 @@ public function contracts(Request $request, PhoneSelector $selector): \Illuminat
|
||||||
});
|
});
|
||||||
|
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'data' => $data,
|
'data' => $data
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@
|
||||||
use App\Models\ImportEvent;
|
use App\Models\ImportEvent;
|
||||||
use App\Models\ImportTemplate;
|
use App\Models\ImportTemplate;
|
||||||
use App\Services\CsvImportService;
|
use App\Services\CsvImportService;
|
||||||
|
use App\Services\Import\ImportServiceV2;
|
||||||
use App\Services\Import\ImportSimulationServiceV2;
|
use App\Services\Import\ImportSimulationServiceV2;
|
||||||
use App\Services\ImportProcessor;
|
use App\Services\ImportProcessor;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
|
@ -189,7 +190,6 @@ public function process(Import $import, Request $request, ImportProcessor $proce
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$result = $processor->process($import, user: $request->user());
|
$result = $processor->process($import, user: $request->user());
|
||||||
|
|
||||||
return response()->json($result);
|
return response()->json($result);
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
\Log::error('Import processing failed', [
|
\Log::error('Import processing failed', [
|
||||||
|
|
@ -202,7 +202,7 @@ public function process(Import $import, Request $request, ImportProcessor $proce
|
||||||
|
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'success' => false,
|
'success' => false,
|
||||||
'message' => 'Import processing failed: '.$e->getMessage(),
|
'message' => 'Import processing failed: ' . $e->getMessage(),
|
||||||
], 500);
|
], 500);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -712,6 +712,8 @@ public function simulatePayments(Import $import, Request $request)
|
||||||
* templates. For payments templates, payment-specific summaries/entities will be included
|
* templates. For payments templates, payment-specific summaries/entities will be included
|
||||||
* automatically by the simulation service when mappings contain the payment root.
|
* automatically by the simulation service when mappings contain the payment root.
|
||||||
*
|
*
|
||||||
|
* @param Import $import
|
||||||
|
* @param Request $request
|
||||||
* @return \Illuminate\Http\JsonResponse
|
* @return \Illuminate\Http\JsonResponse
|
||||||
*/
|
*/
|
||||||
public function simulate(Import $import, Request $request)
|
public function simulate(Import $import, Request $request)
|
||||||
|
|
@ -827,19 +829,4 @@ public function destroy(Request $request, Import $import)
|
||||||
|
|
||||||
return back()->with('success', 'Import deleted successfully');
|
return back()->with('success', 'Import deleted successfully');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Download the original import file
|
|
||||||
public function download(Import $import)
|
|
||||||
{
|
|
||||||
// Verify file exists
|
|
||||||
if (! $import->disk || ! $import->path || ! Storage::disk($import->disk)->exists($import->path)) {
|
|
||||||
return response()->json([
|
|
||||||
'error' => 'File not found',
|
|
||||||
], 404);
|
|
||||||
}
|
|
||||||
|
|
||||||
$fileName = $import->original_name ?? 'import_'.$import->uuid;
|
|
||||||
|
|
||||||
return Storage::disk($import->disk)->download($import->path, $fileName);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,177 +0,0 @@
|
||||||
<script setup>
|
|
||||||
import { CalendarIcon, XIcon } from "lucide-vue-next";
|
|
||||||
import { computed, ref } from "vue";
|
|
||||||
import { cn } from "@/lib/utils";
|
|
||||||
import { Button } from "@/Components/ui/button";
|
|
||||||
import { Popover, PopoverContent, PopoverTrigger } from "@/Components/ui/popover";
|
|
||||||
import { RangeCalendar } from "@/Components/ui/range-calendar";
|
|
||||||
import {
|
|
||||||
DateFormatter,
|
|
||||||
getLocalTimeZone,
|
|
||||||
today,
|
|
||||||
parseDate,
|
|
||||||
CalendarDate,
|
|
||||||
} from "@internationalized/date";
|
|
||||||
|
|
||||||
const props = defineProps({
|
|
||||||
modelValue: {
|
|
||||||
type: Object,
|
|
||||||
default: () => ({ start: null, end: null }),
|
|
||||||
},
|
|
||||||
placeholder: {
|
|
||||||
type: String,
|
|
||||||
default: "Izberi datumski obseg",
|
|
||||||
},
|
|
||||||
disabled: {
|
|
||||||
type: Boolean,
|
|
||||||
default: false,
|
|
||||||
},
|
|
||||||
buttonClass: {
|
|
||||||
type: String,
|
|
||||||
default: "w-[280px]",
|
|
||||||
},
|
|
||||||
locale: {
|
|
||||||
type: String,
|
|
||||||
default: "sl-SI",
|
|
||||||
},
|
|
||||||
numberOfMonths: {
|
|
||||||
type: Number,
|
|
||||||
default: 2,
|
|
||||||
},
|
|
||||||
minValue: {
|
|
||||||
type: Object,
|
|
||||||
default: undefined,
|
|
||||||
},
|
|
||||||
maxValue: {
|
|
||||||
type: Object,
|
|
||||||
default: undefined,
|
|
||||||
},
|
|
||||||
clearable: {
|
|
||||||
type: Boolean,
|
|
||||||
default: true,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const emit = defineEmits(["update:modelValue"]);
|
|
||||||
|
|
||||||
const open = ref(false);
|
|
||||||
|
|
||||||
const df = new DateFormatter(props.locale, {
|
|
||||||
dateStyle: "medium",
|
|
||||||
});
|
|
||||||
|
|
||||||
// Check if there's a selected value
|
|
||||||
const hasValue = computed(() => {
|
|
||||||
const val = props.modelValue;
|
|
||||||
return val?.start || val?.end;
|
|
||||||
});
|
|
||||||
|
|
||||||
// Convert string dates to CalendarDate objects for the calendar
|
|
||||||
const calendarValue = computed({
|
|
||||||
get() {
|
|
||||||
const val = props.modelValue;
|
|
||||||
if (!val) return undefined;
|
|
||||||
|
|
||||||
let start = null;
|
|
||||||
let end = null;
|
|
||||||
|
|
||||||
if (val.start) {
|
|
||||||
if (typeof val.start === "string") {
|
|
||||||
start = parseDate(val.start);
|
|
||||||
} else if (val.start instanceof CalendarDate) {
|
|
||||||
start = val.start;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (val.end) {
|
|
||||||
if (typeof val.end === "string") {
|
|
||||||
end = parseDate(val.end);
|
|
||||||
} else if (val.end instanceof CalendarDate) {
|
|
||||||
end = val.end;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!start && !end) return undefined;
|
|
||||||
return { start, end };
|
|
||||||
},
|
|
||||||
set(newValue) {
|
|
||||||
if (!newValue) {
|
|
||||||
emit("update:modelValue", { start: null, end: null });
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Convert CalendarDate to ISO string (YYYY-MM-DD) for easier handling
|
|
||||||
const result = {
|
|
||||||
start: newValue.start ? newValue.start.toString() : null,
|
|
||||||
end: newValue.end ? newValue.end.toString() : null,
|
|
||||||
};
|
|
||||||
emit("update:modelValue", result);
|
|
||||||
|
|
||||||
// Close popover when both dates are selected
|
|
||||||
if (result.start && result.end) {
|
|
||||||
open.value = false;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const displayText = computed(() => {
|
|
||||||
const val = calendarValue.value;
|
|
||||||
if (!val?.start) return props.placeholder;
|
|
||||||
|
|
||||||
const startFormatted = df.format(val.start.toDate(getLocalTimeZone()));
|
|
||||||
if (!val.end) return startFormatted;
|
|
||||||
|
|
||||||
const endFormatted = df.format(val.end.toDate(getLocalTimeZone()));
|
|
||||||
return `${startFormatted} - ${endFormatted}`;
|
|
||||||
});
|
|
||||||
|
|
||||||
function clearValue(event) {
|
|
||||||
event.stopPropagation();
|
|
||||||
emit("update:modelValue", { start: null, end: null });
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<Popover v-model:open="open">
|
|
||||||
<PopoverTrigger as-child>
|
|
||||||
<Button
|
|
||||||
variant="outline"
|
|
||||||
:disabled="disabled"
|
|
||||||
:class="
|
|
||||||
cn(
|
|
||||||
'justify-start text-left font-normal',
|
|
||||||
!calendarValue?.start && 'text-muted-foreground',
|
|
||||||
buttonClass
|
|
||||||
)
|
|
||||||
"
|
|
||||||
>
|
|
||||||
<CalendarIcon class="mr-2 h-4 w-4 shrink-0" />
|
|
||||||
<span class="truncate flex-1">{{ displayText }}</span>
|
|
||||||
<span
|
|
||||||
v-if="clearable && hasValue && !disabled"
|
|
||||||
class="ml-2 shrink-0 opacity-50 hover:opacity-100 cursor-pointer"
|
|
||||||
@click.stop.prevent="clearValue"
|
|
||||||
>
|
|
||||||
<XIcon class="h-4 w-4" />
|
|
||||||
</span>
|
|
||||||
</Button>
|
|
||||||
</PopoverTrigger>
|
|
||||||
<PopoverContent class="w-auto p-0" align="start">
|
|
||||||
<RangeCalendar
|
|
||||||
v-model="calendarValue"
|
|
||||||
:locale="locale"
|
|
||||||
:number-of-months="numberOfMonths"
|
|
||||||
:min-value="minValue"
|
|
||||||
:max-value="maxValue"
|
|
||||||
initial-focus
|
|
||||||
@update:start-value="
|
|
||||||
(startDate) => {
|
|
||||||
if (calendarValue?.start?.toString() !== startDate?.toString()) {
|
|
||||||
calendarValue = { start: startDate, end: undefined };
|
|
||||||
}
|
|
||||||
}
|
|
||||||
"
|
|
||||||
/>
|
|
||||||
</PopoverContent>
|
|
||||||
</Popover>
|
|
||||||
</template>
|
|
||||||
|
|
@ -2,7 +2,6 @@
|
||||||
import AdminLayout from "@/Layouts/AdminLayout.vue";
|
import AdminLayout from "@/Layouts/AdminLayout.vue";
|
||||||
import { Link, router, useForm } from "@inertiajs/vue3";
|
import { Link, router, useForm } from "@inertiajs/vue3";
|
||||||
import { ref, computed, nextTick } from "vue";
|
import { ref, computed, nextTick } from "vue";
|
||||||
import axios from "axios";
|
|
||||||
import {
|
import {
|
||||||
Card,
|
Card,
|
||||||
CardContent,
|
CardContent,
|
||||||
|
|
@ -40,9 +39,6 @@ import {
|
||||||
BadgeCheckIcon,
|
BadgeCheckIcon,
|
||||||
} from "lucide-vue-next";
|
} from "lucide-vue-next";
|
||||||
import { fmtDateDMY } from "@/Utilities/functions";
|
import { fmtDateDMY } from "@/Utilities/functions";
|
||||||
import { upperFirst } from "lodash";
|
|
||||||
import AppCombobox from "@/Components/app/ui/AppCombobox.vue";
|
|
||||||
import AppRangeDatePicker from "@/Components/app/ui/AppRangeDatePicker.vue";
|
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
profiles: { type: Array, default: () => [] },
|
profiles: { type: Array, default: () => [] },
|
||||||
|
|
@ -127,19 +123,13 @@ const contracts = ref({
|
||||||
const segmentId = ref(null);
|
const segmentId = ref(null);
|
||||||
const search = ref("");
|
const search = ref("");
|
||||||
const clientId = ref(null);
|
const clientId = ref(null);
|
||||||
const startDateRange = ref({ start: null, end: null });
|
const startDateFrom = ref("");
|
||||||
const promiseDateRange = ref({ start: null, end: null });
|
const startDateTo = ref("");
|
||||||
|
const promiseDateFrom = ref("");
|
||||||
|
const promiseDateTo = ref("");
|
||||||
const onlyMobile = ref(false);
|
const onlyMobile = ref(false);
|
||||||
const onlyValidated = ref(false);
|
const onlyValidated = ref(false);
|
||||||
const loadingContracts = ref(false);
|
const loadingContracts = ref(false);
|
||||||
|
|
||||||
// Transform clients for AppCombobox
|
|
||||||
const clientItems = computed(() =>
|
|
||||||
props.clients.map((c) => ({
|
|
||||||
value: c.id,
|
|
||||||
label: c.name,
|
|
||||||
}))
|
|
||||||
);
|
|
||||||
const selectedContractIds = ref(new Set());
|
const selectedContractIds = ref(new Set());
|
||||||
const perPage = ref(25);
|
const perPage = ref(25);
|
||||||
|
|
||||||
|
|
@ -163,11 +153,6 @@ const contractColumns = [
|
||||||
accessorFn: (row) => row.selected_phone?.number || "—",
|
accessorFn: (row) => row.selected_phone?.number || "—",
|
||||||
header: "Izbrana številka",
|
header: "Izbrana številka",
|
||||||
},
|
},
|
||||||
{
|
|
||||||
id: "segment",
|
|
||||||
accessorFn: (row) => upperFirst(row.segment?.name) || "—",
|
|
||||||
header: "Segment",
|
|
||||||
},
|
|
||||||
{ accessorKey: "no_phone_reason", header: "Opomba" },
|
{ accessorKey: "no_phone_reason", header: "Opomba" },
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
@ -190,22 +175,19 @@ async function loadContracts(url = null) {
|
||||||
if (segmentId.value) params.append("segment_id", segmentId.value);
|
if (segmentId.value) params.append("segment_id", segmentId.value);
|
||||||
if (search.value) params.append("q", search.value);
|
if (search.value) params.append("q", search.value);
|
||||||
if (clientId.value) params.append("client_id", clientId.value);
|
if (clientId.value) params.append("client_id", clientId.value);
|
||||||
if (startDateRange.value?.start)
|
if (startDateFrom.value) params.append("start_date_from", startDateFrom.value);
|
||||||
params.append("start_date_from", startDateRange.value.start);
|
if (startDateTo.value) params.append("start_date_to", startDateTo.value);
|
||||||
if (startDateRange.value?.end)
|
if (promiseDateFrom.value) params.append("promise_date_from", promiseDateFrom.value);
|
||||||
params.append("start_date_to", startDateRange.value.end);
|
if (promiseDateTo.value) params.append("promise_date_to", promiseDateTo.value);
|
||||||
if (promiseDateRange.value?.start)
|
|
||||||
params.append("promise_date_from", promiseDateRange.value.start);
|
|
||||||
if (promiseDateRange.value?.end)
|
|
||||||
params.append("promise_date_to", promiseDateRange.value.end);
|
|
||||||
if (onlyMobile.value) params.append("only_mobile", "1");
|
if (onlyMobile.value) params.append("only_mobile", "1");
|
||||||
if (onlyValidated.value) params.append("only_validated", "1");
|
if (onlyValidated.value) params.append("only_validated", "1");
|
||||||
params.append("per_page", perPage.value);
|
params.append("per_page", perPage.value);
|
||||||
|
|
||||||
const target = url || `${route("admin.packages.contracts")}?${params.toString()}`;
|
const target = url || `${route("admin.packages.contracts")}?${params.toString()}`;
|
||||||
const { data: json } = await axios.get(target, {
|
const res = await fetch(target, {
|
||||||
headers: { "X-Requested-With": "XMLHttpRequest" },
|
headers: { "X-Requested-With": "XMLHttpRequest" },
|
||||||
});
|
});
|
||||||
|
const json = await res.json();
|
||||||
|
|
||||||
// Wait for next tick before updating to avoid Vue reconciliation issues
|
// Wait for next tick before updating to avoid Vue reconciliation issues
|
||||||
await nextTick();
|
await nextTick();
|
||||||
|
|
@ -256,13 +238,10 @@ function goToPage(page) {
|
||||||
if (segmentId.value) params.append("segment_id", segmentId.value);
|
if (segmentId.value) params.append("segment_id", segmentId.value);
|
||||||
if (search.value) params.append("q", search.value);
|
if (search.value) params.append("q", search.value);
|
||||||
if (clientId.value) params.append("client_id", clientId.value);
|
if (clientId.value) params.append("client_id", clientId.value);
|
||||||
if (startDateRange.value?.start)
|
if (startDateFrom.value) params.append("start_date_from", startDateFrom.value);
|
||||||
params.append("start_date_from", startDateRange.value.start);
|
if (startDateTo.value) params.append("start_date_to", startDateTo.value);
|
||||||
if (startDateRange.value?.end) params.append("start_date_to", startDateRange.value.end);
|
if (promiseDateFrom.value) params.append("promise_date_from", promiseDateFrom.value);
|
||||||
if (promiseDateRange.value?.start)
|
if (promiseDateTo.value) params.append("promise_date_to", promiseDateTo.value);
|
||||||
params.append("promise_date_from", promiseDateRange.value.start);
|
|
||||||
if (promiseDateRange.value?.end)
|
|
||||||
params.append("promise_date_to", promiseDateRange.value.end);
|
|
||||||
if (onlyMobile.value) params.append("only_mobile", "1");
|
if (onlyMobile.value) params.append("only_mobile", "1");
|
||||||
if (onlyValidated.value) params.append("only_validated", "1");
|
if (onlyValidated.value) params.append("only_validated", "1");
|
||||||
params.append("per_page", perPage.value);
|
params.append("per_page", perPage.value);
|
||||||
|
|
@ -276,8 +255,10 @@ function resetFilters() {
|
||||||
segmentId.value = null;
|
segmentId.value = null;
|
||||||
clientId.value = null;
|
clientId.value = null;
|
||||||
search.value = "";
|
search.value = "";
|
||||||
startDateRange.value = { start: null, end: null };
|
startDateFrom.value = "";
|
||||||
promiseDateRange.value = { start: null, end: null };
|
startDateTo.value = "";
|
||||||
|
promiseDateFrom.value = "";
|
||||||
|
promiseDateTo.value = "";
|
||||||
onlyMobile.value = false;
|
onlyMobile.value = false;
|
||||||
onlyValidated.value = false;
|
onlyValidated.value = false;
|
||||||
contracts.value = {
|
contracts.value = {
|
||||||
|
|
@ -467,10 +448,9 @@ const numbersCount = computed(() => {
|
||||||
<div class="flex items-center justify-between">
|
<div class="flex items-center justify-between">
|
||||||
<div class="flex items-center gap-2">
|
<div class="flex items-center gap-2">
|
||||||
<Checkbox
|
<Checkbox
|
||||||
:model-value="form.delivery_report"
|
:checked="form.delivery_report"
|
||||||
@update:model-value="(val) => (form.delivery_report = val)"
|
@update:checked="(val) => (form.delivery_report = val)"
|
||||||
id="delivery-report"
|
id="delivery-report"
|
||||||
:disabled="true"
|
|
||||||
/>
|
/>
|
||||||
<Label for="delivery-report" class="cursor-pointer text-sm">
|
<Label for="delivery-report" class="cursor-pointer text-sm">
|
||||||
Zahtevaj delivery report
|
Zahtevaj delivery report
|
||||||
|
|
@ -573,15 +553,17 @@ const numbersCount = computed(() => {
|
||||||
</div>
|
</div>
|
||||||
<div class="space-y-2">
|
<div class="space-y-2">
|
||||||
<Label>Stranka</Label>
|
<Label>Stranka</Label>
|
||||||
<AppCombobox
|
<Select v-model="clientId" @update:model-value="loadContracts()">
|
||||||
v-model="clientId"
|
<SelectTrigger>
|
||||||
:items="clientItems"
|
<SelectValue placeholder="Vse stranke" />
|
||||||
placeholder="Vse stranke"
|
</SelectTrigger>
|
||||||
search-placeholder="Išči stranko..."
|
<SelectContent>
|
||||||
empty-text="Stranka ni najdena."
|
<SelectItem :value="null">Vse stranke</SelectItem>
|
||||||
button-class="w-full"
|
<SelectItem v-for="c in clients" :key="c.id" :value="c.id">
|
||||||
@update:model-value="loadContracts()"
|
{{ c.name }}
|
||||||
/>
|
</SelectItem>
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
</div>
|
</div>
|
||||||
<div class="space-y-2">
|
<div class="space-y-2">
|
||||||
<Label>Iskanje po referenci</Label>
|
<Label>Iskanje po referenci</Label>
|
||||||
|
|
@ -604,21 +586,29 @@ const numbersCount = computed(() => {
|
||||||
<div class="grid gap-4 md:grid-cols-2">
|
<div class="grid gap-4 md:grid-cols-2">
|
||||||
<div class="space-y-3">
|
<div class="space-y-3">
|
||||||
<p class="text-sm text-muted-foreground">Datum začetka pogodbe</p>
|
<p class="text-sm text-muted-foreground">Datum začetka pogodbe</p>
|
||||||
<AppRangeDatePicker
|
<div class="grid grid-cols-2 gap-2">
|
||||||
v-model="startDateRange"
|
<div class="space-y-2">
|
||||||
placeholder="Izberi obdobje"
|
<Label class="text-xs">Od</Label>
|
||||||
button-class="w-full"
|
<Input v-model="startDateFrom" type="date" />
|
||||||
:number-of-months="1"
|
</div>
|
||||||
/>
|
<div class="space-y-2">
|
||||||
|
<Label class="text-xs">Do</Label>
|
||||||
|
<Input v-model="startDateTo" type="date" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="space-y-3">
|
<div class="space-y-3">
|
||||||
<p class="text-sm text-muted-foreground">Datum obljube plačila</p>
|
<p class="text-sm text-muted-foreground">Datum obljube plačila</p>
|
||||||
<AppRangeDatePicker
|
<div class="grid grid-cols-2 gap-2">
|
||||||
v-model="promiseDateRange"
|
<div class="space-y-2">
|
||||||
placeholder="Izberi obdobje"
|
<Label class="text-xs">Od</Label>
|
||||||
button-class="w-full"
|
<Input v-model="promiseDateFrom" type="date" />
|
||||||
:number-of-months="1"
|
</div>
|
||||||
/>
|
<div class="space-y-2">
|
||||||
|
<Label class="text-xs">Do</Label>
|
||||||
|
<Input v-model="promiseDateTo" type="date" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -631,8 +621,8 @@ const numbersCount = computed(() => {
|
||||||
<div class="flex flex-wrap gap-4">
|
<div class="flex flex-wrap gap-4">
|
||||||
<div class="flex items-center gap-2">
|
<div class="flex items-center gap-2">
|
||||||
<Checkbox
|
<Checkbox
|
||||||
:model-value="onlyMobile"
|
:checked="onlyMobile"
|
||||||
@update:model-value="
|
@update:checked="
|
||||||
(val) => {
|
(val) => {
|
||||||
onlyMobile = val;
|
onlyMobile = val;
|
||||||
}
|
}
|
||||||
|
|
@ -645,8 +635,8 @@ const numbersCount = computed(() => {
|
||||||
</div>
|
</div>
|
||||||
<div class="flex items-center gap-2">
|
<div class="flex items-center gap-2">
|
||||||
<Checkbox
|
<Checkbox
|
||||||
:model-value="onlyValidated"
|
:checked="onlyValidated"
|
||||||
@update:model-value="
|
@update:checked="
|
||||||
(val) => {
|
(val) => {
|
||||||
onlyValidated = val;
|
onlyValidated = val;
|
||||||
}
|
}
|
||||||
|
|
@ -663,11 +653,11 @@ const numbersCount = computed(() => {
|
||||||
<!-- Action buttons -->
|
<!-- Action buttons -->
|
||||||
<div class="flex items-center gap-2">
|
<div class="flex items-center gap-2">
|
||||||
<Button @click="loadContracts()">
|
<Button @click="loadContracts()">
|
||||||
<SearchIcon class="h-4 w-4" />
|
<SearchIcon class="h-4 w-4 mr-2" />
|
||||||
Išči pogodbe
|
Išči pogodbe
|
||||||
</Button>
|
</Button>
|
||||||
<Button @click="resetFilters" variant="outline">
|
<Button @click="resetFilters" variant="outline">
|
||||||
<XCircleIcon class="h-4 w-4" />
|
<XCircleIcon class="h-4 w-4 mr-2" />
|
||||||
Počisti filtre
|
Počisti filtre
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -679,7 +669,7 @@ const numbersCount = computed(() => {
|
||||||
<CardHeader>
|
<CardHeader>
|
||||||
<div class="flex items-center justify-between">
|
<div class="flex items-center justify-between">
|
||||||
<div>
|
<div>
|
||||||
<CardTitle>Rezultati iskanja (do 500 zapisov)</CardTitle>
|
<CardTitle>Rezultati iskanja</CardTitle>
|
||||||
<CardDescription v-if="contracts.meta.total > 0">
|
<CardDescription v-if="contracts.meta.total > 0">
|
||||||
Najdeno {{ contracts.meta.total }}
|
Najdeno {{ contracts.meta.total }}
|
||||||
{{
|
{{
|
||||||
|
|
@ -699,7 +689,7 @@ const numbersCount = computed(() => {
|
||||||
variant="secondary"
|
variant="secondary"
|
||||||
class="text-sm"
|
class="text-sm"
|
||||||
>
|
>
|
||||||
<CheckCircle2Icon class="h-3 w-3" />
|
<CheckCircle2Icon class="h-3 w-3 mr-1" />
|
||||||
Izbrano: {{ selectedContractIds.size }}
|
Izbrano: {{ selectedContractIds.size }}
|
||||||
</Badge>
|
</Badge>
|
||||||
<Button
|
<Button
|
||||||
|
|
@ -712,7 +702,7 @@ const numbersCount = computed(() => {
|
||||||
@click="submitCreateFromContracts"
|
@click="submitCreateFromContracts"
|
||||||
:disabled="selectedContractIds.size === 0 || creatingFromContracts"
|
:disabled="selectedContractIds.size === 0 || creatingFromContracts"
|
||||||
>
|
>
|
||||||
<SaveIcon class="h-4 w-4" />
|
<SaveIcon class="h-4 w-4 mr-2" />
|
||||||
Ustvari paket ({{ selectedContractIds.size }}
|
Ustvari paket ({{ selectedContractIds.size }}
|
||||||
{{
|
{{
|
||||||
selectedContractIds.size === 1
|
selectedContractIds.size === 1
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,6 @@ import {
|
||||||
import DataTableNew2 from "@/Components/DataTable/DataTableNew2.vue";
|
import DataTableNew2 from "@/Components/DataTable/DataTableNew2.vue";
|
||||||
import { PackageIcon, PlusIcon, Trash2Icon, EyeIcon } from "lucide-vue-next";
|
import { PackageIcon, PlusIcon, Trash2Icon, EyeIcon } from "lucide-vue-next";
|
||||||
import AppCard from "@/Components/app/ui/card/AppCard.vue";
|
import AppCard from "@/Components/app/ui/card/AppCard.vue";
|
||||||
import { fmtDateTime } from "@/Utilities/functions";
|
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
packages: { type: Object, required: true },
|
packages: { type: Object, required: true },
|
||||||
|
|
@ -30,6 +29,7 @@ const showDeleteDialog = ref(false);
|
||||||
|
|
||||||
const columns = [
|
const columns = [
|
||||||
{ accessorKey: "id", header: "ID" },
|
{ accessorKey: "id", header: "ID" },
|
||||||
|
{ accessorKey: "uuid", header: "UUID" },
|
||||||
{ accessorKey: "name", header: "Ime" },
|
{ accessorKey: "name", header: "Ime" },
|
||||||
{ accessorKey: "type", header: "Tip" },
|
{ accessorKey: "type", header: "Tip" },
|
||||||
{ accessorKey: "status", header: "Status" },
|
{ accessorKey: "status", header: "Status" },
|
||||||
|
|
@ -84,7 +84,7 @@ function confirmDelete() {
|
||||||
</div>
|
</div>
|
||||||
<Link :href="route('admin.packages.create')">
|
<Link :href="route('admin.packages.create')">
|
||||||
<Button>
|
<Button>
|
||||||
<PlusIcon class="h-4 w-4" />
|
<PlusIcon class="h-4 w-4 mr-2" />
|
||||||
Nov paket
|
Nov paket
|
||||||
</Button>
|
</Button>
|
||||||
</Link>
|
</Link>
|
||||||
|
|
@ -111,6 +111,10 @@ function confirmDelete() {
|
||||||
:meta="packages"
|
:meta="packages"
|
||||||
route-name="admin.packages.index"
|
route-name="admin.packages.index"
|
||||||
>
|
>
|
||||||
|
<template #cell-uuid="{ row }">
|
||||||
|
<span class="font-mono text-xs text-muted-foreground">{{ row.uuid }}</span>
|
||||||
|
</template>
|
||||||
|
|
||||||
<template #cell-name="{ row }">
|
<template #cell-name="{ row }">
|
||||||
<span class="text-sm">{{ row.name ?? "—" }}</span>
|
<span class="text-sm">{{ row.name ?? "—" }}</span>
|
||||||
</template>
|
</template>
|
||||||
|
|
@ -124,9 +128,7 @@ function confirmDelete() {
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template #cell-finished_at="{ row }">
|
<template #cell-finished_at="{ row }">
|
||||||
<span class="text-xs text-muted-foreground">{{
|
<span class="text-xs text-muted-foreground">{{ row.finished_at ?? "—" }}</span>
|
||||||
fmtDateTime(row.finished_at) ?? "—"
|
|
||||||
}}</span>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template #cell-actions="{ row }">
|
<template #cell-actions="{ row }">
|
||||||
|
|
@ -155,10 +157,8 @@ function confirmDelete() {
|
||||||
<AlertDialogTitle>Izbriši paket?</AlertDialogTitle>
|
<AlertDialogTitle>Izbriši paket?</AlertDialogTitle>
|
||||||
<AlertDialogDescription>
|
<AlertDialogDescription>
|
||||||
Ali ste prepričani, da želite izbrisati paket
|
Ali ste prepričani, da želite izbrisati paket
|
||||||
<strong v-if="packageToDelete"
|
<strong v-if="packageToDelete">#{{ packageToDelete.id }} - {{ packageToDelete.name || 'Brez imena' }}</strong>?
|
||||||
>#{{ packageToDelete.id }} -
|
Tega dejanja ni mogoče razveljaviti.
|
||||||
{{ packageToDelete.name || "Brez imena" }}</strong
|
|
||||||
>? Tega dejanja ni mogoče razveljaviti.
|
|
||||||
</AlertDialogDescription>
|
</AlertDialogDescription>
|
||||||
</AlertDialogHeader>
|
</AlertDialogHeader>
|
||||||
<AlertDialogFooter>
|
<AlertDialogFooter>
|
||||||
|
|
|
||||||
|
|
@ -245,7 +245,7 @@ async function startImport() {
|
||||||
|
|
||||||
<!-- Has Header Checkbox -->
|
<!-- Has Header Checkbox -->
|
||||||
<div class="flex items-center space-x-2">
|
<div class="flex items-center space-x-2">
|
||||||
<Checkbox id="has-header" :model-value="form.has_header" />
|
<Checkbox id="has-header" v-model:checked="form.has_header" />
|
||||||
<Label
|
<Label
|
||||||
for="has-header"
|
for="has-header"
|
||||||
class="cursor-pointer text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
|
class="cursor-pointer text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
|
||||||
|
|
|
||||||
|
|
@ -1094,16 +1094,6 @@ async function fetchEvents() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function downloadImport() {
|
|
||||||
if (!importId.value) return;
|
|
||||||
try {
|
|
||||||
const url = route("imports.download", { import: importId.value });
|
|
||||||
window.location.href = url;
|
|
||||||
} catch (e) {
|
|
||||||
console.error("Download failed", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Simulation (generic or payments) state
|
// Simulation (generic or payments) state
|
||||||
const showPaymentSim = ref(false);
|
const showPaymentSim = ref(false);
|
||||||
const paymentSimLoading = ref(false);
|
const paymentSimLoading = ref(false);
|
||||||
|
|
@ -1317,8 +1307,7 @@ async function fetchSimulation() {
|
||||||
<Checkbox
|
<Checkbox
|
||||||
:id="'show-missing-checkbox'"
|
:id="'show-missing-checkbox'"
|
||||||
:checked="showMissingEnabled"
|
:checked="showMissingEnabled"
|
||||||
:model-value="showMissingEnabled"
|
@update:checked="
|
||||||
@update:model-value="
|
|
||||||
(val) => {
|
(val) => {
|
||||||
showMissingEnabled = val;
|
showMissingEnabled = val;
|
||||||
saveImportOptions();
|
saveImportOptions();
|
||||||
|
|
@ -1350,7 +1339,6 @@ async function fetchSimulation() {
|
||||||
:can-process="canProcess"
|
:can-process="canProcess"
|
||||||
:selected-mappings-count="selectedMappingsCount"
|
:selected-mappings-count="selectedMappingsCount"
|
||||||
@preview="openPreview"
|
@preview="openPreview"
|
||||||
@download="downloadImport"
|
|
||||||
@save-mappings="saveMappings"
|
@save-mappings="saveMappings"
|
||||||
@process-import="processImport"
|
@process-import="processImport"
|
||||||
@simulate="openSimulation"
|
@simulate="openSimulation"
|
||||||
|
|
|
||||||
|
|
@ -4,10 +4,9 @@ import {
|
||||||
ArrowPathIcon,
|
ArrowPathIcon,
|
||||||
BeakerIcon,
|
BeakerIcon,
|
||||||
ArrowDownOnSquareIcon,
|
ArrowDownOnSquareIcon,
|
||||||
ArrowDownTrayIcon,
|
|
||||||
} from "@heroicons/vue/24/outline";
|
} from "@heroicons/vue/24/outline";
|
||||||
import { Button } from "@/Components/ui/button";
|
import { Button } from '@/Components/ui/button';
|
||||||
import { Badge } from "@/Components/ui/badge";
|
import { Badge } from '@/Components/ui/badge';
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
importId: [Number, String],
|
importId: [Number, String],
|
||||||
|
|
@ -17,68 +16,54 @@ const props = defineProps({
|
||||||
canProcess: Boolean,
|
canProcess: Boolean,
|
||||||
selectedMappingsCount: Number,
|
selectedMappingsCount: Number,
|
||||||
});
|
});
|
||||||
const emits = defineEmits([
|
const emits = defineEmits(["preview", "save-mappings", "process-import", "simulate"]);
|
||||||
"preview",
|
|
||||||
"save-mappings",
|
|
||||||
"process-import",
|
|
||||||
"simulate",
|
|
||||||
"download",
|
|
||||||
]);
|
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<div class="flex flex-wrap gap-2 items-center">
|
<div class="flex flex-wrap gap-2 items-center" v-if="!isCompleted">
|
||||||
<!-- Download button - always visible -->
|
|
||||||
<Button
|
<Button
|
||||||
variant="secondary"
|
variant="secondary"
|
||||||
@click.prevent="$emit('download')"
|
@click.prevent="$emit('preview')"
|
||||||
:disabled="!importId"
|
:disabled="!importId"
|
||||||
title="Preznesi originalno uvozno datoteko"
|
|
||||||
>
|
>
|
||||||
<ArrowDownTrayIcon class="h-4 w-4" />
|
<EyeIcon class="h-4 w-4 mr-2" />
|
||||||
Prenos datoteko
|
Predogled vrstic
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
variant="default"
|
||||||
|
class="bg-orange-600 hover:bg-orange-700"
|
||||||
|
@click.prevent="$emit('save-mappings')"
|
||||||
|
:disabled="!importId || processing || savingMappings || isCompleted"
|
||||||
|
title="Shrani preslikave za ta uvoz"
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
v-if="savingMappings"
|
||||||
|
class="inline-block h-4 w-4 mr-2 border-2 border-white/70 border-t-transparent rounded-full animate-spin"
|
||||||
|
></span>
|
||||||
|
<ArrowPathIcon v-else class="h-4 w-4 mr-2" />
|
||||||
|
<span>Shrani preslikave</span>
|
||||||
|
<Badge
|
||||||
|
v-if="selectedMappingsCount"
|
||||||
|
variant="secondary"
|
||||||
|
class="ml-2 text-xs"
|
||||||
|
>{{ selectedMappingsCount }}</Badge>
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
variant="default"
|
||||||
|
class="bg-purple-600 hover:bg-purple-700"
|
||||||
|
@click.prevent="$emit('process-import')"
|
||||||
|
:disabled="!canProcess"
|
||||||
|
>
|
||||||
|
<BeakerIcon class="h-4 w-4 mr-2" />
|
||||||
|
{{ processing ? "Obdelava…" : "Obdelaj uvoz" }}
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
variant="default"
|
||||||
|
class="bg-blue-600 hover:bg-blue-700"
|
||||||
|
@click.prevent="$emit('simulate')"
|
||||||
|
:disabled="!importId || processing"
|
||||||
|
>
|
||||||
|
<ArrowDownOnSquareIcon class="h-4 w-4 mr-2" />
|
||||||
|
Simulacija vnosa
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
<!-- Other action buttons - only when not completed -->
|
|
||||||
<div class="flex flex-wrap gap-2 items-center" v-if="!isCompleted">
|
|
||||||
<Button variant="secondary" @click.prevent="$emit('preview')" :disabled="!importId">
|
|
||||||
<EyeIcon class="h-4 w-4 mr-2" />
|
|
||||||
Predogled vrstic
|
|
||||||
</Button>
|
|
||||||
<Button
|
|
||||||
variant="default"
|
|
||||||
class="bg-orange-600 hover:bg-orange-700"
|
|
||||||
@click.prevent="$emit('save-mappings')"
|
|
||||||
:disabled="!importId || processing || savingMappings || isCompleted"
|
|
||||||
title="Shrani preslikave za ta uvoz"
|
|
||||||
>
|
|
||||||
<span
|
|
||||||
v-if="savingMappings"
|
|
||||||
class="inline-block h-4 w-4 mr-2 border-2 border-white/70 border-t-transparent rounded-full animate-spin"
|
|
||||||
></span>
|
|
||||||
<ArrowPathIcon v-else class="h-4 w-4 mr-2" />
|
|
||||||
<span>Shrani preslikave</span>
|
|
||||||
<Badge v-if="selectedMappingsCount" variant="secondary" class="ml-2 text-xs">{{
|
|
||||||
selectedMappingsCount
|
|
||||||
}}</Badge>
|
|
||||||
</Button>
|
|
||||||
<Button
|
|
||||||
variant="default"
|
|
||||||
class="bg-purple-600 hover:bg-purple-700"
|
|
||||||
@click.prevent="$emit('process-import')"
|
|
||||||
:disabled="!canProcess"
|
|
||||||
>
|
|
||||||
<BeakerIcon class="h-4 w-4 mr-2" />
|
|
||||||
{{ processing ? "Obdelava…" : "Obdelaj uvoz" }}
|
|
||||||
</Button>
|
|
||||||
<Button
|
|
||||||
variant="default"
|
|
||||||
class="bg-blue-600 hover:bg-blue-700"
|
|
||||||
@click.prevent="$emit('simulate')"
|
|
||||||
:disabled="!importId || processing"
|
|
||||||
>
|
|
||||||
<ArrowDownOnSquareIcon class="h-4 w-4 mr-2" />
|
|
||||||
Simulacija vnosa
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
||||||
|
|
@ -1,24 +1,10 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import {
|
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from '@/Components/ui/table';
|
||||||
Table,
|
import { Select, SelectContent, SelectGroup, SelectItem, SelectTrigger, SelectValue } from '@/Components/ui/select';
|
||||||
TableBody,
|
import { Checkbox } from '@/Components/ui/checkbox';
|
||||||
TableCell,
|
import { Input } from '@/Components/ui/input';
|
||||||
TableHead,
|
import { Badge } from '@/Components/ui/badge';
|
||||||
TableHeader,
|
import { ScrollArea } from '@/Components/ui/scroll-area';
|
||||||
TableRow,
|
|
||||||
} from "@/Components/ui/table";
|
|
||||||
import {
|
|
||||||
Select,
|
|
||||||
SelectContent,
|
|
||||||
SelectGroup,
|
|
||||||
SelectItem,
|
|
||||||
SelectTrigger,
|
|
||||||
SelectValue,
|
|
||||||
} from "@/Components/ui/select";
|
|
||||||
import { Checkbox } from "@/Components/ui/checkbox";
|
|
||||||
import { Input } from "@/Components/ui/input";
|
|
||||||
import { Badge } from "@/Components/ui/badge";
|
|
||||||
import { ScrollArea } from "@/Components/ui/scroll-area";
|
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
rows: Array,
|
rows: Array,
|
||||||
|
|
@ -33,12 +19,12 @@ const props = defineProps({
|
||||||
mappingError: String,
|
mappingError: String,
|
||||||
show: { type: Boolean, default: true },
|
show: { type: Boolean, default: true },
|
||||||
fieldsForEntity: Function,
|
fieldsForEntity: Function,
|
||||||
});
|
})
|
||||||
const emits = defineEmits(["update:rows", "save"]);
|
const emits = defineEmits(['update:rows','save'])
|
||||||
|
|
||||||
function duplicateTarget(row) {
|
function duplicateTarget(row){
|
||||||
if (!row || !row.entity || !row.field) return false;
|
if(!row || !row.entity || !row.field) return false
|
||||||
return props.duplicateTargets?.has?.(row.entity + "." + row.field) || false;
|
return props.duplicateTargets?.has?.(row.entity + '.' + row.field) || false
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
|
|
@ -46,192 +32,137 @@ function duplicateTarget(row) {
|
||||||
<div class="flex items-center justify-between mb-2">
|
<div class="flex items-center justify-between mb-2">
|
||||||
<h3 class="font-semibold">
|
<h3 class="font-semibold">
|
||||||
Detected Columns
|
Detected Columns
|
||||||
<Badge variant="outline" class="ml-2 text-[10px]">{{
|
<Badge variant="outline" class="ml-2 text-[10px]">{{ detected?.has_header ? 'header' : 'positional' }}</Badge>
|
||||||
detected?.has_header ? "header" : "positional"
|
|
||||||
}}</Badge>
|
|
||||||
</h3>
|
</h3>
|
||||||
<div class="text-xs text-muted-foreground">
|
<div class="text-xs text-muted-foreground">
|
||||||
detected: {{ detected?.columns?.length || 0 }}, rows: {{ rows.length }},
|
detected: {{ detected?.columns?.length || 0 }}, rows: {{ rows.length }}, delimiter: {{ detected?.delimiter || 'auto' }}
|
||||||
delimiter: {{ detected?.delimiter || "auto" }}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<p v-if="detectedNote" class="text-xs text-muted-foreground mb-2">
|
<p v-if="detectedNote" class="text-xs text-muted-foreground mb-2">{{ detectedNote }}</p>
|
||||||
{{ detectedNote }}
|
|
||||||
</p>
|
|
||||||
<div class="relative border rounded-lg">
|
<div class="relative border rounded-lg">
|
||||||
<ScrollArea class="h-[420px]">
|
<ScrollArea class="h-[420px]">
|
||||||
<Table>
|
<Table>
|
||||||
<TableHeader class="sticky top-0 z-10 bg-background">
|
<TableHeader class="sticky top-0 z-10 bg-background">
|
||||||
<TableRow class="hover:bg-transparent">
|
<TableRow class="hover:bg-transparent">
|
||||||
<TableHead class="w-[180px] bg-muted/95 backdrop-blur"
|
<TableHead class="w-[180px] bg-muted/95 backdrop-blur">Source column</TableHead>
|
||||||
>Source column</TableHead
|
|
||||||
>
|
|
||||||
<TableHead class="w-[150px] bg-muted/95 backdrop-blur">Entity</TableHead>
|
<TableHead class="w-[150px] bg-muted/95 backdrop-blur">Entity</TableHead>
|
||||||
<TableHead class="w-[150px] bg-muted/95 backdrop-blur">Field</TableHead>
|
<TableHead class="w-[150px] bg-muted/95 backdrop-blur">Field</TableHead>
|
||||||
<TableHead class="w-[140px] bg-muted/95 backdrop-blur">Meta key</TableHead>
|
<TableHead class="w-[140px] bg-muted/95 backdrop-blur">Meta key</TableHead>
|
||||||
<TableHead class="w-[120px] bg-muted/95 backdrop-blur">Meta type</TableHead>
|
<TableHead class="w-[120px] bg-muted/95 backdrop-blur">Meta type</TableHead>
|
||||||
<TableHead class="w-[120px] bg-muted/95 backdrop-blur">Transform</TableHead>
|
<TableHead class="w-[120px] bg-muted/95 backdrop-blur">Transform</TableHead>
|
||||||
<TableHead class="w-[130px] bg-muted/95 backdrop-blur"
|
<TableHead class="w-[130px] bg-muted/95 backdrop-blur">Apply mode</TableHead>
|
||||||
>Apply mode</TableHead
|
<TableHead class="w-[60px] text-center bg-muted/95 backdrop-blur">Skip</TableHead>
|
||||||
>
|
|
||||||
<TableHead class="w-[60px] text-center bg-muted/95 backdrop-blur"
|
|
||||||
>Skip</TableHead
|
|
||||||
>
|
|
||||||
</TableRow>
|
</TableRow>
|
||||||
</TableHeader>
|
</TableHeader>
|
||||||
<TableBody>
|
<TableBody>
|
||||||
<TableRow
|
<TableRow v-for="(row, idx) in rows" :key="idx" :class="duplicateTarget(row) ? 'bg-destructive/10' : ''">
|
||||||
v-for="(row, idx) in rows"
|
<TableCell class="font-medium">{{ row.source_column }}</TableCell>
|
||||||
:key="idx"
|
<TableCell>
|
||||||
:class="duplicateTarget(row) ? 'bg-destructive/10' : ''"
|
<Select :model-value="row.entity || ''" @update:model-value="(val) => row.entity = val || ''" :disabled="isCompleted">
|
||||||
>
|
<SelectTrigger class="h-8 text-xs">
|
||||||
<TableCell class="font-medium">{{ row.source_column }}</TableCell>
|
<SelectValue placeholder="Select entity..." />
|
||||||
<TableCell>
|
</SelectTrigger>
|
||||||
<Select
|
<SelectContent>
|
||||||
:model-value="row.entity || ''"
|
<SelectGroup>
|
||||||
@update:model-value="(val) => (row.entity = val || '')"
|
<SelectItem v-for="opt in entityOptions" :key="opt.value" :value="opt.value">{{ opt.label }}</SelectItem>
|
||||||
:disabled="isCompleted"
|
</SelectGroup>
|
||||||
>
|
</SelectContent>
|
||||||
<SelectTrigger class="h-8 text-xs">
|
</Select>
|
||||||
<SelectValue placeholder="Select entity..." />
|
</TableCell>
|
||||||
</SelectTrigger>
|
<TableCell>
|
||||||
<SelectContent>
|
<Select
|
||||||
<SelectGroup>
|
:model-value="row.field || ''"
|
||||||
<SelectItem
|
@update:model-value="(val) => row.field = val || ''"
|
||||||
v-for="opt in entityOptions"
|
:disabled="isCompleted"
|
||||||
:key="opt.value"
|
:class="duplicateTarget(row) ? 'border-destructive' : ''"
|
||||||
:value="opt.value"
|
>
|
||||||
>{{ opt.label }}</SelectItem
|
<SelectTrigger class="h-8 text-xs" :class="duplicateTarget(row) ? 'border-destructive bg-destructive/10' : ''">
|
||||||
>
|
<SelectValue placeholder="Select field..." />
|
||||||
</SelectGroup>
|
</SelectTrigger>
|
||||||
</SelectContent>
|
<SelectContent>
|
||||||
</Select>
|
<SelectGroup>
|
||||||
</TableCell>
|
<SelectItem v-for="f in fieldsForEntity(row.entity)" :key="f" :value="f">{{ f }}</SelectItem>
|
||||||
<TableCell>
|
</SelectGroup>
|
||||||
<Select
|
</SelectContent>
|
||||||
:model-value="row.field || ''"
|
</Select>
|
||||||
@update:model-value="(val) => (row.field = val || '')"
|
</TableCell>
|
||||||
:disabled="isCompleted"
|
<TableCell>
|
||||||
:class="duplicateTarget(row) ? 'border-destructive' : ''"
|
<Input
|
||||||
>
|
v-if="row.field === 'meta'"
|
||||||
<SelectTrigger
|
v-model="(row.options ||= {}).key"
|
||||||
class="h-8 text-xs"
|
type="text"
|
||||||
:class="
|
class="h-8 text-xs"
|
||||||
duplicateTarget(row) ? 'border-destructive bg-destructive/10' : ''
|
placeholder="e.g. monthly_rent"
|
||||||
"
|
:disabled="isCompleted"
|
||||||
>
|
/>
|
||||||
<SelectValue placeholder="Select field..." />
|
<span v-else class="text-muted-foreground text-xs">—</span>
|
||||||
</SelectTrigger>
|
</TableCell>
|
||||||
<SelectContent>
|
<TableCell>
|
||||||
<SelectGroup>
|
<Select
|
||||||
<SelectItem
|
v-if="row.field === 'meta'"
|
||||||
v-for="f in fieldsForEntity(row.entity)"
|
:model-value="(row.options ||= {}).type || 'string'"
|
||||||
:key="f"
|
@update:model-value="(val) => (row.options ||= {}).type = val"
|
||||||
:value="f"
|
:disabled="isCompleted"
|
||||||
>{{ f }}</SelectItem
|
>
|
||||||
>
|
<SelectTrigger class="h-8 text-xs">
|
||||||
</SelectGroup>
|
<SelectValue />
|
||||||
</SelectContent>
|
</SelectTrigger>
|
||||||
</Select>
|
<SelectContent>
|
||||||
</TableCell>
|
<SelectGroup>
|
||||||
<TableCell>
|
<SelectItem value="string">string</SelectItem>
|
||||||
<Input
|
<SelectItem value="number">number</SelectItem>
|
||||||
v-if="row.field === 'meta'"
|
<SelectItem value="date">date</SelectItem>
|
||||||
v-model="(row.options ||= {}).key"
|
<SelectItem value="boolean">boolean</SelectItem>
|
||||||
type="text"
|
</SelectGroup>
|
||||||
class="h-8 text-xs"
|
</SelectContent>
|
||||||
placeholder="e.g. monthly_rent"
|
</Select>
|
||||||
:disabled="isCompleted"
|
<span v-else class="text-muted-foreground text-xs">—</span>
|
||||||
/>
|
</TableCell>
|
||||||
<span v-else class="text-muted-foreground text-xs">—</span>
|
<TableCell>
|
||||||
</TableCell>
|
<Select :model-value="row.transform || 'none'" @update:model-value="(val) => row.transform = val === 'none' ? '' : val" :disabled="isCompleted">
|
||||||
<TableCell>
|
<SelectTrigger class="h-8 text-xs">
|
||||||
<Select
|
<SelectValue />
|
||||||
v-if="row.field === 'meta'"
|
</SelectTrigger>
|
||||||
:model-value="(row.options ||= {}).type || 'string'"
|
<SelectContent>
|
||||||
@update:model-value="(val) => ((row.options ||= {}).type = val)"
|
<SelectGroup>
|
||||||
:disabled="isCompleted"
|
<SelectItem value="none">None</SelectItem>
|
||||||
>
|
<SelectItem value="trim">Trim</SelectItem>
|
||||||
<SelectTrigger class="h-8 text-xs">
|
<SelectItem value="upper">Uppercase</SelectItem>
|
||||||
<SelectValue />
|
<SelectItem value="lower">Lowercase</SelectItem>
|
||||||
</SelectTrigger>
|
</SelectGroup>
|
||||||
<SelectContent>
|
</SelectContent>
|
||||||
<SelectGroup>
|
</Select>
|
||||||
<SelectItem value="string">string</SelectItem>
|
</TableCell>
|
||||||
<SelectItem value="number">number</SelectItem>
|
<TableCell>
|
||||||
<SelectItem value="date">date</SelectItem>
|
<Select :model-value="row.apply_mode || 'both'" @update:model-value="(val) => row.apply_mode = val" :disabled="isCompleted">
|
||||||
<SelectItem value="boolean">boolean</SelectItem>
|
<SelectTrigger class="h-8 text-xs">
|
||||||
</SelectGroup>
|
<SelectValue />
|
||||||
</SelectContent>
|
</SelectTrigger>
|
||||||
</Select>
|
<SelectContent>
|
||||||
<span v-else class="text-muted-foreground text-xs">—</span>
|
<SelectGroup>
|
||||||
</TableCell>
|
<SelectItem value="keyref">Keyref</SelectItem>
|
||||||
<TableCell>
|
<SelectItem value="both">Both</SelectItem>
|
||||||
<Select
|
<SelectItem value="insert">Insert only</SelectItem>
|
||||||
:model-value="row.transform || 'none'"
|
<SelectItem value="update">Update only</SelectItem>
|
||||||
@update:model-value="
|
</SelectGroup>
|
||||||
(val) => (row.transform = val === 'none' ? '' : val)
|
</SelectContent>
|
||||||
"
|
</Select>
|
||||||
:disabled="isCompleted"
|
</TableCell>
|
||||||
>
|
<TableCell class="text-center">
|
||||||
<SelectTrigger class="h-8 text-xs">
|
<Checkbox :checked="row.skip" @update:checked="(val) => row.skip = val" :disabled="isCompleted" />
|
||||||
<SelectValue />
|
</TableCell>
|
||||||
</SelectTrigger>
|
</TableRow>
|
||||||
<SelectContent>
|
</TableBody>
|
||||||
<SelectGroup>
|
</Table>
|
||||||
<SelectItem value="none">None</SelectItem>
|
|
||||||
<SelectItem value="trim">Trim</SelectItem>
|
|
||||||
<SelectItem value="upper">Uppercase</SelectItem>
|
|
||||||
<SelectItem value="lower">Lowercase</SelectItem>
|
|
||||||
</SelectGroup>
|
|
||||||
</SelectContent>
|
|
||||||
</Select>
|
|
||||||
</TableCell>
|
|
||||||
<TableCell>
|
|
||||||
<Select
|
|
||||||
:model-value="row.apply_mode || 'both'"
|
|
||||||
@update:model-value="(val) => (row.apply_mode = val)"
|
|
||||||
:disabled="isCompleted"
|
|
||||||
>
|
|
||||||
<SelectTrigger class="h-8 text-xs">
|
|
||||||
<SelectValue />
|
|
||||||
</SelectTrigger>
|
|
||||||
<SelectContent>
|
|
||||||
<SelectGroup>
|
|
||||||
<SelectItem value="keyref">Keyref</SelectItem>
|
|
||||||
<SelectItem value="both">Both</SelectItem>
|
|
||||||
<SelectItem value="insert">Insert only</SelectItem>
|
|
||||||
<SelectItem value="update">Update only</SelectItem>
|
|
||||||
</SelectGroup>
|
|
||||||
</SelectContent>
|
|
||||||
</Select>
|
|
||||||
</TableCell>
|
|
||||||
<TableCell class="text-center">
|
|
||||||
<Checkbox
|
|
||||||
:model-value="row.skip"
|
|
||||||
@update:model-value="(val) => (row.skip = val)"
|
|
||||||
:disabled="isCompleted"
|
|
||||||
/>
|
|
||||||
</TableCell>
|
|
||||||
</TableRow>
|
|
||||||
</TableBody>
|
|
||||||
</Table>
|
|
||||||
</ScrollArea>
|
</ScrollArea>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div v-if="mappingSaved" class="text-sm text-emerald-700 mt-2 flex items-center gap-2">
|
||||||
v-if="mappingSaved"
|
|
||||||
class="text-sm text-emerald-700 mt-2 flex items-center gap-2"
|
|
||||||
>
|
|
||||||
<Badge variant="default" class="bg-emerald-600">Saved</Badge>
|
<Badge variant="default" class="bg-emerald-600">Saved</Badge>
|
||||||
<span>{{ mappingSavedCount }} mappings saved</span>
|
<span>{{ mappingSavedCount }} mappings saved</span>
|
||||||
</div>
|
</div>
|
||||||
<div v-else-if="mappingError" class="text-sm text-destructive mt-2">
|
<div v-else-if="mappingError" class="text-sm text-destructive mt-2">{{ mappingError }}</div>
|
||||||
{{ mappingError }}
|
|
||||||
</div>
|
|
||||||
<div v-if="missingCritical?.length" class="mt-2">
|
<div v-if="missingCritical?.length" class="mt-2">
|
||||||
<Badge variant="destructive" class="text-xs"
|
<Badge variant="destructive" class="text-xs">Missing critical: {{ missingCritical.join(', ') }}</Badge>
|
||||||
>Missing critical: {{ missingCritical.join(", ") }}</Badge
|
|
||||||
>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
||||||
|
|
@ -1,21 +1,13 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, watch } from "vue";
|
import { ref } from "vue";
|
||||||
import AppLayout from "@/Layouts/AppLayout.vue";
|
import AppLayout from "@/Layouts/AppLayout.vue";
|
||||||
import DataTableClient from "@/Components/DataTable/DataTableClient.vue";
|
import DataTableClient from "@/Components/DataTable/DataTableClient.vue";
|
||||||
import DataTableExample from "../Examples/DataTableExample.vue";
|
import DataTableExample from "../Examples/DataTableExample.vue";
|
||||||
import { useForm } from "@inertiajs/vue3";
|
|
||||||
import Checkbox from "@/Components/ui/checkbox/Checkbox.vue";
|
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
example: { type: String, default: "Demo" },
|
example: { type: String, default: "Demo" },
|
||||||
});
|
});
|
||||||
|
|
||||||
const checkboxValue = ref(false);
|
|
||||||
|
|
||||||
const testForm = useForm({
|
|
||||||
allowed: false,
|
|
||||||
});
|
|
||||||
|
|
||||||
// Dummy columns
|
// Dummy columns
|
||||||
const columns = [
|
const columns = [
|
||||||
{ key: "id", label: "ID", sortable: true, class: "w-16" },
|
{ key: "id", label: "ID", sortable: true, class: "w-16" },
|
||||||
|
|
@ -61,17 +53,10 @@ function onRowClick(row) {
|
||||||
// no-op demo; could show toast or details
|
// no-op demo; could show toast or details
|
||||||
console.debug("Row clicked:", row);
|
console.debug("Row clicked:", row);
|
||||||
}
|
}
|
||||||
|
|
||||||
watch(
|
|
||||||
() => testForm.allowed,
|
|
||||||
(newVal) => {
|
|
||||||
console.log(newVal);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<AppLayout>
|
|
||||||
<Checkbox v-model:checked="testForm.allowed" />
|
<DataTableExample></DataTableExample>
|
||||||
</AppLayout>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
|
||||||
|
|
@ -463,7 +463,6 @@
|
||||||
Route::get('imports/{import}/missing-keyref-rows', [ImportController::class, 'missingKeyrefRows'])->name('imports.missing-keyref-rows');
|
Route::get('imports/{import}/missing-keyref-rows', [ImportController::class, 'missingKeyrefRows'])->name('imports.missing-keyref-rows');
|
||||||
Route::get('imports/{import}/missing-keyref-csv', [ImportController::class, 'exportMissingKeyrefCsv'])->name('imports.missing-keyref-csv');
|
Route::get('imports/{import}/missing-keyref-csv', [ImportController::class, 'exportMissingKeyrefCsv'])->name('imports.missing-keyref-csv');
|
||||||
Route::get('imports/{import}/preview', [ImportController::class, 'preview'])->name('imports.preview');
|
Route::get('imports/{import}/preview', [ImportController::class, 'preview'])->name('imports.preview');
|
||||||
Route::get('imports/{import}/download', [ImportController::class, 'download'])->name('imports.download');
|
|
||||||
Route::get('imports/{import}/missing-contracts', [ImportController::class, 'missingContracts'])->name('imports.missing-contracts');
|
Route::get('imports/{import}/missing-contracts', [ImportController::class, 'missingContracts'])->name('imports.missing-contracts');
|
||||||
Route::post('imports/{import}/options', [ImportController::class, 'updateOptions'])->name('imports.options');
|
Route::post('imports/{import}/options', [ImportController::class, 'updateOptions'])->name('imports.options');
|
||||||
// Generic simulation endpoint (new) – provides projected effects for first N rows regardless of payments template
|
// Generic simulation endpoint (new) – provides projected effects for first N rows regardless of payments template
|
||||||
|
|
|
||||||
|
|
@ -1,72 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
use App\Models\Import;
|
|
||||||
use App\Models\User;
|
|
||||||
use Illuminate\Support\Facades\Auth;
|
|
||||||
use Illuminate\Support\Facades\Storage;
|
|
||||||
use Illuminate\Support\Str;
|
|
||||||
|
|
||||||
it('downloads the original import file', function () {
|
|
||||||
// Create a test file
|
|
||||||
$uuid = (string) Str::uuid();
|
|
||||||
$disk = 'local';
|
|
||||||
$path = "imports/{$uuid}.csv";
|
|
||||||
$csv = "email,reference\nalpha@example.com,REF-1\n";
|
|
||||||
Storage::disk($disk)->put($path, $csv);
|
|
||||||
|
|
||||||
// Authenticate a user
|
|
||||||
$user = User::factory()->create();
|
|
||||||
Auth::login($user);
|
|
||||||
|
|
||||||
// Create import record
|
|
||||||
$import = Import::create([
|
|
||||||
'uuid' => $uuid,
|
|
||||||
'user_id' => $user->id,
|
|
||||||
'import_template_id' => null,
|
|
||||||
'client_id' => null,
|
|
||||||
'source_type' => 'csv',
|
|
||||||
'file_name' => basename($path),
|
|
||||||
'original_name' => 'test-import.csv',
|
|
||||||
'disk' => $disk,
|
|
||||||
'path' => $path,
|
|
||||||
'size' => strlen($csv),
|
|
||||||
'status' => 'uploaded',
|
|
||||||
'meta' => ['has_header' => true],
|
|
||||||
]);
|
|
||||||
|
|
||||||
// Test download endpoint
|
|
||||||
$response = test()->get(route('imports.download', ['import' => $import->id]));
|
|
||||||
|
|
||||||
$response->assertSuccessful();
|
|
||||||
expect($response->headers->get('Content-Disposition'))->toContain('test-import.csv');
|
|
||||||
|
|
||||||
// Clean up
|
|
||||||
Storage::disk($disk)->delete($path);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('returns 404 when file does not exist', function () {
|
|
||||||
// Authenticate a user
|
|
||||||
$user = User::factory()->create();
|
|
||||||
Auth::login($user);
|
|
||||||
|
|
||||||
// Create import record with non-existent file
|
|
||||||
$import = Import::create([
|
|
||||||
'uuid' => (string) Str::uuid(),
|
|
||||||
'user_id' => $user->id,
|
|
||||||
'import_template_id' => null,
|
|
||||||
'client_id' => null,
|
|
||||||
'source_type' => 'csv',
|
|
||||||
'file_name' => 'missing.csv',
|
|
||||||
'original_name' => 'missing.csv',
|
|
||||||
'disk' => 'local',
|
|
||||||
'path' => 'imports/nonexistent.csv',
|
|
||||||
'size' => 0,
|
|
||||||
'status' => 'uploaded',
|
|
||||||
'meta' => ['has_header' => true],
|
|
||||||
]);
|
|
||||||
|
|
||||||
// Test download endpoint
|
|
||||||
$response = test()->get(route('imports.download', ['import' => $import->id]));
|
|
||||||
|
|
||||||
$response->assertNotFound();
|
|
||||||
});
|
|
||||||
Loading…
Reference in New Issue
Block a user