<template>
  <Filters
    :report-button="true"
    @reset-form="data = []"
    @run-search="() => filterData(filters)"
    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"
      :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 expand-mode="rowClick" />
      <DxSelection mode="single" />
      <DxPaging :enabled="false" />
      <DxScrolling column-rendering-mode="virtual" mode="virtual" />
      <DxLoadPanel
        shading-color="rgba(0,0,0,0.4)"
        :position="position"
        :show-indicator="showIndicator"
        :show-pane="showPane"
        :shading="shading"
        v-model:visible="loadingData"
        :enabled="true"
      />
      <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"
        :caption="`Periode: ${getMonthName(currentMonth)}, ${currentYear}`"
        css-class="custom-table-column"
      >
        <DxColumn
          alignment="center"
          :min-width="170"
          data-type="text"
          data-field="nama_regional"
          caption="Nama Regional"
          css-class="custom-table-column"
          :group-index="0"
        />
        <DxColumn
          alignment="center"
          :min-width="170"
          data-type="text"
          data-field="nama_uid"
          caption="Nama UID"
          css-class="custom-table-column"
          :group-index="1"
        />
        <DxColumn
          alignment="center"
          :min-width="170"
          data-type="text"
          data-field="nama_up3"
          caption="Nama UP3"
          css-class="custom-table-column"
          :group-index="2"
        />
        <DxColumn
          alignment="center"
          :min-width="170"
          data-type="text"
          data-field="na  ma_ulp"
          caption="Nama Unit"
          css-class="custom-table-column"
          name="namaULP"
          cell-template="formatText"
        />
      </DxColumn>
      <DxColumn alignment="center" caption="Aging Complains" css-class="custom-table-column">
        <DxColumn
          alignment="center"
          caption="Rata-Rata RCT Gangguan"
          css-class="custom-table-column"
        >
          <DxColumn
            :width="150"
            alignment="center"
            data-field="avg_durasi_recovery_gangguan"
            data-type="number"
            :caption="`${getMonthNameShort(currentMonth)} ${currentYear}`"
            css-class="custom-table-column"
            cell-template="formatNumber"
          />
          <DxColumn
            :width="150"
            alignment="center"
            data-field="sla_gangguan"
            data-type="number"
            caption="SLA (Menit)"
            css-class="custom-table-column"
            cell-template="formatNumber"
          />
        </DxColumn>
        <DxColumn
          alignment="center"
          caption="Rata-Rata RCT Keluhan"
          css-class="custom-table-column"
        >
          <DxColumn
            :width="150"
            alignment="center"
            data-field="avg_durasi_recovery_keluhan"
            data-type="number"
            :caption="`${getMonthNameShort(currentMonth)} ${currentYear}`"
            css-class="custom-table-column"
            cell-template="formatNumber"
          />
          <DxColumn
            :width="150"
            alignment="center"
            data-field="sla_keluhan"
            data-type="number"
            caption="SLA (Jam)"
            css-class="custom-table-column"
            cell-template="formatNumber"
          />
        </DxColumn>
      </DxColumn>
      <DxColumn alignment="center" caption="% Aging Complains" css-class="custom-table-column">
        <DxColumn
          :width="150"
          alignment="center"
          data-field="aging_complaint_gangguan"
          data-type="number"
          caption="G"
          css-class="custom-table-column"
          cell-template="formatPercentage"
        />
        <DxColumn
          :width="150"
          alignment="center"
          data-field="aging_complaint_keluhan"
          data-type="number"
          caption="K"
          css-class="custom-table-column"
          cell-template="formatPercentage"
        />
      </DxColumn>
      <DxColumn
        :min-width="170"
        alignment="center"
        data-field="avg_aging_complaint"
        data-type="number"
        caption="% Rata-Rata Aging Complains"
        css-class="custom-table-column"
        cell-template="formatPercentage"
      />

      <DxSummary>
        <DxTotalItem
          summary-type="sum"
          display-format="RATA-RATA NASIONAL"
          show-in-column="nama_ulp"
          css-class="text-white !text-left"
        />
        <DxTotalItem
          column="avg_durasi_recovery_gangguan"
          summary-type="sum"
          display-format="{0}"
          css-class="text-white !text-right"
          :customize-text="(e: any) => formatNumber(e.value)"
        />
        <DxTotalItem
          column="sla_gangguan"
          summary-type="sum"
          display-format="{0}"
          css-class="text-white !text-right"
          :customize-text="(e: any) => formatNumber(e.value)"
        />
        <DxTotalItem
          column="avg_durasi_recovery_keluhan"
          summary-type="sum"
          display-format="{0}"
          css-class="text-white !text-right"
          :customize-text="(e: any) => formatNumber(e.value)"
        />
        <DxTotalItem
          column="sla_keluhan"
          summary-type="sum"
          display-format="{0}"
          css-class="text-white !text-right"
          :customize-text="(e: any) => formatNumber(e.value)"
        />
        <DxTotalItem
          column="aging_complaint_gangguan"
          summary-type="avg"
          display-format="{0}"
          css-class="text-white !text-right"
          :customize-text="(e: any) => (isNumber(e.value) ? formatPercentage(e.value) : '0%')"
        />
        <DxTotalItem
          column="aging_complaint_keluhan"
          summary-type="avg"
          display-format="{0}"
          css-class="text-white !text-right"
          :customize-text="(e: any) => (isNumber(e.value) ? formatPercentage(e.value) : '0%')"
        />
        <DxTotalItem
          column="avg_aging_complaint"
          summary-type="avg"
          display-format="{0}"
          css-class="text-white !text-right"
          :customize-text="(e: any) => (isNumber(e.value) ? formatPercentage(e.value) : '0%')"
        />

        <DxGroupItem
          css-class="!text-right"
          show-in-column="avg_durasi_recovery_gangguan"
          :show-in-group-footer="false"
          :align-by-column="true"
          column="avg_durasi_recovery_gangguan"
          summary-type="sum"
          display-format="{0}"
          :customize-text="(e: any) => formatNumber(e.value)"
        />
        <DxGroupItem
          css-class="!text-right"
          show-in-column="sla_gangguan"
          :show-in-group-footer="false"
          :align-by-column="true"
          column="sla_gangguan"
          summary-type="sum"
          display-format="{0}"
          :customize-text="(e: any) => formatNumber(e.value)"
        />
        <DxGroupItem
          css-class="!text-right"
          show-in-column="avg_durasi_recovery_keluhan"
          :show-in-group-footer="false"
          :align-by-column="true"
          column="avg_durasi_recovery_keluhan"
          summary-type="sum"
          display-format="{0}"
          :customize-text="(e: any) => formatNumber(e.value)"
        />
        <DxGroupItem
          css-class="!text-right"
          show-in-column="sla_keluhan"
          :show-in-group-footer="false"
          :align-by-column="true"
          column="sla_keluhan"
          summary-type="sum"
          display-format="{0}"
          :customize-text="(e: any) => formatNumber(e.value)"
        />
        <DxGroupItem
          css-class="!text-right"
          show-in-column="aging_complaint_gangguan"
          :show-in-group-footer="false"
          :align-by-column="true"
          column="aging_complaint_gangguan"
          summary-type="avg"
          display-format="{0}"
          :customize-text="
            (e: any) => (parseFloat(e.value.toString()) ? formatPercentage(e.value) : '0%')
          "
        />
        <DxGroupItem
          css-class="!text-right"
          show-in-column="aging_complaint_keluhan"
          :show-in-group-footer="false"
          :align-by-column="true"
          column="aging_complaint_keluhan"
          summary-type="avg"
          display-format="{0}"
          :customize-text="
            (e: any) => (parseFloat(e.value.toString()) ? formatPercentage(e.value) : '0%')
          "
        />
        <DxGroupItem
          css-class="!text-right"
          show-in-column="avg_aging_complaint"
          :show-in-group-footer="false"
          :align-by-column="true"
          column="avg_aging_complaint"
          summary-type="avg"
          display-format="{0}"
          :customize-text="
            (e: any) => (parseFloat(e.value.toString()) ? formatPercentage(e.value) : '0%')
          "
        />
      </DxSummary>

      <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 #formatPercentage="{ data }">
        <p class="text-right cursor-pointer">
          {{ parseFloat(data.text) ? formatPercentage(data.text) : '0%' }}
        </p>
      </template>

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

  <DetailDialog
    :open="dialogDetail"
    title="Detail (Monalisa) Aging Complaint"
    @on-close="closedialogDetail"
    :full-width="true"
  >
    <div class="w-full mb-4 lg:w-[70%] lg:float-left">
      <div class="p-4 bg-white rounded-xl lg:mr-4">
        <DxDataGrid
          :allow-column-reordering="true"
          class="max-h-[calc(100vh-140px)]"
          :data-source="dataSub"
          :show-column-lines="true"
          :show-row-lines="false"
          :show-borders="true"
          :row-alternation-enabled="true"
          :hover-state-enabled="true"
          @selection-changed="onDataSubSelectionChanged"
          :column-width="100"
          @exporting="onExporting"
          :allow-column-resizing="true"
          column-resizing-mode="widget"
        >
          <DxSelection mode="single" />
          <DxPaging :page-size="20" :enabled="true" />
          <DxPager
            :visible="true"
            :allowed-page-sizes="[20, 50, 100]"
            display-mode="full"
            :show-page-size-selector="true"
            :show-info="true"
            :show-navigation-buttons="true"
          />
          <DxLoadPanel
            shading-color="rgba(0,0,0,0.4)"
            :position="position"
            :show-indicator="showIndicator"
            :show-pane="showPane"
            :shading="shading"
            v-model:visible="loadingSubData"
            :enabled="true"
          />
          <DxSearchPanel :visible="true" :highlight-case-sensitive="true" />
          <DxExport
            :enabled="true"
            :formats="['pdf', 'xlsx', 'document']"
            :allow-export-selected-data="false"
          />

          <DxColumn
            css-class="custom-table-column"
            :width="50"
            alignment="center"
            :calculateCellValue="(item: any) => dataSub.findIndex((i) => i == item) + 1"
            data-type="number"
            caption="No"
            cell-template="formatNumber"
          />
          <DxColumn
            :width="150"
            alignment="center"
            data-field="no_laporan"
            caption="No Laporan"
            :allow-resizing="false"
            css-class="custom-table-column"
            cell-template="formatText"
          />
          <DxColumn
            :width="150"
            alignment="center"
            data-field=""
            caption="UID/UIW"
            :allow-resizing="false"
            css-class="custom-table-column"
            cell-template="formatText"
          />
          <DxColumn
            :width="150"
            alignment="center"
            data-field=""
            caption="UP3"
            :allow-resizing="false"
            css-class="custom-table-column"
            cell-template="formatText"
          />
          <DxColumn
            :width="150"
            alignment="center"
            data-field=""
            caption="ULP"
            :allow-resizing="false"
            css-class="custom-table-column"
            cell-template="formatText"
          />
          <DxColumn
            :width="150"
            alignment="center"
            data-field=""
            caption="ID Pelanggan"
            :allow-resizing="false"
            css-class="custom-table-column"
            cell-template="formatNumber"
          />
          <DxColumn
            :width="150"
            data-field=""
            caption="Nama Pelanggan"
            :allow-resizing="false"
            css-class="custom-table-column"
            cell-template="formatText"
          />
          <DxColumn
            :width="150"
            data-field=""
            caption="Nama Pelapor"
            :allow-resizing="false"
            css-class="custom-table-column"
            cell-template="formatText"
          />
          <DxColumn
            :width="150"
            data-field=""
            caption="Alamat Pelapor"
            :allow-resizing="false"
            css-class="custom-table-column"
            cell-template="formatText"
          />
          <DxColumn
            :width="150"
            data-field=""
            caption="No Telp Pelapor"
            :allow-resizing="false"
            css-class="custom-table-column"
            cell-template="formatText"
          />
          <DxColumn
            :width="150"
            data-field=""
            caption="Keterangan Pelapor"
            :allow-resizing="false"
            css-class="custom-table-column"
            cell-template="formatText"
          />
          <DxColumn
            :width="150"
            data-field=""
            caption="Penyebab"
            :allow-resizing="false"
            css-class="custom-table-column"
            cell-template="formatText"
          />
          <DxColumn
            :width="150"
            alignment="center"
            data-field=""
            caption="Kode Gangguan"
            :allow-resizing="false"
            css-class="custom-table-column"
            cell-template="formatText"
          />
          <DxColumn
            :width="150"
            alignment="center"
            data-field=""
            caption="Jenis Gangguan"
            :allow-resizing="false"
            css-class="custom-table-column"
            cell-template="formatText"
          />
          <DxColumn
            :width="150"
            alignment="center"
            data-field=""
            caption="Durasi Response Time"
            :allow-resizing="false"
            css-class="custom-table-column"
            cell-template="formatText"
          />
          <DxColumn
            :width="150"
            alignment="center"
            data-field=""
            caption="Durasi Recovery Time"
            :allow-resizing="false"
            css-class="custom-table-column"
            cell-template="formatText"
          />
          <DxColumn
            :width="150"
            alignment="center"
            data-field=""
            caption="Tgl Lapor"
            :allow-resizing="false"
            css-class="custom-table-column"
            cell-template="formatText"
          />

          <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 #formatPercentage="{ data }">
            <p class="text-right cursor-pointer">
              {{ parseFloat(data.text) ? formatPercentage(data.text) : '0%' }}
            </p>
          </template>

          <template #formatText="{ data }">
            <p class="text-left cursor-pointer">
              {{ data.text }}
            </p>
          </template>
        </DxDataGrid>
      </div>
    </div>
    <div class="w-full mb-4 lg:w-[30%] lg:float-right">
      <div class="p-4 space-y-2 bg-white rounded-xl">
        <div class="flex flex-row items-center justify-between w-full">
          <h3 class="text-sm font-medium w-[135px] text-gray-800">No Laporan:</h3>
          <InputText :readonly="true" :value="dataSubSelected?.no_laporan" class-name="flex-1" />
        </div>

        <div class="flex flex-row items-center justify-between w-full">
          <h3 class="text-sm font-medium w-[135px] text-gray-800">UID/UIW:</h3>
          <InputText :readonly="true" class-name="flex-1" />
        </div>

        <div class="flex flex-row items-center justify-between w-full">
          <h3 class="text-sm font-medium w-[135px] text-gray-800">UP3:</h3>
          <InputText :readonly="true" value="" class-name="flex-1" />
        </div>

        <div class="flex flex-row items-center justify-between w-full">
          <h3 class="text-sm font-medium w-[135px] text-gray-800">ULP:</h3>
          <InputText :readonly="true" value="" class-name="flex-1" />
        </div>

        <div class="flex flex-row items-center justify-between w-full">
          <h3 class="text-sm font-medium w-[135px] text-gray-800">ID Pelanggan:</h3>
          <InputText :readonly="true" value="" class-name="flex-1" />
        </div>

        <div class="flex flex-row items-center justify-between w-full">
          <h3 class="text-sm font-medium w-[135px] text-gray-800">Nama Pelanggan:</h3>
          <InputText :readonly="true" value="" class-name="flex-1" />
        </div>

        <div class="flex flex-row items-center justify-between w-full">
          <h3 class="text-sm font-medium w-[135px] text-gray-800">Nama Pelapor:</h3>
          <InputText :readonly="true" class-name="flex-1" value="" />
        </div>

        <div class="flex flex-row items-center justify-between w-full">
          <h3 class="text-sm font-medium w-[135px] text-gray-800">Alamat Pelapor:</h3>
          <InputText :readonly="true" value="" type="textarea" class-name="flex-1" />
        </div>

        <div class="flex flex-row items-center justify-between w-full">
          <h3 class="text-sm font-medium w-[135px] text-gray-800">No Telp Pelapor:</h3>
          <InputText :readonly="true" value="" class-name="flex-1" />
        </div>

        <div class="flex flex-row items-center justify-between w-full">
          <h3 class="text-sm font-medium w-[135px] text-gray-800">Keterangan Pelapor:</h3>
          <InputText :readonly="true" value="" type="textarea" class-name="flex-1" />
        </div>

        <div class="flex flex-row items-center justify-between w-full">
          <h3 class="text-sm font-medium w-[135px] text-gray-800">Penyebab:</h3>
          <InputText :readonly="true" type="textarea" value="" class-name="flex-1" />
        </div>

        <div class="flex flex-row items-center justify-between w-full">
          <h3 class="text-sm font-medium w-[135px] text-gray-800">Kode Gangguan:</h3>
          <InputText :readonly="true" value="" class-name="flex-1" />
        </div>

        <div class="flex flex-row items-center justify-between w-full">
          <h3 class="text-sm font-medium w-[135px] text-gray-800">Jenis Gangguan:</h3>
          <InputText :readonly="true" value="" class-name="flex-1" />
        </div>

        <div class="flex flex-row items-center justify-between w-full">
          <h3 class="text-sm font-medium w-[135px] text-gray-800">Durasi Response Time:</h3>
          <InputText :readonly="true" value="" class-name="flex-1" />
        </div>

        <div class="flex flex-row items-center justify-between w-full">
          <h3 class="text-sm font-medium w-[135px] text-gray-800">Durasi Recovery Time:</h3>
          <InputText :readonly="true" value="" class-name="flex-1" />
        </div>

        <div class="flex flex-row items-center justify-between w-full">
          <h3 class="text-sm font-medium w-[135px] text-gray-800">Tgl Lapor:</h3>
          <InputText :readonly="true" value="" class-name="flex-1" />
        </div>
      </div>
    </div>
  </DetailDialog>
