Added bldgadditional
This commit is contained in:
parent
bc83099819
commit
99608062ff
4 changed files with 136 additions and 73 deletions
118
backend/main.go
118
backend/main.go
|
|
@ -444,7 +444,7 @@ func connect() {
|
|||
array2 := []string{}
|
||||
|
||||
results, err := db.Query(`SELECT IFNULL(DATE_FORMAT(b.txndate, '%M %d, %Y'), '') AS result, IFNULL(REPLACE(b.remarks, 'RECEIVE', 'RECEIVED'), '') AS result2
|
||||
FROM occupancydocflowtxn b, occupancy o WHERE o.occupancyid = b.occupancyreceivingid AND o.controlNo = ? ORDER BY b.occupancydocflowtxnid DESC`, data)
|
||||
FROM occupancydocflowtxn b, occupancy o WHERE o.occupancyid = b.occupancyreceivingid AND o.controlNo = ? ORDER BY b.occupancydocflowtxnid DESC`, data)
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusBadRequest, err)
|
||||
c.String(http.StatusBadRequest, err.Error())
|
||||
|
|
@ -1030,6 +1030,28 @@ func connect() {
|
|||
"result8": array8,
|
||||
"result9": array9,
|
||||
})
|
||||
|
||||
case "check-bldgadditional-approval":
|
||||
err := db.QueryRow("SELECT COUNT(building_orderofpaymentid) AS result FROM building_orderofpayment WHERE occupancyid = (SELECT occupancyid FROM occupancy WHERE controlNo = ?) AND for_approval = 1 AND is_approve = 0 AND popstransmitted = 0 AND is_paid = 0 AND is_delete = 0", data).Scan(&result)
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusBadRequest, err)
|
||||
c.String(http.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"result": result,
|
||||
})
|
||||
|
||||
case "check-bldgadditional-printing":
|
||||
err := db.QueryRow("SELECT COUNT(building_orderofpaymentid) AS result FROM building_orderofpayment WHERE occupancyid = (SELECT occupancyid FROM occupancy WHERE controlNo = ?) AND for_approval = 1 AND is_approve = 1 AND popstransmitted = 0 AND is_paid = 0 AND is_delete = 0", data).Scan(&result)
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusBadRequest, err)
|
||||
c.String(http.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"result": result,
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
|
|
@ -1259,6 +1281,53 @@ func connect() {
|
|||
}
|
||||
})
|
||||
|
||||
// router.POST("/api/update-docflow-bldgadditional", middleware.TokenChecker(), func(c *gin.Context) {
|
||||
// type UpdateDocflowData struct {
|
||||
// Data string `json:"data"`
|
||||
// Data2 string `json:"data2"`
|
||||
// }
|
||||
// var updateDocflowData UpdateDocflowData
|
||||
// if err := c.ShouldBindJSON(&updateDocflowData); err != nil {
|
||||
// c.String(http.StatusBadRequest, "Invalid request body")
|
||||
// return
|
||||
// }
|
||||
|
||||
// c.Writer.Header().Set("X-XSS-Protection", "1; mode=block")
|
||||
// c.Writer.Header().Set("X-Content-Type-Options", "nosniff")
|
||||
// c.Writer.Header().Set("X-DNS-Prefetch-Control", "off")
|
||||
// c.Writer.Header().Set("X-Frame-Options", "DENY")
|
||||
// c.Writer.Header().Set("X-Download-Options", "noopen")
|
||||
// c.Writer.Header().Set("Referrer-Policy", "no-referrer")
|
||||
|
||||
// dbpost, err := db.Prepare("UPDATE occupancydocflowtxn SET is_approve = 1 WHERE remarks = ? AND occupancyreceivingid = (SELECT occupancyid FROM occupancy WHERE controlNo = ?)")
|
||||
// if err != nil {
|
||||
// c.AbortWithError(http.StatusInternalServerError, err)
|
||||
// c.String(http.StatusInternalServerError, "Internal Server Error")
|
||||
// return
|
||||
// }
|
||||
// defer dbpost.Close()
|
||||
|
||||
// exec, err := dbpost.Exec(updateDocflowData.Data, updateDocflowData.Data2)
|
||||
// if err != nil {
|
||||
// c.AbortWithError(http.StatusInternalServerError, err)
|
||||
// c.String(http.StatusInternalServerError, "Internal Server Error")
|
||||
// return
|
||||
// }
|
||||
|
||||
// affect, err := exec.RowsAffected()
|
||||
// if err != nil {
|
||||
// c.AbortWithError(http.StatusInternalServerError, err)
|
||||
// c.String(http.StatusInternalServerError, "Internal Server Error")
|
||||
// return
|
||||
// }
|
||||
|
||||
// if affect > 0 {
|
||||
// c.String(http.StatusOK, "Success on Updating Docflow on Electrical")
|
||||
// } else {
|
||||
// c.String(http.StatusInternalServerError, "Failed on Updating Docflow on Electrical")
|
||||
// }
|
||||
// })
|
||||
|
||||
router.POST("/api/update-docflow-electrical", middleware.TokenChecker(), func(c *gin.Context) {
|
||||
type UpdateDocflowData struct {
|
||||
Data string `json:"data"`
|
||||
|
|
@ -1528,6 +1597,53 @@ func connect() {
|
|||
}
|
||||
})
|
||||
|
||||
router.POST("/api/update-opapproved-bldgadditional", middleware.TokenChecker(), func(c *gin.Context) {
|
||||
type UpdateOpData struct {
|
||||
Data int `json:"data"`
|
||||
}
|
||||
var updateOpData UpdateOpData
|
||||
if err := c.ShouldBindJSON(&updateOpData); err != nil {
|
||||
c.AbortWithError(http.StatusBadRequest, err)
|
||||
c.String(http.StatusBadRequest, "Invalid request body")
|
||||
return
|
||||
}
|
||||
|
||||
c.Writer.Header().Set("X-XSS-Protection", "1; mode=block")
|
||||
c.Writer.Header().Set("X-Content-Type-Options", "nosniff")
|
||||
c.Writer.Header().Set("X-DNS-Prefetch-Control", "off")
|
||||
c.Writer.Header().Set("X-Frame-Options", "DENY")
|
||||
c.Writer.Header().Set("X-Download-Options", "noopen")
|
||||
c.Writer.Header().Set("Referrer-Policy", "no-referrer")
|
||||
|
||||
dbpost, err := db.Prepare("UPDATE building_orderofpayment SET is_approve = 1 WHERE occupancyid = ? AND for_approval = 1 AND is_paid = 0")
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusInternalServerError, err)
|
||||
c.String(http.StatusInternalServerError, "Internal Server Error")
|
||||
return
|
||||
}
|
||||
defer dbpost.Close()
|
||||
|
||||
exec, err := dbpost.Exec(updateOpData.Data)
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusInternalServerError, err)
|
||||
c.String(http.StatusInternalServerError, "Internal Server Error")
|
||||
return
|
||||
}
|
||||
|
||||
affect, err := exec.RowsAffected()
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusInternalServerError, err)
|
||||
c.String(http.StatusInternalServerError, "Internal Server Error")
|
||||
return
|
||||
}
|
||||
|
||||
if affect > 0 {
|
||||
c.String(http.StatusOK, "Success on Updating Order of Payment on Approval")
|
||||
} else {
|
||||
c.String(http.StatusInternalServerError, "Failed on Updating Order of Payment on Approval")
|
||||
}
|
||||
})
|
||||
|
||||
router.POST("/api/update-opapproved-electrical", middleware.TokenChecker(), func(c *gin.Context) {
|
||||
type UpdateOpData struct {
|
||||
Data int `json:"data"`
|
||||
|
|
|
|||
|
|
@ -4,14 +4,13 @@ import { FiLogOut } from 'solid-icons/fi'
|
|||
import { Tabs } from '@kobalte/core/tabs'
|
||||
import { onMount, createSignal, Show, createEffect } from 'solid-js'
|
||||
import dayjs from 'dayjs'
|
||||
import { checkConnection, createPdf } from '../../utils/functions'
|
||||
import { checkConnection, createPdfOccupancy, createPdfElectrical } from '../../utils/functions'
|
||||
import { FaSolidThumbsUp } from 'solid-icons/fa'
|
||||
import { _employeeName, _employeeId } from '../../stores/employee'
|
||||
import { useNavigate } from '@solidjs/router'
|
||||
import { _applicationNo, _date, _optn, _name, _location, _type, _assessor, _feeList, _codeList, _amountList, _signatureAssessor, _signatureApprover, _assessorid, _approvedDate, _assessedDate, _units, _totalUnits, _floorArea } from '../../stores/pdfinfo'
|
||||
import { VsRefresh } from 'solid-icons/vs'
|
||||
import { getApi, getApiMulti, postApi } from '../../utils/functions'
|
||||
import createPdfOccupancy from '../../utils/functions/createPdfOccupancy'
|
||||
|
||||
const PESO = import.meta.env.VITE_PESO
|
||||
|
||||
|
|
@ -42,6 +41,8 @@ export default () => {
|
|||
|
||||
const [filter, setFilter] = createSignal('')
|
||||
|
||||
let bldgadditional = false
|
||||
|
||||
const checkAccess = async (access: string) => {
|
||||
const response = await getApi('check-access', access, employeeId())
|
||||
const result = response
|
||||
|
|
@ -226,6 +227,9 @@ export default () => {
|
|||
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') {
|
||||
const additionalResult = await getApi('check-bldgadditional-approval', application)
|
||||
bldgadditional = additionalResult > 0
|
||||
|
||||
await setNewStatus(division, 'OCCUPANCY ORDER OF PAYMENT PRINTED', '173', 'OCCOPPRINTED', 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)
|
||||
|
|
@ -239,7 +243,7 @@ export default () => {
|
|||
setPrintedApplication(application)
|
||||
setPrinted(true)
|
||||
if (division === 'electrical') {
|
||||
createPdf()
|
||||
createPdfElectrical()
|
||||
} else createPdfOccupancy()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,6 +51,8 @@ export default () => {
|
|||
|
||||
const [apology, setApology] = createSignal(false)
|
||||
|
||||
let bldgadditional = false
|
||||
|
||||
const getListForApproval = async () => {
|
||||
const responseE = await getApiMulti('get-listopapproval-electrical')
|
||||
setApplicationListElectrical(responseE.result)
|
||||
|
|
@ -112,7 +114,7 @@ export default () => {
|
|||
const total = calculateTotal(op.result4)
|
||||
const formattedTotal = new Intl.NumberFormat('en-US', {
|
||||
minimumFractionDigits: 2,
|
||||
maximumFractionDigits: 2,
|
||||
// maximumFractionDigits: 2,
|
||||
}).format(total)
|
||||
setTotalOp(formattedTotal)
|
||||
setDateOp(dayjs(op.result5[0]).format('MMMM DD, YYYY'))
|
||||
|
|
@ -124,35 +126,6 @@ export default () => {
|
|||
return total
|
||||
}
|
||||
|
||||
// const approveHandler = async (application: string) => {
|
||||
// let signed: boolean = false
|
||||
// let forprinting: boolean = false
|
||||
// let updateOrderofpayment: boolean = false
|
||||
|
||||
// setConnected(await checkConnection())
|
||||
// if (connected() === false) {
|
||||
// setErrorMessage('No Connection on Server')
|
||||
// return
|
||||
// }
|
||||
|
||||
// signed = await setNewStatus('ELECTRICAL ORDER OF PAYMENT APPROVED AND SIGNED', '170', 'ELECOPAPPROVEDSIGNED', 1)
|
||||
// const approvedid = await getIdByApplication(application)
|
||||
// updateDocflow(approvedid, 'FOR ELECTRICAL ORDER OF PAYMENT APPROVAL')
|
||||
// if (!signed) return
|
||||
|
||||
// forprinting = await setNewStatus('FOR ELECTRICAL ORDER OF PAYMENT PRINTING', '95', 'ELECOPPRINT', 0)
|
||||
// if (!forprinting) return
|
||||
|
||||
// updateOrderofpayment = await updateOp()
|
||||
|
||||
// if (updateOrderofpayment) {
|
||||
// postTransaction()
|
||||
// postPops(application)
|
||||
// setApprovedApplication(application)
|
||||
// setApproved(true)
|
||||
// }
|
||||
// }
|
||||
|
||||
const approveHandler = async (division: string, application: string) => {
|
||||
let signed: boolean = false
|
||||
let forprinting: boolean = false
|
||||
|
|
@ -166,7 +139,6 @@ export default () => {
|
|||
|
||||
if (division === 'electrical') {
|
||||
signed = await setNewStatus(division, 'ELECTRICAL ORDER OF PAYMENT APPROVED AND SIGNED', '170', 'ELECOPAPPROVEDSIGNED', 1)
|
||||
// const approvedid = await getIdByApplication(division, application)
|
||||
updateDocflow(division, application, 'FOR ELECTRICAL ORDER OF PAYMENT APPROVAL')
|
||||
if (!signed) return
|
||||
|
||||
|
|
@ -182,10 +154,12 @@ export default () => {
|
|||
setApproved(true)
|
||||
}
|
||||
} else if (division === 'occupancy') {
|
||||
const additionalResult = await getApi('check-bldgadditional-approval', application)
|
||||
bldgadditional = additionalResult > 0
|
||||
|
||||
signed = await setNewStatus(division, 'OCCUPANCY ORDER OF PAYMENT APPROVED AND SIGNED', '172', 'OCCOPAPPROVEDSIGNED', 1)
|
||||
// const approvedid = await getIdByApplication(division, application)
|
||||
updateDocflow(division, application, 'FOR OCCUPANCY RECOMMENDING APPROVAL')
|
||||
updateDocflow(division, application, 'FOR ADDITIONAL ORDER OF PAYMENT RECOMMENDING APPROVAL')
|
||||
if (bldgadditional) updateDocflow(division, application, 'FOR ADDITIONAL ORDER OF PAYMENT RECOMMENDING APPROVAL')
|
||||
if (!signed) return
|
||||
|
||||
forprinting = await setNewStatus(division, 'APPROVED FOR PRINTING OF BUREAU OF FIRE AND ORDER OF PAYMENT', '23', 'OCORDEROFPAYMENT', 0)
|
||||
|
|
@ -218,29 +192,12 @@ export default () => {
|
|||
if (division === 'electrical') {
|
||||
return await postApi('update-opapproved-electrical', { data: parseInt(applicationId().toString()) })
|
||||
} else {
|
||||
return await postApi('update-opapproved-occupancy', { data: parseInt(applicationId().toString()) })
|
||||
const occupancy = await postApi('update-opapproved-occupancy', { data: parseInt(applicationId().toString()) })
|
||||
if (bldgadditional) await postApi('update-opapproved-bldgadditional', { data: parseInt(applicationId().toString()) })
|
||||
return occupancy
|
||||
}
|
||||
}
|
||||
|
||||
// const getPrintDetails = async (id: number) => {
|
||||
// const response = await ofetch(API + 'get-printdetails-electrical/' + id)
|
||||
// const applicationno = response.result
|
||||
// const date = response.result2
|
||||
// const location = response.result3
|
||||
// const name = response.result8
|
||||
// const type = `${response.result4} - ${response.result5}`
|
||||
// const assessor = response.result7
|
||||
|
||||
// _optn.set('M' + applicationno.split('-')[0] + applicationno.split('-')[1])
|
||||
// _applicationNo.set(applicationno)
|
||||
// _date.set(dayjs(date).format('MMMM DD, YYYY'))
|
||||
// _name.set(name)
|
||||
// _location.set(location)
|
||||
// _type.set(type)
|
||||
// _assessor.set(assessor)
|
||||
// _assessorid.set(employeeId())
|
||||
// }
|
||||
|
||||
const postPops = async (division: string, application: string) => {
|
||||
let response
|
||||
|
||||
|
|
@ -335,25 +292,9 @@ export default () => {
|
|||
}
|
||||
|
||||
const updateDocflow = async (division: string, application: string, status: string) => {
|
||||
// if (division === 'electrical') {
|
||||
// await postApi('update-docflow-electrical', { data: parseInt(applicationid.toString()), data2: status })
|
||||
// } else if (division === 'occupancy') {
|
||||
// await postApi('update-docflow-occupancy', { data: parseInt(applicationid.toString()), data2: status })
|
||||
// }
|
||||
|
||||
await postApi(`update-docflow-${division}`, { data: status, data2: application })
|
||||
}
|
||||
|
||||
// const getIdByApplication = async (division: string, applicationNo: string) => {
|
||||
// let response
|
||||
// if (division === 'electrical') {
|
||||
// response = await getApi('get-idbyapplication-electrical', applicationNo)
|
||||
// } else if (division === 'occupancy') {
|
||||
// response = await getApi('get-idbyapplication-occupancy', applicationNo)
|
||||
// }
|
||||
// return parseInt(response)
|
||||
// }
|
||||
|
||||
const refresh = async (division: string) => {
|
||||
if (division === 'electrical') {
|
||||
await load('electrical')
|
||||
|
|
|
|||
|
|
@ -23,3 +23,5 @@ export const _assessedDate = atom('')
|
|||
export const _units = atom(0)
|
||||
export const _totalUnits = atom(0)
|
||||
export const _floorArea = atom(0)
|
||||
|
||||
export const _additional = atom(false)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue