133 Commits c46629b101 ... f2c5fa330e

Author SHA1 Message Date
  yazid138 f2c5fa330e commit 3 months ago
  yazid138 3849af50b6 Merge branch 'master' of https://source.prod.sidali.vertibiz.com/yazid/ptb-be 3 months ago
  yazid138 c84531be8c commit 3 months ago
  yazid138 6effefbf12 fixing role auth from api dikti 2 years ago
  yazid138 b7cacda5e3 commit 3 years ago
  yazid138 11bb1b0925 udah fix 3 years ago
  yazid138 d03fcccf51 commit lagi 3 years ago
  yazid138 2bcce7edfd commit 3 years ago
  yazid138 0eee4c4a76 commit lagi 3 years ago
  yazid138 7cd64696d4 commit 3 years ago
  yazid138 90e90eb6bc commit andi 3 years ago
  yazid138 7f31fc97ae surat sanksi jadi no laporan di wa 3 years ago
  yazid138 ceb3bc1620 fix aja ini mah 3 years ago
  yazid138 c009d12e45 commit lagi 3 years ago
  yazid138 165eee775b update lagi 3 years ago
  yazid138 abb48f8367 commit lagi andi 3 years ago
  yazid138 b8dc1d4396 commit lagi andi 3 years ago
  yazid138 551da03d34 fix 3 years ago
  yazid138 234905514c fix lagi 3 years ago
  yazid138 0270135174 commit lagi deh 3 years ago
  yazid138 dfcfd51619 add: api perubahan sanksi 3 years ago
  yazid138 ded621192c commit lagi 3 years ago
  yazid138 f8ad6d765b commit andi 3 years ago
  yazid138 0ba4639567 commit aja dah 3 years ago
  yazid138 1846501e25 commit aja dah 3 years ago
  yazid138 543e5abd42 udah aman 3 years ago
  yazid138 3726e2b90b fixing laporan 3 years ago
  yazid138 4f1b4c039c sip dah 3 years ago
  yazid138 2c769f0f91 commit dulu aja dah 3 years ago
  yazid138 d7787e41a1 add auto update status sanksi 3 years ago
  yazid138 25ea10f977 add edit tmt 3 years ago
  yazid138 3b67e33b27 auth with cookie 3 years ago
  yazid138 1fd83bb909 add data keterangan to get one sanksi 3 years ago
  yazid138 8358468040 add rekomendasi 3 years ago
  yazid138 0e45c05643 add all to get one sanksi 3 years ago
  yazid138 96e575f4ad add sanksi to laporan 3 years ago
  yazid138 e38d76cc8e add sanksi to laporan 3 years ago
  yazid138 ce27a6d069 fixing get all sanksi 3 years ago
  yazid138 058815a8cf add delegasi 3 years ago
  yazid138 7facea9ea8 add pelanggaran 3 years ago
  yazid138 13408e091f add pelanggaran 3 years ago
  yazid138 39add7e6da Merge branch 'master' of https://source.sidali.sixsenz.net/yazid/ptb-be 3 years ago
  yazid138 5fbab77b61 tambahin data laporan dan sanksi di jumlah status laporan 3 years ago
  yazid a545a7bbc1 fix, dikti bisa liat semua laporan yg dibuat oleh lldikti 3 years ago
  yazid138 94601db263 fix again 3 years ago
  yazid138 c4c371f8b9 laporan get by pembina 3 years ago
  yazid138 d0967cd977 fix again 3 years ago
  yazid138 e19ad2568b fix 3 years ago
  yazid138 c046d55aa0 fix be 3 years ago
  yazid138 2f10e556fd fix 3 years ago
  yazid138 f27d8a4597 fix 3 years ago
  yazid138 573bae073e add jumlah status laporan 3 years ago
  yazid138 8a52bced1e fixing list sanksi 3 years ago
  yazid138 0cf37b540f fix 3 years ago
  yazid138 e6eed1d3c6 buat laporan selesai 3 years ago
  yazid138 5dc308adf3 tanpa reset jadwal 3 years ago
  yazid138 0155822784 a 3 years ago
  yazid138 e485fb1d23 fixing 3 years ago
  yazid138 295384f235 commit 3 years ago
  yazid138 f12fe1cc00 fix 3 years ago
  yazid138 e85c23925f fix 3 years ago
  yazid138 2626953fcb sip 3 years ago
  yazid138 49b8cf0eab sip 3 years ago
  yazid138 c67d3f2a02 sip 3 years ago
  yazid138 68751b305f commit 3 years ago
  yazid138 d6ce7f4472 add auto reminder sanksi 3 years ago
  yazid138 dfe3657812 commit aja 3 years ago
  yazid138 80f7e22475 commit aja dulu 3 years ago
  yazid138 aafbaaf46d fix perbaikan 3 years ago
  yazid138 f712702ea4 commit aja dulu deh di bagian masa berlaku sanksi 3 years ago
  yazid138 203e199c76 fix deh 3 years ago
  yazid138 c3c259b647 jumlah laporan 3 years ago
  yazid138 65ed20b8c3 commit aja deh 3 years ago
  yazid138 d930e5fcb6 fix flow dokumen perbaikan 3 years ago
  yazid138 7279c09ef1 fixing route 3 years ago
  yazid138 50355802fe fixing sanksi dan pencabutan sanksi 3 years ago
  yazid138 426f763acd commit lagi 3 years ago
  yazid138 2f1960f366 add pengunjung 3 years ago
  yazid138 c4fba24b5c commit deh 3 years ago
  yazid138 15b4c928c8 fix laporan publik 3 years ago
  yazid138 7a0b9d1ed5 remove data from auto.controller.js 3 years ago
  yazid138 51f283ae61 add auto notif wa 3 years ago
  yazid138 603a14e170 ganti format osVaue 3 years ago
  yazid138 aa56aa2c73 fix log 3 years ago
  yazid138 1ff9944870 fix pemantauan 3 years ago
  yazid138 1ee4bf7634 fixing pemantauan 3 years ago
  yazid138 ec1a9d3009 update login lagi 3 years ago
  yazid138 cb08663d73 4, 6 3 years ago
  yazid138 d8e77641da fix log 3 years ago
  yazid138 7032d7dfc2 commit dulu deh 3 years ago
  yazid138 24931b4f40 commit lagi deh 3 years ago
  yazid138 94cbf29f55 commit 3 years ago
  yazid138 c9f57be031 commit 3 years ago
  yazid138 fb061c4299 commit deh 3 years ago
  yazid138 04ce944d7f fix role again 3 years ago
  yazid138 4ddc1192fd commit aja deh 3 years ago
  yazid138 89af65fa2f finish token and roling 3 years ago
  yazid138 da45976866 fix data graph 3 years ago
  yazid138 fe8b7bc8c0 udah fix excel 3 years ago
  yazid138 142bf83517 commit lagi 3 years ago
  yazid138 d2cb23c8d7 commit lagi 3 years ago
  yazid138 9c29e4412d commit lagi dah 3 years ago
  yazid138 d2749deba8 fix consume api get excel 3 years ago
  yazid138 f99d7c97d6 commit lagi 3 years ago
  yazid138 778602a677 commit dulu 3 years ago
  yazid138 6157e3775c commit dulu aja deh 3 years ago
  yazid138 c9cde9c5cb fix graph data 3 years ago
  yazid138 5f6dc9e547 fix data graph 3 years ago
  yazid138 783aa95e01 dah beres di graph 3 years ago
  yazid138 e04a23e698 aman 3 years ago
  yazid138 ddd8391e0f fix pt 3 years ago
  yazid138 8e399cbc0e commit aja dah 3 years ago
  yazid138 7302e600c1 commit lagi 3 years ago
  yazid138 01e3f0eec5 hapus unique user di model sanksi 3 years ago
  yazid138 d601d06b38 commit aja dah 3 years ago
  yazid138 201fd79ebb commit dulu 3 years ago
  yazid138 5678ca8ebc add data action di pemantauan 3 years ago
  yazid138 816eb3e079 commit 3 years ago
  yazid138 f2104daff6 tambah role_asal di pelaporan 3 years ago
  yazid138 aae29292a7 pemantauan menggunakan laporan_id 3 years ago
  yazid138 c59918ff83 mengubah text pemantauan jadwal pemeriksaan 3 years ago
  yazid138 a3fa205bf7 update no hp aktif di user 3 years ago
  yazid138 43dc6acd9e penambahan level laporan 3 years ago
  yazid138 4f9b4e7cbf perubahan di pembuatan laporan publik 3 years ago
  yazid138 a97645edbd tambahan data for_pt di pemantauan 3 years ago
  yazid138 22994273df perubahan input data update laporan 3 years ago
  yazid138 b34337ab76 commit 3 years ago
  yazid138 2708291eca ubah keterangan pemantauan 3 years ago
  yazid138 25e0f6cb45 commit 3 years ago
  yazid138 ebe4870e1d commit 3 years ago
  yazid138 3ff32ae146 commit 3 years ago
  yazid138 8e91d716d4 commit 3 years ago
  yazid138 719b09db7d commit 3 years ago

