|
|
@@ -12,8 +12,6 @@ const {
|
|
|
cekBanyakDataSanksi,
|
|
|
} = require('../utils/cekData')
|
|
|
const laporanModel = require('../model/laporan.model')
|
|
|
-const ip = require('ip')
|
|
|
-const osValue = require('../utils/osValue')
|
|
|
|
|
|
exports.create = handleError(async (req, res) => {
|
|
|
const { no_sanksi, keterangan, from_date, to_date } = req.body
|
|
|
@@ -69,7 +67,10 @@ exports.create = handleError(async (req, res) => {
|
|
|
keberatan: hariKerja(10),
|
|
|
},
|
|
|
})
|
|
|
- await laporanModel.findByIdAndUpdate(laporan._id, { sanksi: data._id })
|
|
|
+ await laporanModel.findByIdAndUpdate(laporan._id, {
|
|
|
+ sanksi: data._id,
|
|
|
+ // aktif: false,
|
|
|
+ })
|
|
|
await pemantauanModel.create({
|
|
|
laporan: laporan._id,
|
|
|
sanksi: data._id,
|
|
|
@@ -106,7 +107,8 @@ exports.getAll = handleError(async (req, res) => {
|
|
|
if (jawaban === 'true') {
|
|
|
where['jawaban.keberatan'] = { $exists: true, $ne: null }
|
|
|
}
|
|
|
- } else if (banding === 'true') {
|
|
|
+ }
|
|
|
+ if (banding === 'true') {
|
|
|
where.banding = true
|
|
|
where['pengajuan.keberatan'] = { $exists: true, $ne: null }
|
|
|
where['jawaban.keberatan'] = { $exists: true, $ne: null }
|
|
|
@@ -114,15 +116,18 @@ exports.getAll = handleError(async (req, res) => {
|
|
|
if (jawaban === 'true') {
|
|
|
where['jawaban.banding'] = { $exists: true, $ne: null }
|
|
|
}
|
|
|
- } else if (cabutSanksi === 'true') {
|
|
|
+ }
|
|
|
+ if (cabutSanksi === 'true') {
|
|
|
where.perbaikan = { $exists: true, $ne: [] }
|
|
|
if (jawaban === 'true') {
|
|
|
where['pengajuan.cabut_sanksi'] = { $exists: true, $ne: null }
|
|
|
// where['jawaban.cabut_sanksi'] = { $exists: true, $ne: null }
|
|
|
}
|
|
|
- } else if (perbaikan === 'true') {
|
|
|
+ }
|
|
|
+ if (perbaikan === 'true') {
|
|
|
where['jawaban.banding'] = { $exists: true, $ne: null }
|
|
|
- } else if (delegasi === 'true') {
|
|
|
+ }
|
|
|
+ if (delegasi === 'true') {
|
|
|
where.delegasi = true
|
|
|
}
|
|
|
const data = await cekBanyakDataSanksi(user, where)
|
|
|
@@ -167,6 +172,7 @@ exports.editTmt = handleError(async (req, res) => {
|
|
|
const user = req.user
|
|
|
const { id } = req.params
|
|
|
const { from_date, to_date } = req.body
|
|
|
+ const files = req.files
|
|
|
|
|
|
const sanksi = await cekSatuDataSanksi(res, user, id)
|
|
|
if (!sanksi) return
|
|
|
@@ -177,11 +183,21 @@ exports.editTmt = handleError(async (req, res) => {
|
|
|
})
|
|
|
if (!isValid) return
|
|
|
|
|
|
+ if (!files.length) {
|
|
|
+ return response.error(res, {
|
|
|
+ message: 'dokumen harus ada',
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ const dokumen = await addManyDokumen(files)
|
|
|
+ const dokumen_id = dokumen.map((e) => e._id)
|
|
|
+
|
|
|
const data = await sanksiModel.findByIdAndUpdate(sanksi._id, {
|
|
|
masa_berlaku: {
|
|
|
from_date,
|
|
|
to_date,
|
|
|
},
|
|
|
+ 'pengajuan.update_tmt': { dokumen: dokumen_id },
|
|
|
})
|
|
|
|
|
|
await pemantauanModel.create({
|