1221 lines
45 KiB
Go
1221 lines
45 KiB
Go
package main
|
|
|
|
import (
|
|
"database/sql"
|
|
"net/http"
|
|
|
|
"strings"
|
|
|
|
// "crypto/rand"
|
|
// "crypto/rsa"
|
|
// "crypto/x509"
|
|
// "encoding/base64"
|
|
// "encoding/pem"
|
|
// "errors"
|
|
// "os"
|
|
|
|
"github.com/gin-contrib/cors"
|
|
"github.com/gin-gonic/gin"
|
|
_ "github.com/go-sql-driver/mysql"
|
|
)
|
|
|
|
// DEV
|
|
var connection string = "root:superuser@tcp(localhost:3306)/iips"
|
|
|
|
// SERVER
|
|
// var connection string = "iips:iipsuser@tcp(192.168.7.100:3306)/iips"
|
|
|
|
func main() {
|
|
connect()
|
|
}
|
|
|
|
func connect() {
|
|
db, err := sql.Open("mysql", connection)
|
|
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
defer db.Close()
|
|
|
|
router := gin.Default()
|
|
// router.Use(cors.Default())
|
|
|
|
//DEV
|
|
router.Use(cors.New(cors.Config{
|
|
AllowOrigins: []string{"http://localhost:5173"},
|
|
AllowMethods: []string{"GET", "POST"},
|
|
AllowHeaders: []string{"Origin", "OCBO-ShieldConnection"},
|
|
ExposeHeaders: []string{"Content-Length"},
|
|
AllowCredentials: true,
|
|
}))
|
|
|
|
//SERVER
|
|
// router.Use(cors.New(cors.Config{
|
|
// AllowOrigins: []string{"http://192.168.7.160:8080/inquiry"},
|
|
// AllowMethods: []string{"GET"},
|
|
// AllowHeaders: []string{"Origin", "OCBO-ShieldConnection"},
|
|
// ExposeHeaders: []string{"Content-Length"},
|
|
// AllowCredentials: true,
|
|
// }))
|
|
|
|
router.StaticFile("/", "static/index.html")
|
|
|
|
// shield := "inquiry"
|
|
|
|
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("Server", "Batman")
|
|
|
|
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())
|
|
}
|
|
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.StatusBadRequest, err)
|
|
c.String(http.StatusBadRequest, err.Error())
|
|
}
|
|
|
|
c.JSON(http.StatusOK, gin.H{
|
|
"result": "Connection is OK",
|
|
})
|
|
|
|
case "get-listopapproval-electrical":
|
|
array := []string{}
|
|
|
|
results, err := db.Query("SELECT DISTINCT IFNULL(electricalid, '') as result FROM electricaldocflowtxn WHERE remarks = ?", "FOR ELECTRICAL ORDER OF PAYMENT APPROVAL")
|
|
if err != nil {
|
|
c.AbortWithError(http.StatusBadRequest, err)
|
|
c.String(http.StatusBadRequest, err.Error())
|
|
}
|
|
for results.Next() {
|
|
err = results.Scan(&result)
|
|
if err != nil {
|
|
c.AbortWithError(http.StatusBadRequest, err)
|
|
c.String(http.StatusBadRequest, err.Error())
|
|
}
|
|
array = append(array, result)
|
|
}
|
|
c.JSON(http.StatusOK, gin.H{
|
|
"result": array,
|
|
})
|
|
|
|
case "get-list-assessors":
|
|
var result2 string
|
|
|
|
array := []string{}
|
|
array2 := []string{}
|
|
|
|
results, err := db.Query("SELECT IFNULL(employeeid, '') AS result, IFNULL(employeename, '') AS result2 FROM employee WHERE is_assessment = ? AND is_delete = ? AND employeename NOT LIKE ? AND employeename NOT LIKE ? AND employeename NOT LIKE ?", 1, 0, "%OFFICE%", "%TEST%", "%SAMPLE%")
|
|
if err != nil {
|
|
c.AbortWithError(http.StatusBadRequest, err)
|
|
c.String(http.StatusBadRequest, err.Error())
|
|
}
|
|
for results.Next() {
|
|
err = results.Scan(&result, &result2)
|
|
if err != nil {
|
|
c.AbortWithError(http.StatusBadRequest, err)
|
|
c.String(http.StatusBadRequest, err.Error())
|
|
}
|
|
array = append(array, result)
|
|
array2 = append(array2, result2)
|
|
}
|
|
c.JSON(http.StatusOK, gin.H{
|
|
"result": array,
|
|
"result2": array2,
|
|
})
|
|
|
|
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 ?)", 1, 0, "%OFFICE%", "%TEST%", "%SAMPLE%", "%BUILDING%", "%OCCUPANCY%")
|
|
if err != nil {
|
|
c.AbortWithError(http.StatusBadRequest, err)
|
|
c.String(http.StatusBadRequest, err.Error())
|
|
}
|
|
for results.Next() {
|
|
err = results.Scan(&result, &result2)
|
|
if err != nil {
|
|
c.AbortWithError(http.StatusBadRequest, err)
|
|
c.String(http.StatusBadRequest, err.Error())
|
|
}
|
|
array = append(array, result)
|
|
array2 = append(array2, result2)
|
|
}
|
|
c.JSON(http.StatusOK, gin.H{
|
|
"result": array,
|
|
"result2": array2,
|
|
})
|
|
}
|
|
})
|
|
|
|
router.GET("/api/:method/: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())
|
|
}
|
|
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())
|
|
}
|
|
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())
|
|
}
|
|
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())
|
|
}
|
|
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())
|
|
}
|
|
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())
|
|
}
|
|
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())
|
|
}
|
|
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())
|
|
}
|
|
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())
|
|
}
|
|
for results.Next() {
|
|
err = results.Scan(&result, &result2)
|
|
if err != nil {
|
|
c.AbortWithError(http.StatusBadRequest, err)
|
|
c.String(http.StatusBadRequest, err.Error())
|
|
}
|
|
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())
|
|
}
|
|
for results.Next() {
|
|
err = results.Scan(&result, &result2)
|
|
if err != nil {
|
|
c.AbortWithError(http.StatusBadRequest, err)
|
|
c.String(http.StatusBadRequest, err.Error())
|
|
}
|
|
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())
|
|
}
|
|
for results.Next() {
|
|
err = results.Scan(&result, &result2)
|
|
if err != nil {
|
|
c.AbortWithError(http.StatusBadRequest, err)
|
|
c.String(http.StatusBadRequest, err.Error())
|
|
}
|
|
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())
|
|
}
|
|
for results.Next() {
|
|
err = results.Scan(&result, &result2, &result3, &result4)
|
|
if err != nil {
|
|
c.AbortWithError(http.StatusBadRequest, err)
|
|
c.String(http.StatusBadRequest, err.Error())
|
|
}
|
|
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())
|
|
}
|
|
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())
|
|
}
|
|
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())
|
|
}
|
|
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())
|
|
}
|
|
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())
|
|
}
|
|
c.JSON(http.StatusOK, gin.H{
|
|
"result": result,
|
|
})
|
|
|
|
case "GetFeesBuilding":
|
|
var result2, result3 string
|
|
array := []string{}
|
|
array2 := []string{}
|
|
array3 := []string{}
|
|
|
|
results, err := db.Query(`SELECT r.accountdescription AS result, bo.amount AS result2, bo.is_paid AS result3 FROM building_orderofpayment bo, ref_bldgcomputationsheet r where bo.bldgApplicationNo = ? AND bo.ref_bldgcomputationsheetid = r.ref_bldgcomputationsheetid`, data)
|
|
if err != nil {
|
|
c.AbortWithError(http.StatusBadRequest, err)
|
|
c.String(http.StatusBadRequest, err.Error())
|
|
}
|
|
|
|
for results.Next() {
|
|
err = results.Scan(&result, &result2, &result3)
|
|
if err != nil {
|
|
c.AbortWithError(http.StatusBadRequest, err)
|
|
c.String(http.StatusBadRequest, err.Error())
|
|
}
|
|
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 "GetFeesOccupancy":
|
|
var result2, result3 string
|
|
array := []string{}
|
|
array2 := []string{}
|
|
array3 := []string{}
|
|
|
|
results, err := db.Query(`SELECT r.accountdescription AS result, oo.amount AS result2, oo.is_paid AS result3 FROM occupancy_orderofpayment oo, ref_bldgcomputationsheet r WHERE oo.ref_bldgcomputationsheetid = r.ref_bldgcomputationsheetid AND oo.occupancyid = (SELECT occupancyid FROM occupancy WHERE controlNo = ?)`, data)
|
|
if err != nil {
|
|
c.AbortWithError(http.StatusBadRequest, err)
|
|
c.String(http.StatusBadRequest, err.Error())
|
|
}
|
|
|
|
for results.Next() {
|
|
err = results.Scan(&result, &result2, &result3)
|
|
if err != nil {
|
|
c.AbortWithError(http.StatusBadRequest, err)
|
|
c.String(http.StatusBadRequest, err.Error())
|
|
}
|
|
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 "GetFeesElectrical":
|
|
var result2, result3 string
|
|
array := []string{}
|
|
array2 := []string{}
|
|
array3 := []string{}
|
|
|
|
results, err := db.Query(`SELECT r.accountdescription AS result, eo.amount AS result2, eo.is_paid AS result3 FROM electrical_orderofpayment_new eo, ref_bldgcomputationsheet r WHERE eo.ref_bldgcomputationsheetid = r.ref_bldgcomputationsheetid AND eo.electricalid = (SELECT electricalid FROM electrical WHERE electricalNo = ?)`, data)
|
|
if err != nil {
|
|
c.AbortWithError(http.StatusBadRequest, err)
|
|
c.String(http.StatusBadRequest, err.Error())
|
|
}
|
|
|
|
for results.Next() {
|
|
err = results.Scan(&result, &result2, &result3)
|
|
if err != nil {
|
|
c.AbortWithError(http.StatusBadRequest, err)
|
|
c.String(http.StatusBadRequest, err.Error())
|
|
}
|
|
array = append(array, result)
|
|
array2 = append(array2, result2)
|
|
array3 = append(array3, result3)
|
|
}
|
|
|
|
c.JSON(http.StatusOK, gin.H{
|
|
"result": array,
|
|
"result2": array2,
|
|
"result3": array3,
|
|
})
|
|
|
|
// } else if method == "GetProgressFlowBuilding" {
|
|
// var result2, result3, result4 string
|
|
// array := []string{}
|
|
// array2 := []string{}
|
|
// array3 := []string{}
|
|
// array4 := []string{}
|
|
|
|
// results, err := db.Query(`SELECT IFNULL(rp.progressflow, '') AS result, IFNULL(p.dateIn, '') AS result2, IFNULL(p.dateReturn, '') AS result3, IFNULL(p.accomplish, '') AS result4 FROM progressflow p, ref_progressflow rp WHERE p.bldgApplicationNo = ? AND p.ref_progressflowid BETWEEN 2 AND 9 AND p.ref_progressflowid = rp.ref_progressflowid`, data)
|
|
// if err != nil {
|
|
// c.AbortWithError(http.StatusBadRequest, err)
|
|
// c.String(http.StatusBadRequest, err.Error())
|
|
// }
|
|
|
|
// for results.Next() {
|
|
// err = results.Scan(&result, &result2, &result3, &result4)
|
|
// if err != nil {
|
|
// c.AbortWithError(http.StatusBadRequest, err)
|
|
// c.String(http.StatusBadRequest, err.Error())
|
|
// }
|
|
// result, _ := encrypt(result)
|
|
// result2, _ := encrypt(result2)
|
|
// result3, _ := encrypt(result3)
|
|
// result4, _ := encrypt(result4)
|
|
|
|
// 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,
|
|
// })
|
|
|
|
// } else if method == "GetProgressFlowOccupancy" {
|
|
// var result2, result3, result4 string
|
|
// array := []string{}
|
|
// array2 := []string{}
|
|
// array3 := []string{}
|
|
// array4 := []string{}
|
|
|
|
// results, err := db.Query(`SELECT IFNULL(rp.progressflow, '') AS result, IFNULL(p.datetimeStart, '') AS result2, IFNULL(p.datetimeEnd, '') AS result3, IFNULL(p.accomplish, '') AS result4 FROM occupancyprogressflow p, ref_progressflow rp WHERE p.ref_progressflowid BETWEEN 2 AND 9 AND p.ref_progressflowid = rp.ref_progressflowid AND p.occupancyid = (SELECT occupancyid FROM occupancy WHERE controlNo = ?)`, data)
|
|
// if err != nil {
|
|
// c.AbortWithError(http.StatusBadRequest, err)
|
|
// c.String(http.StatusBadRequest, err.Error())
|
|
// }
|
|
|
|
// for results.Next() {
|
|
// err = results.Scan(&result, &result2, &result3, &result4)
|
|
// if err != nil {
|
|
// c.AbortWithError(http.StatusBadRequest, err)
|
|
// c.String(http.StatusBadRequest, err.Error())
|
|
// }
|
|
// result, _ := encrypt(result)
|
|
// result2, _ := encrypt(result2)
|
|
// result3, _ := encrypt(result3)
|
|
// result4, _ := encrypt(result4)
|
|
|
|
// 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,
|
|
// })
|
|
|
|
// } else if method == "GetProgressFlowElectrical" {
|
|
// var result2, result3 string
|
|
// array := []string{}
|
|
// array2 := []string{}
|
|
// array3 := []string{}
|
|
|
|
// results, err := db.Query(`SELECT IFNULL(rp.progressflow, '') AS result, IFNULL(p.dateStart, '') AS result2, IFNULL(p.dateEnd, '') AS result3 FROM electricalprogressflow p, ref_progressflow rp WHERE p.ref_progressflowid = rp.ref_progressflowid AND p.electricalid = (SELECT electricalid FROM electrical WHERE electricalNo = ?)`, data)
|
|
// if err != nil {
|
|
// c.AbortWithError(http.StatusBadRequest, err)
|
|
// c.String(http.StatusBadRequest, err.Error())
|
|
// }
|
|
|
|
// for results.Next() {
|
|
// err = results.Scan(&result, &result2, &result3)
|
|
// if err != nil {
|
|
// c.AbortWithError(http.StatusBadRequest, err)
|
|
// c.String(http.StatusBadRequest, err.Error())
|
|
// }
|
|
// result, _ := encrypt(result)
|
|
// result2, _ := encrypt(result2)
|
|
// result3, _ := encrypt(result3)
|
|
|
|
// 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 "GetPermitsBuilding":
|
|
var result2, result3, result4 string
|
|
array := []string{}
|
|
array2 := []string{}
|
|
array3 := []string{}
|
|
array4 := []string{}
|
|
|
|
results, err := db.Query(`SELECT IFNULL(p.permitNo, '') AS result, IFNULL(rp.block, '') AS result2, IFNULL(rp.lot, '') AS result3, IFNULL(rp.address, '') AS result4 FROM receiving_permitnoaddress rp, permitnos p WHERE p.receiving_permitnoaddressid = rp.receiving_permitnoaddressid AND rp.receivingid = (SELECT receivingid FROM receiving WHERE applicationNo = ?)`, data)
|
|
if err != nil {
|
|
c.AbortWithError(http.StatusBadRequest, err)
|
|
c.String(http.StatusBadRequest, err.Error())
|
|
}
|
|
|
|
for results.Next() {
|
|
err = results.Scan(&result, &result2, &result3, &result4)
|
|
if err != nil {
|
|
c.AbortWithError(http.StatusBadRequest, err)
|
|
c.String(http.StatusBadRequest, err.Error())
|
|
}
|
|
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 "GetPermitsOccupancy":
|
|
var result2, result3, result4, result5, result6, result7 string
|
|
array := []string{}
|
|
array2 := []string{}
|
|
array3 := []string{}
|
|
array4 := []string{}
|
|
array5 := []string{}
|
|
array6 := []string{}
|
|
array7 := []string{}
|
|
|
|
results, err := db.Query(`SELECT IFNULL(p.occupancyPermitNo, '') AS result, IFNULL(rp.block, '') AS result2, IFNULL(rp.lot, '') AS result3, IFNULL(rp.address, '') AS result4, IFNULL(rp.occblock, '') AS result5, IFNULL(rp.occlot, '') AS result6, IFNULL(rp.occaddress, '') AS result7 FROM occupancypermitnos p, receiving_permitnoaddress rp, receiving r, occupancy o WHERE p.occupancyid = o.occupancyid AND o.bldgApplicationNo = r.applicationNo AND r.receivingid = rp.receivingid AND o.occupancyid = (SELECT occupancyid FROM occupancy WHERE controlNo = ?)`, data)
|
|
if err != nil {
|
|
c.AbortWithError(http.StatusBadRequest, err)
|
|
c.String(http.StatusBadRequest, err.Error())
|
|
}
|
|
|
|
for results.Next() {
|
|
err = results.Scan(&result, &result2, &result3, &result4, &result5, &result6, &result7)
|
|
if err != nil {
|
|
c.AbortWithError(http.StatusBadRequest, err)
|
|
c.String(http.StatusBadRequest, err.Error())
|
|
}
|
|
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)
|
|
}
|
|
|
|
c.JSON(http.StatusOK, gin.H{
|
|
"result": array,
|
|
"result2": array2,
|
|
"result3": array3,
|
|
"result4": array4,
|
|
"result5": array5,
|
|
"result6": array6,
|
|
"result7": array7,
|
|
})
|
|
|
|
case "GetPermitsElectrical":
|
|
var result2 string
|
|
array := []string{}
|
|
array2 := []string{}
|
|
|
|
results, err := db.Query(`SELECT IFNULL(ceiNo, '') AS result, IFNULL(dateRelease,'') AS result2 FROM electrical_certificate WHERE electricalid = (SELECT electricalid FROM electrical WHERE electricalNo = ?)`, data)
|
|
if err != nil {
|
|
c.AbortWithError(http.StatusBadRequest, err)
|
|
c.String(http.StatusBadRequest, err.Error())
|
|
}
|
|
|
|
for results.Next() {
|
|
err = results.Scan(&result, &result2)
|
|
if err != nil {
|
|
c.AbortWithError(http.StatusBadRequest, err)
|
|
c.String(http.StatusBadRequest, err.Error())
|
|
}
|
|
array = append(array, result)
|
|
array2 = append(array2, result2)
|
|
}
|
|
|
|
c.JSON(http.StatusOK, gin.H{
|
|
"result": array,
|
|
"result2": array2,
|
|
})
|
|
|
|
case "GetDailyReceived":
|
|
var result2, result3, result4 string
|
|
decodedString := strings.Replace(data, "~", "/", -1)
|
|
array := []string{}
|
|
array2 := []string{}
|
|
array3 := []string{}
|
|
array4 := []string{}
|
|
|
|
results, err := db.Query(`SELECT r.applicationNo 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, IFNULL(r.locationofconstruction, '') AS result3, IFNULL(CONCAT(ro.occupancy, ' - ', rot.occupancyType), '') AS result4
|
|
FROM receiving r, customer c, ref_occupancy ro, ref_occupancy_type rot
|
|
WHERE (r.receivedate LIKE ? OR r.receivezoning LIKE ?) AND r.customerid = c.customerid AND r.ref_occupancy_typeid = rot.ref_occupancy_typeid AND rot.ref_occupancyid = ro.ref_occupancyid`, decodedString+"%", decodedString+"%")
|
|
|
|
if err != nil {
|
|
c.AbortWithError(http.StatusBadRequest, err)
|
|
c.String(http.StatusBadRequest, err.Error())
|
|
}
|
|
|
|
for results.Next() {
|
|
err = results.Scan(&result, &result2, &result3, &result4)
|
|
if err != nil {
|
|
c.AbortWithError(http.StatusBadRequest, err)
|
|
c.String(http.StatusBadRequest, err.Error())
|
|
}
|
|
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,
|
|
})
|
|
|
|
// } else if method == "GetDailyReceivedOccupancy" {
|
|
// var result2, result3, result4 string
|
|
// decodedString := strings.Replace(data, "~", "-", -1)
|
|
// array := []string{}
|
|
// array2 := []string{}
|
|
// array3 := []string{}
|
|
// array4 := []string{}
|
|
|
|
// results, err := db.Query(`SELECT 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, IFNULL(r.locationofconstruction, '') AS result3, IFNULL(CONCAT(ro.occupancy, ' - ', rot.occupancyType), '') AS result4
|
|
// FROM occupancy o, receiving r, customer c, ref_occupancy ro, ref_occupancy_type rot
|
|
// WHERE o.dateEntered LIKE ? AND o.bldgApplicationNo = r.applicationNo AND r.customerid = c.customerid AND o.ref_occupancy_typeid = rot.ref_occupancy_typeid AND rot.ref_occupancyid = ro.ref_occupancyid`, decodedString+"%")
|
|
|
|
// if err != nil {
|
|
// c.AbortWithError(http.StatusBadRequest, err)
|
|
// c.String(http.StatusBadRequest, err.Error())
|
|
// }
|
|
|
|
// for results.Next() {
|
|
// err = results.Scan(&result, &result2, &result3, &result4)
|
|
// if err != nil {
|
|
// c.AbortWithError(http.StatusBadRequest, err)
|
|
// c.String(http.StatusBadRequest, err.Error())
|
|
// }
|
|
// result, _ := encrypt(result)
|
|
// result2, _ := encrypt(result2)
|
|
// result3, _ := encrypt(result3)
|
|
// result4, _ := encrypt(result4)
|
|
|
|
// 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,
|
|
// })
|
|
|
|
// } else if method == "GetDailyReceivedElectrical" {
|
|
// var result2, result3, result4 string
|
|
// decodedString := strings.Replace(data, "~", "-", -1)
|
|
// array := []string{}
|
|
// array2 := []string{}
|
|
// array3 := []string{}
|
|
// array4 := []string{}
|
|
|
|
// results, err := db.Query(`SELECT 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, IFNULL(e.locationofinstallation, '') AS result3, IFNULL(ro.occupancyoruse, '') AS result4
|
|
// FROM electrical e, customer c, ref_elec_occupancy ro, electricaldocflowtxn ed
|
|
// WHERE e.customerid = c.customerid AND e.ref_elec_occupancyid = ro.ref_elec_occupancyid AND e.electricalid = ed.electricalid AND ed.remarks = 'RECEIVED FOR ELECTRICAL APPLICATION' AND ed.txndate LIKE ?`, decodedString+"%")
|
|
|
|
// if err != nil {
|
|
// c.AbortWithError(http.StatusBadRequest, err)
|
|
// c.String(http.StatusBadRequest, err.Error())
|
|
// }
|
|
|
|
// for results.Next() {
|
|
// err = results.Scan(&result, &result2, &result3, &result4)
|
|
// if err != nil {
|
|
// c.AbortWithError(http.StatusBadRequest, err)
|
|
// c.String(http.StatusBadRequest, err.Error())
|
|
// }
|
|
// result, _ := encrypt(result)
|
|
// result2, _ := encrypt(result2)
|
|
// result3, _ := encrypt(result3)
|
|
// result4, _ := encrypt(result4)
|
|
|
|
// 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,
|
|
// })
|
|
|
|
// } else if method == "GetLatestStatusBuilding" {
|
|
// err = db.QueryRow("SELECT d.remarks AS result FROM docflowtxn d, receiving r WHERE r.receivingid = d.receivingid AND d.docflowtxnid = (SELECT MAX(docflowtxnid) FROM docflowtxn WHERE receivingid = (SELECT receivingid FROM receiving WHERE applicationNo = ?))", data).Scan(&result)
|
|
// if err != nil {
|
|
// c.AbortWithError(http.StatusBadRequest, err)
|
|
// c.String(http.StatusBadRequest, err.Error())
|
|
// }
|
|
// result, err := encrypt(result)
|
|
// if err != nil {
|
|
// c.AbortWithError(http.StatusServiceUnavailable, err)
|
|
// c.String(http.StatusServiceUnavailable, err.Error())
|
|
// }
|
|
|
|
// c.JSON(http.StatusOK, gin.H{
|
|
// "result": result,
|
|
// })
|
|
|
|
// } else if method == "GetLatestStatusOccupancy" {
|
|
// err = db.QueryRow("SELECT d.remarks AS result FROM occupancydocflowtxn d, occupancy o WHERE d.occupancyreceivingid = o.occupancyid AND d.occupancydocflowtxnid = (SELECT MAX(occupancydocflowtxnid) FROM occupancydocflowtxn WHERE occupancyreceivingid = (SELECT occupancyid FROM occupancy WHERE controlNo = ?))", data).Scan(&result)
|
|
// if err != nil {
|
|
// c.AbortWithError(http.StatusBadRequest, err)
|
|
// c.String(http.StatusBadRequest, err.Error())
|
|
// }
|
|
// result, err := encrypt(result)
|
|
// if err != nil {
|
|
// c.AbortWithError(http.StatusServiceUnavailable, err)
|
|
// c.String(http.StatusServiceUnavailable, err.Error())
|
|
// }
|
|
|
|
// c.JSON(http.StatusOK, gin.H{
|
|
// "result": result,
|
|
// })
|
|
|
|
// } else if method == "GetLatestStatusElectrical" {
|
|
// err = db.QueryRow("SELECT d.remarks AS result FROM electricaldocflowtxn d, electrical e WHERE e.electricalid = d.electricalid AND d.electricaldocflowtxnid = (SELECT MAX(electricaldocflowtxnid) FROM electricaldocflowtxn WHERE electricalid = (SELECT electricalid FROM electrical WHERE electricalNo = ?))", data).Scan(&result)
|
|
// if err != nil {
|
|
// c.AbortWithError(http.StatusBadRequest, err)
|
|
// c.String(http.StatusBadRequest, err.Error())
|
|
// }
|
|
// result, err := encrypt(result)
|
|
// if err != nil {
|
|
// c.AbortWithError(http.StatusServiceUnavailable, err)
|
|
// c.String(http.StatusServiceUnavailable, err.Error())
|
|
// }
|
|
|
|
// c.JSON(http.StatusOK, gin.H{
|
|
// "result": result,
|
|
// })
|
|
|
|
// } else if method == "GetSumPaid" {
|
|
// err = db.QueryRow("SELECT IFNULL(SUM(amount), 0) AS result FROM building_orderofpayment WHERE bldgApplicationNo = ? AND is_paid = 1", data).Scan(&result)
|
|
// if err != nil {
|
|
// c.AbortWithError(http.StatusBadRequest, err)
|
|
// c.String(http.StatusBadRequest, err.Error())
|
|
// }
|
|
// result, err := encrypt(result)
|
|
// if err != nil {
|
|
// c.AbortWithError(http.StatusServiceUnavailable, err)
|
|
// c.String(http.StatusServiceUnavailable, err.Error())
|
|
// }
|
|
|
|
// c.JSON(http.StatusOK, gin.H{
|
|
// "result": result,
|
|
// })
|
|
|
|
// } else if method == "GetSumPaidOccupancy" {
|
|
// err = db.QueryRow("SELECT IFNULL(SUM(amount), 0) AS result FROM occupancy_orderofpayment WHERE is_paid = 1 AND occupancyid = (SELECT occupancyid FROM occupancy WHERE controlNo = ?)", data).Scan(&result)
|
|
// if err != nil {
|
|
// c.AbortWithError(http.StatusBadRequest, err)
|
|
// c.String(http.StatusBadRequest, err.Error())
|
|
// }
|
|
// result, err := encrypt(result)
|
|
// if err != nil {
|
|
// c.AbortWithError(http.StatusServiceUnavailable, err)
|
|
// c.String(http.StatusServiceUnavailable, err.Error())
|
|
// }
|
|
|
|
// c.JSON(http.StatusOK, gin.H{
|
|
// "result": result,
|
|
// })
|
|
|
|
// } else if method == "GetSumPaidElectrical" {
|
|
// err = db.QueryRow("SELECT IFNULL(SUM(amount), 0) AS result FROM electrical_orderofpayment_new WHERE is_paid = 1 AND electricalid = (SELECT electricalid FROM electrical WHERE electricalNo = ?)", data).Scan(&result)
|
|
// if err != nil {
|
|
// c.AbortWithError(http.StatusBadRequest, err)
|
|
// c.String(http.StatusBadRequest, err.Error())
|
|
// }
|
|
// result, err := encrypt(result)
|
|
// if err != nil {
|
|
// c.AbortWithError(http.StatusServiceUnavailable, err)
|
|
// c.String(http.StatusServiceUnavailable, err.Error())
|
|
// }
|
|
|
|
// c.JSON(http.StatusOK, gin.H{
|
|
// "result": result,
|
|
// })
|
|
|
|
// } else if method == "GetApprovedPermits" {
|
|
// var result2 string
|
|
// decodedString := strings.Replace(data, "~", "-", -1)
|
|
// array := []string{}
|
|
// array2 := []string{}
|
|
|
|
// results, err := db.Query("SELECT IFNULL(receivingid, '') AS result, IFNULL(datetransac, '') AS result2 FROM docflowtxn WHERE datetransac LIKE ? AND remarks = 'PERMIT ALREADY RELEASE'", decodedString+"%")
|
|
|
|
// if err != nil {
|
|
// c.AbortWithError(http.StatusBadRequest, err)
|
|
// c.String(http.StatusBadRequest, err.Error())
|
|
// }
|
|
|
|
// for results.Next() {
|
|
// err = results.Scan(&result, &result2)
|
|
// if err != nil {
|
|
// c.AbortWithError(http.StatusBadRequest, err)
|
|
// c.String(http.StatusBadRequest, err.Error())
|
|
// }
|
|
// result, _ := encrypt(result)
|
|
// result2, _ := encrypt(result2)
|
|
|
|
// array = append(array, result)
|
|
// array2 = append(array2, result2)
|
|
|
|
// }
|
|
|
|
// c.JSON(http.StatusOK, gin.H{
|
|
// "result": array,
|
|
// "result2": array2,
|
|
// })
|
|
|
|
// } else if method == "GetApprovedPermitsOccupancy" {
|
|
// var result2 string
|
|
// decodedString := strings.Replace(data, "~", "-", -1)
|
|
// array := []string{}
|
|
// array2 := []string{}
|
|
|
|
// results, err := db.Query("SELECT IFNULL(occupancyreceivingid, '') AS result, IFNULL(txndate, '') AS result2 FROM occupancydocflowtxn WHERE txndate LIKE ? AND remarks LIKE 'OCCUPANCY PERMIT RELEASED%'", decodedString+"%")
|
|
|
|
// if err != nil {
|
|
// c.AbortWithError(http.StatusBadRequest, err)
|
|
// c.String(http.StatusBadRequest, err.Error())
|
|
// }
|
|
|
|
// for results.Next() {
|
|
// err = results.Scan(&result, &result2)
|
|
// if err != nil {
|
|
// c.AbortWithError(http.StatusBadRequest, err)
|
|
// c.String(http.StatusBadRequest, err.Error())
|
|
// }
|
|
// result, _ := encrypt(result)
|
|
// result2, _ := encrypt(result2)
|
|
|
|
// array = append(array, result)
|
|
// array2 = append(array2, result2)
|
|
|
|
// }
|
|
|
|
// c.JSON(http.StatusOK, gin.H{
|
|
// "result": array,
|
|
// "result2": array2,
|
|
// })
|
|
|
|
// } else if method == "GetApprovedPermitsElectrical" {
|
|
// var result2 string
|
|
// decodedString := strings.Replace(data, "~", "-", -1)
|
|
// array := []string{}
|
|
// array2 := []string{}
|
|
|
|
// results, err := db.Query("SELECT IFNULL(electricalid, '') AS result, IFNULL(txndate, '') AS result2 FROM electricaldocflowtxn WHERE txndate LIKE ? AND remarks LIKE 'ELECTRICAL PERMIT RELEASED%'", decodedString+"%")
|
|
|
|
// if err != nil {
|
|
// c.AbortWithError(http.StatusBadRequest, err)
|
|
// c.String(http.StatusBadRequest, err.Error())
|
|
// }
|
|
|
|
// for results.Next() {
|
|
// err = results.Scan(&result, &result2)
|
|
// if err != nil {
|
|
// c.AbortWithError(http.StatusBadRequest, err)
|
|
// c.String(http.StatusBadRequest, err.Error())
|
|
// }
|
|
// result, _ := encrypt(result)
|
|
// result2, _ := encrypt(result2)
|
|
|
|
// array = append(array, result)
|
|
// array2 = append(array2, result2)
|
|
|
|
// }
|
|
|
|
// c.JSON(http.StatusOK, gin.H{
|
|
// "result": array,
|
|
// "result2": array2,
|
|
// })
|
|
|
|
// } else if method == "GetApprovedPermitsDetails" {
|
|
// var result2, result3, result4, result5, result6 string
|
|
// err = db.QueryRow(`SELECT r.applicationNo AS result, IF(c.firstName = '', c.lastName, CONCAT(c.firstName, ' ', c.middleInitial, '. ', c.lastName)) AS result2, IFNULL(rp.block, '') AS result3, IFNULL(rp.lot, '') AS result4, IFNULL(rp.address, '') AS result5, IFNULL(pn.permitNo, '') AS result6
|
|
// FROM receiving r, customer c, receiving_permitnoaddress rp, permitnos pn
|
|
// WHERE r.customerid = c.customerid AND r.receivingid = rp.receivingid AND rp.receiving_permitnoaddressid = pn.receiving_permitnoaddressid AND r.receivingid = ? AND pn.permitNo LIKE '%BU'`, data).Scan(&result, &result2, &result3, &result4, &result5, &result6)
|
|
// if err != nil {
|
|
// c.AbortWithError(http.StatusBadRequest, err)
|
|
// c.String(http.StatusBadRequest, err.Error())
|
|
// }
|
|
// result, _ := encrypt(result)
|
|
// result2, _ := encrypt(result2)
|
|
// result3, _ := encrypt(result3)
|
|
// result4, _ := encrypt(result4)
|
|
// result5, _ := encrypt(result5)
|
|
// result6, _ := encrypt(result6)
|
|
|
|
// c.JSON(http.StatusOK, gin.H{
|
|
// "result": result,
|
|
// "result2": result2,
|
|
// "result3": result3,
|
|
// "result4": result4,
|
|
// "result5": result5,
|
|
// "result6": result6,
|
|
// })
|
|
// } else if method == "GetApprovedPermitsOccupancyDetails" {
|
|
// var result2, result3, result4, result5, result6 string
|
|
// err = db.QueryRow(`SELECT o.controlNo AS result, IF(c.firstName = '', c.lastName, CONCAT(c.firstName, ' ', c.middleInitial, '. ', c.lastName)) AS result2, IFNULL(rp.block, '') AS result3, IFNULL(rp.lot, '') AS result4, IFNULL(rp.address, '') AS result5, IFNULL(pn.occupancyPermitNo, '') AS result6
|
|
// FROM occupancy o, receiving r, customer c, receiving_permitnoaddress rp, occupancypermitnos pn
|
|
// WHERE o.customerid = c.customerid AND o.bldgApplicationNo = r.applicationNo AND r.receivingid = rp.receivingid AND o.occupancyid = pn.occupancyid AND o.occupancyid = ?`, data).Scan(&result, &result2, &result3, &result4, &result5, &result6)
|
|
// if err != nil {
|
|
// c.AbortWithError(http.StatusBadRequest, err)
|
|
// c.String(http.StatusBadRequest, err.Error())
|
|
// }
|
|
// result, _ := encrypt(result)
|
|
// result2, _ := encrypt(result2)
|
|
// result3, _ := encrypt(result3)
|
|
// result4, _ := encrypt(result4)
|
|
// result5, _ := encrypt(result5)
|
|
// result6, _ := encrypt(result6)
|
|
|
|
// c.JSON(http.StatusOK, gin.H{
|
|
// "result": result,
|
|
// "result2": result2,
|
|
// "result3": result3,
|
|
// "result4": result4,
|
|
// "result5": result5,
|
|
// "result6": result6,
|
|
// })
|
|
|
|
// } else if method == "GetApprovedPermitsElectricalDetails" {
|
|
// var result2, result3, result4, result5, result6 string
|
|
// err = db.QueryRow(`SELECT e.electricalNo AS result, IF(c.firstName = '', c.lastName, CONCAT(c.firstName, ' ', c.middleInitial, '. ', c.lastName)) AS result2, '' AS result3, '' AS result4, IFNULL(e.locationofinstallation, '') AS result5, IFNULL(ec.ceiNo, '') AS result6
|
|
// FROM electrical e, customer c, electrical_certificate ec
|
|
// WHERE e.customerid = c.customerid AND e.electricalid = ec.electricalid AND e.electricalid = ?`, data).Scan(&result, &result2, &result3, &result4, &result5, &result6)
|
|
// if err != nil {
|
|
// c.AbortWithError(http.StatusBadRequest, err)
|
|
// c.String(http.StatusBadRequest, err.Error())
|
|
// }
|
|
// result, _ := encrypt(result)
|
|
// result2, _ := encrypt(result2)
|
|
// result3, _ := encrypt(result3)
|
|
// result4, _ := encrypt(result4)
|
|
// result5, _ := encrypt(result5)
|
|
// result6, _ := encrypt(result6)
|
|
|
|
// c.JSON(http.StatusOK, gin.H{
|
|
// "result": result,
|
|
// "result2": result2,
|
|
// "result3": result3,
|
|
// "result4": result4,
|
|
// "result5": result5,
|
|
// "result6": result6,
|
|
// })
|
|
|
|
}
|
|
})
|
|
|
|
// router.GET("/api/:method/:data/:data2", 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")
|
|
|
|
// // fixedMethod := strings.Replace(method, "~", "/", -1)
|
|
// // fixedData := strings.Replace(data, "~", "/", -1)
|
|
// // fixedData2 := strings.Replace(data2, "~", "/", -1)
|
|
|
|
// // method, err := decrypt(fixedMethod)
|
|
// // if err != nil {
|
|
// // c.AbortWithError(http.StatusBadGateway, err)
|
|
// // c.String(http.StatusBadGateway, err.Error())
|
|
// // }
|
|
// // data, err := decrypt(fixedData)
|
|
// // if err != nil {
|
|
// // c.AbortWithError(http.StatusBadGateway, err)
|
|
// // c.String(http.StatusBadGateway, err.Error())
|
|
// // }
|
|
// // data2, err := decrypt(fixedData2)
|
|
// // if err != nil {
|
|
// // c.AbortWithError(http.StatusBadGateway, err)
|
|
// // c.String(http.StatusBadGateway, err.Error())
|
|
// // }
|
|
|
|
// // log.Println("Method", method)
|
|
// // log.Println("Data", data)
|
|
// // log.Println("Data2", data2)
|
|
|
|
// if method == "SearchByNameBuilding" {
|
|
// var newData string
|
|
// if data2 == "empty" {
|
|
// newData = ""
|
|
// } else {
|
|
// newData = data2
|
|
// }
|
|
|
|
// err := db.QueryRow("SELECT IFNULL(b.receivingid, '') AS result FROM receiving b, customer c WHERE c.customerid = b.customerid AND c.lastName LIKE ? AND c.firstName = ?", "%"+data+"%", newData).Scan(&result)
|
|
// if err != nil {
|
|
// c.AbortWithError(http.StatusBadRequest, err)
|
|
// c.String(http.StatusBadRequest, err.Error())
|
|
// }
|
|
// c.JSON(http.StatusOK, gin.H{
|
|
// "result": result,
|
|
// })
|
|
|
|
// } else if method == "SearchByNameOccupancy" {
|
|
// var newData string
|
|
// if data2 == "empty" {
|
|
// newData = ""
|
|
// } else {
|
|
// newData = data2
|
|
// }
|
|
|
|
// err := db.QueryRow("SELECT IFNULL(b.occupancyid, '') AS result FROM occupancy b, customer c WHERE c.customerid = b.customerid AND c.lastName LIKE ? AND c.firstName = ?", "%"+data+"%", newData).Scan(&result)
|
|
// if err != nil {
|
|
// c.AbortWithError(http.StatusBadRequest, err)
|
|
// c.String(http.StatusBadRequest, err.Error())
|
|
// }
|
|
// c.JSON(http.StatusOK, gin.H{
|
|
// "result": result,
|
|
// })
|
|
|
|
// } else if method == "SearchByNameElectrical" {
|
|
// var newData string
|
|
// if data2 == "empty" {
|
|
// newData = ""
|
|
// } else {
|
|
// newData = data2
|
|
// }
|
|
|
|
// err := db.QueryRow("SELECT IFNULL(b.electricalid, '') AS result FROM electrical b, customer c WHERE c.customerid = b.customerid AND c.lastName LIKE ? AND c.firstName = ?", "%"+data+"%", newData).Scan(&result)
|
|
// if err != nil {
|
|
// c.AbortWithError(http.StatusBadRequest, err)
|
|
// c.String(http.StatusBadRequest, err.Error())
|
|
// }
|
|
// c.JSON(http.StatusOK, gin.H{
|
|
// "result": result,
|
|
// })
|
|
// }
|
|
// })
|
|
|
|
router.Run(":4320")
|
|
}
|