Compare commits
4 Commits
9779112066
...
v1.3.8
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
000a77ccf4 | ||
|
|
ecd9f6a181 | ||
|
|
68e6d80903 | ||
|
|
af1b41994c |
28
package-lock.json
generated
28
package-lock.json
generated
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "app-ts",
|
"name": "app-ts",
|
||||||
"version": "1.3.6",
|
"version": "1.3.8",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "app-ts",
|
"name": "app-ts",
|
||||||
"version": "1.3.6",
|
"version": "1.3.8",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@dnd-kit/core": "^6.3.1",
|
"@dnd-kit/core": "^6.3.1",
|
||||||
@@ -2089,9 +2089,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/brace-expansion": {
|
"node_modules/brace-expansion": {
|
||||||
"version": "5.0.4",
|
"version": "5.0.5",
|
||||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.4.tgz",
|
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.5.tgz",
|
||||||
"integrity": "sha512-h+DEnpVvxmfVefa4jFbCf5HdH5YMDXRsmKflpf1pILZWRFlTbJpxeU55nJl4Smt5HQaGzg1o6RHFPJaOqnmBDg==",
|
"integrity": "sha512-VZznLgtwhn+Mact9tfiwx64fA9erHH/MCXEUfB/0bX/6Fz6ny5EGTXYltMocqg4xFAQZtnO3DHWWXi8RiuN7cQ==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"balanced-match": "^4.0.2"
|
"balanced-match": "^4.0.2"
|
||||||
@@ -3086,9 +3086,9 @@
|
|||||||
"license": "BSD-3-Clause"
|
"license": "BSD-3-Clause"
|
||||||
},
|
},
|
||||||
"node_modules/fastify": {
|
"node_modules/fastify": {
|
||||||
"version": "5.8.2",
|
"version": "5.8.4",
|
||||||
"resolved": "https://registry.npmjs.org/fastify/-/fastify-5.8.2.tgz",
|
"resolved": "https://registry.npmjs.org/fastify/-/fastify-5.8.4.tgz",
|
||||||
"integrity": "sha512-lZmt3navvZG915IE+f7/TIVamxIwmBd+OMB+O9WBzcpIwOo6F0LTh0sluoMFk5VkrKTvvrwIaoJPkir4Z+jtAg==",
|
"integrity": "sha512-sa42J1xylbBAYUWALSBoyXKPDUvM3OoNOibIefA+Oha57FryXKKCZarA1iDntOCWp3O35voZLuDg2mdODXtPzQ==",
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
"type": "github",
|
"type": "github",
|
||||||
@@ -4282,9 +4282,9 @@
|
|||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/nodemailer": {
|
"node_modules/nodemailer": {
|
||||||
"version": "8.0.2",
|
"version": "8.0.4",
|
||||||
"resolved": "https://registry.npmjs.org/nodemailer/-/nodemailer-8.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/nodemailer/-/nodemailer-8.0.4.tgz",
|
||||||
"integrity": "sha512-zbj002pZAIkWQFxyAaqoxvn+zoIwRnS40hgjqTXudKOOJkiFFgBeNqjgD3/YCR12sZnrghWYBY+yP1ZucdDRpw==",
|
"integrity": "sha512-k+jf6N8PfQJ0Fe8ZhJlgqU5qJU44Lpvp2yvidH3vp1lPnVQMgi4yEEMPXg5eJS1gFIJTVq1NHBk7Ia9ARdSBdQ==",
|
||||||
"license": "MIT-0",
|
"license": "MIT-0",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=6.0.0"
|
"node": ">=6.0.0"
|
||||||
@@ -4540,9 +4540,9 @@
|
|||||||
"license": "ISC"
|
"license": "ISC"
|
||||||
},
|
},
|
||||||
"node_modules/picomatch": {
|
"node_modules/picomatch": {
|
||||||
"version": "4.0.3",
|
"version": "4.0.4",
|
||||||
"resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.3.tgz",
|
"resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.4.tgz",
|
||||||
"integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==",
|
"integrity": "sha512-QP88BAKvMam/3NxH6vj2o21R6MjxZUAd6nlwAS/pnGvN9IVLocLHxGYIzFhg6fUQ+5th6P4dv4eW9jX3DSIj7A==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"engines": {
|
"engines": {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "app-ts",
|
"name": "app-ts",
|
||||||
"version": "1.3.6",
|
"version": "1.3.8",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "dist/server.js",
|
"main": "dist/server.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -561,7 +561,9 @@ export default function useAttendanceAdmin({ alert }: AlertContext) {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const loadUsers = async () => {
|
const loadUsers = async () => {
|
||||||
try {
|
try {
|
||||||
const response = await apiFetch(`${API_BASE}/users?limit=1000`);
|
const response = await apiFetch(
|
||||||
|
`${API_BASE}/attendance?action=attendance_users`,
|
||||||
|
);
|
||||||
const result = await response.json();
|
const result = await response.json();
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
const apiUsers: ApiUser[] = result.data;
|
const apiUsers: ApiUser[] = result.data;
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { FastifyInstance } from "fastify";
|
import { FastifyInstance } from "fastify";
|
||||||
|
import prisma from "../../config/database";
|
||||||
import { requireAuth, requirePermission } from "../../middleware/auth";
|
import { requireAuth, requirePermission } from "../../middleware/auth";
|
||||||
import { logAudit } from "../../services/audit";
|
import { logAudit } from "../../services/audit";
|
||||||
import { success, error, parseId } from "../../utils/response";
|
import { success, error, parseId } from "../../utils/response";
|
||||||
@@ -132,6 +133,38 @@ export default async function attendanceRoutes(
|
|||||||
return reply.send({ success: true, data });
|
return reply.send({ success: true, data });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// --- action=attendance_users: users with attendance.record permission ---
|
||||||
|
if (action === "attendance_users") {
|
||||||
|
const users = await prisma.users.findMany({
|
||||||
|
where: {
|
||||||
|
is_active: true,
|
||||||
|
roles: {
|
||||||
|
is: {
|
||||||
|
OR: [
|
||||||
|
{ name: "admin" },
|
||||||
|
{
|
||||||
|
role_permissions: {
|
||||||
|
some: { permissions: { name: "attendance.record" } },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
select: { id: true, first_name: true, last_name: true, username: true },
|
||||||
|
orderBy: { last_name: "asc" },
|
||||||
|
});
|
||||||
|
return reply.send({
|
||||||
|
success: true,
|
||||||
|
data: users.map((u) => ({
|
||||||
|
id: u.id,
|
||||||
|
first_name: u.first_name,
|
||||||
|
last_name: u.last_name,
|
||||||
|
username: u.username,
|
||||||
|
})),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// --- action=projects: active projects for attendance project switching ---
|
// --- action=projects: active projects for attendance project switching ---
|
||||||
if (action === "projects") {
|
if (action === "projects") {
|
||||||
const data = await attendanceService.getActiveProjects();
|
const data = await attendanceService.getActiveProjects();
|
||||||
|
|||||||
@@ -16,7 +16,10 @@ export const CreateUserSchema = z.object({
|
|||||||
export const UpdateUserSchema = z.object({
|
export const UpdateUserSchema = z.object({
|
||||||
username: z.string().optional(),
|
username: z.string().optional(),
|
||||||
email: z.string().email("Neplatný formát e-mailu").optional(),
|
email: z.string().email("Neplatný formát e-mailu").optional(),
|
||||||
password: z.string().min(8, "Heslo musí mít alespoň 8 znaků").optional(),
|
password: z.preprocess(
|
||||||
|
(v) => (v === "" ? undefined : v),
|
||||||
|
z.string().min(8, "Heslo musí mít alespoň 8 znaků").optional(),
|
||||||
|
),
|
||||||
first_name: z.string().optional(),
|
first_name: z.string().optional(),
|
||||||
last_name: z.string().optional(),
|
last_name: z.string().optional(),
|
||||||
role_id: z.union([z.number(), z.string(), z.null()]).optional(),
|
role_id: z.union([z.number(), z.string(), z.null()]).optional(),
|
||||||
|
|||||||
@@ -4,6 +4,29 @@ import { getBusinessDaysInMonth } from "../utils/czech-holidays";
|
|||||||
import { localDateStr } from "../utils/date";
|
import { localDateStr } from "../utils/date";
|
||||||
import { getSystemSettings } from "./system-settings";
|
import { getSystemSettings } from "./system-settings";
|
||||||
|
|
||||||
|
/** Get active users whose role has attendance.record permission (or admin role) */
|
||||||
|
async function getAttendanceUsers() {
|
||||||
|
return prisma.users.findMany({
|
||||||
|
where: {
|
||||||
|
is_active: true,
|
||||||
|
roles: {
|
||||||
|
is: {
|
||||||
|
OR: [
|
||||||
|
{ name: "admin" },
|
||||||
|
{
|
||||||
|
role_permissions: {
|
||||||
|
some: { permissions: { name: "attendance.record" } },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
select: { id: true, first_name: true, last_name: true },
|
||||||
|
orderBy: { last_name: "asc" },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
type AttendanceWithRelations = Prisma.attendanceGetPayload<{
|
type AttendanceWithRelations = Prisma.attendanceGetPayload<{
|
||||||
include: {
|
include: {
|
||||||
users: { select: { id: true; first_name: true; last_name: true } };
|
users: { select: { id: true; first_name: true; last_name: true } };
|
||||||
@@ -421,11 +444,7 @@ export async function switchProject(userId: number, projectId: number | null) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function getBalances(year: number) {
|
export async function getBalances(year: number) {
|
||||||
const users = await prisma.users.findMany({
|
const users = await getAttendanceUsers();
|
||||||
where: { is_active: true },
|
|
||||||
select: { id: true, first_name: true, last_name: true },
|
|
||||||
orderBy: { last_name: "asc" },
|
|
||||||
});
|
|
||||||
|
|
||||||
const balances: Record<
|
const balances: Record<
|
||||||
string,
|
string,
|
||||||
@@ -463,11 +482,7 @@ export async function getBalances(year: number) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function getWorkfund(year: number) {
|
export async function getWorkfund(year: number) {
|
||||||
const users = await prisma.users.findMany({
|
const users = await getAttendanceUsers();
|
||||||
where: { is_active: true },
|
|
||||||
select: { id: true, first_name: true, last_name: true },
|
|
||||||
orderBy: { last_name: "asc" },
|
|
||||||
});
|
|
||||||
|
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
const currentYear = now.getFullYear();
|
const currentYear = now.getFullYear();
|
||||||
@@ -734,11 +749,7 @@ export async function getPrintData(
|
|||||||
const monthStart = new Date(yr, mo - 1, 1);
|
const monthStart = new Date(yr, mo - 1, 1);
|
||||||
const monthEnd = new Date(yr, mo, 0, 23, 59, 59);
|
const monthEnd = new Date(yr, mo, 0, 23, 59, 59);
|
||||||
|
|
||||||
const users = await prisma.users.findMany({
|
const users = await getAttendanceUsers();
|
||||||
where: { is_active: true },
|
|
||||||
select: { id: true, first_name: true, last_name: true },
|
|
||||||
orderBy: { last_name: "asc" },
|
|
||||||
});
|
|
||||||
|
|
||||||
const where: Record<string, unknown> = {
|
const where: Record<string, unknown> = {
|
||||||
shift_date: { gte: monthStart, lte: monthEnd },
|
shift_date: { gte: monthStart, lte: monthEnd },
|
||||||
|
|||||||
Reference in New Issue
Block a user