mobioffice-cli 0.0.1

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.
Files changed (156) hide show
  1. package/.prettierrc +4 -0
  2. package/README.md +1 -0
  3. package/a.js +3 -0
  4. package/lib/index.js +87 -0
  5. package/package.json +50 -0
  6. package/scripts/1.ts +1300 -0
  7. package/scripts/GCloudPubSub/pub-sub-config.json +12 -0
  8. package/scripts/GCloudPubSub/visitorAutoRejection.ts +86 -0
  9. package/scripts/actions/assignUsersFromOneActionToOther.ts +64 -0
  10. package/scripts/actions/assignUsersListToAction.ts +81 -0
  11. package/scripts/actions/getActionsListOfUser.ts +42 -0
  12. package/scripts/actions/getCompanyUserDetails.ts +49 -0
  13. package/scripts/actions/giveActionToUser.ts +41 -0
  14. package/scripts/actions/giveUsersToActivitySelector.ts +56 -0
  15. package/scripts/actions/groupActionsInActivitySelector.ts +101 -0
  16. package/scripts/actions/modifySummaryReportDB.ts +42 -0
  17. package/scripts/actions/setUrlToActionStep.ts +18 -0
  18. package/scripts/actions/syncMySqlAttendanceDBWithFirebase.ts +93 -0
  19. package/scripts/actions/syncMySqlMeetingsDBWithFirebase.ts +103 -0
  20. package/scripts/actions/test.ts +29 -0
  21. package/scripts/actions/transferFeedsOldIdToNew.ts +40 -0
  22. package/scripts/actions/transformUserIntoManager.ts +89 -0
  23. package/scripts/argvConfig.js +9 -0
  24. package/scripts/backUpData/testCode.ts +131 -0
  25. package/scripts/benaraScripts/addWorkAreaMap.ts +46 -0
  26. package/scripts/benaraScripts/add_customers.ts +26 -0
  27. package/scripts/benaraScripts/add_customers_contact.ts +27 -0
  28. package/scripts/benaraScripts/add_empty_work_area.ts +17 -0
  29. package/scripts/benaraScripts/assignManagers.ts +35 -0
  30. package/scripts/benaraScripts/changeCheckInFlag.ts +45 -0
  31. package/scripts/benaraScripts/createCustomerContactsList.ts +170 -0
  32. package/scripts/benaraScripts/createUserByDeletingOldUser.ts +70 -0
  33. package/scripts/benaraScripts/createUsersAreaMapCollection.ts +23 -0
  34. package/scripts/benaraScripts/createWorkAreaMap.ts +24 -0
  35. package/scripts/benaraScripts/mapWorkAreasToUsers.ts +112 -0
  36. package/scripts/companies_data.json +2496 -0
  37. package/scripts/create_or_update_users.ts +31 -0
  38. package/scripts/csvToJson/csvToJson.ts +90 -0
  39. package/scripts/csvToJson/users.json +3896 -0
  40. package/scripts/db.js +27 -0
  41. package/scripts/db.json +13 -0
  42. package/scripts/dbMySql.ts +63 -0
  43. package/scripts/delete_action_steps.ts +11 -0
  44. package/scripts/delete_user.ts +71 -0
  45. package/scripts/dev_companies_data.json +613 -0
  46. package/scripts/enroll.xlsx +0 -0
  47. package/scripts/export_users.ts +72 -0
  48. package/scripts/files/visitorManagementFiles/displayScreen.json +70 -0
  49. package/scripts/files/visitorManagementFiles/init_report_visibility.ts +79 -0
  50. package/scripts/firebaseConfig.js +12 -0
  51. package/scripts/firebaseDocs/deleteIncommingCollection.ts +47 -0
  52. package/scripts/firebaseDocs/updateDoc.ts +43 -0
  53. package/scripts/getActionDataIntoJSON/getActionData.ts +68 -0
  54. package/scripts/get_attendance_by_any_date.ts +14 -0
  55. package/scripts/get_attendance_by_month.ts +12 -0
  56. package/scripts/get_attendance_monthly_by_team.ts +11 -0
  57. package/scripts/get_daily_report.ts +10 -0
  58. package/scripts/get_mangers.ts +13 -0
  59. package/scripts/grant_user_license.ts +18 -0
  60. package/scripts/init_CustomCollection.ts +16 -0
  61. package/scripts/init_action_steps.ts +28 -0
  62. package/scripts/init_actions.ts +31 -0
  63. package/scripts/init_company.ts +18 -0
  64. package/scripts/init_customer_mysql.ts +12 -0
  65. package/scripts/init_feed.ts +4 -0
  66. package/scripts/init_feed_details_screen.ts +14 -0
  67. package/scripts/init_geofence.ts +26 -0
  68. package/scripts/init_print_details_screen.ts +14 -0
  69. package/scripts/init_report_actions.ts +24 -0
  70. package/scripts/init_report_definition_detail.ts +26 -0
  71. package/scripts/init_report_definition_summary.ts +16 -0
  72. package/scripts/init_report_visibility.ts +46 -0
  73. package/scripts/init_user_customcollection.ts +16 -0
  74. package/scripts/json/action.json +21 -0
  75. package/scripts/json/company.json +24 -0
  76. package/scripts/json/report-action.json +13 -0
  77. package/scripts/json/report-def-deet.json +43 -0
  78. package/scripts/json/resp.json +784 -0
  79. package/scripts/json/steps.json +24 -0
  80. package/scripts/json/test.ts +49 -0
  81. package/scripts/mysqlConfig.ts +9 -0
  82. package/scripts/revoke_or_extend_license.ts +14 -0
  83. package/scripts/stream.js +4 -0
  84. package/scripts/testing1.ts +35 -0
  85. package/scripts/update/doc.json +20 -0
  86. package/scripts/update/getDocByPath.ts +34 -0
  87. package/scripts/update/updateDocByPath.ts +47 -0
  88. package/scripts/update/updateUsersOfCompanies.ts +58 -0
  89. package/scripts/update_actions.ts +19 -0
  90. package/scripts/update_actions_steps.ts +19 -0
  91. package/scripts/update_company.ts +19 -0
  92. package/scripts/update_geofence.ts +20 -0
  93. package/scripts/update_managers.ts +16 -0
  94. package/scripts/visitorMgmt/createArea.ts +68 -0
  95. package/scripts/visitorMgmt/createArea.txt +3 -0
  96. package/scripts/visitorMgmt/createVisitorPathInstructionDocs.ts +130 -0
  97. package/scripts/visitorMgmt/createVisitorPathInstructionDocs.txt +18 -0
  98. package/scripts/visitorMgmt/encryptDateString.ts +71 -0
  99. package/scripts/visitorMgmt/makeHostsManagersOfEachOther.ts +117 -0
  100. package/scripts/whatsapp_gupshup/sendMessage.ts +97 -0
  101. package/src/index.ts +87 -0
  102. package/src/models/Feed-Details-Screen.model.ts +29 -0
  103. package/src/models/action.model.ts +355 -0
  104. package/src/models/actions/doffing.ts +71 -0
  105. package/src/models/actions/folding.ts +39 -0
  106. package/src/models/attendance.model.ts +615 -0
  107. package/src/models/cicoPost.model.ts +20 -0
  108. package/src/models/company.model.ts +975 -0
  109. package/src/models/contact-us/resquest.model.ts +87 -0
  110. package/src/models/crud/crud.ts +30 -0
  111. package/src/models/customCollection.model.ts +47 -0
  112. package/src/models/customer/customer.model.ts +85 -0
  113. package/src/models/deviceChangeReq.ts +150 -0
  114. package/src/models/dispatch.model.ts +99 -0
  115. package/src/models/feed.models.ts +104 -0
  116. package/src/models/geofence.model.ts +61 -0
  117. package/src/models/leaveApplicationPost.model.ts +79 -0
  118. package/src/models/license.model.ts +215 -0
  119. package/src/models/log.model.ts +25 -0
  120. package/src/models/meeting.model.ts +80 -0
  121. package/src/models/meter.model.ts +62 -0
  122. package/src/models/missingPunchPost.model.ts +84 -0
  123. package/src/models/offline.model.ts +1133 -0
  124. package/src/models/post.model.ts +105 -0
  125. package/src/models/printDetailsScreen.model.ts +30 -0
  126. package/src/models/pushNotifications/pushNotification.model.ts +17 -0
  127. package/src/models/report-actions.model.ts +57 -0
  128. package/src/models/report-definition-details.model.ts +89 -0
  129. package/src/models/report-definition.model.ts +26 -0
  130. package/src/models/report-definitions-summary.model.ts +59 -0
  131. package/src/models/report-detail-data.model.ts +49 -0
  132. package/src/models/report-visibility.model.ts +44 -0
  133. package/src/models/report.model.ts +179 -0
  134. package/src/models/reportGenerator.model.ts +883 -0
  135. package/src/models/response.model.ts +31 -0
  136. package/src/models/steps.factory.model.ts +195 -0
  137. package/src/models/storeGupShupLog.model.ts +49 -0
  138. package/src/models/summary.model.ts +63 -0
  139. package/src/models/tasks/sub-task-group.model.ts +173 -0
  140. package/src/models/tasks/tags.model.ts +113 -0
  141. package/src/models/tasks/task-group.model.ts +172 -0
  142. package/src/models/tasks/task.model.ts +681 -0
  143. package/src/models/tempCollection.model.ts +398 -0
  144. package/src/models/user.model.ts +319 -0
  145. package/src/models/utility.model.ts +100 -0
  146. package/src/models/visitorManagement/acknowledgement.model.ts +71 -0
  147. package/src/models/visitorManagement/invite.model.ts +406 -0
  148. package/src/models/visitorManagement/newIn.model.ts +82 -0
  149. package/src/models/visitorManagement/selfServe.model.ts +58 -0
  150. package/src/models/worklogPost.model.ts +8 -0
  151. package/src/services/customer.ts +382 -0
  152. package/src/services/meeting.ts +123 -0
  153. package/test/1.ts +13 -0
  154. package/test/db.js +19 -0
  155. package/test/firebaseConfig.js +1 -0
  156. package/tsconfig.json +16 -0
