diff --git a/backend/main.go b/backend/main.go index 5b692b6..25248e2 100644 --- a/backend/main.go +++ b/backend/main.go @@ -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, + }) + } }) diff --git a/src/components/Column/Column.sass b/src/components/Column/Column.sass index b26f108..20969b2 100644 --- a/src/components/Column/Column.sass +++ b/src/components/Column/Column.sass @@ -14,7 +14,7 @@ align-items: center align-content: center -.column-right +.column-bottom display: flex flex-direction: column flex-wrap: wrap diff --git a/src/components/Column/Column.tsx b/src/components/Column/Column.tsx index 73a19c3..aec3d3e 100644 --- a/src/components/Column/Column.tsx +++ b/src/components/Column/Column.tsx @@ -3,7 +3,7 @@ import type { JSXElement } from 'solid-js' interface Props { children: JSXElement - content?: 'top' | 'center' | 'right' | 'split' | 'spaced' + content?: 'top' | 'center' | 'bottom' | 'split' | 'spaced' gap?: number } diff --git a/src/components/Modal/ModalButton.tsx b/src/components/Modal/ModalButton.tsx index e83f82f..7153a17 100644 --- a/src/components/Modal/ModalButton.tsx +++ b/src/components/Modal/ModalButton.tsx @@ -13,6 +13,7 @@ interface Props { design?: 'bu-primary' | 'bu-link' | 'bu-info' | 'bu-success' | 'bu-warning' | 'bu-danger' | 'bu-dark' | 'bu-light' | 'bu-text' | 'bu-ghost' | 'bo-primary' | 'bo-secondary' | 'bo-success' | 'bo-danger' | 'bo-warning' | 'bo-info' | 'bo-light' | 'bo-dark' | 'bo-link' width?: number wide?: boolean + class?: string } export default (props: Props) => { diff --git a/src/pages/LoginPage/Login.tsx b/src/pages/LoginPage/Login.tsx index e5346cf..7916775 100644 --- a/src/pages/LoginPage/Login.tsx +++ b/src/pages/LoginPage/Login.tsx @@ -138,7 +138,7 @@ export default () => { - Click anywhere to close + Click anywhere to proceed diff --git a/src/pages/MainPage/Main.sass b/src/pages/MainPage/Main.sass index f52d846..7e66e00 100644 --- a/src/pages/MainPage/Main.sass +++ b/src/pages/MainPage/Main.sass @@ -14,3 +14,101 @@ h1 .name font-size: 1.25rem + +.tabs + width: 100% + + &[data-orientation="vertical"] + display: flex + + &__list + position: relative + display: flex + + &__list[data-orientation="horizontal"] + align-items: center + + &__list[data-orientation="vertical"] + flex-direction: column + align-items: stretch + + &__indicator + position: absolute + background-color: hsl(200 98% 39%) + transition: all 250ms + + &__indicator[data-orientation="horizontal"] + bottom: -1px + height: 2px + + &__indicator[data-orientation="vertical"] + right: -1px + width: 2px + + &__trigger + display: inline-block + padding: 8px 16px + outline: none + cursor: pointer + + &__trigger:hover + background-color: hsl(0 0% 98%) + color: hsl(240 5% 34%) + + &__trigger:focus-visible + background-color: hsl(240 5% 96%) + +.tabs__trigger[data-disabled], +.tabs__trigger[data-disabled]:hover + opacity: 0.5 + background-color: transparent + +.tabs__content + padding: 16px + +.table + width: 100% + border-collapse: collapse + margin: 2rem + + th, td + border: 1px solid vars.$tableBorderColor + padding: 0.75rem + text-align: left + font-size: 1.1rem + + td:nth-child(1) + width: 12rem + + td:nth-child(3) + width: 9rem + + th + background-color: vars.$tableHeaderBackground + color: white + +.modal + font-weight: 500 + + &__application-number + font-size: 1.75rem + + &__name + padding: 1rem 0 0 0 + font-size: 1rem + + &__row + display: flex + flex-direction: column + flex-wrap: wrap + justify-content: flex-start + align-items: flex-start + gap: 0.5rem + padding: 2rem 0 0 0 + + &__label + font-size: 0.75rem + + &__detail + font-size: 1rem + diff --git a/src/pages/MainPage/Main.tsx b/src/pages/MainPage/Main.tsx index 6d60518..3543735 100644 --- a/src/pages/MainPage/Main.tsx +++ b/src/pages/MainPage/Main.tsx @@ -1,9 +1,102 @@ import './Main.sass' -import { Logo, Link, Page, Row, Padding, Table } from '../../components/' +import { Logo, Link, Page, Row, Padding, ModalButton, Box, Column } from '../../components/' import { FiLogOut } from 'solid-icons/fi' -// import { ofetch } from 'ofetch' +import { Tabs } from '@kobalte/core/tabs' +import { ofetch } from 'ofetch' +import { onMount, createSignal } from 'solid-js' +import dayjs from 'dayjs' + +const API = import.meta.env.VITE_BACKEND export default () => { + const [updatedList, setUpdatedList] = createSignal([]) + const [totalOp, setTotalOp] = createSignal(0) + const [assessor, setAssessor] = createSignal('') + const [approver, setApprover] = createSignal('') + const [dateOp, setDateOp] = createSignal('') + + const getListForApproval = async () => { + try { + const response = await ofetch(API + 'get-listopapproval-electrical', { parseResponse: JSON.parse }) + return response.result + } catch (error) { + console.error(error) + } + } + + const getListOfReadyForApprovalFiltered = async (list: number[]) => { + let newList: number[] = [] + + for (let i = 0; i < list.length; i++) { + const response = await ofetch(API + 'get-laststatus-electrical/' + list[i], { parseResponse: JSON.parse }) + if (response.result === 'FOR ELECTRICAL ORDER OF PAYMENT APPROVAL') { + newList.push(list[i]) + } + } + + return [...newList] + } + + const getApplicationById = async (list: number[]) => { + let applicationList: string[] = [] + + for (let i = 0; i < list.length; i++) { + const response = await ofetch(API + 'get-applicationbyid-electrical/' + list[i], { parseResponse: JSON.parse }) + applicationList.push(response.result) + } + + setUpdatedList([...applicationList]) + } + + const load = async () => { + // const listForApproval = await getListForApproval() + // const listOfReadyForApprovalFiltered = await getListOfReadyForApprovalFiltered(listForApproval) + // await getApplicationById(listOfReadyForApprovalFiltered) + + // console.log(listOfReadyForApprovalFiltered) + await getopdetails() + } + + const getopdetails = async () => { + const op = await ofetch(API + 'get-opdetails-electrical/23512', { parseResponse: JSON.parse }) + setTotalOp(calculateTotal(op.result4)) + setAssessor(await getEmployeeName(op.result[0])) + setApprover(await getEmployeeName(op.result2[0])) + setDateOp(dayjs(op.result5[0]).format('MMMM DD, YYYY')) + } + + const calculateTotal = (list: number[]) => { + let total = 0 + for (let i = 0; i < list.length; i++) { + total += parseInt(list[i].toString()) + } + return total + } + + const getEmployeeName = async (id: string) => { + try { + const response = await ofetch(API + 'get-employeename/' + id, { parseResponse: JSON.parse }) + const result = response.result + return result + } catch { + return '' + } + } + + const getPaymentName = async (id: string) => { + try { + const response = await ofetch(API + 'get-paymentname/' + id, { parseResponse: JSON.parse }) + const result = response.result + return result + } catch { + return '' + } + } + + onMount(async () => { + await load() + }) + return ( <> @@ -24,10 +117,72 @@ export default () => { -

List of Ready to Approve and Sign OP (Order of Payments)

-
+ + + + Building + + + Occupancy + + + Electrical + + + + + +

List of Ready to Approve and Sign Building Order of Payments

+
+
+ + +

List of Ready to Approve and Sign Occupancy Order of Payments

+
+
+ + +

List of Ready to Approve and Sign Electrical Order of Payments

+
+ + + + + + + + + + + +
Application NumberName
11111 + + + + + 25-0000000123 + + Sample Name - + + + + + + + + + +
+ + +
diff --git a/src/pages/RegisterPage/Register.tsx b/src/pages/RegisterPage/Register.tsx index 43ddf86..b837073 100644 --- a/src/pages/RegisterPage/Register.tsx +++ b/src/pages/RegisterPage/Register.tsx @@ -233,6 +233,9 @@ export default () => {

Name of Approver

{APPROVERNAME} +

Password

+ +

Upload Signature

setFile(data)} accept=".png"> @@ -253,17 +256,29 @@ export default () => { - +