Cleanup backend

This commit is contained in:
Patrick Alvin Alcala 2025-09-24 16:52:16 +08:00
parent 69245a0ea0
commit 9fce20a0e5

View file

@ -4,8 +4,6 @@ import (
"database/sql"
"net/http"
"strings"
// "crypto/rand"
// "crypto/rsa"
// "crypto/x509"
@ -116,28 +114,23 @@ func connect() {
})
case "get-list-assessors":
var result2 string
array := []string{}
array2 := []string{}
results, err := db.Query("SELECT IFNULL(employeeid, '') AS employeeid, IFNULL(employeename, '') AS employeename 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)
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())
}
for results.Next() {
err = results.Scan(&result, &result2)
err = results.Scan(&result)
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,
"result": array,
})
case "get-list-approvers":
@ -446,776 +439,8 @@ func connect() {
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")
}