From ca31034a14c7fac0e853769ae9b99ed27e4d2e19 Mon Sep 17 00:00:00 2001 From: Patrick Alvin Alcala Date: Fri, 24 Oct 2025 18:10:17 +0800 Subject: [PATCH 1/4] Updated backend index --- backend/static/index.html | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/backend/static/index.html b/backend/static/index.html index 1184893..7008cf4 100644 --- a/backend/static/index.html +++ b/backend/static/index.html @@ -2,22 +2,32 @@ - + + + + OCBO e-Sign Server From c7572fbc90d81826473091b39fbe3f583479d251 Mon Sep 17 00:00:00 2001 From: Patrick Alvin Alcala Date: Fri, 24 Oct 2025 18:10:38 +0800 Subject: [PATCH 2/4] Cleanup --- index.html | 1 - 1 file changed, 1 deletion(-) diff --git a/index.html b/index.html index ad43fc4..48829a6 100644 --- a/index.html +++ b/index.html @@ -12,7 +12,6 @@ - OCBO e-Sign From dc912bdef2098068bb9e1555fe711ad4a5bf2c8a Mon Sep 17 00:00:00 2001 From: Patrick Alvin Alcala Date: Fri, 24 Oct 2025 18:10:48 +0800 Subject: [PATCH 3/4] Updated main page --- src/pages/MainPage/Main.tsx | 61 ++++++++++++++++++++++++------------- 1 file changed, 39 insertions(+), 22 deletions(-) diff --git a/src/pages/MainPage/Main.tsx b/src/pages/MainPage/Main.tsx index cf38e9d..9043640 100644 --- a/src/pages/MainPage/Main.tsx +++ b/src/pages/MainPage/Main.tsx @@ -14,6 +14,8 @@ import { _applicationNo, _date, _optn, _name, _location, _type, _assessor, _feeL const API = import.meta.env.VITE_BACKEND const PESO = import.meta.env.VITE_PESO const ID = import.meta.env.VITE_HEADID +const NAME = import.meta.env.VITE_HEAD +const PUBLICIP = import.meta.env.VITE_PUBLICIP export default () => { const navigate = useNavigate() @@ -108,9 +110,10 @@ export default () => { updateOrderofpayment = await updateOp() if (updateOrderofpayment) { + postTransaction() + postPops(application) setApprovedApplication(application) setApproved(true) - postTransaction() } } @@ -142,34 +145,48 @@ export default () => { } } - 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 + // 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()) - } + // _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 (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 formattedDate = dayjs(today).format('YYYY-MM-DD') const formattedDatewithTime = dayjs(today).format('YYYY-MM-DD HH:mm:ss') - await ofetch(API + 'update-opapproved-electrical', { - method: 'POST', - body: { data: application, data2: formattedDate }, - }) + for (let i = 0; i < applicationNo.length; i++) { + await ofetch(API + 'post-pops', { + 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 = () => { From 050f98f2960c885f3396a67b25dcf68659b94121 Mon Sep 17 00:00:00 2001 From: Patrick Alvin Alcala Date: Fri, 24 Oct 2025 18:10:58 +0800 Subject: [PATCH 4/4] Updated backend --- backend/main.go | 92 ++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 71 insertions(+), 21 deletions(-) diff --git a/backend/main.go b/backend/main.go index 4a7ae48..66a416b 100644 --- a/backend/main.go +++ b/backend/main.go @@ -754,7 +754,7 @@ func connect() { }) 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{} array2 := []string{} array3 := []string{} @@ -764,19 +764,18 @@ func connect() { array7 := []string{} array8 := []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, - 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 - 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) + 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.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 + WHERE e.electricalid = ?`, data) if err != nil { c.AbortWithError(http.StatusBadRequest, err) c.String(http.StatusBadRequest, err.Error()) return } 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 { c.AbortWithError(http.StatusBadRequest, err) c.String(http.StatusBadRequest, err.Error()) @@ -791,19 +790,17 @@ func connect() { array7 = append(array7, result7) array8 = append(array8, result8) array9 = append(array9, result9) - array10 = append(array10, result10) } c.JSON(http.StatusOK, gin.H{ - "result": array, - "result2": array2, - "result3": array3, - "result4": array4, - "result5": array5, - "result6": array6, - "result7": array7, - "result8": array8, - "result9": array9, - "result10": array10, + "result": array, + "result2": array2, + "result3": array3, + "result4": array4, + "result5": array5, + "result6": array6, + "result7": array7, + "result8": array8, + "result9": array9, }) } }) @@ -959,18 +956,24 @@ func connect() { dbpost, err := db.Prepare("UPDATE electricaldocflowtxn SET is_approve = 1 WHERE electricalid = ? AND remarks = ?") if err != nil { - panic(err.Error()) + 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 { - panic(err.Error()) + c.AbortWithError(http.StatusInternalServerError, err) + c.String(http.StatusInternalServerError, "Internal Server Error") + return } affect, err := exec.RowsAffected() if err != nil { - panic(err.Error()) + c.AbortWithError(http.StatusInternalServerError, err) + c.String(http.StatusInternalServerError, "Internal Server Error") + return } 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") }