|
|
@@ -6,7 +6,7 @@ const pelanggaranModel = require('../model/pelanggaran.model')
|
|
|
const pemantauanModel = require('../model/pemantauan.model')
|
|
|
const { validate } = require('../utils/validation')
|
|
|
const { notifWA } = require('../utils/notifFunction')
|
|
|
-const { addDokumen, addManyDokumen } = require('../utils/dokumenFunction')
|
|
|
+const { addManyDokumen } = require('../utils/dokumenFunction')
|
|
|
const userModel = require('../model/user.model')
|
|
|
const { cekSatuDataLaporan, cekBanyakDataLaporan } = require('../utils/cekData')
|
|
|
|
|
|
@@ -62,6 +62,7 @@ exports.create = handleError(async (req, res) => {
|
|
|
data = await laporanModel.create(data)
|
|
|
await pemantauanModel.create({
|
|
|
laporan: data._id,
|
|
|
+ action: 'CREATE LAPORAN',
|
|
|
pt_id: pt[0].id,
|
|
|
user: user._id,
|
|
|
keterangan: 'Membuat Laporan',
|
|
|
@@ -235,6 +236,7 @@ exports.public = handleError(async (req, res) => {
|
|
|
data = await laporanModel.create(data)
|
|
|
await pemantauanModel.create({
|
|
|
laporan: data._id,
|
|
|
+ action: 'CREATE LAPORAN',
|
|
|
pt_id: pt[0].id,
|
|
|
user: user._id,
|
|
|
keterangan: 'Membuat Laporan',
|
|
|
@@ -266,7 +268,7 @@ exports.getAll = handleError(async (req, res) => {
|
|
|
const where = {}
|
|
|
const { no_laporan, pt_id, jadwal, evaluasi, aktif } = req.query
|
|
|
if (no_laporan) where.no_laporan = no_laporan
|
|
|
- if (pt_id) where.pt.id = pt_id
|
|
|
+ if (pt_id) where['pt.id'] = pt_id
|
|
|
if (aktif) where.aktif = aktif === 'true'
|
|
|
if (jadwal === 'true') {
|
|
|
where.jadwal = {
|
|
|
@@ -346,6 +348,7 @@ exports.update = handleError(async (req, res) => {
|
|
|
const update = await laporanModel.findByIdAndUpdate(laporan._id, data)
|
|
|
if (change_role || aktif) {
|
|
|
await pemantauanModel.create({
|
|
|
+ action: 'UPDATE LAPORAN',
|
|
|
laporan: laporan._id,
|
|
|
pt_id: laporan.pt.id,
|
|
|
user: user._id,
|