</template>

<script setup lang="ts">
import { onMounted, ref, watch } from 'vue'
import Filters from '@/components/Form/Filters.vue'
import Type2 from '@/components/Form/FiltersType/Type2.vue'
import { DxDataGrid } from 'devextreme-vue'
import {
  DxColumn,
  DxColumnFixing,
  DxExport,
  DxLoadPanel,
  DxPaging,
  DxScrolling,
  DxSearchPanel,
  DxSelection,
  DxSummary,
  DxTotalItem,
  DxGroupItem,
  DxGrouping
} from 'devextreme-vue/data-grid'
import { jsPDF } from 'jspdf'
import { exportDataGrid as exportToPdf } from 'devextreme/pdf_exporter'
import { exportDataGrid as exportToExcel } from 'devextreme/excel_exporter'
import { saveAs } from 'file-saver'
import { Workbook } from 'exceljs'
import { useQuery } from '@vue/apollo-composable'
import { queries } from '@/utils/api/api.graphql'
import { getMonthName, getMonthNameShort } from '@/utils/texts'
import { formatNumber, formatPercentage, isNumber } from '@/utils/numbers'
import DetailDialog from '@/components/Dialogs/DetailDialog.vue'
import InputText from '@/components/InputText.vue'
import { apolloClient } from '@/utils/api/api.graphql'
import { provideApolloClient } from '@vue/apollo-composable'