+ 2 - 1
.gitignore

@@ -55,7 +55,8 @@ typings/
 .yarn-integrity
 
 # dotenv environment variables file
-#.env
+.env
+tes.js
 
 # next.js build output
 # .next

+ 263 - 0
controller/auto.controller.js

@@ -0,0 +1,263 @@
+const handleError = require('../utils/handleError')
+const response = require('../utils/responseHandler')
+const { notifWA } = require('../utils/notifFunction')
+const sanksiModel = require('../model/sanksi.model')
+const {
+  TEMPLATE_KEBERATAN,
+  TEMPLATE_BANDING,
+  TEMPLATE_REMINDER,
+} = require('../utils/constanta')
+const moment = require('moment')
+
+exports.keberatan = handleError(async (req, res) => {
+  const dataSanksi = await sanksiModel
+    .find({
+      'batas_waktu.keberatan': {
+        $lt: new Date().toISOString(),
+      },
+      'batas_waktu.jawaban_keberatan': {
+        $exists: false,
+        $eq: null,
+      },
+    })
+    .populate('user')
+    .populate('laporan')
+
+  if (!dataSanksi.length) {
+    return response.success(res, {
+      message: 'Tidak ada notifikasi yg dikirim',
+    })
+  }
+
+  Promise.all(
+    dataSanksi.map(
+      async (sanksi) =>
+        await notifWA(TEMPLATE_KEBERATAN, [
+          {
+            key: '1',
+            value: 'nama_pt',
+            value_text: sanksi.laporan.pt.nama,
+          },
+          {
+            key: '2',
+            value: 'pemberi_sanksi',
+            value_text: sanksi.user.lembaga.nama,
+          },
+          {
+            key: '3',
+            value: 'no_laporan',
+            value_text: sanksi.laporan.no_laporan,
+          },
+        ])
+    )
+  )
+  return response.success(res, {
+    message: 'Notifikasi berhasil terkirim',
+  })
+})
+
+exports.banding = handleError(async (req, res) => {
+  const dataSanksi = await sanksiModel
+    .find({
+      'batas_waktu.banding': {
+        $lt: new Date().toISOString(),
+      },
+      'batas_waktu.jawaban_banding': {
+        $exists: false,
+        $eq: null,
+      },
+      'batas_waktu.jawaban_keberatan': {
+        $exists: true,
+        $ne: null,
+      },
+    })
+    .populate('user')
+    .populate('laporan')
+
+  if (!dataSanksi.length) {
+    return response.success(res, {
+      message: 'Tidak ada notifikasi yg dikirim',
+    })
+  }
+
+  Promise.all(
+    dataSanksi.map(
+      async (sanksi) =>
+        await notifWA(TEMPLATE_BANDING, [
+          {
+            key: '1',
+            value: 'nama_pt',
+            value_text: sanksi.laporan.pt.nama,
+          },
+          {
+            key: '2',
+            value: 'pemberi_sanksi',
+            value_text: sanksi.user.lembaga.nama,
+          },
+          {
+            key: '3',
+            value: 'no_laporan',
+            value_text: sanksi.laporan.no_laporan,
+          },
+        ])
+    )
+  )
+  return response.success(res, {
+    message: 'Notifikasi berhasil terkirim',
+  })
+})
+
+exports.reminderKeberatan = handleError(async (req, res) => {
+  let dataSanksi = await sanksiModel
+    .find({
+      'batas_waktu.jawaban_keberatan': {
+        $exists: true,
+        $ne: null,
+      },
+      'jawaban.keberatan': {
+        $exists: false,
+        $eq: null,
+      },
+    })
+    .populate('user')
+    .populate('laporan')
+  const notif = await Promise.all(
+    dataSanksi.map(async (e) => {
+      if (
+        e.batas_waktu.jawaban_keberatan &&
+        new Date() >
+          moment(e.batas_waktu.jawaban_keberatan).add(-7, 'days').toDate() &&
+        new Date() < e.batas_waktu.jawaban_keberatan
+      ) {
+        const dayLeft = moment(e.batas_waktu.jawaban_keberatan).diff(
+          new Date(),
+          'days'
+        )
+        try {
+          await notifWA(TEMPLATE_REMINDER, [
+            {
+              key: '1',
+              value: 'no_laporan',
+              value_text: e.laporan.no_laporan,
+            },
+            {
+              key: '2',
+              value: 'keterangan',
+              value_text: 'Proses Menjawab Pengajuan Keberatan',
+            },
+            {
+              key: '3',
+              value: 'pt',
+              value_text: e.laporan.pt.nama,
+            },
+            {
+              key: '4',
+              value: 'masa',
+              value_text: `menjawab pengajuan keberatan tersisa ${dayLeft} hari lagi.`,
+            },
+          ])
+        } catch (error) {
+          return response.error(res, {
+            message: 'Notifikasi gagal terkirim',
+            error: error.message,
+          })
+        }
+      }
+    })
+  )
+
+  let message = 'Tidak ada notifikasi yang dikirim'
+  if (notif.length) message = 'Notifikasi berhasil terkirim'
+
+  return response.success(res, {
+    message,
+  })
+})
+
+exports.reminderBanding = handleError(async (req, res) => {
+  let dataSanksi = await sanksiModel
+    .find({
+      'batas_waktu.jawaban_banding': {
+        $exists: true,
+        $ne: null,
+      },
+      'jawaban.banding': {
+        $exists: false,
+        $eq: null,
+      },
+    })
+    .populate('user')
+    .populate('laporan')
+  const notif = await Promise.all(
+    dataSanksi.map(async (e) => {
+      if (
+        e.batas_waktu.jawaban_banding &&
+        new Date() >
+          moment(e.batas_waktu.jawaban_banding).add(-7, 'days').toDate() &&
+        new Date() < e.batas_waktu.jawaban_banding
+      ) {
+        const dayLeft = moment(e.batas_waktu.jawaban_banding).diff(
+          new Date(),
+          'days'
+        )
+        try {
+          await notifWA(TEMPLATE_REMINDER, [
+            {
+              key: '1',
+              value: 'no_laporan',
+              value_text: e.laporan.no_laporan,
+            },
+            {
+              key: '2',
+              value: 'keterangan',
+              value_text: 'Proses Menjawab Pengajuan Banding',
+            },
+            {
+              key: '3',
+              value: 'pt',
+              value_text: e.laporan.pt.nama,
+            },
+            {
+              key: '4',
+              value: 'masa',
+              value_text: `menjawab pengajuan banding tersisa ${dayLeft} hari lagi.`,
+            },
+          ])
+        } catch (error) {
+          return response.error(res, {
+            message: 'Notifikasi gagal terkirim',
+            error: error.message,
+          })
+        }
+      }
+    })
+  )
+
+  let message = 'Tidak ada notifikasi yang dikirim'
+  if (notif.length) message = 'Notifikasi berhasil terkirim'
+
+  return response.success(res, {
+    message,
+  })
+})
+
+exports.updateStatusSanksi = handleError(async (req, res) => {
+  const sanksi = await sanksiModel.find({
+    'masa_berlaku.to_date': {
+      $lte: new Date().toISOString(),
+    },
+    aktif: true,
+  })
+
+  Promise.all(
+    sanksi.map(async (e) =>
+      sanksiModel.findByIdAndUpdate(e._id, {
+        aktif: false,
+      })
+    )
+  )
+
+  return response.success(res, {
+    message: 'update status sanksi berhasil',
+  })
+})

