|
|
@@ -10,6 +10,8 @@ const { addManyDokumen } = require('../utils/dokumenFunction')
|
|
|
const userModel = require('../model/user.model')
|
|
|
const { cekSatuDataLaporan, cekBanyakDataLaporan } = require('../utils/cekData')
|
|
|
const { TEMPLATE_LAPORAN } = require('../utils/constanta')
|
|
|
+const logModel = require('../model/log.model')
|
|
|
+const kontakModel = require('../model/kontak.model')
|
|
|
|
|
|
exports.create = handleError(async (req, res) => {
|
|
|
const user = req.user
|
|
|
@@ -61,6 +63,26 @@ exports.create = handleError(async (req, res) => {
|
|
|
}
|
|
|
|
|
|
data = await laporanModel.create(data)
|
|
|
+
|
|
|
+ const notif = await notifWA(TEMPLATE_LAPORAN, [
|
|
|
+ {
|
|
|
+ key: '1',
|
|
|
+ value: 'nama',
|
|
|
+ value_text: user.nama,
|
|
|
+ },
|
|
|
+ { key: '2', value: 'pt', value_text: pt[0].nama },
|
|
|
+ { key: '3', value: 'keterangan', value_text: keterangan },
|
|
|
+ { key: '4', value: 'no_laporan', value_text: no_laporan },
|
|
|
+ ])
|
|
|
+
|
|
|
+ let contacts = await kontakModel.find()
|
|
|
+ contacts = contacts.map((e) => e.nama).join(', ')
|
|
|
+ if (notif[0].status == 'success') {
|
|
|
+ await logModel.create({
|
|
|
+ aktivitas: `Server berhasil mengirim notif wa kepada ${contacts} untuk Pembuatan Laporan`,
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
await pemantauanModel.create({
|
|
|
laporan: data._id,
|
|
|
action: 'CREATE LAPORAN',
|
|
|
@@ -247,7 +269,7 @@ exports.public = handleError(async (req, res) => {
|
|
|
|
|
|
if (no_verifikasi)
|
|
|
await userModel.findByIdAndUpdate(user._id, { verified: true })
|
|
|
- await notifWA(TEMPLATE_LAPORAN, [
|
|
|
+ const notif = await notifWA(TEMPLATE_LAPORAN, [
|
|
|
{
|
|
|
key: '1',
|
|
|
value: 'nama',
|
|
|
@@ -258,6 +280,14 @@ exports.public = handleError(async (req, res) => {
|
|
|
{ key: '4', value: 'no_laporan', value_text: no_laporan },
|
|
|
])
|
|
|
|
|
|
+ let contacts = await kontakModel.find()
|
|
|
+ contacts = contacts.map((e) => e.nama).join(', ')
|
|
|
+ if (notif[0].status == 'success') {
|
|
|
+ await logModel.create({
|
|
|
+ aktivitas: `Server berhasil mengirim notif wa kepada ${contacts} untuk Pembuatan Laporan`,
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
return response.success(res, {
|
|
|
message: 'Berhasil menambah laporan',
|
|
|
data,
|
|
|
@@ -333,11 +363,11 @@ exports.update = handleError(async (req, res) => {
|
|
|
}`
|
|
|
alasan = keterangan2
|
|
|
data.alasan_delegasi = keterangan2
|
|
|
- if (laporan.jadwal) {
|
|
|
- await laporanModel.findByIdAndUpdate(laporan._id, {
|
|
|
- $unset: { jadwal: 1 },
|
|
|
- })
|
|
|
- }
|
|
|
+ // if (laporan.jadwal) {
|
|
|
+ // await laporanModel.findByIdAndUpdate(laporan._id, {
|
|
|
+ // $unset: { jadwal: 1 },
|
|
|
+ // })
|
|
|
+ // }
|
|
|
}
|
|
|
if (aktif) {
|
|
|
data.aktif = aktif === 'true'
|