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
@@ -1,79 +0,0 @@
|
|
1
|
-
import { Post } from "./post.model"
|
2
|
-
import * as admin from "firebase-admin";
|
3
|
-
import { Action } from "./action.model";
|
4
|
-
import { User } from "./user.model";
|
5
|
-
import { Company } from "./company.model";
|
6
|
-
import { Attendance } from "./attendance.model";
|
7
|
-
import { Utilities } from "./utility.model";
|
8
|
-
|
9
|
-
class LeaveApplication extends Post {
|
10
|
-
actionEvent: string = "";
|
11
|
-
actionType: string = "worklog";
|
12
|
-
actionName: string = "leave-application";
|
13
|
-
isProcessed: boolean = false;
|
14
|
-
|
15
|
-
static async setIncomingInfoToLeaveApplicationPost(info: any, post: LeaveApplication) {
|
16
|
-
post.actionEvent = info.extra.actionEvent;
|
17
|
-
post.actionId = info.extra.actionId;
|
18
|
-
post.actionName = info.extra.actionName;
|
19
|
-
post.actionType = info.extra.actionType;
|
20
|
-
post.companyId = info.extra.companyId;
|
21
|
-
post.createdAt = info.extra.createdAt;
|
22
|
-
post.description = `Leave application for ${info.extra.extraData.reason} on ${info.extra.extraData.leaveDate}.`;
|
23
|
-
post.eventId = info.extra.eventId;
|
24
|
-
post.isGeofence = info.extra.isGeofence;
|
25
|
-
post.userId = info.userId;
|
26
|
-
const newExtraData = await this.modifyExtraDataForLeave(info);
|
27
|
-
post.extraData = newExtraData;
|
28
|
-
post.isProcessed = false;
|
29
|
-
post.target = info.target || "" ;
|
30
|
-
post.time = info.extra.time;
|
31
|
-
post.checkInternet = info.extra.checkInternet;
|
32
|
-
return post;
|
33
|
-
}
|
34
|
-
|
35
|
-
static async modifyExtraDataForLeave(info: any) {
|
36
|
-
const time = info.extra.startAt;
|
37
|
-
const date = new Date(info.extra.startAt).toLocaleDateString("en-GB");
|
38
|
-
const newExtraData = {
|
39
|
-
...info.extra.extraData,
|
40
|
-
date: date,
|
41
|
-
time: time,
|
42
|
-
reason: info.extra.extraData.reason,
|
43
|
-
appliedDate: info.extra.extraData.leaveDate,
|
44
|
-
forApprovalText : "Approval Pending"
|
45
|
-
}
|
46
|
-
return newExtraData;
|
47
|
-
}
|
48
|
-
|
49
|
-
static async getOpenedLeaveRequests(firestore: admin.firestore.Firestore,nickName: string,phone: string,actionName:string) {
|
50
|
-
try{
|
51
|
-
let teamList = await Company.getTeamListOfManager(firestore, nickName, phone);
|
52
|
-
teamList = teamList.map(user => user.id);
|
53
|
-
const allOpenRequests = [];
|
54
|
-
const companyId = await Company.getCompanyIdByNickName(firestore, nickName);
|
55
|
-
const actionId = await Action.getActionId(firestore, companyId, actionName);
|
56
|
-
for (let userId of teamList) {
|
57
|
-
const openRequestsDocs = await firestore.collection("Companies")
|
58
|
-
.doc(companyId)
|
59
|
-
.collection("Actions")
|
60
|
-
.doc(actionId)
|
61
|
-
.collection(actionName)
|
62
|
-
.where("isProcessed", "==", false)
|
63
|
-
.where("userId", "==", userId)
|
64
|
-
.get();
|
65
|
-
const openRequests = openRequestsDocs.docs.map(doc => {
|
66
|
-
return doc.data();
|
67
|
-
})
|
68
|
-
allOpenRequests.push(...openRequests);
|
69
|
-
}
|
70
|
-
return allOpenRequests;
|
71
|
-
}
|
72
|
-
catch(error:any){
|
73
|
-
throw new Error(error.message)
|
74
|
-
}
|
75
|
-
}
|
76
|
-
|
77
|
-
}
|
78
|
-
|
79
|
-
export { LeaveApplication };
|
@@ -1,215 +0,0 @@
|
|
1
|
-
import * as admin from 'firebase-admin';
|
2
|
-
import { Action } from './action.model';
|
3
|
-
import { Company } from './company.model';
|
4
|
-
import { User } from './user.model';
|
5
|
-
|
6
|
-
class License {
|
7
|
-
company: string = "";
|
8
|
-
to_date?: string = "";//new Date();
|
9
|
-
from_date?: string = "";//new Date();
|
10
|
-
user: string = "";
|
11
|
-
license_type?: string = "";
|
12
|
-
device_id: string = "";
|
13
|
-
static minimumDevices: number = 1;
|
14
|
-
|
15
|
-
static async validateUserLicense(firestore: admin.firestore.Firestore,
|
16
|
-
arrayUnion: any,
|
17
|
-
today_date: admin.firestore.Timestamp,
|
18
|
-
nickName: string,
|
19
|
-
user: string,
|
20
|
-
device_id: string,
|
21
|
-
modelName: string,
|
22
|
-
brand: string) {
|
23
|
-
user = user.replace(' ', '+')
|
24
|
-
console.log(user)
|
25
|
-
let userDetails_snapshot = await firestore.collection('Licenses').where('company', '==', nickName).where('user', '==', user).get();
|
26
|
-
if (userDetails_snapshot.empty) {
|
27
|
-
return ["User not found", null, null]
|
28
|
-
}
|
29
|
-
let flag: boolean = false
|
30
|
-
let device_flag: boolean = false
|
31
|
-
let license_date = await Promise.all(userDetails_snapshot.docs.map(async (doc) => {
|
32
|
-
if (doc.data().device_id == 1) {
|
33
|
-
doc.ref.update({
|
34
|
-
device_id: device_id,
|
35
|
-
extraDevices: arrayUnion({
|
36
|
-
deviceId: device_id,
|
37
|
-
modelName: modelName,
|
38
|
-
brandName: brand,
|
39
|
-
fromData: Date.now()
|
40
|
-
})
|
41
|
-
})
|
42
|
-
device_flag = true
|
43
|
-
if ((today_date.seconds * 1000) <= doc.data().to_date) {
|
44
|
-
flag = true
|
45
|
-
}
|
46
|
-
} else {
|
47
|
-
let extraDevices = doc.data().extraDevices ? doc.data().extraDevices : [];
|
48
|
-
extraDevices = extraDevices.map((device: any) => {
|
49
|
-
return device.deviceId;
|
50
|
-
})
|
51
|
-
const uniqueExtraDevices = Array.from(new Set([...extraDevices]));
|
52
|
-
for (let storedDeviceId of uniqueExtraDevices) {
|
53
|
-
if (device_id == storedDeviceId) {
|
54
|
-
device_flag = true
|
55
|
-
}
|
56
|
-
}
|
57
|
-
if ((today_date.seconds * 1000) <= doc.data().to_date) {
|
58
|
-
flag = true
|
59
|
-
}
|
60
|
-
if (!device_flag) {
|
61
|
-
let userInfo = await Company.getUserDetailsByPhone(firestore, nickName, user);
|
62
|
-
userInfo = userInfo[0];
|
63
|
-
const devicesLimit = userInfo.devicesLimit ? userInfo.devicesLimit : this.minimumDevices;
|
64
|
-
console.log("devicesLimit", devicesLimit);
|
65
|
-
if (flag) {
|
66
|
-
if (extraDevices.length < Number(devicesLimit)) {
|
67
|
-
const objToStore = {
|
68
|
-
deviceId: device_id,
|
69
|
-
modelName: modelName,
|
70
|
-
brandName: brand,
|
71
|
-
fromDate: Date.now()
|
72
|
-
}
|
73
|
-
userDetails_snapshot.forEach((doc) => {
|
74
|
-
doc.ref.update({
|
75
|
-
extraDevices: arrayUnion(objToStore)
|
76
|
-
})
|
77
|
-
})
|
78
|
-
device_flag = true;
|
79
|
-
}
|
80
|
-
}
|
81
|
-
}
|
82
|
-
}
|
83
|
-
return doc.data().to_date
|
84
|
-
}))
|
85
|
-
let filtered_newest_date: any = license_date.reduce((a, b) => { return a > b ? a : b })
|
86
|
-
let convert_to_timestamp = await License.convertTimestamptoDate(filtered_newest_date)
|
87
|
-
const status = flag && device_flag;
|
88
|
-
const action = "requestForm";
|
89
|
-
const companyId = await Company.getCompanyIdByNickName(firestore, nickName);
|
90
|
-
const actionId = await Action.getActionId(firestore, companyId, action);
|
91
|
-
return [status, convert_to_timestamp, device_flag, actionId]
|
92
|
-
}
|
93
|
-
|
94
|
-
static async getUserDevices(firestore: admin.firestore.Firestore, nickName: string, phone: string) {
|
95
|
-
let license: any = await firestore.collection("Licenses")
|
96
|
-
.where("user", "==", `+${phone}`)
|
97
|
-
.where("company", "==", nickName)
|
98
|
-
.get();
|
99
|
-
license = license.docs[0].data();
|
100
|
-
const devicesList = license.extraDevices.map((obj: any) => {
|
101
|
-
let label;
|
102
|
-
if (obj.modelName && obj.brandName) {
|
103
|
-
label = `${obj.brandName}(${obj.modelName})`;
|
104
|
-
}
|
105
|
-
return {
|
106
|
-
id: obj.deviceId,
|
107
|
-
label: label ? label : obj.deviceId
|
108
|
-
}
|
109
|
-
});
|
110
|
-
if (devicesList.length > 0) {
|
111
|
-
return {
|
112
|
-
data: {
|
113
|
-
resArray: devicesList,
|
114
|
-
},
|
115
|
-
message: "success"
|
116
|
-
};
|
117
|
-
} else {
|
118
|
-
return {
|
119
|
-
data: {
|
120
|
-
resArray: [{
|
121
|
-
label: "No devices found"
|
122
|
-
}]
|
123
|
-
},
|
124
|
-
message: "Error"
|
125
|
-
}
|
126
|
-
}
|
127
|
-
}
|
128
|
-
|
129
|
-
static async grantUserLicense(firestore: admin.firestore.Firestore, nickName: string, newUserDetails: License) {
|
130
|
-
|
131
|
-
console.log(newUserDetails)
|
132
|
-
|
133
|
-
newUserDetails.user = "+" + newUserDetails.user
|
134
|
-
let to_date = await License.convertDatetoTimestamp(newUserDetails["to_date"])
|
135
|
-
let from_date = await License.convertDatetoTimestamp(newUserDetails["from_date"])
|
136
|
-
|
137
|
-
console.log(to_date, from_date)
|
138
|
-
|
139
|
-
Object.assign(newUserDetails, { company: nickName }, { to_date: to_date }, { from_date: from_date })
|
140
|
-
let company_id = await Company.getCompanyIdbyNickname(firestore, newUserDetails.company)
|
141
|
-
if (company_id == 'Not found') {
|
142
|
-
return "Company does not exists"
|
143
|
-
}
|
144
|
-
let snapshot = await firestore.collection('Companies').doc(company_id).collection('Users').where('phone', '==', newUserDetails.user).get()
|
145
|
-
if (snapshot.empty) {
|
146
|
-
return "User does not exists"
|
147
|
-
}
|
148
|
-
let user_license = await firestore.collection('Licenses').where('company', '==', `${newUserDetails.company}`).where('user', '==', newUserDetails.user).get();
|
149
|
-
|
150
|
-
let flag: boolean = false
|
151
|
-
let user_list: any = []
|
152
|
-
user_license.forEach((doc) => {
|
153
|
-
user_list.push(doc.data())
|
154
|
-
if (newUserDetails.company == doc.data().company) {
|
155
|
-
if (newUserDetails.user == doc.data().user) {
|
156
|
-
if (newUserDetails.license_type == doc.data().license_type) {
|
157
|
-
if (newUserDetails.to_date == doc.data().to_date) {
|
158
|
-
flag = true
|
159
|
-
}
|
160
|
-
}
|
161
|
-
}
|
162
|
-
}
|
163
|
-
})
|
164
|
-
if (flag) {
|
165
|
-
return `${newUserDetails.user} data already exists`
|
166
|
-
}
|
167
|
-
await firestore.collection('Licenses').add(newUserDetails)
|
168
|
-
return `${newUserDetails.user} created successfully`
|
169
|
-
}
|
170
|
-
static async convertDatetoTimestamp(data: any) {
|
171
|
-
const [day, month, year] = data.split('-');
|
172
|
-
const timestamp = new Date(year, month - 1, day, 24, 0, 0).getTime();
|
173
|
-
return timestamp
|
174
|
-
}
|
175
|
-
|
176
|
-
static async convertTimestamptoDate(timestamp: number) {
|
177
|
-
let date = new Date(timestamp).toLocaleString()
|
178
|
-
return date
|
179
|
-
}
|
180
|
-
|
181
|
-
static async extendLicense(firestore: admin.firestore.Firestore, nickName: string, userDetails: License) {
|
182
|
-
userDetails.user = "+" + userDetails.user
|
183
|
-
let companyId = await Company.getCompanyIdbyNickname(firestore, nickName)
|
184
|
-
let userExist = await firestore.collection('Companies').doc(companyId).collection('Users').where('phone', '==', userDetails.user).get()
|
185
|
-
if (userExist.empty) {
|
186
|
-
return "User does exists"
|
187
|
-
}
|
188
|
-
let snapshot = await firestore.collection('Licenses').where('company', '==', nickName).where('user', '==', userDetails.user).where('license_type', '==', userDetails.license_type).get()
|
189
|
-
if (snapshot.empty) {
|
190
|
-
return "User details not found"
|
191
|
-
}
|
192
|
-
let toDateTimestamp = await this.convertDatetoTimestamp(userDetails.to_date)
|
193
|
-
snapshot.forEach((doc) => {
|
194
|
-
doc.ref.update({ to_date: toDateTimestamp })
|
195
|
-
})
|
196
|
-
return 'Updated successfully'
|
197
|
-
}
|
198
|
-
|
199
|
-
static async resetDeviceIdforUserLicense(firestore: admin.firestore.Firestore, company: string, phone: string) {
|
200
|
-
if (phone[0] != "+") {
|
201
|
-
phone = "+" + phone
|
202
|
-
}
|
203
|
-
console.log(phone)
|
204
|
-
let userLicense = await firestore.collection("Licenses").where("user", "==", phone).where("company", "==", company).get()
|
205
|
-
if (userLicense.empty) {
|
206
|
-
return { message: "User not found" }
|
207
|
-
}
|
208
|
-
userLicense.forEach((doc) => {
|
209
|
-
doc.ref.update({ device_id: 1 })
|
210
|
-
})
|
211
|
-
return { message: "updated" }
|
212
|
-
}
|
213
|
-
}
|
214
|
-
|
215
|
-
export { License };
|
@@ -1,80 +0,0 @@
|
|
1
|
-
import { Pool } from "mysql2/typings/mysql/lib/Pool";
|
2
|
-
import CurdService from "./crud/crud";
|
3
|
-
|
4
|
-
class MeetingSummary {
|
5
|
-
customerName: string;
|
6
|
-
contactName: string;
|
7
|
-
meetingImage: string;
|
8
|
-
constructor(customerName: string,
|
9
|
-
contactName: string,
|
10
|
-
meetingImage: string) {
|
11
|
-
this.customerName = customerName;
|
12
|
-
this.meetingImage = meetingImage;
|
13
|
-
this.contactName = contactName;
|
14
|
-
}
|
15
|
-
|
16
|
-
static async syncReportDBFirebaseUserEntries(meetingsDBConnection:Pool,doc:any,employeeName:string) {
|
17
|
-
try {
|
18
|
-
const reportData = {
|
19
|
-
companyId: doc.companyId ?? "",
|
20
|
-
employeeName: employeeName ?? "",
|
21
|
-
eventId: doc.eventId ?? "",
|
22
|
-
userId: doc.userId ?? "",
|
23
|
-
phone: doc.phone ?? "",
|
24
|
-
meetingDate: doc.extraData.date ?? "",
|
25
|
-
meetingStartTime: doc.extraData["Start Time"] ?? "",
|
26
|
-
meetingEndTime: doc.extraData["End Time"] ?? "",
|
27
|
-
meetingImage: doc.extraData["meetingImage"] ?? "",
|
28
|
-
contactName: doc.extraData.contactName ?? "",
|
29
|
-
customerName: doc.extraData.customerName ?? "",
|
30
|
-
companyNickName: "benara",
|
31
|
-
time: doc.date
|
32
|
-
}
|
33
|
-
await this.uploadEntryToReportDB(meetingsDBConnection, reportData);
|
34
|
-
} catch (error: any) {
|
35
|
-
console.log(error.message);
|
36
|
-
}
|
37
|
-
}
|
38
|
-
|
39
|
-
static async uploadEntryToReportDB(meetingsConnection: Pool, info: any) {
|
40
|
-
const curdService = new CurdService(meetingsConnection);
|
41
|
-
try {
|
42
|
-
const qryString = `INSERT INTO meeting_reports
|
43
|
-
(userId, eventId, companyId, name, phone, companyNickName,
|
44
|
-
meetingDate, meetingStartTime, meetingEndTime, contactName, customerName,
|
45
|
-
meetingImage, createOn )
|
46
|
-
VALUES ('${info.userId}',
|
47
|
-
'${info.eventId}',
|
48
|
-
'${info.companyId}',
|
49
|
-
'${info.employeeName}',
|
50
|
-
'${info.phone}',
|
51
|
-
'${info.companyNickName}',
|
52
|
-
'${info.meetingDate}',
|
53
|
-
'${info.meetingStartTime}',
|
54
|
-
'${info.meetingEndTime}',
|
55
|
-
'${info.contactName}',
|
56
|
-
'${info.customerName}',
|
57
|
-
'${info.meetingImage}',
|
58
|
-
'${info.time}')`
|
59
|
-
await curdService.query(qryString)
|
60
|
-
} catch(error: any) {
|
61
|
-
console.log(error.message);
|
62
|
-
}
|
63
|
-
}
|
64
|
-
|
65
|
-
static async updateEndTimeToReportDB(meetingsConnection: Pool, eventId: string, meetingEndTime:any){
|
66
|
-
const curdService = new CurdService(meetingsConnection)
|
67
|
-
try{
|
68
|
-
const qryString = `update meeting_reports
|
69
|
-
set meetingEndTime = '${meetingEndTime}'
|
70
|
-
where eventId = '${eventId}'`
|
71
|
-
await curdService.query(qryString)
|
72
|
-
}
|
73
|
-
catch (error) {
|
74
|
-
console.log(error)
|
75
|
-
}
|
76
|
-
}
|
77
|
-
|
78
|
-
}
|
79
|
-
|
80
|
-
export { MeetingSummary };
|
@@ -1,62 +0,0 @@
|
|
1
|
-
import { Post } from "./post.model"
|
2
|
-
import * as admin from "firebase-admin";
|
3
|
-
import { Offline } from "./offline.model";
|
4
|
-
import { TempCollection } from "./tempCollection.model";
|
5
|
-
import { User } from "./user.model";
|
6
|
-
|
7
|
-
class Meter extends Post {
|
8
|
-
actionEvent: string = "";
|
9
|
-
actionType: string = "worklog";
|
10
|
-
actionName: string = "meter_reading";
|
11
|
-
|
12
|
-
static async createPostForMeter(firestore: admin.firestore.Firestore,postInfo: any){
|
13
|
-
let post = new Meter();
|
14
|
-
post = await Meter.setIncomingInfoToMeter(postInfo, post);
|
15
|
-
let eventId = await Post.createNewPost(firestore,post)
|
16
|
-
return eventId
|
17
|
-
}
|
18
|
-
|
19
|
-
|
20
|
-
static async setIncomingInfoToMeter(info:any, post:Meter){
|
21
|
-
post.actionEvent = info.extra.actionEvent;
|
22
|
-
post.id = info.id
|
23
|
-
post.actionId = info.extra.actionId;
|
24
|
-
post.companyId = info.extra.companyId;
|
25
|
-
post.createdAt = info.extra.createdAt;
|
26
|
-
post.description = info.description;
|
27
|
-
post.eventId = info.extra.eventId;
|
28
|
-
post.isGeofence = info.extra.isGeofence;
|
29
|
-
post.userId = info.userId;
|
30
|
-
const newExtraData = await this.modifyExtraDataForMeter(info);
|
31
|
-
post.extraData = newExtraData;
|
32
|
-
post.seen = info.extra.seen;
|
33
|
-
post.startAt = "";
|
34
|
-
post.startLat = info.extra.startLat;
|
35
|
-
post.startLong = info.extra.startLong;
|
36
|
-
post.endAt = "";
|
37
|
-
post.endLat = info.extra.endLat;
|
38
|
-
post.endLong = info.extra.endLong;
|
39
|
-
post.stepValues = info.extra.stepValues;
|
40
|
-
post.time = info.extra.time;
|
41
|
-
post.checkInternet = info.extra.checkInternet;
|
42
|
-
return post;
|
43
|
-
}
|
44
|
-
|
45
|
-
static async modifyExtraDataForMeter(info: any) {
|
46
|
-
const time = info.createdAt;
|
47
|
-
const date = new Date(time).toLocaleDateString("en-GB");
|
48
|
-
const newExtraData = {
|
49
|
-
// ...info.extra.extraData,
|
50
|
-
status: info.status,
|
51
|
-
machineMeterId:info.machineMeterId,
|
52
|
-
currentReading:info.currentReading,
|
53
|
-
consumption:info.consumption,
|
54
|
-
date: date,
|
55
|
-
time: time
|
56
|
-
}
|
57
|
-
return newExtraData;
|
58
|
-
}
|
59
|
-
|
60
|
-
}
|
61
|
-
|
62
|
-
export { Meter };
|
@@ -1,84 +0,0 @@
|
|
1
|
-
import { Post } from "./post.model"
|
2
|
-
import * as admin from "firebase-admin";
|
3
|
-
import { Action } from "./action.model";
|
4
|
-
import { User } from "./user.model";
|
5
|
-
import { Company } from "./company.model";
|
6
|
-
import { Attendance } from "./attendance.model";
|
7
|
-
|
8
|
-
class MissingPunch extends Post {
|
9
|
-
actionEvent: string = "";
|
10
|
-
actionType: string = "worklog";
|
11
|
-
actionName: string = "mp";
|
12
|
-
description: string = "";
|
13
|
-
isProcessed: boolean = false;
|
14
|
-
missedEvent: string = "";
|
15
|
-
|
16
|
-
static async getOpenedMpRequests(firestore: admin.firestore.Firestore,
|
17
|
-
nickName: string,
|
18
|
-
phone: string) {
|
19
|
-
let teamList = await Company.getTeamListOfManager(firestore, nickName, phone);
|
20
|
-
teamList = teamList.map(user => user.id);
|
21
|
-
const allOpenRequests = [];
|
22
|
-
const companyId = await Company.getCompanyIdByNickName(firestore, nickName);
|
23
|
-
const actionId = await Action.getActionId(firestore, companyId, "mp");
|
24
|
-
for (let userId of teamList) {
|
25
|
-
const openRequestsDocs = await firestore.collection("Companies")
|
26
|
-
.doc(companyId)
|
27
|
-
.collection("Actions")
|
28
|
-
.doc(actionId)
|
29
|
-
.collection("mp")
|
30
|
-
.where("isProcessed", "==", false)
|
31
|
-
.where("userId", "==", userId)
|
32
|
-
.get();
|
33
|
-
const openRequests = openRequestsDocs.docs.map(doc => {
|
34
|
-
return doc.data();
|
35
|
-
})
|
36
|
-
allOpenRequests.push(...openRequests);
|
37
|
-
}
|
38
|
-
return allOpenRequests;
|
39
|
-
}
|
40
|
-
|
41
|
-
static async createUpdatedFeed(requestDoc: any,
|
42
|
-
description: string,
|
43
|
-
forApprovalText: string) {
|
44
|
-
const extraData = {
|
45
|
-
...requestDoc.extraData,
|
46
|
-
forApprovalText
|
47
|
-
}
|
48
|
-
const updatedFeed = {
|
49
|
-
...requestDoc,
|
50
|
-
description: description,
|
51
|
-
forApprovalText,
|
52
|
-
extraData
|
53
|
-
}
|
54
|
-
return updatedFeed;
|
55
|
-
}
|
56
|
-
|
57
|
-
static async updateFeedByUserId(firestore: admin.firestore.Firestore,
|
58
|
-
updatedFeed: any,
|
59
|
-
userId: string,
|
60
|
-
companyId: string) {
|
61
|
-
const oldFeeds = await firestore.collection("Feeds")
|
62
|
-
.doc(userId)
|
63
|
-
.collection(companyId)
|
64
|
-
.where("eventId", "==", updatedFeed.eventId)
|
65
|
-
.get();
|
66
|
-
oldFeeds.forEach((doc) => {
|
67
|
-
doc.ref.set(updatedFeed);
|
68
|
-
})
|
69
|
-
}
|
70
|
-
|
71
|
-
static async updateUserManagersFeed(firestore: admin.firestore.Firestore,
|
72
|
-
updatedFeed: any,
|
73
|
-
userId: string,
|
74
|
-
companyId: string) {
|
75
|
-
updatedFeed.description = updatedFeed.description.slice(5);
|
76
|
-
const userDetails: any = await User.getUserInfoById(firestore, userId, companyId);
|
77
|
-
const managersList = userDetails.reportingTo;
|
78
|
-
for (let id of managersList) {
|
79
|
-
await this.updateFeedByUserId(firestore, updatedFeed, id, companyId);
|
80
|
-
}
|
81
|
-
}
|
82
|
-
}
|
83
|
-
|
84
|
-
export { MissingPunch };
|