zet-lib 1.5.24 → 1.5.25
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/lib/zAppRouter.js +20 -10
- package/lib/zRoute.js +637 -625
- package/package.json +1 -1
package/lib/zAppRouter.js
CHANGED
|
@@ -840,10 +840,10 @@ router.post("/zzapproval", async (req, res) => {
|
|
|
840
840
|
|
|
841
841
|
router.get("/za/:token", csrfProtection, async (req, res) => {
|
|
842
842
|
let token = req.params.token;
|
|
843
|
-
let data = {}
|
|
844
|
-
|
|
843
|
+
let data = {};
|
|
844
|
+
let data2 = {};
|
|
845
845
|
let template = "";
|
|
846
|
-
let result
|
|
846
|
+
let result = {}
|
|
847
847
|
let isClosed = false;
|
|
848
848
|
let footers = "";
|
|
849
849
|
let details = [];
|
|
@@ -868,11 +868,10 @@ router.get("/za/:token", csrfProtection, async (req, res) => {
|
|
|
868
868
|
],
|
|
869
869
|
where: { "zapprovals_details.token": token },
|
|
870
870
|
});
|
|
871
|
-
|
|
872
|
-
if(!result.
|
|
873
|
-
return res.send("Not Found");
|
|
871
|
+
//console.log(results)
|
|
872
|
+
if(!result.id){
|
|
873
|
+
return res.send("Not Found!");
|
|
874
874
|
}
|
|
875
|
-
result = result[0];
|
|
876
875
|
let approvers = result.approvers;
|
|
877
876
|
knowings = result.knowings ? result.knowings : [];
|
|
878
877
|
|
|
@@ -1058,6 +1057,8 @@ router.post("/za/:token", csrfProtection, async (req, res) => {
|
|
|
1058
1057
|
let status_stats = [];
|
|
1059
1058
|
let approversSigned = [];
|
|
1060
1059
|
//{"stats":"0/2","status":[{"user":"12","status":2},{"user":"35","status":2}]}
|
|
1060
|
+
//3 approve
|
|
1061
|
+
//4 reject
|
|
1061
1062
|
let last_status;
|
|
1062
1063
|
details.map((item) => {
|
|
1063
1064
|
if (item.type == 1) {
|
|
@@ -1096,7 +1097,7 @@ router.post("/za/:token", csrfProtection, async (req, res) => {
|
|
|
1096
1097
|
});
|
|
1097
1098
|
// 6 comment 4 reject
|
|
1098
1099
|
//update ke table data yang dipakai
|
|
1099
|
-
let status_approval_table = 2
|
|
1100
|
+
let status_approval_table = 2;
|
|
1100
1101
|
if(req.body.status == 4){
|
|
1101
1102
|
status_approval_table = 22
|
|
1102
1103
|
} else {
|
|
@@ -1120,7 +1121,16 @@ router.post("/za/:token", csrfProtection, async (req, res) => {
|
|
|
1120
1121
|
|
|
1121
1122
|
//send notification
|
|
1122
1123
|
if (status == 3 || status == 4) {
|
|
1123
|
-
|
|
1124
|
+
await connection.update({
|
|
1125
|
+
table : result.table,
|
|
1126
|
+
data:{
|
|
1127
|
+
approval_status: status == 3 ? 21 : 22
|
|
1128
|
+
},
|
|
1129
|
+
where : {
|
|
1130
|
+
id: result.id_data
|
|
1131
|
+
}
|
|
1132
|
+
})
|
|
1133
|
+
let message = `Document ${titleEmail} has been ${status == 3 ? "Approved" : "Rejected"};`;
|
|
1124
1134
|
approvers.forEach(function (item) {
|
|
1125
1135
|
io.to(users[item].token).emit("message", message);
|
|
1126
1136
|
});
|
|
@@ -1218,7 +1228,6 @@ router.post("/za/:token", csrfProtection, async (req, res) => {
|
|
|
1218
1228
|
},
|
|
1219
1229
|
});
|
|
1220
1230
|
|
|
1221
|
-
|
|
1222
1231
|
//send toastr using socket.io
|
|
1223
1232
|
io.to(users[item].token).emit(
|
|
1224
1233
|
"message",
|
|
@@ -1260,6 +1269,7 @@ router.post('/get_approval_comments', async(req,res) => {
|
|
|
1260
1269
|
//{"{\"status\": \"6\", \"user_id\": \"192\", \"comments\": \"yayayay\"}","{\"status\": \"6\", \"user_id\": \"192\", \"comments\": \"kurang\"}","{\"status\": \"6\", \"user_id\": \"192\", \"comments\": \"oke\"}","{\"status\": \"4\", \"user_id\": \"192\", \"comments\": \"reject\"}","{\"status\": \"6\", \"user_id\": \"192\", \"comments\": \"dsfsdf\"}"}
|
|
1261
1270
|
let zuser = myCache.get('zuser') || {};
|
|
1262
1271
|
let approval_history = result.approval_history || [];
|
|
1272
|
+
//console.log(approval_history)
|
|
1263
1273
|
approval_history.forEach((item) => {
|
|
1264
1274
|
// Safe access dengan optional chaining dan fallback
|
|
1265
1275
|
const user = zuser[item.user_id];
|