@7365admin1/core 2.21.0 → 2.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/index.d.ts +336 -11
- package/dist/index.js +2182 -147
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2185 -153
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -38,6 +38,7 @@ __export(src_exports, {
|
|
|
38
38
|
BulletinStatus: () => BulletinStatus,
|
|
39
39
|
CameraType: () => CameraType,
|
|
40
40
|
DEVICE_STATUS: () => DEVICE_STATUS,
|
|
41
|
+
DayOfWeek: () => DayOfWeek,
|
|
41
42
|
EAccessCardTypes: () => EAccessCardTypes,
|
|
42
43
|
EAccessCardUserTypes: () => EAccessCardUserTypes,
|
|
43
44
|
FacilitySort: () => FacilitySort,
|
|
@@ -67,6 +68,7 @@ __export(src_exports, {
|
|
|
67
68
|
MIncidentReport: () => MIncidentReport,
|
|
68
69
|
MManpowerDesignations: () => MManpowerDesignations,
|
|
69
70
|
MManpowerMonitoring: () => MManpowerMonitoring,
|
|
71
|
+
MManpowerRemarks: () => MManpowerRemarks,
|
|
70
72
|
MMember: () => MMember,
|
|
71
73
|
MNfcPatrolLog: () => MNfcPatrolLog,
|
|
72
74
|
MNfcPatrolRoute: () => MNfcPatrolRoute,
|
|
@@ -79,6 +81,7 @@ __export(src_exports, {
|
|
|
79
81
|
MOnlineForm: () => MOnlineForm,
|
|
80
82
|
MOrg: () => MOrg,
|
|
81
83
|
MOvernightParkingApprovalHours: () => MOvernightParkingApprovalHours,
|
|
84
|
+
MOvernightParkingRequest: () => MOvernightParkingRequest,
|
|
82
85
|
MPatrolLog: () => MPatrolLog,
|
|
83
86
|
MPatrolQuestion: () => MPatrolQuestion,
|
|
84
87
|
MPatrolRoute: () => MPatrolRoute,
|
|
@@ -103,6 +106,8 @@ __export(src_exports, {
|
|
|
103
106
|
MVisitorTransaction: () => MVisitorTransaction,
|
|
104
107
|
MWorkOrder: () => MWorkOrder,
|
|
105
108
|
OrgNature: () => OrgNature,
|
|
109
|
+
OvernightParkingRequestSort: () => OvernightParkingRequestSort,
|
|
110
|
+
OvernightParkingRequestStatus: () => OvernightParkingRequestStatus,
|
|
106
111
|
PERSON_TYPES: () => PERSON_TYPES,
|
|
107
112
|
PMDashboardCollection: () => PMDashboardCollection,
|
|
108
113
|
Period: () => Period,
|
|
@@ -111,6 +116,7 @@ __export(src_exports, {
|
|
|
111
116
|
SiteStatus: () => SiteStatus,
|
|
112
117
|
SortFields: () => SortFields,
|
|
113
118
|
SortOrder: () => SortOrder,
|
|
119
|
+
SubscriptionType: () => SubscriptionType,
|
|
114
120
|
UseAccessManagementRepo: () => UseAccessManagementRepo,
|
|
115
121
|
VehicleCategory: () => VehicleCategory,
|
|
116
122
|
VehicleOrder: () => VehicleOrder,
|
|
@@ -119,6 +125,7 @@ __export(src_exports, {
|
|
|
119
125
|
VehicleType: () => VehicleType,
|
|
120
126
|
VisitorSort: () => VisitorSort,
|
|
121
127
|
VisitorStatus: () => VisitorStatus,
|
|
128
|
+
addressSchema: () => addressSchema,
|
|
122
129
|
allowedFieldsSite: () => allowedFieldsSite,
|
|
123
130
|
allowedNatures: () => allowedNatures,
|
|
124
131
|
attendanceSchema: () => attendanceSchema,
|
|
@@ -142,12 +149,15 @@ __export(src_exports, {
|
|
|
142
149
|
mAndEDashboardCollection: () => mAndEDashboardCollection,
|
|
143
150
|
manpowerDesignationsSchema: () => manpowerDesignationsSchema,
|
|
144
151
|
manpowerMonitoringSchema: () => manpowerMonitoringSchema,
|
|
152
|
+
manpowerRemarksSchema: () => manpowerRemarksSchema,
|
|
145
153
|
nfcPatrolSettingsSchema: () => nfcPatrolSettingsSchema,
|
|
146
154
|
nfcPatrolSettingsSchemaUpdate: () => nfcPatrolSettingsSchemaUpdate,
|
|
147
155
|
orgSchema: () => orgSchema,
|
|
156
|
+
overnight_parking_requests_namespace_collection: () => overnight_parking_requests_namespace_collection,
|
|
148
157
|
pestDashboardCollection: () => pestDashboardCollection,
|
|
149
158
|
poolDashboardCollection: () => poolDashboardCollection,
|
|
150
159
|
promoCodeSchema: () => promoCodeSchema,
|
|
160
|
+
remarksSchema: () => remarksSchema,
|
|
151
161
|
robotSchema: () => robotSchema,
|
|
152
162
|
schema: () => schema,
|
|
153
163
|
schemaBilling: () => schemaBilling,
|
|
@@ -174,6 +184,7 @@ __export(src_exports, {
|
|
|
174
184
|
schemaOccurrenceSubject: () => schemaOccurrenceSubject,
|
|
175
185
|
schemaOnlineForm: () => schemaOnlineForm,
|
|
176
186
|
schemaOvernightParkingApprovalHours: () => schemaOvernightParkingApprovalHours,
|
|
187
|
+
schemaOvernightParkingRequest: () => schemaOvernightParkingRequest,
|
|
177
188
|
schemaPatrolLog: () => schemaPatrolLog,
|
|
178
189
|
schemaPatrolQuestion: () => schemaPatrolQuestion,
|
|
179
190
|
schemaPatrolRoute: () => schemaPatrolRoute,
|
|
@@ -198,6 +209,7 @@ __export(src_exports, {
|
|
|
198
209
|
schemaUpdateOccurrenceSubject: () => schemaUpdateOccurrenceSubject,
|
|
199
210
|
schemaUpdateOnlineForm: () => schemaUpdateOnlineForm,
|
|
200
211
|
schemaUpdateOptions: () => schemaUpdateOptions,
|
|
212
|
+
schemaUpdateOvernightParkingRequest: () => schemaUpdateOvernightParkingRequest,
|
|
201
213
|
schemaUpdatePatrolLog: () => schemaUpdatePatrolLog,
|
|
202
214
|
schemaUpdatePatrolQuestion: () => schemaUpdatePatrolQuestion,
|
|
203
215
|
schemaUpdatePatrolRoute: () => schemaUpdatePatrolRoute,
|
|
@@ -271,6 +283,8 @@ __export(src_exports, {
|
|
|
271
283
|
useGuestManagementController: () => useGuestManagementController,
|
|
272
284
|
useGuestManagementRepo: () => useGuestManagementRepo,
|
|
273
285
|
useGuestManagementService: () => useGuestManagementService,
|
|
286
|
+
useHrmLabsAttendanceCtrl: () => useHrmLabsAttendanceCtrl,
|
|
287
|
+
useHrmLabsAttendanceSrvc: () => useHrmLabsAttendanceSrvc,
|
|
274
288
|
useIncidentReportController: () => useIncidentReportController,
|
|
275
289
|
useIncidentReportRepo: () => useIncidentReportRepo,
|
|
276
290
|
useIncidentReportService: () => useIncidentReportService,
|
|
@@ -282,6 +296,8 @@ __export(src_exports, {
|
|
|
282
296
|
useManpowerMonitoringCtrl: () => useManpowerMonitoringCtrl,
|
|
283
297
|
useManpowerMonitoringRepo: () => useManpowerMonitoringRepo,
|
|
284
298
|
useManpowerMonitoringSrvc: () => useManpowerMonitoringSrvc,
|
|
299
|
+
useManpowerRemarkCtrl: () => useManpowerRemarkCtrl,
|
|
300
|
+
useManpowerRemarksRepo: () => useManpowerRemarksRepo,
|
|
285
301
|
useMemberController: () => useMemberController,
|
|
286
302
|
useMemberRepo: () => useMemberRepo,
|
|
287
303
|
useNewDashboardController: () => useNewDashboardController,
|
|
@@ -313,6 +329,9 @@ __export(src_exports, {
|
|
|
313
329
|
useOrgRepo: () => useOrgRepo,
|
|
314
330
|
useOvernightParkingController: () => useOvernightParkingController,
|
|
315
331
|
useOvernightParkingRepo: () => useOvernightParkingRepo,
|
|
332
|
+
useOvernightParkingRequestController: () => useOvernightParkingRequestController,
|
|
333
|
+
useOvernightParkingRequestRepo: () => useOvernightParkingRequestRepo,
|
|
334
|
+
useOvernightParkingRequestService: () => useOvernightParkingRequestService,
|
|
316
335
|
usePatrolLogController: () => usePatrolLogController,
|
|
317
336
|
usePatrolLogRepo: () => usePatrolLogRepo,
|
|
318
337
|
usePatrolQuestionController: () => usePatrolQuestionController,
|
|
@@ -4936,6 +4955,16 @@ function useSiteRepo() {
|
|
|
4936
4955
|
throw error;
|
|
4937
4956
|
}
|
|
4938
4957
|
}
|
|
4958
|
+
async function getAllSitesUnpaginated() {
|
|
4959
|
+
try {
|
|
4960
|
+
const sites = await collection.find({ deletedAt: "" }).project({
|
|
4961
|
+
_id: 1
|
|
4962
|
+
}).toArray();
|
|
4963
|
+
return sites;
|
|
4964
|
+
} catch (error) {
|
|
4965
|
+
throw error;
|
|
4966
|
+
}
|
|
4967
|
+
}
|
|
4939
4968
|
return {
|
|
4940
4969
|
createIndexes,
|
|
4941
4970
|
createSite,
|
|
@@ -4948,7 +4977,8 @@ function useSiteRepo() {
|
|
|
4948
4977
|
getByName,
|
|
4949
4978
|
getByExactName,
|
|
4950
4979
|
updateSiteIncidentCounter,
|
|
4951
|
-
updateSiteById
|
|
4980
|
+
updateSiteById,
|
|
4981
|
+
getAllSitesUnpaginated
|
|
4952
4982
|
};
|
|
4953
4983
|
}
|
|
4954
4984
|
|
|
@@ -8063,6 +8093,11 @@ function useOrgController() {
|
|
|
8063
8093
|
var import_node_server_utils36 = require("@7365admin1/node-server-utils");
|
|
8064
8094
|
var import_joi20 = __toESM(require("joi"));
|
|
8065
8095
|
var import_mongodb22 = require("mongodb");
|
|
8096
|
+
var SubscriptionType = /* @__PURE__ */ ((SubscriptionType2) => {
|
|
8097
|
+
SubscriptionType2["ORGANIZATION"] = "organization";
|
|
8098
|
+
SubscriptionType2["AFFILIATE"] = "affiliate";
|
|
8099
|
+
return SubscriptionType2;
|
|
8100
|
+
})(SubscriptionType || {});
|
|
8066
8101
|
var schema = import_joi20.default.object({
|
|
8067
8102
|
user: import_joi20.default.string().hex().required(),
|
|
8068
8103
|
amount: import_joi20.default.number().min(0).required(),
|
|
@@ -8096,7 +8131,7 @@ function MSubscription(value) {
|
|
|
8096
8131
|
currency: import_joi20.default.string().required(),
|
|
8097
8132
|
description: import_joi20.default.string().optional().allow("", null),
|
|
8098
8133
|
promoCode: import_joi20.default.string().optional().allow("", null),
|
|
8099
|
-
type: import_joi20.default.string().valid(
|
|
8134
|
+
type: import_joi20.default.string().valid(...Object.values(SubscriptionType)).optional().allow(null, ""),
|
|
8100
8135
|
paidSeats: import_joi20.default.number().optional().min(0).allow("", null),
|
|
8101
8136
|
currentSeats: import_joi20.default.number().optional().min(0).allow("", null),
|
|
8102
8137
|
maxSeats: import_joi20.default.number().optional().min(0).allow("", null),
|
|
@@ -8150,7 +8185,6 @@ function MSubscription(value) {
|
|
|
8150
8185
|
status: "active",
|
|
8151
8186
|
billingCycle: value.billingCycle,
|
|
8152
8187
|
nextBillingDate,
|
|
8153
|
-
// Fixed nextBillingDate logic
|
|
8154
8188
|
lastPaymentStatus: value.lastPaymentStatus ?? "success",
|
|
8155
8189
|
failedAttempts: value.failedAttempts ?? 0,
|
|
8156
8190
|
createdAt: createdAt.toISOString(),
|
|
@@ -16619,7 +16653,7 @@ var schemaBuildingUnit = import_joi43.default.object({
|
|
|
16619
16653
|
buildingName: import_joi43.default.string().optional().allow("", null),
|
|
16620
16654
|
block: import_joi43.default.number().integer().min(1).required(),
|
|
16621
16655
|
level: import_joi43.default.string().required(),
|
|
16622
|
-
category: import_joi43.default.string().
|
|
16656
|
+
category: import_joi43.default.string().optional().allow(null, ""),
|
|
16623
16657
|
status: import_joi43.default.string().optional().allow("", null),
|
|
16624
16658
|
buildingUnitFiles: import_joi43.default.array().items(import_joi43.default.string()).optional().allow("", null),
|
|
16625
16659
|
companyName: import_joi43.default.string().optional().allow("", null),
|
|
@@ -18700,10 +18734,12 @@ var schemaCustomerSite = import_joi48.default.object({
|
|
|
18700
18734
|
_id: import_joi48.default.string().hex().optional().allow("", null),
|
|
18701
18735
|
name: import_joi48.default.string().required(),
|
|
18702
18736
|
site: import_joi48.default.string().hex().optional().allow("", null),
|
|
18703
|
-
siteOrg: import_joi48.default.string().hex().
|
|
18704
|
-
siteOrgName: import_joi48.default.string().
|
|
18737
|
+
siteOrg: import_joi48.default.string().hex().optional().allow("", null),
|
|
18738
|
+
siteOrgName: import_joi48.default.string().optional().allow("", null),
|
|
18705
18739
|
org: import_joi48.default.string().hex().required(),
|
|
18706
18740
|
status: import_joi48.default.string().optional().allow("", null),
|
|
18741
|
+
address: addressSchema.optional().allow("", null),
|
|
18742
|
+
category: import_joi48.default.string().valid(...Object.values(SiteCategories)).optional().allow(null, ""),
|
|
18707
18743
|
createdAt: import_joi48.default.string().optional().allow("", null),
|
|
18708
18744
|
updatedAt: import_joi48.default.string().optional().allow("", null),
|
|
18709
18745
|
deletedAt: import_joi48.default.string().optional().allow("", null)
|
|
@@ -18748,6 +18784,8 @@ function MCustomerSite(value) {
|
|
|
18748
18784
|
siteOrg: value.siteOrg,
|
|
18749
18785
|
siteOrgName: value.siteOrgName,
|
|
18750
18786
|
org: value.org,
|
|
18787
|
+
address: value.address,
|
|
18788
|
+
category: value.category,
|
|
18751
18789
|
status: value.status ?? "active",
|
|
18752
18790
|
createdAt: value.createdAt ?? /* @__PURE__ */ new Date(),
|
|
18753
18791
|
updatedAt: value.updatedAt ?? "",
|
|
@@ -19018,7 +19056,12 @@ function useCustomerSiteService() {
|
|
|
19018
19056
|
}
|
|
19019
19057
|
}
|
|
19020
19058
|
const siteId = await createSite(
|
|
19021
|
-
{
|
|
19059
|
+
{
|
|
19060
|
+
name: value.name,
|
|
19061
|
+
orgId: value.siteOrg,
|
|
19062
|
+
address: value.address,
|
|
19063
|
+
category: value.category
|
|
19064
|
+
},
|
|
19022
19065
|
session
|
|
19023
19066
|
);
|
|
19024
19067
|
if (!siteId) {
|
|
@@ -19130,25 +19173,15 @@ function useCustomerSiteController() {
|
|
|
19130
19173
|
} = useCustomerSiteRepo();
|
|
19131
19174
|
const { add: _add, addViaInvite: _addViaInvite } = useCustomerSiteService();
|
|
19132
19175
|
async function add(req, res, next) {
|
|
19133
|
-
const
|
|
19134
|
-
name: import_joi50.default.string().required(),
|
|
19135
|
-
site: import_joi50.default.string().hex().optional().allow("", null),
|
|
19136
|
-
siteOrg: import_joi50.default.string().hex().required(),
|
|
19137
|
-
siteOrgName: import_joi50.default.string().required(),
|
|
19138
|
-
org: import_joi50.default.string().hex().required()
|
|
19139
|
-
});
|
|
19140
|
-
const payload = { ...req.body };
|
|
19141
|
-
const { error } = validation.validate(payload);
|
|
19176
|
+
const { error, value } = schemaCustomerSite.validate(req.body);
|
|
19142
19177
|
if (error) {
|
|
19143
|
-
|
|
19144
|
-
|
|
19145
|
-
|
|
19146
|
-
});
|
|
19147
|
-
next(new import_node_server_utils90.BadRequestError(error.message));
|
|
19178
|
+
const messages = error.details.map((d) => d.message).join(", ");
|
|
19179
|
+
import_node_server_utils90.logger.log({ level: "error", message: messages });
|
|
19180
|
+
next(new import_node_server_utils90.BadRequestError(messages));
|
|
19148
19181
|
return;
|
|
19149
19182
|
}
|
|
19150
19183
|
try {
|
|
19151
|
-
const data = await _add(
|
|
19184
|
+
const data = await _add(value);
|
|
19152
19185
|
res.status(201).json(data);
|
|
19153
19186
|
return;
|
|
19154
19187
|
} catch (error2) {
|
|
@@ -24181,7 +24214,7 @@ function useSiteFacilityService() {
|
|
|
24181
24214
|
});
|
|
24182
24215
|
}, generateTimeSlots2 = function(start, end, interval) {
|
|
24183
24216
|
const slots = [];
|
|
24184
|
-
const
|
|
24217
|
+
const timeToMinutes2 = (t) => {
|
|
24185
24218
|
const [h, m] = t.split(":").map(Number);
|
|
24186
24219
|
return h * 60 + m;
|
|
24187
24220
|
};
|
|
@@ -24190,8 +24223,8 @@ function useSiteFacilityService() {
|
|
|
24190
24223
|
const mm = m % 60;
|
|
24191
24224
|
return `${String(h).padStart(2, "0")}:${String(mm).padStart(2, "0")}`;
|
|
24192
24225
|
};
|
|
24193
|
-
const startMin =
|
|
24194
|
-
const endMin =
|
|
24226
|
+
const startMin = timeToMinutes2(start);
|
|
24227
|
+
const endMin = timeToMinutes2(end);
|
|
24195
24228
|
const intervalMin = interval * 60;
|
|
24196
24229
|
for (let t = startMin; t + intervalMin <= endMin; t += intervalMin) {
|
|
24197
24230
|
const s = minutesToTime(t);
|
|
@@ -26577,7 +26610,10 @@ function useBulletinBoardService() {
|
|
|
26577
26610
|
const existingBulletinBoard = await _getBulletinBoardById(id);
|
|
26578
26611
|
if (Array.isArray(existingBulletinBoard.file)) {
|
|
26579
26612
|
for (const file of existingBulletinBoard.file) {
|
|
26580
|
-
|
|
26613
|
+
try {
|
|
26614
|
+
await _deleteFileById(file, session);
|
|
26615
|
+
} catch (error) {
|
|
26616
|
+
}
|
|
26581
26617
|
}
|
|
26582
26618
|
}
|
|
26583
26619
|
await _deleteBulletinBoardById(id, session);
|
|
@@ -26737,14 +26773,16 @@ function useBulletinBoardController() {
|
|
|
26737
26773
|
}
|
|
26738
26774
|
}
|
|
26739
26775
|
async function deleteBulletinBoardById(req, res, next) {
|
|
26740
|
-
const
|
|
26741
|
-
|
|
26742
|
-
|
|
26776
|
+
const schema2 = import_joi76.default.object({
|
|
26777
|
+
_id: import_joi76.default.string().hex().length(24).required()
|
|
26778
|
+
});
|
|
26779
|
+
const { error, value } = schema2.validate({ _id: req.params.id });
|
|
26743
26780
|
if (error) {
|
|
26744
26781
|
import_node_server_utils134.logger.log({ level: "error", message: error.message });
|
|
26745
26782
|
next(new import_node_server_utils134.BadRequestError(error.message));
|
|
26746
26783
|
return;
|
|
26747
26784
|
}
|
|
26785
|
+
const { _id } = value;
|
|
26748
26786
|
try {
|
|
26749
26787
|
await _deleteBulletinBoardById(_id);
|
|
26750
26788
|
res.status(200).json({ message: "Successfully deleted bulletin board." });
|
|
@@ -40167,6 +40205,8 @@ var import_node_server_utils194 = require("@7365admin1/node-server-utils");
|
|
|
40167
40205
|
|
|
40168
40206
|
// src/utils/hrmlabs-attendance.util.ts
|
|
40169
40207
|
var import_axios2 = __toESM(require("axios"));
|
|
40208
|
+
var import_moment_timezone = __toESM(require("moment-timezone"));
|
|
40209
|
+
var default_early_checkIn = 4;
|
|
40170
40210
|
async function hrmLabsAuthentication({
|
|
40171
40211
|
authUrl,
|
|
40172
40212
|
username,
|
|
@@ -40193,6 +40233,205 @@ async function hrmLabsAuthentication({
|
|
|
40193
40233
|
"HRMLabs Authentication failed. Please check your credentials."
|
|
40194
40234
|
);
|
|
40195
40235
|
}
|
|
40236
|
+
async function fetchAttendanceData({
|
|
40237
|
+
attendanceUrl,
|
|
40238
|
+
token,
|
|
40239
|
+
startDate,
|
|
40240
|
+
endDate,
|
|
40241
|
+
siteName,
|
|
40242
|
+
search
|
|
40243
|
+
}) {
|
|
40244
|
+
try {
|
|
40245
|
+
const res = await import_axios2.default.post(
|
|
40246
|
+
attendanceUrl,
|
|
40247
|
+
{
|
|
40248
|
+
start: startDate,
|
|
40249
|
+
end: endDate,
|
|
40250
|
+
locationName: siteName,
|
|
40251
|
+
search
|
|
40252
|
+
},
|
|
40253
|
+
{
|
|
40254
|
+
headers: { Authorization: `Bearer ${token}` },
|
|
40255
|
+
validateStatus: () => true
|
|
40256
|
+
}
|
|
40257
|
+
);
|
|
40258
|
+
if (res.status >= 200 && res.status < 300 && res.data?.success) {
|
|
40259
|
+
return { success: true, data: res.data.data || [] };
|
|
40260
|
+
}
|
|
40261
|
+
return {
|
|
40262
|
+
success: false,
|
|
40263
|
+
message: `Attendance API failed with status ${res.status}`,
|
|
40264
|
+
data: []
|
|
40265
|
+
};
|
|
40266
|
+
} catch (error) {
|
|
40267
|
+
console.error("fetchAttendanceData error:", error.message || error);
|
|
40268
|
+
return {
|
|
40269
|
+
success: false,
|
|
40270
|
+
message: error?.message || "Unknown error while fetching attendance data",
|
|
40271
|
+
data: []
|
|
40272
|
+
};
|
|
40273
|
+
}
|
|
40274
|
+
}
|
|
40275
|
+
function filterByShiftTime(attendance, shiftData, timezone, format) {
|
|
40276
|
+
return attendance.filter((item) => {
|
|
40277
|
+
if (!item.checkIn)
|
|
40278
|
+
return false;
|
|
40279
|
+
const checkInLocal = (0, import_moment_timezone.default)(item.checkIn, format);
|
|
40280
|
+
if (!checkInLocal.isValid())
|
|
40281
|
+
return false;
|
|
40282
|
+
const [startHour, startMinute] = shiftData.checkIn.split(":").map(Number);
|
|
40283
|
+
const [endHour, endMinute] = shiftData.checkOut.split(":").map(Number);
|
|
40284
|
+
const shiftStart = (0, import_moment_timezone.default)(checkInLocal).set({ hour: startHour, minute: startMinute, second: 0, millisecond: 0 }).subtract(default_early_checkIn, "hour");
|
|
40285
|
+
const shiftEnd = (0, import_moment_timezone.default)(checkInLocal).set({
|
|
40286
|
+
hour: endHour,
|
|
40287
|
+
minute: endMinute,
|
|
40288
|
+
second: 0,
|
|
40289
|
+
millisecond: 0
|
|
40290
|
+
}).subtract(default_early_checkIn, "hour");
|
|
40291
|
+
if (shiftEnd.isBefore(shiftStart))
|
|
40292
|
+
shiftEnd.add(1, "day");
|
|
40293
|
+
return checkInLocal.isBetween(shiftStart, shiftEnd, null, "[]");
|
|
40294
|
+
});
|
|
40295
|
+
}
|
|
40296
|
+
function paginate49(data, page, limit) {
|
|
40297
|
+
const length = data.length;
|
|
40298
|
+
const startIndex = (page - 1) * limit;
|
|
40299
|
+
const endIndex = startIndex + limit;
|
|
40300
|
+
return {
|
|
40301
|
+
items: data.slice(startIndex, endIndex),
|
|
40302
|
+
pages: Math.ceil(length / limit),
|
|
40303
|
+
pageRange: `${startIndex + 1}-${Math.min(endIndex, length)} of ${length}`
|
|
40304
|
+
};
|
|
40305
|
+
}
|
|
40306
|
+
function designationCount(attendance, designationConfig, shiftName) {
|
|
40307
|
+
let data = [];
|
|
40308
|
+
const seen = /* @__PURE__ */ new Set();
|
|
40309
|
+
const count = {};
|
|
40310
|
+
const uniqueAttendanceData = attendance.filter((item) => {
|
|
40311
|
+
if (seen.has(item.identificationNumber))
|
|
40312
|
+
return false;
|
|
40313
|
+
seen.add(item.identificationNumber);
|
|
40314
|
+
return true;
|
|
40315
|
+
});
|
|
40316
|
+
for (const record of uniqueAttendanceData) {
|
|
40317
|
+
count[record.jobTitle] = (count[record.jobTitle] || 0) + 1;
|
|
40318
|
+
}
|
|
40319
|
+
let total = 0;
|
|
40320
|
+
const result = [];
|
|
40321
|
+
const addedTitles = /* @__PURE__ */ new Set();
|
|
40322
|
+
const shiftMap = {
|
|
40323
|
+
"Day Shift": "morningShift",
|
|
40324
|
+
"Afternoon Shift": "afternoonShift",
|
|
40325
|
+
"Night Shift": "nightShift"
|
|
40326
|
+
};
|
|
40327
|
+
for (const designation of designationConfig.designations) {
|
|
40328
|
+
const title = designation.title;
|
|
40329
|
+
const shifts = designation.shifts;
|
|
40330
|
+
if (shiftName === "all") {
|
|
40331
|
+
total = (shifts.morningShift || 0) + (shifts.afternoonShift || 0) + (shifts.nightShift || 0);
|
|
40332
|
+
} else {
|
|
40333
|
+
total = shifts[shiftMap[shiftName]] || 0;
|
|
40334
|
+
}
|
|
40335
|
+
const countValue = count[title] ?? 0;
|
|
40336
|
+
result.push({
|
|
40337
|
+
name: title,
|
|
40338
|
+
count: countValue,
|
|
40339
|
+
total
|
|
40340
|
+
});
|
|
40341
|
+
addedTitles.add(title);
|
|
40342
|
+
}
|
|
40343
|
+
for (const title in count) {
|
|
40344
|
+
if (!addedTitles.has(title)) {
|
|
40345
|
+
result.push({
|
|
40346
|
+
name: title,
|
|
40347
|
+
count: count[title],
|
|
40348
|
+
total: 0
|
|
40349
|
+
});
|
|
40350
|
+
}
|
|
40351
|
+
}
|
|
40352
|
+
return result;
|
|
40353
|
+
}
|
|
40354
|
+
function totalCountPerShift(attendance, shiftData, timezone, format) {
|
|
40355
|
+
let totalCountPerShift3 = [];
|
|
40356
|
+
const seen = /* @__PURE__ */ new Set();
|
|
40357
|
+
const uniqueAttendanceData = [];
|
|
40358
|
+
for (const item of attendance) {
|
|
40359
|
+
if (!seen.has(item.identificationNumber)) {
|
|
40360
|
+
const duplicates = attendance.filter(
|
|
40361
|
+
(a) => a.identificationNumber === item.identificationNumber
|
|
40362
|
+
);
|
|
40363
|
+
if (duplicates.length > 1) {
|
|
40364
|
+
const preferred = duplicates.find((a) => a.timeDiff > 0.1) || item;
|
|
40365
|
+
uniqueAttendanceData.push(preferred);
|
|
40366
|
+
} else {
|
|
40367
|
+
uniqueAttendanceData.push(item);
|
|
40368
|
+
}
|
|
40369
|
+
seen.add(item.identificationNumber);
|
|
40370
|
+
}
|
|
40371
|
+
}
|
|
40372
|
+
let data = [];
|
|
40373
|
+
for (const shift of shiftData) {
|
|
40374
|
+
data = uniqueAttendanceData.filter((item) => {
|
|
40375
|
+
if (!item.checkIn)
|
|
40376
|
+
return false;
|
|
40377
|
+
const checkInLocal = (0, import_moment_timezone.default)(item.checkIn, format);
|
|
40378
|
+
if (!checkInLocal.isValid())
|
|
40379
|
+
return false;
|
|
40380
|
+
const [startHour, startMinute] = shift.checkIn.split(":").map(Number);
|
|
40381
|
+
const [endHour, endMinute] = shift.checkOut.split(":").map(Number);
|
|
40382
|
+
const shiftStart = (0, import_moment_timezone.default)(checkInLocal).set({
|
|
40383
|
+
hour: startHour,
|
|
40384
|
+
minute: startMinute,
|
|
40385
|
+
second: 0,
|
|
40386
|
+
millisecond: 0
|
|
40387
|
+
}).subtract(default_early_checkIn, "hour");
|
|
40388
|
+
const shiftEnd = (0, import_moment_timezone.default)(checkInLocal).set({
|
|
40389
|
+
hour: endHour,
|
|
40390
|
+
minute: endMinute,
|
|
40391
|
+
second: 0,
|
|
40392
|
+
millisecond: 0
|
|
40393
|
+
}).subtract(default_early_checkIn, "hour");
|
|
40394
|
+
if (shiftEnd.isBefore(shiftStart))
|
|
40395
|
+
shiftEnd.add(1, "day");
|
|
40396
|
+
return checkInLocal.isBetween(shiftStart, shiftEnd, null, "[]");
|
|
40397
|
+
});
|
|
40398
|
+
totalCountPerShift3.push(data.length);
|
|
40399
|
+
}
|
|
40400
|
+
const shiftInsertMap = {
|
|
40401
|
+
"Day Shift": (data2) => data2.push(0),
|
|
40402
|
+
"Afternoon Shift": (data2) => data2.splice(1, 0, 0),
|
|
40403
|
+
"Night Shift": (data2) => data2.unshift(0)
|
|
40404
|
+
};
|
|
40405
|
+
if (shiftData.length === 1) {
|
|
40406
|
+
const shiftName = shiftData[0]?.name;
|
|
40407
|
+
const insertFn = shiftInsertMap[shiftName];
|
|
40408
|
+
if (insertFn) {
|
|
40409
|
+
insertFn(totalCountPerShift3);
|
|
40410
|
+
}
|
|
40411
|
+
}
|
|
40412
|
+
return totalCountPerShift3;
|
|
40413
|
+
}
|
|
40414
|
+
function filterByStatus(attendance, shiftData, timezone, format, status) {
|
|
40415
|
+
return attendance.filter((item) => {
|
|
40416
|
+
if (!item.checkIn)
|
|
40417
|
+
return false;
|
|
40418
|
+
const checkInLocal = (0, import_moment_timezone.default)(item.checkIn, format);
|
|
40419
|
+
if (!checkInLocal.isValid())
|
|
40420
|
+
return false;
|
|
40421
|
+
const [lateHour, lateMinute] = shiftData.lateCheckInAlert.split(":").map(Number);
|
|
40422
|
+
const lateLoginTime = (0, import_moment_timezone.default)(checkInLocal).set({
|
|
40423
|
+
hour: lateHour,
|
|
40424
|
+
minute: lateMinute,
|
|
40425
|
+
second: 0,
|
|
40426
|
+
millisecond: 0
|
|
40427
|
+
});
|
|
40428
|
+
if (status == "onTime") {
|
|
40429
|
+
return checkInLocal.isBefore(lateLoginTime);
|
|
40430
|
+
} else if (status == "late") {
|
|
40431
|
+
return checkInLocal.isAfter(lateLoginTime);
|
|
40432
|
+
}
|
|
40433
|
+
});
|
|
40434
|
+
}
|
|
40196
40435
|
function sleep(ms) {
|
|
40197
40436
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
40198
40437
|
}
|
|
@@ -40226,9 +40465,189 @@ async function fetchSites({ siteUrl, token }) {
|
|
|
40226
40465
|
} while (attempt < maxRetries);
|
|
40227
40466
|
throw lastError;
|
|
40228
40467
|
}
|
|
40468
|
+
async function totalCountPerStatus(attendance, shiftName, shiftData, timezone, format, totalShifts) {
|
|
40469
|
+
const totalCountPerStatus3 = {
|
|
40470
|
+
onTime: 0,
|
|
40471
|
+
late: 0,
|
|
40472
|
+
noShow: 0,
|
|
40473
|
+
earlyOut: 0,
|
|
40474
|
+
totalCount: 0
|
|
40475
|
+
};
|
|
40476
|
+
const seenGlobal = /* @__PURE__ */ new Set();
|
|
40477
|
+
const parseTime = (timeStr) => {
|
|
40478
|
+
const [hour, minute] = timeStr.split(":").map(Number);
|
|
40479
|
+
return { hour, minute };
|
|
40480
|
+
};
|
|
40481
|
+
for (const shift of shiftData) {
|
|
40482
|
+
const shiftStartTime = parseTime(shift.checkIn);
|
|
40483
|
+
const shiftEndTime = parseTime(shift.checkOut);
|
|
40484
|
+
const lateTime = parseTime(shift.lateCheckInAlert);
|
|
40485
|
+
const uniqueAttendanceData = shiftName === "all" ? await filterByShiftTime(attendance, shift, timezone, format) : attendance;
|
|
40486
|
+
for (const item of uniqueAttendanceData) {
|
|
40487
|
+
const {
|
|
40488
|
+
checkIn: checkInStr,
|
|
40489
|
+
checkOut: checkOutStr,
|
|
40490
|
+
identificationNumber
|
|
40491
|
+
} = item;
|
|
40492
|
+
if (!checkInStr || seenGlobal.has(identificationNumber))
|
|
40493
|
+
continue;
|
|
40494
|
+
const checkIn = (0, import_moment_timezone.default)(checkInStr, format);
|
|
40495
|
+
const checkOut = checkOutStr ? (0, import_moment_timezone.default)(checkOutStr, format) : null;
|
|
40496
|
+
const checkOutChecker = checkOut ? (0, import_moment_timezone.default)(checkOutStr, format) : checkIn;
|
|
40497
|
+
if (!checkIn.isValid())
|
|
40498
|
+
continue;
|
|
40499
|
+
const shiftStart = (0, import_moment_timezone.default)(checkIn).set({ ...shiftStartTime, second: 59, millisecond: 59 }).subtract(default_early_checkIn, "hour");
|
|
40500
|
+
const shiftEnd = (0, import_moment_timezone.default)(checkOutChecker).set({ ...shiftEndTime, second: 0, millisecond: 0 }).subtract(default_early_checkIn, "hour");
|
|
40501
|
+
const lateCheckIn = (0, import_moment_timezone.default)(checkIn).set({
|
|
40502
|
+
...lateTime,
|
|
40503
|
+
second: 59,
|
|
40504
|
+
millisecond: 59
|
|
40505
|
+
});
|
|
40506
|
+
if (shiftEnd.isBefore(shiftStart))
|
|
40507
|
+
shiftEnd.add(1, "day");
|
|
40508
|
+
if (checkIn.isBetween(shiftStart, shiftEnd, null, "[]")) {
|
|
40509
|
+
seenGlobal.add(identificationNumber);
|
|
40510
|
+
if (checkIn.isSameOrBefore(lateCheckIn)) {
|
|
40511
|
+
totalCountPerStatus3.onTime++;
|
|
40512
|
+
} else {
|
|
40513
|
+
totalCountPerStatus3.late++;
|
|
40514
|
+
}
|
|
40515
|
+
if (checkOut && item.timeDiff < 12) {
|
|
40516
|
+
totalCountPerStatus3.earlyOut++;
|
|
40517
|
+
}
|
|
40518
|
+
}
|
|
40519
|
+
}
|
|
40520
|
+
}
|
|
40521
|
+
const shiftMap = {
|
|
40522
|
+
"Day Shift": totalShifts.morningShift,
|
|
40523
|
+
"Afternoon Shift": totalShifts.afternoonShift,
|
|
40524
|
+
"Night Shift": totalShifts.nightShift,
|
|
40525
|
+
all: totalShifts.morningShift + totalShifts.afternoonShift + totalShifts.nightShift
|
|
40526
|
+
};
|
|
40527
|
+
const totalPresent = totalCountPerStatus3.onTime + totalCountPerStatus3.late;
|
|
40528
|
+
totalCountPerStatus3.noShow = shiftMap[shiftName] - totalPresent;
|
|
40529
|
+
totalCountPerStatus3.totalCount = shiftMap[shiftName];
|
|
40530
|
+
return totalCountPerStatus3;
|
|
40531
|
+
}
|
|
40532
|
+
async function chartCountData(attendance, shiftData, timezone, format, totalShifts, startDateStr, endDateStr, status = "all") {
|
|
40533
|
+
const categorizedData = [];
|
|
40534
|
+
const seenPerDay = /* @__PURE__ */ new Set();
|
|
40535
|
+
const parseTime = (timeStr) => {
|
|
40536
|
+
const [hour, minute] = timeStr.split(":").map(Number);
|
|
40537
|
+
return { hour, minute };
|
|
40538
|
+
};
|
|
40539
|
+
const startDate = (0, import_moment_timezone.default)(startDateStr, "DD-MM-YYYY");
|
|
40540
|
+
const endDate = (0, import_moment_timezone.default)(endDateStr, "DD-MM-YYYY");
|
|
40541
|
+
const daysInRange = [];
|
|
40542
|
+
for (let day = startDate.clone(); day.isSameOrBefore(endDate); day.add(1, "day")) {
|
|
40543
|
+
daysInRange.push(day.format("DD-MM-YYYY"));
|
|
40544
|
+
}
|
|
40545
|
+
for (const day of daysInRange) {
|
|
40546
|
+
const dailyData = { date: day, late: 0, under: 0, over: 0, normal: 0 };
|
|
40547
|
+
const dailyAttendance = attendance.filter((item) => {
|
|
40548
|
+
const checkInDate = item.checkIn.split(" ")[0];
|
|
40549
|
+
return checkInDate === day;
|
|
40550
|
+
});
|
|
40551
|
+
const [morningCount, nightCount] = totalCountPerShift(
|
|
40552
|
+
dailyAttendance,
|
|
40553
|
+
shiftData,
|
|
40554
|
+
timezone,
|
|
40555
|
+
format
|
|
40556
|
+
);
|
|
40557
|
+
if (status === "all" || status === "under" || status === "over") {
|
|
40558
|
+
const shifts = [
|
|
40559
|
+
{
|
|
40560
|
+
label: "morningShift",
|
|
40561
|
+
expected: totalShifts.morningShift,
|
|
40562
|
+
actual: morningCount
|
|
40563
|
+
},
|
|
40564
|
+
{
|
|
40565
|
+
label: "nightShift",
|
|
40566
|
+
expected: totalShifts.nightShift,
|
|
40567
|
+
actual: nightCount
|
|
40568
|
+
}
|
|
40569
|
+
];
|
|
40570
|
+
const today = /* @__PURE__ */ new Date();
|
|
40571
|
+
today.setHours(0, 0, 0, 0);
|
|
40572
|
+
for (const { label, expected, actual } of shifts) {
|
|
40573
|
+
const [dayPart, month, year] = day.split("-");
|
|
40574
|
+
const currentDay = /* @__PURE__ */ new Date(`${year}-${month}-${dayPart}`);
|
|
40575
|
+
currentDay.setHours(0, 0, 0, 0);
|
|
40576
|
+
if (currentDay <= today) {
|
|
40577
|
+
if (status === "all") {
|
|
40578
|
+
if (actual < expected)
|
|
40579
|
+
dailyData.under++;
|
|
40580
|
+
else if (actual > expected)
|
|
40581
|
+
dailyData.over++;
|
|
40582
|
+
else
|
|
40583
|
+
dailyData.normal++;
|
|
40584
|
+
} else if (status === "under" && actual < expected) {
|
|
40585
|
+
dailyData.under++;
|
|
40586
|
+
} else if (status === "over" && actual > expected) {
|
|
40587
|
+
dailyData.over++;
|
|
40588
|
+
}
|
|
40589
|
+
}
|
|
40590
|
+
}
|
|
40591
|
+
}
|
|
40592
|
+
if (status === "late" || status === "all") {
|
|
40593
|
+
for (const shift of shiftData) {
|
|
40594
|
+
const shiftStartTime = parseTime(shift.checkIn);
|
|
40595
|
+
const shiftEndTime = parseTime(shift.checkOut);
|
|
40596
|
+
const lateTime = parseTime(shift.lateCheckInAlert);
|
|
40597
|
+
const uniqueAttendanceData = await filterByShiftTime(
|
|
40598
|
+
dailyAttendance,
|
|
40599
|
+
shift,
|
|
40600
|
+
timezone,
|
|
40601
|
+
format
|
|
40602
|
+
);
|
|
40603
|
+
for (const item of uniqueAttendanceData) {
|
|
40604
|
+
const {
|
|
40605
|
+
checkIn: checkInStr,
|
|
40606
|
+
checkOut: checkOutStr,
|
|
40607
|
+
identificationNumber
|
|
40608
|
+
} = item;
|
|
40609
|
+
if (!checkInStr)
|
|
40610
|
+
continue;
|
|
40611
|
+
const checkIn = (0, import_moment_timezone.default)(checkInStr, format);
|
|
40612
|
+
if (!checkIn.isValid())
|
|
40613
|
+
continue;
|
|
40614
|
+
const dayKey = `${identificationNumber}-${checkIn.format(
|
|
40615
|
+
"YYYY-MM-DD"
|
|
40616
|
+
)}`;
|
|
40617
|
+
if (seenPerDay.has(dayKey))
|
|
40618
|
+
continue;
|
|
40619
|
+
seenPerDay.add(dayKey);
|
|
40620
|
+
const checkOut = checkOutStr ? (0, import_moment_timezone.default)(checkOutStr, format) : checkIn;
|
|
40621
|
+
const shiftStart = (0, import_moment_timezone.default)(checkIn).set({ ...shiftStartTime, second: 59, millisecond: 59 }).subtract(default_early_checkIn, "hour");
|
|
40622
|
+
const shiftEnd = (0, import_moment_timezone.default)(checkOut).set({ ...shiftEndTime, second: 0, millisecond: 0 }).subtract(default_early_checkIn, "hour");
|
|
40623
|
+
const lateCheckIn = (0, import_moment_timezone.default)(checkIn).set({
|
|
40624
|
+
...lateTime,
|
|
40625
|
+
second: 59,
|
|
40626
|
+
millisecond: 59
|
|
40627
|
+
});
|
|
40628
|
+
if (shiftEnd.isBefore(shiftStart))
|
|
40629
|
+
shiftEnd.add(1, "day");
|
|
40630
|
+
if (checkIn.isBetween(shiftStart, shiftEnd, null, "[]") && checkIn.isAfter(lateCheckIn)) {
|
|
40631
|
+
dailyData.late++;
|
|
40632
|
+
}
|
|
40633
|
+
}
|
|
40634
|
+
}
|
|
40635
|
+
}
|
|
40636
|
+
categorizedData.push(dailyData);
|
|
40637
|
+
}
|
|
40638
|
+
return categorizedData;
|
|
40639
|
+
}
|
|
40229
40640
|
var hrmlabs_attendance_util_default = {
|
|
40230
40641
|
hrmLabsAuthentication,
|
|
40231
|
-
|
|
40642
|
+
fetchAttendanceData,
|
|
40643
|
+
filterByShiftTime,
|
|
40644
|
+
paginate: paginate49,
|
|
40645
|
+
designationCount,
|
|
40646
|
+
totalCountPerShift,
|
|
40647
|
+
filterByStatus,
|
|
40648
|
+
fetchSites,
|
|
40649
|
+
totalCountPerStatus,
|
|
40650
|
+
chartCountData
|
|
40232
40651
|
};
|
|
40233
40652
|
|
|
40234
40653
|
// src/repositories/manpower-monitoring.repo.ts
|
|
@@ -40423,17 +40842,202 @@ function useManpowerMonitoringRepo() {
|
|
|
40423
40842
|
}
|
|
40424
40843
|
|
|
40425
40844
|
// src/services/manpower-monitoring.service.ts
|
|
40845
|
+
var import_node_server_utils196 = require("@7365admin1/node-server-utils");
|
|
40846
|
+
|
|
40847
|
+
// src/repositories/manpower-remarks.repo.ts
|
|
40426
40848
|
var import_node_server_utils195 = require("@7365admin1/node-server-utils");
|
|
40427
|
-
|
|
40849
|
+
|
|
40850
|
+
// src/models/manpower-remarks.model.ts
|
|
40851
|
+
var import_joi112 = __toESM(require("joi"));
|
|
40852
|
+
var import_mongodb109 = require("mongodb");
|
|
40853
|
+
var remarksSchema = import_joi112.default.object({
|
|
40854
|
+
name: import_joi112.default.string().required(),
|
|
40855
|
+
remark: import_joi112.default.object({
|
|
40856
|
+
isAcknowledged: import_joi112.default.boolean().required(),
|
|
40857
|
+
status: import_joi112.default.string().optional().allow("", null),
|
|
40858
|
+
acknowledgementRemarks: import_joi112.default.string().optional().allow("", null),
|
|
40859
|
+
acknowledgedAt: import_joi112.default.string().optional().allow("", null)
|
|
40860
|
+
}).required()
|
|
40861
|
+
});
|
|
40862
|
+
var manpowerRemarksSchema = import_joi112.default.object({
|
|
40863
|
+
siteId: import_joi112.default.string().hex().optional(),
|
|
40864
|
+
siteName: import_joi112.default.string().optional(),
|
|
40865
|
+
remarks: import_joi112.default.array().items(remarksSchema).required(),
|
|
40866
|
+
createdBy: import_joi112.default.string().hex().optional().allow("", null),
|
|
40867
|
+
createdByName: import_joi112.default.string().optional().allow("", null),
|
|
40868
|
+
morningAlertTime: import_joi112.default.string().optional().allow("", null),
|
|
40869
|
+
afternoonAlertTime: import_joi112.default.string().optional().allow("", null),
|
|
40870
|
+
nightAlertTime: import_joi112.default.string().optional().allow("", null),
|
|
40871
|
+
serviceProviderId: import_joi112.default.string().hex().optional(),
|
|
40872
|
+
status: import_joi112.default.string().required()
|
|
40873
|
+
});
|
|
40874
|
+
var MManpowerRemarks = class {
|
|
40875
|
+
constructor(data) {
|
|
40876
|
+
this._id = new import_mongodb109.ObjectId();
|
|
40877
|
+
this.serviceProviderId = data.serviceProviderId || "";
|
|
40878
|
+
this.siteId = data.siteId || "";
|
|
40879
|
+
this.siteName = data.siteName || "";
|
|
40880
|
+
this.remarks = data.remarks || [];
|
|
40881
|
+
this.createdBy = data.createdBy || "";
|
|
40882
|
+
this.createdByName = data.createdByName || "";
|
|
40883
|
+
this.createdAt = /* @__PURE__ */ new Date();
|
|
40884
|
+
this.createdAtSGT = data.createdAtSGT || "";
|
|
40885
|
+
this.updatedAt = data.updatedAt || "";
|
|
40886
|
+
this.morningAlertTime = data.morningAlertTime || "";
|
|
40887
|
+
this.afternoonAlertTime = data.afternoonAlertTime || "";
|
|
40888
|
+
this.nightAlertTime = data.nightAlertTime || "";
|
|
40889
|
+
this.status = data.status || "active";
|
|
40890
|
+
}
|
|
40891
|
+
};
|
|
40892
|
+
|
|
40893
|
+
// src/repositories/manpower-remarks.repo.ts
|
|
40894
|
+
var import_mongodb110 = require("mongodb");
|
|
40895
|
+
var import_moment_timezone2 = __toESM(require("moment-timezone"));
|
|
40896
|
+
function useManpowerRemarksRepo() {
|
|
40897
|
+
const db = import_node_server_utils195.useAtlas.getDb();
|
|
40898
|
+
if (!db) {
|
|
40899
|
+
throw new Error("Unable to connect to server.");
|
|
40900
|
+
}
|
|
40901
|
+
const namespace_collection = "manpower-remarks";
|
|
40902
|
+
const collection = db.collection(namespace_collection);
|
|
40903
|
+
async function createManpowerRemarks(value, session) {
|
|
40904
|
+
try {
|
|
40905
|
+
value = new MManpowerRemarks(value);
|
|
40906
|
+
if (value.siteId)
|
|
40907
|
+
value.siteId = new import_mongodb110.ObjectId(value.siteId);
|
|
40908
|
+
if (value.serviceProviderId)
|
|
40909
|
+
value.serviceProviderId = new import_mongodb110.ObjectId(value.serviceProviderId);
|
|
40910
|
+
const result = await collection.insertOne(value, { session });
|
|
40911
|
+
return result;
|
|
40912
|
+
} catch (error) {
|
|
40913
|
+
throw new Error(error.message || error || "Server Internal Error");
|
|
40914
|
+
}
|
|
40915
|
+
}
|
|
40916
|
+
async function getManpowerRemarksAllSite({
|
|
40917
|
+
page = 1,
|
|
40918
|
+
limit = 10,
|
|
40919
|
+
serviceProviderId = "",
|
|
40920
|
+
search = "",
|
|
40921
|
+
status = "active",
|
|
40922
|
+
date = ""
|
|
40923
|
+
}) {
|
|
40924
|
+
try {
|
|
40925
|
+
page = page ? page - 1 : 0;
|
|
40926
|
+
limit = limit || 10;
|
|
40927
|
+
const searchQuery = {};
|
|
40928
|
+
const nowSGT = (0, import_moment_timezone2.default)().tz("Asia/Singapore");
|
|
40929
|
+
searchQuery.serviceProviderId = new import_mongodb110.ObjectId(serviceProviderId);
|
|
40930
|
+
if (search != "") {
|
|
40931
|
+
searchQuery.siteName = { $regex: search, $options: "i" };
|
|
40932
|
+
}
|
|
40933
|
+
if (status) {
|
|
40934
|
+
searchQuery.status = status;
|
|
40935
|
+
}
|
|
40936
|
+
if (date) {
|
|
40937
|
+
searchQuery.createdAtSGT = date;
|
|
40938
|
+
}
|
|
40939
|
+
const result = await collection.aggregate([
|
|
40940
|
+
{ $match: searchQuery },
|
|
40941
|
+
{
|
|
40942
|
+
$facet: {
|
|
40943
|
+
totalCount: [{ $count: "count" }],
|
|
40944
|
+
items: [
|
|
40945
|
+
{ $sort: { siteName: 1 } },
|
|
40946
|
+
{ $skip: page * limit },
|
|
40947
|
+
{ $limit: limit }
|
|
40948
|
+
]
|
|
40949
|
+
}
|
|
40950
|
+
}
|
|
40951
|
+
]).toArray();
|
|
40952
|
+
const total = result[0].totalCount[0]?.count || 0;
|
|
40953
|
+
const items = result[0].items;
|
|
40954
|
+
return (0, import_node_server_utils195.paginate)(items, page, limit, total);
|
|
40955
|
+
} catch (error) {
|
|
40956
|
+
throw new Error(error.message || "Server Internal Error");
|
|
40957
|
+
}
|
|
40958
|
+
}
|
|
40959
|
+
async function getManpowerRemarksBySiteId(_id, date, serviceProviderId) {
|
|
40960
|
+
try {
|
|
40961
|
+
_id = new import_mongodb110.ObjectId(_id);
|
|
40962
|
+
serviceProviderId = new import_mongodb110.ObjectId(serviceProviderId);
|
|
40963
|
+
} catch (error) {
|
|
40964
|
+
throw new Error("Invalid Site ID format.");
|
|
40965
|
+
}
|
|
40966
|
+
try {
|
|
40967
|
+
const data = await collection.findOne({
|
|
40968
|
+
siteId: _id,
|
|
40969
|
+
createdAtSGT: date,
|
|
40970
|
+
serviceProviderId
|
|
40971
|
+
});
|
|
40972
|
+
return data;
|
|
40973
|
+
} catch (error) {
|
|
40974
|
+
throw error;
|
|
40975
|
+
}
|
|
40976
|
+
}
|
|
40977
|
+
async function updateManpowerRemarks(_id, value) {
|
|
40978
|
+
try {
|
|
40979
|
+
_id = new import_mongodb110.ObjectId(_id);
|
|
40980
|
+
} catch (error) {
|
|
40981
|
+
throw new import_node_server_utils195.BadRequestError("Invalid ID format.");
|
|
40982
|
+
}
|
|
40983
|
+
try {
|
|
40984
|
+
if (value.createdBy) {
|
|
40985
|
+
value.createdBy = new import_mongodb110.ObjectId(value.createdBy);
|
|
40986
|
+
}
|
|
40987
|
+
const updateValue = {
|
|
40988
|
+
...value,
|
|
40989
|
+
updatedAt: /* @__PURE__ */ new Date()
|
|
40990
|
+
};
|
|
40991
|
+
const res = await collection.updateOne({ _id }, { $set: updateValue });
|
|
40992
|
+
if (res.modifiedCount === 0) {
|
|
40993
|
+
throw new Error("Unable to update remarks.");
|
|
40994
|
+
}
|
|
40995
|
+
return res.modifiedCount;
|
|
40996
|
+
} catch (error) {
|
|
40997
|
+
throw error;
|
|
40998
|
+
}
|
|
40999
|
+
}
|
|
41000
|
+
async function updateRemarksStatus(_id, value) {
|
|
41001
|
+
try {
|
|
41002
|
+
_id = new import_mongodb110.ObjectId(_id);
|
|
41003
|
+
} catch (error) {
|
|
41004
|
+
throw new import_node_server_utils195.BadRequestError("Invalid ID format.");
|
|
41005
|
+
}
|
|
41006
|
+
try {
|
|
41007
|
+
const updateValue = {
|
|
41008
|
+
...value,
|
|
41009
|
+
updatedAt: /* @__PURE__ */ new Date()
|
|
41010
|
+
};
|
|
41011
|
+
const res = await collection.updateOne({ _id }, { $set: updateValue });
|
|
41012
|
+
if (res.modifiedCount === 0) {
|
|
41013
|
+
throw new Error("Unable to update remarks status.");
|
|
41014
|
+
}
|
|
41015
|
+
return res.modifiedCount;
|
|
41016
|
+
} catch (error) {
|
|
41017
|
+
throw error;
|
|
41018
|
+
}
|
|
41019
|
+
}
|
|
41020
|
+
return {
|
|
41021
|
+
createManpowerRemarks,
|
|
41022
|
+
getManpowerRemarksAllSite,
|
|
41023
|
+
getManpowerRemarksBySiteId,
|
|
41024
|
+
updateManpowerRemarks,
|
|
41025
|
+
updateRemarksStatus
|
|
41026
|
+
};
|
|
41027
|
+
}
|
|
41028
|
+
|
|
41029
|
+
// src/services/manpower-monitoring.service.ts
|
|
41030
|
+
var import_moment_timezone3 = __toESM(require("moment-timezone"));
|
|
40428
41031
|
function useManpowerMonitoringSrvc() {
|
|
40429
41032
|
const {
|
|
40430
41033
|
createManpowerMonitoringSettings: _createManpowerMonitoringSettings
|
|
40431
41034
|
} = useManpowerMonitoringRepo();
|
|
41035
|
+
const { createManpowerRemarks: _createManpowerRemarks } = useManpowerRemarksRepo();
|
|
40432
41036
|
async function createManpowerMonitoringSettings(payload) {
|
|
40433
41037
|
console.log("Im here now at service");
|
|
40434
|
-
const session =
|
|
41038
|
+
const session = import_node_server_utils196.useAtlas.getClient()?.startSession();
|
|
40435
41039
|
if (!session) {
|
|
40436
|
-
throw new
|
|
41040
|
+
throw new import_node_server_utils196.BadRequestError("Database session not available.");
|
|
40437
41041
|
}
|
|
40438
41042
|
await session.startTransaction();
|
|
40439
41043
|
const morningCheckInTime = payload?.shifts?.[payload.shiftType][0]?.checkIn;
|
|
@@ -40442,10 +41046,10 @@ function useManpowerMonitoringSrvc() {
|
|
|
40442
41046
|
const morningAlertFrequencyMins = payload?.shifts?.[payload.shiftType][0]?.alertFrequencyMins;
|
|
40443
41047
|
const afternoonAlertFrequencyMins = payload.shiftType == "3-shifts" ? payload?.shifts?.[payload.shiftType][1]?.alertFrequencyMins : null;
|
|
40444
41048
|
const nightAlertFrequencyMins = payload.shiftType == "3-shifts" ? payload?.shifts?.[payload.shiftType][2]?.alertFrequencyMins : payload?.shifts?.[payload.shiftType][1]?.alertFrequencyMins;
|
|
40445
|
-
const morningAlertTime =
|
|
40446
|
-
const afternoonAlertTime = afternoonCheckInTime ?
|
|
40447
|
-
const nightAlertTime =
|
|
40448
|
-
const nowSGT = (0,
|
|
41049
|
+
const morningAlertTime = import_moment_timezone3.default.tz(morningCheckInTime, "HH:mm", "Asia/Singapore").add(morningAlertFrequencyMins, "minutes").format("HH:mm");
|
|
41050
|
+
const afternoonAlertTime = afternoonCheckInTime ? import_moment_timezone3.default.tz(afternoonCheckInTime, "HH:mm", "Asia/Singapore").add(afternoonAlertFrequencyMins, "minutes").format("HH:mm") : "";
|
|
41051
|
+
const nightAlertTime = import_moment_timezone3.default.tz(nightCheckInTime, "HH:mm", "Asia/Singapore").add(nightAlertFrequencyMins, "minutes").format("HH:mm");
|
|
41052
|
+
const nowSGT = (0, import_moment_timezone3.default)().tz("Asia/Singapore");
|
|
40449
41053
|
console.log("im done preparing the payload");
|
|
40450
41054
|
try {
|
|
40451
41055
|
const remarksPayload = {
|
|
@@ -40491,13 +41095,19 @@ function useManpowerMonitoringSrvc() {
|
|
|
40491
41095
|
updatedAt: "",
|
|
40492
41096
|
status: "active"
|
|
40493
41097
|
};
|
|
40494
|
-
|
|
41098
|
+
const manpowerRemark = await _createManpowerRemarks(
|
|
41099
|
+
remarksPayload,
|
|
41100
|
+
session
|
|
41101
|
+
);
|
|
41102
|
+
if (!manpowerRemark) {
|
|
41103
|
+
throw new Error("Failed to create manpower remarks");
|
|
41104
|
+
}
|
|
40495
41105
|
const result = await _createManpowerMonitoringSettings(payload, session);
|
|
40496
41106
|
await session.commitTransaction();
|
|
40497
41107
|
return result;
|
|
40498
41108
|
} catch (error) {
|
|
40499
41109
|
await session.abortTransaction();
|
|
40500
|
-
|
|
41110
|
+
import_node_server_utils196.logger.error(error.message || error);
|
|
40501
41111
|
console.error("Error creating monitoring settings:", error);
|
|
40502
41112
|
throw new Error(error?.message || "Internal Server Error!");
|
|
40503
41113
|
} finally {
|
|
@@ -40510,8 +41120,8 @@ function useManpowerMonitoringSrvc() {
|
|
|
40510
41120
|
}
|
|
40511
41121
|
|
|
40512
41122
|
// src/controllers/manpower-monitoring.controller.ts
|
|
40513
|
-
var
|
|
40514
|
-
var
|
|
41123
|
+
var import_node_server_utils197 = require("@7365admin1/node-server-utils");
|
|
41124
|
+
var import_joi113 = __toESM(require("joi"));
|
|
40515
41125
|
function useManpowerMonitoringCtrl() {
|
|
40516
41126
|
const {
|
|
40517
41127
|
getAllManpowerSettings: _getAllManpowerSettings,
|
|
@@ -40528,13 +41138,13 @@ function useManpowerMonitoringCtrl() {
|
|
|
40528
41138
|
const payload = { ...req.body };
|
|
40529
41139
|
const { error } = manpowerMonitoringSchema.validate(payload);
|
|
40530
41140
|
if (error) {
|
|
40531
|
-
next(new
|
|
41141
|
+
next(new import_node_server_utils197.BadRequestError(error.message));
|
|
40532
41142
|
return;
|
|
40533
41143
|
}
|
|
40534
41144
|
const result = await _createManpowerMonitoringSettings(payload);
|
|
40535
41145
|
return res.json(result);
|
|
40536
41146
|
} catch (error) {
|
|
40537
|
-
|
|
41147
|
+
import_node_server_utils197.logger.log({ level: "error", message: error.message });
|
|
40538
41148
|
next(error);
|
|
40539
41149
|
return;
|
|
40540
41150
|
}
|
|
@@ -40542,14 +41152,14 @@ function useManpowerMonitoringCtrl() {
|
|
|
40542
41152
|
async function getAllManpowerSettings(req, res, next) {
|
|
40543
41153
|
try {
|
|
40544
41154
|
const { page, search, limit } = req.query;
|
|
40545
|
-
const schema2 =
|
|
40546
|
-
page:
|
|
40547
|
-
limit:
|
|
40548
|
-
search:
|
|
41155
|
+
const schema2 = import_joi113.default.object({
|
|
41156
|
+
page: import_joi113.default.number().optional().allow("", null),
|
|
41157
|
+
limit: import_joi113.default.number().optional().allow("", null),
|
|
41158
|
+
search: import_joi113.default.string().optional().allow("", null)
|
|
40549
41159
|
});
|
|
40550
41160
|
const { error } = schema2.validate({ page, search, limit });
|
|
40551
41161
|
if (error) {
|
|
40552
|
-
next(new
|
|
41162
|
+
next(new import_node_server_utils197.BadRequestError(error.message));
|
|
40553
41163
|
return;
|
|
40554
41164
|
}
|
|
40555
41165
|
const result = await _getAllManpowerSettings({
|
|
@@ -40559,7 +41169,7 @@ function useManpowerMonitoringCtrl() {
|
|
|
40559
41169
|
});
|
|
40560
41170
|
return res.json(result);
|
|
40561
41171
|
} catch (error) {
|
|
40562
|
-
|
|
41172
|
+
import_node_server_utils197.logger.log({ level: "error", message: error.message });
|
|
40563
41173
|
next(error);
|
|
40564
41174
|
return;
|
|
40565
41175
|
}
|
|
@@ -40568,64 +41178,64 @@ function useManpowerMonitoringCtrl() {
|
|
|
40568
41178
|
try {
|
|
40569
41179
|
const _id = req.params.id;
|
|
40570
41180
|
const serviceProviderId = req.params.serviceProviderId;
|
|
40571
|
-
const schema2 =
|
|
40572
|
-
_id:
|
|
40573
|
-
serviceProviderId:
|
|
41181
|
+
const schema2 = import_joi113.default.object({
|
|
41182
|
+
_id: import_joi113.default.string().hex().required(),
|
|
41183
|
+
serviceProviderId: import_joi113.default.string().hex().required()
|
|
40574
41184
|
});
|
|
40575
41185
|
const { error } = schema2.validate({ _id, serviceProviderId });
|
|
40576
41186
|
if (error) {
|
|
40577
|
-
next(new
|
|
41187
|
+
next(new import_node_server_utils197.BadRequestError(error.message));
|
|
40578
41188
|
return;
|
|
40579
41189
|
}
|
|
40580
41190
|
const result = await _getManpowerSettingsBySiteId(_id, serviceProviderId);
|
|
40581
41191
|
return res.json(result);
|
|
40582
41192
|
} catch (error) {
|
|
40583
|
-
|
|
41193
|
+
import_node_server_utils197.logger.log({ level: "error", message: error.message });
|
|
40584
41194
|
next(error);
|
|
40585
41195
|
return;
|
|
40586
41196
|
}
|
|
40587
41197
|
}
|
|
40588
41198
|
async function updateManpowerMonitoringSettings(req, res, next) {
|
|
40589
41199
|
try {
|
|
40590
|
-
const validation =
|
|
40591
|
-
_id:
|
|
40592
|
-
shiftType:
|
|
40593
|
-
enabled:
|
|
40594
|
-
shifts:
|
|
40595
|
-
"2-shifts":
|
|
40596
|
-
"3-shifts":
|
|
41200
|
+
const validation = import_joi113.default.object({
|
|
41201
|
+
_id: import_joi113.default.string().hex().required(),
|
|
41202
|
+
shiftType: import_joi113.default.string().optional().allow("", null),
|
|
41203
|
+
enabled: import_joi113.default.boolean().required(),
|
|
41204
|
+
shifts: import_joi113.default.object({
|
|
41205
|
+
"2-shifts": import_joi113.default.array().items(shiftSchema).optional(),
|
|
41206
|
+
"3-shifts": import_joi113.default.array().items(shiftSchema).optional()
|
|
40597
41207
|
}).optional(),
|
|
40598
|
-
emails:
|
|
41208
|
+
emails: import_joi113.default.array().items(import_joi113.default.string().email()).optional()
|
|
40599
41209
|
});
|
|
40600
41210
|
const _id = req.params.id;
|
|
40601
41211
|
const payload = { ...req.body };
|
|
40602
41212
|
console.log("_id", _id);
|
|
40603
41213
|
const { error } = validation.validate({ _id, ...payload });
|
|
40604
41214
|
if (error) {
|
|
40605
|
-
next(new
|
|
41215
|
+
next(new import_node_server_utils197.BadRequestError(error.message));
|
|
40606
41216
|
return;
|
|
40607
41217
|
}
|
|
40608
41218
|
const result = await _updateManpowerMonitoringSettings(_id, payload);
|
|
40609
41219
|
return res.json(result);
|
|
40610
41220
|
} catch (error) {
|
|
40611
|
-
|
|
41221
|
+
import_node_server_utils197.logger.log({ level: "error", message: error.message });
|
|
40612
41222
|
next(error);
|
|
40613
41223
|
return;
|
|
40614
41224
|
}
|
|
40615
41225
|
}
|
|
40616
41226
|
async function multipleManpowerMonitoringSettings(req, res, next) {
|
|
40617
41227
|
try {
|
|
40618
|
-
const validation =
|
|
41228
|
+
const validation = import_joi113.default.array().items(manpowerMonitoringSchema);
|
|
40619
41229
|
const payload = req.body;
|
|
40620
41230
|
const { error } = validation.validate(payload);
|
|
40621
41231
|
if (error) {
|
|
40622
|
-
next(new
|
|
41232
|
+
next(new import_node_server_utils197.BadRequestError(error.message));
|
|
40623
41233
|
return;
|
|
40624
41234
|
}
|
|
40625
41235
|
const result = await _multipleManpowerMonitoringSettings(payload);
|
|
40626
41236
|
return res.json(result);
|
|
40627
41237
|
} catch (error) {
|
|
40628
|
-
|
|
41238
|
+
import_node_server_utils197.logger.log({ level: "error", message: error.message });
|
|
40629
41239
|
next(error);
|
|
40630
41240
|
return;
|
|
40631
41241
|
}
|
|
@@ -40633,18 +41243,18 @@ function useManpowerMonitoringCtrl() {
|
|
|
40633
41243
|
async function getAllSites(req, res, next) {
|
|
40634
41244
|
try {
|
|
40635
41245
|
const serviceProviderId = req.query.serviceProviderId;
|
|
40636
|
-
const validation =
|
|
40637
|
-
serviceProviderId:
|
|
41246
|
+
const validation = import_joi113.default.object({
|
|
41247
|
+
serviceProviderId: import_joi113.default.string().hex().required()
|
|
40638
41248
|
});
|
|
40639
41249
|
const { error } = validation.validate({ serviceProviderId });
|
|
40640
41250
|
if (error) {
|
|
40641
|
-
next(new
|
|
41251
|
+
next(new import_node_server_utils197.BadRequestError(error.message));
|
|
40642
41252
|
return;
|
|
40643
41253
|
}
|
|
40644
41254
|
const result = await _getAllSites(serviceProviderId);
|
|
40645
41255
|
return res.json(result);
|
|
40646
41256
|
} catch (error) {
|
|
40647
|
-
|
|
41257
|
+
import_node_server_utils197.logger.log({ level: "error", message: error.message });
|
|
40648
41258
|
next(error);
|
|
40649
41259
|
return;
|
|
40650
41260
|
}
|
|
@@ -40660,27 +41270,27 @@ function useManpowerMonitoringCtrl() {
|
|
|
40660
41270
|
}
|
|
40661
41271
|
|
|
40662
41272
|
// src/models/manpower-designations.model.ts
|
|
40663
|
-
var
|
|
40664
|
-
var
|
|
40665
|
-
var designationsSchema =
|
|
40666
|
-
title:
|
|
40667
|
-
shifts:
|
|
40668
|
-
morningShift:
|
|
40669
|
-
afternoonShift:
|
|
40670
|
-
nightShift:
|
|
41273
|
+
var import_joi114 = __toESM(require("joi"));
|
|
41274
|
+
var import_mongodb111 = require("mongodb");
|
|
41275
|
+
var designationsSchema = import_joi114.default.object({
|
|
41276
|
+
title: import_joi114.default.string().required(),
|
|
41277
|
+
shifts: import_joi114.default.object({
|
|
41278
|
+
morningShift: import_joi114.default.number().required(),
|
|
41279
|
+
afternoonShift: import_joi114.default.number().optional(),
|
|
41280
|
+
nightShift: import_joi114.default.number().required()
|
|
40671
41281
|
}).required()
|
|
40672
41282
|
});
|
|
40673
|
-
var manpowerDesignationsSchema =
|
|
40674
|
-
siteId:
|
|
40675
|
-
siteName:
|
|
40676
|
-
serviceProviderId:
|
|
40677
|
-
designations:
|
|
40678
|
-
createdBy:
|
|
40679
|
-
createdByName:
|
|
41283
|
+
var manpowerDesignationsSchema = import_joi114.default.object({
|
|
41284
|
+
siteId: import_joi114.default.string().hex().required(),
|
|
41285
|
+
siteName: import_joi114.default.string().required(),
|
|
41286
|
+
serviceProviderId: import_joi114.default.string().hex().optional(),
|
|
41287
|
+
designations: import_joi114.default.array().items(designationsSchema).required(),
|
|
41288
|
+
createdBy: import_joi114.default.string().hex().required(),
|
|
41289
|
+
createdByName: import_joi114.default.string().optional().allow("", null)
|
|
40680
41290
|
});
|
|
40681
41291
|
var MManpowerDesignations = class {
|
|
40682
41292
|
constructor(data) {
|
|
40683
|
-
this._id = new
|
|
41293
|
+
this._id = new import_mongodb111.ObjectId();
|
|
40684
41294
|
this.siteId = data.siteId || "";
|
|
40685
41295
|
this.siteName = data.siteName || "";
|
|
40686
41296
|
this.serviceProviderId = data.serviceProviderId || "";
|
|
@@ -40693,10 +41303,10 @@ var MManpowerDesignations = class {
|
|
|
40693
41303
|
};
|
|
40694
41304
|
|
|
40695
41305
|
// src/repositories/manpower-designations.repo.ts
|
|
40696
|
-
var
|
|
40697
|
-
var
|
|
41306
|
+
var import_node_server_utils198 = require("@7365admin1/node-server-utils");
|
|
41307
|
+
var import_mongodb112 = require("mongodb");
|
|
40698
41308
|
function useManpowerDesignationRepo() {
|
|
40699
|
-
const db =
|
|
41309
|
+
const db = import_node_server_utils198.useAtlas.getDb();
|
|
40700
41310
|
if (!db) {
|
|
40701
41311
|
throw new Error("Unable to connect to server.");
|
|
40702
41312
|
}
|
|
@@ -40706,11 +41316,11 @@ function useManpowerDesignationRepo() {
|
|
|
40706
41316
|
try {
|
|
40707
41317
|
value = new MManpowerDesignations(value);
|
|
40708
41318
|
if (value.createdBy)
|
|
40709
|
-
value.createdBy = new
|
|
41319
|
+
value.createdBy = new import_mongodb112.ObjectId(value.createdBy);
|
|
40710
41320
|
if (value.siteId)
|
|
40711
|
-
value.siteId = new
|
|
41321
|
+
value.siteId = new import_mongodb112.ObjectId(value.siteId);
|
|
40712
41322
|
if (value.serviceProviderId)
|
|
40713
|
-
value.serviceProviderId = new
|
|
41323
|
+
value.serviceProviderId = new import_mongodb112.ObjectId(value.serviceProviderId);
|
|
40714
41324
|
const result = await collection.insertOne(value);
|
|
40715
41325
|
return result;
|
|
40716
41326
|
} catch (error) {
|
|
@@ -40719,8 +41329,8 @@ function useManpowerDesignationRepo() {
|
|
|
40719
41329
|
}
|
|
40720
41330
|
async function getManpowerDesignationsBySiteId(_id, serviceProviderId) {
|
|
40721
41331
|
try {
|
|
40722
|
-
_id = new
|
|
40723
|
-
serviceProviderId = new
|
|
41332
|
+
_id = new import_mongodb112.ObjectId(_id);
|
|
41333
|
+
serviceProviderId = new import_mongodb112.ObjectId(serviceProviderId);
|
|
40724
41334
|
} catch (error) {
|
|
40725
41335
|
throw new Error("Invalid Site ID format.");
|
|
40726
41336
|
}
|
|
@@ -40736,7 +41346,7 @@ function useManpowerDesignationRepo() {
|
|
|
40736
41346
|
}
|
|
40737
41347
|
async function updateManpowerDesignations(_id, value) {
|
|
40738
41348
|
try {
|
|
40739
|
-
_id = new
|
|
41349
|
+
_id = new import_mongodb112.ObjectId(_id);
|
|
40740
41350
|
} catch (error) {
|
|
40741
41351
|
throw new Error("Invalid ID format.");
|
|
40742
41352
|
}
|
|
@@ -40762,8 +41372,8 @@ function useManpowerDesignationRepo() {
|
|
|
40762
41372
|
}
|
|
40763
41373
|
|
|
40764
41374
|
// src/controllers/manpower-designations.controller.ts
|
|
40765
|
-
var
|
|
40766
|
-
var
|
|
41375
|
+
var import_node_server_utils199 = require("@7365admin1/node-server-utils");
|
|
41376
|
+
var import_joi115 = __toESM(require("joi"));
|
|
40767
41377
|
function useManpowerDesignationCtrl() {
|
|
40768
41378
|
const {
|
|
40769
41379
|
createManpowerDesignations: _createManpowerDesignations,
|
|
@@ -40775,13 +41385,13 @@ function useManpowerDesignationCtrl() {
|
|
|
40775
41385
|
const payload = { ...req.body };
|
|
40776
41386
|
const { error } = manpowerDesignationsSchema.validate(payload);
|
|
40777
41387
|
if (error) {
|
|
40778
|
-
next(new
|
|
41388
|
+
next(new import_node_server_utils199.BadRequestError(error.message));
|
|
40779
41389
|
return;
|
|
40780
41390
|
}
|
|
40781
41391
|
const result = await _createManpowerDesignations(payload);
|
|
40782
41392
|
return res.json(result);
|
|
40783
41393
|
} catch (error) {
|
|
40784
|
-
|
|
41394
|
+
import_node_server_utils199.logger.log({ level: "error", message: error.message });
|
|
40785
41395
|
next(error);
|
|
40786
41396
|
return;
|
|
40787
41397
|
}
|
|
@@ -40789,13 +41399,13 @@ function useManpowerDesignationCtrl() {
|
|
|
40789
41399
|
async function getManpowerSettingsBySiteId(req, res, next) {
|
|
40790
41400
|
try {
|
|
40791
41401
|
const { id, serviceProviderId } = req.params;
|
|
40792
|
-
const schema2 =
|
|
40793
|
-
id:
|
|
40794
|
-
serviceProviderId:
|
|
41402
|
+
const schema2 = import_joi115.default.object({
|
|
41403
|
+
id: import_joi115.default.string().hex().required(),
|
|
41404
|
+
serviceProviderId: import_joi115.default.string().hex().required()
|
|
40795
41405
|
});
|
|
40796
41406
|
const { error } = schema2.validate({ id, serviceProviderId });
|
|
40797
41407
|
if (error) {
|
|
40798
|
-
next(new
|
|
41408
|
+
next(new import_node_server_utils199.BadRequestError(error.message));
|
|
40799
41409
|
return;
|
|
40800
41410
|
}
|
|
40801
41411
|
const result = await _getManpowerDesignationsBySiteId(
|
|
@@ -40804,28 +41414,28 @@ function useManpowerDesignationCtrl() {
|
|
|
40804
41414
|
);
|
|
40805
41415
|
return res.json(result);
|
|
40806
41416
|
} catch (error) {
|
|
40807
|
-
|
|
41417
|
+
import_node_server_utils199.logger.log({ level: "error", message: error.message });
|
|
40808
41418
|
next(error);
|
|
40809
41419
|
return;
|
|
40810
41420
|
}
|
|
40811
41421
|
}
|
|
40812
41422
|
async function updateManpowerDesignations(req, res, next) {
|
|
40813
41423
|
try {
|
|
40814
|
-
const validation =
|
|
40815
|
-
_id:
|
|
40816
|
-
designations:
|
|
41424
|
+
const validation = import_joi115.default.object({
|
|
41425
|
+
_id: import_joi115.default.string().hex().required(),
|
|
41426
|
+
designations: import_joi115.default.array().items(designationsSchema).required()
|
|
40817
41427
|
});
|
|
40818
41428
|
const _id = req.params.id;
|
|
40819
41429
|
const payload = { ...req.body };
|
|
40820
41430
|
const { error } = validation.validate({ _id, ...payload });
|
|
40821
41431
|
if (error) {
|
|
40822
|
-
next(new
|
|
41432
|
+
next(new import_node_server_utils199.BadRequestError(error.message));
|
|
40823
41433
|
return;
|
|
40824
41434
|
}
|
|
40825
41435
|
const result = await _updateManpowerDesignations(_id, payload);
|
|
40826
41436
|
return res.json(result);
|
|
40827
41437
|
} catch (error) {
|
|
40828
|
-
|
|
41438
|
+
import_node_server_utils199.logger.log({ level: "error", message: error.message });
|
|
40829
41439
|
next(error);
|
|
40830
41440
|
return;
|
|
40831
41441
|
}
|
|
@@ -40838,20 +41448,30 @@ function useManpowerDesignationCtrl() {
|
|
|
40838
41448
|
}
|
|
40839
41449
|
|
|
40840
41450
|
// src/models/overnight-parking.model.ts
|
|
40841
|
-
var
|
|
40842
|
-
var
|
|
40843
|
-
var dayScheduleSchema =
|
|
40844
|
-
isEnabled:
|
|
40845
|
-
startTime:
|
|
41451
|
+
var import_joi116 = __toESM(require("joi"));
|
|
41452
|
+
var import_mongodb113 = require("mongodb");
|
|
41453
|
+
var dayScheduleSchema = import_joi116.default.object({
|
|
41454
|
+
isEnabled: import_joi116.default.boolean().required(),
|
|
41455
|
+
startTime: import_joi116.default.string().pattern(/^([01]\d|2[0-3]):([0-5]\d)$/).optional().allow(null, "").messages({
|
|
40846
41456
|
"string.pattern.base": "startTime must be in HH:mm format"
|
|
40847
41457
|
}),
|
|
40848
|
-
endTime:
|
|
41458
|
+
endTime: import_joi116.default.string().pattern(/^([01]\d|2[0-3]):([0-5]\d)$/).optional().allow(null, "").messages({
|
|
40849
41459
|
"string.pattern.base": "endTime must be in HH:mm format"
|
|
40850
41460
|
})
|
|
40851
|
-
}).
|
|
40852
|
-
var
|
|
40853
|
-
|
|
40854
|
-
|
|
41461
|
+
}).optional().allow(null);
|
|
41462
|
+
var DayOfWeek = /* @__PURE__ */ ((DayOfWeek2) => {
|
|
41463
|
+
DayOfWeek2["SUNDAY"] = "sunday";
|
|
41464
|
+
DayOfWeek2["MONDAY"] = "monday";
|
|
41465
|
+
DayOfWeek2["TUESDAY"] = "tuesday";
|
|
41466
|
+
DayOfWeek2["WEDNESDAY"] = "wednesday";
|
|
41467
|
+
DayOfWeek2["THURSDAY"] = "thursday";
|
|
41468
|
+
DayOfWeek2["FRIDAY"] = "friday";
|
|
41469
|
+
DayOfWeek2["SATURDAY"] = "saturday";
|
|
41470
|
+
return DayOfWeek2;
|
|
41471
|
+
})(DayOfWeek || {});
|
|
41472
|
+
var schemaOvernightParkingApprovalHours = import_joi116.default.object({
|
|
41473
|
+
_id: import_joi116.default.string().hex().length(24).optional(),
|
|
41474
|
+
site: import_joi116.default.string().hex().length(24).required(),
|
|
40855
41475
|
monday: dayScheduleSchema,
|
|
40856
41476
|
tuesday: dayScheduleSchema,
|
|
40857
41477
|
wednesday: dayScheduleSchema,
|
|
@@ -40859,9 +41479,10 @@ var schemaOvernightParkingApprovalHours = import_joi115.default.object({
|
|
|
40859
41479
|
friday: dayScheduleSchema,
|
|
40860
41480
|
saturday: dayScheduleSchema,
|
|
40861
41481
|
sunday: dayScheduleSchema,
|
|
40862
|
-
|
|
40863
|
-
|
|
40864
|
-
|
|
41482
|
+
autoApproveOvernightParking: import_joi116.default.boolean().optional().allow(null).default(false),
|
|
41483
|
+
createdAt: import_joi116.default.date().optional(),
|
|
41484
|
+
updatedAt: import_joi116.default.date().optional(),
|
|
41485
|
+
deletedAt: import_joi116.default.date().optional().allow(null)
|
|
40865
41486
|
});
|
|
40866
41487
|
function MOvernightParkingApprovalHours(value) {
|
|
40867
41488
|
const { error } = schemaOvernightParkingApprovalHours.validate(value);
|
|
@@ -40870,29 +41491,37 @@ function MOvernightParkingApprovalHours(value) {
|
|
|
40870
41491
|
}
|
|
40871
41492
|
if (value.site && typeof value.site === "string") {
|
|
40872
41493
|
try {
|
|
40873
|
-
value.site = new
|
|
41494
|
+
value.site = new import_mongodb113.ObjectId(value.site);
|
|
40874
41495
|
} catch {
|
|
40875
41496
|
throw new Error("Invalid site ID.");
|
|
40876
41497
|
}
|
|
40877
41498
|
}
|
|
40878
41499
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
40879
41500
|
return {
|
|
40880
|
-
|
|
41501
|
+
site: value.site,
|
|
41502
|
+
monday: value.monday ?? null,
|
|
41503
|
+
tuesday: value.tuesday ?? null,
|
|
41504
|
+
wednesday: value.wednesday ?? null,
|
|
41505
|
+
thursday: value.thursday ?? null,
|
|
41506
|
+
friday: value.friday ?? null,
|
|
41507
|
+
saturday: value.saturday ?? null,
|
|
41508
|
+
sunday: value.sunday ?? null,
|
|
41509
|
+
autoApproveOvernightParking: value.autoApproveOvernightParking ?? false,
|
|
40881
41510
|
createdAt: value.createdAt ?? now,
|
|
40882
41511
|
updatedAt: value.updatedAt ?? now
|
|
40883
41512
|
};
|
|
40884
41513
|
}
|
|
40885
41514
|
|
|
40886
41515
|
// src/repositories/overnight-parking.repo.ts
|
|
40887
|
-
var
|
|
41516
|
+
var import_node_server_utils200 = require("@7365admin1/node-server-utils");
|
|
40888
41517
|
var overnight_parking_namespace_collection = "site.overnight-parking";
|
|
40889
41518
|
function useOvernightParkingRepo() {
|
|
40890
|
-
const db =
|
|
41519
|
+
const db = import_node_server_utils200.useAtlas.getDb();
|
|
40891
41520
|
if (!db) {
|
|
40892
|
-
throw new
|
|
41521
|
+
throw new import_node_server_utils200.InternalServerError("Unable to connect to server.");
|
|
40893
41522
|
}
|
|
40894
41523
|
const collection = db.collection(overnight_parking_namespace_collection);
|
|
40895
|
-
const { delNamespace, setCache, getCache } = (0,
|
|
41524
|
+
const { delNamespace, setCache, getCache } = (0, import_node_server_utils200.useCache)(
|
|
40896
41525
|
overnight_parking_namespace_collection
|
|
40897
41526
|
);
|
|
40898
41527
|
async function createIndexes() {
|
|
@@ -40916,7 +41545,7 @@ function useOvernightParkingRepo() {
|
|
|
40916
41545
|
await collection.createIndexes(indexesToCreate);
|
|
40917
41546
|
}
|
|
40918
41547
|
} catch (error) {
|
|
40919
|
-
throw new
|
|
41548
|
+
throw new import_node_server_utils200.InternalServerError("Failed to create collection indexes.");
|
|
40920
41549
|
}
|
|
40921
41550
|
}
|
|
40922
41551
|
async function upsert(value, session) {
|
|
@@ -40934,6 +41563,7 @@ function useOvernightParkingRepo() {
|
|
|
40934
41563
|
friday: value.friday,
|
|
40935
41564
|
saturday: value.saturday,
|
|
40936
41565
|
sunday: value.sunday,
|
|
41566
|
+
autoApproveOvernightParking: value.autoApproveOvernightParking,
|
|
40937
41567
|
updatedAt: now
|
|
40938
41568
|
},
|
|
40939
41569
|
$setOnInsert: {
|
|
@@ -40944,11 +41574,11 @@ function useOvernightParkingRepo() {
|
|
|
40944
41574
|
{ upsert: true, session }
|
|
40945
41575
|
);
|
|
40946
41576
|
delNamespace().then(() => {
|
|
40947
|
-
|
|
41577
|
+
import_node_server_utils200.logger.info(
|
|
40948
41578
|
`Cache cleared for namespace: ${overnight_parking_namespace_collection}`
|
|
40949
41579
|
);
|
|
40950
41580
|
}).catch((err) => {
|
|
40951
|
-
|
|
41581
|
+
import_node_server_utils200.logger.error(
|
|
40952
41582
|
`Failed to clear cache for namespace: ${overnight_parking_namespace_collection}`,
|
|
40953
41583
|
err
|
|
40954
41584
|
);
|
|
@@ -40959,13 +41589,13 @@ function useOvernightParkingRepo() {
|
|
|
40959
41589
|
}
|
|
40960
41590
|
}
|
|
40961
41591
|
async function getSiteOvernightParking(site) {
|
|
40962
|
-
const siteId = (0,
|
|
40963
|
-
const cacheKey = (0,
|
|
41592
|
+
const siteId = (0, import_node_server_utils200.toObjectId)(site);
|
|
41593
|
+
const cacheKey = (0, import_node_server_utils200.makeCacheKey)(overnight_parking_namespace_collection, {
|
|
40964
41594
|
site
|
|
40965
41595
|
});
|
|
40966
41596
|
const cachedData = await getCache(cacheKey);
|
|
40967
41597
|
if (cachedData) {
|
|
40968
|
-
|
|
41598
|
+
import_node_server_utils200.logger.info(`Cache hit for key: ${cacheKey}`);
|
|
40969
41599
|
return cachedData;
|
|
40970
41600
|
}
|
|
40971
41601
|
try {
|
|
@@ -40974,9 +41604,9 @@ function useOvernightParkingRepo() {
|
|
|
40974
41604
|
deletedAt: null
|
|
40975
41605
|
});
|
|
40976
41606
|
setCache(cacheKey, data, 15 * 60).then(() => {
|
|
40977
|
-
|
|
41607
|
+
import_node_server_utils200.logger.info(`Cache set for key: ${cacheKey}`);
|
|
40978
41608
|
}).catch((err) => {
|
|
40979
|
-
|
|
41609
|
+
import_node_server_utils200.logger.error(`Failed to set cache for key: ${cacheKey}`, err);
|
|
40980
41610
|
});
|
|
40981
41611
|
return data;
|
|
40982
41612
|
} catch (error) {
|
|
@@ -40991,8 +41621,8 @@ function useOvernightParkingRepo() {
|
|
|
40991
41621
|
}
|
|
40992
41622
|
|
|
40993
41623
|
// src/controllers/overnight-parking.controller.ts
|
|
40994
|
-
var
|
|
40995
|
-
var
|
|
41624
|
+
var import_joi117 = __toESM(require("joi"));
|
|
41625
|
+
var import_node_server_utils201 = require("@7365admin1/node-server-utils");
|
|
40996
41626
|
function useOvernightParkingController() {
|
|
40997
41627
|
const { upsert: _upsert, getSiteOvernightParking: _getSiteOvernightParking } = useOvernightParkingRepo();
|
|
40998
41628
|
async function upsert(req, res, next) {
|
|
@@ -41007,22 +41637,22 @@ function useOvernightParkingController() {
|
|
|
41007
41637
|
);
|
|
41008
41638
|
if (error) {
|
|
41009
41639
|
const messages = error.details.map((d) => d.message).join(", ");
|
|
41010
|
-
|
|
41011
|
-
next(new
|
|
41640
|
+
import_node_server_utils201.logger.log({ level: "error", message: messages });
|
|
41641
|
+
next(new import_node_server_utils201.BadRequestError(messages));
|
|
41012
41642
|
return;
|
|
41013
41643
|
}
|
|
41014
41644
|
const data = await _upsert(value);
|
|
41015
41645
|
res.status(201).json(data);
|
|
41016
41646
|
return;
|
|
41017
41647
|
} catch (error) {
|
|
41018
|
-
|
|
41648
|
+
import_node_server_utils201.logger.log({ level: "error", message: error.message });
|
|
41019
41649
|
next(error);
|
|
41020
41650
|
return;
|
|
41021
41651
|
}
|
|
41022
41652
|
}
|
|
41023
41653
|
async function getSiteOvernightParking(req, res, next) {
|
|
41024
|
-
const schema2 =
|
|
41025
|
-
site:
|
|
41654
|
+
const schema2 = import_joi117.default.object({
|
|
41655
|
+
site: import_joi117.default.string().hex().length(24).required()
|
|
41026
41656
|
});
|
|
41027
41657
|
try {
|
|
41028
41658
|
const { error, value } = schema2.validate(
|
|
@@ -41033,8 +41663,8 @@ function useOvernightParkingController() {
|
|
|
41033
41663
|
);
|
|
41034
41664
|
if (error) {
|
|
41035
41665
|
const messages = error.details.map((d) => d.message).join(", ");
|
|
41036
|
-
|
|
41037
|
-
next(new
|
|
41666
|
+
import_node_server_utils201.logger.log({ level: "error", message: messages });
|
|
41667
|
+
next(new import_node_server_utils201.BadRequestError(messages));
|
|
41038
41668
|
return;
|
|
41039
41669
|
}
|
|
41040
41670
|
const { site } = value;
|
|
@@ -41042,7 +41672,7 @@ function useOvernightParkingController() {
|
|
|
41042
41672
|
res.status(201).json(data);
|
|
41043
41673
|
return;
|
|
41044
41674
|
} catch (error) {
|
|
41045
|
-
|
|
41675
|
+
import_node_server_utils201.logger.log({ level: "error", message: error.message });
|
|
41046
41676
|
next(error);
|
|
41047
41677
|
return;
|
|
41048
41678
|
}
|
|
@@ -41052,6 +41682,1392 @@ function useOvernightParkingController() {
|
|
|
41052
41682
|
getSiteOvernightParking
|
|
41053
41683
|
};
|
|
41054
41684
|
}
|
|
41685
|
+
|
|
41686
|
+
// src/models/overnight-parking-request.model.ts
|
|
41687
|
+
var import_joi118 = __toESM(require("joi"));
|
|
41688
|
+
var import_node_server_utils202 = require("@7365admin1/node-server-utils");
|
|
41689
|
+
var OvernightParkingRequestStatus = /* @__PURE__ */ ((OvernightParkingRequestStatus2) => {
|
|
41690
|
+
OvernightParkingRequestStatus2["PENDING"] = "pending";
|
|
41691
|
+
OvernightParkingRequestStatus2["APPROVED"] = "approved";
|
|
41692
|
+
OvernightParkingRequestStatus2["REJECTED"] = "rejected";
|
|
41693
|
+
OvernightParkingRequestStatus2["DELETED"] = "deleted";
|
|
41694
|
+
OvernightParkingRequestStatus2["EXPIRED"] = "expired";
|
|
41695
|
+
return OvernightParkingRequestStatus2;
|
|
41696
|
+
})(OvernightParkingRequestStatus || {});
|
|
41697
|
+
var OvernightParkingRequestSort = /* @__PURE__ */ ((OvernightParkingRequestSort2) => {
|
|
41698
|
+
OvernightParkingRequestSort2["ID"] = "_id";
|
|
41699
|
+
OvernightParkingRequestSort2["CREATED_AT"] = "createdAt";
|
|
41700
|
+
return OvernightParkingRequestSort2;
|
|
41701
|
+
})(OvernightParkingRequestSort || {});
|
|
41702
|
+
var schemaOvernightParkingRequest = import_joi118.default.object({
|
|
41703
|
+
_id: import_joi118.default.string().hex().length(24).optional(),
|
|
41704
|
+
site: import_joi118.default.string().hex().length(24).required(),
|
|
41705
|
+
name: import_joi118.default.string().required(),
|
|
41706
|
+
contact: import_joi118.default.string().required(),
|
|
41707
|
+
email: import_joi118.default.string().email().required(),
|
|
41708
|
+
isOvernightParking: import_joi118.default.boolean().optional(),
|
|
41709
|
+
numberOfPassengers: import_joi118.default.number().integer().min(0).optional().default(0),
|
|
41710
|
+
purposeOfVisit: import_joi118.default.string().optional().allow("", null),
|
|
41711
|
+
status: import_joi118.default.string().valid(...Object.values(OvernightParkingRequestStatus)).optional().allow(null, "").default("pending" /* PENDING */),
|
|
41712
|
+
comment: import_joi118.default.string().optional().allow(null, "")
|
|
41713
|
+
});
|
|
41714
|
+
var schemaUpdateOvernightParkingRequest = import_joi118.default.object({
|
|
41715
|
+
_id: import_joi118.default.string().hex().length(24).required(),
|
|
41716
|
+
status: import_joi118.default.string().valid(...Object.values(OvernightParkingRequestStatus)).required(),
|
|
41717
|
+
comment: import_joi118.default.string().optional().allow(null, "")
|
|
41718
|
+
});
|
|
41719
|
+
function MOvernightParkingRequest(value) {
|
|
41720
|
+
const { error } = schemaOvernightParkingRequest.validate(value);
|
|
41721
|
+
if (error) {
|
|
41722
|
+
throw new Error(error.details[0].message);
|
|
41723
|
+
}
|
|
41724
|
+
if (value.site && typeof value.site === "string")
|
|
41725
|
+
value.site = (0, import_node_server_utils202.toObjectId)(value.site);
|
|
41726
|
+
const data = {
|
|
41727
|
+
...value,
|
|
41728
|
+
createdAt: value.createdAt ? new Date(value.createdAt).toISOString() : (/* @__PURE__ */ new Date()).toISOString(),
|
|
41729
|
+
updatedAt: value.updatedAt,
|
|
41730
|
+
deletedAt: value.deletedAt
|
|
41731
|
+
};
|
|
41732
|
+
return data;
|
|
41733
|
+
}
|
|
41734
|
+
|
|
41735
|
+
// src/repositories/overnight-parking-request.repository.ts
|
|
41736
|
+
var import_node_server_utils203 = require("@7365admin1/node-server-utils");
|
|
41737
|
+
var overnight_parking_requests_namespace_collection = "site.overnight-parking-requests";
|
|
41738
|
+
function useOvernightParkingRequestRepo() {
|
|
41739
|
+
const db = import_node_server_utils203.useAtlas.getDb();
|
|
41740
|
+
if (!db) {
|
|
41741
|
+
throw new import_node_server_utils203.InternalServerError("Unable to connect to server.");
|
|
41742
|
+
}
|
|
41743
|
+
const collection = db.collection(
|
|
41744
|
+
overnight_parking_requests_namespace_collection
|
|
41745
|
+
);
|
|
41746
|
+
const { delNamespace, getCache, setCache } = (0, import_node_server_utils203.useCache)(
|
|
41747
|
+
overnight_parking_requests_namespace_collection
|
|
41748
|
+
);
|
|
41749
|
+
async function add(value, session) {
|
|
41750
|
+
try {
|
|
41751
|
+
value = MOvernightParkingRequest(value);
|
|
41752
|
+
const res = await collection.insertOne(value, { session });
|
|
41753
|
+
delNamespace().then(() => {
|
|
41754
|
+
import_node_server_utils203.logger.info(
|
|
41755
|
+
`Cache cleared for namespace: ${overnight_parking_requests_namespace_collection}`
|
|
41756
|
+
);
|
|
41757
|
+
}).catch((err) => {
|
|
41758
|
+
import_node_server_utils203.logger.error(
|
|
41759
|
+
`Failed to clear cache for namespace: ${overnight_parking_requests_namespace_collection}`,
|
|
41760
|
+
err
|
|
41761
|
+
);
|
|
41762
|
+
});
|
|
41763
|
+
return res.insertedId;
|
|
41764
|
+
} catch (error) {
|
|
41765
|
+
throw error;
|
|
41766
|
+
}
|
|
41767
|
+
}
|
|
41768
|
+
async function getAll({
|
|
41769
|
+
site = "",
|
|
41770
|
+
page = 1,
|
|
41771
|
+
limit = 10,
|
|
41772
|
+
sort = {},
|
|
41773
|
+
status = ""
|
|
41774
|
+
}) {
|
|
41775
|
+
page = page ? page - 1 : 0;
|
|
41776
|
+
const skip = page * limit;
|
|
41777
|
+
const siteId = (0, import_node_server_utils203.toObjectId)(site);
|
|
41778
|
+
const query = {
|
|
41779
|
+
site: siteId,
|
|
41780
|
+
...status && { status }
|
|
41781
|
+
};
|
|
41782
|
+
const cacheOptions = {
|
|
41783
|
+
site,
|
|
41784
|
+
page,
|
|
41785
|
+
limit,
|
|
41786
|
+
sort: JSON.stringify(sort),
|
|
41787
|
+
...status && { status }
|
|
41788
|
+
};
|
|
41789
|
+
const cacheKey = (0, import_node_server_utils203.makeCacheKey)(
|
|
41790
|
+
overnight_parking_requests_namespace_collection,
|
|
41791
|
+
cacheOptions
|
|
41792
|
+
);
|
|
41793
|
+
const cachedData = await getCache(cacheKey);
|
|
41794
|
+
if (cachedData) {
|
|
41795
|
+
import_node_server_utils203.logger.info(`Cache hit for key: ${cacheKey}`);
|
|
41796
|
+
return cachedData;
|
|
41797
|
+
}
|
|
41798
|
+
try {
|
|
41799
|
+
const items = await collection.aggregate([
|
|
41800
|
+
{ $match: query },
|
|
41801
|
+
{ $sort: sort },
|
|
41802
|
+
{ $skip: skip },
|
|
41803
|
+
{ $limit: limit }
|
|
41804
|
+
]).toArray();
|
|
41805
|
+
const length = await collection.countDocuments(query);
|
|
41806
|
+
const data = (0, import_node_server_utils203.paginate)(items, page, limit, length);
|
|
41807
|
+
setCache(cacheKey, data, 15 * 60).then(() => {
|
|
41808
|
+
import_node_server_utils203.logger.info(`Cache set for key: ${cacheKey}`);
|
|
41809
|
+
}).catch((err) => {
|
|
41810
|
+
import_node_server_utils203.logger.error(`Failed to set cache for key: ${cacheKey}`, err);
|
|
41811
|
+
});
|
|
41812
|
+
return data;
|
|
41813
|
+
} catch (error) {
|
|
41814
|
+
throw error;
|
|
41815
|
+
}
|
|
41816
|
+
}
|
|
41817
|
+
async function getOvernightParkingRequestById(id) {
|
|
41818
|
+
try {
|
|
41819
|
+
const cacheKey = (0, import_node_server_utils203.makeCacheKey)(
|
|
41820
|
+
overnight_parking_requests_namespace_collection,
|
|
41821
|
+
{ id }
|
|
41822
|
+
);
|
|
41823
|
+
const cachedData = await getCache(cacheKey);
|
|
41824
|
+
if (cachedData) {
|
|
41825
|
+
import_node_server_utils203.logger.info(`Cache hit for key: ${cacheKey}`);
|
|
41826
|
+
return cachedData;
|
|
41827
|
+
}
|
|
41828
|
+
const _id = (0, import_node_server_utils203.toObjectId)(id);
|
|
41829
|
+
const data = await collection.findOne({ _id });
|
|
41830
|
+
if (!data)
|
|
41831
|
+
throw new import_node_server_utils203.BadRequestError("Overnight parking request not found.");
|
|
41832
|
+
setCache(cacheKey, data, 15 * 60).then(() => {
|
|
41833
|
+
import_node_server_utils203.logger.info(`Cache set for key: ${cacheKey}`);
|
|
41834
|
+
}).catch((err) => {
|
|
41835
|
+
import_node_server_utils203.logger.error(`Failed to set cache for key: ${cacheKey}`, err);
|
|
41836
|
+
});
|
|
41837
|
+
return data;
|
|
41838
|
+
} catch (error) {
|
|
41839
|
+
throw error;
|
|
41840
|
+
}
|
|
41841
|
+
}
|
|
41842
|
+
async function updateOvernightParkingRequestById(id, value, session) {
|
|
41843
|
+
try {
|
|
41844
|
+
const _id = (0, import_node_server_utils203.toObjectId)(id);
|
|
41845
|
+
value.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
41846
|
+
const data = await collection.updateOne(
|
|
41847
|
+
{ _id },
|
|
41848
|
+
{ $set: value },
|
|
41849
|
+
{ session }
|
|
41850
|
+
);
|
|
41851
|
+
if (data.matchedCount === 0)
|
|
41852
|
+
throw new import_node_server_utils203.BadRequestError("Overnight parking request not found.");
|
|
41853
|
+
delNamespace().then(() => {
|
|
41854
|
+
import_node_server_utils203.logger.info(
|
|
41855
|
+
`Cache cleared for namespace: ${overnight_parking_requests_namespace_collection}`
|
|
41856
|
+
);
|
|
41857
|
+
}).catch((err) => {
|
|
41858
|
+
import_node_server_utils203.logger.error(
|
|
41859
|
+
`Failed to clear cache for namespace: ${overnight_parking_requests_namespace_collection}`,
|
|
41860
|
+
err
|
|
41861
|
+
);
|
|
41862
|
+
});
|
|
41863
|
+
return data;
|
|
41864
|
+
} catch (error) {
|
|
41865
|
+
throw error;
|
|
41866
|
+
}
|
|
41867
|
+
}
|
|
41868
|
+
async function deleteOvernightParkingRequestById(id, session) {
|
|
41869
|
+
try {
|
|
41870
|
+
const _id = (0, import_node_server_utils203.toObjectId)(id);
|
|
41871
|
+
const value = {
|
|
41872
|
+
deletedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
41873
|
+
status: "deleted" /* DELETED */
|
|
41874
|
+
};
|
|
41875
|
+
const data = await collection.updateOne(
|
|
41876
|
+
{ _id },
|
|
41877
|
+
{ $set: value },
|
|
41878
|
+
{ session }
|
|
41879
|
+
);
|
|
41880
|
+
if (data.matchedCount === 0)
|
|
41881
|
+
throw new import_node_server_utils203.BadRequestError("Overnight parking request not found.");
|
|
41882
|
+
delNamespace().then(() => {
|
|
41883
|
+
import_node_server_utils203.logger.info(
|
|
41884
|
+
`Cache cleared for namespace: ${overnight_parking_requests_namespace_collection}`
|
|
41885
|
+
);
|
|
41886
|
+
}).catch((err) => {
|
|
41887
|
+
import_node_server_utils203.logger.error(
|
|
41888
|
+
`Failed to clear cache for namespace: ${overnight_parking_requests_namespace_collection}`,
|
|
41889
|
+
err
|
|
41890
|
+
);
|
|
41891
|
+
});
|
|
41892
|
+
return data;
|
|
41893
|
+
} catch (error) {
|
|
41894
|
+
throw error;
|
|
41895
|
+
}
|
|
41896
|
+
}
|
|
41897
|
+
async function updateExpiredRequests(site, session) {
|
|
41898
|
+
try {
|
|
41899
|
+
const _site = (0, import_node_server_utils203.toObjectId)(site);
|
|
41900
|
+
const value = {
|
|
41901
|
+
status: "expired" /* EXPIRED */
|
|
41902
|
+
};
|
|
41903
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
41904
|
+
const data = await collection.updateMany(
|
|
41905
|
+
{
|
|
41906
|
+
site: _site,
|
|
41907
|
+
createdAt: { $lte: now },
|
|
41908
|
+
status: "pending" /* PENDING */
|
|
41909
|
+
},
|
|
41910
|
+
{ $set: value },
|
|
41911
|
+
{ session }
|
|
41912
|
+
);
|
|
41913
|
+
delNamespace().then(() => {
|
|
41914
|
+
import_node_server_utils203.logger.info(
|
|
41915
|
+
`Cache cleared for namespace: ${overnight_parking_requests_namespace_collection}`
|
|
41916
|
+
);
|
|
41917
|
+
}).catch((err) => {
|
|
41918
|
+
import_node_server_utils203.logger.error(
|
|
41919
|
+
`Failed to clear cache for namespace: ${overnight_parking_requests_namespace_collection}`,
|
|
41920
|
+
err
|
|
41921
|
+
);
|
|
41922
|
+
});
|
|
41923
|
+
return data;
|
|
41924
|
+
} catch (error) {
|
|
41925
|
+
throw error;
|
|
41926
|
+
}
|
|
41927
|
+
}
|
|
41928
|
+
return {
|
|
41929
|
+
add,
|
|
41930
|
+
getAll,
|
|
41931
|
+
getOvernightParkingRequestById,
|
|
41932
|
+
updateOvernightParkingRequestById,
|
|
41933
|
+
deleteOvernightParkingRequestById,
|
|
41934
|
+
updateExpiredRequests
|
|
41935
|
+
};
|
|
41936
|
+
}
|
|
41937
|
+
|
|
41938
|
+
// src/services/overnight-parking-request.service.ts
|
|
41939
|
+
var import_node_server_utils204 = require("@7365admin1/node-server-utils");
|
|
41940
|
+
function getDayKey(date = /* @__PURE__ */ new Date()) {
|
|
41941
|
+
const days = [
|
|
41942
|
+
"sunday" /* SUNDAY */,
|
|
41943
|
+
"monday" /* MONDAY */,
|
|
41944
|
+
"tuesday" /* TUESDAY */,
|
|
41945
|
+
"wednesday" /* WEDNESDAY */,
|
|
41946
|
+
"thursday" /* THURSDAY */,
|
|
41947
|
+
"friday" /* FRIDAY */,
|
|
41948
|
+
"saturday" /* SATURDAY */
|
|
41949
|
+
];
|
|
41950
|
+
return days[date.getDay()];
|
|
41951
|
+
}
|
|
41952
|
+
function timeToMinutes(time) {
|
|
41953
|
+
const [hours, minutes] = time.split(":").map(Number);
|
|
41954
|
+
return hours * 60 + minutes;
|
|
41955
|
+
}
|
|
41956
|
+
function isCurrentTimeWithinRange(startTime, endTime, now = /* @__PURE__ */ new Date()) {
|
|
41957
|
+
const currentMinutes = now.getHours() * 60 + now.getMinutes();
|
|
41958
|
+
const startMinutes = timeToMinutes(startTime);
|
|
41959
|
+
const endMinutes = timeToMinutes(endTime);
|
|
41960
|
+
if (startMinutes <= endMinutes) {
|
|
41961
|
+
return currentMinutes >= startMinutes && currentMinutes <= endMinutes;
|
|
41962
|
+
}
|
|
41963
|
+
return currentMinutes >= startMinutes || currentMinutes <= endMinutes;
|
|
41964
|
+
}
|
|
41965
|
+
function shouldAutoApprove(overnightParking, now = /* @__PURE__ */ new Date()) {
|
|
41966
|
+
if (!overnightParking)
|
|
41967
|
+
return false;
|
|
41968
|
+
if (overnightParking.autoApproveOvernightParking !== true) {
|
|
41969
|
+
return false;
|
|
41970
|
+
}
|
|
41971
|
+
const dayKey = getDayKey(now);
|
|
41972
|
+
const daySchedule = overnightParking[dayKey];
|
|
41973
|
+
if (!daySchedule)
|
|
41974
|
+
return false;
|
|
41975
|
+
if (daySchedule.isEnabled !== true)
|
|
41976
|
+
return false;
|
|
41977
|
+
if (!daySchedule.startTime || !daySchedule.endTime)
|
|
41978
|
+
return false;
|
|
41979
|
+
return isCurrentTimeWithinRange(
|
|
41980
|
+
daySchedule.startTime,
|
|
41981
|
+
daySchedule.endTime,
|
|
41982
|
+
now
|
|
41983
|
+
);
|
|
41984
|
+
}
|
|
41985
|
+
function useOvernightParkingRequestService() {
|
|
41986
|
+
const {
|
|
41987
|
+
add: _add,
|
|
41988
|
+
updateOvernightParkingRequestById: _updateOvernightParkingRequestById,
|
|
41989
|
+
deleteOvernightParkingRequestById: _deleteOvernightParkingRequestById,
|
|
41990
|
+
updateExpiredRequests: _updateExpiredRequests
|
|
41991
|
+
} = useOvernightParkingRequestRepo();
|
|
41992
|
+
const { getAllSitesUnpaginated: _getAllSitesUnpaginated } = useSiteRepo();
|
|
41993
|
+
const { getSiteOvernightParking: _getSiteOvernightParking } = useOvernightParkingRepo();
|
|
41994
|
+
async function add(value) {
|
|
41995
|
+
const session = import_node_server_utils204.useAtlas.getClient()?.startSession();
|
|
41996
|
+
try {
|
|
41997
|
+
session?.startTransaction();
|
|
41998
|
+
const overnightParking = await _getSiteOvernightParking(value.site);
|
|
41999
|
+
const payload = {
|
|
42000
|
+
...value,
|
|
42001
|
+
status: shouldAutoApprove(overnightParking) ? "approved" /* APPROVED */ : "pending" /* PENDING */
|
|
42002
|
+
};
|
|
42003
|
+
const result = await _add(payload, session);
|
|
42004
|
+
await session?.commitTransaction();
|
|
42005
|
+
return result;
|
|
42006
|
+
} catch (error) {
|
|
42007
|
+
await session?.abortTransaction();
|
|
42008
|
+
throw error;
|
|
42009
|
+
} finally {
|
|
42010
|
+
session?.endSession();
|
|
42011
|
+
}
|
|
42012
|
+
}
|
|
42013
|
+
async function updateOvernightParkingRequestById(id, value) {
|
|
42014
|
+
const session = import_node_server_utils204.useAtlas.getClient()?.startSession();
|
|
42015
|
+
try {
|
|
42016
|
+
session?.startTransaction();
|
|
42017
|
+
const result = await _updateOvernightParkingRequestById(id, value);
|
|
42018
|
+
await session?.commitTransaction();
|
|
42019
|
+
return result;
|
|
42020
|
+
} catch (error) {
|
|
42021
|
+
await session?.abortTransaction();
|
|
42022
|
+
throw error;
|
|
42023
|
+
} finally {
|
|
42024
|
+
session?.endSession();
|
|
42025
|
+
}
|
|
42026
|
+
}
|
|
42027
|
+
async function deleteOvernightParkingRequestById(id) {
|
|
42028
|
+
const session = import_node_server_utils204.useAtlas.getClient()?.startSession();
|
|
42029
|
+
try {
|
|
42030
|
+
session?.startTransaction();
|
|
42031
|
+
const result = await _deleteOvernightParkingRequestById(id, session);
|
|
42032
|
+
await session?.commitTransaction();
|
|
42033
|
+
return result;
|
|
42034
|
+
} catch (error) {
|
|
42035
|
+
await session?.abortTransaction();
|
|
42036
|
+
throw error;
|
|
42037
|
+
} finally {
|
|
42038
|
+
session?.endSession();
|
|
42039
|
+
}
|
|
42040
|
+
}
|
|
42041
|
+
async function processExpiredRequests() {
|
|
42042
|
+
const sites = await _getAllSitesUnpaginated();
|
|
42043
|
+
for (const site of sites) {
|
|
42044
|
+
const session = import_node_server_utils204.useAtlas.getClient()?.startSession();
|
|
42045
|
+
try {
|
|
42046
|
+
session?.startTransaction();
|
|
42047
|
+
await _updateExpiredRequests(site._id, session);
|
|
42048
|
+
await session?.commitTransaction();
|
|
42049
|
+
} catch (error) {
|
|
42050
|
+
await session?.abortTransaction();
|
|
42051
|
+
import_node_server_utils204.logger.error(`Failed processing site ${site._id}`, error);
|
|
42052
|
+
} finally {
|
|
42053
|
+
session?.endSession();
|
|
42054
|
+
}
|
|
42055
|
+
}
|
|
42056
|
+
}
|
|
42057
|
+
return {
|
|
42058
|
+
add,
|
|
42059
|
+
updateOvernightParkingRequestById,
|
|
42060
|
+
deleteOvernightParkingRequestById,
|
|
42061
|
+
processExpiredRequests
|
|
42062
|
+
};
|
|
42063
|
+
}
|
|
42064
|
+
|
|
42065
|
+
// src/controllers/overnight-parking-request.controller.ts
|
|
42066
|
+
var import_joi119 = __toESM(require("joi"));
|
|
42067
|
+
var import_node_server_utils205 = require("@7365admin1/node-server-utils");
|
|
42068
|
+
function useOvernightParkingRequestController() {
|
|
42069
|
+
const {
|
|
42070
|
+
add: _add,
|
|
42071
|
+
updateOvernightParkingRequestById: _updateOvernightParkingRequestById,
|
|
42072
|
+
deleteOvernightParkingRequestById: _deleteOvernightParkingRequestById
|
|
42073
|
+
} = useOvernightParkingRequestService();
|
|
42074
|
+
const {
|
|
42075
|
+
getAll: _getAll,
|
|
42076
|
+
getOvernightParkingRequestById: _getOvernightParkingRequestById
|
|
42077
|
+
} = useOvernightParkingRequestRepo();
|
|
42078
|
+
async function add(req, res, next) {
|
|
42079
|
+
try {
|
|
42080
|
+
const { error, value } = schemaOvernightParkingRequest.validate(
|
|
42081
|
+
req.body,
|
|
42082
|
+
{
|
|
42083
|
+
abortEarly: false
|
|
42084
|
+
}
|
|
42085
|
+
);
|
|
42086
|
+
if (error) {
|
|
42087
|
+
const messages = error.details.map((d) => d.message).join(", ");
|
|
42088
|
+
import_node_server_utils205.logger.log({ level: "error", message: messages });
|
|
42089
|
+
next(new import_node_server_utils205.BadRequestError(messages));
|
|
42090
|
+
return;
|
|
42091
|
+
}
|
|
42092
|
+
const data = await _add(value);
|
|
42093
|
+
res.status(201).json(data);
|
|
42094
|
+
return;
|
|
42095
|
+
} catch (error) {
|
|
42096
|
+
import_node_server_utils205.logger.log({ level: "error", message: error.message });
|
|
42097
|
+
next(error);
|
|
42098
|
+
return;
|
|
42099
|
+
}
|
|
42100
|
+
}
|
|
42101
|
+
async function getAll(req, res, next) {
|
|
42102
|
+
try {
|
|
42103
|
+
const validation = import_joi119.default.object({
|
|
42104
|
+
page: import_joi119.default.number().integer().min(1).optional().default(1),
|
|
42105
|
+
limit: import_joi119.default.number().integer().min(1).max(100).optional().default(10),
|
|
42106
|
+
sort: import_joi119.default.string().valid(...Object.values(OvernightParkingRequestSort)).optional().allow(null, ""),
|
|
42107
|
+
status: import_joi119.default.string().valid(...Object.values(OvernightParkingRequestStatus)).optional().allow(null, ""),
|
|
42108
|
+
site: import_joi119.default.string().hex().length(24).optional().allow(null, ""),
|
|
42109
|
+
order: import_joi119.default.string().valid(...Object.values(SortOrder)).default("asc" /* ASC */)
|
|
42110
|
+
});
|
|
42111
|
+
const { error, value } = validation.validate(req.query, {
|
|
42112
|
+
abortEarly: false
|
|
42113
|
+
});
|
|
42114
|
+
if (error) {
|
|
42115
|
+
const messages = error.details.map((d) => d.message).join(", ");
|
|
42116
|
+
import_node_server_utils205.logger.log({ level: "error", message: messages });
|
|
42117
|
+
next(new import_node_server_utils205.BadRequestError(messages));
|
|
42118
|
+
return;
|
|
42119
|
+
}
|
|
42120
|
+
const { site, page, limit, status, sort, order } = value;
|
|
42121
|
+
const sortObj = {
|
|
42122
|
+
[sort ? sort : "_id" /* ID */]: order === "asc" /* ASC */ ? 1 : -1
|
|
42123
|
+
};
|
|
42124
|
+
const data = await _getAll({
|
|
42125
|
+
site,
|
|
42126
|
+
page,
|
|
42127
|
+
limit,
|
|
42128
|
+
sort: sortObj,
|
|
42129
|
+
status
|
|
42130
|
+
});
|
|
42131
|
+
res.status(200).json(data);
|
|
42132
|
+
return;
|
|
42133
|
+
} catch (error) {
|
|
42134
|
+
import_node_server_utils205.logger.log({ level: "error", message: error.message });
|
|
42135
|
+
next(error);
|
|
42136
|
+
return;
|
|
42137
|
+
}
|
|
42138
|
+
}
|
|
42139
|
+
async function getOvernightParkingRequestById(req, res, next) {
|
|
42140
|
+
try {
|
|
42141
|
+
const validation = import_joi119.default.object({
|
|
42142
|
+
_id: import_joi119.default.string().hex().length(24).required()
|
|
42143
|
+
});
|
|
42144
|
+
const { error, value } = validation.validate(
|
|
42145
|
+
{ _id: req.params.id },
|
|
42146
|
+
{
|
|
42147
|
+
abortEarly: false
|
|
42148
|
+
}
|
|
42149
|
+
);
|
|
42150
|
+
if (error) {
|
|
42151
|
+
const messages = error.details.map((d) => d.message).join(", ");
|
|
42152
|
+
import_node_server_utils205.logger.log({ level: "error", message: messages });
|
|
42153
|
+
next(new import_node_server_utils205.BadRequestError(messages));
|
|
42154
|
+
return;
|
|
42155
|
+
}
|
|
42156
|
+
const { _id } = value;
|
|
42157
|
+
const data = await _getOvernightParkingRequestById(_id);
|
|
42158
|
+
res.status(200).json(data);
|
|
42159
|
+
return;
|
|
42160
|
+
} catch (error) {
|
|
42161
|
+
import_node_server_utils205.logger.log({ level: "error", message: error.message });
|
|
42162
|
+
next(error);
|
|
42163
|
+
return;
|
|
42164
|
+
}
|
|
42165
|
+
}
|
|
42166
|
+
async function updateOvernightParkingRequestById(req, res, next) {
|
|
42167
|
+
try {
|
|
42168
|
+
const { error, value } = schemaUpdateOvernightParkingRequest.validate(
|
|
42169
|
+
{ _id: req.params.id, ...req.body },
|
|
42170
|
+
{
|
|
42171
|
+
abortEarly: false
|
|
42172
|
+
}
|
|
42173
|
+
);
|
|
42174
|
+
if (error) {
|
|
42175
|
+
const messages = error.details.map((d) => d.message).join(", ");
|
|
42176
|
+
import_node_server_utils205.logger.log({ level: "error", message: messages });
|
|
42177
|
+
next(new import_node_server_utils205.BadRequestError(messages));
|
|
42178
|
+
return;
|
|
42179
|
+
}
|
|
42180
|
+
const { _id, ...rest } = value;
|
|
42181
|
+
await _updateOvernightParkingRequestById(_id, rest);
|
|
42182
|
+
res.status(200).json({ message: "Successfully updated overnight parking request" });
|
|
42183
|
+
return;
|
|
42184
|
+
} catch (error) {
|
|
42185
|
+
import_node_server_utils205.logger.log({ level: "error", message: error.message });
|
|
42186
|
+
next(error);
|
|
42187
|
+
return;
|
|
42188
|
+
}
|
|
42189
|
+
}
|
|
42190
|
+
async function deleteOvernightParkingRequestById(req, res, next) {
|
|
42191
|
+
try {
|
|
42192
|
+
const schema2 = import_joi119.default.object({
|
|
42193
|
+
_id: import_joi119.default.string().hex().length(24).required()
|
|
42194
|
+
});
|
|
42195
|
+
const { error, value } = schema2.validate(
|
|
42196
|
+
{ _id: req.params.id },
|
|
42197
|
+
{
|
|
42198
|
+
abortEarly: false
|
|
42199
|
+
}
|
|
42200
|
+
);
|
|
42201
|
+
if (error) {
|
|
42202
|
+
const messages = error.details.map((d) => d.message).join(", ");
|
|
42203
|
+
import_node_server_utils205.logger.log({ level: "error", message: messages });
|
|
42204
|
+
next(new import_node_server_utils205.BadRequestError(messages));
|
|
42205
|
+
return;
|
|
42206
|
+
}
|
|
42207
|
+
const { _id } = value;
|
|
42208
|
+
await _deleteOvernightParkingRequestById(_id);
|
|
42209
|
+
res.status(200).json({ message: "Successfully deleted overnight parking request" });
|
|
42210
|
+
return;
|
|
42211
|
+
} catch (error) {
|
|
42212
|
+
import_node_server_utils205.logger.log({ level: "error", message: error.message });
|
|
42213
|
+
next(error);
|
|
42214
|
+
return;
|
|
42215
|
+
}
|
|
42216
|
+
}
|
|
42217
|
+
return {
|
|
42218
|
+
add,
|
|
42219
|
+
getAll,
|
|
42220
|
+
getOvernightParkingRequestById,
|
|
42221
|
+
updateOvernightParkingRequestById,
|
|
42222
|
+
deleteOvernightParkingRequestById
|
|
42223
|
+
};
|
|
42224
|
+
}
|
|
42225
|
+
|
|
42226
|
+
// src/services/hrmlabs-attendance.service.ts
|
|
42227
|
+
var import_node_server_utils206 = require("@7365admin1/node-server-utils");
|
|
42228
|
+
var {
|
|
42229
|
+
hrmLabsAuthentication: hrmLabsAuthentication3,
|
|
42230
|
+
fetchAttendanceData: fetchAttendanceData2,
|
|
42231
|
+
filterByShiftTime: filterByShiftTime2,
|
|
42232
|
+
paginate: paginate55,
|
|
42233
|
+
designationCount: designationCount2,
|
|
42234
|
+
totalCountPerShift: totalCountPerShift2,
|
|
42235
|
+
filterByStatus: filterByStatus2,
|
|
42236
|
+
totalCountPerStatus: totalCountPerStatus2,
|
|
42237
|
+
chartCountData: chartCountData2
|
|
42238
|
+
} = hrmlabs_attendance_util_default;
|
|
42239
|
+
function useHrmLabsAttendanceSrvc() {
|
|
42240
|
+
const { getManpowerSettingsBySiteId: _getManpowerSettingsBySiteId } = useManpowerMonitoringRepo();
|
|
42241
|
+
const { getManpowerDesignationsBySiteId: _getManpowerDesignationsBySiteId } = useManpowerDesignationRepo();
|
|
42242
|
+
async function getAttendanceData(payload) {
|
|
42243
|
+
const {
|
|
42244
|
+
startDate,
|
|
42245
|
+
endDate,
|
|
42246
|
+
siteName,
|
|
42247
|
+
siteId,
|
|
42248
|
+
shiftName,
|
|
42249
|
+
search,
|
|
42250
|
+
page = 1,
|
|
42251
|
+
limit = 10,
|
|
42252
|
+
status = "all",
|
|
42253
|
+
serviceProviderId
|
|
42254
|
+
} = payload;
|
|
42255
|
+
const username = process.env.HRMLABS_USERNAME;
|
|
42256
|
+
const domain = process.env.HRMLABS_DOMAIN;
|
|
42257
|
+
const password = process.env.HRMLABS_PASSWORD;
|
|
42258
|
+
const authUrl = process.env.HRMLABS_AUTH_URL;
|
|
42259
|
+
const attendanceUrl = process.env.HRMLABS_ATTENDANCE_URL;
|
|
42260
|
+
const timeZone = "Asia/Singapore";
|
|
42261
|
+
const dateFormat = "DD-MM-YYYY HH:mm:ss";
|
|
42262
|
+
if (!startDate) {
|
|
42263
|
+
return { success: false, message: "Start Date should not be empty" };
|
|
42264
|
+
}
|
|
42265
|
+
try {
|
|
42266
|
+
const config2 = await _getManpowerSettingsBySiteId(
|
|
42267
|
+
siteId,
|
|
42268
|
+
serviceProviderId
|
|
42269
|
+
);
|
|
42270
|
+
if (!config2) {
|
|
42271
|
+
return {
|
|
42272
|
+
success: false,
|
|
42273
|
+
message: "Manpower monitoring settings not found for the provided site ID."
|
|
42274
|
+
};
|
|
42275
|
+
}
|
|
42276
|
+
const shiftType = config2.shiftType === "2-shifts" ? "2-shifts" : "3-shifts";
|
|
42277
|
+
const shiftData = config2.shifts[shiftType].find(
|
|
42278
|
+
(s) => s.name === shiftName
|
|
42279
|
+
);
|
|
42280
|
+
if (!shiftData) {
|
|
42281
|
+
return {
|
|
42282
|
+
success: false,
|
|
42283
|
+
message: "Shift not found in configuration."
|
|
42284
|
+
};
|
|
42285
|
+
}
|
|
42286
|
+
const token = await hrmLabsAuthentication3({
|
|
42287
|
+
authUrl,
|
|
42288
|
+
username,
|
|
42289
|
+
password,
|
|
42290
|
+
domain
|
|
42291
|
+
});
|
|
42292
|
+
const attendanceData = await fetchAttendanceData2({
|
|
42293
|
+
attendanceUrl,
|
|
42294
|
+
token,
|
|
42295
|
+
startDate,
|
|
42296
|
+
endDate,
|
|
42297
|
+
siteName,
|
|
42298
|
+
search
|
|
42299
|
+
});
|
|
42300
|
+
if (!attendanceData?.success) {
|
|
42301
|
+
return {
|
|
42302
|
+
success: false,
|
|
42303
|
+
message: "Failed to fetch attendance data from HRMLabs.",
|
|
42304
|
+
items: [],
|
|
42305
|
+
pages: 0,
|
|
42306
|
+
pageRange: "0-0 of 0",
|
|
42307
|
+
count: {}
|
|
42308
|
+
};
|
|
42309
|
+
}
|
|
42310
|
+
let filteredAttendance;
|
|
42311
|
+
if (status === "all") {
|
|
42312
|
+
filteredAttendance = filterByShiftTime2(
|
|
42313
|
+
attendanceData.data,
|
|
42314
|
+
shiftData,
|
|
42315
|
+
timeZone,
|
|
42316
|
+
dateFormat
|
|
42317
|
+
);
|
|
42318
|
+
} else {
|
|
42319
|
+
const filteredByShift = filterByShiftTime2(
|
|
42320
|
+
attendanceData.data,
|
|
42321
|
+
shiftData,
|
|
42322
|
+
timeZone,
|
|
42323
|
+
dateFormat
|
|
42324
|
+
);
|
|
42325
|
+
filteredAttendance = filterByStatus2(
|
|
42326
|
+
filteredByShift,
|
|
42327
|
+
shiftData,
|
|
42328
|
+
timeZone,
|
|
42329
|
+
dateFormat,
|
|
42330
|
+
status
|
|
42331
|
+
);
|
|
42332
|
+
}
|
|
42333
|
+
const paginatedItems = paginate55(filteredAttendance, page, limit);
|
|
42334
|
+
return {
|
|
42335
|
+
items: paginatedItems.items,
|
|
42336
|
+
pages: paginatedItems.pages,
|
|
42337
|
+
pageRange: paginatedItems.pageRange
|
|
42338
|
+
};
|
|
42339
|
+
} catch (error) {
|
|
42340
|
+
import_node_server_utils206.logger.error(error.message || error);
|
|
42341
|
+
console.log("Error fetching attendance data:", error);
|
|
42342
|
+
throw new Error(error?.message || "Internal Server Error!");
|
|
42343
|
+
}
|
|
42344
|
+
}
|
|
42345
|
+
async function getAttendanceDataCount(payload) {
|
|
42346
|
+
const { startDate, endDate, siteName, siteId, search, serviceProviderId } = payload;
|
|
42347
|
+
const username = process.env.HRMLABS_USERNAME;
|
|
42348
|
+
const domain = process.env.HRMLABS_DOMAIN;
|
|
42349
|
+
const password = process.env.HRMLABS_PASSWORD;
|
|
42350
|
+
const authUrl = process.env.HRMLABS_AUTH_URL;
|
|
42351
|
+
const attendanceUrl = process.env.HRMLABS_ATTENDANCE_URL;
|
|
42352
|
+
const timeZone = "Asia/Singapore";
|
|
42353
|
+
const dateFormat = "DD-MM-YYYY HH:mm:ss";
|
|
42354
|
+
let totalCount;
|
|
42355
|
+
if (!startDate) {
|
|
42356
|
+
return { success: false, message: "Start Date should not be empty" };
|
|
42357
|
+
}
|
|
42358
|
+
try {
|
|
42359
|
+
const config2 = await _getManpowerSettingsBySiteId(
|
|
42360
|
+
siteId,
|
|
42361
|
+
serviceProviderId
|
|
42362
|
+
);
|
|
42363
|
+
if (!config2) {
|
|
42364
|
+
return {
|
|
42365
|
+
success: false,
|
|
42366
|
+
message: "Manpower monitoring settings not found for the provided site ID."
|
|
42367
|
+
};
|
|
42368
|
+
}
|
|
42369
|
+
const shiftType = config2.shiftType;
|
|
42370
|
+
const shiftData = config2.shifts[shiftType];
|
|
42371
|
+
if (!shiftData) {
|
|
42372
|
+
return {
|
|
42373
|
+
success: false,
|
|
42374
|
+
message: "Shift not found in configuration."
|
|
42375
|
+
};
|
|
42376
|
+
}
|
|
42377
|
+
const designationConfig = await _getManpowerDesignationsBySiteId(
|
|
42378
|
+
siteId,
|
|
42379
|
+
serviceProviderId
|
|
42380
|
+
);
|
|
42381
|
+
if (!designationConfig) {
|
|
42382
|
+
return {
|
|
42383
|
+
success: false,
|
|
42384
|
+
message: "Manpower monitoring designations not found for the provided site ID."
|
|
42385
|
+
};
|
|
42386
|
+
}
|
|
42387
|
+
const totalShifts = designationConfig.designations.reduce(
|
|
42388
|
+
(acc, item) => {
|
|
42389
|
+
acc.morningShift += item.shifts.morningShift;
|
|
42390
|
+
acc.afternoonShift += item.shifts.afternoonShift;
|
|
42391
|
+
acc.nightShift += item.shifts.nightShift;
|
|
42392
|
+
return acc;
|
|
42393
|
+
},
|
|
42394
|
+
{
|
|
42395
|
+
morningShift: 0,
|
|
42396
|
+
afternoonShift: 0,
|
|
42397
|
+
nightShift: 0
|
|
42398
|
+
}
|
|
42399
|
+
);
|
|
42400
|
+
const token = await hrmLabsAuthentication3({
|
|
42401
|
+
authUrl,
|
|
42402
|
+
username,
|
|
42403
|
+
password,
|
|
42404
|
+
domain
|
|
42405
|
+
});
|
|
42406
|
+
const attendanceData = await fetchAttendanceData2({
|
|
42407
|
+
attendanceUrl,
|
|
42408
|
+
token,
|
|
42409
|
+
startDate,
|
|
42410
|
+
endDate,
|
|
42411
|
+
siteName,
|
|
42412
|
+
search
|
|
42413
|
+
});
|
|
42414
|
+
if (!attendanceData?.success) {
|
|
42415
|
+
return {
|
|
42416
|
+
totalCount: {
|
|
42417
|
+
dayShift: {
|
|
42418
|
+
actual: 0,
|
|
42419
|
+
expected: totalShifts.morningShift
|
|
42420
|
+
},
|
|
42421
|
+
afternoonShift: {
|
|
42422
|
+
actual: 0,
|
|
42423
|
+
expected: totalShifts.afternoonShift
|
|
42424
|
+
},
|
|
42425
|
+
nightShift: {
|
|
42426
|
+
actual: 0,
|
|
42427
|
+
expected: totalShifts.nightShift
|
|
42428
|
+
}
|
|
42429
|
+
}
|
|
42430
|
+
};
|
|
42431
|
+
}
|
|
42432
|
+
const result = totalCountPerShift2(
|
|
42433
|
+
attendanceData.data,
|
|
42434
|
+
shiftData,
|
|
42435
|
+
timeZone,
|
|
42436
|
+
dateFormat
|
|
42437
|
+
);
|
|
42438
|
+
totalCount = {
|
|
42439
|
+
dayShift: {
|
|
42440
|
+
actual: result[0],
|
|
42441
|
+
expected: totalShifts.morningShift
|
|
42442
|
+
},
|
|
42443
|
+
afternoonShift: {
|
|
42444
|
+
actual: shiftType == "2-shifts" ? 0 : result[1],
|
|
42445
|
+
expected: totalShifts.afternoonShift
|
|
42446
|
+
},
|
|
42447
|
+
nightShift: {
|
|
42448
|
+
actual: shiftType == "2-shifts" ? result[1] : result[2],
|
|
42449
|
+
expected: totalShifts.nightShift
|
|
42450
|
+
}
|
|
42451
|
+
};
|
|
42452
|
+
return { totalCount };
|
|
42453
|
+
} catch (error) {
|
|
42454
|
+
import_node_server_utils206.logger.error(error.message || error);
|
|
42455
|
+
console.log("Error fetching attendance data count:", error);
|
|
42456
|
+
throw new Error(error?.message || "Internal Server Error!");
|
|
42457
|
+
}
|
|
42458
|
+
}
|
|
42459
|
+
async function getAllAttendance(payload) {
|
|
42460
|
+
const { startDate, endDate, siteName, siteId, search, serviceProviderId } = payload;
|
|
42461
|
+
let { shiftName } = payload;
|
|
42462
|
+
const username = process.env.HRMLABS_USERNAME;
|
|
42463
|
+
const domain = process.env.HRMLABS_DOMAIN;
|
|
42464
|
+
const password = process.env.HRMLABS_PASSWORD;
|
|
42465
|
+
const authUrl = process.env.HRMLABS_AUTH_URL;
|
|
42466
|
+
const attendanceUrl = process.env.HRMLABS_ATTENDANCE_URL;
|
|
42467
|
+
const timeZone = "Asia/Singapore";
|
|
42468
|
+
const dateFormat = "DD-MM-YYYY HH:mm:ss";
|
|
42469
|
+
if (!startDate) {
|
|
42470
|
+
return { success: false, message: "Start Date should not be empty" };
|
|
42471
|
+
}
|
|
42472
|
+
try {
|
|
42473
|
+
const config2 = await _getManpowerSettingsBySiteId(
|
|
42474
|
+
siteId,
|
|
42475
|
+
serviceProviderId
|
|
42476
|
+
);
|
|
42477
|
+
if (!config2) {
|
|
42478
|
+
return {
|
|
42479
|
+
success: false,
|
|
42480
|
+
message: "Manpower monitoring settings not found for the provided site ID."
|
|
42481
|
+
};
|
|
42482
|
+
}
|
|
42483
|
+
const designationConfig = await _getManpowerDesignationsBySiteId(
|
|
42484
|
+
siteId,
|
|
42485
|
+
serviceProviderId
|
|
42486
|
+
);
|
|
42487
|
+
if (!designationConfig) {
|
|
42488
|
+
return {
|
|
42489
|
+
success: false,
|
|
42490
|
+
message: "Manpower monitoring designations not found for the provided site ID."
|
|
42491
|
+
};
|
|
42492
|
+
}
|
|
42493
|
+
let shiftData = [];
|
|
42494
|
+
const shiftType = config2.shiftType === "2-shifts" ? "2-shifts" : "3-shifts";
|
|
42495
|
+
if (shiftName == "all") {
|
|
42496
|
+
shiftData = config2.shifts[shiftType];
|
|
42497
|
+
} else {
|
|
42498
|
+
shiftName = shiftName.split(" ").map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join(" ");
|
|
42499
|
+
const filteredShiftData = config2.shifts[shiftType].find(
|
|
42500
|
+
(s) => s.name === shiftName
|
|
42501
|
+
);
|
|
42502
|
+
shiftData.push(filteredShiftData);
|
|
42503
|
+
}
|
|
42504
|
+
if (!shiftData) {
|
|
42505
|
+
return {
|
|
42506
|
+
success: false,
|
|
42507
|
+
message: "Shift not found in configuration."
|
|
42508
|
+
};
|
|
42509
|
+
}
|
|
42510
|
+
const totalShifts = designationConfig.designations.reduce(
|
|
42511
|
+
(acc, item) => {
|
|
42512
|
+
acc.morningShift += item.shifts.morningShift;
|
|
42513
|
+
acc.afternoonShift += item.shifts.afternoonShift;
|
|
42514
|
+
acc.nightShift += item.shifts.nightShift;
|
|
42515
|
+
return acc;
|
|
42516
|
+
},
|
|
42517
|
+
{
|
|
42518
|
+
morningShift: 0,
|
|
42519
|
+
afternoonShift: 0,
|
|
42520
|
+
nightShift: 0
|
|
42521
|
+
}
|
|
42522
|
+
);
|
|
42523
|
+
const token = await hrmLabsAuthentication3({
|
|
42524
|
+
authUrl,
|
|
42525
|
+
username,
|
|
42526
|
+
password,
|
|
42527
|
+
domain
|
|
42528
|
+
});
|
|
42529
|
+
const attendanceData = await fetchAttendanceData2({
|
|
42530
|
+
attendanceUrl,
|
|
42531
|
+
token,
|
|
42532
|
+
startDate,
|
|
42533
|
+
endDate,
|
|
42534
|
+
siteName,
|
|
42535
|
+
search
|
|
42536
|
+
});
|
|
42537
|
+
if (!attendanceData?.success) {
|
|
42538
|
+
const jobTitleCount2 = designationCount2(
|
|
42539
|
+
attendanceData.data,
|
|
42540
|
+
designationConfig,
|
|
42541
|
+
shiftName
|
|
42542
|
+
);
|
|
42543
|
+
const totalCount2 = {
|
|
42544
|
+
dayShift: {
|
|
42545
|
+
actual: 0,
|
|
42546
|
+
expected: totalShifts.morningShift
|
|
42547
|
+
},
|
|
42548
|
+
afternoonShift: {
|
|
42549
|
+
actual: 0,
|
|
42550
|
+
expected: totalShifts.afternoonShift
|
|
42551
|
+
},
|
|
42552
|
+
nightShift: {
|
|
42553
|
+
actual: 0,
|
|
42554
|
+
expected: totalShifts.nightShift
|
|
42555
|
+
}
|
|
42556
|
+
};
|
|
42557
|
+
const countPerStatus2 = await totalCountPerStatus2(
|
|
42558
|
+
attendanceData.data,
|
|
42559
|
+
shiftName,
|
|
42560
|
+
shiftData,
|
|
42561
|
+
timeZone,
|
|
42562
|
+
dateFormat,
|
|
42563
|
+
totalShifts
|
|
42564
|
+
);
|
|
42565
|
+
return {
|
|
42566
|
+
success: false,
|
|
42567
|
+
message: "Failed to fetch attendance data from HRMLabs.",
|
|
42568
|
+
items: [],
|
|
42569
|
+
count: {},
|
|
42570
|
+
countPerJobTitle: jobTitleCount2,
|
|
42571
|
+
totalCount: totalCount2,
|
|
42572
|
+
countPerStatus: countPerStatus2
|
|
42573
|
+
};
|
|
42574
|
+
}
|
|
42575
|
+
let filteredAttendance;
|
|
42576
|
+
if (shiftName === "all") {
|
|
42577
|
+
filteredAttendance = attendanceData.data;
|
|
42578
|
+
} else {
|
|
42579
|
+
filteredAttendance = filterByShiftTime2(
|
|
42580
|
+
attendanceData.data,
|
|
42581
|
+
shiftData[0],
|
|
42582
|
+
timeZone,
|
|
42583
|
+
dateFormat
|
|
42584
|
+
);
|
|
42585
|
+
}
|
|
42586
|
+
const jobTitleCount = designationCount2(
|
|
42587
|
+
filteredAttendance,
|
|
42588
|
+
designationConfig,
|
|
42589
|
+
shiftName
|
|
42590
|
+
);
|
|
42591
|
+
const result = totalCountPerShift2(
|
|
42592
|
+
attendanceData.data,
|
|
42593
|
+
shiftData,
|
|
42594
|
+
timeZone,
|
|
42595
|
+
dateFormat
|
|
42596
|
+
);
|
|
42597
|
+
const totalCount = {
|
|
42598
|
+
dayShift: {
|
|
42599
|
+
actual: result[0],
|
|
42600
|
+
expected: totalShifts.morningShift
|
|
42601
|
+
},
|
|
42602
|
+
afternoonShift: {
|
|
42603
|
+
actual: shiftType == "2-shifts" ? 0 : result[1],
|
|
42604
|
+
expected: totalShifts.afternoonShift
|
|
42605
|
+
},
|
|
42606
|
+
nightShift: {
|
|
42607
|
+
actual: shiftType == "2-shifts" ? result[1] : result[2],
|
|
42608
|
+
expected: totalShifts.nightShift
|
|
42609
|
+
}
|
|
42610
|
+
};
|
|
42611
|
+
const countPerStatus = await totalCountPerStatus2(
|
|
42612
|
+
filteredAttendance,
|
|
42613
|
+
shiftName,
|
|
42614
|
+
shiftData,
|
|
42615
|
+
timeZone,
|
|
42616
|
+
dateFormat,
|
|
42617
|
+
totalShifts
|
|
42618
|
+
);
|
|
42619
|
+
return {
|
|
42620
|
+
items: filteredAttendance,
|
|
42621
|
+
countPerJobTitle: jobTitleCount,
|
|
42622
|
+
totalCount,
|
|
42623
|
+
countPerStatus
|
|
42624
|
+
};
|
|
42625
|
+
} catch (error) {
|
|
42626
|
+
import_node_server_utils206.logger.error(error.message || error);
|
|
42627
|
+
console.log("Error fetching attendance data:", error);
|
|
42628
|
+
throw new Error(error?.message || "Internal Server Error!");
|
|
42629
|
+
}
|
|
42630
|
+
}
|
|
42631
|
+
async function getChartAttendanceData(payload) {
|
|
42632
|
+
const {
|
|
42633
|
+
startDate,
|
|
42634
|
+
endDate,
|
|
42635
|
+
siteName,
|
|
42636
|
+
siteId,
|
|
42637
|
+
search,
|
|
42638
|
+
serviceProviderId,
|
|
42639
|
+
status
|
|
42640
|
+
} = payload;
|
|
42641
|
+
let { shiftName } = payload;
|
|
42642
|
+
const username = process.env.HRMLABS_USERNAME;
|
|
42643
|
+
const domain = process.env.HRMLABS_DOMAIN;
|
|
42644
|
+
const password = process.env.HRMLABS_PASSWORD;
|
|
42645
|
+
const authUrl = process.env.HRMLABS_AUTH_URL;
|
|
42646
|
+
const attendanceUrl = process.env.HRMLABS_ATTENDANCE_URL;
|
|
42647
|
+
const timeZone = "Asia/Singapore";
|
|
42648
|
+
const dateFormat = "DD-MM-YYYY HH:mm:ss";
|
|
42649
|
+
if (!startDate) {
|
|
42650
|
+
return { success: false, message: "Start Date should not be empty" };
|
|
42651
|
+
}
|
|
42652
|
+
try {
|
|
42653
|
+
const config2 = await _getManpowerSettingsBySiteId(
|
|
42654
|
+
siteId,
|
|
42655
|
+
serviceProviderId
|
|
42656
|
+
);
|
|
42657
|
+
if (!config2) {
|
|
42658
|
+
return {
|
|
42659
|
+
success: false,
|
|
42660
|
+
message: "Manpower monitoring settings not found for the provided site ID."
|
|
42661
|
+
};
|
|
42662
|
+
}
|
|
42663
|
+
const designationConfig = await _getManpowerDesignationsBySiteId(
|
|
42664
|
+
siteId,
|
|
42665
|
+
serviceProviderId
|
|
42666
|
+
);
|
|
42667
|
+
if (!designationConfig) {
|
|
42668
|
+
return {
|
|
42669
|
+
success: false,
|
|
42670
|
+
message: "Manpower monitoring designations not found for the provided site ID."
|
|
42671
|
+
};
|
|
42672
|
+
}
|
|
42673
|
+
const shiftType = config2.shiftType === "2-shifts" ? "2-shifts" : "3-shifts";
|
|
42674
|
+
const shiftData = config2.shifts[shiftType];
|
|
42675
|
+
if (!shiftData) {
|
|
42676
|
+
return {
|
|
42677
|
+
success: false,
|
|
42678
|
+
message: "Shift not found in configuration."
|
|
42679
|
+
};
|
|
42680
|
+
}
|
|
42681
|
+
const token = await hrmLabsAuthentication3({
|
|
42682
|
+
authUrl,
|
|
42683
|
+
username,
|
|
42684
|
+
password,
|
|
42685
|
+
domain
|
|
42686
|
+
});
|
|
42687
|
+
const attendanceData = await fetchAttendanceData2({
|
|
42688
|
+
attendanceUrl,
|
|
42689
|
+
token,
|
|
42690
|
+
startDate,
|
|
42691
|
+
endDate,
|
|
42692
|
+
siteName,
|
|
42693
|
+
search
|
|
42694
|
+
});
|
|
42695
|
+
if (!attendanceData?.success) {
|
|
42696
|
+
return {
|
|
42697
|
+
success: false,
|
|
42698
|
+
message: "Failed to fetch attendance data from HRMLabs.",
|
|
42699
|
+
items: [],
|
|
42700
|
+
pages: 0,
|
|
42701
|
+
pageRange: "0-0 of 0",
|
|
42702
|
+
count: {}
|
|
42703
|
+
};
|
|
42704
|
+
}
|
|
42705
|
+
const filteredAttendance = attendanceData.data;
|
|
42706
|
+
const totalShifts = designationConfig.designations.reduce(
|
|
42707
|
+
(acc, item) => {
|
|
42708
|
+
acc.morningShift += item.shifts.morningShift;
|
|
42709
|
+
acc.afternoonShift += item.shifts.afternoonShift;
|
|
42710
|
+
acc.nightShift += item.shifts.nightShift;
|
|
42711
|
+
return acc;
|
|
42712
|
+
},
|
|
42713
|
+
{
|
|
42714
|
+
morningShift: 0,
|
|
42715
|
+
afternoonShift: 0,
|
|
42716
|
+
nightShift: 0
|
|
42717
|
+
}
|
|
42718
|
+
);
|
|
42719
|
+
const chartCount = await chartCountData2(
|
|
42720
|
+
filteredAttendance,
|
|
42721
|
+
shiftData,
|
|
42722
|
+
timeZone,
|
|
42723
|
+
dateFormat,
|
|
42724
|
+
totalShifts,
|
|
42725
|
+
startDate,
|
|
42726
|
+
endDate,
|
|
42727
|
+
status
|
|
42728
|
+
);
|
|
42729
|
+
return {
|
|
42730
|
+
chartCount
|
|
42731
|
+
};
|
|
42732
|
+
} catch (error) {
|
|
42733
|
+
import_node_server_utils206.logger.error(error.message || error);
|
|
42734
|
+
console.log("Error fetching attendance data:", error);
|
|
42735
|
+
throw new Error(error?.message || "Internal Server Error!");
|
|
42736
|
+
}
|
|
42737
|
+
}
|
|
42738
|
+
return {
|
|
42739
|
+
getAttendanceData,
|
|
42740
|
+
getAttendanceDataCount,
|
|
42741
|
+
getAllAttendance,
|
|
42742
|
+
getChartAttendanceData
|
|
42743
|
+
};
|
|
42744
|
+
}
|
|
42745
|
+
|
|
42746
|
+
// src/controllers/hrmlabs-attendance.controller.ts
|
|
42747
|
+
var import_node_server_utils207 = require("@7365admin1/node-server-utils");
|
|
42748
|
+
var import_joi120 = __toESM(require("joi"));
|
|
42749
|
+
function useHrmLabsAttendanceCtrl() {
|
|
42750
|
+
const hrmLabsAttendanceSrvc = useHrmLabsAttendanceSrvc();
|
|
42751
|
+
async function getAttendanceData(req, res, next) {
|
|
42752
|
+
try {
|
|
42753
|
+
const {
|
|
42754
|
+
startDate,
|
|
42755
|
+
endDate,
|
|
42756
|
+
siteName,
|
|
42757
|
+
siteId,
|
|
42758
|
+
shiftName,
|
|
42759
|
+
page,
|
|
42760
|
+
limit,
|
|
42761
|
+
search,
|
|
42762
|
+
status,
|
|
42763
|
+
serviceProviderId
|
|
42764
|
+
} = req.body;
|
|
42765
|
+
const schema2 = import_joi120.default.object({
|
|
42766
|
+
startDate: import_joi120.default.string().optional().allow("", null),
|
|
42767
|
+
endDate: import_joi120.default.string().optional().allow("", null),
|
|
42768
|
+
siteName: import_joi120.default.string().optional().allow("", null),
|
|
42769
|
+
siteId: import_joi120.default.string().required(),
|
|
42770
|
+
shiftName: import_joi120.default.string().optional().allow("", null),
|
|
42771
|
+
page: import_joi120.default.number().optional().allow("", null),
|
|
42772
|
+
limit: import_joi120.default.number().optional().allow("", null),
|
|
42773
|
+
search: import_joi120.default.string().optional().allow("", null),
|
|
42774
|
+
status: import_joi120.default.string().optional().allow("", null),
|
|
42775
|
+
serviceProviderId: import_joi120.default.string().required()
|
|
42776
|
+
});
|
|
42777
|
+
const { error } = schema2.validate({
|
|
42778
|
+
startDate,
|
|
42779
|
+
endDate,
|
|
42780
|
+
siteName,
|
|
42781
|
+
siteId,
|
|
42782
|
+
shiftName,
|
|
42783
|
+
page,
|
|
42784
|
+
limit,
|
|
42785
|
+
search,
|
|
42786
|
+
status,
|
|
42787
|
+
serviceProviderId
|
|
42788
|
+
});
|
|
42789
|
+
if (error) {
|
|
42790
|
+
next(new import_node_server_utils207.BadRequestError(error.message));
|
|
42791
|
+
return;
|
|
42792
|
+
}
|
|
42793
|
+
const result = await hrmLabsAttendanceSrvc.getAttendanceData(req.body);
|
|
42794
|
+
return res.json(result);
|
|
42795
|
+
} catch (error) {
|
|
42796
|
+
import_node_server_utils207.logger.log({ level: "error", message: error.message });
|
|
42797
|
+
next(error);
|
|
42798
|
+
return;
|
|
42799
|
+
}
|
|
42800
|
+
}
|
|
42801
|
+
async function getAttendanceDataCount(req, res, next) {
|
|
42802
|
+
try {
|
|
42803
|
+
const { startDate, endDate, siteName, siteId, serviceProviderId } = req.body;
|
|
42804
|
+
const schema2 = import_joi120.default.object({
|
|
42805
|
+
startDate: import_joi120.default.string().optional().allow("", null),
|
|
42806
|
+
endDate: import_joi120.default.string().optional().allow("", null),
|
|
42807
|
+
siteName: import_joi120.default.string().optional().allow("", null),
|
|
42808
|
+
siteId: import_joi120.default.string().required(),
|
|
42809
|
+
serviceProviderId: import_joi120.default.string().required()
|
|
42810
|
+
});
|
|
42811
|
+
const { error } = schema2.validate({
|
|
42812
|
+
startDate,
|
|
42813
|
+
endDate,
|
|
42814
|
+
siteName,
|
|
42815
|
+
siteId,
|
|
42816
|
+
serviceProviderId
|
|
42817
|
+
});
|
|
42818
|
+
if (error) {
|
|
42819
|
+
next(new import_node_server_utils207.BadRequestError(error.message));
|
|
42820
|
+
return;
|
|
42821
|
+
}
|
|
42822
|
+
const result = await hrmLabsAttendanceSrvc.getAttendanceDataCount(
|
|
42823
|
+
req.body
|
|
42824
|
+
);
|
|
42825
|
+
return res.json(result);
|
|
42826
|
+
} catch (error) {
|
|
42827
|
+
import_node_server_utils207.logger.log({ level: "error", message: error.message });
|
|
42828
|
+
next(error);
|
|
42829
|
+
return;
|
|
42830
|
+
}
|
|
42831
|
+
}
|
|
42832
|
+
async function getAllAttendance(req, res, next) {
|
|
42833
|
+
try {
|
|
42834
|
+
const {
|
|
42835
|
+
startDate,
|
|
42836
|
+
endDate,
|
|
42837
|
+
siteName,
|
|
42838
|
+
siteId,
|
|
42839
|
+
shiftName,
|
|
42840
|
+
search,
|
|
42841
|
+
serviceProviderId
|
|
42842
|
+
} = req.body;
|
|
42843
|
+
const schema2 = import_joi120.default.object({
|
|
42844
|
+
startDate: import_joi120.default.string().optional().allow("", null),
|
|
42845
|
+
endDate: import_joi120.default.string().optional().allow("", null),
|
|
42846
|
+
siteName: import_joi120.default.string().optional().allow("", null),
|
|
42847
|
+
siteId: import_joi120.default.string().required(),
|
|
42848
|
+
shiftName: import_joi120.default.string().optional().allow("", null),
|
|
42849
|
+
search: import_joi120.default.string().optional().allow("", null),
|
|
42850
|
+
serviceProviderId: import_joi120.default.string().required()
|
|
42851
|
+
});
|
|
42852
|
+
const { error } = schema2.validate({
|
|
42853
|
+
startDate,
|
|
42854
|
+
endDate,
|
|
42855
|
+
siteName,
|
|
42856
|
+
siteId,
|
|
42857
|
+
shiftName,
|
|
42858
|
+
search,
|
|
42859
|
+
serviceProviderId
|
|
42860
|
+
});
|
|
42861
|
+
if (error) {
|
|
42862
|
+
next(new import_node_server_utils207.BadRequestError(error.message));
|
|
42863
|
+
return;
|
|
42864
|
+
}
|
|
42865
|
+
const result = await hrmLabsAttendanceSrvc.getAllAttendance(req.body);
|
|
42866
|
+
return res.json(result);
|
|
42867
|
+
} catch (error) {
|
|
42868
|
+
import_node_server_utils207.logger.log({ level: "error", message: error.message });
|
|
42869
|
+
next(error);
|
|
42870
|
+
return;
|
|
42871
|
+
}
|
|
42872
|
+
}
|
|
42873
|
+
async function getChartAttendanceData(req, res, next) {
|
|
42874
|
+
try {
|
|
42875
|
+
const {
|
|
42876
|
+
startDate,
|
|
42877
|
+
endDate,
|
|
42878
|
+
siteName,
|
|
42879
|
+
siteId,
|
|
42880
|
+
search = "",
|
|
42881
|
+
serviceProviderId,
|
|
42882
|
+
status
|
|
42883
|
+
} = req.body;
|
|
42884
|
+
const schema2 = import_joi120.default.object({
|
|
42885
|
+
startDate: import_joi120.default.string().optional().allow("", null),
|
|
42886
|
+
endDate: import_joi120.default.string().optional().allow("", null),
|
|
42887
|
+
siteName: import_joi120.default.string().optional().allow("", null),
|
|
42888
|
+
siteId: import_joi120.default.string().required(),
|
|
42889
|
+
search: import_joi120.default.string().optional().allow("", null),
|
|
42890
|
+
serviceProviderId: import_joi120.default.string().required(),
|
|
42891
|
+
status: import_joi120.default.string().optional().allow("", null)
|
|
42892
|
+
});
|
|
42893
|
+
const { error } = schema2.validate({
|
|
42894
|
+
startDate,
|
|
42895
|
+
endDate,
|
|
42896
|
+
siteName,
|
|
42897
|
+
siteId,
|
|
42898
|
+
search,
|
|
42899
|
+
serviceProviderId,
|
|
42900
|
+
status
|
|
42901
|
+
});
|
|
42902
|
+
if (error) {
|
|
42903
|
+
next(new import_node_server_utils207.BadRequestError(error.message));
|
|
42904
|
+
return;
|
|
42905
|
+
}
|
|
42906
|
+
const result = await hrmLabsAttendanceSrvc.getChartAttendanceData(
|
|
42907
|
+
req.body
|
|
42908
|
+
);
|
|
42909
|
+
return res.json(result);
|
|
42910
|
+
} catch (error) {
|
|
42911
|
+
import_node_server_utils207.logger.log({ level: "error", message: error.message });
|
|
42912
|
+
next(error);
|
|
42913
|
+
return;
|
|
42914
|
+
}
|
|
42915
|
+
}
|
|
42916
|
+
return {
|
|
42917
|
+
getAttendanceData,
|
|
42918
|
+
getAttendanceDataCount,
|
|
42919
|
+
getAllAttendance,
|
|
42920
|
+
getChartAttendanceData
|
|
42921
|
+
};
|
|
42922
|
+
}
|
|
42923
|
+
|
|
42924
|
+
// src/controllers/manpower-remarks.controller.ts
|
|
42925
|
+
var import_node_server_utils208 = require("@7365admin1/node-server-utils");
|
|
42926
|
+
var import_joi121 = __toESM(require("joi"));
|
|
42927
|
+
function useManpowerRemarkCtrl() {
|
|
42928
|
+
const {
|
|
42929
|
+
createManpowerRemarks: _createManpowerRemarks,
|
|
42930
|
+
getManpowerRemarksAllSite: _getManpowerRemarksAllSite,
|
|
42931
|
+
updateRemarksStatus: _updateRemarksStatus,
|
|
42932
|
+
getManpowerRemarksBySiteId: _getManpowerRemarksBySiteId,
|
|
42933
|
+
updateManpowerRemarks: _updateManpowerRemarks
|
|
42934
|
+
} = useManpowerRemarksRepo();
|
|
42935
|
+
async function createManpowerRemark(req, res, next) {
|
|
42936
|
+
try {
|
|
42937
|
+
const payload = { ...req.body };
|
|
42938
|
+
const { error } = manpowerRemarksSchema.validate(payload);
|
|
42939
|
+
if (error) {
|
|
42940
|
+
next(new import_node_server_utils208.BadRequestError(error.message));
|
|
42941
|
+
return;
|
|
42942
|
+
}
|
|
42943
|
+
const result = await _createManpowerRemarks(payload);
|
|
42944
|
+
return res.json(result);
|
|
42945
|
+
} catch (error) {
|
|
42946
|
+
import_node_server_utils208.logger.log({ level: "error", message: error.message });
|
|
42947
|
+
next(error);
|
|
42948
|
+
return;
|
|
42949
|
+
}
|
|
42950
|
+
}
|
|
42951
|
+
async function getManpowerRemarksAllSite(req, res, next) {
|
|
42952
|
+
try {
|
|
42953
|
+
const { page, limit, serviceProviderId, search, status, date } = req.query;
|
|
42954
|
+
const schema2 = import_joi121.default.object({
|
|
42955
|
+
page: import_joi121.default.number().optional().allow("", null),
|
|
42956
|
+
limit: import_joi121.default.number().optional().allow("", null),
|
|
42957
|
+
serviceProviderId: import_joi121.default.string().hex().optional().allow("", null),
|
|
42958
|
+
search: import_joi121.default.string().optional().allow("", null),
|
|
42959
|
+
status: import_joi121.default.string().required(),
|
|
42960
|
+
date: import_joi121.default.string().required()
|
|
42961
|
+
});
|
|
42962
|
+
const { error } = schema2.validate({
|
|
42963
|
+
page,
|
|
42964
|
+
limit,
|
|
42965
|
+
serviceProviderId,
|
|
42966
|
+
search,
|
|
42967
|
+
status,
|
|
42968
|
+
date
|
|
42969
|
+
});
|
|
42970
|
+
if (error) {
|
|
42971
|
+
next(new import_node_server_utils208.BadRequestError(error.message));
|
|
42972
|
+
return;
|
|
42973
|
+
}
|
|
42974
|
+
const result = await _getManpowerRemarksAllSite({
|
|
42975
|
+
page: Number(page),
|
|
42976
|
+
limit: Number(limit),
|
|
42977
|
+
serviceProviderId: serviceProviderId?.toString() || "",
|
|
42978
|
+
search: search?.toString() || "",
|
|
42979
|
+
status: status?.toString() || "",
|
|
42980
|
+
date: date?.toString() || ""
|
|
42981
|
+
});
|
|
42982
|
+
return res.json(result);
|
|
42983
|
+
} catch (error) {
|
|
42984
|
+
import_node_server_utils208.logger.log({ level: "error", message: error.message });
|
|
42985
|
+
next(error);
|
|
42986
|
+
return;
|
|
42987
|
+
}
|
|
42988
|
+
}
|
|
42989
|
+
async function getManpowerRemarksBySiteId(req, res, next) {
|
|
42990
|
+
try {
|
|
42991
|
+
const { id, serviceProviderId } = req.params;
|
|
42992
|
+
const date = req.query.date;
|
|
42993
|
+
const schema2 = import_joi121.default.object({
|
|
42994
|
+
id: import_joi121.default.string().hex().required(),
|
|
42995
|
+
date: import_joi121.default.string().required(),
|
|
42996
|
+
serviceProviderId: import_joi121.default.string().hex().required()
|
|
42997
|
+
});
|
|
42998
|
+
const { error } = schema2.validate({
|
|
42999
|
+
id,
|
|
43000
|
+
date,
|
|
43001
|
+
serviceProviderId
|
|
43002
|
+
});
|
|
43003
|
+
if (error) {
|
|
43004
|
+
next(new import_node_server_utils208.BadRequestError(error.message));
|
|
43005
|
+
return;
|
|
43006
|
+
}
|
|
43007
|
+
const result = await _getManpowerRemarksBySiteId(
|
|
43008
|
+
id,
|
|
43009
|
+
date,
|
|
43010
|
+
serviceProviderId
|
|
43011
|
+
);
|
|
43012
|
+
return res.json(result);
|
|
43013
|
+
} catch (error) {
|
|
43014
|
+
import_node_server_utils208.logger.log({ level: "error", message: error.message });
|
|
43015
|
+
next(error);
|
|
43016
|
+
return;
|
|
43017
|
+
}
|
|
43018
|
+
}
|
|
43019
|
+
async function updateManpowerMonitoringSettings(req, res, next) {
|
|
43020
|
+
try {
|
|
43021
|
+
const validation = import_joi121.default.object({
|
|
43022
|
+
_id: import_joi121.default.string().hex().required(),
|
|
43023
|
+
remarks: import_joi121.default.array().items(remarksSchema).required(),
|
|
43024
|
+
createdBy: import_joi121.default.string().hex().optional().allow("", null),
|
|
43025
|
+
createdByName: import_joi121.default.string().optional().allow("", null)
|
|
43026
|
+
});
|
|
43027
|
+
const _id = req.params.id;
|
|
43028
|
+
const payload = { ...req.body };
|
|
43029
|
+
const { error } = validation.validate({ _id, ...payload });
|
|
43030
|
+
if (error) {
|
|
43031
|
+
next(new import_node_server_utils208.BadRequestError(error.message));
|
|
43032
|
+
return;
|
|
43033
|
+
}
|
|
43034
|
+
const result = await _updateManpowerRemarks(_id, payload);
|
|
43035
|
+
return res.json(result);
|
|
43036
|
+
} catch (error) {
|
|
43037
|
+
import_node_server_utils208.logger.log({ level: "error", message: error.message });
|
|
43038
|
+
next(error);
|
|
43039
|
+
return;
|
|
43040
|
+
}
|
|
43041
|
+
}
|
|
43042
|
+
async function updateRemarksStatus(req, res, next) {
|
|
43043
|
+
try {
|
|
43044
|
+
const validation = import_joi121.default.object({
|
|
43045
|
+
_id: import_joi121.default.string().hex().required(),
|
|
43046
|
+
status: import_joi121.default.string().required()
|
|
43047
|
+
});
|
|
43048
|
+
const _id = req.params.id;
|
|
43049
|
+
const payload = { ...req.body };
|
|
43050
|
+
const { error } = validation.validate({ _id, ...payload });
|
|
43051
|
+
if (error) {
|
|
43052
|
+
next(new import_node_server_utils208.BadRequestError(error.message));
|
|
43053
|
+
return;
|
|
43054
|
+
}
|
|
43055
|
+
const result = await _updateRemarksStatus(_id, payload);
|
|
43056
|
+
return res.json(result);
|
|
43057
|
+
} catch (error) {
|
|
43058
|
+
import_node_server_utils208.logger.log({ level: "error", message: error.message });
|
|
43059
|
+
next(error);
|
|
43060
|
+
return;
|
|
43061
|
+
}
|
|
43062
|
+
}
|
|
43063
|
+
return {
|
|
43064
|
+
createManpowerRemark,
|
|
43065
|
+
getManpowerRemarksAllSite,
|
|
43066
|
+
getManpowerRemarksBySiteId,
|
|
43067
|
+
updateManpowerMonitoringSettings,
|
|
43068
|
+
updateRemarksStatus
|
|
43069
|
+
};
|
|
43070
|
+
}
|
|
41055
43071
|
// Annotate the CommonJS export names for ESM import in node:
|
|
41056
43072
|
0 && (module.exports = {
|
|
41057
43073
|
ANPRMode,
|
|
@@ -41062,6 +43078,7 @@ function useOvernightParkingController() {
|
|
|
41062
43078
|
BulletinStatus,
|
|
41063
43079
|
CameraType,
|
|
41064
43080
|
DEVICE_STATUS,
|
|
43081
|
+
DayOfWeek,
|
|
41065
43082
|
EAccessCardTypes,
|
|
41066
43083
|
EAccessCardUserTypes,
|
|
41067
43084
|
FacilitySort,
|
|
@@ -41091,6 +43108,7 @@ function useOvernightParkingController() {
|
|
|
41091
43108
|
MIncidentReport,
|
|
41092
43109
|
MManpowerDesignations,
|
|
41093
43110
|
MManpowerMonitoring,
|
|
43111
|
+
MManpowerRemarks,
|
|
41094
43112
|
MMember,
|
|
41095
43113
|
MNfcPatrolLog,
|
|
41096
43114
|
MNfcPatrolRoute,
|
|
@@ -41103,6 +43121,7 @@ function useOvernightParkingController() {
|
|
|
41103
43121
|
MOnlineForm,
|
|
41104
43122
|
MOrg,
|
|
41105
43123
|
MOvernightParkingApprovalHours,
|
|
43124
|
+
MOvernightParkingRequest,
|
|
41106
43125
|
MPatrolLog,
|
|
41107
43126
|
MPatrolQuestion,
|
|
41108
43127
|
MPatrolRoute,
|
|
@@ -41127,6 +43146,8 @@ function useOvernightParkingController() {
|
|
|
41127
43146
|
MVisitorTransaction,
|
|
41128
43147
|
MWorkOrder,
|
|
41129
43148
|
OrgNature,
|
|
43149
|
+
OvernightParkingRequestSort,
|
|
43150
|
+
OvernightParkingRequestStatus,
|
|
41130
43151
|
PERSON_TYPES,
|
|
41131
43152
|
PMDashboardCollection,
|
|
41132
43153
|
Period,
|
|
@@ -41135,6 +43156,7 @@ function useOvernightParkingController() {
|
|
|
41135
43156
|
SiteStatus,
|
|
41136
43157
|
SortFields,
|
|
41137
43158
|
SortOrder,
|
|
43159
|
+
SubscriptionType,
|
|
41138
43160
|
UseAccessManagementRepo,
|
|
41139
43161
|
VehicleCategory,
|
|
41140
43162
|
VehicleOrder,
|
|
@@ -41143,6 +43165,7 @@ function useOvernightParkingController() {
|
|
|
41143
43165
|
VehicleType,
|
|
41144
43166
|
VisitorSort,
|
|
41145
43167
|
VisitorStatus,
|
|
43168
|
+
addressSchema,
|
|
41146
43169
|
allowedFieldsSite,
|
|
41147
43170
|
allowedNatures,
|
|
41148
43171
|
attendanceSchema,
|
|
@@ -41166,12 +43189,15 @@ function useOvernightParkingController() {
|
|
|
41166
43189
|
mAndEDashboardCollection,
|
|
41167
43190
|
manpowerDesignationsSchema,
|
|
41168
43191
|
manpowerMonitoringSchema,
|
|
43192
|
+
manpowerRemarksSchema,
|
|
41169
43193
|
nfcPatrolSettingsSchema,
|
|
41170
43194
|
nfcPatrolSettingsSchemaUpdate,
|
|
41171
43195
|
orgSchema,
|
|
43196
|
+
overnight_parking_requests_namespace_collection,
|
|
41172
43197
|
pestDashboardCollection,
|
|
41173
43198
|
poolDashboardCollection,
|
|
41174
43199
|
promoCodeSchema,
|
|
43200
|
+
remarksSchema,
|
|
41175
43201
|
robotSchema,
|
|
41176
43202
|
schema,
|
|
41177
43203
|
schemaBilling,
|
|
@@ -41198,6 +43224,7 @@ function useOvernightParkingController() {
|
|
|
41198
43224
|
schemaOccurrenceSubject,
|
|
41199
43225
|
schemaOnlineForm,
|
|
41200
43226
|
schemaOvernightParkingApprovalHours,
|
|
43227
|
+
schemaOvernightParkingRequest,
|
|
41201
43228
|
schemaPatrolLog,
|
|
41202
43229
|
schemaPatrolQuestion,
|
|
41203
43230
|
schemaPatrolRoute,
|
|
@@ -41222,6 +43249,7 @@ function useOvernightParkingController() {
|
|
|
41222
43249
|
schemaUpdateOccurrenceSubject,
|
|
41223
43250
|
schemaUpdateOnlineForm,
|
|
41224
43251
|
schemaUpdateOptions,
|
|
43252
|
+
schemaUpdateOvernightParkingRequest,
|
|
41225
43253
|
schemaUpdatePatrolLog,
|
|
41226
43254
|
schemaUpdatePatrolQuestion,
|
|
41227
43255
|
schemaUpdatePatrolRoute,
|
|
@@ -41295,6 +43323,8 @@ function useOvernightParkingController() {
|
|
|
41295
43323
|
useGuestManagementController,
|
|
41296
43324
|
useGuestManagementRepo,
|
|
41297
43325
|
useGuestManagementService,
|
|
43326
|
+
useHrmLabsAttendanceCtrl,
|
|
43327
|
+
useHrmLabsAttendanceSrvc,
|
|
41298
43328
|
useIncidentReportController,
|
|
41299
43329
|
useIncidentReportRepo,
|
|
41300
43330
|
useIncidentReportService,
|
|
@@ -41306,6 +43336,8 @@ function useOvernightParkingController() {
|
|
|
41306
43336
|
useManpowerMonitoringCtrl,
|
|
41307
43337
|
useManpowerMonitoringRepo,
|
|
41308
43338
|
useManpowerMonitoringSrvc,
|
|
43339
|
+
useManpowerRemarkCtrl,
|
|
43340
|
+
useManpowerRemarksRepo,
|
|
41309
43341
|
useMemberController,
|
|
41310
43342
|
useMemberRepo,
|
|
41311
43343
|
useNewDashboardController,
|
|
@@ -41337,6 +43369,9 @@ function useOvernightParkingController() {
|
|
|
41337
43369
|
useOrgRepo,
|
|
41338
43370
|
useOvernightParkingController,
|
|
41339
43371
|
useOvernightParkingRepo,
|
|
43372
|
+
useOvernightParkingRequestController,
|
|
43373
|
+
useOvernightParkingRequestRepo,
|
|
43374
|
+
useOvernightParkingRequestService,
|
|
41340
43375
|
usePatrolLogController,
|
|
41341
43376
|
usePatrolLogRepo,
|
|
41342
43377
|
usePatrolQuestionController,
|