|
|
@@ -7,10 +7,9 @@ exports.cekSatuDataLaporan = async (
|
|
|
res,
|
|
|
user,
|
|
|
laporan_id,
|
|
|
- where = { delegasi: false }
|
|
|
+ where = { delegasi: false, aktif: true }
|
|
|
) => {
|
|
|
- const w = { _id: laporan_id, aktif: true, ...where }
|
|
|
- if (where.aktif === false) w.aktif = false
|
|
|
+ const w = { _id: laporan_id, aktif: where.aktif || true, ...where }
|
|
|
switch (user.role.id) {
|
|
|
case 2020:
|
|
|
if (!where.delegasi) w.role_data = 'dikti'
|
|
|
@@ -50,8 +49,7 @@ exports.cekSatuDataLaporan = async (
|
|
|
}
|
|
|
|
|
|
exports.cekBanyakDataLaporan = async (user, where = { delegasi: false }) => {
|
|
|
- const w = { aktif: true, ...where }
|
|
|
- if (where.aktif === false) w.aktif = false
|
|
|
+ const w = { aktif: where.aktif || true, ...where }
|
|
|
switch (user.role.id) {
|
|
|
case 2020:
|
|
|
if (!where.delegasi) w.role_data = 'dikti'
|
|
|
@@ -91,7 +89,7 @@ exports.cekSatuDataSanksi = async (
|
|
|
sanksi_id,
|
|
|
where = { banding: false }
|
|
|
) => {
|
|
|
- const w = { aktif: true }
|
|
|
+ const w = { aktif: where.aktif || true }
|
|
|
switch (user.role.id) {
|
|
|
case 2020:
|
|
|
if (!where.banding) w.role_data = 'dikti'
|
|
|
@@ -133,7 +131,7 @@ exports.cekSatuDataSanksi = async (
|
|
|
}
|
|
|
|
|
|
exports.cekBanyakDataSanksi = async (user, where = { banding: false }) => {
|
|
|
- const w = { aktif: true }
|
|
|
+ const w = {}
|
|
|
switch (user.role.id) {
|
|
|
case 2020:
|
|
|
if (!where.banding) {
|
|
|
@@ -149,14 +147,14 @@ exports.cekBanyakDataSanksi = async (user, where = { banding: false }) => {
|
|
|
break
|
|
|
}
|
|
|
let data = await sanksiModel
|
|
|
- .find({ aktif: true, ...where })
|
|
|
+ .find({ aktif: where.aktif || true, ...where })
|
|
|
.populate({
|
|
|
path: 'laporan',
|
|
|
select: 'pt',
|
|
|
match: w,
|
|
|
})
|
|
|
.populate('user')
|
|
|
- .select('-batas_waktu -aktif -dokumen -pelanggaran')
|
|
|
+ .select('-batas_waktu -dokumen -pelanggaran')
|
|
|
.sort({
|
|
|
createdAt: -1,
|
|
|
})
|