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"`
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue