mobioffice-cli 1.0.0 → 1.0.2
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/{src/index.ts → lib/index.d.ts} +1 -45
- package/lib/models/Feed-Details-Screen.model.d.ts +6 -0
- package/lib/models/Feed-Details-Screen.model.js +27 -0
- package/lib/models/action.model.d.ts +58 -0
- package/lib/models/action.model.js +315 -0
- package/lib/models/actions/doffing.d.ts +6 -0
- package/lib/models/actions/doffing.js +64 -0
- package/lib/models/actions/folding.d.ts +7 -0
- package/lib/models/actions/folding.js +37 -0
- package/lib/models/attendance.model.d.ts +44 -0
- package/lib/models/attendance.model.js +446 -0
- package/lib/models/cicoPost.model.d.ts +9 -0
- package/lib/models/cicoPost.model.js +19 -0
- package/lib/models/company.model.d.ts +67 -0
- package/lib/models/company.model.js +725 -0
- package/lib/models/contact-us/resquest.model.d.ts +30 -0
- package/lib/models/contact-us/resquest.model.js +73 -0
- package/lib/models/crud/crud.d.ts +7 -0
- package/lib/models/crud/crud.js +27 -0
- package/lib/models/customCollection.model.d.ts +9 -0
- package/lib/models/customCollection.model.js +40 -0
- package/lib/models/customer/customer.model.d.ts +32 -0
- package/lib/models/customer/customer.model.js +62 -0
- package/lib/models/deviceChangeReq.d.ts +10 -0
- package/lib/models/deviceChangeReq.js +138 -0
- package/lib/models/dispatch.model.d.ts +14 -0
- package/lib/models/dispatch.model.js +93 -0
- package/lib/models/feed.models.d.ts +8 -0
- package/lib/models/feed.models.js +97 -0
- package/lib/models/geofence.model.d.ts +7 -0
- package/lib/models/geofence.model.js +61 -0
- package/lib/models/leaveApplicationPost.model.d.ts +12 -0
- package/lib/models/leaveApplicationPost.model.js +72 -0
- package/lib/models/license.model.d.ts +25 -0
- package/lib/models/license.model.js +198 -0
- package/lib/models/log.model.d.ts +6 -0
- package/{src/models/log.model.ts → lib/models/log.model.js} +11 -11
- package/lib/models/meeting.model.d.ts +11 -0
- package/lib/models/meeting.model.js +79 -0
- package/lib/models/meter.model.d.ts +18 -0
- package/lib/models/meter.model.js +54 -0
- package/lib/models/missingPunchPost.model.d.ts +15 -0
- package/lib/models/missingPunchPost.model.js +69 -0
- package/lib/models/offline.model.d.ts +70 -0
- package/lib/models/offline.model.js +831 -0
- package/lib/models/post.model.d.ts +38 -0
- package/lib/models/post.model.js +94 -0
- package/lib/models/printDetailsScreen.model.d.ts +6 -0
- package/lib/models/printDetailsScreen.model.js +27 -0
- package/lib/models/pushNotifications/pushNotification.model.d.ts +4 -0
- package/lib/models/pushNotifications/pushNotification.model.js +17 -0
- package/lib/models/report-actions.model.d.ts +26 -0
- package/lib/models/report-actions.model.js +56 -0
- package/lib/models/report-definition-details.model.d.ts +13 -0
- package/lib/models/report-definition-details.model.js +85 -0
- package/lib/models/report-definition.model.d.ts +23 -0
- package/lib/models/report-definition.model.js +26 -0
- package/lib/models/report-definitions-summary.model.d.ts +8 -0
- package/lib/models/report-definitions-summary.model.js +59 -0
- package/lib/models/report-detail-data.model.d.ts +46 -0
- package/lib/models/report-detail-data.model.js +49 -0
- package/lib/models/report-visibility.model.d.ts +7 -0
- package/lib/models/report-visibility.model.js +42 -0
- package/lib/models/report.model.d.ts +19 -0
- package/lib/models/report.model.js +138 -0
- package/lib/models/reportGenerator.model.d.ts +164 -0
- package/lib/models/reportGenerator.model.js +642 -0
- package/lib/models/response.model.d.ts +18 -0
- package/lib/models/response.model.js +30 -0
- package/lib/models/steps.factory.model.d.ts +172 -0
- package/lib/models/steps.factory.model.js +187 -0
- package/lib/models/storeGupShupLog.model.d.ts +6 -0
- package/lib/models/storeGupShupLog.model.js +51 -0
- package/lib/models/summary.model.d.ts +10 -0
- package/{src/models/summary.model.ts → lib/models/summary.model.js} +28 -27
- package/lib/models/tasks/sub-task-group.model.d.ts +42 -0
- package/lib/models/tasks/sub-task-group.model.js +154 -0
- package/lib/models/tasks/tags.model.d.ts +29 -0
- package/lib/models/tasks/tags.model.js +70 -0
- package/lib/models/tasks/task-group.model.d.ts +53 -0
- package/lib/models/tasks/task-group.model.js +156 -0
- package/lib/models/tasks/task.model.d.ts +163 -0
- package/lib/models/tasks/task.model.js +603 -0
- package/lib/models/tempCollection.model.d.ts +40 -0
- package/{src/models/tempCollection.model.ts → lib/models/tempCollection.model.js} +114 -130
- package/lib/models/user.model.d.ts +42 -0
- package/lib/models/user.model.js +272 -0
- package/lib/models/utility.model.d.ts +13 -0
- package/lib/models/utility.model.js +93 -0
- package/lib/models/visitorManagement/acknowledgement.model.d.ts +9 -0
- package/lib/models/visitorManagement/acknowledgement.model.js +55 -0
- package/lib/models/visitorManagement/invite.model.d.ts +32 -0
- package/lib/models/visitorManagement/invite.model.js +326 -0
- package/lib/models/visitorManagement/newIn.model.d.ts +19 -0
- package/lib/models/visitorManagement/newIn.model.js +67 -0
- package/lib/models/visitorManagement/selfServe.model.d.ts +13 -0
- package/lib/models/visitorManagement/selfServe.model.js +46 -0
- package/lib/models/worklogPost.model.d.ts +6 -0
- package/lib/models/worklogPost.model.js +9 -0
- package/lib/services/customer.d.ts +30 -0
- package/lib/services/customer.js +354 -0
- package/lib/services/meeting.d.ts +19 -0
- package/lib/services/meeting.js +109 -0
- package/package.json +4 -1
- package/.prettierrc +0 -4
- package/a.js +0 -3
- package/scripts/1.ts +0 -1300
- package/scripts/GCloudPubSub/pub-sub-config.json +0 -12
- package/scripts/GCloudPubSub/visitorAutoRejection.ts +0 -86
- package/scripts/actions/assignUsersFromOneActionToOther.ts +0 -64
- package/scripts/actions/assignUsersListToAction.ts +0 -81
- package/scripts/actions/getActionsListOfUser.ts +0 -42
- package/scripts/actions/getCompanyUserDetails.ts +0 -49
- package/scripts/actions/giveActionToUser.ts +0 -41
- package/scripts/actions/giveUsersToActivitySelector.ts +0 -56
- package/scripts/actions/groupActionsInActivitySelector.ts +0 -101
- package/scripts/actions/modifySummaryReportDB.ts +0 -42
- package/scripts/actions/setUrlToActionStep.ts +0 -18
- package/scripts/actions/syncMySqlAttendanceDBWithFirebase.ts +0 -93
- package/scripts/actions/syncMySqlMeetingsDBWithFirebase.ts +0 -103
- package/scripts/actions/test.ts +0 -29
- package/scripts/actions/transferFeedsOldIdToNew.ts +0 -40
- package/scripts/actions/transformUserIntoManager.ts +0 -89
- package/scripts/argvConfig.js +0 -9
- package/scripts/backUpData/testCode.ts +0 -131
- package/scripts/benaraScripts/addWorkAreaMap.ts +0 -46
- package/scripts/benaraScripts/add_customers.ts +0 -26
- package/scripts/benaraScripts/add_customers_contact.ts +0 -27
- package/scripts/benaraScripts/add_empty_work_area.ts +0 -17
- package/scripts/benaraScripts/assignManagers.ts +0 -35
- package/scripts/benaraScripts/changeCheckInFlag.ts +0 -45
- package/scripts/benaraScripts/createCustomerContactsList.ts +0 -170
- package/scripts/benaraScripts/createUserByDeletingOldUser.ts +0 -70
- package/scripts/benaraScripts/createUsersAreaMapCollection.ts +0 -23
- package/scripts/benaraScripts/createWorkAreaMap.ts +0 -24
- package/scripts/benaraScripts/mapWorkAreasToUsers.ts +0 -112
- package/scripts/companies_data.json +0 -2496
- package/scripts/create_or_update_users.ts +0 -31
- package/scripts/csvToJson/csvToJson.ts +0 -90
- package/scripts/csvToJson/users.json +0 -3896
- package/scripts/db.js +0 -27
- package/scripts/db.json +0 -13
- package/scripts/dbMySql.ts +0 -63
- package/scripts/delete_action_steps.ts +0 -11
- package/scripts/delete_user.ts +0 -71
- package/scripts/dev_companies_data.json +0 -613
- package/scripts/enroll.xlsx +0 -0
- package/scripts/export_users.ts +0 -72
- package/scripts/files/visitorManagementFiles/displayScreen.json +0 -70
- package/scripts/files/visitorManagementFiles/init_report_visibility.ts +0 -79
- package/scripts/firebaseConfig.js +0 -12
- package/scripts/firebaseDocs/deleteIncommingCollection.ts +0 -47
- package/scripts/firebaseDocs/updateDoc.ts +0 -43
- package/scripts/getActionDataIntoJSON/getActionData.ts +0 -68
- package/scripts/get_attendance_by_any_date.ts +0 -14
- package/scripts/get_attendance_by_month.ts +0 -12
- package/scripts/get_attendance_monthly_by_team.ts +0 -11
- package/scripts/get_daily_report.ts +0 -10
- package/scripts/get_mangers.ts +0 -13
- package/scripts/grant_user_license.ts +0 -18
- package/scripts/init_CustomCollection.ts +0 -16
- package/scripts/init_action_steps.ts +0 -28
- package/scripts/init_actions.ts +0 -31
- package/scripts/init_company.ts +0 -18
- package/scripts/init_customer_mysql.ts +0 -12
- package/scripts/init_feed.ts +0 -4
- package/scripts/init_feed_details_screen.ts +0 -14
- package/scripts/init_geofence.ts +0 -26
- package/scripts/init_print_details_screen.ts +0 -14
- package/scripts/init_report_actions.ts +0 -24
- package/scripts/init_report_definition_detail.ts +0 -26
- package/scripts/init_report_definition_summary.ts +0 -16
- package/scripts/init_report_visibility.ts +0 -46
- package/scripts/init_user_customcollection.ts +0 -16
- package/scripts/json/action.json +0 -21
- package/scripts/json/company.json +0 -24
- package/scripts/json/report-action.json +0 -13
- package/scripts/json/report-def-deet.json +0 -43
- package/scripts/json/resp.json +0 -784
- package/scripts/json/steps.json +0 -24
- package/scripts/json/test.ts +0 -49
- package/scripts/mysqlConfig.ts +0 -9
- package/scripts/revoke_or_extend_license.ts +0 -14
- package/scripts/stream.js +0 -4
- package/scripts/testing1.ts +0 -35
- package/scripts/update/doc.json +0 -20
- package/scripts/update/getDocByPath.ts +0 -34
- package/scripts/update/updateDocByPath.ts +0 -47
- package/scripts/update/updateUsersOfCompanies.ts +0 -58
- package/scripts/update_actions.ts +0 -19
- package/scripts/update_actions_steps.ts +0 -19
- package/scripts/update_company.ts +0 -19
- package/scripts/update_geofence.ts +0 -20
- package/scripts/update_managers.ts +0 -16
- package/scripts/visitorMgmt/createArea.ts +0 -68
- package/scripts/visitorMgmt/createArea.txt +0 -3
- package/scripts/visitorMgmt/createVisitorPathInstructionDocs.ts +0 -130
- package/scripts/visitorMgmt/createVisitorPathInstructionDocs.txt +0 -18
- package/scripts/visitorMgmt/encryptDateString.ts +0 -71
- package/scripts/visitorMgmt/makeHostsManagersOfEachOther.ts +0 -117
- package/scripts/whatsapp_gupshup/sendMessage.ts +0 -97
- package/src/models/Feed-Details-Screen.model.ts +0 -29
- package/src/models/action.model.ts +0 -355
- package/src/models/actions/doffing.ts +0 -71
- package/src/models/actions/folding.ts +0 -39
- package/src/models/attendance.model.ts +0 -615
- package/src/models/cicoPost.model.ts +0 -20
- package/src/models/company.model.ts +0 -975
- package/src/models/contact-us/resquest.model.ts +0 -87
- package/src/models/crud/crud.ts +0 -30
- package/src/models/customCollection.model.ts +0 -47
- package/src/models/customer/customer.model.ts +0 -85
- package/src/models/deviceChangeReq.ts +0 -150
- package/src/models/dispatch.model.ts +0 -99
- package/src/models/feed.models.ts +0 -104
- package/src/models/geofence.model.ts +0 -61
- package/src/models/leaveApplicationPost.model.ts +0 -79
- package/src/models/license.model.ts +0 -215
- package/src/models/meeting.model.ts +0 -80
- package/src/models/meter.model.ts +0 -62
- package/src/models/missingPunchPost.model.ts +0 -84
- package/src/models/offline.model.ts +0 -1133
- package/src/models/post.model.ts +0 -105
- package/src/models/printDetailsScreen.model.ts +0 -30
- package/src/models/pushNotifications/pushNotification.model.ts +0 -17
- package/src/models/report-actions.model.ts +0 -57
- package/src/models/report-definition-details.model.ts +0 -89
- package/src/models/report-definition.model.ts +0 -26
- package/src/models/report-definitions-summary.model.ts +0 -59
- package/src/models/report-detail-data.model.ts +0 -49
- package/src/models/report-visibility.model.ts +0 -44
- package/src/models/report.model.ts +0 -179
- package/src/models/reportGenerator.model.ts +0 -883
- package/src/models/response.model.ts +0 -31
- package/src/models/steps.factory.model.ts +0 -195
- package/src/models/storeGupShupLog.model.ts +0 -49
- package/src/models/tasks/sub-task-group.model.ts +0 -173
- package/src/models/tasks/tags.model.ts +0 -113
- package/src/models/tasks/task-group.model.ts +0 -172
- package/src/models/tasks/task.model.ts +0 -681
- package/src/models/user.model.ts +0 -319
- package/src/models/utility.model.ts +0 -100
- package/src/models/visitorManagement/acknowledgement.model.ts +0 -71
- package/src/models/visitorManagement/invite.model.ts +0 -406
- package/src/models/visitorManagement/newIn.model.ts +0 -82
- package/src/models/visitorManagement/selfServe.model.ts +0 -58
- package/src/models/worklogPost.model.ts +0 -8
- package/src/services/customer.ts +0 -382
- package/src/services/meeting.ts +0 -123
- package/test/1.ts +0 -13
- package/test/db.js +0 -19
- package/test/firebaseConfig.js +0 -1
- package/tsconfig.json +0 -16
@@ -0,0 +1,446 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
exports.Attendance = void 0;
|
7
|
+
const action_model_1 = require("./action.model");
|
8
|
+
const company_model_1 = require("./company.model");
|
9
|
+
const license_model_1 = require("./license.model");
|
10
|
+
const user_model_1 = require("./user.model");
|
11
|
+
const utility_model_1 = require("./utility.model");
|
12
|
+
const crud_1 = __importDefault(require("./crud/crud"));
|
13
|
+
class Attendance {
|
14
|
+
static async getAttendancebyUser(firestore, company, phone, from_date, to_date, isOnlyMonthRequired) {
|
15
|
+
console.log("in getAttendance by user");
|
16
|
+
console.log(from_date, to_date);
|
17
|
+
let epochFromDate = await Attendance.convertToTimestamp(from_date);
|
18
|
+
let epochToDate = await license_model_1.License.convertDatetoTimestamp(to_date);
|
19
|
+
let datesInMonthList = await Attendance.getDatesInInterval(from_date, to_date, isOnlyMonthRequired);
|
20
|
+
let userStartAtDoc = Array.apply(null, Array(datesInMonthList.length)).map(() => {
|
21
|
+
return [];
|
22
|
+
});
|
23
|
+
let userEndAtDoc = Array.apply(null, Array(datesInMonthList.length)).map(() => {
|
24
|
+
return [];
|
25
|
+
});
|
26
|
+
let userId = await user_model_1.User.getUserIdByPhone(firestore, phone);
|
27
|
+
let companyId = await company_model_1.Company.getCompanyIdByNickName(firestore, company);
|
28
|
+
let actionId = await action_model_1.Action.getActionId(firestore, companyId, "check_in_out");
|
29
|
+
if (!actionId) {
|
30
|
+
return { data: datesInMonthList, message: "action" };
|
31
|
+
}
|
32
|
+
let userAttendance_snapshot = await Attendance.getAttendancefromFirestore(firestore, companyId, actionId, userId, epochFromDate, epochToDate);
|
33
|
+
if (userAttendance_snapshot.empty) {
|
34
|
+
return { data: datesInMonthList, message: "data not found" };
|
35
|
+
}
|
36
|
+
userAttendance_snapshot.forEach((doc) => {
|
37
|
+
if (epochFromDate <= doc.data().startAt &&
|
38
|
+
doc.data().startAt <= epochToDate) {
|
39
|
+
let startAt = new Date(doc.data().startAt).toLocaleString("en-GB", {
|
40
|
+
year: "numeric",
|
41
|
+
month: "numeric",
|
42
|
+
day: "numeric",
|
43
|
+
hour: "2-digit",
|
44
|
+
minute: "2-digit",
|
45
|
+
});
|
46
|
+
let idx = parseInt(startAt.split(",")[0].split("/")[0]) - 1;
|
47
|
+
userStartAtDoc[idx].push(startAt.replace(",", ""));
|
48
|
+
}
|
49
|
+
else if (epochFromDate <= doc.data().endAt &&
|
50
|
+
doc.data().endAt <= epochToDate) {
|
51
|
+
let endAt = new Date(doc.data().endAt).toLocaleString("en-GB", {
|
52
|
+
year: "numeric",
|
53
|
+
month: "numeric",
|
54
|
+
day: "numeric",
|
55
|
+
hour: "2-digit",
|
56
|
+
minute: "2-digit",
|
57
|
+
});
|
58
|
+
let idx = parseInt(endAt.split(",")[0].split("/")[0]) - 1;
|
59
|
+
userEndAtDoc[idx].push(endAt.replace(",", ""));
|
60
|
+
}
|
61
|
+
});
|
62
|
+
for (let date in datesInMonthList) {
|
63
|
+
let startAt = userStartAtDoc[date][userStartAtDoc[date].length - 1]
|
64
|
+
? userStartAtDoc[date][userStartAtDoc[date].length - 1]
|
65
|
+
: "";
|
66
|
+
let endAt = userEndAtDoc[date][0] ? userEndAtDoc[date][0] : "";
|
67
|
+
Object.assign(datesInMonthList[date], { in: startAt }, { status: null });
|
68
|
+
Object.assign(datesInMonthList[date], { out: endAt }, { status: null });
|
69
|
+
}
|
70
|
+
return { data: datesInMonthList, message: "Success" };
|
71
|
+
}
|
72
|
+
static async getByDateAttendancebyUser(firestore, company, phone, from_date, to_date) {
|
73
|
+
let epochFromDate = await Attendance.convertToTimestamp(from_date);
|
74
|
+
let epochToDate = await license_model_1.License.convertDatetoTimestamp(to_date);
|
75
|
+
let attendanceObj = {
|
76
|
+
"In Time": "",
|
77
|
+
"Out Time": "",
|
78
|
+
};
|
79
|
+
let userStartAt = "";
|
80
|
+
let userEndAt = "";
|
81
|
+
let userId = await user_model_1.User.getUserIdByPhone(firestore, phone);
|
82
|
+
let companyId = await company_model_1.Company.getCompanyIdByNickName(firestore, company);
|
83
|
+
let actionId = await action_model_1.Action.getActionId(firestore, companyId, "check_in_out");
|
84
|
+
if (!actionId) {
|
85
|
+
return { data: attendanceObj, message: "No action" };
|
86
|
+
}
|
87
|
+
let userAttendance_snapshot = await Attendance.getAttendancefromFirestore(firestore, companyId, actionId, userId, epochFromDate, epochToDate);
|
88
|
+
if (userAttendance_snapshot.empty) {
|
89
|
+
return { data: attendanceObj, message: "Data not found" };
|
90
|
+
}
|
91
|
+
userAttendance_snapshot.forEach((doc) => {
|
92
|
+
console.log("before if condition", epochFromDate, doc.data().startAt);
|
93
|
+
if (epochFromDate <= doc.data().startAt &&
|
94
|
+
doc.data().startAt <= epochToDate) {
|
95
|
+
console.log(epochFromDate, doc.data().startAt);
|
96
|
+
let startAt = new Date(doc.data().startAt).toLocaleString("en-GB", {
|
97
|
+
year: "numeric",
|
98
|
+
month: "numeric",
|
99
|
+
day: "numeric",
|
100
|
+
hour: "2-digit",
|
101
|
+
minute: "2-digit",
|
102
|
+
});
|
103
|
+
userStartAt = startAt.replace(",", "").split(" ")[1];
|
104
|
+
console.log(userStartAt);
|
105
|
+
}
|
106
|
+
else if (epochFromDate <= doc.data().endAt &&
|
107
|
+
doc.data().endAt <= epochToDate) {
|
108
|
+
let endAt = new Date(doc.data().endAt).toLocaleString("en-GB", {
|
109
|
+
year: "numeric",
|
110
|
+
month: "numeric",
|
111
|
+
day: "numeric",
|
112
|
+
hour: "2-digit",
|
113
|
+
minute: "2-digit",
|
114
|
+
});
|
115
|
+
userEndAt = endAt.replace(",", "").split(" ")[1];
|
116
|
+
}
|
117
|
+
});
|
118
|
+
console.log("startAt", userStartAt);
|
119
|
+
console.log("endAt", userEndAt);
|
120
|
+
attendanceObj["In Time"] = userStartAt;
|
121
|
+
attendanceObj["Out Time"] = userEndAt;
|
122
|
+
return { data: attendanceObj, message: "Success" };
|
123
|
+
}
|
124
|
+
static async getDatesInMonth(date, from_date) {
|
125
|
+
console.log("here", date, from_date);
|
126
|
+
let startDate;
|
127
|
+
const endDate = Number(date.split("-")[0]);
|
128
|
+
if (from_date) {
|
129
|
+
startDate = Number(from_date.split("-")[0]);
|
130
|
+
}
|
131
|
+
else {
|
132
|
+
startDate = 1;
|
133
|
+
}
|
134
|
+
let month = date.split("-")[1];
|
135
|
+
let year = date.split("-")[2];
|
136
|
+
let getDatesInMonth = [];
|
137
|
+
// let daysinmonth = new Date(parseInt(year), parseInt(month),0).getDate();
|
138
|
+
for (startDate; startDate <= endDate; startDate++) {
|
139
|
+
getDatesInMonth.push({
|
140
|
+
date: `${String(startDate).padStart(2, "0")}/${month}/${year}`,
|
141
|
+
in: "",
|
142
|
+
out: "",
|
143
|
+
status: "",
|
144
|
+
});
|
145
|
+
}
|
146
|
+
console.log(getDatesInMonth);
|
147
|
+
return getDatesInMonth;
|
148
|
+
}
|
149
|
+
static async getDatesInInterval(startDate, endDate, isOnlyMonthRequired) {
|
150
|
+
if (isOnlyMonthRequired) {
|
151
|
+
return this.getDaysOfMonth(startDate, endDate);
|
152
|
+
}
|
153
|
+
console.log(startDate, endDate);
|
154
|
+
const startYear = Number(startDate.split("-")[2]);
|
155
|
+
const startMonth = Number(startDate.split("-")[1]);
|
156
|
+
const startDay = Number(startDate.split("-")[0]);
|
157
|
+
const endYear = Number(endDate.split("-")[2]);
|
158
|
+
const endMonth = Number(endDate.split("-")[1]);
|
159
|
+
const endDay = Number(endDate.split("-")[0]);
|
160
|
+
let datesInInterval = [];
|
161
|
+
for (let i = startYear; i <= endYear; i++) {
|
162
|
+
console.log("year", i);
|
163
|
+
const currentYear = i;
|
164
|
+
const isStartYear = this.isStartYear(currentYear, startYear);
|
165
|
+
const isEndYear = this.isEndYear(currentYear, endYear);
|
166
|
+
if (isStartYear && isEndYear) {
|
167
|
+
console.log("only year");
|
168
|
+
const daysOfYear = this.getDaysOfYear(i, startMonth, endMonth, startDay, endDay, "onlyYear");
|
169
|
+
datesInInterval = [...datesInInterval, ...daysOfYear];
|
170
|
+
}
|
171
|
+
else if (isStartYear) {
|
172
|
+
console.log("start year");
|
173
|
+
const daysOfYear = this.getDaysOfYear(i, startMonth, 12, startDay, endDay, "startYear");
|
174
|
+
datesInInterval = [...datesInInterval, ...daysOfYear];
|
175
|
+
}
|
176
|
+
else if (isEndYear) {
|
177
|
+
console.log("end year");
|
178
|
+
const daysOfYear = this.getDaysOfYear(i, 1, endMonth, startDay, endDay, "endYear");
|
179
|
+
datesInInterval = [...datesInInterval, ...daysOfYear];
|
180
|
+
}
|
181
|
+
else {
|
182
|
+
console.log("middle year");
|
183
|
+
const daysOfYear = this.getDaysOfYear(i, 1, 12, startDay, endDay, "middleYear");
|
184
|
+
datesInInterval = [...datesInInterval, ...daysOfYear];
|
185
|
+
}
|
186
|
+
}
|
187
|
+
console.log(datesInInterval);
|
188
|
+
return datesInInterval;
|
189
|
+
}
|
190
|
+
static isStartMonth(currMonth, startMonth) {
|
191
|
+
return currMonth === startMonth;
|
192
|
+
}
|
193
|
+
static isEndMonth(currMonth, endMonth) {
|
194
|
+
return currMonth === endMonth;
|
195
|
+
}
|
196
|
+
static isStartYear(currYear, startYear) {
|
197
|
+
return currYear === startYear;
|
198
|
+
}
|
199
|
+
static isEndYear(currYear, endYear) {
|
200
|
+
return currYear === endYear;
|
201
|
+
}
|
202
|
+
static getDaysOfYear(year, startMonth, endMonth, startDay, endDay, yearType) {
|
203
|
+
let datesOfYear = [];
|
204
|
+
console.log(startMonth, endMonth);
|
205
|
+
for (let j = startMonth; j < endMonth + 1; j++) {
|
206
|
+
console.log("currMonth", j);
|
207
|
+
const isStartMonth = this.isStartMonth(j, startMonth);
|
208
|
+
const isEndMonth = this.isEndMonth(j, endMonth);
|
209
|
+
console.log("isStartMonth", isStartMonth);
|
210
|
+
console.log("isEndMonth", isEndMonth);
|
211
|
+
if (isStartMonth && isEndMonth && yearType === "onlyYear") {
|
212
|
+
console.log("only month");
|
213
|
+
const from_date = `${startDay}-${j}-${year}`;
|
214
|
+
const to_date = `${endDay}-${j}-${year}`;
|
215
|
+
const daysOfMonth = this.getDaysOfMonth(from_date, to_date);
|
216
|
+
datesOfYear = [...datesOfYear, ...daysOfMonth];
|
217
|
+
}
|
218
|
+
else if (isStartMonth &&
|
219
|
+
(yearType === "startYear" || yearType === "onlyYear")) {
|
220
|
+
console.log("start month");
|
221
|
+
const from_date = `${startDay}-${j}-${year}`;
|
222
|
+
const lastDateOfMonth = new Date(year, j, 0).getDate();
|
223
|
+
const to_date = `${lastDateOfMonth}-${j}-${year}`;
|
224
|
+
const daysOfMonth = this.getDaysOfMonth(from_date, to_date);
|
225
|
+
datesOfYear = [...datesOfYear, ...daysOfMonth];
|
226
|
+
}
|
227
|
+
else if (isEndMonth &&
|
228
|
+
(yearType === "endYear" || yearType === "onlyYear")) {
|
229
|
+
console.log("last month");
|
230
|
+
const from_date = `${1}-${j}-${year}`;
|
231
|
+
const to_date = `${endDay}-${j}-${year}`;
|
232
|
+
const daysOfMonth = this.getDaysOfMonth(from_date, to_date);
|
233
|
+
datesOfYear = [...datesOfYear, ...daysOfMonth];
|
234
|
+
}
|
235
|
+
else {
|
236
|
+
console.log("middle month");
|
237
|
+
const from_date = `${1}-${j}-${year}`;
|
238
|
+
const lastDateOfMonth = new Date(year, j, 0).getDate();
|
239
|
+
const to_date = `${lastDateOfMonth}-${j}-${year}`;
|
240
|
+
const daysOfMonth = this.getDaysOfMonth(from_date, to_date);
|
241
|
+
datesOfYear = [...datesOfYear, ...daysOfMonth];
|
242
|
+
}
|
243
|
+
}
|
244
|
+
return datesOfYear;
|
245
|
+
}
|
246
|
+
static getDaysOfMonth(startDay, endDay) {
|
247
|
+
const datesOfMonth = [];
|
248
|
+
const start_day = Number(startDay.split("-")[0]);
|
249
|
+
const end_day = Number(endDay.split("-")[0]);
|
250
|
+
const month = Number(startDay.split("-")[1]);
|
251
|
+
const year = Number(startDay.split("-")[2]);
|
252
|
+
for (let i = start_day; i <= end_day; i++) {
|
253
|
+
const date = `${i.toString().padStart(2, "0")}/${month
|
254
|
+
.toString()
|
255
|
+
.padStart(2, "0")}/${year}`;
|
256
|
+
datesOfMonth.push({
|
257
|
+
date: date,
|
258
|
+
in: "",
|
259
|
+
out: "",
|
260
|
+
status: "",
|
261
|
+
});
|
262
|
+
}
|
263
|
+
return datesOfMonth;
|
264
|
+
}
|
265
|
+
static async getAttendancefromFirestore(firestore, companyId, actionId, userId, epochFromDate, epochToDate) {
|
266
|
+
let userAttendancebyMonth = await firestore
|
267
|
+
.collection("Companies")
|
268
|
+
.doc(companyId)
|
269
|
+
.collection("Actions")
|
270
|
+
.doc(actionId)
|
271
|
+
.collection("check_in_out")
|
272
|
+
.where("userId", "==", userId)
|
273
|
+
.where("createdAt", ">=", epochFromDate)
|
274
|
+
.where("createdAt", "<=", epochToDate + 86400000)
|
275
|
+
.orderBy("createdAt", "desc")
|
276
|
+
.get();
|
277
|
+
return userAttendancebyMonth;
|
278
|
+
}
|
279
|
+
static async convertToTimestamp(date) {
|
280
|
+
const [day, month, year] = date.split("-");
|
281
|
+
const timestamp = new Date(year, month - 1, day).getTime();
|
282
|
+
return timestamp;
|
283
|
+
}
|
284
|
+
static async getformateddate(timestamp) {
|
285
|
+
let temp = new Date(timestamp).toLocaleString("en-GB", {
|
286
|
+
year: "numeric",
|
287
|
+
month: "numeric",
|
288
|
+
day: "numeric",
|
289
|
+
hour: "2-digit",
|
290
|
+
minute: "2-digit",
|
291
|
+
});
|
292
|
+
let time = temp.split(",")[1].replace(" ", "");
|
293
|
+
let date = temp.split(",")[0].replace(",", "");
|
294
|
+
return [date, time];
|
295
|
+
}
|
296
|
+
static async getAttendancebyMonth(firestore, nickName, phone, month, year, fromDate, toDate) {
|
297
|
+
let endDate = new Date(parseInt(year), parseInt(month), 0).getDate();
|
298
|
+
let from_date;
|
299
|
+
let to_date;
|
300
|
+
let isOnlyMonthRequired = false;
|
301
|
+
if (fromDate && toDate) {
|
302
|
+
from_date = fromDate.split("/").join("-");
|
303
|
+
to_date = toDate.split("/").join("-");
|
304
|
+
}
|
305
|
+
else {
|
306
|
+
from_date = `01-${month}-${year}`;
|
307
|
+
to_date = `${endDate}-${month}-${year}`;
|
308
|
+
isOnlyMonthRequired = true;
|
309
|
+
}
|
310
|
+
console.log(from_date, to_date);
|
311
|
+
return Attendance.getAttendancebyUser(firestore, nickName, phone, from_date, to_date, isOnlyMonthRequired);
|
312
|
+
}
|
313
|
+
static async getAttendanceMonthlybyTeam(firestore, nickName, month, year) {
|
314
|
+
let employeeslistbycompany = await company_model_1.Company.getUsersListbyCompany(firestore, nickName);
|
315
|
+
if (employeeslistbycompany.length < 1) {
|
316
|
+
return "No employees in present company";
|
317
|
+
}
|
318
|
+
let employeesAttendance = await Promise.all(employeeslistbycompany.map(async (doc) => {
|
319
|
+
let userMothlyAttendance = await Attendance.getAttendancebyMonth(firestore, nickName, doc.phone, month, year);
|
320
|
+
let employeeName = doc.name;
|
321
|
+
if (!employeeName) {
|
322
|
+
employeeName = "unknown";
|
323
|
+
}
|
324
|
+
return { name: employeeName, data: userMothlyAttendance.data };
|
325
|
+
}));
|
326
|
+
return employeesAttendance;
|
327
|
+
}
|
328
|
+
static async getDailyReport(firestore, nickName, phoneNo) {
|
329
|
+
let employeeslistbycompany = await company_model_1.Company.getTeamListOfManager(firestore, nickName, phoneNo);
|
330
|
+
if (employeeslistbycompany.length < 1) {
|
331
|
+
return null;
|
332
|
+
}
|
333
|
+
let toDate = await Attendance.getCurrentdate();
|
334
|
+
toDate = toDate.replace(/\//g, "-");
|
335
|
+
console.log(toDate);
|
336
|
+
let employeesAttendance = await Promise.all(employeeslistbycompany.map(async (doc) => {
|
337
|
+
let employeeAttendance = await Attendance.getByDateAttendancebyUser(firestore, nickName, doc.phone, toDate, toDate);
|
338
|
+
let employeeName = doc.name;
|
339
|
+
console.log(employeeAttendance);
|
340
|
+
if (!employeeName) {
|
341
|
+
employeeName = "unknown";
|
342
|
+
}
|
343
|
+
return { name: employeeName, ...employeeAttendance.data };
|
344
|
+
}));
|
345
|
+
return employeesAttendance;
|
346
|
+
}
|
347
|
+
static async getCurrentdate() {
|
348
|
+
return new Date().toLocaleDateString("en-GB", { timeZone: "asia/kolkata" });
|
349
|
+
}
|
350
|
+
static async getCurrentTime() {
|
351
|
+
return new Date().toLocaleTimeString("en-GB", {
|
352
|
+
timeZone: "asia/kolkata",
|
353
|
+
hour: "2-digit",
|
354
|
+
minute: "2-digit",
|
355
|
+
hourCycle: "h12",
|
356
|
+
});
|
357
|
+
}
|
358
|
+
static async uploadEntryToReportDB(attendanceConnection, info) {
|
359
|
+
const curdService = new crud_1.default(attendanceConnection);
|
360
|
+
try {
|
361
|
+
const time = await utility_model_1.Utilities.epochToMySqlDateTime(info.time);
|
362
|
+
const qryString = `INSERT INTO attendanceEntries (companyId, employeeName,
|
363
|
+
eventType, timeInt, time, actionName, phoneNo, isInactive)
|
364
|
+
VALUES ('${info.companyId}',
|
365
|
+
'${info.employeeName}',
|
366
|
+
'${info.eventType}',
|
367
|
+
${info.time},
|
368
|
+
'${time}',
|
369
|
+
'${info.actionName}',
|
370
|
+
'${info.phoneNo}', false);`;
|
371
|
+
const result = await curdService.query(qryString);
|
372
|
+
}
|
373
|
+
catch (error) {
|
374
|
+
console.log(error.message);
|
375
|
+
}
|
376
|
+
}
|
377
|
+
static async enrollWorkerFaceToDB(connection, data) {
|
378
|
+
const curdService = new crud_1.default(connection);
|
379
|
+
try {
|
380
|
+
const currentTimestamp = new Date()
|
381
|
+
.toISOString()
|
382
|
+
.replace(/T/, " ")
|
383
|
+
.replace(/\..+/, "");
|
384
|
+
const qryString = `INSERT INTO worker_enroll (
|
385
|
+
refId, companyId, faceJpg, name, faceTemplates, enrolledBy, dob, proofType, phone, inchargeName, proofImage, createdAt)
|
386
|
+
VALUES ('${data.id}', '${data.companyId}', '${data.faceJpg}',
|
387
|
+
'${data.name}', '${data.faceTemplates}', '${data.enrolledBy}', '${data.dob}',
|
388
|
+
'${data.proofType}','${data.phone}', '${data.inchargeName}', '${data.proofImage}', '${currentTimestamp}');`;
|
389
|
+
return await curdService.query(qryString);
|
390
|
+
}
|
391
|
+
catch (error) {
|
392
|
+
console.log(error.message);
|
393
|
+
return error;
|
394
|
+
}
|
395
|
+
}
|
396
|
+
static async checkUserExist(connection, id) {
|
397
|
+
const curdService = new crud_1.default(connection);
|
398
|
+
try {
|
399
|
+
const qryString = `SELECT * FROM worker_enroll WHERE refId = '${id}'`;
|
400
|
+
return await curdService.query(qryString);
|
401
|
+
}
|
402
|
+
catch (error) {
|
403
|
+
console.log(error.message);
|
404
|
+
return error;
|
405
|
+
}
|
406
|
+
}
|
407
|
+
static async updateExistUser(connection, data, id) {
|
408
|
+
const curdService = new crud_1.default(connection);
|
409
|
+
try {
|
410
|
+
const qryString = `UPDATE worker_enroll
|
411
|
+
SET companyId = '${data.companyId}', faceJpg = '${data.faceJpg}', faceId = '${data.faceId}', faceName = '${data.faceName}', faceTemplates = '${data.faceTemplates}', Name = '${data.Name}',
|
412
|
+
DOB = '${data.DOB}', ProofType = '${data.ProofType}', Phone = '${data.Phone}', InchargeName = '${data.InchargeName}', ProofImage = '${data.ProofImage}', created_at = CURDATE()
|
413
|
+
WHERE refId = '${id}';`;
|
414
|
+
return await curdService.query(qryString);
|
415
|
+
}
|
416
|
+
catch (error) {
|
417
|
+
console.log(error.message);
|
418
|
+
return error;
|
419
|
+
}
|
420
|
+
}
|
421
|
+
static async workerCheckIn(connection, enrollId, companyId, actionName) {
|
422
|
+
const curdService = new crud_1.default(connection);
|
423
|
+
try {
|
424
|
+
const qryString = `INSERT INTO worker_attendance (enrollId, companyId, timeStamp, actionType)
|
425
|
+
VALUES ('${enrollId}', '${companyId}', NOW(), '${actionName}');`;
|
426
|
+
return await curdService.query(qryString);
|
427
|
+
}
|
428
|
+
catch (error) {
|
429
|
+
console.log(error.message);
|
430
|
+
return error;
|
431
|
+
}
|
432
|
+
}
|
433
|
+
static async cicoValidate(connection, enrollId, action) {
|
434
|
+
const curdService = new crud_1.default(connection);
|
435
|
+
try {
|
436
|
+
const currentDate = new Date().toISOString().split("T")[0];
|
437
|
+
const qryString = `SELECT * FROM worker_attendance WHERE enrollId = ${enrollId} AND actionType='${action}' AND timeStamp >= '${currentDate} 00:00:00' AND timeStamp <= '${currentDate} 23:59:59';`;
|
438
|
+
return await curdService.query(qryString);
|
439
|
+
}
|
440
|
+
catch (error) {
|
441
|
+
console.log(error.message);
|
442
|
+
return error;
|
443
|
+
}
|
444
|
+
}
|
445
|
+
}
|
446
|
+
exports.Attendance = Attendance;
|
@@ -0,0 +1,9 @@
|
|
1
|
+
import { Post } from "./post.model";
|
2
|
+
import * as admin from "firebase-admin";
|
3
|
+
declare class CheckInCheckOutPost extends Post {
|
4
|
+
actionEvent: string;
|
5
|
+
actionType: string;
|
6
|
+
actionName: string;
|
7
|
+
static sendCICOPost(firestore: admin.firestore.Firestore, cicoPost: any): Promise<void>;
|
8
|
+
}
|
9
|
+
export { CheckInCheckOutPost };
|
@@ -0,0 +1,19 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.CheckInCheckOutPost = void 0;
|
4
|
+
const post_model_1 = require("./post.model");
|
5
|
+
class CheckInCheckOutPost extends post_model_1.Post {
|
6
|
+
actionEvent = "";
|
7
|
+
actionType = "checkInOut";
|
8
|
+
actionName = "check_in_out";
|
9
|
+
static async sendCICOPost(firestore, cicoPost) {
|
10
|
+
await firestore.collection("Companies")
|
11
|
+
.doc(cicoPost.companyId)
|
12
|
+
.collection("Actions")
|
13
|
+
.doc(cicoPost.actionId)
|
14
|
+
.collection(cicoPost.actionName)
|
15
|
+
.doc(cicoPost.eventId)
|
16
|
+
.set(cicoPost);
|
17
|
+
}
|
18
|
+
}
|
19
|
+
exports.CheckInCheckOutPost = CheckInCheckOutPost;
|
@@ -0,0 +1,67 @@
|
|
1
|
+
import * as admin from "firebase-admin";
|
2
|
+
declare class Company {
|
3
|
+
id: string;
|
4
|
+
nickname: string;
|
5
|
+
description: string;
|
6
|
+
image: string;
|
7
|
+
name: string;
|
8
|
+
users: string[];
|
9
|
+
endpoints: string[];
|
10
|
+
static initCompany(firestore: admin.firestore.Firestore): Promise<void>;
|
11
|
+
static getCompanyIdByNickName(firestore: admin.firestore.Firestore, nickName: string): Promise<string>;
|
12
|
+
static getOrCreateCompany(firestore: admin.firestore.Firestore, companyDetails: any): Promise<any[]>;
|
13
|
+
static createCompany(firestore: admin.firestore.Firestore, companyDetails: any): Promise<any>;
|
14
|
+
static convertCompanyDataType(companyDetails: any): Promise<any>;
|
15
|
+
static updateCompany(firestore: admin.firestore.Firestore, nickName: string, companyDoc: any): Promise<"Updated successfully" | "Company doesn't exists">;
|
16
|
+
static addUserIdsInsideCompanies(firestore: admin.firestore.Firestore, arrayUnion: any, nickName: string): Promise<void>;
|
17
|
+
static checkIfUserExists(firestore: admin.firestore.Firestore, companyId: string, userId: string): Promise<true | null>;
|
18
|
+
static intiActionsInCompany(firestore: admin.firestore.Firestore, companyId: string, actions: []): Promise<[]>;
|
19
|
+
static getUserDetailsByPhone(firestore: admin.firestore.Firestore, nickName: string, phoneNumber: string): Promise<any>;
|
20
|
+
static createOrUpdateUser(firestore: admin.firestore.Firestore, auth: admin.auth.Auth, arrayUnion: any, nickName: string, newDetails: any): Promise<"Please provide actions" | "error occured when adding userId in users array" | {
|
21
|
+
companyId: string;
|
22
|
+
userId: string;
|
23
|
+
actions: string[];
|
24
|
+
}>;
|
25
|
+
static createNewUser(firestore: admin.firestore.Firestore, auth: any, arrayUnion: any, nickName: string, newDetails: any): Promise<"Please provide actions" | "error occured when adding userId in users array" | {
|
26
|
+
companyId: string;
|
27
|
+
userId: string;
|
28
|
+
actions: string[];
|
29
|
+
} | {
|
30
|
+
data: admin.firestore.DocumentData;
|
31
|
+
message: string;
|
32
|
+
}>;
|
33
|
+
static updateUser(firestore: admin.firestore.Firestore, arrayUnion: any, nickName: string, newDetails: any): Promise<admin.firestore.DocumentData>;
|
34
|
+
static addReportingToInfoToDetails(firestore: admin.firestore.Firestore, newDetails: any, companyId: string): Promise<void>;
|
35
|
+
static getSubordinatesById(firestore: admin.firestore.Firestore, uid: string, cid: string): Promise<any[]>;
|
36
|
+
static updateUserPhone(firestore: admin.firestore.Firestore, uid: string, phone: string): Promise<true | null>;
|
37
|
+
static convertUserDataType(data: any): Promise<any>;
|
38
|
+
static createUser(firestore: admin.firestore.Firestore, auth: admin.auth.Auth, arrayUnion: any, companyId: string, newDetails: any): Promise<"Please provide actions" | "error occured when adding userId in users array" | {
|
39
|
+
companyId: string;
|
40
|
+
userId: string;
|
41
|
+
actions: string[];
|
42
|
+
}>;
|
43
|
+
static addUserId(firestore: admin.firestore.Firestore, arrayUnion: any, companyId: string, id: string, actions: string[]): Promise<string[]>;
|
44
|
+
static getCompanyDocByCompanyId(firestore: admin.firestore.Firestore, companyId: string): Promise<admin.firestore.DocumentData | undefined>;
|
45
|
+
static addUserIdinCompany(firestore: admin.firestore.Firestore, arrayUnion: any, companyId: string, userId: string): Promise<void>;
|
46
|
+
static getUsersListbyCompany(firestore: admin.firestore.Firestore, nickName: string): Promise<any[]>;
|
47
|
+
static getCompanyIdbyNickname(firestore: admin.firestore.Firestore, nickName: string): Promise<string>;
|
48
|
+
static userIdbycompany(firestore: admin.firestore.Firestore, nickName: string): Promise<any>;
|
49
|
+
static getMangersList(firestore: admin.firestore.Firestore, nickName: string): Promise<unknown[]>;
|
50
|
+
static getTeamListOfManager(firestore: admin.firestore.Firestore, nickName: string, phone: string): Promise<admin.firestore.DocumentData[]>;
|
51
|
+
initByNickname(db: any, nickname: string): Promise<void>;
|
52
|
+
initViaSnapshotDoc(doc: admin.firestore.DocumentData): void;
|
53
|
+
static testFB(fdb: admin.firestore.Firestore, s: string): Promise<any>;
|
54
|
+
static getUsers(firestore: admin.firestore.Firestore, nickname: string): Promise<{
|
55
|
+
users: any;
|
56
|
+
id: any;
|
57
|
+
}>;
|
58
|
+
static getCompanyDocByNickName(fdb: admin.firestore.Firestore, nickname: string): Promise<admin.firestore.DocumentData>;
|
59
|
+
static getCompaniesList(firestore: admin.firestore.Firestore): Promise<any>;
|
60
|
+
static getActionDocByEventId(firestore: admin.firestore.Firestore, eventId: string, companyId: string, actionName: string): Promise<admin.firestore.DocumentData | null>;
|
61
|
+
static getActionDocByEnrollId(firestore: admin.firestore.Firestore, enrollId: string, companyId: string, actionId: string, actionName: string): Promise<admin.firestore.DocumentData | null>;
|
62
|
+
static getActionDocsByEventIdsForMpApproval(firestore: admin.firestore.Firestore, eventIds: string[], companyId: string, actionName: string): Promise<any[]>;
|
63
|
+
static markActionDocAsProcessed(firestore: admin.firestore.Firestore, eventId: string, companyId: string, actionName: string): Promise<void>;
|
64
|
+
static getActionInfo(firestore: admin.firestore.Firestore, companyId: string, actionName: string): Promise<admin.firestore.DocumentData | undefined>;
|
65
|
+
static updateReportingTo(firestore: admin.firestore.Firestore, arrayUnion: any, nickName: string, userData: any): Promise<string>;
|
66
|
+
}
|
67
|
+
export { Company };
|