Added occupancy
This commit is contained in:
parent
7deb4ef2ae
commit
d93cfe2a73
1 changed files with 203 additions and 34 deletions
237
backend/main.go
237
backend/main.go
|
|
@ -54,7 +54,7 @@ func connect() {
|
|||
router.Use(cors.New(cors.Config{
|
||||
AllowOrigins: []string{"http://localhost:5173"},
|
||||
AllowMethods: []string{"GET", "POST"},
|
||||
AllowHeaders: []string{"Origin", "OCBO-ShieldConnection"},
|
||||
AllowHeaders: []string{"Origin", "OCBO-Token"},
|
||||
ExposeHeaders: []string{"Content-Length"},
|
||||
AllowCredentials: true,
|
||||
}))
|
||||
|
|
@ -62,9 +62,9 @@ func connect() {
|
|||
//SERVER
|
||||
// router.Use(cors.New(cors.Config{
|
||||
// //AllowAllOrigins: true,
|
||||
// AllowOrigins: []string{"https://ocboapps.davaocity.gov.ph"},
|
||||
// AllowOrigins: []string{"https://ocboapps.davaocity.gov.ph"},
|
||||
// AllowMethods: []string{"GET", "POST"},
|
||||
// AllowHeaders: []string{"Origin"},
|
||||
// AllowHeaders: []string{"Origin", "OCBO-Token"},
|
||||
// ExposeHeaders: []string{"Content-Length"},
|
||||
// AllowCredentials: true,
|
||||
// }))
|
||||
|
|
@ -580,7 +580,7 @@ func connect() {
|
|||
})
|
||||
|
||||
case "get-idbyapplication-occupancy":
|
||||
err := db.QueryRow(`SELECT IFNULL(occupancyid, '') AS result FROM occupancy WHERE controlNo = ?`, data).Scan(&result)
|
||||
err := db.QueryRow(`SELECT IFNULL(occupancyid, 0) AS result FROM occupancy WHERE controlNo = ?`, data).Scan(&result)
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusBadRequest, err)
|
||||
c.String(http.StatusBadRequest, err.Error())
|
||||
|
|
@ -591,7 +591,7 @@ func connect() {
|
|||
})
|
||||
|
||||
case "get-idbyapplication-electrical":
|
||||
err := db.QueryRow(`SELECT IFNULL(electricalid, '') AS result FROM electrical WHERE electricalNo = ?`, data).Scan(&result)
|
||||
err := db.QueryRow(`SELECT IFNULL(electricalid, 0) AS result FROM electrical WHERE electricalNo = ?`, data).Scan(&result)
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusBadRequest, err)
|
||||
c.String(http.StatusBadRequest, err.Error())
|
||||
|
|
@ -659,30 +659,25 @@ func connect() {
|
|||
"result": result,
|
||||
})
|
||||
|
||||
case "get-opdetails-electrical":
|
||||
var result2, result3, result4, result5, result6, result7, result8, result9, result10, result11, result12 string
|
||||
case "get-opdetails-occupancy":
|
||||
var result2, result3, result4, result5, result6 string
|
||||
array := []string{}
|
||||
array2 := []string{}
|
||||
array3 := []string{}
|
||||
array4 := []string{}
|
||||
array5 := []string{}
|
||||
array6 := []string{}
|
||||
array7 := []string{}
|
||||
array8 := []string{}
|
||||
array9 := []string{}
|
||||
array10 := []string{}
|
||||
array11 := []string{}
|
||||
array12 := []string{}
|
||||
|
||||
results, err := db.Query(`SELECT IFNULL(e.electricalNo, '') AS result, IFNULL(c.firstName, '') AS result2, IFNULL(c.middleInitial, '') AS result3, IFNULL(c.lastName, '') AS result4, IFNULL(e.locationofinstallation, '') AS result5, IFNULL(re.occupancyoruse, '') AS result6, IFNULL(em.employeename, '') AS result7, IFNULL(rb.accountdescription, '') AS result8, IFNULL(o.amount, '') AS result9, IFNULL(o.opDate, '') AS result10, IFNULL(e.electricalid, 0) AS result11, IFNULL(o.assessedbyid, 0) AS result12
|
||||
FROM electrical e, customer c, electrical_orderofpayment_new o, ref_elec_occupancy re, ref_bldgcomputationsheet rb, employee em WHERE e.customerid = c.customerid AND e.electricalid = o.electricalid AND e.ref_elec_occupancyid = re.ref_elec_occupancyid AND o.ref_bldgcomputationsheetid = rb.ref_bldgcomputationsheetid AND o.assessedbyid = em.employeeid AND e.electricalNo = ?`, data)
|
||||
results, err := db.Query(`SELECT IFNULL(r.locationofconstruction, '') AS result, IFNULL(CONCAT(ro.occupancy, '-', rot.occupancyType), '') AS result2, IFNULL(em.employeename, '') AS result3, IFNULL(o.amount, '') AS result4, IFNULL(o.assessedDate, '') AS result5, IFNULL(oc.occupancyid, 0) AS result6
|
||||
FROM occupancy oc LEFT JOIN receiving r ON oc.bldgApplicationNo = r.applicationNo JOIN ref_occupancy_type rot ON oc.ref_occupancy_typeid = rot.ref_occupancy_typeid JOIN ref_occupancy ro ON rot.ref_occupancyid = ro.ref_occupancyid JOIN occupancy_orderofpayment o ON oc.occupancyid = o.occupancyid JOIN employee em ON o.assessedbyid = em.employeeid
|
||||
WHERE oc.controlNo = ?`, 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, &result11, &result12)
|
||||
err = results.Scan(&result, &result2, &result3, &result4, &result5, &result6)
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusBadRequest, err)
|
||||
c.String(http.StatusBadRequest, err.Error())
|
||||
|
|
@ -694,27 +689,58 @@ func connect() {
|
|||
array4 = append(array4, result4)
|
||||
array5 = append(array5, result5)
|
||||
array6 = append(array6, result6)
|
||||
array7 = append(array7, result7)
|
||||
array8 = append(array8, result8)
|
||||
array9 = append(array9, result9)
|
||||
array10 = append(array10, result10)
|
||||
array11 = append(array11, result11)
|
||||
array12 = append(array12, result12)
|
||||
|
||||
}
|
||||
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,
|
||||
"result11": array11,
|
||||
"result12": array12,
|
||||
"result": array, //applicationNo
|
||||
"result2": array2, //noOfPermits
|
||||
"result3": array3, //firstName
|
||||
"result4": array4, //middleName
|
||||
"result5": array5, //lastName
|
||||
"result6": array6, //occFirstName
|
||||
})
|
||||
|
||||
case "get-opdetails-electrical":
|
||||
var result2, result3, result4, result5, result6 string
|
||||
array := []string{}
|
||||
array2 := []string{}
|
||||
array3 := []string{}
|
||||
array4 := []string{}
|
||||
array5 := []string{}
|
||||
array6 := []string{}
|
||||
|
||||
// results, err := db.Query(`SELECT IFNULL(e.electricalNo, '') AS result, IFNULL(c.firstName, '') AS result2, IFNULL(c.middleInitial, '') AS result3, IFNULL(c.lastName, '') AS result4, IFNULL(e.locationofinstallation, '') AS result5, IFNULL(re.occupancyoruse, '') AS result6, IFNULL(em.employeename, '') AS result7, IFNULL(rb.accountdescription, '') AS result8, IFNULL(o.amount, '') AS result9, IFNULL(o.opDate, '') AS result10, IFNULL(e.electricalid, 0) AS result11, IFNULL(o.assessedbyid, 0) AS result12
|
||||
// FROM electrical e join customer c on e.customerid = c.customerid join electrical_orderofpayment_new o on e.electricalid = o.electricalid join ref_elec_occupancy re on e.ref_elec_occupancyid = re.ref_elec_occupancyid join ref_bldgcomputationsheet rb on o.ref_bldgcomputationsheetid = rb.ref_bldgcomputationsheetid join employee em on o.assessedbyid = em.employeeid
|
||||
// WHERE e.electricalNo = ?`, data)
|
||||
results, err := db.Query(`SELECT IFNULL(e.locationofinstallation, '') AS result, IFNULL(re.occupancyoruse, '') AS result2, IFNULL(em.employeename, '') AS result3, IFNULL(o.amount, '') AS result4, IFNULL(o.opDate, '') AS result5, IFNULL(e.electricalid, 0) AS result6
|
||||
FROM electrical e join electrical_orderofpayment_new o on e.electricalid = o.electricalid join ref_elec_occupancy re on e.ref_elec_occupancyid = re.ref_elec_occupancyid join employee em on o.assessedbyid = em.employeeid
|
||||
WHERE e.electricalNo = ?`, 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)
|
||||
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)
|
||||
array4 = append(array4, result4)
|
||||
array5 = append(array5, result5)
|
||||
array6 = append(array6, result6)
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"result": array,
|
||||
"result2": array2,
|
||||
"result3": array3,
|
||||
"result4": array4,
|
||||
"result5": array5,
|
||||
"result6": array6,
|
||||
})
|
||||
|
||||
case "get-paymentname":
|
||||
|
|
@ -956,6 +982,7 @@ func connect() {
|
|||
}
|
||||
})
|
||||
|
||||
// router.POST("/api/post-registration", middleware.tokenChecker, func(c *gin.Context) {
|
||||
router.POST("/api/post-registration", func(c *gin.Context) {
|
||||
type RegistrationData struct {
|
||||
Data int `json:"data"`
|
||||
|
|
@ -1000,6 +1027,54 @@ func connect() {
|
|||
|
||||
})
|
||||
|
||||
router.POST("/api/post-newstatus-occupancy", func(c *gin.Context) {
|
||||
type NewstatusData struct {
|
||||
Data int `json:"data"` //occuapancyid
|
||||
Data2 string `json:"data2"` //date
|
||||
Data3 string `json:"data3"` //remarks
|
||||
Data4 string `json:"data4"` //is_tag
|
||||
Data5 string `json:"data5"` //tagword
|
||||
Data6 int `json:"data6"` //is_aprrove
|
||||
Data7 int `json:"data7"` //employeeid
|
||||
}
|
||||
var newstatusData NewstatusData
|
||||
if err := c.ShouldBindJSON(&newstatusData); 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(`INSERT INTO occupancydocflowtxn (occupancydocflowtxnid, occupancyreceivingid, txndate, remarks, is_tag, tagword, is_approve, employeeid, is_compliance, comments)
|
||||
VALUES (NULL, ?, ?, ?, ?, ?, ?, ?, 0, NULL)`)
|
||||
if err != nil {
|
||||
panic(err.Error())
|
||||
}
|
||||
defer dbpost.Close()
|
||||
|
||||
exec, err := dbpost.Exec(newstatusData.Data, newstatusData.Data2, newstatusData.Data3, newstatusData.Data4, newstatusData.Data5, newstatusData.Data6, newstatusData.Data7)
|
||||
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 Setting New Status")
|
||||
} else {
|
||||
c.String(http.StatusInternalServerError, "Failed on Setting New Status")
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
router.POST("/api/post-newstatus-electrical", func(c *gin.Context) {
|
||||
type NewstatusData struct {
|
||||
Data int `json:"data"`
|
||||
|
|
@ -1048,6 +1123,53 @@ func connect() {
|
|||
|
||||
})
|
||||
|
||||
router.POST("/api/update-docflow-occupancy", func(c *gin.Context) {
|
||||
type UpdateDocflowData struct {
|
||||
Data int `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 occupancyreceivingid = ? AND remarks = ?")
|
||||
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", func(c *gin.Context) {
|
||||
type UpdateDocflowData struct {
|
||||
Data int `json:"data"`
|
||||
|
|
@ -1230,6 +1352,53 @@ func connect() {
|
|||
}
|
||||
})
|
||||
|
||||
router.POST("/api/update-opapproved-occupancy", 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 occupancy_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", func(c *gin.Context) {
|
||||
type UpdateOpData struct {
|
||||
Data int `json:"data"`
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue