Updated backend
This commit is contained in:
parent
feeda84f4c
commit
76fe316bf7
1 changed files with 78 additions and 2 deletions
|
|
@ -96,7 +96,7 @@ func connect() {
|
|||
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")
|
||||
results, err := db.Query("SELECT DISTINCT IFNULL(electricalid, 0) 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())
|
||||
|
|
@ -178,7 +178,39 @@ func connect() {
|
|||
"result": array,
|
||||
})
|
||||
|
||||
case "get-listopapproval-electrical2":
|
||||
var status string
|
||||
array := []string{}
|
||||
|
||||
results, err := db.Query("SELECT DISTINCT IFNULL(electricalid, 0) AS result FROM electricaldocflowtxn WHERE remarks = ? LIMIT 20", "FOR ELECTRICAL ORDER OF PAYMENT APPROVAL")
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusBadRequest, err)
|
||||
c.String(http.StatusBadRequest, err.Error())
|
||||
}
|
||||
for results.Next() {
|
||||
var result string
|
||||
err = results.Scan(&result)
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusBadRequest, err)
|
||||
c.String(http.StatusBadRequest, err.Error())
|
||||
}
|
||||
err = db.QueryRow("SELECT IFNULL(remarks, '') AS status FROM electricaldocflowtxn WHERE electricaldocflowtxnid = (SELECT MAX(electricaldocflowtxnid) FROM electricaldocflowtxn WHERE electricalid = ?)", result).Scan(&status)
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusBadRequest, err)
|
||||
c.String(http.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
if status == "FOR ELECTRICAL ORDER OF PAYMENT APPROVAL" {
|
||||
array = append(array, result)
|
||||
}
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"result": array,
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
router.GET("/api/:method/:data", func(c *gin.Context) {
|
||||
|
|
@ -501,7 +533,7 @@ func connect() {
|
|||
"result": result,
|
||||
})
|
||||
|
||||
case "get-employeename":
|
||||
case "get-employeename":
|
||||
err := db.QueryRow("SELECT IFNULL(employeename, '') AS result FROM employee WHERE employeeid = ?", data).Scan(&result)
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusBadRequest, err)
|
||||
|
|
@ -511,6 +543,50 @@ func connect() {
|
|||
"result": result,
|
||||
})
|
||||
|
||||
case "get-opdetails-electrical":
|
||||
var result2, result3, result4, result5 string
|
||||
array := []string{}
|
||||
array2 := []string{}
|
||||
array3 := []string{}
|
||||
array4 := []string{}
|
||||
array5 := []string{}
|
||||
|
||||
results, err := db.Query("SELECT IFNULL(assessedbyid, 0) AS result, IFNULL(reviewedbyid, 0) AS result2, IFNULL(ref_bldgcomputationsheetid, 0) AS result3, IFNULL(amount, 0) AS result4, IFNULL(opDate, '') AS result5 FROM electrical_orderofpayment_new WHERE electricalid = ?", 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)
|
||||
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)
|
||||
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"result": array,
|
||||
"result2": array2,
|
||||
"result3": array3,
|
||||
"result4": array4,
|
||||
"result5": array5,
|
||||
})
|
||||
|
||||
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())
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"result": result,
|
||||
})
|
||||
|
||||
}
|
||||
})
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue