<template>
  <Filters
    @run-report="() => exportToPDF(reportMeta, data, true)"
    @reset-form="data = []"
    @run-search="() => filterData(filters)"
    :report-button="true"
    class="mb-4"
  >
    <Type2 @update:filters="(value) => (filters = value)" />
  </Filters>

  <div id="data">
    <DxDataGrid
      ref="dataGridRef"
      :allow-column-reordering="true"
      class="max-h-[calc(100vh-140px)] mb-10"
      :data-source="data"
      v-if="loadingData == false"
      :show-column-lines="true"
      :show-row-lines="false"
      :show-borders="true"
      :row-alternation-enabled="true"
      :hover-state-enabled="true"
      @selection-changed="onDataSelectionChanged"
      @exporting="onExporting"
      :allow-column-resizing="true"
      column-resizing-mode="widget"
      :word-wrap-enabled="true"
    >
      <DxGrouping :context-menu-enabled="true" expand-mode="rowClick" :auto-expand-all="false" />
      <DxSelection mode="single" />
      <DxPaging :enabled="false" />
      <DxScrolling column-rendering-mode="virtual" mode="virtual" />

      <DxSearchPanel :visible="true" :highlight-case-sensitive="true" />
      <DxExport
        :enabled="true"
        :formats="['pdf', 'xlsx', 'document']"
        :allow-export-selected-data="false"
      />
      <DxColumnFixing :enabled="true" />

      <DxColumn
        alignment="center"
        data-field="nama_ulp"
        caption="Nama Unit"
        css-class="custom-table-column"
        cell-template="formatText"
      />
      <DxColumn
        v-if="grouping.length > 0"
        v-for="(group, index) in grouping"
        :width="150"
        alignment="center"
        :data-field="group.data"
        :caption="group.caption"
        css-class="custom-table-column"
        cell-template="formatText"
        :group-index="index"
      />
      <DxColumn alignment="center" caption="Lapor Ulang Gangguan" css-class="custom-table-column">
        <DxColumn alignment="center" caption="MoM" css-class="custom-table-column">
          <DxColumn
            :width="150"
            alignment="center"
            data-field="mom_bulan_kemarin"
            data-type="number"
            :caption="`${getMonthName(lastMonth)} ${lastYearMoM}`"
            css-class="custom-table-column"
            cell-template="formatNumber"
          />
          <DxColumn
            :width="150"
            alignment="center"
            data-field="mom_bulan_ini"
            data-type="number"
            :caption="`${getMonthName(currentMonth)} ${currentYear}`"
            css-class="custom-table-column"
            cell-template="formatNumber"
          />
          <DxColumn
            :width="70"
            alignment="center"
            data-field="persen_mom"
            data-type="number"
            caption="%"
            css-class="custom-table-column"
            cell-template="formatNumber"
          />
        </DxColumn>
        <DxColumn alignment="center" caption="YoY" css-class="custom-table-column">
          <DxColumn
            :width="150"
            alignment="center"
            data-field="yoy_tahun_kemarin"
            data-type="number"
            :caption="`s.d ${getMonthName(currentMonth)} ${lastYear}`"
            css-class="custom-table-column"
            cell-template="formatNumber"
          />
          <DxColumn
            :width="150"
            alignment="center"
            data-field="yoy_tahun_ini"
            data-type="number"
            :caption="`s.d ${getMonthName(currentMonth)} ${currentYear}`"
            css-class="custom-table-column"
            cell-template="formatNumber"
          />
          <DxColumn
            :width="70"
            alignment="center"
            data-field="persen_yoy"
            data-type="number"
            caption="%"
            css-class="custom-table-column"
            cell-template="formatNumber"
          />
        </DxColumn>
      </DxColumn>

      <template #formatNumber="{ data }">
        <p class="text-right cursor-pointer">
          {{
            isNumber(data.text)
              ? data.column.caption == '%'
                ? formatPercentage(data.text)
                : formatNumber(data.text)
              : data.text
          }}
        </p>
      </template>

      <template #formatText="{ data }">
        <p class="!text-left cursor-pointer">
          {{ data.text }}
        </p>
      </template>

      <DxSummary :calculate-custom-summary="calculateCustomSummary">
        <DxGroupItem
          :align-by-column="true"
          column="mom_bulan_kemarin"
          name="mom_bulan_kemarin"
          summary-type="custom"
          display-format="{0}"
          css-class="!text-right"
          :customize-text="(e: any) => formatNumber(e.value)"
        />
        <DxGroupItem
          :align-by-column="true"
          column="mom_bulan_ini"
          name="mom_bulan_ini"
          summary-type="custom"
          display-format="{0}"
          css-class="!text-right"
          :customize-text="(e: any) => formatNumber(e.value)"
        />
        <DxGroupItem
          :align-by-column="true"
          column="persen_mom"
          name="persen_mom"
          summary-type="custom"
          display-format="{0}"
          css-class="!text-right"
          :customize-text="(e: any) => formatPercentage(e.value)"
        />
        <DxGroupItem
          :align-by-column="true"
          column="yoy_tahun_kemarin"
          name="yoy_tahun_kemarin"
          summary-type="custom"
          display-format="{0}"
          css-class="!text-right"
          :customize-text="(e: any) => formatNumber(e.value)"
        />
        <DxGroupItem
          :align-by-column="true"
          column="yoy_tahun_ini"
          name="yoy_tahun_ini"
          summary-type="custom"
          display-format="{0}"
          css-class="!text-right"
          :customize-text="(e: any) => formatNumber(e.value)"
        />
        <DxGroupItem
          :align-by-column="true"
          column="persen_yoy"
          name="persen_yoy"
          summary-type="custom"
          display-format="{0}"
          css-class="!text-right"
          :customize-text="(e: any) => formatPercentage(e.value)"
        />

        <DxTotalItem
          display-format="Total"
          show-in-column="nama_ulp"
          css-class="text-white !text-left"
        />
        <DxTotalItem
          column="mom_bulan_kemarin"
          name="mom_bulan_kemarin"
          summary-type="custom"
          display-format="{0}"
          css-class="text-white !text-right"
          :customize-text="(e: any) => formatNumber(e.value)"
        />
        <DxTotalItem
          column="mom_bulan_ini"
          name="mom_bulan_ini"
          summary-type="custom"
          display-format="{0}"
          css-class="text-white !text-right"
          :customize-text="(e: any) => formatNumber(e.value)"
        />
        <DxTotalItem
          column="persen_mom"
          name="persen_mom"
          summary-type="custom"
          display-format="{0}"
          css-class="text-white !text-right"
          :customize-text="(e: any) => formatPercentage(e.value)"
        />
        <DxTotalItem
          column="yoy_tahun_kemarin"
          name="yoy_tahun_kemarin"
          summary-type="custom"
          display-format="{0}"
          css-class="text-white !text-right"
          :customize-text="(e: any) => formatNumber(e.value)"
        />
        <DxTotalItem
          column="yoy_tahun_ini"
          name="yoy_tahun_ini"
          summary-type="custom"
          display-format="{0}"
          css-class="text-white !text-right"
          :customize-text="(e: any) => formatNumber(e.value)"
        />
        <DxTotalItem
          column="persen_yoy"
          name="persen_yoy"
          summary-type="custom"
          display-format="{0}"
          css-class="text-white !text-right"
          :customize-text="(e: any) => formatPercentage(e.value)"
        />
      </DxSummary>
    </DxDataGrid>
  </div>
  <BufferDialog v-if="loadingData || loadingSubData" />