+ 533 - 0
controller/graph.controller.js

@@ -0,0 +1,533 @@
+const handleError = require('../utils/handleError')
+const excel = require('../utils/excel')
+const response = require('../utils/responseHandler')
+const {
+  cekBanyakDataLaporan,
+  dataLaporanAggregate,
+  cekBanyakDataSanksi,
+} = require('../utils/cekData')
+const laporanModel = require('../model/laporan.model')
+const sanksiModel = require('../model/sanksi.model')
+const moment = require('moment')
+
+exports.laporan = handleError(async (req, res) => {
+  const user = req.user
+  const data = {}
+  const date = new Date()
+
+  // let berdasarkan_tahun = {}
+  const {
+    jumlahLaporan,
+    jadwal,
+    evaluasi,
+    sanksi,
+    newLaporan,
+    laporanBulan,
+    laporanTahun,
+    bulan,
+    tahun,
+    listJadwal,
+  } = req.query
+
+  // if (tahun) {
+  berdasarkan_tahun = {
+    $and: [
+      {
+        createdAt: {
+          $gte: new Date(`${tahun || date.getFullYear()}`),
+        },
+      },
+      {
+        createdAt: {
+          $lt: new Date(`${parseInt(tahun) + 1 || date.getFullYear() + 1}`),
+        },
+      },
+    ],
+  }
+  // }
+
+  const laporan = await cekBanyakDataLaporan(user, { ...berdasarkan_tahun })
+
+  if (jumlahLaporan == 'true') {
+    const delegasi = await cekBanyakDataLaporan(user, {
+      delegasi: true,
+      ...berdasarkan_tahun,
+    })
+    const ditutup = await cekBanyakDataLaporan(user, {
+      aktif: false,
+      ...berdasarkan_tahun,
+    })
+
+    data.jumlah_laporan = {
+      dikti: laporan.length,
+      lldikti: delegasi.length,
+      ditutup: ditutup.length,
+      tes: {
+        delegasi: true,
+        ...berdasarkan_tahun,
+      },
+    }
+  }
+
+  if (jadwal == 'true') {
+    const hasJadwal = laporan.filter((e) => e.jadwal.judul).length
+    const notHasJadwal = laporan.filter((e) => !e.jadwal.judul).length
+
+    data.jadwal = {
+      hasJadwal,
+      notHasJadwal,
+    }
+  }
+
+  if (evaluasi == 'true') {
+    const hasEvaluasi = laporan.filter(
+      (e) => e.evaluasi.length && e.jadwal.judul
+    ).length
+    const notHasEvaluasi = laporan.filter(
+      (e) => e.evaluasi.length == 0 && e.jadwal.judul
+    ).length
+
+    data.evaluasi = {
+      hasEvaluasi,
+      notHasEvaluasi,
+    }
+  }
+
+  if (sanksi == 'true') {
+    const hasSanksi = laporan.filter(
+      (e) => e.sanksi && e.evaluasi.length
+    ).length
+    const notHasSanksi = laporan.filter(
+      (e) => !e.sanksi && e.evaluasi.length
+    ).length
+
+    data.sanksi = {
+      hasSanksi,
+      notHasSanksi,
+    }
+  }
+
+  if (newLaporan == 'true') {
+    data.newLaporan = await cekBanyakDataLaporan(user, {
+      limit: 3,
+      select: 'no_laporan pt.nama -user createdAt',
+    })
+  }
+
+  if (laporanBulan == 'true') {
+    let date = {}
+    if (bulan || (bulan && tahun)) {
+      const temp = new Date()
+      date = {
+        $expr: {
+          $and: [
+            { $eq: [{ $month: '$createdAt' }, parseInt(bulan)] },
+            {
+              $eq: [
+                { $year: '$createdAt' },
+                parseInt(tahun) || temp.getFullYear(),
+              ],
+            },
+          ],
+        },
+      }
+    }
+
+    data.laporan_perbulan = await dataLaporanAggregate(
+      user,
+      { ...date },
+      {
+        _id: {
+          bulan: {
+            $month: '$createdAt',
+          },
+          tahun: {
+            $year: '$createdAt',
+          },
+        },
+        jumlah_laporan: {
+          $sum: 1,
+        },
+      }
+    )
+  } else if (laporanTahun == 'true') {
+    const temp = new Date()
+    let date = {
+      $expr: {
+        $eq: [{ $year: '$createdAt' }, parseInt(tahun) || temp.getFullYear()],
+      },
+    }
+
+    data.laporan_perTahun = await dataLaporanAggregate(
+      user,
+      { ...date },
+      {
+        _id: {
+          bulan: {
+            $month: '$createdAt',
+          },
+          tahun: {
+            $year: '$createdAt',
+          },
+        },
+        jumlah_laporan: {
+          $sum: 1,
+        },
+      }
+    )
+  }
+
+  if (listJadwal == 'true') {
+    const temp = new Date()
+    let date = {
+      $expr: {
+        $and: [
+          {
+            $eq: [
+              { $month: '$jadwal.dari_tanggal' },
+              parseInt(bulan) || temp.getMonth() + 1,
+            ],
+          },
+          {
+            $eq: [
+              { $year: '$jadwal.dari_tanggal' },
+              parseInt(tahun) || temp.getFullYear(),
+            ],
+          },
+        ],
+      },
+    }
+
+    data.list_jadwal = await dataLaporanAggregate(
+      user,
+      {
+        aktif: true,
+        ...date,
+        jadwal: {
+          $ne: null,
+          $exists: true,
+        },
+      },
+      {
+        _id: {
+          bulan: {
+            $month: '$jadwal.dari_tanggal',
+          },
+          tahun: {
+            $year: '$jadwal.dari_tanggal',
+          },
+        },
+        jadwal: {
+          $push: '$jadwal',
+        },
+      }
+    )
+  }
+
+  return response.success(res, {
+    message: 'Berhasil menganalisis data',
+    data,
+  })
+})
+
+exports.excel = handleError(async (req, res) => {
+  const user = req.user
+  const w = {}
+  const date = new Date()
+  switch (user.role.id) {
+    case 2020:
+      w['$or'] = [
+        {
+          role_asal: 'dikti',
+        },
+        {
+          role_data: 'dikti',
+        },
+      ]
+      break
+    case 2021:
+      w['$or'] = [
+        {
+          role_asal: 'lldikti',
+        },
+        {
+          role_data: 'lldikti',
+        },
+      ]
+      w['pt.pembina.id'] = user.lembaga.id
+      break
+  }
+
+  const { tahun, penjadwalan, pelaporan, pemeriksaan, delegasi, sanksi } =
+    req.query
+
+  berdasarkan_tahun = {
+    $and: [
+      {
+        createdAt: {
+          $gte: new Date(`${tahun || date.getFullYear()}`),
+        },
+      },
+      {
+        createdAt: {
+          $lt: new Date(`${parseInt(tahun) + 1 || date.getFullYear() + 1}`),
+        },
+      },
+    ],
+  }
+
+  const laporan = await laporanModel
+    .find({ ...w, ...berdasarkan_tahun })
+    .populate('user')
+
+  const dataDelegasi = laporan.map((value) => ({
+    Tanggal: moment(value.createdAt).format('DD-MMMM-YYYY'),
+    'No. Laporan': value.no_laporan,
+    'Nama Perguruan Tinggi': value.pt.nama,
+    'Keterangan Laporan': value.keterangan,
+    'Dibuat Oleh': value.user.nama,
+    Status: !value.aktif
+      ? 'Ditutup'
+      : (value.role_asal === 'dikti' && value.role_data === 'dikti') ||
+        (value.role_data == 'dikti' && user.role.id === 2020) ||
+        (value.role_asal === 'lldikti' && value.role_data === 'lldikti') ||
+        (value.role_data == 'lldikti' && user.role.id === 2021)
+      ? `Ditindaklanjuti ${value.role_data === 'dikti' ? 'DIKTI' : 'LLDIKTI'}`
+      : `Delegasi Ke ${value.role_data === 'dikti' ? 'DIKTI' : 'LLDIKTI'}`,
+  }))
+
+  const dataLaporan = laporan.map((value) => ({
+    Tanggal: moment(value.createdAt).format('DD-MMMM-YYYY'),
+    'No. Laporan': value.no_laporan,
+    'Nama Perguruan Tinggi': value.pt.nama,
+    'Keterangan Laporan': value.keterangan,
+    'Dibuat Oleh': value.user.nama,
+    Status:
+      value.sanksi || value.aktif === false
+        ? 'Pelaporan Selesai'
+        : 'Pelaporan Belum Selesai',
+  }))
+
+  const dataJadwal = laporan
+    .filter((e) => e.aktif === true)
+    .map((value) => ({
+      Tanggal: moment(value.createdAt).format('DD-MMMM-YYYY'),
+      'No. Laporan': value.no_laporan,
+      'Nama Perguruan Tinggi': value.pt.nama,
+      'Keterangan Laporan': value.keterangan,
+      'Dibuat Oleh': value.user.nama,
+      'Dari Tanggal':
+        value.jadwal.judul &&
+        moment(value.jadwal.dari_tanggal).format('DD-MMMM-YYYY'),
+      'Sampai Tanggal':
+        value.jadwal.judul &&
+        moment(value.jadwal.sampai_tanggal).format('DD-MMMM-YYYY'),
+      Status: value.jadwal.judul ? 'Sudah ada jadwal' : 'Belum ada jadwal',
+    }))
+
+  const dataPemeriksaan = laporan
+    .filter((e) => e.aktif === true && e.jadwal.judul)
+    .map((value) => ({
+      Tanggal: moment(value.createdAt).format('DD-MMMM-YYYY'),
+      'No. Laporan': value.no_laporan,
+      'Nama Perguruan Tinggi': value.pt.nama,
+      'Keterangan Laporan': value.keterangan,
+      'Dibuat Oleh': value.user.nama,
+      Status: value.evaluasi.length ? 'Sudah diperiksa' : 'Belum diperiksa',
+    }))
+
+  const dataSanksi = laporan
+    .filter((e) => e.aktif === true && e.evaluasi.length)
+    .map((value) => ({
+      Tanggal: moment(value.createdAt).format('DD-MMMM-YYYY'),
+      'No. Laporan': value.no_laporan,
+      'Nama Perguruan Tinggi': value.pt.nama,
+      'Keterangan Laporan': value.keterangan,
+      'Dibuat Oleh': value.user.nama,
+      Status: value.sanksi ? 'Sudah ditetapkan' : 'Belum ditetapkan',
+    }))
+
+  const data = []
+  if (delegasi === 'true') {
+    data.push({ SheetNames: 'Delegasi', data: dataDelegasi })
+  }
+  if (pelaporan === 'true') {
+    data.push({ SheetNames: 'Pelaporan', data: dataLaporan })
+  }
+  if (penjadwalan === 'true') {
+    data.push({
+      SheetNames: 'Penjadwalan',
+      data: dataJadwal,
+    })
+  }
+  if (pemeriksaan === 'true') {
+    data.push({ SheetNames: 'Pemeriksaan', data: dataPemeriksaan })
+  }
+  if (sanksi === 'true') {
+    data.push({ SheetNames: 'Sanksi', data: dataSanksi })
+  }
+  const buffer = excel.to_excel(data)
+
+  res.header(
+    'Content-Type',
+    'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
+  )
+  return res.end(Buffer.from(buffer))
+})
+
+exports.laporanSelesai = handleError(async (req, res) => {
+  const user = req.user
+
+  laporan = await cekBanyakDataLaporan(user, { aktif: false })
+  sanksi = await cekBanyakDataSanksi(user, { aktif: false })
+  const data = {
+    laporan,
+    sanksi,
+    jumlah_selesai: sanksi.length,
+    jumlah_ditutup: laporan.length,
+  }
+
+  return response.success(res, {
+    message: 'Berhasil menganalisis data',
+    data,
+  })
+})
+
+exports.jumlahStatusLaporan = handleError(async (req, res) => {
+  let dataPembina = await laporanModel.find({
+    aktif: true,
+  })
+  const user = req.user
+
+  dataPembina = [
+    ...new Set(
+      dataPembina.map((e) => `${e.pt.pembina.id};${e.pt.pembina.nama}`)
+    ),
+  ]
+
+  dataPembina = dataPembina.map((e) => ({
+    id: e.split(';')[0],
+    name: e.split(';')[1],
+  })).sort((a, b) => a.name < b.name ? -1 : 1)
+
+  let data = await Promise.all(
+    dataPembina.map(async (e) => {
+      return {
+        pembina: e,
+        laporan: await cekBanyakDataLaporan(user, {
+          all: true,
+          ['pt.pembina.id']: e.id,
+        }),
+        sanksi: (
+          await cekBanyakDataSanksi(
+            user,
+            { all: true },
+            { ['pt.pembina.id']: e.id }
+          )
+        ).filter((e) => e.laporan != null),
+        jumlah_jadwal_evaluasi: await laporanModel
+          .find({
+            aktif: true,
+            jadwal: {
+              $ne: null,
+              $exists: true,
+            },
+            'pt.pembina.id': e.id,
+          })
+          .count(),
+        jumlah_pemeriksaan: await laporanModel
+          .find({
+            aktif: true,
+            evaluasi: {
+              $ne: null,
+              $not: {
+                $size: 0,
+              },
+              $exists: true,
+            },
+            'pt.pembina.id': e.id,
+          })
+          .count(),
+        jumlah_sanksi: await laporanModel
+          .find({
+            aktif: true,
+            sanksi: {
+              $ne: null,
+              $exists: true,
+            },
+            'pt.pembina.id': e.id,
+          })
+          .count(),
+        jumlah_keberatan: (
+          await sanksiModel
+            .find({
+              aktif: true,
+              'pengajuan.keberatan': {
+                $ne: null,
+                $exists: true,
+              },
+            })
+            .populate({
+              path: 'laporan',
+              match: {
+                'pt.pembina.id': e.id,
+              },
+            })
+        ).filter((e) => e.laporan != null).length,
+        jumlah_banding: (
+          await sanksiModel
+            .find({
+              aktif: true,
+              'pengajuan.banding': {
+                $ne: null,
+                $exists: true,
+              },
+            })
+            .populate({
+              path: 'laporan',
+              match: {
+                'pt.pembina.id': e.id,
+              },
+            })
+        ).filter((e) => e.laporan != null).length,
+        jumlah_pemantauan_perbaikan: (
+          await sanksiModel
+            .find({
+              aktif: true,
+              perbaikan: {
+                $ne: [],
+                $exists: true,
+              },
+            })
+            .populate({
+              path: 'laporan',
+              match: {
+                'pt.pembina.id': e.id,
+              },
+            })
+        ).filter((e) => e.laporan != null).length,
+        jumlah_pencabutan_sanksi: (
+          await sanksiModel
+            .find({
+              aktif: true,
+              'pengajuan.cabut_sanksi': {
+                $ne: null,
+                $exists: true,
+              },
+            })
+            .populate({
+              path: 'laporan',
+              match: {
+                'pt.pembina.id': e.id,
+              },
+            })
+        ).filter((e) => e.laporan != null).length,
+      }
+    })
+  )
+
+  return response.success(res, {
+    message: 'Berhasil menganalisis data',
+    data,
+  })
+})

