diff --git a/src/pages/AssessorPage/Assessor.tsx b/src/pages/AssessorPage/Assessor.tsx index 48282c7..3147bad 100644 --- a/src/pages/AssessorPage/Assessor.tsx +++ b/src/pages/AssessorPage/Assessor.tsx @@ -32,7 +32,7 @@ import { _type, _units, } from '../../stores/pdfinfo' -import { checkConnection, createPdfElectrical, createPdfOccupancy, getApi, getApiMulti, postApi } from '../../utils/functions' +import { checkConnection, createPdfElectrical, createPdfOccupancy, getApi, getApiMulti, postApi, voidApi } from '../../utils/functions' import './Assessor.sass' const PESO = import.meta.env.VITE_PESO @@ -68,7 +68,7 @@ export default () => { const [filter, setFilter] = createSignal('') - const listType = ['Print', 'Manual Print', 'Reprint'] + const listType = ['Print', 'Reprint', 'Reprint and Void'] const [selectedType, setSelectedType] = createSignal('Print') let bldgadditional = false @@ -81,7 +81,10 @@ export default () => { } const getPrintDetails = async (division: string, id: number) => { - const response = await getApiMulti(`get-printdetails-${division}`, id) + let response + if (selectedType() === 'Print') response = await getApiMulti(`get-printdetails-${division}`, id) + else response = await getApiMulti(`get-reprintdetails-${division}`, id) + const applicationno = response.result const date = response.result2 const location = response.result3 @@ -112,7 +115,10 @@ export default () => { } const getPrintDetailsFees = async (division: string, id: number) => { - const response = await getApiMulti(`get-printdetailsfees-${division}`, id) + let response + if (selectedType() === 'Print') response = await getApiMulti(`get-printdetailsfees-${division}`, id) + else response = await getApiMulti(`get-reprintdetailsfees-${division}`, id) + const feeList = response.result const accountCodeList = response.result2 const amountList = response.result3 @@ -190,7 +196,6 @@ export default () => { const additionalResult = await getApi('check-bldgadditional-printing', applicationNo) bldgadditional = additionalResult > 0 - console.log('additionalResult', additionalResult) const op = await getApiMulti(`get-opdetails-${division}`, applicationNo) @@ -226,7 +231,10 @@ export default () => { const getListForPrinting = async (division: string) => { try { - const response = await getApiMulti(`get-listopprinting-${division}`) + let response: any + + if (selectedType() === 'Print') response = await getApiMulti(`get-listopprinting-${division}`) + else response = await getApiMulti(`get-listopreprinting-${division}`) if (filter() !== '' && filter().trim().length !== 0) { const filteredApplications = response.result.filter((item: string) => item.includes(filter())) @@ -316,6 +324,42 @@ export default () => { } } + const rePrintHandler = async (division: string, application: string) => { + // let updateOrderofpayment: boolean = false + + setConnected(await checkConnection()) + if (connected() === false) { + setErrorMessage('No Connection on Server') + return + } + + if (selectedType().includes("Void")) { + if (division === 'electrical') { + await setNewStatus(division, 'ELECTRICAL ORDER OF PAYMENT REPRINTED', '175', 'ELECOPREPRINTED', 1) + await setNewStatus(division, 'ELECTRICAL ORDERPAYMENT RELEASED', '97', 'ELECRELEASED', 1) + await setNewStatus(division, 'FOR ELECTRICAL OFFICIAL RECEIPT VALIDATION', '98', 'ELECORVALIDATE', 0) + await updateDocflow(division, application, 'FOR ELECTRICAL ORDER OF PAYMENT PRINTING') + } else if (division === 'occupancy') { + await setNewStatus(division, 'OCCUPANCY ORDER OF PAYMENT REPRINTED', '176', 'OCCOPREPRINTED', 1) + await setNewStatus(division, 'OCCUPANCY ORDER OF PAYMENT RELEASED', '174', 'OCCOPRELEASED', 1) + await setNewStatus(division, 'ORDER OF PAYMENT RELEASE FOR BUREAU OF FIRE', '24', 'OCOOPRELEASE', 0) + await updateDocflow(division, application, 'APPROVED FOR PRINTING OF BUREAU OF FIRE AND ORDER OF PAYMENT') + } + + await voidOp(application) + } + + postTransaction(application) + setPrintedApplication(application) + setPrinted(true) + + if (division === 'electrical') { + createPdfElectrical() + } else if (division === 'occupancy') { + createPdfOccupancy() + } else console.log('building') + } + const updateOp = async (division: string) => { const post = await postApi(`update-opprinted-${division}`, { data: parseInt(applicationId().toString(), 10), @@ -420,14 +464,22 @@ export default () => { navigate('/profile') } + const voidOp = async (application: string) => { + const response = await voidApi(application) + if (response !== null) return true + return false + } + onMount(async () => { const logged = await checkLogged() if (logged) { + setSelectedType('Print') + await checkDivision() if (isBuilding()) await getListForPrinting('building') if (isOccupancy()) await getListForPrinting('occupancy') - // if (isElectrical()) await getListForPrinting('electrical') + if (isElectrical()) await getListForPrinting('electrical') } }) @@ -669,7 +721,12 @@ export default () => { - + + + + + + Click anywhere to cancel @@ -690,7 +747,7 @@ export default () => { - + @@ -763,7 +820,12 @@ export default () => { - + + + + + + Click anywhere to cancel