Compare commits

...

4 commits

Author SHA1 Message Date
050f98f296 Updated backend 2025-10-24 18:10:58 +08:00
dc912bdef2 Updated main page 2025-10-24 18:10:48 +08:00
c7572fbc90 Cleanup 2025-10-24 18:10:38 +08:00
ca31034a14 Updated backend index 2025-10-24 18:10:17 +08:00
4 changed files with 124 additions and 48 deletions

View file

@ -754,7 +754,7 @@ func connect() {
}) })
case "get-popsdetails-electrical": case "get-popsdetails-electrical":
var result2, result3, result4, result5, result6, result7, result8, result9, result10 string var result2, result3, result4, result5, result6, result7, result8, result9 string
array := []string{} array := []string{}
array2 := []string{} array2 := []string{}
array3 := []string{} array3 := []string{}
@ -764,19 +764,18 @@ func connect() {
array7 := []string{} array7 := []string{}
array8 := []string{} array8 := []string{}
array9 := []string{} array9 := []string{}
array10 := []string{}
results, err := db.Query(`SELECT IFNULL(e.electricalNo, '') AS result, IFNULL(c.customerid, 0) AS result2, IFNULL(IF(c.firstName IS NULL OR c.firstName = '', c.lastName, CONCAT(c.firstName, ' ', IF(c.middleInitial IS NULL OR c.middleInitial = '', '', CONCAT(c.middleInitial, '. ')), c.lastName)), '') AS result3, results, err := db.Query(`SELECT IFNULL(e.electricalNo, '') AS result, IFNULL(c.customerid, 0) AS result2, IFNULL(IF(c.firstName IS NULL OR c.firstName = '', c.lastName, CONCAT(c.firstName, ' ', IF(c.middleInitial IS NULL OR c.middleInitial = '', '', CONCAT(c.middleInitial, '. ')), c.lastName)), '') AS result3,
IFNULL(e.locationofinstallation, '') AS result4, IFNULL(op.amount, '') AS result5, IFNULL(op.amt_Gflgu, '') AS result6, IFNULL(op.amt_Gfdpwh, '') AS result7, IFNULL(op.amt_Tfbo, '') AS result8, IFNULL(ref.accountdescription, '') AS result9, IFNULL(ref.accountcode, '') AS result10 IFNULL(e.locationofinstallation, '') AS result4, IFNULL(op.amount, '') AS result5, IFNULL(op.amt_Gflgu, '') AS result6, IFNULL(op.amt_Gfdpwh, '') AS result7, IFNULL(op.amt_Tfbo, '') AS result8, IFNULL(ref.accountcode, '') AS result9
FROM electrical e JOIN customer c ON e.customerid = c.customerid JOIN electrical_orderofpayment_new op ON e.electricalid = op.electricalid JOIN ref_bldgcomputationsheet ref ON op.ref_bldgcomputationsheetid = ref.ref_bldgcomputationsheetid FROM electrical e JOIN customer c ON e.customerid = c.customerid JOIN electrical_orderofpayment_new op ON e.electricalid = op.electricalid JOIN ref_bldgcomputationsheet ref ON op.ref_bldgcomputationsheetid = ref.ref_bldgcomputationsheetid
WHERE e.electricalid = ?`, data) WHERE e.electricalid = ?`, data)
if err != nil { if err != nil {
c.AbortWithError(http.StatusBadRequest, err) c.AbortWithError(http.StatusBadRequest, err)
c.String(http.StatusBadRequest, err.Error()) c.String(http.StatusBadRequest, err.Error())
return return
} }
for results.Next() { for results.Next() {
err = results.Scan(&result, &result2, &result3, &result4, &result5, &result6, &result7, &result8, &result9, &result10) err = results.Scan(&result, &result2, &result3, &result4, &result5, &result6, &result7, &result8, &result9)
if err != nil { if err != nil {
c.AbortWithError(http.StatusBadRequest, err) c.AbortWithError(http.StatusBadRequest, err)
c.String(http.StatusBadRequest, err.Error()) c.String(http.StatusBadRequest, err.Error())
@ -791,19 +790,17 @@ func connect() {
array7 = append(array7, result7) array7 = append(array7, result7)
array8 = append(array8, result8) array8 = append(array8, result8)
array9 = append(array9, result9) array9 = append(array9, result9)
array10 = append(array10, result10)
} }
c.JSON(http.StatusOK, gin.H{ c.JSON(http.StatusOK, gin.H{
"result": array, "result": array,
"result2": array2, "result2": array2,
"result3": array3, "result3": array3,
"result4": array4, "result4": array4,
"result5": array5, "result5": array5,
"result6": array6, "result6": array6,
"result7": array7, "result7": array7,
"result8": array8, "result8": array8,
"result9": array9, "result9": array9,
"result10": array10,
}) })
} }
}) })
@ -959,18 +956,24 @@ func connect() {
dbpost, err := db.Prepare("UPDATE electricaldocflowtxn SET is_approve = 1 WHERE electricalid = ? AND remarks = ?") dbpost, err := db.Prepare("UPDATE electricaldocflowtxn SET is_approve = 1 WHERE electricalid = ? AND remarks = ?")
if err != nil { if err != nil {
panic(err.Error()) c.AbortWithError(http.StatusInternalServerError, err)
c.String(http.StatusInternalServerError, "Internal Server Error")
return
} }
defer dbpost.Close() defer dbpost.Close()
exec, err := dbpost.Exec(updateDocflowData.Data, updateDocflowData.Data2) exec, err := dbpost.Exec(updateDocflowData.Data, updateDocflowData.Data2)
if err != nil { if err != nil {
panic(err.Error()) c.AbortWithError(http.StatusInternalServerError, err)
c.String(http.StatusInternalServerError, "Internal Server Error")
return
} }
affect, err := exec.RowsAffected() affect, err := exec.RowsAffected()
if err != nil { if err != nil {
panic(err.Error()) c.AbortWithError(http.StatusInternalServerError, err)
c.String(http.StatusInternalServerError, "Internal Server Error")
return
} }
if affect > 0 { if affect > 0 {
@ -1115,5 +1118,52 @@ func connect() {
} }
}) })
router.POST("/api/update-opapproved-electrical", 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 electrical_orderofpayment_new SET is_approve = 1 WHERE electricalid = ? 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.Run(":4320") router.Run(":4320")
} }