+ 36 - 0
controller/log.controller.js

@@ -0,0 +1,36 @@
+const logModel = require('../model/log.model')
+const handleError = require('../utils/handleError')
+const response = require('../utils/responseHandler')
+const { validate } = require('../utils/validation')
+
+exports.create = handleError(async (req, res) => {
+  const user = req.user
+  const { aktivitas, os, ipv4, menu } = req.body
+
+  const isValid = validate(res, req.body, {
+    aktivitas: 'string',
+    os: 'string',
+    ipv4: 'string',
+  })
+  if (!isValid) return
+
+  await logModel.create({
+    user: user._id,
+    aktivitas,
+    os,
+    ipv4,
+    menu,
+  })
+
+  return response.success(res, {
+    message: 'log berhasil dibuat',
+  })
+})
+
+exports.all = handleError(async (req, res) => {
+  const log = await logModel.find().populate('user').sort({ createdAt: -1 })
+
+  return response.success(res, {
+    data: log,
+  })
+})

+ 146 - 0
controller/pengunjung.controller.js

@@ -0,0 +1,146 @@
+const pengunjungModel = require('../model/pengunjung.model')
+const handleError = require('../utils/handleError')
+const response = require('../utils/responseHandler')
+const { validate } = require('../utils/validation')
+
+exports.create = handleError(async (req, res) => {
+  const { os, ipv4, location } = req.body
+  const isValid = validate(res, req.body, {
+    os: 'string',
+    ipv4: 'string',
+    location: {
+      $$type: 'object',
+      country: 'string',
+      region: 'string',
+      city: 'string',
+      lat: 'number',
+      lon: 'number',
+      timezone: 'string',
+    },
+  })
+  if (!isValid) return
+
+  await pengunjungModel.create({ os, ipv4, location })
+
+  return response.success(res, {
+    message: 'data pengunjung berhasil dibuat',
+  })
+})
+
+exports.getPengunjung = handleError(async (req, res) => {
+  const { tahun } = req.query
+
+  let date = {}
+  if (tahun) {
+    date = {
+      $expr: {
+        $eq: [
+          { $year: '$createdAt' },
+          parseInt(tahun) || new Date().getFullYear(),
+        ],
+      },
+    }
+  }
+
+  const pengunjung = await pengunjungModel.aggregate([
+    { $match: date },
+    {
+      $group: {
+        _id: {
+          bulan: {
+            $month: '$createdAt',
+          },
+          tahun: {
+            $year: '$createdAt',
+          },
+        },
+        jumlah_pengunjung: {
+          $sum: 1,
+        },
+      },
+    },
+    {
+      $sort: {
+        ['_id.bulan']: 1,
+      },
+    },
+  ])
+
+  return response.success(res, {
+    message: 'data pengunjung',
+    data: pengunjung,
+  })
+})
+
+exports.getPengunjungPublic = handleError(async (req, res) => {
+  const { tahun, bulan } = req.query
+
+  let date = {}
+  if (tahun || bulan) {
+    date = {
+      $expr: {
+        $and: [
+          {
+            $eq: [
+              { $year: '$createdAt' },
+              parseInt(tahun) || new Date().getFullYear(),
+            ],
+          },
+          {
+            $eq: [
+              { $month: '$createdAt' },
+              parseInt(bulan) || new Date().getMonth() + 1,
+            ],
+          },
+        ],
+      },
+    }
+  }
+
+  const pengunjung = await pengunjungModel.aggregate([
+    { $match: date },
+    {
+      $group: {
+        _id: {
+          tanggal: {
+            $dayOfMonth: '$createdAt',
+          },
+          bulan: {
+            $month: '$createdAt',
+          },
+          tahun: {
+            $year: '$createdAt',
+          },
+        },
+        jumlah_pengunjung: {
+          $sum: 1,
+        },
+        data_ip: {
+          $addToSet: '$ipv4',
+        },
+      },
+    },
+    {
+      $addFields: {
+        jumlah_pengunjung: {
+          $size: '$data_ip',
+        },
+      },
+    },
+    {
+      $project: {
+        data_ip: 0,
+      },
+    },
+    {
+      $sort: {
+        ['_id.tanggal']: 1,
+      },
+    },
+  ])
+
+  return response.success(res, {
+    message: 'data pengunjung',
+    data: pengunjung,
+  })
+})

