Fixed dates
This commit is contained in:
parent
821985469e
commit
7881508a7b
|
|
@ -80,14 +80,14 @@ public function __invoke(SmsService $sms): Response
|
||||||
->map(fn ($i) => now()->subDays(6 - $i)->format('Y-m-d'));
|
->map(fn ($i) => now()->subDays(6 - $i)->format('Y-m-d'));
|
||||||
|
|
||||||
$fieldJobTrendRaw = FieldJob::whereBetween(DB::raw('COALESCE(assigned_at, created_at)'), [$start, $end])
|
$fieldJobTrendRaw = FieldJob::whereBetween(DB::raw('COALESCE(assigned_at, created_at)'), [$start, $end])
|
||||||
->selectRaw('DATE(COALESCE(assigned_at, created_at)) as d, COUNT(*) as c')
|
->selectRaw("DATE(COALESCE(assigned_at, created_at) AT TIME ZONE 'Europe/Ljubljana') as d, COUNT(*) as c")
|
||||||
->groupBy('d')
|
->groupBy('d')
|
||||||
->pluck('c', 'd');
|
->pluck('c', 'd');
|
||||||
|
|
||||||
// Completed field jobs last 7 days
|
// Completed field jobs last 7 days
|
||||||
$fieldJobCompletedRaw = FieldJob::whereNotNull('completed_at')
|
$fieldJobCompletedRaw = FieldJob::whereNotNull('completed_at')
|
||||||
->whereBetween('completed_at', [$start, $end])
|
->whereBetween('completed_at', [$start, $end])
|
||||||
->selectRaw('DATE(completed_at) as d, COUNT(*) as c')
|
->selectRaw("DATE(completed_at AT TIME ZONE 'Europe/Ljubljana') as d, COUNT(*) as c")
|
||||||
->groupBy('d')
|
->groupBy('d')
|
||||||
->pluck('c', 'd');
|
->pluck('c', 'd');
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
DB::statement('ALTER TABLE field_jobs ALTER COLUMN assigned_at TYPE timestamp USING assigned_at::timestamp');
|
||||||
|
DB::statement('ALTER TABLE field_jobs ALTER COLUMN completed_at TYPE timestamp USING completed_at::timestamp');
|
||||||
|
DB::statement('ALTER TABLE field_jobs ALTER COLUMN cancelled_at TYPE timestamp USING cancelled_at::timestamp');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
DB::statement('ALTER TABLE field_jobs ALTER COLUMN assigned_at TYPE date USING assigned_at::date');
|
||||||
|
DB::statement('ALTER TABLE field_jobs ALTER COLUMN completed_at TYPE date USING completed_at::date');
|
||||||
|
DB::statement('ALTER TABLE field_jobs ALTER COLUMN cancelled_at TYPE date USING cancelled_at::date');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
@ -32,7 +32,7 @@ const chartData = computed(() => {
|
||||||
}
|
}
|
||||||
|
|
||||||
return props.trends.labels.map((label, i) => ({
|
return props.trends.labels.map((label, i) => ({
|
||||||
date: new Date(label),
|
date: new Date(label + "T00:00:00"),
|
||||||
dateLabel: label,
|
dateLabel: label,
|
||||||
completed: props.trends.field_jobs_completed[i] || 0,
|
completed: props.trends.field_jobs_completed[i] || 0,
|
||||||
assigned: props.trends.field_jobs[i] || 0,
|
assigned: props.trends.field_jobs[i] || 0,
|
||||||
|
|
@ -140,7 +140,7 @@ const crosshairLabelFormatter = (value) => {
|
||||||
type="x"
|
type="x"
|
||||||
:tick-line="false"
|
:tick-line="false"
|
||||||
:grid-line="false"
|
:grid-line="false"
|
||||||
:num-ticks="7"
|
:tick-values="chartData.map((d) => d.date)"
|
||||||
:tick-format="
|
:tick-format="
|
||||||
(d) => {
|
(d) => {
|
||||||
const date = new Date(d);
|
const date = new Date(d);
|
||||||
|
|
|
||||||
|
|
@ -263,10 +263,14 @@ function formatDate(value) {
|
||||||
if (isNaN(d)) {
|
if (isNaN(d)) {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
const dd = String(d.getDate()).padStart(2, "0");
|
const parts = new Intl.DateTimeFormat("en-GB", {
|
||||||
const mm = String(d.getMonth() + 1).padStart(2, "0");
|
timeZone: "Europe/Ljubljana",
|
||||||
const yyyy = d.getFullYear();
|
day: "2-digit",
|
||||||
return `${dd}.${mm}.${yyyy}`;
|
month: "2-digit",
|
||||||
|
year: "numeric",
|
||||||
|
}).formatToParts(d);
|
||||||
|
const map = Object.fromEntries(parts.map((p) => [p.type, p.value]));
|
||||||
|
return `${map.day}.${map.month}.${map.year}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
function formatCurrencyEUR(value) {
|
function formatCurrencyEUR(value) {
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@ import {
|
||||||
Phone,
|
Phone,
|
||||||
Wallet,
|
Wallet,
|
||||||
} from "lucide-vue-next";
|
} from "lucide-vue-next";
|
||||||
|
import { fmtDateDMY } from "@/Utilities/functions";
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
jobs: { type: Object, required: true },
|
jobs: { type: Object, required: true },
|
||||||
|
|
@ -89,17 +90,16 @@ function clearSearch() {
|
||||||
|
|
||||||
function formatDateDMY(d) {
|
function formatDateDMY(d) {
|
||||||
if (!d) return "-";
|
if (!d) return "-";
|
||||||
if (/^\d{4}-\d{2}-\d{2}/.test(d)) {
|
|
||||||
const [y, m, rest] = d.split("-");
|
|
||||||
const day = (rest || "").slice(0, 2) || "01";
|
|
||||||
return `${day}.${m}.${y}`;
|
|
||||||
}
|
|
||||||
const dt = new Date(d);
|
const dt = new Date(d);
|
||||||
if (Number.isNaN(dt.getTime())) return String(d);
|
if (Number.isNaN(dt.getTime())) return String(d);
|
||||||
const dd = String(dt.getDate()).padStart(2, "0");
|
const parts = new Intl.DateTimeFormat("en-GB", {
|
||||||
const mm = String(dt.getMonth() + 1).padStart(2, "0");
|
timeZone: "Europe/Ljubljana",
|
||||||
const yyyy = dt.getFullYear();
|
day: "2-digit",
|
||||||
return `${dd}.${mm}.${yyyy}`;
|
month: "2-digit",
|
||||||
|
year: "numeric",
|
||||||
|
}).formatToParts(dt);
|
||||||
|
const map = Object.fromEntries(parts.map((p) => [p.type, p.value]));
|
||||||
|
return `${map.day}.${map.month}.${map.year}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
function formatAmount(val) {
|
function formatAmount(val) {
|
||||||
|
|
@ -412,7 +412,7 @@ function changePage(url) {
|
||||||
Dodeljeno
|
Dodeljeno
|
||||||
</p>
|
</p>
|
||||||
<p class="font-semibold text-gray-900 dark:text-gray-100">
|
<p class="font-semibold text-gray-900 dark:text-gray-100">
|
||||||
{{ formatDateDMY(job.assigned_at) }}
|
{{ fmtDateDMY(job.assigned_at) }}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -430,7 +430,7 @@ function changePage(url) {
|
||||||
Zadnja aktivnost
|
Zadnja aktivnost
|
||||||
</p>
|
</p>
|
||||||
<p class="font-semibold text-green-700 dark:text-green-400">
|
<p class="font-semibold text-green-700 dark:text-green-400">
|
||||||
{{ formatDateDMY(job.last_activity) || "—" }}
|
{{ fmtDateDMY(job.last_activity) || "—" }}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -33,8 +33,12 @@ export function fmtDateDMY(value) {
|
||||||
if (!value) return "-";
|
if (!value) return "-";
|
||||||
const d = new Date(value);
|
const d = new Date(value);
|
||||||
if (isNaN(d)) return "-";
|
if (isNaN(d)) return "-";
|
||||||
const dd = String(d.getDate()).padStart(2, "0");
|
const parts = new Intl.DateTimeFormat("en-GB", {
|
||||||
const mm = String(d.getMonth() + 1).padStart(2, "0");
|
timeZone: "Europe/Ljubljana",
|
||||||
const yyyy = d.getFullYear();
|
day: "2-digit",
|
||||||
return `${dd}.${mm}.${yyyy}`;
|
month: "2-digit",
|
||||||
|
year: "numeric",
|
||||||
|
}).formatToParts(d);
|
||||||
|
const map = Object.fromEntries(parts.map((p) => [p.type, p.value]));
|
||||||
|
return `${map.day}.${map.month}.${map.year}`;
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue
Block a user