Added new api for mobile

This commit is contained in:
Patrick Alvin Alcala 2026-02-06 18:46:29 +08:00
parent edc40aea6a
commit 0b90b911b6

View file

@ -1361,18 +1361,19 @@ func connect() {
} }
case "get-transactions": case "get-transactions":
var result2 string var result2, result3 string
array := []string{} array := []string{}
array2 := []string{} array2 := []string{}
array3 := []string{}
results, err := db.Query(`SELECT IFNULL(referenceNo, '') AS result, IFNULL(DATE_FORMAT(date_signed, '%M %e, %Y'), '') AS result2 FROM esign_transactions WHERE esignid = (SELECT esignid FROM esign WHERE employeeid = (SELECT employeeid FROM employee WHERE employeename = ?))`, data) results, err := db.Query(`SELECT IFNULL(referenceNo, '') AS result, IFNULL(DATE_FORMAT(date_signed, '%M %e, %Y'), '') AS result2, IFNULL(DATE_FORMAT(date_signed, '%h:%i %p'), '') AS result3 FROM esign_transactions WHERE esignid = (SELECT esignid FROM esign WHERE employeeid = (SELECT employeeid FROM employee WHERE employeename = ?)) ORDER BY date_signed DESC LIMIT 300`, data)
if err != nil { if err != nil {
c.AbortWithError(http.StatusBadRequest, err) c.AbortWithError(http.StatusBadRequest, err)
c.String(http.StatusBadRequest, err.Error()) c.String(http.StatusBadRequest, err.Error())
return return
} }
for results.Next() { for results.Next() {
err = results.Scan(&result, &result2) err = results.Scan(&result, &result2, &result3)
if err != nil { if err != nil {
c.AbortWithError(http.StatusBadRequest, err) c.AbortWithError(http.StatusBadRequest, err)
c.String(http.StatusBadRequest, err.Error()) c.String(http.StatusBadRequest, err.Error())
@ -1380,10 +1381,12 @@ func connect() {
} }
array = append(array, result) array = append(array, result)
array2 = append(array2, result2) array2 = append(array2, result2)
array3 = append(array3, result3)
} }
c.JSON(http.StatusOK, gin.H{ c.JSON(http.StatusOK, gin.H{
"result": array, "result": array,
"result2": array2, "result2": array2,
"result3": array3,
}) })
case "get-transactions-count": case "get-transactions-count":
@ -1396,8 +1399,18 @@ func connect() {
c.JSON(http.StatusOK, gin.H{ c.JSON(http.StatusOK, gin.H{
"result": result, "result": result,
}) })
}
case "get-esignid-byname":
err := db.QueryRow(`SELECT IFNULL(esignid, 0) AS result FROM esign WHERE employeeid = (SELECT employeeid 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,
})
}
}) })
router.GET("/api/:method/:data/:data2/fetch-data", func(c *gin.Context) { router.GET("/api/:method/:data/:data2/fetch-data", func(c *gin.Context) {
@ -1448,6 +1461,68 @@ func connect() {
c.JSON(http.StatusOK, gin.H{ c.JSON(http.StatusOK, gin.H{
"result": result, "result": result,
}) })
case "get-transactions-filter":
var result2, result3 string
array := []string{}
array2 := []string{}
array3 := []string{}
results, err := db.Query("SELECT IFNULL(referenceNo, '') AS result, IFNULL(DATE_FORMAT(date_signed, '%M %e, %Y'), '') AS result2, IFNULL(DATE_FORMAT(date_signed, '%h:%i %p'), '') AS result3 FROM esign_transactions WHERE esignid = (SELECT esignid FROM esign WHERE employeeid = (SELECT employeeid FROM employee WHERE employeename = ?)) AND referenceNo LIKE ? ORDER BY date_signed DESC", data, "%"+data2+"%")
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-infoapproval-electrical":
var result2, result3, result4 string
array := []string{}
array2 := []string{}
array3 := []string{}
array4 := []string{}
results, err := db.Query(`SELECT 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 result, DATE_FORMAT(et.date_signed, '%M') AS result2, DATE_FORMAT(et.date_signed, '%e') AS result3, DATE_FORMAT(et.date_signed, '%Y') AS result4
FROM electrical e JOIN customer c ON e.customerid = c.customerid JOIN esign_transactions et ON e.electricalNo = et.referenceNo WHERE e.electricalNo = ? AND et.esignid = ?`, data, data2)
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,
})
} }
}) })