+ 60 - 0
controller/rekomendasi.controller.js

@@ -0,0 +1,60 @@
+const handleError = require('../utils/handleError')
+const response = require('../utils/responseHandler')
+const { addManyDokumen } = require('../utils/dokumenFunction')
+const { cekSatuDataSanksi } = require('../utils/cekData')
+const pemantauanModel = require('../model/pemantauan.model')
+const sanksiModel = require('../model/sanksi.model')
+
+exports.createRekomendasi = handleError(async (req, res) => {
+  const user = req.user
+  const { id } = req.params
+
+  const sanksi = await cekSatuDataSanksi(res, user, id, { delegasi: true })
+  if (!sanksi) return
+
+  const files = req.files
+  if (!files.length) {
+    return response.error(res, {
+      message: 'dokumen harus ada',
+    })
+  }
+  const dokumen = await addManyDokumen(files)
+  const dokumen_id = dokumen.map((e) => e._id)
+
+  const data = await sanksiModel.findOneAndUpdate(
+    {
+      _id: sanksi._id,
+    },
+    {
+      $push: {
+        rekomendasi: {
+          dokumen: dokumen_id,
+        },
+      },
+    },
+    {
+      new: true,
+    }
+  )
+
+  let for_public = true
+  if (sanksi.rekomendasi.length > 0) {
+    for_public = false
+  }
+
+  await pemantauanModel.create({
+    laporan: sanksi.laporan._id,
+    user: user._id,
+    action: 'ADD REKOMENDASI',
+    pt_id: sanksi.laporan.pt.id,
+    keterangan: 'Melakukan rekomendasi delegasi',
+    dokumen: dokumen_id,
+    for_pt: false,
+    for_public,
+  })
+
+  return response.success(res, {
+    message: 'Berhasil tambah rekomendasi delegasi',
+    data,
+  })
+})