@@ -0,0 +1,406 @@
1
+ import { Company } from "../company.model";
2
+ import { Post } from "../post.model";
3
+ import * as admin from "firebase-admin";
4
+ import { Utilities } from "../utility.model";
5
+ import { Attendance } from "../attendance.model";
6
+ import { Pool } from "mysql2/typings/mysql/lib/Pool";
7
+ import CurdService from "../crud/crud";
8
+ import { Policy } from "@google-cloud/pubsub";
9
+
10
+ class Invitation extends Post {
11
+ isProcessed = false;
12
+
13
+ static async setIncomingInfoToInvitation(
14
+ firestore: admin.firestore.Firestore,
15
+ invitationInfo: any,
16
+ post: Invitation,
17
+ nickName: string
18
+ ) {
19
+ const userDetails = await Company.getUserDetailsByPhone(
20
+ firestore,
21
+ nickName,
22
+ "+" + invitationInfo.phone
23
+ );
24
+ const whomToMeet = userDetails[0].name;
25
+ post.actionEvent = invitationInfo.extra.actionEvent;
26
+ post.actionId = invitationInfo.extra.actionId;
27
+ post.actionName = invitationInfo.extra.actionName;
28
+ post.actionType = invitationInfo.extra.actionType;
29
+ post.companyId = invitationInfo.extra.companyId;
30
+ post.createdAt = invitationInfo.extra.createdAt;
31
+ post.refId = invitationInfo.extra.extraData.phone;
32
+ post.description = `${invitationInfo.extra.extraData.visitorName} is going to meet ${whomToMeet} `;
33
+ post.eventId = invitationInfo.extra.eventId;
34
+ post.isGeofence = invitationInfo.extra.isGeofence;
35
+ post.userId = invitationInfo.userId;
36
+ const newExtraData = await this.modifyExtraDAtaForInvitation(
37
+ invitationInfo,
38
+ whomToMeet
39
+ );
40
+ post.extraData = newExtraData;
41
+ post.time = invitationInfo.extra.time;
42
+ let postOBJ = JSON.parse(JSON.stringify(post));
43
+ postOBJ["isApproved"] = invitationInfo.isApproved;
44
+ return postOBJ;
45
+ }
46
+
47
+ static async modifyExtraDAtaForInvitation(
48
+ invitationInfo: any,
49
+ whomToMeet: string
50
+ ) {
51
+ const visitorName = invitationInfo.extra.extraData.visitorName;
52
+ const personToMeet = whomToMeet;
53
+ const meetingTimeObj = invitationInfo.extra.extraData.meetingTime;
54
+ const meetingEpochTime =
55
+ meetingTimeObj._seconds * 1000 +
56
+ Math.floor(meetingTimeObj._nanoseconds / 1000000);
57
+ const visitorPhoneNumber = invitationInfo.extra.extraData.phone;
58
+ const acknowledgedTime = null;
59
+ const checkOutTimeOfVisitor = null;
60
+ const newExtraData = {
61
+ visitorName,
62
+ personToMeet,
63
+ visitorPhoneNumber,
64
+ status: "Invitation Sent",
65
+ acknowledgedTime,
66
+ time: meetingEpochTime,
67
+ date: invitationInfo.extra.extraData.meetingDate,
68
+ checkInTimeOfVisitor: null,
69
+ checkInDateOfVisitor: "---",
70
+ checkOutTimeOfVisitor,
71
+ };
72
+ return newExtraData;
73
+ }
74
+
75
+ static async uploadEntryToMySql(connection: Pool, info: any) {
76
+ const crudServicce = new CurdService(connection);
77
+ try {
78
+ const checkInTime = info.checkInTime ? `'${info.checkInTime}'` : null;
79
+ const qryString =
80
+ info.cardColor == null ||
81
+ info.image == null ||
82
+ info.idProofType == null ||
83
+ info.idImage == null
84
+ ? `INSERT INTO visits (visitorName, phoneNo, meetingPerson,
85
+ checkInTime, companyId, visitId, category, meetingPersonPhone,
86
+ visitType, scheduledTime, purposeOfVisit, isApproved, cardColor, additionalVisitors, visitorsLeaving, assets, image, idProofType, idImage, refId, inGateKeeperId)
87
+ VALUES ('${info.visitorName}',
88
+ '${info.visitorPhone}',
89
+ '${info.meetingPerson}',
90
+ ${checkInTime},
91
+ '${info.companyId}',
92
+ '${info.visitId}',
93
+ '${info.category}',
94
+ '${info.meetingPersonPhone}',
95
+ '${info.visitType}',
96
+ '${info.scheduledTime}',
97
+ '${info.purposeOfVisit}',
98
+ ${info.isApproved},
99
+ '${info.cardColor ?? ""}',
100
+ ${info.additionalVisitors},
101
+ ${info.visitorsLeaving},
102
+ '${info.assets}',
103
+ '${info.image}',
104
+ ${info.idProofType},
105
+ '${info.idImage ?? ""}',
106
+ '${info.refId ?? ""}',
107
+ '${info.inGateKeeperId ?? ""}');`
108
+ : `INSERT INTO visits (visitorName, phoneNo, meetingPerson,
109
+ checkInTime, companyId, visitId, category, meetingPersonPhone,
110
+ visitType, scheduledTime, purposeOfVisit, isApproved, cardColor, additionalVisitors, visitorsLeaving, assets, image, idProofType, idImage, refId, inGateKeeperId)
111
+ VALUES ('${info.visitorName}',
112
+ '${info.visitorPhone}',
113
+ '${info.meetingPerson}',
114
+ ${checkInTime},
115
+ '${info.companyId}',
116
+ '${info.visitId}',
117
+ '${info.category}',
118
+ '${info.meetingPersonPhone}',
119
+ '${info.visitType}',
120
+ '${info.scheduledTime}',
121
+ '${info.purposeOfVisit}',
122
+ ${info.isApproved},
123
+ '${info.cardColor}',
124
+ ${info.additionalVisitors},
125
+ ${info.visitorsLeaving},
126
+ '${info.assets}',
127
+ '${info.image}',
128
+ '${info.idProofType}',
129
+ '${info.idImage}',
130
+ '${info.refId}',
131
+ '${info.inGateKeeperId}');`;
132
+ console.log(qryString);
133
+ await crudServicce.query(qryString);
134
+ } catch (error: any) {
135
+ console.log(error.message);
136
+ throw new Error(error.message);
137
+ }
138
+ }
139
+
140
+ static async updateInvitationEntryOnReception(
141
+ connection: Pool,
142
+ visitId: string,
143
+ redId: string,
144
+ inGateKeeperId: string,
145
+ checkInTime: string
146
+ ) {
147
+ const crudServicce = new CurdService(connection);
148
+ try {
149
+ const qryString = `UPDATE visits SET checkInTime = '${checkInTime}', refId = '${redId}', inGateKeeperId = '${inGateKeeperId}' WHERE visitId = '${visitId}';`;
150
+ await crudServicce.query(qryString);
151
+ } catch (error: any) {
152
+ console.log(error.message);
153
+ throw new Error(error.message);
154
+ }
155
+ }
156
+
157
+ static async updateInvitationOnApproval(
158
+ connection: Pool,
159
+ visitId: string,
160
+ isApproved: boolean
161
+ ) {
162
+ const curdService = new CurdService(connection)
163
+ try {
164
+ const qryString = `UPDATE visits SET isApproved = ${isApproved} WHERE visitId = '${visitId}';`;
165
+ await curdService.query(qryString);
166
+ } catch (error: any) {
167
+ console.log(error.message);
168
+ throw new Error(error.message);
169
+ }
170
+ }
171
+
172
+ static async updateInvitationWithCardColor(
173
+ connection: Pool,
174
+ visitId: string,
175
+ cardColor: string
176
+ ) {
177
+ const crudServicce = new CurdService(connection)
178
+ try {
179
+ const qryString =
180
+ cardColor == null
181
+ ? `UPDATE visits SET cardColor = ${cardColor} WHERE visitId = '${visitId}';`
182
+ : `UPDATE visits SET cardColor = '${cardColor}' WHERE visitId = '${visitId}';`;
183
+ await crudServicce.query(qryString)
184
+ } catch (error: any) {
185
+ console.log(error.message);
186
+ throw new Error(error.message);
187
+ }
188
+ }
189
+ static async updateInvitationWithIdProof(
190
+ connection: Pool,
191
+ visitId: string,
192
+ proofType: string,
193
+ proofImage: string
194
+ ) {
195
+ const crudServicce = new CurdService(connection);
196
+ try {
197
+ let qryString = `UPDATE visits SET idProofType = `
198
+ if (proofType) {
199
+ qryString += `'${proofType}', idImage = `
200
+ } else {
201
+ qryString += `null, idImage = `
202
+ }
203
+
204
+ if (proofImage) {
205
+ qryString += `'${proofImage}' `
206
+ } else {
207
+ qryString += `null `;
208
+ }
209
+ qryString += `where visitId = '${visitId}';`;
210
+ console.log(qryString);
211
+ console.log("--------------------------");
212
+ await crudServicce.query(qryString);
213
+ } catch (error: any) {
214
+ console.log(error.message);
215
+ throw new Error(error.message);
216
+ }
217
+ }
218
+
219
+ static async updateInvitationWithVisitorsLeaving(
220
+ connection: Pool,
221
+ visitId: string,
222
+ outGateKeeperId: string,
223
+ visitorsLeaving: string
224
+ ) {
225
+ const crudServicce = new CurdService(connection);
226
+ try {
227
+ const qryString = `UPDATE visits
228
+ SET visitorsLeaving = '${Number(visitorsLeaving)}', outGateKeeperId = '${outGateKeeperId}'
229
+ WHERE visitId = '${visitId}';`;
230
+ await crudServicce.query(qryString);
231
+ } catch (error: any) {
232
+ console.log(error.message);
233
+ throw new Error(error.message);
234
+ }
235
+ }
236
+
237
+ static async updateInvitationWithImage(
238
+ connection: Pool,
239
+ visitId: string,
240
+ imageBase64: string,
241
+ additionalVisitors: string,
242
+ assets: string
243
+ ) {
244
+ const crudServicce = new CurdService(connection);
245
+ try {
246
+ const qryString = `UPDATE visits
247
+ SET image = '${imageBase64}', additionalVisitors = '${additionalVisitors}', assets = '${assets}'
248
+ WHERE visitId = '${visitId}';`;
249
+ await crudServicce.query(qryString);
250
+ } catch (error: any) {
251
+ console.log(error.message);
252
+ throw new Error(error.message);
253
+ }
254
+ }
255
+
256
+ static async updateInvitationWithApprovedAt(
257
+ connection: Pool,
258
+ visitId: string,
259
+ approvedAt: string
260
+ ) {
261
+ const crudServicce = new CurdService(connection);
262
+ try {
263
+ const qryString = `UPDATE visits SET approvedAt = '${approvedAt}' WHERE visitId = '${visitId}';`;
264
+ await crudServicce.query(qryString);
265
+ } catch (error: any) {
266
+ console.log(error.message);
267
+ throw new Error(error.message);
268
+ }
269
+ }
270
+
271
+ static async fetchHostMeetingsForTheDay(
272
+ connection: Pool,
273
+ hostPhone: string,
274
+ companyId: string
275
+ ) {
276
+ const crudServicce = new CurdService(connection);
277
+ try {
278
+ let date = await Attendance.getCurrentdate();
279
+ date = date.split("/").reverse().join('-');
280
+ console.log("current date:", date);
281
+ const qryString = `SELECT * FROM visits
282
+ WHERE meetingPersonPhone = '${hostPhone}'
283
+ AND companyId = '${companyId}'
284
+ AND isReassigned IS NOT true
285
+ AND meetingTime IS NULL
286
+ AND DATE(scheduledTime) = '${date}'`;
287
+ const meetingsListInfo: any = await crudServicce.query(qryString);
288
+ const meetingsList = meetingsListInfo.map((meetingInfo: any) => {
289
+ return {
290
+ id: meetingInfo.id,
291
+ visitId: meetingInfo.visitId,
292
+ visitorName: meetingInfo.visitorName,
293
+ scheduledTime: meetingInfo.scheduledTime,
294
+ meetingPerson: meetingInfo.meetingPerson,
295
+ visitType: meetingInfo.visitType
296
+ }
297
+ })
298
+ return meetingsList;
299
+ } catch (error: any) {
300
+ console.log(error.message);
301
+ throw new Error(error.message);
302
+ }
303
+ }
304
+
305
+ static async checkUserIsExist(
306
+ connection: Pool,
307
+ Phone: string,
308
+ companyId: string
309
+ ) {
310
+ const currentDateIST = new Date().toLocaleString("en-US", {
311
+ timeZone: "Asia/Kolkata",
312
+ year: "numeric",
313
+ month: "2-digit",
314
+ day: "2-digit",
315
+ hour: "2-digit",
316
+ minute: "2-digit",
317
+ second: "2-digit",
318
+ hour12: false,
319
+ });
320
+
321
+ const [date, time] = currentDateIST.split(", ");
322
+ const [day, month, year] = date.split("/");
323
+ const formattedDate = `${year}-${day}-${month} ${time}`;
324
+ const crudServicce = new CurdService(connection);
325
+ try {
326
+ const qryString = `SELECT id, companyId, phone, fromTime, toTime, isActive, createdAt FROM gatePassDetails
327
+ WHERE isActive = true
328
+ AND companyId = '${companyId}'
329
+ AND phone = '${Phone}'
330
+ AND fromTime <= '${formattedDate}'
331
+ AND toTime >= '${formattedDate}'
332
+ ORDER BY id DESC
333
+ LIMIT 1;`;
334
+ console.log("qryString ====================================> ", qryString);
335
+ const meetingsListInfo = await crudServicce.query(qryString);
336
+ return meetingsListInfo;
337
+ } catch (error: any) {
338
+ console.log(error.message);
339
+ throw new Error(error.message);
340
+ }
341
+ }
342
+
343
+ static async createGatePass(
344
+ connection: Pool,
345
+ companyId: string,
346
+ phone: string,
347
+ from: string,
348
+ to: string,
349
+ name: string,
350
+ createdBy: string,
351
+ faceJpg: string
352
+ ) {
353
+ const crudServicce = new CurdService(connection);
354
+ try {
355
+ const currentDateIST = new Date().toLocaleString("en-US", {
356
+ timeZone: "Asia/Kolkata",
357
+ year: "numeric",
358
+ month: "2-digit",
359
+ day: "2-digit",
360
+ hour: "2-digit",
361
+ minute: "2-digit",
362
+ second: "2-digit",
363
+ hour12: false,
364
+ });
365
+
366
+ const [date, time] = currentDateIST.split(", ");
367
+ const [day, month, year] = date.split("/");
368
+ const formattedDate = `${year}-${day}-${month} ${time}`;
369
+
370
+ console.log(formattedDate);
371
+ const qryString = `INSERT INTO gatePassDetails (companyId, phone, fromTime, toTime, isActive, createdAt, name, createdBy, image)
372
+ VALUES('${companyId}', '${phone}', '${from}', '${to}', 1, '${formattedDate}', '${name}', '${createdBy}', '${faceJpg}');`;
373
+
374
+ console.log("qryString ====================================> ", qryString);
375
+ const meetingsListInfo = await crudServicce.query(qryString);
376
+ return meetingsListInfo;
377
+ } catch (error: any) {
378
+ console.log(error.message);
379
+ throw new Error(error.message);
380
+ }
381
+ }
382
+
383
+ static async updateUserGatePassData(
384
+ connection: Pool,
385
+ id: number,
386
+ to: string
387
+ ) {
388
+ const crudServicce = new CurdService(connection);
389
+ try {
390
+ const qryString = `UPDATE gatePassDetails
391
+ SET toTime = '${to}'
392
+ WHERE id = '${id}';`;
393
+
394
+ console.log("qryString ====================================> ", qryString);
395
+ const meetingsListInfo = await crudServicce.query(qryString);
396
+ return meetingsListInfo;
397
+ } catch (error: any) {
398
+ console.log(error.message);
399
+ throw new Error(error.message);
400
+ }
401
+ }
402
+
403
+
404
+ }
405
+
406
+ export { Invitation };
@@ -0,0 +1,82 @@
1
+ import * as admin from "firebase-admin";
2
+ import { Post } from "../post.model";
3
+
4
+ class NewIn extends Post {
5
+ isProcessed: boolean = false;
6
+
7
+ static async setIncomingInfoToNewIn(visitorInfo: any, post: NewIn){
8
+ post.actionEvent = visitorInfo.extra.actionEvent;
9
+ post.actionId = visitorInfo.extra.actionId;
10
+ post.actionName = visitorInfo.extra.actionName;
11
+ post.actionType = visitorInfo.extra.actionType;
12
+ post.companyId = visitorInfo.extra.companyId;
13
+ post.createdAt = visitorInfo.extra.createdAt;
14
+ post.description = `${visitorInfo.extra.extraData.visitorName} is going to meet ${visitorInfo.extra.extraData.whomToMeet} `;
15
+ post.eventId = visitorInfo.extra.eventId;
16
+ post.isGeofence = visitorInfo.extra.isGeofence;
17
+ post.userId = visitorInfo.userId;
18
+ const newExtraData = await this.modifyExtraDataForNewIn(visitorInfo);
19
+ post.extraData = newExtraData;
20
+ post.seen = visitorInfo.extra.seen;
21
+ post.stepValues = visitorInfo.extra.stepValues;
22
+ post.time = visitorInfo.extra.time;
23
+ return post;
24
+ }
25
+
26
+ static async modifyExtraDataForNewIn(visitorInfo : any){
27
+ const visitorName = visitorInfo.extra.extraData.visitorName;
28
+ const personToMeet = visitorInfo.extra.extraData.whomToMeet;
29
+ const personToMeetId = visitorInfo.extra.extraData.whomToMeetId;
30
+ const visitorPhoneNumber = visitorInfo.extra.extraData.phone;
31
+ const checkInTimeOfVisitor = visitorInfo.createdAt;
32
+ const visitorPicture = visitorInfo.visitorImage
33
+ const checkInDateOfVisitor = visitorInfo.date
34
+ const status = "In Progress"
35
+ const checkOutTimeOfVisitor = null
36
+ const acknowledgedTime = null
37
+ const newExtraData = {
38
+ visitorName,
39
+ personToMeet,
40
+ visitorPhoneNumber,
41
+ checkInTimeOfVisitor,
42
+ visitorPicture,
43
+ checkInDateOfVisitor,
44
+ status,
45
+ checkOutTimeOfVisitor,
46
+ acknowledgedTime,
47
+ personToMeetId
48
+ }
49
+ return newExtraData;
50
+ }
51
+
52
+ static async uploadQRcodeImg(
53
+ storageRef: any,
54
+ imgAsBase64: string,
55
+ actionName: string,
56
+ createdAt: string,
57
+ ) {
58
+ console.log("imgAsBase64");
59
+ let imageBuffer = Buffer.from(imgAsBase64, "base64")
60
+ let file = await storageRef.file(`visitorManagement/${actionName}/qrCodes/${createdAt}`);
61
+
62
+ await file.save(
63
+ imageBuffer,
64
+ {
65
+ metadata: { contentType: "image/jpeg" },
66
+ },
67
+ () => {
68
+ return "Unable to upload the image.";
69
+ }
70
+ );
71
+ let options: object = {
72
+ action: "read",
73
+ expires: "03-17-2025",
74
+ };
75
+ const url = await file.getSignedUrl(options);
76
+ return url[0];
77
+
78
+ }
79
+
80
+ }
81
+
82
+ export { NewIn };
@@ -0,0 +1,58 @@
1
+ import * as admin from "firebase-admin";
2
+ import { Post } from "../post.model";
3
+
4
+ class SelfServe extends Post {
5
+ isProcessed: boolean = false;
6
+
7
+ static async setIncomingInfoToNewIn(visitorInfo: any, post: SelfServe){
8
+ post.actionEvent = visitorInfo.extra.actionEvent;
9
+ post.actionId = visitorInfo.extra.actionId;
10
+ post.actionName = visitorInfo.extra.actionName;
11
+ post.actionType = visitorInfo.extra.actionType;
12
+ post.companyId = visitorInfo.extra.companyId;
13
+ post.createdAt = visitorInfo.extra.createdAt;
14
+ post.description = `${visitorInfo.extra.extraData.visitorName} is going to meet ${visitorInfo.extra.extraData.whomToMeet} `;
15
+ post.eventId = visitorInfo.extra.eventId;
16
+ post.isGeofence = visitorInfo.extra.isGeofence;
17
+ post.userId = visitorInfo.userId;
18
+
19
+ const newExtraData = await this.modifyExtraDataForNewIn(visitorInfo);
20
+
21
+ post.extraData = newExtraData;
22
+ post.forApproval = visitorInfo.extra.forApproval;
23
+ post.forApprovalText = visitorInfo.extra.forApprovalText;
24
+
25
+ post.seen = visitorInfo.extra.seen;
26
+ post.endAt = "";
27
+ post.endLat = "";
28
+ post.endLong = "";
29
+ post.stepValues = visitorInfo.extra.stepValues;
30
+ post.time = visitorInfo.extra.time;
31
+
32
+
33
+ return post;
34
+ }
35
+
36
+ static async modifyExtraDataForNewIn(visitorInfo : any){
37
+ const visitorName = visitorInfo.extra.extraData.visitorName;
38
+ const personToMeet = visitorInfo.extra.extraData.whomToMeet;
39
+ const vistorPhoneNumber = visitorInfo.phone;
40
+ const checkInTimeOfVisitor = visitorInfo.checkInTime;
41
+ const visitorPicture = visitorInfo.visitorImage
42
+
43
+ const newExtraData = {
44
+ visitorName,
45
+ personToMeet,
46
+ vistorPhoneNumber,
47
+ checkInTimeOfVisitor,
48
+ visitorPicture
49
+
50
+ }
51
+ return newExtraData;
52
+
53
+ }
54
+
55
+
56
+ }
57
+
58
+ export { SelfServe };
@@ -0,0 +1,8 @@
1
+ import { Post } from "./post.model";
2
+
3
+ class WorklogPost extends Post {
4
+ actionType: string = "worklog";
5
+ actionName: string = "worklog";
6
+ }
7
+
8
+ export { WorklogPost };