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