|
@@ -6,7 +6,7 @@ const pelanggaranModel = require('../model/pelanggaran.model')
|
|
|
const pemantauanModel = require('../model/pemantauan.model')
|
|
const pemantauanModel = require('../model/pemantauan.model')
|
|
|
const { validate } = require('../utils/validation')
|
|
const { validate } = require('../utils/validation')
|
|
|
const { notifWA } = require('../utils/notifFunction')
|
|
const { notifWA } = require('../utils/notifFunction')
|
|
|
-const { addDokumen, addManyDokumen } = require('../utils/dokumenFunction')
|
|
|
|
|
|
|
+const { addManyDokumen } = require('../utils/dokumenFunction')
|
|
|
const userModel = require('../model/user.model')
|
|
const userModel = require('../model/user.model')
|
|
|
const { cekSatuDataLaporan, cekBanyakDataLaporan } = require('../utils/cekData')
|
|
const { cekSatuDataLaporan, cekBanyakDataLaporan } = require('../utils/cekData')
|
|
|
|
|
|
|
@@ -55,12 +55,14 @@ exports.create = handleError(async (req, res) => {
|
|
|
pelanggaran: pelanggaran_id,
|
|
pelanggaran: pelanggaran_id,
|
|
|
keterangan,
|
|
keterangan,
|
|
|
role_data: user.role.id === 2020 ? 'dikti' : 'lldikti',
|
|
role_data: user.role.id === 2020 ? 'dikti' : 'lldikti',
|
|
|
|
|
+ role_asal: user.role.id === 2020 ? 'dikti' : 'lldikti',
|
|
|
level: 2,
|
|
level: 2,
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
data = await laporanModel.create(data)
|
|
data = await laporanModel.create(data)
|
|
|
await pemantauanModel.create({
|
|
await pemantauanModel.create({
|
|
|
laporan: data._id,
|
|
laporan: data._id,
|
|
|
|
|
+ action: 'CREATE LAPORAN',
|
|
|
pt_id: pt[0].id,
|
|
pt_id: pt[0].id,
|
|
|
user: user._id,
|
|
user: user._id,
|
|
|
keterangan: 'Membuat Laporan',
|
|
keterangan: 'Membuat Laporan',
|
|
@@ -227,12 +229,14 @@ exports.public = handleError(async (req, res) => {
|
|
|
pelanggaran: pelanggaran_id,
|
|
pelanggaran: pelanggaran_id,
|
|
|
keterangan,
|
|
keterangan,
|
|
|
role_data: 'dikti',
|
|
role_data: 'dikti',
|
|
|
|
|
+ role_asal: 'dikti',
|
|
|
level,
|
|
level,
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
data = await laporanModel.create(data)
|
|
data = await laporanModel.create(data)
|
|
|
await pemantauanModel.create({
|
|
await pemantauanModel.create({
|
|
|
laporan: data._id,
|
|
laporan: data._id,
|
|
|
|
|
+ action: 'CREATE LAPORAN',
|
|
|
pt_id: pt[0].id,
|
|
pt_id: pt[0].id,
|
|
|
user: user._id,
|
|
user: user._id,
|
|
|
keterangan: 'Membuat Laporan',
|
|
keterangan: 'Membuat Laporan',
|
|
@@ -262,10 +266,11 @@ exports.public = 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 where = {}
|
|
const where = {}
|
|
|
- const { no_laporan, pt_id, jadwal, evaluasi, aktif } = req.query
|
|
|
|
|
|
|
+ const { no_laporan, pt_id, jadwal, evaluasi, aktif, delegasi } = req.query
|
|
|
if (no_laporan) where.no_laporan = no_laporan
|
|
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 (aktif) where.aktif = aktif === 'true'
|
|
|
|
|
+ if (delegasi) where.delegasi = delegasi === 'true'
|
|
|
if (jadwal === 'true') {
|
|
if (jadwal === 'true') {
|
|
|
where.jadwal = {
|
|
where.jadwal = {
|
|
|
$exists: true,
|
|
$exists: true,
|
|
@@ -290,9 +295,10 @@ exports.getAll = handleError(async (req, res) => {
|
|
|
exports.getOne = handleError(async (req, res) => {
|
|
exports.getOne = handleError(async (req, res) => {
|
|
|
const { id } = req.params
|
|
const { id } = req.params
|
|
|
const user = req.user
|
|
const user = req.user
|
|
|
- const { aktif } = req.query
|
|
|
|
|
|
|
+ const { aktif, delegasi } = req.query
|
|
|
const where = {}
|
|
const where = {}
|
|
|
if (aktif) where.aktif = aktif === 'true'
|
|
if (aktif) where.aktif = aktif === 'true'
|
|
|
|
|
+ if (delegasi) where.delegasi = delegasi === 'true'
|
|
|
const data = await cekSatuDataLaporan(res, user, id, where)
|
|
const data = await cekSatuDataLaporan(res, user, id, where)
|
|
|
if (!data) return
|
|
if (!data) return
|
|
|
return response.success(res, {
|
|
return response.success(res, {
|
|
@@ -325,6 +331,7 @@ exports.update = handleError(async (req, res) => {
|
|
|
user.role.id === 2020 ? 'LLDIKTI' : 'DIKTI'
|
|
user.role.id === 2020 ? 'LLDIKTI' : 'DIKTI'
|
|
|
}`
|
|
}`
|
|
|
alasan = keterangan2
|
|
alasan = keterangan2
|
|
|
|
|
+ data.alasan_delegasi = keterangan2
|
|
|
if (laporan.jadwal) {
|
|
if (laporan.jadwal) {
|
|
|
await laporanModel.findByIdAndUpdate(laporan._id, {
|
|
await laporanModel.findByIdAndUpdate(laporan._id, {
|
|
|
$unset: { jadwal: 1 },
|
|
$unset: { jadwal: 1 },
|
|
@@ -344,6 +351,7 @@ exports.update = handleError(async (req, res) => {
|
|
|
const update = await laporanModel.findByIdAndUpdate(laporan._id, data)
|
|
const update = await laporanModel.findByIdAndUpdate(laporan._id, data)
|
|
|
if (change_role || aktif) {
|
|
if (change_role || aktif) {
|
|
|
await pemantauanModel.create({
|
|
await pemantauanModel.create({
|
|
|
|
|
+ action: 'UPDATE LAPORAN',
|
|
|
laporan: laporan._id,
|
|
laporan: laporan._id,
|
|
|
pt_id: laporan.pt.id,
|
|
pt_id: laporan.pt.id,
|
|
|
user: user._id,
|
|
user: user._id,
|