|
|
@@ -12,14 +12,25 @@ exports.cekSatuDataLaporan = async (
|
|
|
const w = { _id: laporan_id, aktif: where.aktif || true, ...where }
|
|
|
switch (user.role.id) {
|
|
|
case 2020:
|
|
|
- if (!where.delegasi) w.role_data = 'dikti'
|
|
|
- else {
|
|
|
+ if (where.all) {
|
|
|
+ // w.role_asal = 'dikti'
|
|
|
+ // w['$or'] = [
|
|
|
+ // { role_asal : 'dikti' },
|
|
|
+ // { role_asal: 'lldikti', role_data: 'dikti' },
|
|
|
+ // ]
|
|
|
+ break
|
|
|
+ } else if (!where.delegasi) {
|
|
|
+ w.role_data = 'dikti'
|
|
|
+ } else {
|
|
|
w.role_data = 'lldikti'
|
|
|
w.role_asal = 'dikti'
|
|
|
}
|
|
|
break
|
|
|
case 2021:
|
|
|
- if (!where.delegasi) {
|
|
|
+ if (where.all) {
|
|
|
+ w.role_asal = 'lldikti'
|
|
|
+ w['pt.pembina.id'] = user.lembaga.id
|
|
|
+ } else if (!where.delegasi) {
|
|
|
w.role_data = 'lldikti'
|
|
|
w['pt.pembina.id'] = user.lembaga.id
|
|
|
} else {
|
|
|
@@ -37,8 +48,8 @@ exports.cekSatuDataLaporan = async (
|
|
|
.populate({ path: 'user', populate: 'foto' })
|
|
|
.populate({ path: 'pelanggaran', select: 'pelanggaran' })
|
|
|
.populate('dokumen')
|
|
|
- .populate({path: 'evaluasi', populate: ['user', 'dokumen']})
|
|
|
- // .populate('evaluasi.user')
|
|
|
+ .populate({ path: 'evaluasi', populate: ['user', 'dokumen'] })
|
|
|
+ // .populate('evaluasi.user')
|
|
|
if (!laporan) {
|
|
|
response.error(res, {
|
|
|
message: 'laporan_id tidak ada',
|
|
|
@@ -53,14 +64,25 @@ exports.cekBanyakDataLaporan = async (user, where = { delegasi: false }) => {
|
|
|
const w = { aktif: where.aktif || true, ...where }
|
|
|
switch (user.role.id) {
|
|
|
case 2020:
|
|
|
- if (!where.delegasi) w.role_data = 'dikti'
|
|
|
- else {
|
|
|
+ if (where.all) {
|
|
|
+ // w.role_asal = 'dikti'
|
|
|
+ // w['$or'] = [
|
|
|
+ // { role_asal : 'dikti' },
|
|
|
+ // { role_asal: 'lldikti', role_data: 'dikti' },
|
|
|
+ // ]
|
|
|
+ break
|
|
|
+ } else if (!where.delegasi) {
|
|
|
+ w.role_data = 'dikti'
|
|
|
+ } else {
|
|
|
w.role_data = 'lldikti'
|
|
|
w.role_asal = 'dikti'
|
|
|
}
|
|
|
break
|
|
|
case 2021:
|
|
|
- if (!where.delegasi) {
|
|
|
+ if (where.all) {
|
|
|
+ w.role_asal = 'lldikti'
|
|
|
+ w['pt.pembina.id'] = user.lembaga.id
|
|
|
+ } else if (!where.delegasi) {
|
|
|
w.role_data = 'lldikti'
|
|
|
w['pt.pembina.id'] = user.lembaga.id
|
|
|
} else {
|
|
|
@@ -76,6 +98,7 @@ exports.cekBanyakDataLaporan = async (user, where = { delegasi: false }) => {
|
|
|
const data = await laporanModel
|
|
|
.find(w)
|
|
|
.populate('user')
|
|
|
+ .populate({ path: 'sanksi', populate: ['pelanggaran'] })
|
|
|
.select(w.select || ' -pelanggaran -aktif -dokumen')
|
|
|
.limit(w.limit)
|
|
|
.sort({
|
|
|
@@ -93,8 +116,13 @@ exports.cekSatuDataSanksi = async (
|
|
|
const w = { aktif: where.aktif || true }
|
|
|
switch (user.role.id) {
|
|
|
case 2020:
|
|
|
- if (!where.banding) w.role_data = 'dikti'
|
|
|
-
|
|
|
+ // if (where.all) w.role_asal = 'dikti'
|
|
|
+ if (where.all) break
|
|
|
+ else if (where.delegasi) {
|
|
|
+ w.role_data = 'lldikti'
|
|
|
+ w.role_asal = 'dikti'
|
|
|
+ }
|
|
|
+ else if (!where.banding) w.role_data = 'dikti'
|
|
|
break
|
|
|
case 2021:
|
|
|
w.role_data = 'lldikti'
|
|
|
@@ -131,13 +159,17 @@ exports.cekSatuDataSanksi = async (
|
|
|
return sanksi
|
|
|
}
|
|
|
|
|
|
-exports.cekBanyakDataSanksi = async (user, where = { banding: false }) => {
|
|
|
- const w = {}
|
|
|
+exports.cekBanyakDataSanksi = async (user, where = {}, q = {}) => {
|
|
|
+ const w = { ...q }
|
|
|
switch (user.role.id) {
|
|
|
case 2020:
|
|
|
- if (!where.banding) {
|
|
|
- w.role_data = 'dikti'
|
|
|
+ // if (where.all) w.role_asal = 'dikti'
|
|
|
+ if (where.all) break
|
|
|
+ else if (where.delegasi) {
|
|
|
+ w.role_data = 'lldikti'
|
|
|
+ w.role_asal = 'dikti'
|
|
|
}
|
|
|
+ else if (!where.banding) w.role_data = 'dikti'
|
|
|
break
|
|
|
case 2021:
|
|
|
w['role_data'] = 'lldikti'
|
|
|
@@ -155,7 +187,8 @@ exports.cekBanyakDataSanksi = async (user, where = { banding: false }) => {
|
|
|
match: w,
|
|
|
})
|
|
|
.populate('user')
|
|
|
- .select('-batas_waktu -dokumen -pelanggaran')
|
|
|
+ .populate('pelanggaran')
|
|
|
+ .select('-dokumen')
|
|
|
.sort({
|
|
|
createdAt: -1,
|
|
|
})
|