</template>

<script setup lang="ts">
import Filters from '@/components/Form/Filters.vue'
import Type2 from '@/components/Form/FiltersType/Type2.vue'
import { onMounted, ref } from 'vue'
import { DxDataGrid } from 'devextreme-vue'
import {
  DxColumn,
  DxColumnFixing,
  DxExport,
  DxGroupItem,
  DxGrouping,
  DxPaging,
  DxScrolling,
  DxSearchPanel,
  DxSelection,
  DxSummary,
  DxTotalItem
} from 'devextreme-vue/data-grid'
import { getMonthName } from '@/utils/texts'
import { queries, requestGraphQl } from '@/utils/api/api.graphql'
import { formatNumber, formatPercentage, isNumber } from '@/utils/numbers'
import { apolloClient } from '@/utils/api/api.graphql'
import { provideApolloClient } from '@vue/apollo-composable'
import BufferDialog from '@/components/Dialogs/BufferDialog.vue'
import {
  exportToPDF,
  exportToXLSX,
  exportToDOCX
} from '@/report/Monalisa/Gangguan/Rekap/MonalisaGR_LaporUlang'

const client = apolloClient()
provideApolloClient(client)
const lastMonth = ref(new Date().getMonth() == 1 ? 12 : new Date().getMonth() - 1)
const lastYearMoM = ref(
  new Date().getMonth() == 1 ? new Date().getFullYear() - 1 : new Date().getFullYear()
)
const currentYear = ref(new Date().getFullYear())
const currentMonth = ref(new Date().getMonth())
const lastYear = ref(currentYear.value - 1)
const position = { of: '#data' }
const showIndicator = ref(true)
const shading = ref(true)
const showPane = ref(true)
const data = ref<any[]>([])
const dataSub = ref<any[]>([])
const dataSelected = ref<any>()
const dataSubSelected = ref<any>()
const dialogDetail = ref(false)
const closedialogDetail = () => (dialogDetail.value = false)
const loadingData = ref(false)
const loadingSubData = ref(false)
const reportMeta = ref({
  regional: { id: 0, name: 'Semua Regional' },
  uid: { id: 0, name: 'Semua Unit Induk Distribusi/Wilayah' },
  up3: { id: 0, name: 'Semua Unit Pelaksanaan Pelayanan Pelanggan' },
  ulp: { id: 0, name: 'Semua Unit Layanan Pelanggan' },
  bulan: { id: new Date().getMonth(), name: getMonthName(new Date().getMonth()) },
  tahun: { id: new Date().getFullYear(), name: new Date().getFullYear().toString() },
  periode: '',
  lastMonth: new Date().getMonth() == 1 ? 12 : new Date().getMonth() - 1,
  lastYearMoM: new Date().getMonth() == 1 ? new Date().getFullYear() - 1 : new Date().getFullYear(),
  currentMonth: new Date().getMonth(),
  currentYear: new Date().getFullYear(),
  lastYear: new Date().getFullYear() - 1
})

