﻿import React, { Component, memo, Fragment } from 'react';
import { withRouter } from "react-router-dom";
import FrmBotones from '../../../components/UI/botonera/formBotones.jsx'
import CajaTexto from '../../../components/UI/cajaTexto/cajaTexto.jsx';
import TablaFiltro from '../../../components/UI/tablaFiltro/tablaFiltroSort.jsx';
import ComboBox from '../../../components/UI/comboBox/combobox.jsx'
import CajaTextoNumero from '../../../components/UI/cajaTexto/cajaTextoNumero.jsx';
import CajaTextoBusqueda from '../../../components/UI/cajaTexto/cajaTextoBusqueda.jsx';
import Division from '../../../components/UI/division/division.jsx';
import CheckBox from '../../../components/UI/checkBox/checkBox.jsx';
import { farmatearMontos, farmatearFechaEstandar } from '../../../components/Util/Util.jsx'



function cuentasporCobrar(props) {
    const columnas = [{ dataField: 'TipoCXC', text: 'Número', csvText: 'Número', hidden: false, sort: true, editable: false },
    { dataField: 'Nombre', text: 'Nombre de cuenta por cobrar', hidden: false, sort: true, editable: false },
    {
        dataField: 'Monto', text: 'Monto', hidden: false, sort: true, editable: false, align: 'right',
        formatter: (row, cell) => { return farmatearMontos(cell.Monto) },
        style: (cell, row, rowIndex, colIndex) => {
            return {
                padding: '8px',
                minWidth: '100px',
            }
        }
    },
    {
        dataField: 'Beneficiario_Detalle', text: 'Beneficiario', hidden: false, sort: false, editable: false
    },
    { dataField: 'Linea', text: 'Llave', hidden: true, sort: false, editable: false, csvExport: false }
    ];

    const cellEdit = { mode: 'radio', blurToSave: false, autoSelectText: false };
    const selectRow = { hideSelectColumn: true, mode: "checkbox", clickToSelect: false, clickToEdit: false, };
    const rowStyleSal = (row, rowIndex) => {
        const style = {};
        return style;
    }
    const rowEventsDet = {
        onClick: (e, row, rowIndex) => {
        }
    };

    const cellEditDet = { mode: 'click', blurToSave: true, autoSelectText: true };
    //const selectRowDetBK = { mode: 'checkbox', clickToSelect: false, onSelect: (row, isSelected) => props.onRowSelectDet(row, isSelected), onSelectAll: (isSelect, rows) => porps.handleOnSelectAllDet(isSelect, rows), hideSelectColumn: true, bgColor: '#10a599' };
    const selectRowDet = { mode: 'radio', clickToSelect: true, onSelect: (row, isSelected) => props.onRowSelectDet(row, isSelected), hideSelectColumn: true, bgColor: '#10a599' };

    return (
        <Fragment>
            <div className="col-md-12">
                <div className="content">
                    <div className="content-box">
                        <div className="row">
                            <div className="col-sm-12 col-md-12" >
                                <div className='row'>
                                    <CajaTexto col="4" id="CxCDiasProPRE" type="text" label={props.Datos.CxCDiasProPRE.attributes.label} value={props.onFormato(props.Datos.CxCDiasProPRE.value)} attributes={props.Datos.CxCDiasProPRE.attributes} onChangeInput={() => { }} align='right' />
                                    <CajaTextoNumero col="4" id="CxCdiasPreav" type="number" label={props.Datos.CxCdiasPreav.attributes.label} value={props.Datos.CxCdiasPreav.value} attributes={props.Datos.CxCdiasPreav.attributes} onChangeInput={props.onChangeInputDecimal} onBlur={props.onChangeEditar} onFocus={props.onChangeEditar} onFormatear={props.onFormato} />
                                    <CajaTexto col="4" id="CxCMontoPreav" type="text" label={props.Datos.CxCMontoPreav.attributes.label} value={props.onFormato(props.Datos.CxCMontoPreav.value)} attributes={props.Datos.CxCMontoPreav.attributes} onChangeInput={() => { }} align='right' />
                                </div>
                                <div className='row'>
                                    <CajaTexto col="4" id="CxCDiasProOTROS" type="text" label={props.Datos.CxCDiasProOTROS.attributes.label} value={props.onFormato(props.Datos.CxCDiasProOTROS.value)} attributes={props.Datos.CxCDiasProOTROS.attributes} onChangeInput={() => { }} align='right' />
                                    <CajaTextoNumero col="4" id="CxCDiasOtros" type="number" label={props.Datos.CxCDiasOtros.attributes.label} value={props.Datos.CxCDiasOtros.value} attributes={props.Datos.CxCDiasOtros.attributes} onChangeInput={props.onChangeInputDecimal} onBlur={props.onChangeEditar} onFocus={props.onChangeEditar} onFormatear={props.onFormato} />
                                    <CajaTexto col="4" id="CxCMontoOtros" type="text" label={props.Datos.CxCMontoOtros.attributes.label} value={props.onFormato(props.Datos.CxCMontoOtros.value)} attributes={props.Datos.CxCMontoOtros.attributes} onChangeInput={() => { }} align='right' />
                                </div>
                            </div>
                            <div className="col-sm-12 col-md-12" >
                                <Division id="DivDet" label={props.Datos.DivDetCXC.attributes.label} attributes={props.Datos.DivDetCXC.attributes} />
                                <div className='row'>
                                    <ComboBox id="cmbTipoCXC" col="4" attributes={props.Datos.TipoCXC.attributes} value={props.selectedOptionTipoCXC} label={props.Datos.TipoCXC.attributes.label} datos={props.listaTipoCXC} onChange={props.onhandleSelectedOptionTipoCXC} align='right' />
                                    <CajaTextoNumero col="4" id="MontoCXC" type="number" label={props.Datos.MontoCXC.attributes.label} value={props.Datos.MontoCXC.value} attributes={props.Datos.MontoCXC.attributes} onChangeInput={props.onChangeInputDecimal} onBlur={props.onChangeEditar} onFocus={props.onChangeEditar} onFormatear={props.onFormato} />
                                    <FrmBotones col="4" attributes={props.Datos.BotonesAE.attributes} botones={props.botonesLista} />
                                </div>
                                <div className='row'>
                                    <div className="col-sm-12 col-md-12" >
                                        <CajaTextoBusqueda col="4" id="Beneficiario_Detalle" type="text" label={props.Datos.Beneficiario_Detalle.attributes.label} value={props.Datos.Beneficiario_Detalle.value} attributes={props.Datos.Beneficiario_Detalle.attributes} onChangeInput={() => { }} onClick={() => props.handleModalBen('DET')} onKeyPress={() => { }} onBlur={() => { }} />
                                    </div>
                                </div>
                                <div className="row">
                                    <div className="col-sm-12 col-md-12">
                                        <div id="master-tabla" className="table-responsive  col-xs-12 col-sm-12 col-md-12 col-lg-12">
                                            <TablaFiltro
                                                columnas={columnas}
                                                datos={props.listaPreLiquidacionCXC}
                                                keyField={'Linea'}
                                                modo={cellEditDet}
                                                rowEvents={rowEventsDet}
                                                selectRow={selectRowDet}
                                                rowStyle={rowStyleSal}
                                                verLHOC={false}
                                                exportarCVS={false}
                                                nombreCSV={"CuentasPorCobrar"}
                                            />
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div className="col-sm-12 col-md-12" >
                                <div className='row'>
                                    <div className="col-sm-12 col-md-12" >
                                        <CheckBox id='CxCMultipleSolicitud' col="6" attributes={props.Datos.CxCMultipleSolicitud.attributes} value={props.Datos.CxCMultipleSolicitud.value} label={props.Datos.CxCMultipleSolicitud.attributes.label} onChange={props.handleCheckBox} />
                                        <CajaTextoBusqueda col="4" id="Beneficiario_Deducciones" type="text" label={props.Datos.Beneficiario_Deducciones.attributes.label} value={props.Datos.Beneficiario_Deducciones.value} attributes={props.Datos.Beneficiario_Deducciones.attributes} onChangeInput={() => { }} onClick={() => props.handleModalBen('DED')} onKeyPress={() => { }} onBlur={() => { }} />
                                        <CajaTextoBusqueda col="4" id="Beneficiario_Preaviso" type="text" label={props.Datos.Beneficiario_Preaviso.attributes.label} value={props.Datos.Beneficiario_Preaviso.value} attributes={props.Datos.Beneficiario_Preaviso.attributes} onChangeInput={() => { }} onClick={() => props.handleModalBen('PRE')} onKeyPress={() => { }} onBlur={() => { }} />
                                        <CajaTextoBusqueda col="4" id="Beneficiario_OtrosDias" type="text" label={props.Datos.Beneficiario_OtrosDias.attributes.label} value={props.Datos.Beneficiario_OtrosDias.value} attributes={props.Datos.Beneficiario_OtrosDias.attributes} onChangeInput={() => { }} onClick={() => props.handleModalBen('OTR')} onKeyPress={() => { }} onBlur={() => { }} />
                                    </div>
                                </div>
                                <div className='row'>
                                    <CajaTexto col="4" id="CxcMontoRebaja" type="text" label={props.Datos.CxcMontoRebaja.attributes.label} value={props.onFormato(props.Datos.CxcMontoRebaja.value)} attributes={props.Datos.CxcMontoRebaja.attributes} onChangeInput={() => { }} align='right' />
                                    <CajaTexto col="4" id="CxCMontoLiq" type="text" label={props.Datos.CxCMontoLiq.attributes.label} value={props.onFormato(props.Datos.CxCMontoLiq.value)} attributes={props.Datos.CxCMontoLiq.attributes} onChangeInput={() => { }} align='right' />
                                    <CajaTexto col="4" id="CxCMontoPagar" type="text" label={props.Datos.CxCMontoPagar.attributes.label} value={props.onFormato(props.Datos.CxCMontoPagar.value)} attributes={props.Datos.CxCMontoPagar.attributes} onChangeInput={() => { }} align='right' />
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </Fragment>
    );
};
export default (withRouter(memo(cuentasporCobrar)));