<template>
  <Filters @run-search="() => filterData(filters)" :report-button="true" class="mb-4">
    <Type1 @update:filters="(value) => (filters = value)" />
  </Filters>
  <div id="data">
    <DxDataGrid
      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"
    >
      <DxSelection mode="single" />
      <DxPaging :enabled="false" />
      <DxScrolling column-rendering-mode="virtual" mode="virtual" />
      <DxLoadPanel
        :position="position"
        :show-indicator="showIndicator"
        :show-pane="showPane"
        :shading="shading"
        v-if="loading"
        v-model:visible="loading"
        :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
        :width="50"
        alignment="center"
        :calculateCellValue="(item: any) => data.findIndex((i) => i == item) + 1"
        caption="NO"
        data-type="number"
        css-class="custom-table-column"
        cell-template="formatNumber"
      />
      <DxColumn
        :width="150"
        alignment="center"
        data-field=""
        caption="Kode"
        css-class="custom-table-column"
        cell-template="formatText"
      />
      <DxColumn
        :width="200"
        alignment="center"
        data-field=""
        caption="Nama Regu"
        css-class="custom-table-column"
        cell-template="formatText"
      />
      <DxColumn alignment="center" caption="Laporan" css-class="custom-table-column">
        <DxColumn
          alignment="center"
          data-field="total"
          data-type="number"
          caption="Total"
          css-class="custom-table-column"
          cell-template="formatNumber"
        />
        <DxColumn alignment="center" caption="Belum Selesai" css-class="custom-table-column">
          <DxColumn
            alignment="center"
            data-field="total_inproses"
            data-type="number"
            caption="Jml"
            css-class="custom-table-column"
            cell-template="formatNumber"
          />
          <DxColumn
            alignment="center"
            data-field="persen_inproses"
            data-type="number"
            caption="%"
            css-class="custom-table-column"
            cell-template="formatNumber"
          />
        </DxColumn>
        <DxColumn alignment="center" caption="Sudah Selesai" css-class="custom-table-column">
          <DxColumn
            alignment="center"
            data-field="total_selesai"
            data-type="number"
            caption="Jml"
            css-class="custom-table-column"
            cell-template="formatNumber"
          />
          <DxColumn
            alignment="center"
            data-field="persen_selesai"
            data-type="number"
            caption="%"
            css-class="custom-table-column"
            cell-template="formatNumber"
          />
        </DxColumn>
      </DxColumn>
      <DxColumn alignment="center" caption="Rating" css-class="custom-table-column">
        <DxColumn alignment="center" caption="Bintang" css-class="custom-table-column">
          <DxColumn
            alignment="center"
            data-field="total_rating"
            data-type="number"
            caption="Jml"
            css-class="custom-table-column"
            cell-template="formatNumber"
          />
          <DxColumn
            alignment="center"
            data-field="nilai_rating1"
            data-type="number"
            caption="1"
            css-class="custom-table-column"
            cell-template="formatNumber"
          />
          <DxColumn
            alignment="center"
            data-field="nilai_rating2"
            data-type="number"
            caption="2"
            css-class="custom-table-column"
            cell-template="formatNumber"
          />
          <DxColumn
            alignment="center"
            data-field="nilai_rating3"
            data-type="number"
            caption="3"
            css-class="custom-table-column"
            cell-template="formatNumber"
          />
          <DxColumn
            alignment="center"
            data-field="nilai_rating4"
            data-type="number"
            caption="4"
            css-class="custom-table-column"
            cell-template="formatNumber"
          />
          <DxColumn
            alignment="center"
            data-field="nilai_rating5"
            data-type="number"
            caption="5"
            css-class="custom-table-column"
            cell-template="formatNumber"
          />
          <DxColumn
            alignment="center"
            data-field="indeks_rating"
            data-type="number"
            caption="Index"
            css-class="custom-table-column"
            cell-template="formatNumber"
          />
        </DxColumn>
      </DxColumn>

      <DxColumn alignment="center" caption="Non Rating" css-class="custom-table-column">
        <DxColumn
          :width="150"
          alignment="center"
          data-field="total_nonrating"
          data-type="number"
          caption="Jml"
          css-class="custom-table-column"
          cell-template="formatNumber"
        />
        <DxColumn
          :width="70"
          alignment="center"
          data-field="persen_nonrating"
          data-type="number"
          caption="%"
          css-class="custom-table-column"
          cell-template="formatNumber"
        />
      </DxColumn>

      <template #formatText="{ data }">
        <p class="text-left cursor-pointer" @click="showData()">
          {{ data.text }}
        </p>
      </template>

      <template #formatPercentage="{ data }">
        <p class="text-right cursor-pointer" @click="showData()">
          {{ isNumber(data.text) ? formatPercentage(data.text) : data.text }}
        </p>
      </template>

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

      <template #formatTime="{ data }">
        <p class="!text-right cursor-pointer">
          {{ parseInt(data.text) ? formatWaktu(data.text) : '-' }}
        </p>
      </template>
    </DxDataGrid>
  </div>

  <DetailDialog
    :open="showDetail"
    title="Detail Rating Per Regu"
    @on-close="closeDetail"
    :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
          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="5" :enabled="true" />
          <DxPager
            :visible="true"
            :allowed-page-sizes="[5, 10, 20]"
            display-mode="full"
            :show-page-size-selector="true"
            :show-info="true"
            :show-navigation-buttons="true"
          />
          <DxLoadPanel
            :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=""
            caption="No Laporan"
            css-class="custom-table-column"
            cell-template="formatText"
          />
          <DxColumn
            :width="150"
            alignment="center"
            data-field=""
            caption="Rating"
            css-class="custom-table-column"
            cell-template="formatRating"
          />
          <DxColumn
            :width="150"
            alignment="center"
            data-field=""
            caption="Tgl Lapor"
            css-class="custom-table-column"
            cell-template="formatText"
          />
          <DxColumn
            :width="150"
            alignment="center"
            data-field=""
            caption="Tgl Datang"
            css-class="custom-table-column"
            cell-template="formatText"
          />
          <DxColumn
            :width="150"
            alignment="center"
            data-field=""
            caption="Tgl Nyala"
            css-class="custom-table-column"
            cell-template="formatText"
          />
          <DxColumn
            :width="150"
            alignment="center"
            data-field=""
            caption="Durasi Response Time"
            css-class="custom-table-column"
            cell-template="formatTime"
          />
          <DxColumn
            :width="150"
            alignment="center"
            data-field=""
            caption="Durasi Recovery Time"
            css-class="custom-table-column"
            cell-template="formatTime"
          />
          <DxColumn
            :width="150"
            alignment="center"
            data-field=""
            caption="Referensi Marking"
            css-class="custom-table-column"
            cell-template="formatText"
          />
          <DxColumn
            :width="150"
            alignment="center"
            data-field=""
            caption="IDPEL/NO METER"
            css-class="custom-table-column"
            cell-template="formatText"
          />
          <DxColumn
            :width="150"
            alignment="center"
            data-field=""
            caption="Nama Pelapor"
            css-class="custom-table-column"
            cell-template="formatText"
          />
          <DxColumn
            :width="150"
            alignment="center"
            data-field=""
            caption="Alamat Pelapor"
            css-class="custom-table-column"
            cell-template="formatText"
          />
          <DxColumn
            :width="150"
            alignment="center"
            data-field=""
            caption="No Tlp Pelapor"
            css-class="custom-table-column"
            cell-template="formatText"
          />
          <DxColumn
            :width="150"
            alignment="center"
            data-field=""
            caption="Keterangan Pelapor"
            css-class="custom-table-column"
            cell-template="formatText"
          />
          <DxColumn
            :width="150"
            alignment="center"
            data-field=""
            caption="Posko"
            css-class="custom-table-column"
            cell-template="formatText"
          />
          <DxColumn
            :width="150"
            alignment="center"
            data-field=""
            caption="Tindakan"
            css-class="custom-table-column"
            cell-template="formatText"
          />
          <DxColumn
            :width="150"
            alignment="center"
            data-field=""
            caption="Penyebab"
            css-class="custom-table-column"
            cell-template="formatText"
          />

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

          <template #formatNumber="{ data }">
            <p class="text-right cursor-pointer">
              {{ data.text }}
            </p>
          </template>

          <template #formatTime="{ data }">
            <p>
              {{ parseInt(data.text) ? formatWaktu(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="" 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">Rating:</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 class="flex flex-row items-center justify-between w-full">
          <h3 class="text-sm font-medium w-[135px] text-gray-800">Tgl Datang:</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 Nyala:</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">Referensi Marking:</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">IDPEL/NO METER:</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" 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">Alamat 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">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="" 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">Posko:</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">Tindakan:</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">Penyebab:</h3>
          <InputText :readonly="true" value="" class-name="flex-1" />
        </div>
      </div>
    </div>
  </DetailDialog>
</template>

<script setup lang="ts">
import Filters from '@/components/Form/Filters.vue'
import Type1 from '@/components/Form/FiltersType/Type1.vue'
import { onMounted, ref } from 'vue'
import { DxDataGrid } from 'devextreme-vue'
import {
  DxColumn,
  DxColumnFixing,
  DxExport,
  DxLoadPanel,
  DxPager,
  DxPaging,
  DxScrolling,
  DxSearchPanel,
  DxSelection
} 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 { formatNumber, formatPercentage, isNumber } from '@/utils/numbers'
import { formatWaktu } from '@/components/Form/FiltersType/reference'
import DetailDialog from '@/components/Dialogs/DetailDialog.vue'
import InputText from '@/components/InputText.vue'

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()
const dataSubSelected = ref()
const showDetail = ref(false)
const loadingSubData = ref(false)

const showData = () => {
  showDetail.value = true
}

const closeDetail = () => {
  showDetail.value = 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 onDataSelectionChanged = ({ selectedRowsData }: any) => {
  dataSelected.value = selectedRowsData[0]
  console.log(data)
}

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

const { onResult, onError, loading, refetch } = useQuery(
  queries.gangguan.rekap.gangguanRatingPerRegu,
  {
    dateFrom: new Date('2023-10-01').toISOString().slice(0, 10),
    dateTo: new Date('2023-10-01').toISOString().slice(0, 10),
    posko: '',
    idUid: 0,
    idUp3: 0
  }
)
const filterData = (params: any) => {
  const dateValue = params.periode.split(' s/d ')
  const { posko, uid, up3 } = params
  refetch({
    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),
    posko: posko ? posko.id : 0,
    idUid: uid ? uid.id : 0,
    idUp3: up3 ? up3.id : 0
  })
  onResult((queryResult) => {
    if (queryResult.data != undefined) {
      data.value = queryResult.data.rekapitulasiGangguanRatingPerRegu
    }
    console.log(queryResult.data)
    console.log(queryResult.loading)
    console.log(queryResult.networkStatus)
  })
  onError((error) => {
    console.log(error)
  })
}
const filters = ref()
onMounted(() => {
  if (import.meta.env.DEV) {
    data.value = [
      {
        id: 0,
        nama_regional: 'REGIONAL JMB',
        id_uid: 101,
        nama_uid: 'DISTRIBUSI JAWA TENGAH & DIY',
        id_up3: 52050,
        nama_up3: 'UP3 SURAKARTA',
        id_ulp: 52058,
        nama_ulp: 'ULP SRAGEN',
        id_posko: 520581,
        nama_posko: 'POSKO ULP SRAGEN',
        total: 5,
        total_selesai: 5,
        persen_selesai: 100,
        total_inproses: 0,
        persen_inproses: 0,
        total_rating: 2,
        persen_rating: 40,
        nilai_rating1: 0,
        nilai_rating2: 0,
        nilai_rating3: 0,
        nilai_rating4: 0,
        nilai_rating5: 2,
        indeks_rating: 1,
        total_nonrating: 3,
        persen_nonrating: 60
      },
      {
        id: 1,
        nama_regional: 'REGIONAL JMB',
        id_uid: 103,
        nama_uid: 'DISTRIBUSI JAWA TIMUR',
        id_up3: 150,
        nama_up3: 'UP3 PAMEKASAN',
        id_ulp: 51750,
        nama_ulp: 'ULP KETAPANG',
        id_posko: 517506,
        nama_posko: 'POSKO ULP KETAPANG',
        total: 5,
        total_selesai: 5,
        persen_selesai: 100,
        total_inproses: 0,
        persen_inproses: 0,
        total_rating: null,
        persen_rating: null,
        nilai_rating1: 0,
        nilai_rating2: 0,
        nilai_rating3: 0,
        nilai_rating4: 0,
        nilai_rating5: 0,
        indeks_rating: null,
        total_nonrating: null,
        persen_nonrating: null
      },
      {
        id: 2,
        nama_regional: 'REGIONAL SUMKAL',
        id_uid: 140,
        nama_uid: 'WILAYAH SUMATERA SELATAN, JAMBI & BENGKULU (S2JB)',
        id_up3: 1404,
        nama_up3: 'UP3 JAMBI',
        id_ulp: 14390,
        nama_ulp: 'ULP SABAK',
        id_posko: 143901,
        nama_posko: 'POSKO ULP SABAK',
        total: 2,
        total_selesai: 2,
        persen_selesai: 100,
        total_inproses: 0,
        persen_inproses: 0,
        total_rating: 2,
        persen_rating: 100,
        nilai_rating1: 0,
        nilai_rating2: 0,
        nilai_rating3: 0,
        nilai_rating4: 0,
        nilai_rating5: 2,
        indeks_rating: 1,
        total_nonrating: 0,
        persen_nonrating: 0
      },
      {
        id: 3,
        nama_regional: 'REGIONAL JMB',
        id_uid: 427,
        nama_uid: 'DISTRIBUSI JAWA BARAT',
        id_up3: 539,
        nama_up3: 'UP3 GUNUNG PUTRI',
        id_ulp: 53867,
        nama_ulp: 'ULP JONGGOL',
        id_posko: 538671,
        nama_posko: 'POSKO ULP JONGGOL',
        total: 7,
        total_selesai: 7,
        persen_selesai: 100,
        total_inproses: 0,
        persen_inproses: 0,
        total_rating: 4,
        persen_rating: 57.14285714285714,
        nilai_rating1: 0,
        nilai_rating2: 0,
        nilai_rating3: 0,
        nilai_rating4: 0,
        nilai_rating5: 4,
        indeks_rating: 1,
        total_nonrating: 3,
        persen_nonrating: 42.857142857142854
      },
      {
        id: 4,
        nama_regional: 'REGIONAL JMB',
        id_uid: 427,
        nama_uid: 'DISTRIBUSI JAWA BARAT',
        id_up3: 542,
        nama_up3: 'UP3 MAJALAYA',
        id_ulp: 53531,
        nama_ulp: 'ULP MAJALAYA',
        id_posko: 535311,
        nama_posko: 'POSKO ULP MAJALAYA',
        total: 4,
        total_selesai: 4,
        persen_selesai: 100,
        total_inproses: 0,
        persen_inproses: 0,
        total_rating: null,
        persen_rating: null,
        nilai_rating1: 0,
        nilai_rating2: 0,
        nilai_rating3: 0,
        nilai_rating4: 0,
        nilai_rating5: 0,
        indeks_rating: null,
        total_nonrating: null,
        persen_nonrating: null
      },
      {
        id: 5,
        nama_regional: 'REGIONAL SUMKAL',
        id_uid: 120,
        nama_uid: 'WILAYAH SUMATERA UTARA',
        id_up3: 12100,
        nama_up3: 'UP3 PEMATANG SIANTAR',
        id_ulp: 12115,
        nama_ulp: 'ULP PEMATANG RAYA',
        id_posko: 121155,
        nama_posko: 'POSKO ULP PEMATANG RAYA',
        total: 1,
        total_selesai: 1,
        persen_selesai: 100,
        total_inproses: 0,
        persen_inproses: 0,
        total_rating: 1,
        persen_rating: 100,
        nilai_rating1: 0,
        nilai_rating2: 0,
        nilai_rating3: 0,
        nilai_rating4: 0,
        nilai_rating5: 1,
        indeks_rating: 1,
        total_nonrating: 0,
        persen_nonrating: 0
      },
      {
        id: 6,
        nama_regional: 'REGIONAL SUMKAL',
        id_uid: 171,
        nama_uid: 'DISTRIBUSI LAMPUNG',
        id_up3: 17172,
        nama_up3: 'UP3 METRO',
        id_ulp: 17210,
        nama_ulp: 'ULP SRIBAWONO',
        id_posko: 172101,
        nama_posko: 'POSKO ULP SRIBAWONO',
        total: 18,
        total_selesai: 18,
        persen_selesai: 100,
        total_inproses: 0,
        persen_inproses: 0,
        total_rating: 12,
        persen_rating: 66.66666666666666,
        nilai_rating1: 0,
        nilai_rating2: 0,
        nilai_rating3: 0,
        nilai_rating4: 0,
        nilai_rating5: 12,
        indeks_rating: 1,
        total_nonrating: 6,
        persen_nonrating: 33.33333333333333
      },
      {
        id: 7,
        nama_regional: 'REGIONAL JMB',
        id_uid: 101,
        nama_uid: 'DISTRIBUSI JAWA TENGAH & DIY',
        id_up3: 52200,
        nama_up3: 'UP3 PURWOKERTO',
        id_ulp: 52205,
        nama_ulp: 'ULP WONOSOBO',
        id_posko: 522051,
        nama_posko: 'POSKO ULP WONOSOBO',
        total: 23,
        total_selesai: 23,
        persen_selesai: 100,
        total_inproses: 0,
        persen_inproses: 0,
        total_rating: 22,
        persen_rating: 95.65217391304348,
        nilai_rating1: 0,
        nilai_rating2: 0,
        nilai_rating3: 0,
        nilai_rating4: 0,
        nilai_rating5: 22,
        indeks_rating: 1,
        total_nonrating: 1,
        persen_nonrating: 4.3478260869565215
      },
      {
        id: 8,
        nama_regional: 'REGIONAL SUMKAL',
        id_uid: 120,
        nama_uid: 'WILAYAH SUMATERA UTARA',
        id_up3: 12500,
        nama_up3: 'UP3 RANTAU PRAPAT',
        id_ulp: 12513,
        nama_ulp: 'ULP LABUHAN BILIK',
        id_posko: 125133,
        nama_posko: 'POSKO ULP LABUHAN BILIK',
        total: 1,
        total_selesai: 1,
        persen_selesai: 100,
        total_inproses: 0,
        persen_inproses: 0,
        total_rating: null,
        persen_rating: null,
        nilai_rating1: 0,
        nilai_rating2: 0,
        nilai_rating3: 0,
        nilai_rating4: 0,
        nilai_rating5: 0,
        indeks_rating: null,
        total_nonrating: null,
        persen_nonrating: null
      },
      {
        id: 9,
        nama_regional: 'REGIONAL JMB',
        id_uid: 103,
        nama_uid: 'DISTRIBUSI JAWA TIMUR',
        id_up3: 150,
        nama_up3: 'UP3 PAMEKASAN',
        id_ulp: 51730,
        nama_ulp: 'ULP BANGKALAN',
        id_posko: 517304,
        nama_posko: 'POSKO ULP BANGKALAN',
        total: 32,
        total_selesai: 32,
        persen_selesai: 100,
        total_inproses: 0,
        persen_inproses: 0,
        total_rating: 3,
        persen_rating: 9.375,
        nilai_rating1: 0,
        nilai_rating2: 0,
        nilai_rating3: 0,
        nilai_rating4: 0,
        nilai_rating5: 3,
        indeks_rating: 1,
        total_nonrating: 29,
        persen_nonrating: 90.625
      },
      {
        id: 10,
        nama_regional: 'REGIONAL SUMKAL',
        id_uid: 180,
        nama_uid: 'WILAYAH RIAU DAN KEPULAUAN RIAU',
        id_up3: 181,
        nama_up3: 'UP3 PEKANBARU',
        id_ulp: 18111,
        nama_ulp: 'ULP PEKANBARU KOTA BARAT',
        id_posko: 181111,
        nama_posko: 'POSKO ULP PEKANBARU KOTA BARAT',
        total: 109,
        total_selesai: 109,
        persen_selesai: 100,
        total_inproses: 0,
        persen_inproses: 0,
        total_rating: null,
        persen_rating: null,
        nilai_rating1: 0,
        nilai_rating2: 0,
        nilai_rating3: 0,
        nilai_rating4: 0,
        nilai_rating5: 0,
        indeks_rating: null,
        total_nonrating: null,
        persen_nonrating: null
      },
      {
        id: 11,
        nama_regional: 'REGIONAL JMB',
        id_uid: 427,
        nama_uid: 'DISTRIBUSI JAWA BARAT',
        id_up3: 536,
        nama_up3: 'UP3 CIMAHI',
        id_ulp: 53589,
        nama_ulp: 'ULP LEMBANG',
        id_posko: 535891,
        nama_posko: 'POSKO ULP LEMBANG',
        total: 17,
        total_selesai: 17,
        persen_selesai: 100,
        total_inproses: 0,
        persen_inproses: 0,
        total_rating: 17,
        persen_rating: 100,
        nilai_rating1: 0,
        nilai_rating2: 0,
        nilai_rating3: 0,
        nilai_rating4: 0,
        nilai_rating5: 17,
        indeks_rating: 1,
        total_nonrating: 0,
        persen_nonrating: 0
      },
      {
        id: 12,
        nama_regional: 'REGIONAL SULMAPANA',
        id_uid: 32,
        nama_uid: 'WILAYAH SULAWESI SELATAN, TENGGARA DAN BARAT',
        id_up3: 32800,
        nama_up3: 'UP3 BAUBAU',
        id_ulp: 32820,
        nama_ulp: 'ULP RAHA',
        id_posko: 328201,
        nama_posko: 'POSKO ULP RAHA',
        total: 3,
        total_selesai: 3,
        persen_selesai: 100,
        total_inproses: 0,
        persen_inproses: 0,
        total_rating: null,
        persen_rating: null,
        nilai_rating1: 0,
        nilai_rating2: 0,
        nilai_rating3: 0,
        nilai_rating4: 0,
        nilai_rating5: 0,
        indeks_rating: null,
        total_nonrating: null,
        persen_nonrating: null
      },
      {
        id: 13,
        nama_regional: 'REGIONAL SULMAPANA',
        id_uid: 32,
        nama_uid: 'WILAYAH SULAWESI SELATAN, TENGGARA DAN BARAT',
        id_up3: 32200,
        nama_up3: 'UP3 WATAMPONE',
        id_ulp: 32270,
        nama_ulp: 'ULP PATANGKAI',
        id_posko: 322701,
        nama_posko: 'POSKO ULP PATANGKAI',
        total: 3,
        total_selesai: 3,
        persen_selesai: 100,
        total_inproses: 0,
        persen_inproses: 0,
        total_rating: null,
        persen_rating: null,
        nilai_rating1: 0,
        nilai_rating2: 0,
        nilai_rating3: 0,
        nilai_rating4: 0,
        nilai_rating5: 0,
        indeks_rating: null,
        total_nonrating: null,
        persen_nonrating: null
      },
      {
        id: 14,
        nama_regional: 'REGIONAL SUMKAL',
        id_uid: 221,
        nama_uid: 'WILAYAH KALIMANTAN SELATAN DAN TENGAH',
        id_up3: 2220,
        nama_up3: 'UP3 BARABAI',
        id_ulp: 22250,
        nama_ulp: 'ULP PARINGIN',
        id_posko: 222501,
        nama_posko: 'POSKO ULP PARINGIN',
        total: 1,
        total_selesai: 1,
        persen_selesai: 100,
        total_inproses: 0,
        persen_inproses: 0,
        total_rating: 1,
        persen_rating: 100,
        nilai_rating1: 0,
        nilai_rating2: 0,
        nilai_rating3: 0,
        nilai_rating4: 0,
        nilai_rating5: 1,
        indeks_rating: 1,
        total_nonrating: 0,
        persen_nonrating: 0
      }
    ]
  }
})
</script>
