diff --git a/backend/main.go b/backend/main.go index 66a416b..4a7ae48 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 string + var result2, result3, result4, result5, result6, result7, result8, result9, result10 string array := []string{} array2 := []string{} array3 := []string{} @@ -764,18 +764,19 @@ 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.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) + 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) 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) + err = results.Scan(&result, &result2, &result3, &result4, &result5, &result6, &result7, &result8, &result9, &result10) if err != nil { c.AbortWithError(http.StatusBadRequest, err) c.String(http.StatusBadRequest, err.Error()) @@ -790,17 +791,19 @@ 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, + "result": array, + "result2": array2, + "result3": array3, + "result4": array4, + "result5": array5, + "result6": array6, + "result7": array7, + "result8": array8, + "result9": array9, + "result10": array10, }) } }) @@ -956,24 +959,18 @@ func connect() { dbpost, err := db.Prepare("UPDATE electricaldocflowtxn SET is_approve = 1 WHERE electricalid = ? AND remarks = ?") if err != nil { - c.AbortWithError(http.StatusInternalServerError, err) - c.String(http.StatusInternalServerError, "Internal Server Error") - return + panic(err.Error()) } 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 + panic(err.Error()) } affect, err := exec.RowsAffected() if err != nil { - c.AbortWithError(http.StatusInternalServerError, err) - c.String(http.StatusInternalServerError, "Internal Server Error") - return + panic(err.Error()) } if affect > 0 { @@ -1118,52 +1115,5 @@ 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") } diff --git a/backend/static/index.html b/backend/static/index.html index 7008cf4..1184893 100644 --- a/backend/static/index.html +++ b/backend/static/index.html @@ -2,32 +2,22 @@ - - - - + OCBO e-Sign Server diff --git a/index.html b/index.html index 48829a6..ad43fc4 100644 --- a/index.html +++ b/index.html @@ -12,6 +12,7 @@ + OCBO e-Sign diff --git a/src/pages/MainPage/Main.tsx b/src/pages/MainPage/Main.tsx index 9043640..cf38e9d 100644 --- a/src/pages/MainPage/Main.tsx +++ b/src/pages/MainPage/Main.tsx @@ -14,8 +14,6 @@ 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() @@ -110,10 +108,9 @@ export default () => { updateOrderofpayment = await updateOp() if (updateOrderofpayment) { - postTransaction() - postPops(application) setApprovedApplication(application) setApproved(true) + postTransaction() } } @@ -145,48 +142,34 @@ 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') - 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 }, - }) - } + await ofetch(API + 'update-opapproved-electrical', { + method: 'POST', + body: { data: application, data2: formattedDate }, + }) } // const calculateAmounts = () => {