const grouping = ref<any[]>([
  {
    data: 'nama_regional',
    caption: 'Regional'
  },
  {
    data: 'nama_uid',
    caption: 'UID'
  },
  {
    data: 'nama_up3',
    caption: 'UP3'
  }
])

let mom_bulan_kemarin = 0
let mom_bulan_ini = 0
let yoy_tahun_kemarin = 0
let yoy_tahun_ini = 0
const calculateCustomSummary = (options: any) => {
  if (options.name === 'mom_bulan_kemarin') {
    if (options.summaryProcess === 'calculate') {
      mom_bulan_kemarin += options.value
    } else if (options.summaryProcess === 'finalize') {
      options.totalValue = mom_bulan_kemarin
    }
  }

  if (options.name === 'mom_bulan_ini') {
    if (options.summaryProcess === 'calculate') {
      mom_bulan_ini += options.value
    } else if (options.summaryProcess === 'finalize') {
      options.totalValue = mom_bulan_ini
    }
  }

  if (options.name === 'persen_mom') {
    if (options.summaryProcess === 'start') {
      mom_bulan_kemarin = 0
      mom_bulan_ini = 0
    } else if (options.summaryProcess === 'finalize') {
      options.totalValue =
        mom_bulan_kemarin == 0 ? 0 : ((mom_bulan_kemarin - mom_bulan_ini) / mom_bulan_kemarin) * 100
    }
  }

  if (options.name === 'yoy_tahun_kemarin') {
    if (options.summaryProcess === 'calculate') {
      yoy_tahun_kemarin += options.value
    } else if (options.summaryProcess === 'finalize') {
      options.totalValue = yoy_tahun_kemarin
    }
  }

  if (options.name === 'yoy_tahun_ini') {
    if (options.summaryProcess === 'calculate') {
      yoy_tahun_ini += options.value
    } else if (options.summaryProcess === 'finalize') {
      options.totalValue = yoy_tahun_ini
    }
  }

  if (options.name === 'persen_yoy') {
    if (options.summaryProcess === 'start') {
      yoy_tahun_kemarin = 0
      yoy_tahun_ini = 0
    } else if (options.summaryProcess === 'finalize') {
      options.totalValue =
        yoy_tahun_kemarin == 0 ? 0 : ((yoy_tahun_kemarin - yoy_tahun_ini) / yoy_tahun_kemarin) * 100
    }
  }
}

const resetData = () => {
  data.value = []
  dataSub.value = []
}

