|
|
@@ -0,0 +1,359 @@ |
|
|
|
// material-ui |
|
|
|
import { |
|
|
|
Button, |
|
|
|
Grid, TextField, |
|
|
|
Autocomplete, |
|
|
|
Typography |
|
|
|
} from '@mui/material'; |
|
|
|
import MainCard from "components/MainCard"; |
|
|
|
import { useForm } from "react-hook-form"; |
|
|
|
import * as React from "react"; |
|
|
|
// import * as DateUtils from "utils/DateUtils"; |
|
|
|
import {PNSPS_BUTTON_THEME} from "../../themes/buttonConst"; |
|
|
|
import {ThemeProvider} from "@emotion/react"; |
|
|
|
import * as ComboData from "utils/ComboData"; |
|
|
|
import * as DateUtils from "utils/DateUtils"; |
|
|
|
const LoadingComponent = Loadable(React.lazy(() => import('pages/extra-pages/LoadingComponent'))); |
|
|
|
|
|
|
|
// ==============================|| DASHBOARD - DEFAULT ||============================== // |
|
|
|
|
|
|
|
|
|
|
|
const SearchPublicNoticeForm = ({ applySearch, generateReport, searchCriteria,onDownload }) => { |
|
|
|
|
|
|
|
const [sysTxnMinDate, setSysTxnMinDate] = React.useState(searchCriteria.dateFrom); |
|
|
|
const [sysTxnMaxDate, setsysTxnMaxDate] = React.useState(searchCriteria.dateTo); |
|
|
|
const [txnMinDate, setTxnMinDate] = React.useState(searchCriteria.dateFrom); |
|
|
|
const [txnMaxDate, setTxnMaxDate] = React.useState(searchCriteria.dateTo); |
|
|
|
const [collMinDate, setCollMinDate] = React.useState(searchCriteria.dateFrom); |
|
|
|
const [collMaxDate, setCollMaxDate] = React.useState(searchCriteria.dateTo); |
|
|
|
const [status, setStatus] = React.useState(ComboData.paymentStatus[0]); |
|
|
|
const [method, setMethod] = React.useState(ComboData.paymentMethod[0]); |
|
|
|
const marginBottom = 2.5; |
|
|
|
|
|
|
|
const { register, handleSubmit, getValues } = useForm() |
|
|
|
|
|
|
|
const onSubmit = () => { |
|
|
|
const sysTxnDateFrom = getValues("sysTxnDateFrom") |
|
|
|
const sysTxnDateTo = getValues("sysTxnDateTo") |
|
|
|
const txnDateFrom = getValues("txnDateFrom") |
|
|
|
const txnDateTo = getValues("txnDateTo") |
|
|
|
const collDateFrom = getValues("collDateFrom") |
|
|
|
const collDateTo = getValues("collDateTo") |
|
|
|
|
|
|
|
const temp = { |
|
|
|
PaymentMethod:(method?.type && method?.type != 'Please Select') ? method?.type : "", |
|
|
|
PaymentStatus : (status?.type && status?.type != 'all') ? status?.type : "", |
|
|
|
SysTxnDateFrom:sysTxnDateFrom, |
|
|
|
SysTxnDateTo:sysTxnDateTo, |
|
|
|
TxnDateFrom:txnDateFrom, |
|
|
|
TxnDateTo:txnDateTo, |
|
|
|
CollDateFrom:collDateFrom, |
|
|
|
CollDateTo:collDateTo, |
|
|
|
}; |
|
|
|
applySearch(temp); |
|
|
|
}; |
|
|
|
|
|
|
|
const generatePDFHandler = () => { |
|
|
|
const sysTxnDateFrom = getValues("sysTxnDateFrom") |
|
|
|
const sysTxnDateTo = getValues("sysTxnDateTo") |
|
|
|
const txnDateFrom = getValues("txnDateFrom") |
|
|
|
const txnDateTo = getValues("txnDateTo") |
|
|
|
const collDateFrom = getValues("collDateFrom") |
|
|
|
const collDateTo = getValues("collDateTo") |
|
|
|
|
|
|
|
const temp = { |
|
|
|
PaymentMethod:(method?.type && method?.type != 'Please Select') ? method?.type : "", |
|
|
|
PaymentStatus : (status?.type && status?.type != 'all') ? status?.type : "", |
|
|
|
SysTxnDateFrom:sysTxnDateFrom, |
|
|
|
SysTxnDateTo:sysTxnDateTo, |
|
|
|
TxnDateFrom:txnDateFrom, |
|
|
|
TxnDateTo:txnDateTo, |
|
|
|
CollDateFrom:collDateFrom, |
|
|
|
CollDateTo:collDateTo, |
|
|
|
ReportFormat:"pdf" |
|
|
|
}; |
|
|
|
generateReport(temp); |
|
|
|
} |
|
|
|
|
|
|
|
const generateCSVHandler = () => { |
|
|
|
const sysTxnDateFrom = getValues("sysTxnDateFrom") |
|
|
|
const sysTxnDateTo = getValues("sysTxnDateTo") |
|
|
|
const txnDateFrom = getValues("txnDateFrom") |
|
|
|
const txnDateTo = getValues("txnDateTo") |
|
|
|
const collDateFrom = getValues("collDateFrom") |
|
|
|
const collDateTo = getValues("collDateTo") |
|
|
|
|
|
|
|
const temp = { |
|
|
|
PaymentMethod:(method?.type && method?.type != 'Please Select') ? method?.type : "", |
|
|
|
PaymentStatus : (status?.type && status?.type != 'all') ? status?.type : "", |
|
|
|
SysTxnDateFrom:sysTxnDateFrom, |
|
|
|
SysTxnDateTo:sysTxnDateTo, |
|
|
|
TxnDateFrom:txnDateFrom, |
|
|
|
TxnDateTo:txnDateTo, |
|
|
|
CollDateFrom:collDateFrom, |
|
|
|
CollDateTo:collDateTo, |
|
|
|
ReportFormat:"csv" |
|
|
|
}; |
|
|
|
generateReport(temp); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
<MainCard xs={12} md={12} lg={12} |
|
|
|
border={false} |
|
|
|
content={false} |
|
|
|
> |
|
|
|
|
|
|
|
<form onSubmit={handleSubmit(onSubmit)} > |
|
|
|
<Grid container sx={{ backgroundColor: '#ffffff', ml: 2, mt: 1}} width="98%"> |
|
|
|
{/*row 1*/} |
|
|
|
<Grid item justifyContent="space-between" alignItems="center" sx={{mt:1,ml:3,mb:2.5}}> |
|
|
|
<Typography variant="h5" > |
|
|
|
Submit Form |
|
|
|
</Typography> |
|
|
|
</Grid> |
|
|
|
|
|
|
|
{/*row 2*/} |
|
|
|
|
|
|
|
<Grid item xs={12} s={12} md={12} lg={12} sx={{ ml: 3, mr: 3, mb: marginBottom }}> |
|
|
|
<Grid container spacing={3}> |
|
|
|
<Grid item xs={9} s={9} md={3} lg={3} > |
|
|
|
<Autocomplete |
|
|
|
{...register("paymentMethod")} |
|
|
|
disablePortal={false} |
|
|
|
size="small" |
|
|
|
id="paymentMethod" |
|
|
|
filterOptions={(options) => options} |
|
|
|
options={ComboData.paymentMethod} |
|
|
|
value={method} |
|
|
|
getOptionLabel={(option) => option.label} |
|
|
|
inputValue={method?.label ? method?.label : ""} |
|
|
|
onChange={(event, newValue) => { |
|
|
|
if (newValue !== null) { |
|
|
|
setMethod(newValue); |
|
|
|
} |
|
|
|
}} |
|
|
|
renderInput={(params) => ( |
|
|
|
<TextField {...params} |
|
|
|
label="Payment Method" |
|
|
|
/> |
|
|
|
)} |
|
|
|
InputLabelProps={{ |
|
|
|
shrink: true |
|
|
|
}} |
|
|
|
/> |
|
|
|
</Grid> |
|
|
|
|
|
|
|
<Grid item xs={9} s={9} md={3} lg={3} > |
|
|
|
<Autocomplete |
|
|
|
{...register("status")} |
|
|
|
disablePortal={false} |
|
|
|
size="small" |
|
|
|
id="status" |
|
|
|
filterOptions={(options) => options} |
|
|
|
options={ComboData.paymentStatus} |
|
|
|
value={status} |
|
|
|
getOptionLabel={(option) => option.label} |
|
|
|
inputValue={status?.label ? status?.label : ""} |
|
|
|
onChange={(event, newValue) => { |
|
|
|
if (newValue !== null) { |
|
|
|
setStatus(newValue); |
|
|
|
} |
|
|
|
}} |
|
|
|
renderInput={(params) => ( |
|
|
|
<TextField {...params} |
|
|
|
label="Payment Status" |
|
|
|
/> |
|
|
|
)} |
|
|
|
InputLabelProps={{ |
|
|
|
shrink: true |
|
|
|
}} |
|
|
|
/> |
|
|
|
</Grid> |
|
|
|
|
|
|
|
</Grid> |
|
|
|
</Grid> |
|
|
|
|
|
|
|
<Grid container display="flex" alignItems={"center"}> |
|
|
|
<Grid item xs={12} s={12} md={12} lg={12} sx={{ml:3, mr:3, mb:marginBottom}}> |
|
|
|
<Grid container spacing={1}> |
|
|
|
<Grid item xs={4}> |
|
|
|
<TextField |
|
|
|
fullWidth |
|
|
|
{...register("sysTxnDateFrom")} |
|
|
|
id="sysTxnDateFrom" |
|
|
|
type="date" |
|
|
|
label="PNSPS Transaction Date (From)" |
|
|
|
////defaultValue={searchCriteria.dateFrom} |
|
|
|
InputProps={{ inputProps: { max: sysTxnMaxDate } }} |
|
|
|
onChange={(newValue) => { |
|
|
|
setSysTxnMinDate(DateUtils.dateStr(newValue)); |
|
|
|
}} |
|
|
|
InputLabelProps={{ |
|
|
|
shrink: true |
|
|
|
}} |
|
|
|
/> |
|
|
|
</Grid> |
|
|
|
<Grid item xs={4}> |
|
|
|
<TextField |
|
|
|
fullWidth |
|
|
|
InputLabelProps={{ |
|
|
|
shrink: true |
|
|
|
}} |
|
|
|
{...register("sysTxnDateTo")} |
|
|
|
InputProps={{ inputProps: { min: sysTxnMinDate } }} |
|
|
|
onChange={(newValue) => { |
|
|
|
setsysTxnMaxDate(DateUtils.dateStr(newValue)); |
|
|
|
}} |
|
|
|
id="sysTxnDateTo" |
|
|
|
type="date" |
|
|
|
label="PNSPS Transaction Date (To)" |
|
|
|
////defaultValue={searchCriteria.dateTo} |
|
|
|
/> |
|
|
|
</Grid> |
|
|
|
</Grid> |
|
|
|
</Grid> |
|
|
|
</Grid> |
|
|
|
|
|
|
|
{/*row 3*/} |
|
|
|
<Grid container display="flex" alignItems={"center"}> |
|
|
|
<Grid item xs={12} s={12} md={12} lg={12} sx={{ml:3, mr:3, mb:marginBottom}}> |
|
|
|
<Grid container spacing={1}> |
|
|
|
<Grid item xs={4}> |
|
|
|
<TextField |
|
|
|
fullWidth |
|
|
|
{...register("txnDateFrom")} |
|
|
|
id="txnDateFrom" |
|
|
|
type="date" |
|
|
|
label="FI Transaction Date (From)" |
|
|
|
//defaultValue={searchCriteria.dateFrom} |
|
|
|
InputProps={{ inputProps: { max: txnMaxDate } }} |
|
|
|
onChange={(newValue) => { |
|
|
|
setTxnMaxDate(DateUtils.dateStr(newValue)); |
|
|
|
}} |
|
|
|
InputLabelProps={{ |
|
|
|
shrink: true |
|
|
|
}} |
|
|
|
/> |
|
|
|
</Grid> |
|
|
|
<Grid item xs={4}> |
|
|
|
<TextField |
|
|
|
fullWidth |
|
|
|
InputLabelProps={{ |
|
|
|
shrink: true |
|
|
|
}} |
|
|
|
{...register("txnDateTo")} |
|
|
|
InputProps={{ inputProps: { min: txnMinDate } }} |
|
|
|
onChange={(newValue) => { |
|
|
|
setTxnMinDate(DateUtils.dateStr(newValue)); |
|
|
|
}} |
|
|
|
id="txnDateTo" |
|
|
|
type="date" |
|
|
|
label="FI Transaction Date (To)" |
|
|
|
//defaultValue={searchCriteria.dateTo} |
|
|
|
/> |
|
|
|
</Grid> |
|
|
|
</Grid> |
|
|
|
</Grid> |
|
|
|
</Grid> |
|
|
|
|
|
|
|
{/*row 5*/} |
|
|
|
<Grid container display="flex" alignItems={"center"}> |
|
|
|
<Grid item xs={12} s={12} md={12} lg={12} sx={{ml:3, mr:3, mb:marginBottom}}> |
|
|
|
<Grid container spacing={1}> |
|
|
|
<Grid item xs={4}> |
|
|
|
<TextField |
|
|
|
fullWidth |
|
|
|
{...register("collDateFrom")} |
|
|
|
id="collDateFrom" |
|
|
|
type="date" |
|
|
|
label="Bank Credit Date (From)" |
|
|
|
//defaultValue={searchCriteria.dateFrom} |
|
|
|
InputProps={{ inputProps: { max: collMaxDate } }} |
|
|
|
onChange={(newValue) => { |
|
|
|
setCollMinDate(DateUtils.dateStr(newValue)); |
|
|
|
}} |
|
|
|
InputLabelProps={{ |
|
|
|
shrink: true |
|
|
|
}} |
|
|
|
/> |
|
|
|
</Grid> |
|
|
|
<Grid item xs={4}> |
|
|
|
<TextField |
|
|
|
fullWidth |
|
|
|
InputLabelProps={{ |
|
|
|
shrink: true |
|
|
|
}} |
|
|
|
{...register("collDateTo")} |
|
|
|
InputProps={{ inputProps: { min: collMinDate } }} |
|
|
|
onChange={(newValue) => { |
|
|
|
setCollMaxDate(DateUtils.dateStr(newValue)); |
|
|
|
}} |
|
|
|
id="collDateTo" |
|
|
|
type="date" |
|
|
|
label="Bank Credit Date (To)" |
|
|
|
//defaultValue={searchCriteria.dateTo} |
|
|
|
/> |
|
|
|
</Grid> |
|
|
|
</Grid> |
|
|
|
</Grid> |
|
|
|
</Grid> |
|
|
|
|
|
|
|
<Grid container justifyContent="flex-end" direction="row" alignItems="center" spacing={3}> |
|
|
|
<ThemeProvider theme={PNSPS_BUTTON_THEME}> |
|
|
|
<Grid item sx={{ ml: 3, mb: 3, }} > |
|
|
|
<Button |
|
|
|
variant="contained" |
|
|
|
type="submit" |
|
|
|
> |
|
|
|
View |
|
|
|
</Button> |
|
|
|
</Grid> |
|
|
|
|
|
|
|
<Grid item sx={{ ml: 3, mb: 3, }} > |
|
|
|
{onDownload? |
|
|
|
<LoadingComponent disableText={true} alignItems="flex-start"/> |
|
|
|
: |
|
|
|
<Grid container> |
|
|
|
<Grid item sx={{ ml: 3, mb: 3, }} > |
|
|
|
<Button |
|
|
|
variant="contained" |
|
|
|
onClick={generateCSVHandler} |
|
|
|
> |
|
|
|
Generate CSV |
|
|
|
</Button> |
|
|
|
</Grid> |
|
|
|
|
|
|
|
<Grid item sx={{ ml: 3, mb: 3, }} > |
|
|
|
<Button |
|
|
|
variant="contained" |
|
|
|
onClick={generatePDFHandler} |
|
|
|
> |
|
|
|
Generate PDF |
|
|
|
</Button> |
|
|
|
</Grid> |
|
|
|
</Grid> |
|
|
|
} |
|
|
|
</Grid> |
|
|
|
|
|
|
|
{/* <Grid item sx={{ ml: 3, mr: 3, mb: 3, }} > |
|
|
|
{onDownload? |
|
|
|
<LoadingComponent disableText={true} alignItems="flex-start"/> |
|
|
|
: |
|
|
|
<Button |
|
|
|
variant="contained" |
|
|
|
onClick={generatePDFHandler} |
|
|
|
> |
|
|
|
Generate PDF |
|
|
|
</Button> |
|
|
|
} |
|
|
|
</Grid> */} |
|
|
|
</ThemeProvider> |
|
|
|
</Grid> |
|
|
|
</Grid> |
|
|
|
</form> |
|
|
|
</MainCard> |
|
|
|
); |
|
|
|
}; |
|
|
|
|
|
|
|
export default SearchPublicNoticeForm; |