Compare commits
3 commits
5430bf7a1c
...
225269a7d4
| Author | SHA1 | Date | |
|---|---|---|---|
| 225269a7d4 | |||
| 11aaecdf0f | |||
| 2da2fbdd6e |
3 changed files with 196 additions and 31 deletions
7
.env
7
.env
|
|
@ -1,6 +1,7 @@
|
|||
# VITE_BACKEND=http://localhost:4320/api/
|
||||
VITE_BACKEND=http://localhost:4320/api/
|
||||
#VITE_BACKEND=https://ocboapps.davaocity.gov.ph/esign-server/api/
|
||||
VITE_BACKEND=http://192.168.7.163/server/api/
|
||||
# VITE_BACKEND=http://192.168.7.163/server/api/
|
||||
VITE_HEAD=ARCH. KHASHAYAR L. TOGHYANI
|
||||
VITE_PESO=₱
|
||||
VITE_HEADID=276
|
||||
VITE_HEADID=276
|
||||
VITE_PUBLICIP=58.69.136.59
|
||||
162
backend/main.go
162
backend/main.go
|
|
@ -19,9 +19,11 @@ import (
|
|||
|
||||
// DEV
|
||||
var connection string = "root:superuser@tcp(localhost:3306)/iips"
|
||||
var connectionPops string = "root:superuser@tcp(localhost:3306)/pops"
|
||||
|
||||
// SERVER
|
||||
// var connection string = "iips:iipsuser@tcp(192.168.7.100:3306)/iips"
|
||||
// var connectionPops string = "pops:Pops2023!@tcp(192.168.76.10:3306)/pops"
|
||||
|
||||
func main() {
|
||||
connect()
|
||||
|
|
@ -29,12 +31,14 @@ func main() {
|
|||
|
||||
func connect() {
|
||||
db, err := sql.Open("mysql", connection)
|
||||
dbpop, err := sql.Open("mysql", connectionPops)
|
||||
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
defer db.Close()
|
||||
defer dbpop.Close()
|
||||
|
||||
router := gin.Default()
|
||||
router.Use(cors.Default())
|
||||
|
|
@ -50,9 +54,8 @@ func connect() {
|
|||
|
||||
//SERVER
|
||||
// router.Use(cors.New(cors.Config{
|
||||
// // AllowOrigins: []string{"http://192.168.7.160:8080/esign"},
|
||||
// AllowAllOrigins: true,
|
||||
// AllowMethods: []string{"GET", "POST", "OPTIONS"},
|
||||
// AllowMethods: []string{"GET", "POST"},
|
||||
// AllowHeaders: []string{"Origin"},
|
||||
// ExposeHeaders: []string{"Content-Length"},
|
||||
// AllowCredentials: true,
|
||||
|
|
@ -525,6 +528,17 @@ func connect() {
|
|||
"result": result,
|
||||
})
|
||||
|
||||
case "get-idbyapplication-electrical":
|
||||
err := db.QueryRow(`SELECT IFNULL(electricalid, '') 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 {
|
||||
|
|
@ -654,14 +668,6 @@ func connect() {
|
|||
|
||||
case "get-printdetails-electrical":
|
||||
var result2, result3, result4, result5, result6, result7, result8 string
|
||||
// array := []string{}
|
||||
// array2 := []string{}
|
||||
// array3 := []string{}
|
||||
// array4 := []string{}
|
||||
// array5 := []string{}
|
||||
// array6 := []string{}
|
||||
// array7 := []string{}
|
||||
// array8 := []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
|
||||
|
|
@ -746,6 +752,59 @@ func connect() {
|
|||
c.JSON(http.StatusOK, gin.H{
|
||||
"result": result,
|
||||
})
|
||||
|
||||
case "get-popsdetails-electrical":
|
||||
var result2, result3, result4, result5, result6, result7, result8, result9, result10 string
|
||||
array := []string{}
|
||||
array2 := []string{}
|
||||
array3 := []string{}
|
||||
array4 := []string{}
|
||||
array5 := []string{}
|
||||
array6 := []string{}
|
||||
array7 := []string{}
|
||||
array8 := []string{}
|
||||
array9 := []string{}
|
||||
array10 := []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.accountdescription, '') AS result9, IFNULL(ref.accountcode, '') AS result10
|
||||
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 = ?`, 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, &result10)
|
||||
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)
|
||||
array10 = append(array10, result10)
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"result": array,
|
||||
"result2": array2,
|
||||
"result3": array3,
|
||||
"result4": array4,
|
||||
"result5": array5,
|
||||
"result6": array6,
|
||||
"result7": array7,
|
||||
"result8": array8,
|
||||
"result9": array9,
|
||||
"result10": array10,
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
|
|
@ -833,16 +892,17 @@ func connect() {
|
|||
})
|
||||
|
||||
router.POST("/api/post-newstatus-electrical", func(c *gin.Context) {
|
||||
type RegistrationData struct {
|
||||
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 registrationData RegistrationData
|
||||
if err := c.ShouldBindJSON(®istrationData); err != nil {
|
||||
var newstatusData NewstatusData
|
||||
if err := c.ShouldBindJSON(&newstatusData); err != nil {
|
||||
c.String(http.StatusBadRequest, "Invalid request body")
|
||||
return
|
||||
}
|
||||
|
|
@ -855,13 +915,13 @@ func connect() {
|
|||
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, ?, 0)`)
|
||||
VALUES (NULL, ?, ?, ?, NULL, ?, ?, ?, ?, 0)`)
|
||||
if err != nil {
|
||||
panic(err.Error())
|
||||
}
|
||||
defer dbpost.Close()
|
||||
|
||||
exec, err := dbpost.Exec(registrationData.Data, registrationData.Data2, registrationData.Data3, registrationData.Data4, registrationData.Data5, registrationData.Data6)
|
||||
exec, err := dbpost.Exec(newstatusData.Data, newstatusData.Data2, newstatusData.Data3, newstatusData.Data4, newstatusData.Data5, newstatusData.Data6, newstatusData.Data7)
|
||||
if err != nil {
|
||||
panic(err.Error())
|
||||
}
|
||||
|
|
@ -879,12 +939,13 @@ func connect() {
|
|||
|
||||
})
|
||||
|
||||
router.POST("/api/update-opapproved-electrical", func(c *gin.Context) {
|
||||
type UpdateOpData struct {
|
||||
Data int `json:"data"`
|
||||
router.POST("/api/update-docflow-electrical", func(c *gin.Context) {
|
||||
type UpdateDocflowData struct {
|
||||
Data int `json:"data"`
|
||||
Data2 string `json:"data2"`
|
||||
}
|
||||
var updateOpData UpdateOpData
|
||||
if err := c.ShouldBindJSON(&updateOpData); err != nil {
|
||||
var updateDocflowData UpdateDocflowData
|
||||
if err := c.ShouldBindJSON(&updateDocflowData); err != nil {
|
||||
c.String(http.StatusBadRequest, "Invalid request body")
|
||||
return
|
||||
}
|
||||
|
|
@ -896,13 +957,13 @@ func connect() {
|
|||
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_release = 0 AND is_paid = 0 AND popstransmitted = 0")
|
||||
dbpost, err := db.Prepare("UPDATE electricaldocflowtxn SET is_approve = 1 WHERE electricalid = ? AND remarks = ?")
|
||||
if err != nil {
|
||||
panic(err.Error())
|
||||
}
|
||||
defer dbpost.Close()
|
||||
|
||||
exec, err := dbpost.Exec(updateOpData.Data)
|
||||
exec, err := dbpost.Exec(updateDocflowData.Data, updateDocflowData.Data2)
|
||||
if err != nil {
|
||||
panic(err.Error())
|
||||
}
|
||||
|
|
@ -913,9 +974,9 @@ func connect() {
|
|||
}
|
||||
|
||||
if affect > 0 {
|
||||
c.String(http.StatusOK, "Success on Updating Order of Payment for Approval")
|
||||
c.String(http.StatusOK, "Success on Updating Docflow on Electrical")
|
||||
} else {
|
||||
c.String(http.StatusInternalServerError, "Failed on Updating Order of Payment for Approval")
|
||||
c.String(http.StatusInternalServerError, "Failed on Updating Docflow on Electrical")
|
||||
}
|
||||
})
|
||||
|
||||
|
|
@ -1001,5 +1062,58 @@ func connect() {
|
|||
}
|
||||
})
|
||||
|
||||
router.POST("/api/post-pops", 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.Run(":4320")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import { checkConnection, createPdf } from '../../utils/functions'
|
|||
import { FaSolidThumbsUp } from 'solid-icons/fa'
|
||||
import { _employeeName } from '../../stores/employee'
|
||||
import { useNavigate } from '@solidjs/router'
|
||||
import { _applicationNo, _date, _optn, _name, _location, _type, _assessor, _feeList, _codeList, _amountList, _signatureAssessor, _signatureApprover, _assessorid, _approvedDate, _assessedDate } from '../../stores/pdfinfo'
|
||||
|
||||
const API = import.meta.env.VITE_BACKEND
|
||||
const PESO = import.meta.env.VITE_PESO
|
||||
|
|
@ -96,10 +97,12 @@ export default () => {
|
|||
return
|
||||
}
|
||||
|
||||
signed = await setNewStatus('ELECTRICAL ORDER OF PAYMENT APPROVED AND SIGNED', '170', 'ELECOPAPPROVEDSIGNED')
|
||||
signed = await setNewStatus('ELECTRICAL ORDER OF PAYMENT APPROVED AND SIGNED', '170', 'ELECOPAPPROVEDSIGNED', 1)
|
||||
const approvedid = await getIdByApplication(application)
|
||||
updateDocflow(approvedid, 'FOR ELECTRICAL ORDER OF PAYMENT APPROVAL')
|
||||
if (!signed) return
|
||||
|
||||
forprinting = await setNewStatus('FOR ELECTRICAL ORDER OF PAYMENT PRINTING', '95', 'ELECOPPRINT')
|
||||
forprinting = await setNewStatus('FOR ELECTRICAL ORDER OF PAYMENT PRINTING', '95', 'ELECOPPRINT', 0)
|
||||
if (!forprinting) return
|
||||
|
||||
updateOrderofpayment = await updateOp()
|
||||
|
|
@ -111,7 +114,7 @@ export default () => {
|
|||
}
|
||||
}
|
||||
|
||||
const setNewStatus = async (status: string, tag: string, tagword: string) => {
|
||||
const setNewStatus = async (status: string, tag: string, tagword: string, approved: number) => {
|
||||
const today = new Date()
|
||||
const formattedDate = dayjs(today).format('YYYY-MM-DD HH:mm:ss')
|
||||
const statusid = parseInt(applicationId().toString())
|
||||
|
|
@ -119,7 +122,7 @@ export default () => {
|
|||
try {
|
||||
await ofetch(API + 'post-newstatus-electrical', {
|
||||
method: 'POST',
|
||||
body: { data: statusid, data2: formattedDate, data3: status, data4: tag, data5: tagword, data6: parseInt(ID) },
|
||||
body: { data: statusid, data2: formattedDate, data3: status, data4: tag, data5: tagword, data6: parseInt(approved.toString()), data7: parseInt(ID) },
|
||||
})
|
||||
return true
|
||||
} catch {
|
||||
|
|
@ -139,6 +142,36 @@ export default () => {
|
|||
}
|
||||
}
|
||||
|
||||
const getPrintDetails = async (id: number) => {
|
||||
const response = await ofetch(API + 'get-printdetails-electrical/' + id)
|
||||
const applicationno = response.result
|
||||
const date = response.result2
|
||||
const location = response.result3
|
||||
const name = response.result8
|
||||
const type = `${response.result4} - ${response.result5}`
|
||||
const assessor = response.result7
|
||||
|
||||
_optn.set('M' + applicationno.split('-')[0] + applicationno.split('-')[1])
|
||||
_applicationNo.set(applicationno)
|
||||
_date.set(dayjs(date).format('MMMM DD, YYYY'))
|
||||
_name.set(name)
|
||||
_location.set(location)
|
||||
_type.set(type)
|
||||
_assessor.set(assessor)
|
||||
_assessorid.set(employeeId())
|
||||
}
|
||||
|
||||
const postPops = async (application: string) => {
|
||||
const today = new Date()
|
||||
const formattedDate = dayjs(today).format('YYYY-MM-DD')
|
||||
const formattedDatewithTime = dayjs(today).format('YYYY-MM-DD HH:mm:ss')
|
||||
|
||||
await ofetch(API + 'update-opapproved-electrical', {
|
||||
method: 'POST',
|
||||
body: { data: application, data2: formattedDate },
|
||||
})
|
||||
}
|
||||
|
||||
// const calculateAmounts = () => {
|
||||
// const amounts: string[] = amountList()
|
||||
// let gflguList: number[] = []
|
||||
|
|
@ -212,6 +245,23 @@ export default () => {
|
|||
})
|
||||
}
|
||||
|
||||
const updateDocflow = async (electricalid: number, status: string) => {
|
||||
await ofetch(API + 'update-docflow-electrical', {
|
||||
method: 'POST',
|
||||
body: { data: parseInt(electricalid.toString()), data2: status },
|
||||
})
|
||||
}
|
||||
|
||||
const getIdByApplication = async (applicationNo: string) => {
|
||||
try {
|
||||
const response = await ofetch(API + 'get-idbyapplication-electrical/' + applicationNo, { parseResponse: JSON.parse })
|
||||
const result = response.result
|
||||
return parseInt(result)
|
||||
} catch {
|
||||
return 0
|
||||
}
|
||||
}
|
||||
|
||||
const logout = async () => {
|
||||
removeEmployee()
|
||||
navigate('/')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue