From b8ead5e603ad98f953a20132cc74b2cdb631cfef Mon Sep 17 00:00:00 2001 From: Patrick Alvin Alcala Date: Thu, 9 Oct 2025 16:42:28 +0800 Subject: [PATCH 1/7] Fixed print details --- backend/main.go | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/backend/main.go b/backend/main.go index d2ebb55..691ed4c 100644 --- a/backend/main.go +++ b/backend/main.go @@ -652,7 +652,7 @@ func connect() { }) case "get-printdetails-electrical": - var result2, result3, result4, result5, result6, result7, result8, result9 string + var result2, result3, result4, result5, result6, result7, result8 string array := []string{} array2 := []string{} array3 := []string{} @@ -661,9 +661,8 @@ func connect() { array6 := []string{} array7 := []string{} array8 := []string{} - array9 := []string{} - results, err := db.Query(`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, IFNULL(op.optn, '') AS result9 + results, err := db.Query(`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 WHERE el.customerid = cu.customerid AND el.ref_elec_occupancyid = u.ref_elec_occupancyid AND u.ref_occupancyid = occ.ref_occupancyid AND op.assessedbyid = e.employeeid AND el.electricalid = op.electricalid AND op.is_approve = 0 AND op.for_approval = 1 AND op.is_release = 0 AND is_paid = 0 AND popstransmitted = 0 AND el.electricalid = ?`, data) @@ -673,7 +672,7 @@ func connect() { return } for results.Next() { - err = results.Scan(&result, &result2, &result3, &result4, &result5, &result6, &result7, &result8, &result9) + err = results.Scan(&result, &result2, &result3, &result4, &result5, &result6, &result7, &result8) if err != nil { c.AbortWithError(http.StatusBadRequest, err) c.String(http.StatusBadRequest, err.Error()) @@ -687,8 +686,6 @@ func connect() { array6 = append(array6, result6) array7 = append(array7, result7) array8 = append(array8, result8) - array9 = append(array9, result9) - } c.JSON(http.StatusOK, gin.H{ "result": array, @@ -699,7 +696,6 @@ func connect() { "result6": array6, "result7": array7, "result8": array8, - "result9": array9, }) } From 32ab2bdc8c1d85ebae2e9a33f529f49e79bc861b Mon Sep 17 00:00:00 2001 From: Patrick Alvin Alcala Date: Thu, 9 Oct 2025 16:42:43 +0800 Subject: [PATCH 2/7] Fixed store dependencies --- package.json | 1 + pnpm-lock.yaml | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/package.json b/package.json index acd9403..1b1ae89 100644 --- a/package.json +++ b/package.json @@ -29,6 +29,7 @@ "solidjs-use": "^2.3.0" }, "devDependencies": { + "@nanostores/solid": "^1.1.1", "@types/crypto-js": "^4.2.2", "@types/node": "^24.7.0", "sass-embedded": "^1.93.2", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index f088af1..3938916 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -63,6 +63,9 @@ importers: specifier: ^2.3.0 version: 2.3.0 devDependencies: + '@nanostores/solid': + specifier: ^1.1.1 + version: 1.1.1(nanostores@1.0.1)(solid-js@1.9.9) '@types/crypto-js': specifier: ^4.2.2 version: 4.2.2 @@ -618,6 +621,12 @@ packages: peerDependencies: solid-js: ^1.8.8 + '@nanostores/solid@1.1.1': + resolution: {integrity: sha512-gF0Eat1/c3hOaklBMSVoEjcNzJc5zGk4VSg94H9LPmXYww1pxgr7zylpi3jjyxRu24c8+aYNkmRWzolAwzSA1A==} + peerDependencies: + nanostores: '>=0.9.0 <2.0.0' + solid-js: ^1.6.0 + '@parcel/watcher-android-arm64@2.5.1': resolution: {integrity: sha512-KF8+j9nNbUN8vzOFDpRMsaKBHZ/mcjEjMToVMJOhTozkDonQFFrRcfdLWn6yWKCmJKmdVxSgHiYvTCef4/qcBA==} engines: {node: '>= 10.0.0'} @@ -2353,6 +2362,11 @@ snapshots: '@solid-primitives/utils': 6.3.2(solid-js@1.9.9) solid-js: 1.9.9 + '@nanostores/solid@1.1.1(nanostores@1.0.1)(solid-js@1.9.9)': + dependencies: + nanostores: 1.0.1 + solid-js: 1.9.9 + '@parcel/watcher-android-arm64@2.5.1': optional: true From 1de668d7a7d390e05369c2bf35db65265239c2d2 Mon Sep 17 00:00:00 2001 From: Patrick Alvin Alcala Date: Thu, 9 Oct 2025 16:42:54 +0800 Subject: [PATCH 3/7] Added pdf info storage --- src/stores/pdfinfo.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 src/stores/pdfinfo.ts diff --git a/src/stores/pdfinfo.ts b/src/stores/pdfinfo.ts new file mode 100644 index 0000000..2b818bd --- /dev/null +++ b/src/stores/pdfinfo.ts @@ -0,0 +1,10 @@ +import { atom } from 'nanostores' + +export const _optn = atom('') +export const _applicationNo = atom('') +export const _date = atom('') +export const _name = atom('') +export const _location = atom('') +export const _type = atom('') +export const _code = atom('') + From 519b901928b401c63eb9a88545089e5876df0a59 Mon Sep 17 00:00:00 2001 From: Patrick Alvin Alcala Date: Thu, 9 Oct 2025 16:43:05 +0800 Subject: [PATCH 4/7] Adjusted table --- src/styles/classes.sass | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/styles/classes.sass b/src/styles/classes.sass index 742cc00..fc03ee4 100644 --- a/src/styles/classes.sass +++ b/src/styles/classes.sass @@ -77,13 +77,12 @@ padding: 16px .table - width: 90% + width: 80% border-collapse: collapse margin: 2rem box-shadow: inset 0 1px 2px #16212C, 0 2px 4px #2a3f5332, 0 4px 8px #344c654e th, td - // border: 1px solid vars.$tableBorderColor padding: 0.75rem text-align: left font-size: 1rem From afa20dbc940351879690bb181e1e00d283e0d442 Mon Sep 17 00:00:00 2001 From: Patrick Alvin Alcala Date: Thu, 9 Oct 2025 16:43:15 +0800 Subject: [PATCH 5/7] Update assessors page --- src/pages/AssessorPage/Assessor.tsx | 47 +++++++++++++++++++++++------ 1 file changed, 38 insertions(+), 9 deletions(-) diff --git a/src/pages/AssessorPage/Assessor.tsx b/src/pages/AssessorPage/Assessor.tsx index 0e30b27..6f632b9 100644 --- a/src/pages/AssessorPage/Assessor.tsx +++ b/src/pages/AssessorPage/Assessor.tsx @@ -9,6 +9,7 @@ import { checkConnection, createPdf } from '../../utils/functions' import { FaSolidThumbsUp } from 'solid-icons/fa' import { _employeeName, _employeeId } from '../../stores/employee' import { useNavigate } from '@solidjs/router' +import { _applicationNo, _date, _optn, _name, _location, _type } from '../../stores/pdfinfo' const API = import.meta.env.VITE_BACKEND const PESO = import.meta.env.VITE_PESO @@ -47,6 +48,10 @@ export default () => { const [employeeId, setEmployeeId] = createSignal(0) const [employeeName, setEmployeeName] = createSignal('') + // const [docApplicationNo, setDocApplicationNo] = createSignal('') + // const [docDate, setDocDate] = createSignal('') + // const [docLocation, setDocLocation] = createSignal('') + const checkAccess = async (access: string) => { try { const response = await ofetch(`${API}check-access/${access}/${employeeId()}`) @@ -58,6 +63,26 @@ export default () => { } } + const getPrintDetails = async (id: number) => { + const response = await ofetch(API + 'get-printdetails-electrical/' + id) + const applicationno = response.result[0] + const date = response.result2[0] + const location = response.result3[0] + const name = response.result8[0] + const type = `${response.result4[0]} - ${response.result5[0]}` + + _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) + + // setDocApplicationNo(applicationno) + // setDocDate(dayjs(date).format('MMMM DD, YYYY')) + // setDocLocation(location) + } + // const calculateAmounts = () => { // const amounts: string[] = amountList() // let gflguList: number[] = [] @@ -114,6 +139,8 @@ export default () => { // setAmountList(op.result9) // setDateOpList(op.result10) // calculateAmounts() + + getPrintDetails(op.result11[0]) } const calculateTotal = (list: number[]) => { @@ -161,18 +188,20 @@ export default () => { return } - signed = await setNewStatus('ELECTRICAL ORDER OF PAYMENT PRINTED', '171', 'ELECOPPRINTED') - if (!signed) return + // signed = await setNewStatus('ELECTRICAL ORDER OF PAYMENT PRINTED', '171', 'ELECOPPRINTED') + // if (!signed) return - forprinting = await setNewStatus('FOR ELECTRICAL OFFICIAL RECEIPT VALIDATION', '98', 'ELECORVALIDATE') - if (!forprinting) return + // forprinting = await setNewStatus('FOR ELECTRICAL OFFICIAL RECEIPT VALIDATION', '98', 'ELECORVALIDATE') + // if (!forprinting) return - updateOrderofpayment = await updateOp() + // updateOrderofpayment = await updateOp() - if (updateOrderofpayment) { - setPrintedApplication(application) - setPrinted(true) - } + // if (updateOrderofpayment) { + // setPrintedApplication(application) + // setPrinted(true) + // getPrintDetails(applicationId()) + createPdf() + // } } const updateOp = async () => { From c8eab94bf96134cb35aaa5fd3b58143f2714110a Mon Sep 17 00:00:00 2001 From: Patrick Alvin Alcala Date: Thu, 9 Oct 2025 16:43:26 +0800 Subject: [PATCH 6/7] Updated pdf --- src/utils/functions/createPdf.ts | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/src/utils/functions/createPdf.ts b/src/utils/functions/createPdf.ts index 44c16dd..f3e0166 100644 --- a/src/utils/functions/createPdf.ts +++ b/src/utils/functions/createPdf.ts @@ -1,27 +1,25 @@ import jsPDF from 'jspdf' // @ts-ignore import jspdfBarcode from 'jspdf-barcode' +// import { ofetch } from 'ofetch' +// import dayjs from 'dayjs' +import { _optn, _applicationNo, _date, _name, _type, _location } from '../../stores/pdfinfo' -export default () => { +export default async () => { const PESO = import.meta.env.VITE_PESO - const OPTN = 'M25-000123' - const APPLICATION = '25-000123' - const DATE = 'October 8, 2025' - const NAME = 'BRUCE WAYNE' - const LOCATION = 'DAVAO CITY' - const TYPE = 'RESIDENTIAL - NEW INSTALLATION' + const API = import.meta.env.VITE_API + + const OPTN = _optn.get() + const APPLICATION = _applicationNo.get() + const DATE = _date.get() + const NAME = _name.get() + const LOCATION = _location.get() + const TYPE = _type.get() const CODE = '40201010-5-3' const AMOUNT = 100 - const ASSESSOR = 'ENGR. BATMAN' - const APPROVER = 'AR. KHASHAYAR L. TOGHYANI' - - const init = async () => { - // console.log('yeah') - console.log(PESO) - } - - init() + // const ASSESSOR = 'ENGR. BATMAN' + // const APPROVER = 'AR. KHASHAYAR L. TOGHYANI' const doc = new jsPDF({ orientation: 'l', From 217b7fa3d78ea6c0a6220d3faa81541a7a5518f4 Mon Sep 17 00:00:00 2001 From: Patrick Alvin Alcala Date: Thu, 9 Oct 2025 16:44:07 +0800 Subject: [PATCH 7/7] Created optimizedLogo --- src/utils/scripts/optimizeLogo.js | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 src/utils/scripts/optimizeLogo.js diff --git a/src/utils/scripts/optimizeLogo.js b/src/utils/scripts/optimizeLogo.js new file mode 100644 index 0000000..ed48aac --- /dev/null +++ b/src/utils/scripts/optimizeLogo.js @@ -0,0 +1,30 @@ +import sharp from 'sharp' +import * as fs from 'fs' +import * as path from 'path' +import { consola } from 'consola' +;(async () => { + try { + const dirPath = path.resolve('../../../public') + const webpImage = 'src/assets/images/optimized/logo.webp' + const avifImage = 'src/assets/images/optimized/logo.avif' + const inputSrc = 'src/assets/images/logo.png' + + const avifBuffer = await sharp(inputSrc).avif({ quality: 60 }).resize(props.size).toBuffer() + await sharp(avifBuffer).toFile(avifImage) + + const webpBuffer = await sharp(inputSrc).webp({ quality: 75 }).resize(props.size).toBuffer() + await sharp(webpBuffer).toFile(webpImage) + + if (fs.existsSync(dirPath)) { + const inputSrc = '../../assets/images/logo.png' + const favicon = dirPath + '/favicon.png' + const faviconBuffer = await sharp(inputSrc).png({ quality: 90 }).resize(50).toBuffer() + await sharp(faviconBuffer).toFile(favicon) + consola.success('Favicon generated successfully') + } else { + consola.error('Directory does not exist:', dirPath) + } + } catch (error) { + consola.error('Error generating favicon:', error) + } +})()