1740 lines
66 KiB
Go
1740 lines
66 KiB
Go
package main
|
|
|
|
import (
|
|
"database/sql"
|
|
"fmt"
|
|
"log"
|
|
"net/http"
|
|
"os"
|
|
|
|
"ocbo-esign-backend/connections"
|
|
"ocbo-esign-backend/middleware"
|
|
|
|
"github.com/gin-contrib/cors"
|
|
"github.com/gin-gonic/gin"
|
|
_ "github.com/go-sql-driver/mysql"
|
|
"github.com/joho/godotenv"
|
|
)
|
|
|
|
func main() {
|
|
err := godotenv.Load()
|
|
if err != nil {
|
|
log.Fatal("Error loading .env file")
|
|
}
|
|
|
|
connect()
|
|
}
|
|
|
|
func getCORSConfig(env string) cors.Config {
|
|
switch env {
|
|
case "dev":
|
|
return cors.Config{
|
|
AllowOrigins: []string{"http://localhost:5173"},
|
|
AllowMethods: []string{"GET", "POST"},
|
|
AllowHeaders: []string{"Origin", "OCBO-Token", "Content-Length", "Content-Type"},
|
|
ExposeHeaders: []string{"Content-Length"},
|
|
AllowCredentials: true,
|
|
}
|
|
case "prod":
|
|
return cors.Config{
|
|
AllowOrigins: []string{"https://ocboapps.davaocity.gov.ph"},
|
|
AllowMethods: []string{"GET", "POST"},
|
|
AllowHeaders: []string{"Origin", "OCBO-Token", "Content-Length", "Content-Type"},
|
|
ExposeHeaders: []string{"Content-Length"},
|
|
AllowCredentials: true,
|
|
}
|
|
default:
|
|
return cors.DefaultConfig()
|
|
}
|
|
}
|
|
|
|
func getConnectionStrings(env string) (string, string, error) {
|
|
switch env {
|
|
case "dev":
|
|
return connections.GetConnectionString(), connections.GetConnectionStringPops(), nil
|
|
case "prod":
|
|
return connections.GetConnectionStringServer(), connections.GetConnectionStringPopsServer(), nil
|
|
default:
|
|
return "", "", fmt.Errorf("unknown environment: %s", env)
|
|
}
|
|
}
|
|
|
|
func connect() {
|
|
env := os.Getenv("ENVIRONMENT")
|
|
|
|
conn, connPops, err := getConnectionStrings(env)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
db, err := sql.Open("mysql", conn)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
dbpop, err := sql.Open("mysql", connPops)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
defer db.Close()
|
|
defer dbpop.Close()
|
|
|
|
fmt.Println(env)
|
|
|
|
router := gin.Default()
|
|
router.Use(cors.New(getCORSConfig(env)))
|
|
|
|
router.StaticFile("/", "static/index.html")
|
|
router.StaticFile("/esign.webp", "static/esign.webp")
|
|
router.StaticFile("/favicon.ico", "static/favicon.ico")
|
|
|
|
router.GET("/api/:method", func(c *gin.Context) {
|
|
var result string
|
|
method := c.Param("method")
|
|
|
|
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")
|
|
c.Writer.Header().Set("X-Server", "OCBO Server")
|
|
|
|
switch method {
|
|
case "test":
|
|
err = db.QueryRow("SELECT IFNULL(employeename, '') FROM employee WHERE uname = ?", "TEST").Scan(&result)
|
|
if err != nil {
|
|
c.AbortWithError(http.StatusBadRequest, err)
|
|
c.String(http.StatusBadRequest, err.Error())
|
|
return
|
|
}
|
|
c.String(http.StatusOK, "Connection is OK")
|
|
|
|
case "check-connection":
|
|
err = db.QueryRow("SELECT 1 AS result").Scan(&result)
|
|
if err != nil {
|
|
c.AbortWithError(http.StatusBadGateway, err)
|
|
c.JSON(http.StatusBadGateway, gin.H{"result": false})
|
|
return
|
|
}
|
|
c.JSON(http.StatusOK, gin.H{"result": true})
|
|
|
|
case "get-listopapproval-building":
|
|
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 ot ON o.ref_occupancy_typeid = ot.ref_occupancy_typeid JOIN ref_occupancy ro ON ot.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 = "FOR OCCUPANCY RECOMMENDING APPROVAL" OR remarks = "FOR ADDITIONAL ORDER OF PAYMENT RECOMMENDING APPROVAL") AND od.is_approve = 0 ORDER BY od.txndate DESC`)
|
|
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-listopapproval-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 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 = "FOR OCCUPANCY RECOMMENDING APPROVAL" OR remarks = "FOR ADDITIONAL ORDER OF PAYMENT RECOMMENDING APPROVAL") AND od.is_approve = 0 ORDER BY od.txndate DESC`)
|
|
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-listopapproval-electrical":
|
|
var result2 string
|
|
|
|
array := []string{}
|
|
array2 := []string{}
|
|
|
|
results, err := db.Query(`SELECT IFNULL(e.electricalno, '') 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 iips.electrical e JOIN iips.customer c ON e.customerid = c.customerid JOIN iips.ref_elec_occupancy ec ON e.ref_elec_occupancyid = ec.ref_elec_occupancyid JOIN iips.electricaldocflowtxn ed ON e.electricalid = ed.electricalid JOIN (SELECT electricalid, MAX(electricaldocflowtxnid) AS latest_electricaldocflowtxnid FROM electricaldocflowtxn GROUP BY electricalid) latest_doc ON ed.electricalid = latest_doc.electricalid AND ed.electricaldocflowtxnid = latest_doc.latest_electricaldocflowtxnid WHERE remarks = ? AND is_approve = 0 ORDER BY ed.txndate DESC`, "FOR ELECTRICAL ORDER OF PAYMENT APPROVAL")
|
|
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-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
|
|
|
|
array := []string{}
|
|
array2 := []string{}
|
|
|
|
results, err := db.Query(`SELECT IFNULL(e.electricalno, '') 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 iips.electrical e JOIN iips.customer c ON e.customerid = c.customerid JOIN iips.ref_elec_occupancy ec ON e.ref_elec_occupancyid = ec.ref_elec_occupancyid JOIN iips.electricaldocflowtxn ed ON e.electricalid = ed.electricalid JOIN (SELECT electricalid, MAX(electricaldocflowtxnid) AS latest_electricaldocflowtxnid FROM electricaldocflowtxn GROUP BY electricalid) latest_doc ON ed.electricalid = latest_doc.electricalid AND ed.electricaldocflowtxnid = latest_doc.latest_electricaldocflowtxnid WHERE remarks = ? AND is_approve = 0 ORDER BY e.electricalno ASC`, "FOR ELECTRICAL ORDER OF PAYMENT PRINTING")
|
|
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-list-assessors":
|
|
array := []string{}
|
|
|
|
results, err := db.Query("SELECT IFNULL(employeename, '') AS result FROM employee WHERE is_assessment = ? AND is_delete = ? AND NOT (employeename LIKE ? OR employeename LIKE ? OR employeename LIKE ?) AND employeeid NOT IN (?, ?, ?, ?, ?, ?, ?, ?, ?)", 1, 0, "%OFFICE%", "%TEST%", "%SAMPLE%", 55, 68, 120, 136, 103, 233, 235, 243, 310)
|
|
if err != nil {
|
|
c.AbortWithError(http.StatusBadRequest, err)
|
|
c.String(http.StatusBadRequest, err.Error())
|
|
return
|
|
}
|
|
for results.Next() {
|
|
err = results.Scan(&result)
|
|
if err != nil {
|
|
c.AbortWithError(http.StatusBadRequest, err)
|
|
c.String(http.StatusBadRequest, err.Error())
|
|
return
|
|
}
|
|
array = append(array, result)
|
|
}
|
|
c.JSON(http.StatusOK, gin.H{
|
|
"result": array,
|
|
})
|
|
|
|
case "get-list-approvers":
|
|
var result2 string
|
|
|
|
array := []string{}
|
|
array2 := []string{}
|
|
|
|
results, err := db.Query("SELECT IFNULL(employeeid, '') AS result, IFNULL(employeename, '') AS result2 FROM employee WHERE is_finalapprover = ? AND is_delete = ? AND NOT (employeename LIKE ? OR employeename LIKE ? OR employeename LIKE ? OR employeename LIKE ? OR employeename LIKE ?) AND employeeid NOT IN (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", 1, 0, "%OFFICE%", "%TEST%", "%SAMPLE%", "%BUILDING%", "%OCCUPANCY%", 124, 141, 178, 14, 77, 82, 83, 129, 137, 144, 169, 233, 247, 267, 282)
|
|
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-list-registered":
|
|
headId := os.Getenv("HEADID")
|
|
array := []string{}
|
|
|
|
results, err := db.Query("SELECT IFNULL(emp.employeename, '') AS result FROM esign e LEFT JOIN employee emp ON e.employeeid = emp.employeeid WHERE e.employeeid <> ?", headId)
|
|
if err != nil {
|
|
c.AbortWithError(http.StatusBadRequest, err)
|
|
c.String(http.StatusBadRequest, err.Error())
|
|
return
|
|
}
|
|
for results.Next() {
|
|
err = results.Scan(&result)
|
|
if err != nil {
|
|
c.AbortWithError(http.StatusBadRequest, err)
|
|
c.String(http.StatusBadRequest, err.Error())
|
|
return
|
|
}
|
|
array = append(array, result)
|
|
}
|
|
c.JSON(http.StatusOK, gin.H{
|
|
"result": array,
|
|
})
|
|
|
|
}
|
|
|
|
})
|
|
|
|
router.GET("/api/:method/:data/fetch-data", func(c *gin.Context) {
|
|
var result string
|
|
method := c.Param("method")
|
|
data := c.Param("data")
|
|
|
|
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")
|
|
|
|
switch method {
|
|
case "check-building":
|
|
err = db.QueryRow("SELECT IFNULL(COUNT(receivingid), 0) AS result FROM receiving WHERE applicationNo = ?", 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-occupancy":
|
|
err = db.QueryRow("SELECT IFNULL(COUNT(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())
|
|
return
|
|
}
|
|
c.JSON(http.StatusOK, gin.H{
|
|
"result": result,
|
|
})
|
|
|
|
case "check-signage":
|
|
err = db.QueryRow("SELECT IFNULL(COUNT(signageid), 0) AS result FROM signage WHERE signApplicationNo = ?", 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-electrical":
|
|
err = db.QueryRow("SELECT IFNULL(COUNT(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())
|
|
return
|
|
}
|
|
c.JSON(http.StatusOK, gin.H{
|
|
"result": result,
|
|
})
|
|
|
|
case "check-mechanical":
|
|
err = db.QueryRow("SELECT IFNULL(COUNT(mechanicalid), 0) AS result FROM mechanical WHERE mechApplicationNo = ?", 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-owner-building":
|
|
var result2, result3, result4, result5, result6 string
|
|
|
|
err = db.QueryRow("SELECT IFNULL(c.firstName, '') AS result, IFNULL(c.middleInitial, '') AS result2, IFNULL(c.lastName, '') AS result3, IFNULL(rp.block, '') AS result4, IFNULL(rp.lot, '') AS result5, IFNULL(rp.address, '') AS result6 FROM customer c, receiving r, receiving_permitnoaddress rp WHERE r.customerid = c.customerid AND r.receivingid = rp.receivingid AND r.applicationNo = ?", data).Scan(&result, &result2, &result3, &result4, &result5, &result6)
|
|
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,
|
|
})
|
|
|
|
case "get-owner-occupancy":
|
|
var result2, result3, result4 string
|
|
|
|
err = db.QueryRow("SELECT IFNULL(c.firstName, '') AS result, IFNULL(c.middleInitial, '') AS result2, IFNULL(c.lastName, '') AS result3, IFNULL(c.address, '') AS result4 FROM customer c, receiving r, occupancy o WHERE r.customerid = c.customerid AND r.applicationNo = o.bldgApplicationNo AND o.controlNo = ?", data).Scan(&result, &result2, &result3, &result4)
|
|
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,
|
|
})
|
|
|
|
case "get-owner-electrical":
|
|
var result2, result3, result4 string
|
|
|
|
err = db.QueryRow("SELECT IFNULL(c.firstName, '') AS result, IFNULL(c.middleInitial, '') AS result2, IFNULL(c.lastName, '') AS result3, IFNULL(c.address, '') AS result4 FROM customer c, electrical e WHERE e.customerid = c.customerid AND e.electricalNo = ?", data).Scan(&result, &result2, &result3, &result4)
|
|
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,
|
|
})
|
|
|
|
case "get-status-building":
|
|
var result2 string
|
|
|
|
array := []string{}
|
|
array2 := []string{}
|
|
|
|
results, err := db.Query(`SELECT IFNULL(DATE_FORMAT(b.datetransac, '%M %d, %Y'), '') AS result, IFNULL(REPLACE(REPLACE(b.remarks, 'RECEIVING', 'RECEIVED'), 'PERMIT ALREADY RELEASE', 'PERMIT RELEASED'), '') AS result2
|
|
FROM docflowtxn b, receiving r WHERE r.receivingid = b.receivingid AND r.applicationNo = ? ORDER BY b.docflowtxnid DESC`, data)
|
|
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-status-occupancy":
|
|
var result2 string
|
|
|
|
array := []string{}
|
|
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)
|
|
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-status-electrical":
|
|
var result2 string
|
|
|
|
array := []string{}
|
|
array2 := []string{}
|
|
|
|
results, err := db.Query(`SELECT IFNULL(DATE_FORMAT(b.txndate, '%M %d, %Y'), '') AS result, IFNULL(b.remarks, '') AS result2
|
|
FROM electricaldocflowtxn b, electrical e WHERE e.electricalid = b.electricalid AND e.electricalNo = ? ORDER BY b.electricaldocflowtxnid DESC`, data)
|
|
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-list-clients":
|
|
var result2, result3, result4 string
|
|
|
|
array := []string{}
|
|
array2 := []string{}
|
|
array3 := []string{}
|
|
array4 := []string{}
|
|
|
|
results, err := db.Query(`SELECT IFNULL(IF(firstName = '', lastName, CONCAT(firstName, ' ', IF(middleInitial = '', lastName, CONCAT(middleInitial, '. ', lastName)))), "") AS result, IFNULL(address, '') AS result2, IFNULL(lastName, "") AS result3, IFNULL(firstName, "") AS result4 FROM customer WHERE (lastName LIKE ? OR firstName LIKE ?)`, "%"+data+"%", "%"+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)
|
|
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)
|
|
}
|
|
c.JSON(http.StatusOK, gin.H{
|
|
"result": array,
|
|
"result2": array2,
|
|
"result3": array3,
|
|
"result4": array4,
|
|
})
|
|
|
|
case "get-laststatus-building":
|
|
err := db.QueryRow(`SELECT IFNULL(remarks, '') AS result FROM docflowtxn WHERE docflowtxnid = (SELECT MAX(docflowtxnid) FROM docflowtxn WHERE receivingid = ?)`, 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-laststatus-occupancy":
|
|
err := db.QueryRow(`SELECT IFNULL(remarks, '') AS result FROM occupancydocflowtxn WHERE occupancydocflowtxnid = (SELECT MAX(occupancydocflowtxnid) FROM occupancydocflowtxn WHERE occupancyreceivingid = ?)`, 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-laststatus-electrical":
|
|
err := db.QueryRow(`SELECT IFNULL(remarks, '') AS result FROM electricaldocflowtxn WHERE electricaldocflowtxnid = (SELECT MAX(electricaldocflowtxnid) FROM electricaldocflowtxn WHERE electricalid = ?)`, 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-applicationbyid-building":
|
|
err := db.QueryRow(`SELECT IFNULL(applicationNo, '') AS result FROM receiving WHERE receivingid = ?`, 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-applicationbyid-occupancy":
|
|
err := db.QueryRow(`SELECT IFNULL(controlNo, '') AS result FROM occupancy WHERE occupancyid = ?`, 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-applicationbyid-electrical":
|
|
err := db.QueryRow(`SELECT IFNULL(electricalNo, '') AS result FROM electrical WHERE electricalid = ?`, 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-idbyapplication-building":
|
|
err := db.QueryRow(`SELECT IFNULL(receivingid, '') AS result FROM receiving WHERE applicationNo = ?`, 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-idbyapplication-occupancy":
|
|
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())
|
|
return
|
|
}
|
|
c.JSON(http.StatusOK, gin.H{
|
|
"result": result,
|
|
})
|
|
|
|
case "get-idbyapplication-electrical":
|
|
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())
|
|
return
|
|
}
|
|
c.JSON(http.StatusOK, gin.H{
|
|
"result": result,
|
|
})
|
|
|
|
case "get-employeeid":
|
|
err := db.QueryRow("SELECT IFNULL(employeeid, 0) AS result FROM employee WHERE employeename = ?", 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-registered":
|
|
err := db.QueryRow("SELECT IFNULL(e.esignid, 0) AS result FROM esign e LEFT JOIN employee emp ON e.employeeid = emp.employeeid WHERE emp.employeename = ?", data).Scan(&result)
|
|
if err != nil {
|
|
if err == sql.ErrNoRows {
|
|
result = "0"
|
|
} else {
|
|
c.AbortWithError(http.StatusBadRequest, err)
|
|
c.String(http.StatusBadRequest, err.Error())
|
|
return
|
|
}
|
|
|
|
}
|
|
c.JSON(http.StatusOK, gin.H{
|
|
"result": result,
|
|
})
|
|
|
|
case "get-password":
|
|
err := db.QueryRow("SELECT IFNULL(password, '') AS result FROM esign WHERE employeeid = ?", data).Scan(&result)
|
|
if err != nil {
|
|
if err == sql.ErrNoRows {
|
|
result = "0"
|
|
} else {
|
|
c.AbortWithError(http.StatusBadRequest, err)
|
|
c.String(http.StatusBadRequest, err.Error())
|
|
return
|
|
}
|
|
|
|
}
|
|
c.JSON(http.StatusOK, gin.H{
|
|
"result": result,
|
|
})
|
|
|
|
case "get-employeename":
|
|
err := db.QueryRow("SELECT IFNULL(employeename, '') AS result FROM employee WHERE employeeid = ?", data).Scan(&result)
|
|
if err != nil {
|
|
if err == sql.ErrNoRows {
|
|
result = "0"
|
|
} else {
|
|
c.AbortWithError(http.StatusBadRequest, err)
|
|
c.String(http.StatusBadRequest, err.Error())
|
|
return
|
|
}
|
|
}
|
|
c.JSON(http.StatusOK, gin.H{
|
|
"result": result,
|
|
})
|
|
|
|
case "get-opdetails-occupancy":
|
|
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(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)
|
|
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, //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":
|
|
err := db.QueryRow("SELECT IFNULL(accountdescription, '') AS result FROM ref_bldgcomputationsheet WHERE ref_bldgcomputationsheetid = ?", 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-printdetails-occupancy":
|
|
var result2, result3, result4, result5, result6, result7, result8, result9, result10 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, IFNULL(op.numUnits, 0) AS result9, IFNULL(o.totalFloorArea, 0) AS result10
|
|
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, &result9, &result10)
|
|
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,
|
|
"result9": result9,
|
|
"result10": result10,
|
|
})
|
|
|
|
case "get-printdetails-electrical":
|
|
var result2, result3, result4, result5, result6, result7, result8 string
|
|
|
|
err := db.QueryRow(`SELECT DISTINCT IFNULL(el.electricalNo, '') AS result, IFNULL(op.opDate, '') AS result2, IFNULL(el.locationofinstallation, '') AS result3, IFNULL(occ.occupancy, '') AS result4, IFNULL(u.occupancyoruse, '') AS result5, IFNULL(el.noofUnits, '') 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 electrical el, electrical_orderofpayment_new op, ref_occupancy occ, ref_elec_occupancy u, customer cu, employee e
|
|
WHERE el.customerid = cu.customerid AND el.ref_elec_occupancyid = u.ref_elec_occupancyid AND u.ref_occupancyid = occ.ref_occupancyid AND op.assessedbyid = e.employeeid
|
|
AND el.electricalid = op.electricalid AND op.is_approve = 1 AND op.for_approval = 1 AND op.is_release = 0 AND is_paid = 0 AND popstransmitted = 0 AND el.electricalid = ?`, 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-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-bldgadditional":
|
|
var result2, result3, result4 string
|
|
array := []string{}
|
|
array2 := []string{}
|
|
array3 := []string{}
|
|
array4 := []string{}
|
|
|
|
results, err := db.Query(`SELECT IFNULL(ref.accountdescription, '') AS result, IFNULL(ref.accountcode, '') AS result2, IFNULL(op.amount, '') AS result3, IFNULL(op.numUnits, 0) AS result4
|
|
FROM occupancy o JOIN building_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_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, &result4)
|
|
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)
|
|
}
|
|
c.JSON(http.StatusOK, gin.H{
|
|
"result": array,
|
|
"result2": array2,
|
|
"result3": array3,
|
|
"result4": array4,
|
|
})
|
|
|
|
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 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())
|
|
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-signatureimage":
|
|
err := db.QueryRow("SELECT IFNULL(image, '') AS result FROM esign WHERE employeeid = ?", 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-esignid":
|
|
err := db.QueryRow("SELECT IFNULL(esignid, 0) AS result FROM esign WHERE employeeid = ?", 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-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 {
|
|
c.AbortWithError(http.StatusBadRequest, err)
|
|
c.String(http.StatusBadRequest, err.Error())
|
|
return
|
|
}
|
|
c.JSON(http.StatusOK, gin.H{
|
|
"result": result,
|
|
})
|
|
|
|
case "get-popsdetails-occupancy":
|
|
var result2, result3, result4, result5, result6, result7, result8, result9 string
|
|
array := []string{}
|
|
array2 := []string{}
|
|
array3 := []string{}
|
|
array4 := []string{}
|
|
array5 := []string{}
|
|
array6 := []string{}
|
|
array7 := []string{}
|
|
array8 := []string{}
|
|
array9 := []string{}
|
|
|
|
results, err := db.Query(`SELECT IFNULL(o.controlNo, '') 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(r.locationofconstruction, '') 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 occupancy o JOIN receiving r ON o.bldgApplicationNo = r.applicationNo JOIN customer c ON r.customerid = c.customerid JOIN occupancy_orderofpayment op ON o.occupancyid = op.occupancyid JOIN ref_bldgcomputationsheet ref ON op.ref_bldgcomputationsheetid = ref.ref_bldgcomputationsheetid
|
|
WHERE o.occupancyid = (SELECT occupancyid FROM occupancy WHERE 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)
|
|
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)
|
|
array7 = append(array7, result7)
|
|
array8 = append(array8, result8)
|
|
array9 = append(array9, result9)
|
|
}
|
|
c.JSON(http.StatusOK, gin.H{
|
|
"result": array,
|
|
"result2": array2,
|
|
"result3": array3,
|
|
"result4": array4,
|
|
"result5": array5,
|
|
"result6": array6,
|
|
"result7": array7,
|
|
"result8": array8,
|
|
"result9": array9,
|
|
})
|
|
|
|
case "get-popsdetails-electrical":
|
|
var result2, result3, result4, result5, result6, result7, result8, result9 string
|
|
array := []string{}
|
|
array2 := []string{}
|
|
array3 := []string{}
|
|
array4 := []string{}
|
|
array5 := []string{}
|
|
array6 := []string{}
|
|
array7 := []string{}
|
|
array8 := []string{}
|
|
array9 := []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 = (SELECT electricalid FROM electrical WHERE 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, &result7, &result8, &result9)
|
|
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)
|
|
array7 = append(array7, result7)
|
|
array8 = append(array8, result8)
|
|
array9 = append(array9, result9)
|
|
}
|
|
c.JSON(http.StatusOK, gin.H{
|
|
"result": array,
|
|
"result2": array2,
|
|
"result3": array3,
|
|
"result4": array4,
|
|
"result5": array5,
|
|
"result6": array6,
|
|
"result7": array7,
|
|
"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,
|
|
})
|
|
|
|
}
|
|
})
|
|
|
|
router.GET("/api/:method/:data/:data2/fetch-data", func(c *gin.Context) {
|
|
var result string
|
|
method := c.Param("method")
|
|
data := c.Param("data")
|
|
data2 := c.Param("data2")
|
|
|
|
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")
|
|
|
|
switch method {
|
|
case "check-access":
|
|
err = db.QueryRow("SELECT COUNT(accessid) AS result FROM access a JOIN ref_access ra ON a.ref_accessid = ra.ref_accessid AND ra.access = ? and employeeid = ?", data, data2).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-signeddate":
|
|
err := db.QueryRow("SELECT IFNULL(date_signed, '') AS result FROM esign_transactions WHERE esignid = ? AND referenceNo = ?", data, data2).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-approval":
|
|
err := db.QueryRow("SELECT IFNULL(is_approve, 0) AS result FROM occupancydocflowtxn WHERE remarks = ? AND occupancyreceivingid = (SELECT occupancyid FROM occupancy WHERE controlNo = ?)", data, data2).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,
|
|
})
|
|
}
|
|
})
|
|
|
|
router.POST("/api/post-registration", middleware.TokenChecker(), func(c *gin.Context) {
|
|
type RegistrationData struct {
|
|
Data int `json:"data"`
|
|
Data2 string `json:"data2"`
|
|
Data3 string `json:"data3"`
|
|
Data4 string `json:"data4"`
|
|
}
|
|
var registrationData RegistrationData
|
|
if err := c.ShouldBindJSON(®istrationData); 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 esign (esignid, employeeid, password, signature, image) VALUES (NULL, ?, ?, ?, ?)")
|
|
if err != nil {
|
|
panic(err.Error())
|
|
}
|
|
defer dbpost.Close()
|
|
|
|
exec, err := dbpost.Exec(registrationData.Data, registrationData.Data2, registrationData.Data3, registrationData.Data4)
|
|
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 Registrating e-Sign")
|
|
} else {
|
|
c.String(http.StatusInternalServerError, "Failed on Registrating e-Sign")
|
|
}
|
|
|
|
})
|
|
|
|
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
|
|
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", middleware.TokenChecker(), func(c *gin.Context) {
|
|
type NewstatusData struct {
|
|
Data int `json:"data"`
|
|
Data2 string `json:"data2"`
|
|
Data3 string `json:"data3"`
|
|
Data4 string `json:"data4"`
|
|
Data5 string `json:"data5"`
|
|
Data6 int `json:"data6"`
|
|
Data7 int `json:"data7"`
|
|
}
|
|
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 electricaldocflowtxn (electricaldocflowtxnid, electricalid, txndate, remarks, comments, is_tag, tagword, is_approve, employeeid, is_delete)
|
|
VALUES (NULL, ?, ?, ?, NULL, ?, ?, ?, ?, 0)`)
|
|
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/update-docflow-occupancy", 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"`
|
|
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 electricaldocflowtxn SET is_approve = 1 WHERE remarks = ? AND electricalid = (SELECT electricalid FROM electrical WHERE electricalNo = ?)")
|
|
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-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 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"`
|
|
}
|
|
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 electrical_orderofpayment_new SET popstransmitted = 1, is_release = 1 WHERE electricalid = ? 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/post-esigntransaction", middleware.TokenChecker(), func(c *gin.Context) {
|
|
type UpdateOpData struct {
|
|
Data int `json:"data"`
|
|
Data2 string `json:"data2"`
|
|
Data3 string `json:"data3"`
|
|
}
|
|
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("INSERT INTO esign_transactions (esign_transactionsid, esignid, referenceNo, date_signed) VALUES (NULL, ?, ?, ?)")
|
|
if err != nil {
|
|
panic(err.Error())
|
|
}
|
|
defer dbpost.Close()
|
|
|
|
exec, err := dbpost.Exec(updateOpData.Data, updateOpData.Data2, updateOpData.Data3)
|
|
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 Saving eSign transaction")
|
|
} else {
|
|
c.String(http.StatusInternalServerError, "Failed on Saving eSign transaction")
|
|
}
|
|
})
|
|
|
|
router.POST("/api/post-pops", middleware.TokenChecker(), func(c *gin.Context) {
|
|
type PostPopData struct {
|
|
Data string `json:"data"` //applicationNo
|
|
Data2 string `json:"data2"` //date
|
|
Data3 string `json:"data3"` //customerId
|
|
Data4 string `json:"data4"` //customerName
|
|
Data5 string `json:"data5"` //customerAddress
|
|
Data6 string `json:"data6"` //accountCode
|
|
Data7 string `json:"data7"` //amount
|
|
Data8 string `json:"data8"` //approverName
|
|
Data9 string `json:"data9"` //dateAndTime
|
|
Data10 string `json:"data10"` //gflgu
|
|
Data11 string `json:"data11"` //gfdpwh
|
|
Data12 string `json:"data12"` //tfobo
|
|
Data13 string `json:"data13"` //publicIp
|
|
}
|
|
var postPopDate PostPopData
|
|
if err := c.ShouldBindJSON(&postPopDate); 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 := dbpop.Prepare(`INSERT INTO orderpaydetail (OrderPayId, OPRefId, OPSysId, OPDate, AcctRefId, AcctFullName, AcctAddress, AccountCode, AmountBasic, OPPostedBy, OPPostDate, OfficeCode, Amt_GFLGU, Amt_GFDPWH, Amt_TFBO, TranRefId)
|
|
VALUES (NULL, ?, 'IIPS', ?, ?, ?, ?, ?, ?, ?, ?, 8751, ?, ?, ?, ?)`)
|
|
if err != nil {
|
|
panic(err.Error())
|
|
}
|
|
defer dbpost.Close()
|
|
|
|
exec, err := dbpost.Exec(postPopDate.Data, postPopDate.Data2, postPopDate.Data3, postPopDate.Data4, postPopDate.Data5, postPopDate.Data6, postPopDate.Data7, postPopDate.Data8, postPopDate.Data9, postPopDate.Data10, postPopDate.Data11, postPopDate.Data12, postPopDate.Data13)
|
|
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 Posting on POPS eSign transaction")
|
|
} else {
|
|
c.String(http.StatusInternalServerError, "Failed on Posting on POPS")
|
|
}
|
|
})
|
|
|
|
router.POST("/api/update-opapproved-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.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-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"`
|
|
}
|
|
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")
|
|
}
|