View file

@ -2,22 +2,32 @@
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover" />
<meta name="name" content="OCBO e-Sign Server" />
<meta name="description" content="Backend application for OCBO e-Sign" />
<meta name="author" content="Patrick Alvin Alcala" />
<title>OCBO e-Sign Server</title> <title>OCBO e-Sign Server</title>
<style> <style>
body { body {
display: flex;
flex-direction: column;
background-color: #16212c; background-color: #16212c;
} }
.title { .title {
font-family: 'Roboto', sans-serif; font-family: 'Roboto', sans-serif;
width: 100%;
text-align: center; text-align: center;
margin: 0; margin: 0;
padding: 20px; padding: 20px 0;
color: white; color: rgba(255, 255, 255, 0.848);
font-size: 3.25rem; font-size: 3.25rem;
} }
@media only screen and (max-width: 768px) {
.title {
font-size: 1.25rem;
}
}
</style> </style>
</head> </head>

View file

@ -12,7 +12,6 @@
<meta property="og:description" content="Digital Signature added for OCBO (Office of the City Building Official)" /> <meta property="og:description" content="Digital Signature added for OCBO (Office of the City Building Official)" />
<meta property="og:type" content="website" /> <meta property="og:type" content="website" />
<link rel="icon" type="image/svg+xml" href="/favicon.png" /> <link rel="icon" type="image/svg+xml" href="/favicon.png" />
<!-- <link rel="preconnect" href="https://cdn.jsdelivr.net" /> -->
<title>OCBO e-Sign</title> <title>OCBO e-Sign</title>
</head> </head>

View file

@ -14,6 +14,8 @@ import { _applicationNo, _date, _optn, _name, _location, _type, _assessor, _feeL
const API = import.meta.env.VITE_BACKEND const API = import.meta.env.VITE_BACKEND
const PESO = import.meta.env.VITE_PESO const PESO = import.meta.env.VITE_PESO
const ID = import.meta.env.VITE_HEADID const ID = import.meta.env.VITE_HEADID
const NAME = import.meta.env.VITE_HEAD
const PUBLICIP = import.meta.env.VITE_PUBLICIP
export default () => { export default () => {
const navigate = useNavigate() const navigate = useNavigate()
@ -108,9 +110,10 @@ export default () => {
updateOrderofpayment = await updateOp() updateOrderofpayment = await updateOp()
if (updateOrderofpayment) { if (updateOrderofpayment) {
postTransaction()
postPops(application)
setApprovedApplication(application) setApprovedApplication(application)
setApproved(true) setApproved(true)
postTransaction()
} }
} }
@ -142,34 +145,48 @@ export default () => {
} }
} }
const getPrintDetails = async (id: number) => { // const getPrintDetails = async (id: number) => {
const response = await ofetch(API + 'get-printdetails-electrical/' + id) // const response = await ofetch(API + 'get-printdetails-electrical/' + id)
const applicationno = response.result // const applicationno = response.result
const date = response.result2 // const date = response.result2
const location = response.result3 // const location = response.result3
const name = response.result8 // const name = response.result8
const type = `${response.result4} - ${response.result5}` // const type = `${response.result4} - ${response.result5}`
const assessor = response.result7 // const assessor = response.result7
_optn.set('M' + applicationno.split('-')[0] + applicationno.split('-')[1]) // _optn.set('M' + applicationno.split('-')[0] + applicationno.split('-')[1])
_applicationNo.set(applicationno) // _applicationNo.set(applicationno)
_date.set(dayjs(date).format('MMMM DD, YYYY')) // _date.set(dayjs(date).format('MMMM DD, YYYY'))
_name.set(name) // _name.set(name)
_location.set(location) // _location.set(location)
_type.set(type) // _type.set(type)
_assessor.set(assessor) // _assessor.set(assessor)
_assessorid.set(employeeId()) // _assessorid.set(employeeId())
} // }
const postPops = async (application: string) => { const postPops = async (application: string) => {
const applicationId = await ofetch(API + 'get-idbyapplication-electrical/' + application, { parseResponse: JSON.parse })
const response = await ofetch(API + 'get-popsdetails-electrical/' + applicationId.result, { parseResponse: JSON.parse })
const applicationNo = response.result[0]
const customerid = response.result2[0]
const customerName = response.result3[0]
const location = response.result4[0]
const amountList = response.result5
const lguList = response.result6
const dpwhList = response.result7
const boList = response.result8
const codeList = response.result9
const today = new Date() const today = new Date()
const formattedDate = dayjs(today).format('YYYY-MM-DD') const formattedDate = dayjs(today).format('YYYY-MM-DD')
const formattedDatewithTime = dayjs(today).format('YYYY-MM-DD HH:mm:ss') const formattedDatewithTime = dayjs(today).format('YYYY-MM-DD HH:mm:ss')
await ofetch(API + 'update-opapproved-electrical', { for (let i = 0; i < applicationNo.length; i++) {
method: 'POST', await ofetch(API + 'post-pops', {
body: { data: application, data2: formattedDate }, method: 'POST',
}) body: { data: application, data2: formattedDate, data3: customerid, data4: customerName, data5: location, data6: codeList[i], data7: amountList[i], data8: NAME, data9: formattedDatewithTime, data10: lguList[i], data11: dpwhList[i], data12: boList[i], data13: PUBLICIP },
})
}
} }
// const calculateAmounts = () => { // const calculateAmounts = () => {