Compare commits

..

No commits in common. "225269a7d43c337dfc8277282d571612a08fbc51" and "5430bf7a1c7fde1cf5c03d93e68856b56c7dbf48" have entirely different histories.

3 changed files with 31 additions and 196 deletions

7
.env
View file

@ -1,7 +1,6 @@
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_PUBLICIP=58.69.136.59
VITE_HEADID=276

View file

@ -19,11 +19,9 @@ 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()
@ -31,14 +29,12 @@ 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())
@ -54,8 +50,9 @@ func connect() {
//SERVER
// router.Use(cors.New(cors.Config{
// // AllowOrigins: []string{"http://192.168.7.160:8080/esign"},
// AllowAllOrigins: true,
// AllowMethods: []string{"GET", "POST"},
// AllowMethods: []string{"GET", "POST", "OPTIONS"},
// AllowHeaders: []string{"Origin"},
// ExposeHeaders: []string{"Content-Length"},
// AllowCredentials: true,
@ -528,17 +525,6 @@ 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 {
@ -668,6 +654,14 @@ 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
@ -752,59 +746,6 @@ 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,
})
}
})
@ -892,17 +833,16 @@ func connect() {
})
router.POST("/api/post-newstatus-electrical", func(c *gin.Context) {
type NewstatusData struct {
type RegistrationData 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 newstatusData NewstatusData
if err := c.ShouldBindJSON(&newstatusData); err != nil {
var registrationData RegistrationData
if err := c.ShouldBindJSON(&registrationData); err != nil {
c.String(http.StatusBadRequest, "Invalid request body")
return
}
@ -915,13 +855,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)`)
VALUES (NULL, ?, ?, ?, NULL, ?, ?, 0, ?, 0)`)
if err != nil {
panic(err.Error())
}
defer dbpost.Close()
exec, err := dbpost.Exec(newstatusData.Data, newstatusData.Data2, newstatusData.Data3, newstatusData.Data4, newstatusData.Data5, newstatusData.Data6, newstatusData.Data7)
exec, err := dbpost.Exec(registrationData.Data, registrationData.Data2, registrationData.Data3, registrationData.Data4, registrationData.Data5, registrationData.Data6)
if err != nil {
panic(err.Error())
}
@ -939,13 +879,12 @@ func connect() {
})
router.POST("/api/update-docflow-electrical", func(c *gin.Context) {
type UpdateDocflowData struct {
Data int `json:"data"`
Data2 string `json:"data2"`
router.POST("/api/update-opapproved-electrical", func(c *gin.Context) {
type UpdateOpData struct {
Data int `json:"data"`
}
var updateDocflowData UpdateDocflowData
if err := c.ShouldBindJSON(&updateDocflowData); err != nil {
var updateOpData UpdateOpData
if err := c.ShouldBindJSON(&updateOpData); err != nil {
c.String(http.StatusBadRequest, "Invalid request body")
return
}
@ -957,13 +896,13 @@ func connect() {
c.Writer.Header().Set("X-Download-Options", "noopen")
c.Writer.Header().Set("Referrer-Policy", "no-referrer")
dbpost, err := db.Prepare("UPDATE electricaldocflowtxn SET is_approve = 1 WHERE electricalid = ? AND remarks = ?")
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")
if err != nil {
panic(err.Error())
}
defer dbpost.Close()
exec, err := dbpost.Exec(updateDocflowData.Data, updateDocflowData.Data2)
exec, err := dbpost.Exec(updateOpData.Data)
if err != nil {
panic(err.Error())
}
@ -974,9 +913,9 @@ func connect() {
}
if affect > 0 {
c.String(http.StatusOK, "Success on Updating Docflow on Electrical")
c.String(http.StatusOK, "Success on Updating Order of Payment for Approval")
} else {
c.String(http.StatusInternalServerError, "Failed on Updating Docflow on Electrical")
c.String(http.StatusInternalServerError, "Failed on Updating Order of Payment for Approval")
}
})
@ -1062,58 +1001,5 @@ 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")
}

View file

@ -9,7 +9,6 @@ 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
@ -97,12 +96,10 @@ export default () => {
return
}
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')
signed = await setNewStatus('ELECTRICAL ORDER OF PAYMENT APPROVED AND SIGNED', '170', 'ELECOPAPPROVEDSIGNED')
if (!signed) return
forprinting = await setNewStatus('FOR ELECTRICAL ORDER OF PAYMENT PRINTING', '95', 'ELECOPPRINT', 0)
forprinting = await setNewStatus('FOR ELECTRICAL ORDER OF PAYMENT PRINTING', '95', 'ELECOPPRINT')
if (!forprinting) return
updateOrderofpayment = await updateOp()
@ -114,7 +111,7 @@ export default () => {
}
}
const setNewStatus = async (status: string, tag: string, tagword: string, approved: number) => {
const setNewStatus = async (status: string, tag: string, tagword: string) => {
const today = new Date()
const formattedDate = dayjs(today).format('YYYY-MM-DD HH:mm:ss')
const statusid = parseInt(applicationId().toString())
@ -122,7 +119,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(approved.toString()), data7: parseInt(ID) },
body: { data: statusid, data2: formattedDate, data3: status, data4: tag, data5: tagword, data6: parseInt(ID) },
})
return true
} catch {
@ -142,36 +139,6 @@ 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[] = []
@ -245,23 +212,6 @@ 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('/')