import './Main.sass' import { Logo, Link, Page, Row, Padding, ModalButton, Box, Button } from '../../components/' import { FiLogOut } from 'solid-icons/fi' import { Tabs } from '@kobalte/core/tabs' import { ofetch } from 'ofetch' import { onMount, createSignal } from 'solid-js' import dayjs from 'dayjs' const API = import.meta.env.VITE_BACKEND const PESO = import.meta.env.VITE_PESO const ID = import.meta.env.VITE_ID export default () => { const [totalOp, setTotalOp] = createSignal(0) const [assessor, setAssessor] = createSignal('') const [dateOp, setDateOp] = createSignal('') const [location, setLocation] = createSignal('') const [type, setType] = createSignal('') const [applicationId, setApplicationId] = createSignal(0) const [assessorId, setAssessorId] = createSignal(0) const [gflgu, setGflgu] = createSignal([]) const [gfdpwh, setGfdpwh] = createSignal([]) const [tfbo, setTfbo] = createSignal([]) const [descriptionList, setDescriptionList] = createSignal([]) const [amountList, setAmountList] = createSignal([]) const [dateOpList, setDateOpList] = createSignal([]) const [applicationList, setApplicationList] = createSignal([]) const [nameList, setNameList] = createSignal([]) const getListForApproval = async () => { try { const response = await ofetch(API + 'get-listopapproval-electrical', { parseResponse: JSON.parse }) setApplicationList(response.result) setNameList(response.result2) } catch (error) { console.error(error) } } const load = async () => { await getListForApproval() } const getopdetails = async (applicationNo: string) => { const op = await ofetch(API + 'get-opdetails-electrical/' + applicationNo, { parseResponse: JSON.parse }) setAssessor(op.result7[0]) setLocation(op.result5[0]) setType(op.result6[0]) setDateOp(dayjs(op.result10[0]).format('MMMM DD, YYYY')) // setClient(displayFullname(op.result2[0], op.result3[0], op.result4[0])) setApplicationId(op.result11[0]) setAssessorId(op.result12[0]) setTotalOp(calculateTotal(op.result9)) setDescriptionList(op.result8) setAmountList(op.result9) setDateOpList(op.result10) calculateAmounts() } const calculateTotal = (list: number[]) => { const total = list.map((item) => parseFloat(item.toString())).reduce((acc, curr) => acc + curr, 0) return total } // const displayFullname = (firstname: string, middleinitial: string, lastname: string) => { // let result // if (firstname.length > 0) { // if (middleinitial.length > 0) { // result = `${firstname} ${middleinitial}. ${lastname}` // } else { // result = `${firstname} ${lastname}` // } // } else { // result = lastname // } // return result // } const approveHandler = async () => { const today = new Date() const formattedDate = dayjs(today).format('YYYY-MM-DD HH:mm:ss') for (let i = 0; i < applicationList().length; i++) { await ofetch(API + 'post-newstatus-electrical', { method: 'POST', body: { data: applicationId(), data2: formattedDate, data3: ID, data4: descriptionList()[i], data5: 'json' }, }) } } const calculateAmounts = () => { const amounts: string[] = amountList() let gflguList: number[] = [] let gfdpwhList: number[] = [] let tfboList: number[] = [] for (let i = 0; i < amounts.length; i++) { const gflgu = parseFloat(amounts[i]) * 0.8 const gfdpwh = parseFloat(amounts[i]) * 0.05 const tfbo = parseFloat(amounts[i]) * 0.15 const roundedGflgu = parseFloat(gflgu.toFixed(2)) const roundedGfdpwh = parseFloat(gfdpwh.toFixed(2)) const roundedTfbo = parseFloat(tfbo.toFixed(2)) gflguList.push(roundedGflgu) gfdpwhList.push(roundedGfdpwh) tfboList.push(roundedTfbo) } setGflgu(gflguList) setGfdpwh(gfdpwhList) setTfbo(tfboList) } onMount(async () => { await load() }) return ( <>

OCBO e-Sign

Login Name
Building Occupancy Electrical

List of Ready to Approve and Sign Building Order of Payments

List of Ready to Approve and Sign Occupancy Order of Payments

List of Ready to Approve and Sign Electrical Order of Payments

{applicationList().map((item, index) => ( ))}
Application Number Name Show Details
{item} {nameList()[index]} { await getopdetails(item) }} > {item}
) }