|  | @@ -11,6 +11,7 @@ const {
 | 
	
		
			
				|  |  |    cekBanyakDataPelanggaran,
 | 
	
		
			
				|  |  |    cekBanyakDataSanksi,
 | 
	
		
			
				|  |  |  } = require('../utils/cekData')
 | 
	
		
			
				|  |  | +const laporanModel = require('../model/laporan.model')
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  exports.create = handleError(async (req, res) => {
 | 
	
		
			
				|  |  |    const { no_sanksi, keterangan } = req.body
 | 
	
	
		
			
				|  | @@ -59,12 +60,13 @@ exports.create = handleError(async (req, res) => {
 | 
	
		
			
				|  |  |        keberatan: hariKerja(10),
 | 
	
		
			
				|  |  |      },
 | 
	
		
			
				|  |  |    })
 | 
	
		
			
				|  |  | +  await laporanModel.findByIdAndUpdate(laporan._id, { sanksi: data._id })
 | 
	
		
			
				|  |  |    await pemantauanModel.create({
 | 
	
		
			
				|  |  |      laporan: laporan._id,
 | 
	
		
			
				|  |  |      sanksi: data._id,
 | 
	
		
			
				|  |  |      pt_id: laporan.pt.id,
 | 
	
		
			
				|  |  |      user: user._id,
 | 
	
		
			
				|  |  | -    keterangan: 'Penetapan Sanksi',
 | 
	
		
			
				|  |  | +    keterangan: 'Melakukan penetapan Sanksi',
 | 
	
		
			
				|  |  |      dokumen: dokumen_id,
 | 
	
		
			
				|  |  |    })
 | 
	
		
			
				|  |  |    return response.success(res, {
 | 
	
	
		
			
				|  | @@ -75,7 +77,32 @@ exports.create = handleError(async (req, res) => {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  exports.getAll = handleError(async (req, res) => {
 | 
	
		
			
				|  |  |    const user = req.user
 | 
	
		
			
				|  |  | -  let data = await cekBanyakDataSanksi(user)
 | 
	
		
			
				|  |  | +  const { keberatan, jawaban, banding, cabutSanksi, perbaikan } = req.query
 | 
	
		
			
				|  |  | +  const where = {}
 | 
	
		
			
				|  |  | +  if (keberatan === 'true') {
 | 
	
		
			
				|  |  | +    where['pengajuan.keberatan'] = { $exists: true, $ne: null }
 | 
	
		
			
				|  |  | +    if (jawaban === 'true') {
 | 
	
		
			
				|  |  | +      where['jawaban.keberatan'] = { $exists: true, $ne: null }
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +  } else if (banding === 'true') {
 | 
	
		
			
				|  |  | +    where['pengajuan.keberatan'] = { $exists: true, $ne: null }
 | 
	
		
			
				|  |  | +    where['jawaban.keberatan'] = { $exists: true, $ne: null }
 | 
	
		
			
				|  |  | +    where['pengajuan.banding'] = { $exists: true, $ne: null }
 | 
	
		
			
				|  |  | +    if (jawaban === 'true') {
 | 
	
		
			
				|  |  | +      where['jawaban.banding'] = { $exists: true, $ne: null }
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +  } else if (cabutSanksi === 'true') {
 | 
	
		
			
				|  |  | +    where['pengajuan.cabut_sanksi'] = { $exists: true, $ne: null }
 | 
	
		
			
				|  |  | +    if (jawaban === 'true') {
 | 
	
		
			
				|  |  | +      where['jawaban.cabut_sanksi'] = { $exists: true, $ne: null }
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +  } else if (perbaikan === 'true') {
 | 
	
		
			
				|  |  | +    where.$or = [
 | 
	
		
			
				|  |  | +      { 'jawaban.cabut_sanksi': { $exists: true, $ne: null } },
 | 
	
		
			
				|  |  | +      { 'jawaban.banding': { $exists: true, $ne: null } },
 | 
	
		
			
				|  |  | +    ]
 | 
	
		
			
				|  |  | +  }
 | 
	
		
			
				|  |  | +  const data = await cekBanyakDataSanksi(user, where)
 | 
	
		
			
				|  |  |    return response.success(res, {
 | 
	
		
			
				|  |  |      message: 'Berhasil ambil data Sanksi',
 | 
	
		
			
				|  |  |      data,
 |