const filterData = async (params: any) => {
  resetData()
  const { regional, ulp, uid, up3, bulan, tahun } = params
  lastMonth.value = bulan.id == 1 ? 12 : bulan.id - 1
  lastYearMoM.value = bulan.id == 1 ? tahun.id - 1 : tahun.id
  currentMonth.value = bulan.id
  currentYear.value = tahun.id
  lastYear.value = tahun.id - 1

  var groupList: any[] = [
    {
      data: 'nama_regional',
      caption: 'Regional'
    },
    {
      data: 'nama_uid',
      caption: 'UID'
    },
    {
      data: 'nama_up3',
      caption: 'UP3'
    }
  ]

  if (uid?.id != 0) {
    groupList.forEach((item, index) => {
      if (item.caption == 'Regional') {
        groupList.splice(index, 1)
      }
    })

    if (up3?.id != 0) {
      groupList.forEach((item, index) => {
        if (item.caption == 'UID') {
          groupList.splice(index, 1)
        }
      })

      if (ulp?.id != 0) {
        groupList.forEach((item, index) => {
          if (item.caption == 'UP3') {
            groupList.splice(index, 1)
          }
        })
      }
    }
  }
  grouping.value = groupList

  const query = {
    namaRegional: regional.name == 'Semua Regional' ? '' : regional.name,
    idUlp: ulp ? ulp.id : 0,
    idUid: uid ? uid.id : 0,
    idUp3: up3 ? up3.id : 0,
    bulan: bulan ? bulan.id : 10,
    tahun: bulan ? tahun.id : 2023
  }

  loadingData.value = true
  await requestGraphQl(queries.monalisa.gangguan.rekap.laporUlangGangguan, query)
    .then((result) => {
      if (result.data.data != undefined) {
        data.value = result.data.data.monalisaRekapitulasiLaporUlangGangguan
      } else {
        data.value = []
      }

      reportMeta.value = {
        regional: regional,
        uid: uid,
        up3: up3,
        ulp: ulp,
        bulan: bulan,
        tahun: tahun,
        periode: `${bulan.name} ${tahun.name}`,
        lastMonth: lastMonth.value,
        lastYearMoM: lastYearMoM.value,
        currentMonth: currentMonth.value,
        currentYear: currentYear.value,
        lastYear: lastYear.value
      }
    })
    .catch((err) => {
      console.error(err)
    })
    .finally(() => {
      loadingData.value = false
    })
}
const onExporting = (e: any) => {
  if (e.format === 'pdf') {
    exportToPDF(reportMeta.value, data.value)
  } else if (e.format === 'xlsx') {
    exportToXLSX(reportMeta.value, e)
  } else {
    exportToDOCX(reportMeta.value, data.value)
  }
}
const getDetail = async () => {
  const dateValue = filters.value.periode.split(' s/d ')
  const selected = dataSelected.value

  const query = {
    dateFrom: dateValue[0]
      ? dateValue[0].split('-').reverse().join('-')
      : new Date().toISOString().slice(0, 10),
    dateTo: dateValue[1]
      ? dateValue[1].split('-').reverse().join('-')
      : new Date().toISOString().slice(0, 10),
    idUlp: selected?.id_ulp ? selected?.id_ulp : 0,
    idUid: selected?.id_uid ? selected?.id_uid : 0,
    idUp3: selected?.id_up3 ? selected?.id_up3 : 0,
    namaRegional: selected?.nama_regional ? selected?.nama_regional : '',
    isSelesai: 0,
    media: '',
    tanggal: '',
    namaIssuetype: '',
    namaSubissuetype: ''
  }

  loadingSubData.value = true
  await requestGraphQl(queries.keluhan.rekap.rekapKeluhanAllDetail, query)
    .then((result) => {
      if (result.data.data != undefined) {
        dataSub.value = result.data.data.detailKeluhanAll
      } else {
        dataSub.value = []
      }
    })
    .catch((err) => {
      console.error(err)
    })
    .finally(() => {
      loadingSubData.value = false
      dialogDetail.value = true
    })
}

const dataGridRef = ref<DxDataGrid | null>(null)
const clearSelection = () => {
  const dataGrid = dataGridRef.value!.instance!
  dataGrid.clearSelection()
}
const showDetail = () => {
  clearSelection()
  dataSubSelected.value = null
  getDetail()
}

const onDataSelectionChanged = ({ selectedRowsData }: any) => {
  if (selectedRowsData[0] != undefined) {
    dataSelected.value = selectedRowsData[0]
    showDetail()
  }
}

const onDataSubSelectionChanged = ({ selectedRowsData }: any) => {
  const data = selectedRowsData[0]
  dataSubSelected.value = data
}