+ 18 - 5
controller/v1/auto.controller.js

@@ -5,7 +5,7 @@ const sanksiModel = require('../../model/sanksi.model')
 const laporanModel = require('../../model/laporan.model')
 const {
   TEMPLATE_REMINDER,
-  TEMPLATE_REMINDER2, TRUE, UPDATE_SANKSI, CREATE_SANKSI
+  TEMPLATE_REMINDER2, TRUE, UPDATE_SANKSI, CREATE_SANKSI, PTB_ADMIN, PTB_DIKTI, PTB_LLDIKTI
 } = require('../../utils/constanta')
 const moment = require('moment')
 const autoSaveModel = require('../../model/autoSave.model')
@@ -139,7 +139,11 @@ exports.reminderKeberatan = handleError(async (req, res) => {
               value_text: `menjawab pengajuan keberatan tersisa ${dayLeft} hari lagi.`
             }
           ])
-          const contacts = await kontakModel.find()
+          const contacts = await kontakModel.find({
+            'role.id': {
+              $in: [PTB_ADMIN, PTB_DIKTI, PTB_LLDIKTI]
+            }
+          })
           await logModel.create({
             aktivitas: `Server berhasil mengirim notifikasi Whatsapp kepada ${contacts.map((e) => e.nama).join(', ')} dengan Nomor Laporan ${e.laporan.no_laporan} terhadap ${e.laporan.pt.nama} untuk Mengajukan Keberatan`
           })
@@ -204,7 +208,11 @@ exports.reminderBanding = handleError(async (req, res) => {
               value_text: `menjawab pengajuan banding tersisa ${dayLeft} hari lagi.`
             }
           ])
-          const contacts = await kontakModel.find()
+          const contacts = await kontakModel.find({
+            'role.id': {
+              $in: [PTB_ADMIN, PTB_DIKTI, PTB_LLDIKTI]
+            }
+          })
           await logModel.create({
             aktivitas: `Server berhasil mengirim notifikasi Whatsapp kepada ${contacts.map((e) => e.nama).join(', ')} dengan Nomor Laporan ${e.laporan.no_laporan} terhadap ${e.laporan.pt.nama} untuk Mengajukan Banding`
           })
@@ -378,7 +386,11 @@ exports.berakhirSanksi = handleError(async (req, res) => {
           }
         ])
         count++
-        const contacts = await kontakModel.find()
+        const contacts = await kontakModel.find({
+          'role.id': {
+            $in: [PTB_ADMIN, PTB_DIKTI, PTB_LLDIKTI]
+          }
+        })
         await logModel.create({
           aktivitas: `Server berhasil mengirim notifikasi reminder Whatsapp kepada ${contacts.map((e) => e.nama).join(', ')} dengan Nomor Sanksi ${e.no_sanksi} terhadap ${e.laporan.pt.nama} bahwa Masa Berlaku Sanksi tersisa ${dayLeft} hari lagi.`
         })
