Added occupancy apis
This commit is contained in:
parent
79a3e508dc
commit
7f14cbd044
1 changed files with 148 additions and 14 deletions
162
backend/main.go
162
backend/main.go
|
|
@ -158,6 +158,35 @@ func connect() {
|
|||
"result2": array2,
|
||||
})
|
||||
|
||||
case "get-listopprinting-occupancy":
|
||||
var result2 string
|
||||
|
||||
array := []string{}
|
||||
array2 := []string{}
|
||||
|
||||
results, err := db.Query(`SELECT IFNULL(o.controlNo, '') AS result, 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 result2
|
||||
FROM occupancy o JOIN customer c ON o.customerid = c.customerid JOIN ref_occupancy_type rot ON o.ref_occupancy_typeid = rot.ref_occupancy_typeid JOIN ref_occupancy ro ON rot.ref_occupancyid = ro.ref_occupancyid JOIN occupancydocflowtxn od ON o.occupancyid = od.occupancyreceivingid JOIN (SELECT occupancyreceivingid, MAX(occupancydocflowtxnid) AS latest_occupancydocflowtxnid FROM occupancydocflowtxn GROUP BY occupancyreceivingid) latest_doc ON od.occupancyreceivingid = latest_doc.occupancyreceivingid AND od.occupancydocflowtxnid = latest_doc.latest_occupancydocflowtxnid
|
||||
WHERE remarks = ? AND is_approve = 0 ORDER BY o.controlNo ASC`, "APPROVED FOR PRINTING OF BUREAU OF FIRE AND ORDER OF PAYMENT")
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusBadRequest, err)
|
||||
c.String(http.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
for results.Next() {
|
||||
err = results.Scan(&result, &result2)
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusBadRequest, err)
|
||||
c.String(http.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
array = append(array, result)
|
||||
array2 = append(array2, result2)
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"result": array,
|
||||
"result2": array2,
|
||||
})
|
||||
|
||||
case "get-listopprinting-electrical":
|
||||
var result2 string
|
||||
|
||||
|
|
@ -262,7 +291,7 @@ func connect() {
|
|||
|
||||
})
|
||||
|
||||
router.GET("/api/:method/:data", func(c *gin.Context) {
|
||||
router.GET("/api/:method/:data/fetch-data", func(c *gin.Context) {
|
||||
var result string
|
||||
method := c.Param("method")
|
||||
data := c.Param("data")
|
||||
|
|
@ -749,6 +778,29 @@ func connect() {
|
|||
"result": result,
|
||||
})
|
||||
|
||||
case "get-printdetails-occupancy":
|
||||
var result2, result3, result4, result5, result6, result7, result8 string
|
||||
|
||||
err := db.QueryRow(`SELECT DISTINCT IFNULL(o.controlNo, '') AS result, IFNULL(op.opDate, '') AS result2, IFNULL(r.locationofconstruction, '') AS result3, IFNULL(ro.occupancy, '') AS result4, IFNULL(rot.occupancyType, '') AS result5, IFNULL(o.noOfPermitsApplied, '') AS result6, IFNULL(e.employeename, '') AS result7,
|
||||
IF(cu.firstName IS NULL OR cu.firstName = '', cu.lastName, CONCAT(cu.firstName, ' ', IF(cu.middleInitial IS NULL OR cu.middleInitial = '', '', CONCAT(cu.middleInitial, '. ')), cu.lastName) ) AS result8
|
||||
FROM occupancy o LEFT JOIN receiving r on o.bldgApplicationNo = r.applicationNo JOIN occupancy_orderofpayment op ON o.occupancyid = op.occupancyid JOIN ref_occupancy_type rot ON o.ref_occupancy_typeid = rot.ref_occupancy_typeid JOIN ref_occupancy ro ON rot.ref_occupancyid = ro.ref_occupancyid JOIN customer cu ON o.customerid = cu.customerid JOIN employee e ON op.assessedbyid = e.employeeid
|
||||
WHERE op.is_approve = 1 AND op.for_approval = 1 AND op.is_release = 0 AND is_paid = 0 AND popstransmitted = 0 AND o.occupancyid = ?`, data).Scan(&result, &result2, &result3, &result4, &result5, &result6, &result7, &result8)
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusBadRequest, err)
|
||||
c.String(http.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"result": result,
|
||||
"result2": result2,
|
||||
"result3": result3,
|
||||
"result4": result4,
|
||||
"result5": result5,
|
||||
"result6": result6,
|
||||
"result7": result7,
|
||||
"result8": result8,
|
||||
})
|
||||
|
||||
case "get-printdetails-electrical":
|
||||
var result2, result3, result4, result5, result6, result7, result8 string
|
||||
|
||||
|
|
@ -772,15 +824,46 @@ func connect() {
|
|||
"result8": result8,
|
||||
})
|
||||
|
||||
case "get-printdetailsfees-occupancy":
|
||||
var result2, result3 string
|
||||
array := []string{}
|
||||
array2 := []string{}
|
||||
array3 := []string{}
|
||||
|
||||
results, err := db.Query(`SELECT IFNULL(ref.accountdescription, '') AS result, IFNULL(ref.accountcode, '') AS result2, IFNULL(op.amount, '') AS result3
|
||||
FROM occupancy o JOIN occupancy_orderofpayment op ON o.occupancyid = op.occupancyid JOIN ref_bldgcomputationsheet ref ON op.ref_bldgcomputationsheetid = ref.ref_bldgcomputationsheetid
|
||||
WHERE op.is_approve = 1 AND op.for_approval = 1 AND op.is_release = 0 AND op.is_paid = 0 AND op.popstransmitted = 0 AND op.is_delete <> 1 AND op.occupancyid = ?`, 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)
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusBadRequest, err)
|
||||
c.String(http.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
array = append(array, result)
|
||||
array2 = append(array2, result2)
|
||||
array3 = append(array3, result3)
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"result": array,
|
||||
"result2": array2,
|
||||
"result3": array3,
|
||||
})
|
||||
|
||||
case "get-printdetailsfees-electrical":
|
||||
var result2, result3 string
|
||||
array := []string{}
|
||||
array2 := []string{}
|
||||
array3 := []string{}
|
||||
|
||||
results, err := db.Query(`SELECT IFNULL(ref.accountdescription, '') AS result, IFNULL(ref.accountcode, '') AS result2, IFNULL(op.amount, '') AS result3 FROM electrical_orderofpayment_new op, ref_bldgcomputationsheet ref, electrical el
|
||||
WHERE op.is_approve = 1 AND op.for_approval = 1 AND op.is_release = 0 AND op.is_paid = 0 AND op.popstransmitted = 0 AND op.is_delete <> 1 AND op.ref_bldgcomputationsheetid = ref.ref_bldgcomputationsheetid
|
||||
AND el.electricalid = op.electricalid AND op.electricalid = ?`, data)
|
||||
results, err := db.Query(`SELECT IFNULL(ref.accountdescription, '') AS result, IFNULL(ref.accountcode, '') AS result2, IFNULL(op.amount, '') AS result3
|
||||
FROM electrical el JOIN electrical_orderofpayment_new op ON el.electricalid = op.electricalid JOIN ref_bldgcomputationsheet ref ON op.ref_bldgcomputationsheetid = ref.ref_bldgcomputationsheetid
|
||||
WHERE op.is_approve = 1 AND op.for_approval = 1 AND op.is_release = 0 AND op.is_paid = 0 AND op.popstransmitted = 0 AND op.is_delete <> 1 AND op.electricalid = ?`, data)
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusBadRequest, err)
|
||||
c.String(http.StatusBadRequest, err.Error())
|
||||
|
|
@ -825,6 +908,17 @@ func connect() {
|
|||
"result": result,
|
||||
})
|
||||
|
||||
case "get-signeddateassessed-occupancy":
|
||||
err := db.QueryRow(`SELECT IFNULL(txndate, '') AS result FROM occupancydocflowtxn WHERE occupancyreceivingid = ? AND remarks = "FOR OCCUPANCY RECOMMENDING APPROVAL"`, 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 "get-signeddateassessed-electrical":
|
||||
err := db.QueryRow(`SELECT IFNULL(txndate, '') AS result FROM electricaldocflowtxn WHERE electricalid = ? AND remarks = "FOR ELECTRICAL ORDER OF PAYMENT APPROVAL"`, data).Scan(&result)
|
||||
if err != nil {
|
||||
|
|
@ -938,7 +1032,7 @@ func connect() {
|
|||
}
|
||||
})
|
||||
|
||||
router.GET("/api/:method/:data/:data2", func(c *gin.Context) {
|
||||
router.GET("/api/:method/:data/:data2/fetch-data", func(c *gin.Context) {
|
||||
var result string
|
||||
method := c.Param("method")
|
||||
data := c.Param("data")
|
||||
|
|
@ -1021,7 +1115,7 @@ func connect() {
|
|||
|
||||
})
|
||||
|
||||
router.POST("/api/post-newstatus-occupancy", func(c *gin.Context) {
|
||||
router.POST("/api/post-newstatus-occupancy", middleware.TokenChecker(), func(c *gin.Context) {
|
||||
type NewstatusData struct {
|
||||
Data int `json:"data"` //occuapancyid
|
||||
Data2 string `json:"data2"` //date
|
||||
|
|
@ -1069,7 +1163,7 @@ func connect() {
|
|||
|
||||
})
|
||||
|
||||
router.POST("/api/post-newstatus-electrical", func(c *gin.Context) {
|
||||
router.POST("/api/post-newstatus-electrical", middleware.TokenChecker(), func(c *gin.Context) {
|
||||
type NewstatusData struct {
|
||||
Data int `json:"data"`
|
||||
Data2 string `json:"data2"`
|
||||
|
|
@ -1117,7 +1211,7 @@ func connect() {
|
|||
|
||||
})
|
||||
|
||||
router.POST("/api/update-docflow-occupancy", func(c *gin.Context) {
|
||||
router.POST("/api/update-docflow-occupancy", middleware.TokenChecker(), func(c *gin.Context) {
|
||||
type UpdateDocflowData struct {
|
||||
Data int `json:"data"`
|
||||
Data2 string `json:"data2"`
|
||||
|
|
@ -1164,7 +1258,7 @@ func connect() {
|
|||
}
|
||||
})
|
||||
|
||||
router.POST("/api/update-docflow-electrical", func(c *gin.Context) {
|
||||
router.POST("/api/update-docflow-electrical", middleware.TokenChecker(), func(c *gin.Context) {
|
||||
type UpdateDocflowData struct {
|
||||
Data int `json:"data"`
|
||||
Data2 string `json:"data2"`
|
||||
|
|
@ -1211,7 +1305,47 @@ func connect() {
|
|||
}
|
||||
})
|
||||
|
||||
router.POST("/api/update-opprinted-electrical", func(c *gin.Context) {
|
||||
router.POST("/api/update-opprinted-occupancy", middleware.TokenChecker(), func(c *gin.Context) {
|
||||
type UpdateOpData struct {
|
||||
Data int `json:"data"`
|
||||
}
|
||||
var updateOpData UpdateOpData
|
||||
if err := c.ShouldBindJSON(&updateOpData); 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 iips.occupancy_orderofpayment SET popstransmitted = 1, is_release = 1 WHERE occupancyid = ? AND for_approval = 1 AND is_paid = 0 AND is_approve = 1")
|
||||
if err != nil {
|
||||
panic(err.Error())
|
||||
}
|
||||
defer dbpost.Close()
|
||||
|
||||
exec, err := dbpost.Exec(updateOpData.Data)
|
||||
if err != nil {
|
||||
panic(err.Error())
|
||||
}
|
||||
|
||||
affect, err := exec.RowsAffected()
|
||||
if err != nil {
|
||||
panic(err.Error())
|
||||
}
|
||||
|
||||
if affect > 0 {
|
||||
c.String(http.StatusOK, "Success on Updating Order of Payment for Printing")
|
||||
} else {
|
||||
c.String(http.StatusInternalServerError, "Failed on Updating Order of Payment for Printing")
|
||||
}
|
||||
})
|
||||
|
||||
router.POST("/api/update-opprinted-electrical", middleware.TokenChecker(), func(c *gin.Context) {
|
||||
type UpdateOpData struct {
|
||||
Data int `json:"data"`
|
||||
}
|
||||
|
|
@ -1251,7 +1385,7 @@ func connect() {
|
|||
}
|
||||
})
|
||||
|
||||
router.POST("/api/post-esigntransaction", func(c *gin.Context) {
|
||||
router.POST("/api/post-esigntransaction", middleware.TokenChecker(), func(c *gin.Context) {
|
||||
type UpdateOpData struct {
|
||||
Data int `json:"data"`
|
||||
Data2 string `json:"data2"`
|
||||
|
|
@ -1293,7 +1427,7 @@ func connect() {
|
|||
}
|
||||
})
|
||||
|
||||
router.POST("/api/post-pops", func(c *gin.Context) {
|
||||
router.POST("/api/post-pops", middleware.TokenChecker(), func(c *gin.Context) {
|
||||
type PostPopData struct {
|
||||
Data string `json:"data"` //applicationNo
|
||||
Data2 string `json:"data2"` //date
|
||||
|
|
@ -1346,7 +1480,7 @@ func connect() {
|
|||
}
|
||||
})
|
||||
|
||||
router.POST("/api/update-opapproved-occupancy", func(c *gin.Context) {
|
||||
router.POST("/api/update-opapproved-occupancy", middleware.TokenChecker(), func(c *gin.Context) {
|
||||
type UpdateOpData struct {
|
||||
Data int `json:"data"`
|
||||
}
|
||||
|
|
@ -1393,7 +1527,7 @@ func connect() {
|
|||
}
|
||||
})
|
||||
|
||||
router.POST("/api/update-opapproved-electrical", func(c *gin.Context) {
|
||||
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