|
@@ -4,7 +4,6 @@ const response = require('../utils/responseHandler')
|
|
|
const { addManyDokumen } = require('../utils/dokumenFunction')
|
|
const { addManyDokumen } = require('../utils/dokumenFunction')
|
|
|
const { validate } = require('../utils/validation')
|
|
const { validate } = require('../utils/validation')
|
|
|
const pemantauanModel = require('../model/pemantauan.model')
|
|
const pemantauanModel = require('../model/pemantauan.model')
|
|
|
-const logModel = require('../model/log.model')
|
|
|
|
|
const { hariKerja } = require('../utils/hariKerja')
|
|
const { hariKerja } = require('../utils/hariKerja')
|
|
|
const {
|
|
const {
|
|
|
cekSatuDataSanksi,
|
|
cekSatuDataSanksi,
|
|
@@ -17,7 +16,7 @@ const ip = require('ip')
|
|
|
const osValue = require('../utils/osValue')
|
|
const osValue = require('../utils/osValue')
|
|
|
|
|
|
|
|
exports.create = handleError(async (req, res) => {
|
|
exports.create = handleError(async (req, res) => {
|
|
|
- const { no_sanksi, keterangan } = req.body
|
|
|
|
|
|
|
+ const { no_sanksi, keterangan, from_date, to_date } = req.body
|
|
|
let { pelanggaran_id } = req.body
|
|
let { pelanggaran_id } = req.body
|
|
|
const { laporan_id } = req.params
|
|
const { laporan_id } = req.params
|
|
|
const files = req.files
|
|
const files = req.files
|
|
@@ -27,6 +26,8 @@ exports.create = handleError(async (req, res) => {
|
|
|
no_sanksi: 'string',
|
|
no_sanksi: 'string',
|
|
|
keterangan: 'string',
|
|
keterangan: 'string',
|
|
|
pelanggaran_id: 'string',
|
|
pelanggaran_id: 'string',
|
|
|
|
|
+ from_date: 'string',
|
|
|
|
|
+ to_date: 'string',
|
|
|
})
|
|
})
|
|
|
if (!isValid) return
|
|
if (!isValid) return
|
|
|
|
|
|
|
@@ -60,6 +61,10 @@ exports.create = handleError(async (req, res) => {
|
|
|
pelanggaran: pelanggaran_id,
|
|
pelanggaran: pelanggaran_id,
|
|
|
keterangan,
|
|
keterangan,
|
|
|
dokumen: dokumen_id,
|
|
dokumen: dokumen_id,
|
|
|
|
|
+ masa_berlaku: {
|
|
|
|
|
+ from_date,
|
|
|
|
|
+ to_date,
|
|
|
|
|
+ },
|
|
|
batas_waktu: {
|
|
batas_waktu: {
|
|
|
keberatan: hariKerja(10),
|
|
keberatan: hariKerja(10),
|
|
|
},
|
|
},
|
|
@@ -83,8 +88,12 @@ exports.create = handleError(async (req, res) => {
|
|
|
|
|
|
|
|
exports.getAll = handleError(async (req, res) => {
|
|
exports.getAll = handleError(async (req, res) => {
|
|
|
const user = req.user
|
|
const user = req.user
|
|
|
- const { keberatan, jawaban, banding, cabutSanksi, perbaikan } = req.query
|
|
|
|
|
|
|
+ const { keberatan, jawaban, banding, cabutSanksi, perbaikan, aktif } =
|
|
|
|
|
+ req.query
|
|
|
const where = {}
|
|
const where = {}
|
|
|
|
|
+ if (aktif && aktif === 'false') {
|
|
|
|
|
+ where.aktif = false
|
|
|
|
|
+ }
|
|
|
if (keberatan === 'true') {
|
|
if (keberatan === 'true') {
|
|
|
where['pengajuan.keberatan'] = { $exists: true, $ne: null }
|
|
where['pengajuan.keberatan'] = { $exists: true, $ne: null }
|
|
|
if (jawaban === 'true') {
|
|
if (jawaban === 'true') {
|
|
@@ -119,13 +128,16 @@ exports.getOne = handleError(async (req, res) => {
|
|
|
const { sanksi_id } = req.params
|
|
const { sanksi_id } = req.params
|
|
|
|
|
|
|
|
const w = {}
|
|
const w = {}
|
|
|
- const { banding } = req.query
|
|
|
|
|
|
|
+ const { banding, aktif } = req.query
|
|
|
if (banding === 'true') {
|
|
if (banding === 'true') {
|
|
|
w.banding = true
|
|
w.banding = true
|
|
|
w['pengajuan.keberatan'] = { $exists: true, $ne: null }
|
|
w['pengajuan.keberatan'] = { $exists: true, $ne: null }
|
|
|
w['jawaban.keberatan'] = { $exists: true, $ne: null }
|
|
w['jawaban.keberatan'] = { $exists: true, $ne: null }
|
|
|
w['pengajuan.banding'] = { $exists: true, $ne: null }
|
|
w['pengajuan.banding'] = { $exists: true, $ne: null }
|
|
|
}
|
|
}
|
|
|
|
|
+ if (aktif && aktif === 'false') {
|
|
|
|
|
+ w.aktif = false
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
const sanksi = await cekSatuDataSanksi(res, user, sanksi_id, w)
|
|
const sanksi = await cekSatuDataSanksi(res, user, sanksi_id, w)
|
|
|
if (!sanksi) return
|
|
if (!sanksi) return
|