diff --git a/src/layout/MainLayout/Header/index.js b/src/layout/MainLayout/Header/index.js index ea6c01e..07ebdc8 100644 --- a/src/layout/MainLayout/Header/index.js +++ b/src/layout/MainLayout/Header/index.js @@ -141,17 +141,20 @@ function Header(props) { My Profile
  • - Email Template + Email Template
  • System Setting
  • - Holiday Setting + Holiday Setting
  • Announcement
  • +
  • + Gazette Issue +
  • diff --git a/src/pages/DemandNote/Create/SearchForm.js b/src/pages/DemandNote/Create/SearchForm.js index f88bd65..d8b40c3 100644 --- a/src/pages/DemandNote/Create/SearchForm.js +++ b/src/pages/DemandNote/Create/SearchForm.js @@ -56,7 +56,7 @@ const SearchPublicNoticeForm = ({ applySearch, issueComboData, _paymentCount, _p function getIssueLabel(data) { if (data == {}) return ""; - return data.year + return data.issueYear + " Vol. " + FormatUtils.zeroPad(data.volume, 3) + ", No. " + FormatUtils.zeroPad(data.issueNo, 2) + ", " + DateUtils.dateFormat(data.issueDate, "D MMM YYYY (ddd)"); diff --git a/src/pages/DemandNote/Search/SearchForm.js b/src/pages/DemandNote/Search/SearchForm.js index 5981010..6dbf6db 100644 --- a/src/pages/DemandNote/Search/SearchForm.js +++ b/src/pages/DemandNote/Search/SearchForm.js @@ -75,7 +75,7 @@ const SearchDemandNoteForm = ({ applySearch, orgComboData, searchCriteria, issue function getIssueLabel(data) { if (data == {}) return ""; - return data.year + return data.issueYear + " Vol. " + FormatUtils.zeroPad(data.volume, 3) + ", No. " + FormatUtils.zeroPad(data.issueNo, 2) + ", " + DateUtils.dateFormat(data.issueDate, "D MMM YYYY (ddd)"); diff --git a/src/pages/DemandNote/Search_Public/SearchForm.js b/src/pages/DemandNote/Search_Public/SearchForm.js index 10ad3ba..3dfe8d6 100644 --- a/src/pages/DemandNote/Search_Public/SearchForm.js +++ b/src/pages/DemandNote/Search_Public/SearchForm.js @@ -64,7 +64,7 @@ const SearchDemandNoteForm = ({ applySearch, searchCriteria, issueComboData function getIssueLabel(data) { if (data == {}) return ""; - return data.year + return data.issueYear + " Vol. " + FormatUtils.zeroPad(data.volume, 3) + ", No. " + FormatUtils.zeroPad(data.issueNo, 2) + ", " + DateUtils.dateFormat(data.issueDate, "D MMM YYYY (ddd)"); diff --git a/src/pages/GazetteIssue/index.js b/src/pages/GazetteIssue/index.js new file mode 100644 index 0000000..f231349 --- /dev/null +++ b/src/pages/GazetteIssue/index.js @@ -0,0 +1,167 @@ +// material-ui +import { + Grid, + Typography, + Stack, + Button, + Dialog, DialogTitle, DialogContent, DialogActions, +} from '@mui/material'; +import * as UrlUtils from "utils/ApiPathConst"; +import * as React from "react"; +import * as HttpUtils from "utils/HttpUtils"; +import titleBackgroundImg from 'assets/images/dashboard/gazette-bar.png' + +const BackgroundHead = { + backgroundImage: `url(${titleBackgroundImg})`, + width: '100%', + height: '100%', + backgroundSize: 'contain', + backgroundRepeat: 'no-repeat', + backgroundColor: '#0C489E', + backgroundPosition: 'right' +} +import {PNSPS_LONG_BUTTON_THEME} from "themes/buttonConst"; +import {ThemeProvider} from "@emotion/react"; +import { notifySaveSuccess } from 'utils/CommonFunction'; + +// ==============================|| DASHBOARD - DEFAULT ||============================== // + +const Index = () => { + const [attachments, setAttachments] = React.useState([]); + const [waitImport, setWaitImport] = React.useState(false); + const [waitDownload, setWaitDownload] = React.useState(false); + const [isWarningPopUp, setIsWarningPopUp] = React.useState(false); + const [warningText, setWarningText] = React.useState(""); + + React.useEffect(() => { + if (attachments.length > 0) { + importHoliday(); + } + }, [attachments]); + + const readFile = (event) => { + let file = event.target.files[0]; + if (file) { + if (!file.name.toLowerCase().substr(file.name.length - 5).includes(".xlsx")) { + setWarningText("Please upload a valid file (File format: .xlsx)."); + setIsWarningPopUp(true); + document.getElementById("uploadFileBtn").value = ""; + return; + } + file['id'] = attachments.length; + setAttachments([ + ...attachments, + file + ]); + document.getElementById("uploadFileBtn").value = ""; + } + } + + const doExport=()=>{ + setWaitDownload(true) + HttpUtils.fileDownload({ + url: UrlUtils.GET_ISSUE_LIST, + onResponse: () => { + setTimeout(()=> setWaitDownload(false), 500) + } + }); + } + + const importHoliday = () => { + setWaitImport(true); + if (!attachments || attachments.length <= 0) { + setWarningText("Please upload file."); + setSaving(false); + return; + } + HttpUtils.postWithFiles({ + url: UrlUtils.POST_ISSUE_FILE, + files: attachments, + onSuccess: () => { + notifySaveSuccess() + setWaitImport(false); + setAttachments([]); + // loadForm(); + } + }); + } + + return ( + + +
    + + Gazette Issue + +
    +
    + + + + + + + + + { + readFile(event) + }} + /> + + + + + + +
    + setIsWarningPopUp(false)} + PaperProps={{ + sx: { + minWidth: '40vw', + maxWidth: { xs: '90vw', s: '90vw', m: '70vw', lg: '70vw' }, + maxHeight: { xs: '90vh', s: '70vh', m: '70vh', lg: '60vh' } + } + }} + > + Warning + + {warningText} + + + + + +
    +
    + ); +}; + +export default Index; \ No newline at end of file diff --git a/src/pages/Holiday/Search_GLD/DataGrid.js b/src/pages/Holiday/DataGrid.js similarity index 97% rename from src/pages/Holiday/Search_GLD/DataGrid.js rename to src/pages/Holiday/DataGrid.js index b8f7cb0..807188d 100644 --- a/src/pages/Holiday/Search_GLD/DataGrid.js +++ b/src/pages/Holiday/DataGrid.js @@ -47,7 +47,7 @@ export default function EmailTemplateTable({ recordList }) { 'auto'} /> diff --git a/src/pages/Holiday/Search_GLD/SearchForm.js b/src/pages/Holiday/SearchForm.js similarity index 100% rename from src/pages/Holiday/Search_GLD/SearchForm.js rename to src/pages/Holiday/SearchForm.js diff --git a/src/pages/Holiday/Search_GLD/index.js b/src/pages/Holiday/index.js similarity index 75% rename from src/pages/Holiday/Search_GLD/index.js rename to src/pages/Holiday/index.js index f650638..1a83f3d 100644 --- a/src/pages/Holiday/Search_GLD/index.js +++ b/src/pages/Holiday/index.js @@ -12,7 +12,7 @@ import * as HttpUtils from "utils/HttpUtils"; import Loadable from 'components/Loadable'; const LoadingComponent = Loadable(React.lazy(() => import('pages/extra-pages/LoadingComponent'))); -const HolidayTable = Loadable(React.lazy(() => import('pages/Holiday/Search_GLD/DataGrid'))) +const HolidayTable = Loadable(React.lazy(() => import('pages/Holiday/DataGrid'))) import titleBackgroundImg from 'assets/images/dashboard/gazette-bar.png' // import AddCircleOutlineIcon from '@mui/icons-material/AddCircleOutline'; import MainCard from 'components/MainCard'; @@ -40,13 +40,15 @@ const Index = () => { const [record, setRecord] = React.useState([]); const [comboData, setComboData] = React.useState([]); const [onReady, setOnReady] = React.useState(false); + const [onSearchReady, setOnSearchReady] = React.useState(false); // const navigate = useNavigate() const [searchCriteria, setSearchCriteria] = React.useState({ year: dateStr_Year(new Date()), // dateFrom: DateUtils.dateStr(new Date().setDate(new Date().getDate()-14)), }); const [attachments, setAttachments] = React.useState([]); - const [wait, setWait] = React.useState(false); + const [waitImport, setWaitImport] = React.useState(false); + const [waitDownload, setWaitDownload] = React.useState(false); const [isWarningPopUp, setIsWarningPopUp] = React.useState(false); const [warningText, setWarningText] = React.useState(""); @@ -54,26 +56,29 @@ const Index = () => { // loadForm(); // }, []); - React.useLayoutEffect(() => { - if (comboData && comboData.length > 0) { - setOnReady(true); - } - }, [comboData]); + // React.useLayoutEffect(() => { + // if (comboData) { + // setOnReady(true); + // } + // }, [comboData]); React.useEffect(() => { // console.log(searchCriteria) + setOnSearchReady(false) loadForm(); }, [searchCriteria]); - + function loadForm() { HttpUtils.get({ url: UrlUtils.GET_HOLIDAY, params: searchCriteria, onSuccess: (responseData) => { - console.log(comboData) + // console.log(comboData) setRecord(responseData); if (comboData.length == 0) { loadCombo(); + }else{ + setOnSearchReady(true) } } }); @@ -85,6 +90,8 @@ const Index = () => { onSuccess: (responseData) => { let combo = responseData; setComboData(combo); + setOnReady(true); + setOnSearchReady(true) } }); } @@ -117,8 +124,19 @@ const Index = () => { } } + const doExport=()=>{ + setWaitDownload(true) + HttpUtils.fileDownload({ + url: UrlUtils.GET_HOLIDAY_TEMPLATE, + onResponse: () => { + setTimeout(()=> setWaitDownload(false), 500) + } + }); + } + const importHoliday = () => { - setWait(true); + setWaitImport(true); + setOnSearchReady(false); if (!attachments || attachments.length <= 0) { setWarningText("Please upload file."); setSaving(false); @@ -129,7 +147,7 @@ const Index = () => { files: attachments, onSuccess: () => { notifySaveSuccess() - setWait(false); + setWaitImport(false); setAttachments([]); loadForm(); } @@ -153,8 +171,23 @@ const Index = () => { - - + + + + + + + { type="file" accept=".xlsx" style={{ display: 'none' }} - disabled={wait} + disabled={waitImport} onChange={(event) => { readFile(event) }} @@ -172,14 +205,16 @@ const Index = () => { component="span" variant="contained" size="large" - disabled={wait} + disabled={waitImport} > Upload Files + + {/*row 1*/} { /> {/*row 2*/} - - - - - + {!onSearchReady? + : + + + + + + }
    { }; function getIssueLabel(data) { - return data.year + return data.issueYear + " Vol. " + FormatUtils.zeroPad(data.volume, 3) + ", No. " + FormatUtils.zeroPad(data.issueNo, 2) + ", " + DateUtils.dateFormat(data.issueDate, "D MMM YYYY (ddd)"); diff --git a/src/pages/PublicNotice/Search_GLD/SearchForm.js b/src/pages/PublicNotice/Search_GLD/SearchForm.js index 42579fd..a55750d 100644 --- a/src/pages/PublicNotice/Search_GLD/SearchForm.js +++ b/src/pages/PublicNotice/Search_GLD/SearchForm.js @@ -77,7 +77,7 @@ const SearchPublicNoticeForm = ({ applySearch, orgComboData, searchCriteria, iss function getIssueLabel(data) { if (data == {}) return ""; - return data.year + return data.issueYear + " Vol. " + FormatUtils.zeroPad(data.volume, 3) + ", No. " + FormatUtils.zeroPad(data.issueNo, 2) + ", " + DateUtils.dateFormat(data.issueDate, "D MMM YYYY (ddd)"); diff --git a/src/routes/GLDUserRoutes.js b/src/routes/GLDUserRoutes.js index a2f78c8..ca96592 100644 --- a/src/routes/GLDUserRoutes.js +++ b/src/routes/GLDUserRoutes.js @@ -22,6 +22,10 @@ const UserMaintainPage = Loadable(lazy(() => import('pages/User/GLDUserProfile') const SystemSetting = Loadable(lazy(() => import('pages/Setting/SystemSetting'))); const AnnouncementDetails = Loadable(lazy(() => import('pages/Announcement/Details'))); const AnnouncementSearch = Loadable(lazy(() => import('pages/Announcement/Search'))); +const EmailTemplatePage = Loadable(lazy(() => import('pages/EmailTemplate/Search_GLD'))); +const EmailTemplateDetailPage = Loadable(lazy(() => import('pages/EmailTemplate/Detail_GLD'))); +const HolidayPage = Loadable(lazy(() => import('pages/Holiday'))); +const GazetteIssuePage = Loadable(lazy(() => import('pages/GazetteIssue/index'))); // ==============================|| MAIN ROUTING ||============================== // @@ -100,6 +104,22 @@ const GLDUserRoutes = { path: '/setting/announcement/details/:id', element: }, + { + path: '/setting/emailTemplate', + element: + }, + { + path: '/setting/emailTemplate/:id', + element: + }, + { + path: '/setting/holiday', + element: + }, + { + path: '/setting/gazetteissuepage', + element: + }, ] }, ] diff --git a/src/routes/SettingRoutes.js b/src/routes/SettingRoutes.js index fd3afe3..c9ab06f 100644 --- a/src/routes/SettingRoutes.js +++ b/src/routes/SettingRoutes.js @@ -20,9 +20,6 @@ const UserGroupDetailPage = Loadable(lazy(() => import('pages/pnspsUserGroupDeta const OrganizationSearchPage = Loadable(lazy(() => import('pages/Organization/SearchPage'))); const OrganizationDetailPage = Loadable(lazy(() => import('pages/Organization/DetailPage'))); const OrganizationDetailPage_fromUser = Loadable(lazy(() => import('pages/Organization/DetailPage_FromUser'))); -const EmailTemplatePage = Loadable(lazy(() => import('pages/EmailTemplate/Search_GLD'))); -const EmailTemplateDetailPage = Loadable(lazy(() => import('pages/EmailTemplate/Detail_GLD'))); -const HolidayPage = Loadable(lazy(() => import('pages/Holiday/Search_GLD'))); // ==============================|| AUTH ROUTING ||============================== // @@ -83,18 +80,7 @@ const SettingRoutes = { path: 'passwordpolicy', element: }, - { - path: 'emailTemplate', - element: - }, - { - path: '/emailTemplate/:id', - element: - }, - { - path: 'holiday', - element: - }, + ] }; diff --git a/src/utils/ApiPathConst.js b/src/utils/ApiPathConst.js index bcd1daf..47289e2 100644 --- a/src/utils/ApiPathConst.js +++ b/src/utils/ApiPathConst.js @@ -111,7 +111,10 @@ export const SET_PUBLIC_NOTICE_STATUS_REVIEWED = apiPath+'/application/applicati export const SET_PUBLIC_NOTICE_STATUS_PUBLISH = apiPath+'/application/application-detail-status-publish'; export const UPDATE_PUBLIC_NOTICE_APPLY_DETAIL = apiPath+'/application/save'; +//gazette export const GET_ISSUE_COMBO = apiPath+'/gazette-issue/combo'; +export const GET_ISSUE_LIST = apiPath+'/gazette-issue/export'; +export const POST_ISSUE_FILE = apiPath+'/gazette-issue/import'; export const CHECK_CREATE_PROOF = apiPath+'/proof/check-create';//GET export const LIST_PROOF = apiPath+'/proof/list';//GET @@ -172,4 +175,5 @@ export const GEN_GFMIS_XML = apiPath+'/gfmis'; //GET //Holiday export const GET_HOLIDAY = apiPath+'/holiday/list'; //GET export const POST_HOLIDAY = apiPath+'/holiday/import'; //POST -export const GET_HOLIDAY_COMBO = apiPath+'/holiday/combo'; //GET \ No newline at end of file +export const GET_HOLIDAY_COMBO = apiPath+'/holiday/combo'; //GET +export const GET_HOLIDAY_TEMPLATE = apiPath+'/holiday/export'; //GET