const filters = ref()
onMounted(() => {
  if (import.meta.env.DEV) {
    data.value = [
      {
        id: 0,
        nama_regional: null,
        id_uid: 0,
        nama_uid: '',
        id_up3: 0,
        nama_up3: '',
        id_ulp: 0,
        nama_ulp: '',
        mom_bulan_ini: 14,
        mom_bulan_kemarin: 35,
        persen_mom: 60,
        yoy_tahun_ini: 254,
        yoy_tahun_kemarin: 344,
        persen_yoy: 26.16279069767442
      },
      {
        id: 1,
        nama_regional: 'REGIONAL JMB',
        id_uid: 103,
        nama_uid: 'DISTRIBUSI JAWA TIMUR',
        id_up3: 154,
        nama_up3: 'UP3 SITUBONDO',
        id_ulp: 51654,
        nama_ulp: 'ULP WONOSARI',
        mom_bulan_ini: 1,
        mom_bulan_kemarin: 5,
        persen_mom: 80,
        yoy_tahun_ini: 4,
        yoy_tahun_kemarin: 16,
        persen_yoy: 75
      },
      {
        id: 2,
        nama_regional: 'REGIONAL JMB',
        id_uid: 103,
        nama_uid: 'DISTRIBUSI JAWA TIMUR',
        id_up3: 157,
        nama_up3: 'UP3 SURABAYA UTARA',
        id_ulp: 51101,
        nama_ulp: 'ULP INDRAPURA',
        mom_bulan_ini: 1,
        mom_bulan_kemarin: 2,
        persen_mom: 50,
        yoy_tahun_ini: 7,
        yoy_tahun_kemarin: 22,
        persen_yoy: 68.18181818181817
      },
      {
        id: 3,
        nama_regional: 'REGIONAL SUMKAL',
        id_uid: 131,
        nama_uid: 'WILAYAH SUMATERA BARAT',
        id_up3: 13100,
        nama_up3: 'UP3 PADANG',
        id_ulp: 13105,
        nama_ulp: 'ULP LUBUK ALUNG',
        mom_bulan_ini: 1,
        mom_bulan_kemarin: 1,
        persen_mom: 0,
        yoy_tahun_ini: 1,
        yoy_tahun_kemarin: 4,
        persen_yoy: 75
      },
      {
        id: 4,
        nama_regional: 'REGIONAL JMB',
        id_uid: 103,
        nama_uid: 'DISTRIBUSI JAWA TIMUR',
        id_up3: 153,
        nama_up3: 'UP3 SIDOARJO',
        id_ulp: 51182,
        nama_ulp: 'ULP PORONG',
        mom_bulan_ini: 5,
        mom_bulan_kemarin: 12,
        persen_mom: 58.333333333333336,
        yoy_tahun_ini: 22,
        yoy_tahun_kemarin: 57,
        persen_yoy: 61.40350877192983
      },
      {
        id: 5,
        nama_regional: 'REGIONAL SUMKAL',
        id_uid: 171,
        nama_uid: 'DISTRIBUSI LAMPUNG',
        id_up3: 17171,
        nama_up3: 'UP3 TANJUNGKARANG',
        id_ulp: 17180,
        nama_ulp: 'ULP TELUK BETUNG',
        mom_bulan_ini: 1,
        mom_bulan_kemarin: 5,
        persen_mom: 80,
        yoy_tahun_ini: 32,
        yoy_tahun_kemarin: 106,
        persen_yoy: 69.81132075471697
      },
      {
        id: 6,
        nama_regional: 'REGIONAL JMB',
        id_uid: 103,
        nama_uid: 'DISTRIBUSI JAWA TIMUR',
        id_up3: 146,
        nama_up3: 'UP3 KEDIRI',
        id_ulp: 51409,
        nama_ulp: 'ULP SUTOJAYAN',
        mom_bulan_ini: 1,
        mom_bulan_kemarin: 1,
        persen_mom: 0,
        yoy_tahun_ini: 1,
        yoy_tahun_kemarin: 20,
        persen_yoy: 95
      },
      {
        id: 7,
        nama_regional: 'REGIONAL JMB',
        id_uid: 427,
        nama_uid: 'DISTRIBUSI JAWA BARAT',
        id_up3: 531,
        nama_up3: 'UP3 BOGOR',
        id_ulp: 53821,
        nama_ulp: 'ULP BOGOR TIMUR',
        mom_bulan_ini: 8,
        mom_bulan_kemarin: 6,
        persen_mom: -33.33333333333333,
        yoy_tahun_ini: 69,
        yoy_tahun_kemarin: 102,
        persen_yoy: 32.35294117647059
      },
      {
        id: 8,
        nama_regional: 'REGIONAL SUMKAL',
        id_uid: 140,
        nama_uid: 'WILAYAH SUMATERA SELATAN, JAMBI & BENGKULU (S2JB)',
        id_up3: 1406,
        nama_up3: 'UP3 OGAN ILIR',
        id_ulp: 14910,
        nama_ulp: 'ULP KAYU AGUNG',
        mom_bulan_ini: 1,
        mom_bulan_kemarin: 6,
        persen_mom: 83.33333333333334,
        yoy_tahun_ini: 4,
        yoy_tahun_kemarin: 22,
        persen_yoy: 81.81818181818183
      },
      {
        id: 9,
        nama_regional: 'REGIONAL JMB',
        id_uid: 427,
        nama_uid: 'DISTRIBUSI JAWA BARAT',
        id_up3: 547,
        nama_up3: 'UP3 CIKARANG',
        id_ulp: 53701,
        nama_ulp: 'ULP TAMBUN',
        mom_bulan_ini: 4,
        mom_bulan_kemarin: 1,
        persen_mom: -300,
        yoy_tahun_ini: 14,
        yoy_tahun_kemarin: 8,
        persen_yoy: -75
      },
      {
        id: 10,
        nama_regional: 'REGIONAL JMB',
        id_uid: 427,
        nama_uid: 'DISTRIBUSI JAWA BARAT',
        id_up3: 539,
        nama_up3: 'UP3 GUNUNG PUTRI',
        id_ulp: 53865,
        nama_ulp: 'ULP CILEUNGSI',
        mom_bulan_ini: 8,
        mom_bulan_kemarin: 8,
        persen_mom: 0,
        yoy_tahun_ini: 60,
        yoy_tahun_kemarin: 75,
        persen_yoy: 20
      },
      {
        id: 11,
        nama_regional: 'REGIONAL SULMAPANA',
        id_uid: 44,
        nama_uid: 'WILAYAH NUSA TENGGARA BARAT',
        id_up3: 441,
        nama_up3: 'UP3 MATARAM',
        id_ulp: 44140,
        nama_ulp: 'ULP PRAYA',
        mom_bulan_ini: 4,
        mom_bulan_kemarin: 50,
        persen_mom: 92,
        yoy_tahun_ini: 30,
        yoy_tahun_kemarin: 263,
        persen_yoy: 88.59315589353612
      },
      {
        id: 12,
        nama_regional: 'REGIONAL JMB',
        id_uid: 103,
        nama_uid: 'DISTRIBUSI JAWA TIMUR',
        id_up3: 151,
        nama_up3: 'UP3 PASURUAN',
        id_ulp: 51356,
        nama_ulp: 'ULP PROBOLINGGO',
        mom_bulan_ini: 17,
        mom_bulan_kemarin: 48,
        persen_mom: 64.58333333333334,
        yoy_tahun_ini: 53,
        yoy_tahun_kemarin: 156,
        persen_yoy: 66.02564102564102
      },
      {
        id: 13,
        nama_regional: 'REGIONAL JMB',
        id_uid: 427,
        nama_uid: 'DISTRIBUSI JAWA BARAT',
        id_up3: 538,
        nama_up3: 'UP3 DEPOK',
        id_ulp: 53872,
        nama_ulp: 'ULP CIBINONG',
        mom_bulan_ini: 1,
        mom_bulan_kemarin: 3,
        persen_mom: 66.66666666666666,
        yoy_tahun_ini: 29,
        yoy_tahun_kemarin: 38,
        persen_yoy: 23.684210526315788
      },
      {
        id: 14,
        nama_regional: 'REGIONAL SUMKAL',
        id_uid: 120,
        nama_uid: 'WILAYAH SUMATERA UTARA',
        id_up3: 12128,
        nama_up3: 'UP3 MEDAN UTARA',
        id_ulp: 12801,
        nama_ulp: 'ULP MEDAN TIMUR',
        mom_bulan_ini: 3,
        mom_bulan_kemarin: 5,
        persen_mom: 40,
        yoy_tahun_ini: 13,
        yoy_tahun_kemarin: 119,
        persen_yoy: 89.07563025210085
      }
    ]
  }
})
</script>
