Professional Documents
Culture Documents
state = {
urlSearchPerson: 'search-person',
showSearch:true,
userType:'',
searchParam:'',
searchValue:'',
searchResult:[],
showSearchTable:false,
showMessageNotFound:false,
loading:false,
// SnackBar
variant: '',
vertical: 'bottom',
horizontal: 'right',
snackBar: false,
snackBarMessage: '',
};
componentDidMount() {
})
.catch(() => {
this.setState({
loading: false,
snackBar: true,
snackBarMessage: (
<Fragment>
<i className={'ti-alert'}/> Error al procesar petición
</Fragment>
)
});
});
}else {
this.setState({
snackBar: true,
variant: 'warning',
snackBarMessage: 'Ingrese los parámetros de búsqueda solicitados'
});
}
imprimir = () => {
const input = document.getElementById('imprimir-pdf');
const inputHeightMm = pxToMm(input.offsetHeight);
const a4WidthMm = 210;
const a4HeightMm = 297;
const a4HeightPx = mmToPx(a4HeightMm);
const numPages = inputHeightMm <= a4HeightMm ? 1 : Math.floor(inputHeightMm
/ a4HeightMm) + 1;
console.log({
input, inputHeightMm, a4HeightMm, a4HeightPx, numPages, range: range(0,
numPages),
comp: inputHeightMm <= a4HeightMm, inputHeightPx: input.offsetHeight
});
html2canvas(input)
.then((canvas) => {
const imgData = canvas.toDataURL('image/png');
// Document of a4WidthMm wide and inputHeightMm high
let pdf;
if (inputHeightMm > a4HeightMm) {
// elongated a4 (system print dialog will handle page breaks)
pdf = new jsPDF('p', 'mm', [inputHeightMm + 16, a4WidthMm]);
} else {
// standard a4
pdf = new jsPDF();
}
render() {
const
{showSearch,userType,searchParam,searchResult,searchValue,loading,showMessageNotFou
nd,
showSearchTable} = this.state;
const {match} = this.props;
return (
<div className="report-wrapper mb-20">
<PageTitleBar title={<TranslateMessages id={'sidebar.reports-
title.personal-file'}/>} match={match}/>
{ showSearch &&
<Row style={{marginBottom: "10px"}}>
<Col xs={12} sm={12} md={12} lg={12} xl={12}>
<CardColumns className="col-md-12" style={{padding:
'0', display: 'inline-table'}}>
<Card>
<CardBody>
<CardTitle className="text-uppercase">
<TranslateMessages
id="card.heading.makeSearch"/>
</CardTitle>
<Form onSubmit={(event) =>
this.handleSearchPerson(event)}>
<Row>
<Col xs={12} sm={12} md={12}
lg={12} xl={12}>
<FormGroup>
<FormControl fullWidth
margin="normal">
<InputLabel>Ingrese
parámetro de búsqueda</InputLabel>
<Input
id="search-value"
type="text"
value={searchValue}
onChange={this.handleChange('search-value')}
endAdornment={
<InputAdornment
position="end">
{
searchValue &&
<Fragment>
<Tooltip title="Limpiar">
<IconButton
<i className="material-icons">close</i>
</IconButton>
</Tooltip>
<Tooltip title="Buscar">
<IconButton type="submit">
<i className="material-icons">search</i>
</IconButton>
</Tooltip>
</Fragment>
}
</InputAdornment>
}
/>
</FormControl>
</FormGroup>
</Col>
</Row>
</Form>
{
loading &&
<Row>
<Col xs={12} sm={12} md={12}
lg={12} xl={12}>
<CircularProgress
className="progress-danger
mb-10 text-center"
style={{
marginTop: '25px',
marginLeft: 'auto',
marginRight: 'auto'
}} size={25}
mode="determinate" value={30} min={0}
max={50}/>
</Col>
</Row>
}
{
showSearchTable && !loading &&
<Row style={{marginTop: '10px'}}>
<Col xs={12} sm={12} md={12}
lg={12} xl={12}>
<Scrollbars
className="rct-scroll"
autoHeightMax={457}
autoHeight
style={{
border: '1px solid
rgba(0, 0, 0, 0.125)',
borderRadius: '5px'
}}
>
<Table>
<TableBody>
{
!loading &&
searchResult &&
<TableCell>
<Media>
<Media left>
<Media object
src={
require('Assets/avatars/default/v1/man.jpg') :
require('Assets/avatars/default/v1/woman.jpg') :
require('Assets/avatars/default/v1/no-image.png')
alt="Profile"
className="rounded-circle mr-20"
width="40"
height="40"
/>
</Media>
</Media>
</TableCell>
<TableCell>
{user.document_number}
<small className="text-muted"
style={{marginLeft: '10px'}}>DNI
</small>
</TableCell>
<TableCell>
{`$
{user.name} ${user.paternal} ${user.maternal}`}
<small
className={`text-uppercase text-teal`}
style={{marginLeft: '10px'}}>
{user.tipo_persona}
</small>
</TableCell>
<TableCell>
<Badge
color="success">Habilitado</Badge>
</TableCell>
:
<TableCell>
<Badge
color="danger">Deshabilitado</Badge>
</TableCell>
}
<TableCell>
<Tooltip
title="Visualizar información">
<IconButton
className="text-primary"
aria-label="Delete">
<i className="material-icons">remove_red_eye</i>
</IconButton>
</Tooltip>
</TableCell>
</TableRow>
))
}
</TableBody>
</Table>
</Scrollbars>
</Col>
<Col xs={12} sm={12} md={12}
lg={12} xl={12}
style={{marginTop: '10px'}}>
<small className="text-muted">
{`Se encontraron $
{searchResult.length} coincidencias.`}
</small>
</Col>
</Row>
}
{
showMessageNotFound && !loading &&
<Row style={{marginTop: '10px'}}>
<Col xs={12} sm={12} md={12}
lg={12} xl={12}>
<small className="text-danger">
{`No se encontraron
registros según los parámetros de búsqueda.`}
</small>
</Col>
</Row>
}
</CardBody>
</Card>
</CardColumns>
</Col>
</Row>
}
</div>
)
}
};
export default ReportPersonalFile;