const client = apolloClient()
provideApolloClient(client)
const currentYear = ref(new Date().getFullYear())
const currentMonth = ref(new Date().getMonth())
const lastYear = ref(currentYear.value - 1)
const filters = ref()
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>(null)
const dataSubSelected = ref<any>(null)
const dialogDetail = ref(false)
const closedialogDetail = () => (dialogDetail.value = false)
const loadingData = ref(false)
const loadingSubData = ref(false)

const onExporting = (e: any) => {
  if (e.format === 'pdf') {
    const doc = new jsPDF()

    exportToPdf({
      jsPDFDocument: doc,
      component: e.component,
      indent: 5
    }).then(() => {
      doc.save(`.pdf`)
    })
  } else {
    const workbook = new Workbook()
    const worksheet = workbook.addWorksheet('Employees')

    exportToExcel({
      component: e.component,
      worksheet,
      autoFilterEnabled: true
    }).then(() => {
      workbook.xlsx.writeBuffer().then((buffer: any) => {
        saveAs(new Blob([buffer], { type: 'application/octet-stream' }), 'DataGrid.xlsx')
      })
    })

    e.cancel = true
  }
}

const getDetail = () => {
  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
  }

  const { onResult, onError, loading } = useQuery(
    queries.keluhan.rekap.rekapKeluhanAllDetail,
    query
  )

  onResult((queryResult) => {
    if (queryResult.data != undefined) {
      dataSub.value = queryResult.data.detailKeluhanAll
    }
  })

  onError((error) => {
    console.log(error)
  })

  watch(loading, (value) => {
    loadingSubData.value = value
  })
}