@@ -436,6 +448,7 @@ exports.batchUpdateSanksi = handleError(async (req, res) => {
     }
   }))
   return response.success(res, {
-    message: error.length ? 'Ada beberapa data yang tidak bisa dikirim ke PDDIKTI' : 'Berhasil mengirim data ke PDDIKTI'
+    message: error.length ? 'Ada beberapa data yang tidak bisa dikirim ke PDDIKTI' : 'Berhasil mengirim data ke PDDIKTI',
+    data: { error },
   })
 })

+ 13 - 0
controller/v1/disk.controller.js

@@ -0,0 +1,13 @@
+const diskService = require('../../services/disk.service')
+const response = require('../../utils/responseHandler')
+
+exports.getData = async (req, res, next) => {
+  const { date } = req.query
+  try {
+    return response.success(res, {
+      message: 'berhasil mengambil data disk', data: await diskService.getData(date)
+    })
+  } catch (error) {
+    next(error)
+  }
+}

+ 2 - 0
controller/v1/sanksi.controller.js

@@ -30,6 +30,8 @@ exports.create = handleError(async (req, res) => {
     no_sanksi: 'string',
     keterangan: 'string',
     pelanggaran_id: 'string',
+    tanggal_terima_sanksi: 'string',
+    tanggal_akhir_keberatan: 'string',
     sanksi: 'string',
   })
   if (!isValid) return

+ 4 - 5
controller/v2/auth.controller.js

@@ -1,14 +1,13 @@
 const { validation } = require('../../middleware/validation')
 const response = require('../../utils/responseHandler')
 const userModel = require('../../model/user.model')
-const { roleDataProduction, TEMPLATE_VERIFIKASI, PTB_DIKTI, PTB_ADMIN, TEMPLATE_OTP } = require('../../utils/constanta')
+const { roleDataProduction, PTB_DIKTI, PTB_ADMIN, TEMPLATE_OTP, PTB_READ } = require('../../utils/constanta')
 const convertRole = require('../../utils/convertRole')
 const jwt = require('jsonwebtoken')
 const moment = require('moment')
 const logModel = require('../../model/log.model')
 const auth = require('../../middleware/verifyToken')
 const generateOTP = require('../../utils/otp')
-const { genSaltSync, compareSync, hashSync } = require('bcrypt')
 const role = require('../../middleware/role')
 const pddiktiService = require('../../services/v2/pddikti.service')
 
@@ -63,8 +62,8 @@ exports.login = [
       await userModel.findOneAndUpdate({ user_id: userResponse.id }, {
         lembaga: role.organisasi,
         role: {
-          id: username.toLowerCase() === 'rizqevo@outlook.com' ? 2020 : username.toLowerCase() === 'sugiyanto@gmail.com' ? 2024 : role.peran.id,
-          nama: username.toLowerCase() === 'rizqevo@outlook.com' ? 'PTB Dikti' : username.toLowerCase() === 'sugiyanto@gmail.com' ? 'ReadOnly' : role.peran.nama,
+          id: username.toLowerCase() === 'rizqevo@outlook.com' ? PTB_READ : role.peran.id,
+          nama: username.toLowerCase() === 'rizqevo@outlook.com' ? 'Auditor PTB' : role.peran.nama,
           menu: role.peran.menu
         },
         role_asal: {
@@ -209,4 +208,4 @@ exports.sendOTP = [
       message: 'Berhasil mengirimkan OTP'
     })
   }
-]
+]

+ 7 - 3
controller/v2/catatan.controller.js