const dataGridRef = ref<DxDataGrid | null>(null)
const clearSelection = () => {
  const dataGrid = dataGridRef.value!.instance!
  dataGrid.clearSelection()
}
const showDetail = () => {
  clearSelection()
  dataSubSelected.value = null
  dialogDetail.value = true
  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 filterData = (params: any) => {
  const { regional, ulp, uid, up3, bulan, tahun } = params

  currentMonth.value = bulan.id
  currentYear.value = tahun.id
  lastYear.value = tahun.id - 1

  const { onResult, onError, loading, refetch } = useQuery(
    queries.monalisa.laporan.bulanan.agingComplaintBulanan,
    {
      namaRegional: regional.name == 'Semua Regional' ? '' : regional.name,
      idUid: uid ? uid.id : 0,
      idUp3: up3 ? up3.id : 0,
      idUlp: ulp ? ulp.id : 0,
      bulan: bulan ? bulan.id : currentMonth.value,
      tahun: bulan ? tahun.id : currentYear.value
    }
  )

  onResult((queryResult) => {
    if (queryResult.data != undefined) {
      data.value = queryResult.data.agingComplaintBulanan
    }
  })

  onError((error) => {
    console.log(error)
  })

  watch(loading, (value) => {
    loadingData.value = value
  })
}

onMounted(() => {
  if (import.meta.env.DEV) {
    getMonthName(filters.value.bulan.id)

    data.value = [
      {
        nama_regional: '',
        id_uid: 0,
        nama_uid: '',
        id_up3: 0,
        nama_up3: '',
        id_ulp: 0,
        nama_ulp: 'CONTACT CENTER 123',
        avg_durasi_recovery_gangguan: 30.2,
        sla_gangguan: 180,
        avg_durasi_recovery_keluhan: 0.4,
        sla_keluhan: 72,
        aging_complaint_gangguan: 180,
        aging_complaint_keluhan: 200,
        avg_aging_complaint: 190
      },
      {
        nama_regional: 'REGIONAL SUMKAL',
        id_uid: 120,
        nama_uid: 'WILAYAH SUMATERA UTARA',
        id_up3: 12100,
        nama_up3: 'UP3 PEMATANG SIANTAR',
        id_ulp: 12102,
        nama_ulp: 'ULP LIMA PULUH',
        avg_durasi_recovery_gangguan: 30.2,
        sla_gangguan: 180,
        avg_durasi_recovery_keluhan: 0.4,
        sla_keluhan: 72,
        aging_complaint_gangguan: 180,
        aging_complaint_keluhan: 200,
        avg_aging_complaint: 190
      },
      {
        nama_regional: 'REGIONAL SULMAPANA',
        id_uid: 41,
        nama_uid: 'WILAYAH MALUKU DAN MALUKU UTARA',
        id_up3: 412,
        nama_up3: 'UP3 TERNATE',
        id_ulp: 41230,
        nama_ulp: 'ULP BACAN',
        avg_durasi_recovery_gangguan: 30.2,
        sla_gangguan: 180,
        avg_durasi_recovery_keluhan: 0.4,
        sla_keluhan: 72,
        aging_complaint_gangguan: 180,
        aging_complaint_keluhan: 200,
        avg_aging_complaint: 190
      },
      {
        nama_regional: 'REGIONAL JMB',
        id_uid: 101,
        nama_uid: 'DISTRIBUSI JAWA TENGAH & DIY',
        id_up3: 52150,
        nama_up3: 'UP3 MAGELANG',
        id_ulp: 52156,
        nama_ulp: 'ULP PARAKAN',
        avg_durasi_recovery_gangguan: 30.2,
        sla_gangguan: 180,
        avg_durasi_recovery_keluhan: 0.4,
        sla_keluhan: 72,
        aging_complaint_gangguan: 180,
        aging_complaint_keluhan: 200,
        avg_aging_complaint: 190
      },
      {
        nama_regional: 'REGIONAL SULMAPANA',
        id_uid: 41,
        nama_uid: 'WILAYAH MALUKU DAN MALUKU UTARA',
        id_up3: 412,
        nama_up3: 'UP3 TERNATE',
        id_ulp: 41230,
        nama_ulp: 'ULP BACAN',
        avg_durasi_recovery_gangguan: 30.2,
        sla_gangguan: 180,
        avg_durasi_recovery_keluhan: 0.4,
        sla_keluhan: 72,
        aging_complaint_gangguan: 180,
        aging_complaint_keluhan: 200,
        avg_aging_complaint: 190
      }
    ]
  }
})
</script>