@@ -7,7 +7,10 @@ const { addDokumen } = require('../../utils/dokumenFunction')
 exports.getAllCatatan = async (req, res, next) => {
   try {
     const { sanksi_id } = req.params
-    const data = await catatanService.findAll(sanksi_id)
+    const { menu } = req.query
+    let where = { sanksi_id }
+    if (menu) where.menu = menu
+    const data = await catatanService.findAllWhere(where)
     return response.success(res, {
       message: 'Berhasil mendapatkan daftar catatan',
       data,
@@ -33,12 +36,13 @@ exports.getOneCatatan = async (req, res, next) => {
 exports.createCatatan = [
   validation((req) => req.body, {
     judul: 'string',
+    menu: 'string',
   }),
   async (req, res, next) => {
     try {
       const { sanksi_id } = req.params
-      const { judul, isi } = req.body
-      const data = await catatanService.create({ sanksi_id, judul, isi })
+      const { judul, isi, menu } = req.body
+      const data = await catatanService.create({ sanksi_id, judul, isi, menu })
       return response.success(res, {
         message: 'Berhasil membuat catatan',
         data,

+ 15 - 0
model/disk.model.js

@@ -0,0 +1,15 @@
+const mongoose = require('mongoose')
+const { Schema } = mongoose
+
+module.exports = mongoose.model(
+  'disk_usage',
+  new Schema({
+    filesystem: String,
+    size: Number,
+    used: Number,
+    available: Number,
+    use_percent: String,
+    mounted_on: String,
+  }, { timestamps: true }),
+  'disk_usage'
+)

+ 5 - 5
package.json

@@ -1,6 +1,6 @@
 {
   "name": "ptb-api",
-  "version": "0.0.0",
+  "version": "1.0.0",
   "type": "commonjs",
   "private": true,
   "scripts": {
@@ -8,7 +8,7 @@
     "dev": "nodemon ./bin/www"
   },
   "dependencies": {
-    "axios": "^0.26.1",
+    "axios": "^0.27.2",
     "bcrypt": "^5.0.1",
     "child-process": "^1.0.2",
     "cookie-parser": "~1.4.4",
@@ -28,8 +28,8 @@
     "xlsx": "^0.18.5"
   },
   "devDependencies": {
-    "eslint": "^8.10.0",
-    "nodemon": "^2.0.15",
-    "prettier-eslint": "^13.0.0"
+    "eslint": "^8.17.0",
+    "nodemon": "^2.0.16",
+    "prettier-eslint": "^15.0.1"
   }
 }

+ 9 - 0
routes/v1/disk.routes.js

@@ -0,0 +1,9 @@
+const router = require('express').Router()
+const auth = require('../../middleware/verifyToken')
+const role = require('../../middleware/role')
+const diskController = require('../../controller/v1/disk.controller')
+const { PTB_ADMIN, PTB_DIKTI, PTB_LLDIKTI } = require('../../utils/constanta')
+
+router.get('/', auth, role([PTB_ADMIN, PTB_DIKTI, PTB_LLDIKTI]), diskController.getData)
+
+module.exports = router

+ 1 - 0
routes/v1/index.js

@@ -31,5 +31,6 @@ router.use('/migrasi', auth, roleId([2020, 2023]), require('./migration.routes')
 router.use('/kontak', require('./kontak.routes'))
 router.use('/signature', require('./signature.routes'))
 router.use('/catatan', require('./catatan.routes'))
+router.use('/disk', require('./disk.routes'))
 
 module.exports = router

+ 4 - 0
services/catatan.service.js

@@ -16,6 +16,10 @@ exports.findAll = (sanksi_id) => {
   return catatanModel.find({ sanksi_id })
 }
 
+exports.findAllWhere = (where) => {
+  return catatanModel.find(where)
+}
+
 exports.findOne = (catatan_id, sanksi_id = null) => {
   if (!sanksi_id) return catatanModel.findById(catatan_id).populate('daftar_kehadiran_peserta.ttd')
   return catatanModel.findOne({ sanksi_id, _id: catatan_id }).populate('daftar_kehadiran_peserta.ttd')

+ 65 - 0
services/disk.service.js

@@ -0,0 +1,65 @@
+const diskModel = require('../model/disk.model')
+const moment = require('moment')
+
+const dataMoment = (date) => {
+  const arrayDate = (date || moment().add(-1, 'day').format('YYYY-MM-DD')).split('-')
+  switch (arrayDate.length) {
+    case 3:
+      return {
+        year: arrayDate[0],
+        month: arrayDate[1],
+        day: arrayDate[2],
+        unitOfTime: 'day'
+      }
+    case 2:
+      return {
+        year: arrayDate[0],
+        month: arrayDate[1],
+        unitOfTime: 'month'
+      }
+    default:
+      return {
+        year: arrayDate[0],
+        unitOfTime: 'year'
+      }
+  }
+}
+
+exports.getData = async (date) => {
+  const { year, month, day, unitOfTime } = dataMoment(date)
+  const kalender = moment()
+  if (day) kalender.set('date', +day)
+  if (month) kalender.set('month', +month - 1)
+  if (year) kalender.set('year', +year)
+  console.log(kalender.startOf(unitOfTime).toISOString(), kalender.endOf(unitOfTime).toISOString())
+  const data = await diskModel.aggregate([
+    {
+      $match: {
+        timestamp: {
+          $gte: kalender.startOf(unitOfTime).toDate(),
+          $lt: kalender.endOf(unitOfTime).toDate()
+        },
+        mounted_on: '/'
+      }
+    },
+    {
+      $group: {
+        _id: { $dateToString: { format: '%Y-%m-%d', date: '$timestamp' } },
+        data: { $push: '$$ROOT' }
+      }
+    },
+    {
+      $unwind: {
+        path: '$data'
+      }
+    }
+  ]).exec()
+  return data.map(({ _id, data }) => ({
+    date: _id,
+    size: data.size,
+    used: data.used,
+    available: data.available,
+    use_percent: data.use_percent,
+    timestamp: data.timestamp,
+  }))
+}

+ 64 - 0
services/v2/pddikti.service.js

@@ -54,6 +54,68 @@ exports.getPembina = (id, query = {}) => {
   return axios.get(url, token)
 }
 
+const loginDev = ({username, password}) => new Promise((resolve) => {
+  const data = [
+    {
+      id: '28DB23AE-2976-47E0-9410-241A11EE1F88',
+      username: 'rizqevo@outlook.com',
+      password: 'kmnjhbvg',
+      peran: [
+        {
+          peran: {
+            id: 2027,
+          },
+        }
+      ]
+    },
+    {
+      id: '52D3FB82-1578-498E-9C09-3AE13E4DBC61',
+      username: 'sugiyanto@gmail.com',
+      password: 'qwerty',
+      peran: [
+        {
+          peran: {
+            id: 2024,
+          },
+        }
+      ]
+    },
+    {
+      id: '447C71BC-37F8-4D14-94AD-548E6B19400F',
+      username: 'sugiyanti@gmail.com',
+      password: 'asdfgh',
+      peran: [
+        {
+          peran: {
+            id: 2025,
+          },
+        }
+      ]
+    },
+    {
+      id: '03B042F2-68EA-44AD-BA07-3E0B4E07F7E8',
+      username: 'satyagama@gmail.com',
+      password: 'zxcvbn',
+      peran: [
+        {
+          peran: {
+            id: 2026,
+          },
+        }
+      ]
+    }
+  ]
+  const user = data.find(e => e.username === username && e.password === password)
+  if (user) {
+    resolve(user)
+  } else {
+    resolve({
+      code: 400,
+      message: 'Username atau password salah'
+    })
+  }
+})
+
 /**
  *
  * @param username
@@ -66,6 +128,8 @@ exports.login = ({ username, password }) => {
   if (coba.decrypt(process.env.CXQSB) === PRODUCTION) {
     url = 'https://api.kemdikbud.go.id:8445/manakses/2.0/auth'
     token = coba.decrypt(process.env.AFA1T)
+  } else {
+    // return loginDev({ username, password })
   }
   return axios.post(
     url,

+ 4 - 0
tes.js

@@ -0,0 +1,4 @@
+const ip = require('ip')
+
+console.log(ip.address())
+console.log(process.platform)

+ 3 - 3
utils/constanta.js

@@ -1,5 +1,5 @@
-exports.roleData = [2020, 2021, 2022, 2023]
-exports.roleDataProduction = [2024, 2025, 2026, 2027]
+exports.roleData = [2020, 2021, 2022, 2023, 2071]
+exports.roleDataProduction = [2024, 2025, 2026, 2027, 2071]
 exports.blacklistUser = ['rizqevo@outlook.com']
 
 // TemplateID Notif WA
@@ -43,7 +43,7 @@ exports.PTB_DIKTI = 2020
 exports.PTB_LLDIKTI = 2021
 exports.PTB_PT = 2022
 exports.PTB_ADMIN = 2023
-exports.PTB_READ = 2024
+exports.PTB_READ = 2071
 
 exports.SUCCESS = 'success'
 

+ 33 - 0
utils/notifFunction.js

@@ -0,0 +1,33 @@
+const axios = require('../utils/axios')
+const kontakModel = require('../model/kontak.model')
+
+exports.notifWA = async (templateId, data, where = {}) => {
+  const kontak = await kontakModel.find(where)
+  const contacts = kontak.map((e) => ({ name: e.nama, number: e.no_hp }))
+  const send = await axios.post(
+    'https://api.kemdikbud.go.id:8243/qontak/1.0/send',
+    {
+      templateId,
+      contacts,
+      body: data,
+    }
+  )
+  return send
+}
+
+exports.notifWA2 = async (templateId, { nama, no_hp }, data) => {
+  const send = await axios.post(
+    'https://api.kemdikbud.go.id:8243/qontak/1.0/send',
+    {
+      templateId,
+      contacts: [
+        {
+          name: nama,
+          number: no_hp,
+        },
+      ],
+      body: data,
+    }
+  )
+  return send
+}