danielbrito1987

WindowDialog.js

Jul 27th, 2021
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import React from 'react';
  2. import { connect } from 'react-redux';
  3. import { bindActionCreators } from 'redux'
  4. import { panelWindow } from '../actions'
  5.  
  6. import { formatDate, formatNumber } from 'devextreme/localization';
  7. import translate from '../language/index'
  8. import { FREE, BUSY } from '../containers/StatusTypes'
  9.  
  10. import { Popup as PopupForm, ToolbarItem, Position } from 'devextreme-react/popup';
  11. import { AsyncRule, Form as FormPopup, Item, Label, RequiredRule, SimpleItem, StringLengthRule, Tab, TabbedItem, TabPanelOptions } from 'devextreme-react/form';
  12. import { ScrollView, Button, Box, DropDownBox } from 'devextreme-react';
  13.  
  14.  
  15. import DataGrid, { Column, Export, ColumnChooser, ColumnFixing, Selection, Editing, FilterRow, HeaderFilter, SearchPanel, GroupPanel, Sorting, Pager, Paging, Popup, Summary, TotalItem, Lookup, Grouping, Form, Scrolling, GroupItem } from 'devextreme-react/data-grid';
  16. import { Tooltip } from 'devextreme-react/tooltip';
  17.  
  18. import Magnifier from "react-magnifier";
  19. import { isPlate, imageToDataUri } from '../funcs'
  20. import Carousel from './Carousel';
  21.  
  22. import * as consts from './../constants'
  23. import { sendRequest } from '../api/api';
  24. import CustomStore from 'devextreme/data/custom_store';
  25.  
  26. import FileUploader from 'devextreme-react/file-uploader';
  27. import { apiLoad, saveChange } from './../actions'
  28. import notify from 'devextreme/ui/notify';
  29. import { v4 as uuidv4 } from 'uuid'
  30.  
  31. import jsPDF from 'jspdf';
  32. import 'jspdf-autotable';
  33. import { exportDataGrid as exportDataGridToPdf } from 'devextreme/pdf_exporter';
  34. import { toBase64, isCPF, isCNPJ } from '../funcs'
  35.  
  36. import ActiveCell from '../components/ActiveCell';
  37. import YesCell from '../components/YesCell';
  38. import axios from 'axios';
  39.  
  40. const mapStateToProps = store => ({
  41.   modal: store.overlay.modal,
  42.   windows: store.panel.windows,
  43. });
  44.  
  45. let up = 0;
  46.  
  47. const mapDispatchToProps = dispatch =>
  48.   bindActionCreators({ panelWindow, apiLoad, saveChange }, dispatch);
  49.  
  50. class WindowDialog extends React.Component {
  51.   constructor(props) {
  52.     super(props);
  53.     this.timeUpdate = 0;
  54.     this.cancel;
  55.     this._isMounted = false;
  56.     this.dataGridMovimentsRef = React.createRef();
  57.     this.dataGridTarifacaoRef = React.createRef();
  58.     this.dataGridHistoricoRef = React.createRef();
  59.         this.dataGridRef = React.createRef();
  60.         this.gridDocumentsContainer = React.createRef();
  61.         this.fpGuest = React.createRef();
  62.     this.txtQtdHospedes = React.createRef();
  63.  
  64.     let date = new Date();
  65.     date.setHours(date.getHours() - 3);
  66.     this.state = {
  67.       events: [],
  68.       frmSimulate: {},
  69.       simulateInfo: null,
  70.       dataSource: new CustomStore({
  71.         key: 'pessoa_id',
  72.         load: () => sendRequest('/pessoas/0'),
  73.                 insert: (values) => function(){},
  74.         update: (key, values) => function(){}
  75.       }),
  76.       editRowKey: undefined,
  77.             isPhysical: true,
  78.       frmGuest: {},
  79.             contacts: [],
  80.             documents: [],
  81.             addresses: [],
  82.             expanded: true,
  83.             expandedAddress: true,
  84.             expandedContact: true,
  85.             expandedDocument: true,
  86.             contactsDeletedSource: [],
  87.       expand: this.props.expand,
  88.       animation: '',
  89.       animationClose: '',
  90.       error: { field: null, message: null },
  91.       qtd_hospedes: 2,
  92.       camera: null,
  93.       imagens: [],
  94.       isCam: true,
  95.       checkin_em: date.toISOString().substr(0, 19),
  96.       checkout: new Date(),
  97.       awake: new Date(),
  98.       tipo_tarifacao: 0,
  99.       tabIndex: this.props.tabIndex ? this.props.tabIndex : (this.props.status == FREE ? 0 : 7),
  100.       transportes: [],
  101.       hospedes: [],
  102.       servicos: [],
  103.       produtos: [],
  104.       movements: [],
  105.       tarifacoes: [],
  106.       dsTarifacao: [],
  107.       vendas: [],
  108.       frmChekin: { checkin_em: new Date() },
  109.       frmMovimentacao: {},
  110.       fdPaymentMethod: {},
  111.       fdDiscount: {},
  112.       paymentMethodVisible: false,
  113.       discountVisible: false,
  114.       totalServicos: 0,
  115.       totalConsumo: 0,
  116.       totalAdiantamento: 0,
  117.       totalAcrescimos: 0,
  118.       totalDescontos: 0,
  119.       valorReceber: 0,
  120.       valorTroco: 0
  121.     }
  122.  
  123.     this.openModal = this.openModal.bind(this);
  124.     this.closeModal = this.closeModal.bind(this);
  125.     this.changeTab = this.changeTab.bind(this);
  126.     this.update = this.update.bind(this);
  127.     this.onKeyDown = this.onKeyDown.bind(this);
  128.     this.onError = this.onError.bind(this);
  129.     this.addVehicle = this.addVehicle.bind(this);
  130.     this.delVehicle = this.delVehicle.bind(this);
  131.     this.firstTransport = this.firstTransport.bind(this);
  132.     this.addGuest = this.addGuest.bind(this);
  133.     this.delGuest = this.delGuest.bind(this);
  134.     this.paymentMethodClick = this.paymentMethodClick.bind(this);
  135.     this.discountClick = this.discountClick.bind(this);
  136.     this.hideInfo = this.hideInfo.bind(this);
  137.     this.makeDiscount = this.makeDiscount.bind(this);
  138.     this.makePaymentMethod = this.makePaymentMethod.bind(this);
  139.  
  140.     this.takeSnapShot = this.takeSnapShot.bind(this);
  141.     this.clearSnapShot = this.clearSnapShot.bind(this);
  142.     this.loadCamera = this.loadCamera.bind(this);
  143.     this.catchSnapShot = this.catchSnapShot.bind(this);
  144.     this.thumbsClick = this.thumbsClick.bind(this);
  145.     this.onToolbarPreparing = this.onToolbarPreparing.bind(this);
  146.     this.onToolbarPreparingMoviments = this.onToolbarPreparingMoviments.bind(this);
  147.     this.onToolbarPreparingTransport = this.onToolbarPreparingTransport.bind(this);
  148.     this.onToolbarPreparingProdutosServicos = this.onToolbarPreparingProdutosServicos.bind(this);
  149.     this.onProductsTableSelectionChanged =  this.onProductsTableSelectionChanged.bind(this);
  150.    
  151.     this.getPaymentMethodById = this.getPaymentMethodById.bind(this);
  152.     this.getDiscountById = this.getDiscountById.bind(this);
  153.     this.calcularTotal = this.calcularTotal.bind(this);
  154.     this.onCalculatePrice = this.onCalculatePrice.bind(this);
  155.  
  156.     this.onSaving = this.onSaving.bind(this);
  157.         this.onInitNewRow = this.onInitNewRow.bind(this);
  158.         this.onEditingStartGuest = this.onEditingStartGuest.bind(this);
  159.         this.validateForm = this.validateForm.bind(this);
  160.         this.typePersonChange = this.typePersonChange.bind(this);
  161.         this.asyncCpfCnpjValidation = this.asyncCpfCnpjValidation.bind(this);
  162.         this.setImage = this.setImage.bind(this);
  163.     this.renderImgs = this.renderImgs.bind(this);
  164.     this.renderSavedImgs = this.renderSavedImgs.bind(this);
  165.     this.clearImages = this.clearImages.bind(this);
  166.         this.onDropZoneEnter = this.onDropZoneEnter.bind(this);
  167.         this.onDropZoneLeave = this.onDropZoneLeave.bind(this);
  168.         this.onSavingDocuments = this.onSavingDocuments.bind(this);
  169.         this.onEditCanceledDocuments = this.onEditCanceledDocuments.bind(this);
  170.         this.onEditingStartDocuments = this.onEditingStartDocuments.bind(this);
  171.     this.onSavingBilling = this.onSavingBilling.bind(this);
  172.  
  173.         this.onToolbarPreparingAddress = this.onToolbarPreparingAddress.bind(this);
  174.         this.onToolbarPreparingContact = this.onToolbarPreparingContact.bind(this);
  175.         this.onToolbarPreparingDocument = this.onToolbarPreparingDocument.bind(this);
  176.     this.onToolbarPreparingBill = this.onToolbarPreparingBill.bind(this);
  177.  
  178.         this.collapseAllClick = this.collapseAllClick.bind(this);
  179.         this.collapseAllClickAddress = this.collapseAllClickAddress.bind(this);
  180.         this.collapseAllClickContact = this.collapseAllClickContact.bind(this);
  181.         this.collapseAllClickDocument = this.collapseAllClickDocument.bind(this);
  182.  
  183.         this.exportGrid = this.exportGrid.bind(this);
  184.         this.exportGridAddress = this.exportGridAddress.bind(this);
  185.         this.exportGridContact = this.exportGridContact.bind(this);
  186.         this.exportGridDocument = this.exportGridDocument.bind(this);
  187.  
  188.         this.onRowRemovedContact = this.onRowRemovedContact.bind(this);
  189.     this.getUhData = this.getUhData.bind(this);
  190.     this.getGuests = this.getGuests.bind(this);
  191.     this.checkin = this.checkin.bind(this);
  192.  
  193.     this.minimizeBtnOp = {
  194.       icon: 'dx-icon dx-icon-minus',
  195.       stylingMode: 'text',
  196.       onClick: this.openModal
  197.     }
  198.  
  199.     this.billingBtnOp = {
  200.       text: translate('Billing'),
  201.       icon: 'fas fa-dollar-sign',
  202.       onClick: () => this.changeTab(1)
  203.     }
  204.  
  205.     this.paymentsBtnOp = {
  206.       text: translate('PaymentsAndDiscounts'),
  207.       icon: 'fas fa-coins',
  208.       onClick: () => this.changeTab(2)
  209.     }
  210.  
  211.     this.checkInBtnOp = {
  212.       text: this.props.status == FREE ? translate('CheckIn') : translate('CheckOut'),
  213.       icon: 'fa fa-sign-in-alt',
  214.       type: 'success',
  215.       onClick: this.checkin.bind(this)
  216.     }
  217.  
  218.     this.paymentMethodButtonOptions = {
  219.       icon: 'check',
  220.       text: translate('Confirm'),
  221.       onClick: this.makePaymentMethod.bind(this)
  222.     };
  223.     this.discountButtonOptions = {
  224.       icon: 'check',
  225.       text: translate('Confirm'),
  226.       onClick: this.makeDiscount.bind(this)
  227.     };
  228.     this.closeButtonOptions = {
  229.       text: translate('Close'),
  230.       onClick: this.hideInfo
  231.     };
  232.   }
  233.  
  234.     collapseAllClick(e)
  235.     {
  236.     let newValue = !this.state.expanded;
  237.     e.component.option('hint', newValue ? translate('CollapseAll') : translate('ExpandAll'));
  238.         e.component.option('icon', newValue ? 'arrowup' : 'arrowdown');
  239.     this.setState({
  240.       expanded: newValue
  241.     });
  242.     }
  243.  
  244.   exportGrid()
  245.     {
  246.         const doc = new jsPDF({ orientation: "landscape" });
  247.         const dataGrid = this.dataGridRef.current.instance;
  248.  
  249.         var colCount=0;  
  250.         for (var i=0; i < dataGrid.columnCount(); i++)
  251.         {  
  252.             if(dataGrid.columnOption(i,"groupIndex") > -1)
  253.             {  
  254.                 colCount++;  // já é suficiente
  255.                 break;
  256.             }  
  257.         }    
  258.  
  259.         exportDataGridToPdf(
  260.         {
  261.             jsPDFDocument: doc,
  262.             component: dataGrid,
  263.             hideRowsExpanded: !this.state.expanded && colCount > 0
  264.         }).then(() =>
  265.         {
  266.           doc.save(document.title+'.pdf');
  267.         });
  268.     }
  269.  
  270.     collapseAllClickAddress(e)
  271.     {
  272.     let newValue = !this.state.expandedAddress;
  273.     e.component.option('hint', newValue ? translate('CollapseAll') : translate('ExpandAll'));
  274.         e.component.option('icon', newValue ? 'arrowup' : 'arrowdown');
  275.     this.setState({
  276.       expandedAddress: newValue
  277.     });
  278.     }
  279.    
  280.     onToolbarPreparingAddress(e) {
  281.     e.toolbarOptions.items.unshift({
  282.       location: 'after',
  283.       widget: 'dxButton',
  284.       options: {
  285.                 icon:'exportpdf',
  286.         hint: translate('INF_65'),
  287.         onClick: this.exportGridAddress
  288.       }
  289.     },
  290.         {
  291.       location: 'after',
  292.       widget: 'dxButton',
  293.       options: {
  294.                 icon: 'arrowup',
  295.         hint: translate('CollapseAll'),
  296.         onClick: this.collapseAllClickAddress
  297.       }
  298.     });
  299.     }
  300.  
  301.     exportGridAddress()
  302.     {
  303.         const doc = new jsPDF({ orientation: "landscape" });
  304.         const dataGrid = this.dataGridRef.current.instance;
  305.  
  306.         var colCount=0;  
  307.         for (var i=0; i < dataGrid.columnCount(); i++)
  308.         {  
  309.             if(dataGrid.columnOption(i,"groupIndex") > -1)
  310.             {  
  311.                 colCount++;  // já é suficiente
  312.                 break;
  313.             }  
  314.         }    
  315.  
  316.         exportDataGridToPdf(
  317.         {
  318.             jsPDFDocument: doc,
  319.             component: dataGrid,
  320.             hideRowsExpanded: !this.state.expanded && colCount > 0
  321.         }).then(() =>
  322.         {
  323.           doc.save(document.title+'_'+translate('Address')+'.pdf');
  324.         });
  325.     }
  326.  
  327.     collapseAllClickContact(e)
  328.     {
  329.     let newValue = !this.state.expandedContact;
  330.     e.component.option('hint', newValue ? translate('CollapseAll') : translate('ExpandAll'));
  331.         e.component.option('icon', newValue ? 'arrowup' : 'arrowdown');
  332.     this.setState({
  333.       expandedContact: newValue
  334.     });
  335.     }
  336.    
  337.     onToolbarPreparingContact(e) {
  338.     e.toolbarOptions.items.unshift({
  339.       location: 'after',
  340.       widget: 'dxButton',
  341.       options: {
  342.                 icon:'exportpdf',
  343.         hint: translate('INF_65'),
  344.         onClick: this.exportGridContact
  345.       }
  346.     },
  347.         {
  348.       location: 'after',
  349.       widget: 'dxButton',
  350.       options: {
  351.                 icon: 'arrowup',
  352.         hint: translate('CollapseAll'),
  353.         onClick: this.collapseAllClickContact
  354.       }
  355.     });
  356.     }
  357.  
  358.     exportGridContact()
  359.     {
  360.         const doc = new jsPDF({ orientation: "landscape" });
  361.         const dataGrid = this.dataGridRef.current.instance;
  362.  
  363.         var colCount=0;  
  364.         for (var i=0; i < dataGrid.columnCount(); i++)
  365.         {  
  366.             if(dataGrid.columnOption(i,"groupIndex") > -1)
  367.             {  
  368.                 colCount++;  // já é suficiente
  369.                 break;
  370.             }  
  371.         }    
  372.  
  373.         exportDataGridToPdf(
  374.         {
  375.             jsPDFDocument: doc,
  376.             component: dataGrid,
  377.             hideRowsExpanded: !this.state.expanded && colCount > 0
  378.         }).then(() =>
  379.         {
  380.           doc.save(document.title+'_'+translate('Contact')+'.pdf');
  381.         });
  382.     }
  383.  
  384.     collapseAllClickDocument(e)
  385.     {
  386.     let newValue = !this.state.expandedDocument;
  387.     e.component.option('hint', newValue ? translate('CollapseAll') : translate('ExpandAll'));
  388.         e.component.option('icon', newValue ? 'arrowup' : 'arrowdown');
  389.     this.setState({
  390.       expandedDocument: newValue
  391.     });
  392.     }
  393.    
  394.     onToolbarPreparingDocument(e) {
  395.     e.toolbarOptions.items.unshift({
  396.       location: 'after',
  397.       widget: 'dxButton',
  398.       options: {
  399.                 icon:'exportpdf',
  400.         hint: translate('INF_65'),
  401.         onClick: this.exportGridDocument
  402.       }
  403.     },
  404.         {
  405.       location: 'after',
  406.       widget: 'dxButton',
  407.       options: {
  408.                 icon: 'arrowup',
  409.         hint: translate('CollapseAll'),
  410.         onClick: this.collapseAllClickDocument
  411.       }
  412.     });
  413.     }
  414.  
  415.     exportGridDocument()
  416.     {
  417.         const doc = new jsPDF({ orientation: "landscape" });
  418.         const dataGrid = this.dataGridRef.current.instance;
  419.  
  420.         var colCount=0;  
  421.         for (var i=0; i < dataGrid.columnCount(); i++)
  422.         {  
  423.             if(dataGrid.columnOption(i,"groupIndex") > -1)
  424.             {  
  425.                 colCount++;  // já é suficiente
  426.                 break;
  427.             }  
  428.         }    
  429.  
  430.         exportDataGridToPdf(
  431.         {
  432.             jsPDFDocument: doc,
  433.             component: dataGrid,
  434.             hideRowsExpanded: !this.state.expanded && colCount > 0
  435.         }).then(() =>
  436.         {
  437.           doc.save(document.title+'_'+translate('Document')+'.pdf');
  438.         });
  439.     }
  440.  
  441.     onEditingStartDocuments(e)
  442.     {
  443.         if(this._isMounted)
  444.         {
  445.             this.setState({
  446.                 editRowKeyDocuments: e.key,
  447.                 imagensSource: e.data.imagens ? e.data.imagens : [],
  448.             });
  449.         }
  450.     }
  451.  
  452.     onEditCanceledDocuments(e){
  453.         if(this._isMounted)
  454.         {
  455.             this.setState({
  456.                 editRowKeyDocuments: null
  457.             });
  458.         }
  459.     }
  460.  
  461.     onRowRemovedContact(e)
  462.     {
  463.         if(Number.isInteger(e.key))
  464.         {
  465.             let contactsDeletedSource = this.state.contactsDeletedSource;
  466.             contactsDeletedSource.push(e.key);
  467.             this.setState({contactsDeletedSource: contactsDeletedSource});
  468.         }
  469.     }
  470.  
  471.   onDropZoneEnter(e) {
  472.     if(e.dropZoneElement.id === 'dropzone-external') {
  473.             if(this._isMounted)
  474.             {
  475.                 this.setState({ isDropZoneActive: true });
  476.             }
  477.     }
  478.   }
  479.  
  480.   onDropZoneLeave(e) {
  481.     if(e.dropZoneElement.id === 'dropzone-external') {
  482.             if(this._isMounted)
  483.             {
  484.                 this.setState({ isDropZoneActive: false });
  485.             }
  486.     }
  487.     }
  488.    
  489.     setImage(imagem)
  490.     {
  491.         let _this = this;
  492.         let images = [];
  493.  
  494.         for(var i =0; i < imagem.value.length; i++)
  495.         {
  496.             if(imagem.value[i].size > 1048576)
  497.             {
  498.                 notify({ message: translate('ERROR_18')+' 1 MB.', position: 'top center'}, 'warning', 3000);
  499.                 return;
  500.             }
  501.  
  502.             toBase64(imagem.value[i]).then(function(dataURI)
  503.             {
  504.                 if(_this._isMounted)
  505.                 {
  506.                     images.push(dataURI);
  507.                     _this.setState({imagens: images, textVisible: false});
  508.                 }
  509.             });
  510.         }
  511.     }
  512.  
  513.     clearImages()
  514.     {
  515.         if(this._isMounted)
  516.         {
  517.             this.setState({imagens: [], textVisible: true});
  518.         }
  519.     }
  520.  
  521.     renderImgs()
  522.     {
  523.         if (this.state.imagens && this.state.imagens.length > 0)
  524.         {    
  525.             var data = this.state.imagens.map((img, index) =>
  526.             {
  527.                 return (
  528.                     <div className="dropzone-image" key={index}>
  529.                         <img src={img} alt="" />
  530.                     </div>
  531.                 );
  532.             });
  533.            
  534.             return data;
  535.         }
  536.         else return [];
  537.     }
  538.  
  539.     removeImgSaved(img, index)
  540.     {
  541.         let images = this.state.imagensSource;
  542.         let imagensDeletedSource = this.state.imagensDeletedSource;
  543.         imagensDeletedSource.push(images.splice(index, 1));
  544.  
  545.         if(this._isMounted)
  546.         {
  547.             this.setState({popupConfirm: true, keyDel: img, typeDel: 0, imagensSource: images, imagensDeletedSource: imagensDeletedSource});
  548.         }
  549.     }
  550.  
  551.     renderSavedImgs()
  552.     {
  553.         if (this.state.imagensSource && this.state.imagensSource.length > 0)
  554.         {    
  555.             var data = this.state.imagensSource.map((img, index) =>
  556.             {
  557.                 return (
  558.                     <div className="saved-image" key={index}>
  559.                         <img src={img} alt="" />
  560.                         <i className="fa fa-close" onClick={() => this.removeImgSaved(img, index)}></i>
  561.                     </div>
  562.                 );
  563.             });
  564.            
  565.             return data;
  566.         }
  567.         else return [];
  568.     }
  569.  
  570.     onSavingDocuments(e)
  571.     {
  572.         let documents = this.state.documents;
  573.         let doc = e.changes.length > 0 ? e.changes[0].data : {};
  574.         let idxEdit = -1;
  575.         let _this = this;
  576.  
  577.         if(this.state.editRowKeyDocuments)
  578.         {
  579.             documents.forEach(function (val, index) {
  580.                 if(val.pessoa_documento_id == _this.state.editRowKeyDocuments)
  581.                 {
  582.                     idxEdit = index;
  583.                     return;
  584.                 }
  585.             });
  586.            
  587.             documents[idxEdit].estado = doc.hasOwnProperty('estado') ? doc.estado : documents[idxEdit].estado;
  588.             documents[idxEdit].expedidor = doc.hasOwnProperty('expedidor') ? doc.expedidor : documents[idxEdit].expedidor;
  589.             documents[idxEdit].imagens = this.state.imagens.length > 0 ? this.state.imagens : [];
  590.             documents[idxEdit].numero = doc.hasOwnProperty('numero') ? doc.numero : documents[idxEdit].numero;
  591.             documents[idxEdit].tipo = doc.hasOwnProperty('tipo') ? doc.tipo : documents[idxEdit].tipo;
  592.             documents[idxEdit].ativo = doc.hasOwnProperty('ativo') ? doc.ativo : documents[idxEdit].ativo;
  593.             documents[idxEdit].principal = doc.hasOwnProperty('principal') ? doc.principal : documents[idxEdit].principal;
  594.             documents[idxEdit].observacao = doc.hasOwnProperty('observacao') ? doc.observacao : documents[idxEdit].observacao;
  595.             documents[idxEdit].nome = doc.hasOwnProperty('nome') ? doc.nome : documents[idxEdit].nome;
  596.             documents[idxEdit].expedido_em = doc.hasOwnProperty('expedido_em') ? doc.expedido_em : documents[idxEdit].expedido_em;
  597.  
  598.             // removidas
  599.             documents[idxEdit].imagens_removidas = this.state.imagensDeletedSource.length > 0 ? this.state.imagensDeletedSource.concat(documents[idxEdit].imagens_removidas) : [];
  600.            
  601.         }
  602.         else
  603.         {
  604.             doc = Object.assign({pessoa_documento_id: uuidv4(), imagens: this.state.imagens}, doc);
  605.             documents.push(doc);
  606.         }
  607.        
  608.         if(this._isMounted)
  609.         {
  610.             this.setState({imagens: [], imagensSource: [], imagensDeletedSource: [], contactsDeletedSource: [], dependentsDeletedSource: [], editRowKeyDocuments: undefined, documents: documents});
  611.             e.cancel = true;
  612.             this.gridDocumentsContainer.current.instance.refresh();
  613.             this.gridDocumentsContainer.current.instance.cancelEditData();
  614.         }
  615.     }
  616.  
  617.     onSaving(e)
  618.     {
  619.         if(!this.fpGuest.current.instance.validate().isValid)
  620.         {
  621.             e.cancel = true;
  622.             return;
  623.         }
  624.  
  625.         // valida cpf e cnpj
  626.         if(this.state.frmGuest.tipo == 0 )
  627.         {
  628.             if(!isCPF(this.state.frmGuest.cpf_cnpj))
  629.             {
  630.                 notify({ message: translate('INF_60'), position: 'top center'}, 'warning', 3000);
  631.                 e.cancel = true;
  632.                 return;
  633.             }
  634.         }
  635.         else if(this.state.frmGuest.tipo == 1 )
  636.         {
  637.             if(!isCNPJ(this.state.frmGuest.cpf_cnpj))
  638.             {
  639.                 notify({ message: translate('INF_61'), position: 'top center'}, 'warning', 3000);
  640.                 e.cancel = true;
  641.                 return;
  642.             }
  643.         }
  644.  
  645.         if(this.state.editRowKey)
  646.         {
  647.             e.cancel = true;
  648.  
  649.             e.promise = saveChange(this.props.dispatch, '/pessoas/2', {
  650.                 type: 'update',
  651.                 data: Object.assign({contacts: this.state.contacts, addresses: this.state.addresses, documents: this.state.documents, contatos_removidos: this.state.contactsDeletedSource}, this.state.frmGuest)
  652.             });
  653.            
  654.             let _this = this;
  655.             e.promise.then(function(e)
  656.             {
  657.                 if(_this._isMounted && e)
  658.                 {
  659.                     _this.setState({editRowKey: undefined, contactsDeletedSource: [], contacts: [], addresses: [], frmGuest: {}});
  660.                     _this.dataGridRef.current.instance.refresh();
  661.                     _this.dataGridRef.current.instance.cancelEditData();
  662.                 }
  663.             });
  664.             return;
  665.         }
  666.         else
  667.         {
  668.             e.promise = sendRequest(`/pessoas/2`, 'POST', {
  669.                 values: Object.assign({contacts: this.state.contacts, addresses: this.state.addresses, documents: this.state.documents}, this.state.frmGuest)
  670.             });
  671.            
  672.             let _this = this;
  673.             e.cancel = true;
  674.             e.promise.then(function(e)
  675.             {
  676.                 if(_this._isMounted && e)
  677.                 {
  678.                     _this.setState({editRowKey: undefined, contactsDeletedSource: [], contacts: [], addresses: [], documents: [], frmGuest: {}});
  679.                     _this.dataGridRef.current.instance.refresh();
  680.                     _this.dataGridRef.current.instance.cancelEditData();
  681.                 }
  682.             });
  683.             return;
  684.         }
  685.     };
  686.  
  687.   onSavingBilling()
  688.   {
  689.     let tabelaPreco = {};
  690.     let lista = this.state.tarifacoes;
  691.  
  692.     lista.forEach((item, index) => {
  693.       if(item.tabela_preco_id == this.state.frmSimulate.tabela_preco) {
  694.         tabelaPreco = item;
  695.         lista = null;
  696.       }
  697.     });    
  698.  
  699.     let checkout = new Date(this.state.checkout || this.state.frmChekin.checkin_em);
  700.     let duracao = new Date(tabelaPreco.duracao_tarifacao);
  701.     checkout.setHours(checkout.getHours() + duracao.getHours())
  702.  
  703.     let tarifacao = {
  704.       tarifacao_id: this.state.dsTarifacao.length + 1,
  705.       descricao: tabelaPreco.descricao,
  706.       duracao: tabelaPreco.duracao_tarifacao,
  707.       valor_cobrado: tabelaPreco.valor_cobrado,
  708.       horario_lancamento: new Date()
  709.     };
  710.  
  711.     let tarifacoes = this.state.dsTarifacao;
  712.     tarifacoes.push(tarifacao);
  713.  
  714.     this.setState({
  715.       dsTarifacao: tarifacoes,
  716.       checkout: checkout,
  717.       tipo_tarifacao: tabelaPreco.tipo_tarifacao
  718.     })
  719.   }
  720.  
  721.     onInitNewRow(e)
  722.     {
  723.         if(this._isMounted && e.rowType === "data")
  724.         {
  725.             this.setState({contacts: [], addresses: [], documents: [], frmGuest: {}});
  726.         }
  727.     }
  728.  
  729.     typePersonChange(e)
  730.     {
  731.         this.setState({isPhysical: e.value == 0 ? true : false });
  732.     }
  733.  
  734.   paymentMethodClick() {
  735.     this.setState({ paymentMethodVisible: !this.state.paymentMethodVisible, discountVisible: false });
  736.   }
  737.  
  738.   discountClick() {
  739.     this.setState({ discountVisible: !this.state.discountVisible, paymentMethodVisible: false });
  740.   }
  741.  
  742.   makePaymentMethod() {
  743.     let movements = this.state.movements;
  744.     let movement = this.getPaymentMethodById(this.state.fdPaymentMethod.forma_pagamento_id);
  745.     let total = 0;
  746.  
  747.     let payment = {
  748.       cod_movimento: movements.length + 1,
  749.       movimentacao: movement.descricao,
  750.       valor: this.state.fdPaymentMethod.valor,
  751.       tipo: 'pagamento',
  752.       data: new Date()
  753.     }
  754.  
  755.     movements.push(payment);
  756.  
  757.     movements.forEach((element) => {
  758.       if(element.tipo == 'pagamento')
  759.         total += element.valor;
  760.     })
  761.  
  762.     if (this._isMounted) {
  763.       this.setState({
  764.         payments: movements,
  765.         totalAdiantamento: total,
  766.         paymentMethodVisible: false
  767.       });
  768.     }
  769.  
  770.     this.calcularTotal();
  771.   }
  772.  
  773.   makeDiscount() {
  774.     let movements = this.state.movements;
  775.     let movement = this.getDiscountById(this.state.fdDiscount.id);
  776.     let total = 0;
  777.  
  778.     let payment = {
  779.       cod_movimento: movements.length + 1,
  780.       movimentacao: movement.descricao,
  781.       valor: this.state.fdDiscount.valor,
  782.       tipo: 'desconto',
  783.       data: new Date()
  784.     }
  785.  
  786.     movements.push(payment);
  787.  
  788.     movements.forEach((element) => {
  789.       if(element.tipo == 'desconto')
  790.         total += element.valor;
  791.     })
  792.  
  793.     if (this._isMounted) {
  794.       this.setState({
  795.         payments: movements,
  796.         totalDescontos: total,
  797.         discountVisible: false
  798.       });
  799.     }
  800.  
  801.     this.calcularTotal();
  802.   }
  803.  
  804.   getPaymentMethodById(id) {
  805.     let payment = {};
  806.    
  807.     this.state.srcFormasPagamento.forEach(function (data, index) {
  808.       if(data.forma_pagamento_id == id) {
  809.         payment = data;
  810.       }
  811.     })
  812.  
  813.     return payment;
  814.   }
  815.  
  816.   getDiscountById(id) {
  817.     let discount = {};
  818.  
  819.     this.state.srcDescontoParceiros.forEach(function (data, index) {
  820.       if (data.id == id) {
  821.         discount = data;
  822.       }
  823.     })
  824.  
  825.     return discount;
  826.   }
  827.  
  828.   calcularTotal() {
  829.     let vlrReceber = 0;
  830.     let vlrTroco = 0;
  831.     let vlrDescontos = this.state.totalDescontos;
  832.     let vlrAcrescimo = this.state.totalAcrescimos;
  833.     let vlrConsumo = this.state.totalConsumo;
  834.     let vlrServico = this.state.totalServicos;
  835.     let vlrAdiantamento = this.state.totalAdiantamento;
  836.  
  837.     vlrReceber = (this.state.simulateInfo[0].valor_cobrado + this.state.simulateInfo[0].valor_hora_adicional + vlrServico + vlrConsumo + vlrAcrescimo) - (vlrDescontos + vlrAdiantamento);
  838.     vlrTroco = vlrAdiantamento > vlrReceber ? vlrAdiantamento - vlrReceber : 0;
  839.  
  840.     this.setState({
  841.       valorReceber: vlrReceber,
  842.       valorTroco: vlrTroco,
  843.       totalAcrescimos: this.state.simulateInfo[0].valor_hora_adicional
  844.     })
  845.   }
  846.  
  847.   hideInfo() {
  848.     this.setState({
  849.       paymentMethodVisible: false,
  850.       discountVisible: false,
  851.       fdPaymentMethod: {},
  852.       fdDiscount: {}
  853.     });
  854.   }
  855.  
  856.   loadCamera() {
  857.     if (this._isMounted) {
  858.       //Captura elemento de vídeo
  859.       var video = document.querySelector("#web_camera");
  860.       if (!video) {
  861.         return;
  862.       }
  863.       //As opções abaixo são necessárias para o funcionamento correto no iOS
  864.       video.setAttribute('autoplay', '');
  865.       video.setAttribute('muted', '');
  866.       video.setAttribute('playsinline', '');
  867.  
  868.       let _this = this;
  869.  
  870.       //Verifica se o navegador pode capturar mídia
  871.       if (navigator.mediaDevices) {
  872.         navigator.mediaDevices.getUserMedia({ audio: false, video: { facingMode: 'user' } })
  873.           .then(function (stream) {
  874.             //Definir o elemento vídeo a carregar o capturado pela webcam
  875.             video.srcObject = stream;
  876.           })
  877.           .catch(function (error) {
  878.             _this.setState({ camera: '/img/no-cam.svg', isCam: false });
  879.           });
  880.       }
  881.     }
  882.   }
  883.  
  884.   takeSnapShot() {
  885.     if (this._isMounted) {
  886.       let imagens = this.state.imagens;
  887.  
  888.       if (imagens.length >= 10) {
  889.         let messages = this.props.messages;
  890.         messages.push({ type: 'info', title: translate('CheckIn'), description: translate('INF_42'), uuid: uuidv4() });
  891.         this.props.messageBox(messages);
  892.         return;
  893.       }
  894.       //Captura elemento de vídeo
  895.       var video = document.querySelector("#web_camera");
  896.  
  897.       var dataURI = imageToDataUri(video, video.videoWidth, video.videoHeight);
  898.  
  899.       imagens.push(dataURI);
  900.       this.setState({ camera: null, imagens: imagens });
  901.  
  902.       let _this = this;
  903.       setTimeout(() => {
  904.         _this.loadCamera();
  905.       }, 100);
  906.     }
  907.   }
  908.  
  909.   clearSnapShot() {
  910.     if (this._isMounted) {
  911.       let imagens = this.state.imagens;
  912.  
  913.       for (var i = 0; i < imagens.length; i++) {
  914.         if (imagens[i] == this.state.camera) {
  915.           imagens.splice(i, 1);
  916.         }
  917.       }
  918.  
  919.       this.setState({ camera: null, imagens: imagens });
  920.  
  921.       let _this = this;
  922.       setTimeout(() => {
  923.         _this.loadCamera();
  924.       }, 100);
  925.     }
  926.   }
  927.  
  928.   catchSnapShot() {
  929.     if (this._isMounted) {
  930.       this.setState({ camera: null });
  931.  
  932.       let _this = this;
  933.       setTimeout(() => {
  934.         _this.loadCamera();
  935.       }, 100);
  936.     }
  937.   }
  938.  
  939.   thumbsClick(image) {
  940.     if (this._isMounted) {
  941.       this.setState({ camera: image });
  942.     }
  943.   }
  944.  
  945.   onError(error) {
  946.     if (this._isMounted) {
  947.       this.setState({ error: error });
  948.     }
  949.   }
  950.  
  951.   update() {
  952.     this.forceUpdate();
  953.   }
  954.  
  955.   delVehicle(_index) {
  956.     let transportes = this.state.transportes;
  957.  
  958.     transportes.splice(_index, 1);
  959.  
  960.     if (this._isMounted) {
  961.       this.setState({ transportes: transportes, tipo_transporte: 2, placa_transporte: '', modelo_transporte: '', cor_transporte: '' });
  962.       up++;
  963.     }
  964.   }
  965.  
  966.   addVehicle(vehicle) {
  967.     let transportes = this.state.transportes;
  968.  
  969.     transportes.push(vehicle);
  970.  
  971.     if (this._isMounted) {
  972.       this.setState({ transportes: transportes, tipo_transporte: 2, placa_transporte: '', modelo_transporte: '', cor_transporte: '' });
  973.       up++;
  974.     }
  975.   }
  976.  
  977.   firstTransport(type, value) {
  978.     let transportes = this.state.transportes;
  979.  
  980.     switch (type) {
  981.       case 1: transportes[0].tipo = value; break;
  982.       case 2: transportes[0].placa = value; break;
  983.       case 3: transportes[0].modelo = value; break;
  984.       case 4: transportes[0].cor = value; break;
  985.     }
  986.  
  987.     if (this._isMounted) {
  988.       this.setState({ transportes: transportes, tipo_transporte: 2, placa_transporte: '', modelo_transporte: '', cor_transporte: '' });
  989.       up++;
  990.     }
  991.   }
  992.  
  993.   delGuest(_index) {
  994.     let hospedes = this.state.hospedes;
  995.  
  996.     hospedes.splice(_index, 1);
  997.  
  998.     if (this._isMounted) {
  999.       this.setState({ hospedes: hospedes, tipo_hospede: hospedes.length > 0 ? hospedes[0].tipo_hospede : 0, nome_hospede: hospedes.length > 0 ? hospedes[0].nome_hospede : '', cpf_cnpj_hospede: hospedes.length > 0 ? hospedes[0].cpf_cnpj_hospede : '' });
  1000.       up++;
  1001.     }
  1002.   }
  1003.  
  1004.   addGuest(hospede) {
  1005.     let hospedes = this.state.hospedes;
  1006.  
  1007.     hospedes.push(hospede);
  1008.  
  1009.     if (this._isMounted) {
  1010.       this.setState({ hospedes: hospedes, tipo_hospede: hospedes.length > 0 ? hospedes[0].tipo_hospede : 0, nome_hospede: hospedes.length > 0 ? hospedes[0].nome_hospede : '', cpf_cnpj_hospede: hospedes.length > 0 ? hospedes[0].cpf_cnpj_hospede : '' });
  1011.       up++;
  1012.     }
  1013.   }
  1014.  
  1015.   async componentDidMount() {
  1016.     this._isMounted = true;
  1017.     window.addEventListener('resize', this.update);
  1018.     document.addEventListener("keydown", this.onKeyDown, false);
  1019.  
  1020.     let _this = this;
  1021.     setTimeout(() => {
  1022.       _this.loadCamera();
  1023.     }, 300);
  1024.  
  1025.     if(_this.props.status == BUSY) {
  1026.       //await _this.getGuests();
  1027.       await _this.getUhData();
  1028.       await _this.onCalculatePrice();
  1029.     }
  1030.  
  1031.     const promise0 = sendRequest('/formas-pagamento-ativas');
  1032.     promise0.then(function (res) {
  1033.       if(_this._isMounted)
  1034.       {
  1035.         _this.setState({ srcFormasPagamento: res });
  1036.       }
  1037.     });
  1038.  
  1039.     const promise1 = sendRequest('/parceiros/regras');
  1040.     promise1.then(function (res) {
  1041.       if(_this._isMounted)
  1042.       {
  1043.         _this.setState({ srcDescontoParceiros: res });
  1044.       }  
  1045.     });
  1046.  
  1047.     const promise2 = sendRequest('/tabelas-precos-ativas');
  1048.     promise2.then(function (res) {
  1049.       let lista = [];
  1050.  
  1051.       if(_this._isMounted)
  1052.       {
  1053.         res.forEach((data, index) => {
  1054.           let diaSemana = new Date();
  1055.  
  1056.           if(diaSemana.getDay() == data.dia_semana && data.categoria_id == _this.props.windows[0].categoria_id) {
  1057.             lista.push(data);
  1058.           }
  1059.         })
  1060.  
  1061.         _this.setState({ tarifacoes: lista });
  1062.       }
  1063.     });
  1064.  
  1065.     const promise3 = sendRequest('/produtos-servicos');
  1066.     promise3.then(function (res) {
  1067.       if(_this._isMounted)
  1068.       {
  1069.         _this.setState({ srcProdutosservicos: res });
  1070.       }  
  1071.     });
  1072.  
  1073.     const promise4 = sendRequest('/grupo-produtos-ativos');
  1074.         promise4.then(function(res){
  1075.             if(_this._isMounted)
  1076.             {
  1077.                 _this.setState({groupsSource: res});
  1078.             }
  1079.         });
  1080.        
  1081.         const promise5 = sendRequest('/unidades-medida');
  1082.         promise5.then(function(res){
  1083.             if(_this._isMounted)
  1084.             {
  1085.                 _this.setState({measuresSource: res});
  1086.             }
  1087.         });
  1088.   }
  1089.  
  1090.   async getUhData() {
  1091.     let _this = this;
  1092.  
  1093.     const res = await sendRequest('/vendas/getByUhId/' + _this.props.windows[0].uh_id);
  1094.  
  1095.     let form = _this.state.frmChekin;
  1096.     form['checkin_em'] = new Date(res[0].checkin_em);
  1097.     form['qtd_hospedes'] = res[0].hospedes;
  1098.  
  1099.     _this.setState({
  1100.       vendas: res,
  1101.       checkin_em: new Date(res[0].checkin_em),
  1102.       frmChekin: form
  1103.     });
  1104.   }
  1105.  
  1106.   getGuests() {
  1107.     const promise = sendRequest('/pessoas/getGuests/' + this.props.windows[0].uh_id);
  1108.  
  1109.     promise.then((res) => {
  1110.       this.setState({
  1111.         dataSource: res
  1112.       });
  1113.     });
  1114.   }
  1115.  
  1116.   onKeyDown(e) {
  1117.     if(e.altKey) {
  1118.       switch(e.keyCode) {
  1119.         case 49: this.changeTab(0);
  1120.                  break;
  1121.         case 50: this.changeTab(1);
  1122.                  break;
  1123.         case 51: this.changeTab(2);
  1124.                  break;
  1125.         case 52: this.changeTab(3);
  1126.                  break;
  1127.         case 53: this.changeTab(4);
  1128.                  break;
  1129.         case 54: this.changeTab(5);
  1130.                  break;
  1131.         case 55: this.changeTab(6);
  1132.                  break;
  1133.       }
  1134.     } else if(e.keyCode == 27) {
  1135.       this.closeModal();
  1136.     }    
  1137.   }
  1138.  
  1139.   componentWillUnmount() {
  1140.     this._isMounted = false;
  1141.     clearInterval(this.timeUpdate);
  1142.     if (this.cancel) this.cancel();
  1143.   }
  1144.  
  1145.     validateForm(e){
  1146.         e.component.validate();
  1147.     }
  1148.  
  1149.     onEditingStartGuest(e) {
  1150.     let _this = this;
  1151.         const promise1 = sendRequest('/pessoas/' + e.key + '/0');
  1152.        
  1153.         promise1.then(function(res){
  1154.       if(_this._isMounted)
  1155.             {
  1156.                 _this.setState({
  1157.           editRowKey: e.key,
  1158.           fpGuest: res.pessoa,
  1159.                     contacts: res.contacts,
  1160.                     addresses: res.addresses,
  1161.                     documents: res.documents
  1162.                 });
  1163.             }
  1164.         });
  1165.     }
  1166.    
  1167.     asyncCpfCnpjValidation(params)
  1168.     {
  1169.         const editRowKey = !!this.state.editRowKey;
  1170.         const promise4 = sendRequest('/pessoas/usuario/cpfcnpj/check/2', 'POST', {cpf_cnpj: params.value});
  1171.         return promise4.then(function(res)
  1172.         {
  1173.             return res || editRowKey
  1174.         });
  1175.   }
  1176.  
  1177.   renderState(data) {
  1178.     return <span>{data.descricao}</span>;
  1179.   }
  1180.  
  1181.   openModal() {
  1182.     if (!this.state.expand && this.props.modal) {
  1183.       return;
  1184.     }
  1185.  
  1186.     if (this._isMounted) {
  1187.       this.setState({ expand: !this.state.expand, animationClose: (!this.state.expand) ? '' : ' zoomOutDown2 ' });
  1188.  
  1189.       let wd = this.props.windows;
  1190.       for (var i = 0; i < wd.length; i++) {
  1191.         if (this.props.uh_codigo == wd[i].uh_codigo) {
  1192.           wd[i].expand = !wd[i].expand;
  1193.           wd[i].tabIndex = this.state.tabIndex;
  1194.         }
  1195.       }
  1196.  
  1197.       this.props.panelWindow(wd);
  1198.  
  1199.       let _this = this;
  1200.       setTimeout(function () {
  1201.         _this.setState({ animationClose: '', frmMovimentacao: { qtd_hospedes: frmChekin.qtd_hospedes } });
  1202.       }, 1000);
  1203.     }
  1204.   }
  1205.  
  1206.   closeModal() {
  1207.     if (this._isMounted) {
  1208.       let wd = this.props.windows, wnd = [];
  1209.       for (var i = 0; i < wd.length; i++) {
  1210.         if (this.props.uh_codigo != wd[i].uh_codigo) {
  1211.           wnd.push(wd[i]);
  1212.         }
  1213.       }
  1214.  
  1215.       this.props.panelWindow(wnd);
  1216.     }
  1217.   }
  1218.  
  1219.   async changeTab(_idx) {
  1220.     if (this._isMounted) {
  1221.       var wd = this.props.windows;
  1222.       for (var i = 0; i < wd.length; i++) {
  1223.         if (this.props.uh_codigo == wd[i].uh_codigo) {
  1224.           wd[i].title = _idx;
  1225.         }
  1226.       }
  1227.       this.props.panelWindow(wd);
  1228.       var _this = this;
  1229.  
  1230.       if(_idx == 2) {
  1231.         await _this.onCalculatePrice();
  1232.       }
  1233.  
  1234.       setTimeout(function () {
  1235.         if (_this._isMounted) {
  1236.           _this.setState({ tabIndex: _idx });
  1237.         }
  1238.       }, 100);
  1239.     }
  1240.   }
  1241.  
  1242.   onToolbarPreparingBill(e) {
  1243.     e.toolbarOptions.items.unshift(
  1244.       {
  1245.         location: 'before',
  1246.         widget: 'dxLookup',
  1247.         options: {
  1248.           width: 200,
  1249.           dataSource: this.state.tarifacoes,
  1250.           valueExpr: 'tabela_preco_id',
  1251.           displayExpr: 'descricao',
  1252.           value: this.state.frmSimulate.tabela_preco,
  1253.           searchEnabled: false,
  1254.           showClearButton: false,
  1255.           showCancelButton: false,
  1256.           closeOnOutsideClick: true,
  1257.           onValueChanged: (args) => {
  1258.             let formValues = this.state.frmSimulate;
  1259.  
  1260.             formValues['tabela_preco'] = args.value;
  1261.  
  1262.             this.setState({
  1263.               frmSimulate: formValues
  1264.             })
  1265.           }
  1266.         }
  1267.       },
  1268.       {
  1269.         location: 'before',
  1270.         widget: 'dxButton',
  1271.         options: {
  1272.           type: 'success',
  1273.           text: translate('Confirm'),
  1274.           hint: translate('Confirm'),
  1275.           onClick: this.onSavingBilling
  1276.         }
  1277.       }
  1278.     )
  1279.   }
  1280.  
  1281.   onToolbarPreparingMoviments(e) {
  1282.     e.toolbarOptions.items.unshift(
  1283.       {
  1284.         location: 'after',
  1285.         widget: 'dxButton',
  1286.         options: {
  1287.           type: 'success',
  1288.           text: (this.state.discountVisible || this.state.paymentMethodVisible) ? translate('Confirm') : translate('PostPaymentMethod'),
  1289.           onClick: (this.state.discountVisible || this.state.paymentMethodVisible) ? (this.state.paymentMethodVisible ? this.makePaymentMethod : this.makeDiscount) : this.paymentMethodClick
  1290.         }
  1291.       },
  1292.       {
  1293.         location: 'after',
  1294.         widget: 'dxButton',
  1295.         options: {
  1296.           type: 'danger',
  1297.           text: (this.state.discountVisible || this.state.paymentMethodVisible) ? translate('Cancel') : translate('PostDiscount'),
  1298.           onClick: (this.state.discountVisible || this.state.paymentMethodVisible) ? this.hideInfo : this.discountClick
  1299.         }
  1300.       });
  1301.   }
  1302.  
  1303.   onToolbarPreparingTransport(e) {
  1304.     e.toolbarOptions.items.unshift(
  1305.       {
  1306.         location: 'after',
  1307.         widget: 'dxButton',
  1308.         options: {
  1309.           type: 'success',
  1310.           text: translate('Add'),
  1311.           onClick: null
  1312.         }
  1313.       },
  1314.     );
  1315.   }
  1316.  
  1317.   onToolbarPreparingProdutosServicos(e) {
  1318.     e.toolbarOptions.items.unshift(
  1319.       {
  1320.         location: 'after',
  1321.         widget: 'dxButton',
  1322.         options: {
  1323.           type: 'success',
  1324.           text: translate('Add'),
  1325.           onClick: null
  1326.         }
  1327.       },
  1328.     );
  1329.   }
  1330.  
  1331.   onProductsTableSelectionChanged(e)
  1332.     {
  1333.         this.setState({productServicesValues: e.selectedRowKeys.length && e.selectedRowKeys || []});
  1334.     }
  1335.  
  1336.   async onCalculatePrice()
  1337.     {
  1338.         let _this = this;
  1339.  
  1340.         let checkin = _this.state.checkin_em ? new Date(_this.state.checkin_em) : new Date(_this.frmChekin.checkin_em);
  1341.         let checkout = _this.state.checkout > checkin ? new Date(_this.state.checkout) : new Date();
  1342.  
  1343.         // O Check-out não pode ser menor que o Check-in
  1344.         if(checkin.getTime() >= checkout.getTime())
  1345.         {
  1346.             notify({ message: translate('ERROR_51'), position: 'top center'}, 'warning', 3000);
  1347.             return false;
  1348.         }
  1349.  
  1350.     let data = {
  1351.       checkin: checkin,
  1352.       checkout: checkout,
  1353.       categoria: _this.props.windows[0].categoria_id,
  1354.       tipo_tarifacao: _this.state.tipo_tarifacao,
  1355.       algoritmo: _this.state.checkout > _this.state.frmChekin.checkin_em ? 0 : 1
  1356.     };
  1357.  
  1358.     if(_this.state.frmSimulate.tabela_preco) {
  1359.       data.tabela_preco = _this.state.frmSimulate.tabela_preco;
  1360.     }
  1361.  
  1362.         const promise = sendRequest('/simular-tarifacao', 'POST', data);
  1363.         promise.then(function(res){
  1364.       //let checkout = new Date(res[1].data_fim);
  1365.  
  1366.       checkout.setHours(checkout.getHours() - 3);
  1367.       let awake = new Date(checkout);
  1368.       awake.setMinutes(awake.getMinutes() - 10);
  1369.  
  1370.       if(res && res.length > 0) {
  1371.         _this.setState({
  1372.           simulateInfo: res,
  1373.           checkout: checkout,
  1374.           awake: awake
  1375.         });
  1376.       } else {
  1377.         _this.setState({
  1378.           checkout: checkout,
  1379.           awake: awake
  1380.         });
  1381.       }
  1382.            
  1383.       _this.calcularTotal();
  1384.         });
  1385.     }
  1386.  
  1387.   onToolbarPreparing(e) {
  1388.     e.toolbarOptions.items.unshift({
  1389.       location: 'after',
  1390.       widget: 'dxButton',
  1391.       options: {
  1392.                 icon:'exportpdf',
  1393.         hint: translate('INF_65'),
  1394.         onClick: this.exportGrid
  1395.       }
  1396.     },
  1397.         {
  1398.       location: 'after',
  1399.       widget: 'dxButton',
  1400.       options: {
  1401.                 icon: 'arrowup',
  1402.         hint: translate('CollapseAll'),
  1403.         onClick: this.collapseAllClick
  1404.       }
  1405.     });
  1406.     }
  1407.  
  1408.   durationColumn_customizeText = (cellInfo) => {
  1409.     let date = new Date(cellInfo.data.duracao);
  1410.     return date.toLocaleTimeString();
  1411.   }
  1412.  
  1413.   entrada_customizeText = (cellInfo) => {
  1414.     return cellInfo.data.checkin_em ? formatDate(new Date(cellInfo.data.checkin_em), "dd/MM/yyyy hh:mm:ss") : "";
  1415.   }
  1416.  
  1417.   saida_customizeText = (cellInfo) => {
  1418.     return cellInfo.data.checkout_em ? formatDate(new Date(cellInfo.data.checkout_em), "dd/MM/yyyy hh:mm:ss") : "";
  1419.   }
  1420.  
  1421.   valorCobrado_customizeText = (cellInfo) => {
  1422.     return formatNumber(Number(cellInfo.data.valor_cobrado), consts.fmtCurrency);
  1423.   }
  1424.  
  1425.   valorSuite_customizeText = (cellInfo) => {
  1426.     return formatNumber(Number(cellInfo.data.valor_hospedagem), consts.fmtCurrency);
  1427.   }
  1428.  
  1429.   valorConsumos_customizeText = (cellInfo) => {
  1430.     return formatNumber(Number(cellInfo.data.valor_consumos), consts.fmtCurrency);
  1431.   }
  1432.  
  1433.   valorLiquido_customizeText = (cellInfo) => {
  1434.     return formatNumber(Number(cellInfo.data.valor_consumos), consts.fmtCurrency);
  1435.   }
  1436.  
  1437.   valorAcrescimos_customizeText = (cellInfo) => {
  1438.     return formatNumber(Number(cellInfo.data.valor_consumos), consts.fmtCurrency);
  1439.   }
  1440.  
  1441.   valorBruto_customizeText = (cellInfo) => {
  1442.     return formatNumber(Number(cellInfo.data.valor_consumos), consts.fmtCurrency);
  1443.   }
  1444.  
  1445.   comanda_customizeText = (cellInfo) => {
  1446.     return cellInfo.data.venda_id.toString().padStart(6, '0');
  1447.   }
  1448.  
  1449.   checkin() {
  1450.     let data = {
  1451.       checkin_em: formatDate(new Date(this.state.frmChekin.checkin_em), 'Y-m-d\TH:m:s'),
  1452.       qtd_hospedes: this.state.frmChekin.qtd_hospedes,
  1453.       uh_codigo: this.props.uh_codigo,
  1454.       // observacoes: this.state.frmChekin.observacoes,
  1455.       // transportes: this.state.transportes,
  1456.       // hospedes: this.state.dataSource,
  1457.       // produtos: this.state.produtos,
  1458.       // servicos: this.state.produtos,
  1459.       // imagens: this.state.imagens
  1460.     };
  1461.  
  1462.     const promise = sendRequest('/vendas/checkin', 'POST', data);
  1463.     promise.then((res) => {
  1464.       if (res.result) {
  1465.         notify({ message: 'Check-In realizado com sucesso!', position: 'top center'}, 'success', 3000);
  1466.       }
  1467.     })
  1468.     .catch((error) => {
  1469.       console.log(error);
  1470.       notify({ message: 'Erro ao realizar o check-in!', position: 'top center'}, 'error', 3000);
  1471.     })
  1472.   }
  1473.  
  1474.   render() {
  1475.     const { isPhysical, srcFormasPagamento, payments, srcDescontoParceiros, srcProdutosservicos, groupsSource, measuresSource, productServicesValues, frmChekin, dataSourceMoviments, fdDiscount, fdPaymentMethod, transportes, tarifacoes, dsTarifacao, dataSource, editRowKey, isDropZoneActive, textVisible, frmGuest, frmSimulate, contacts, addresses, documents, checkout, awake, simulateInfo, vendas } = this.state;
  1476.  
  1477.     let tabName = '';
  1478.     let tabIndex = this.state.tabIndex;
  1479.  
  1480.     switch (tabIndex) {
  1481.       default:
  1482.       case 0:
  1483.         {
  1484.           tabName = this.props.status == FREE ? translate('CheckIn') : translate('CheckOut');
  1485.         } break;
  1486.       case 1:
  1487.         {
  1488.           tabName = translate('Billing');
  1489.         } break;
  1490.       case 2:
  1491.         {
  1492.           tabName = this.state.expand ? translate('FinancialMovement') : translate('Movement');
  1493.         } break;
  1494.       case 3:
  1495.         {
  1496.           tabName = translate('ProductsAndServices');
  1497.         } break;
  1498.       case 4:
  1499.         {
  1500.           tabName = translate('Guests');
  1501.         } break;
  1502.       case 5:
  1503.         {
  1504.           tabName = translate('ModeTransport');
  1505.         } break;
  1506.       case 6:
  1507.         {
  1508.           tabName = this.state.expand ? translate('CustomerHistory') : translate('History');
  1509.         } break;
  1510.       case 7:
  1511.         {
  1512.           tabName = translate('CheckOut');
  1513.         } break;
  1514.     }
  1515.  
  1516.     return (
  1517.       <React.Fragment>
  1518.         <PopupForm
  1519.           visible={this.state.expand}
  1520.           onHiding={this.closeModal}
  1521.           dragEnabled={true}
  1522.           closeOnOutsideClick={false}
  1523.           showTitle={true}
  1524.           title={this.props.uh_codigo + ' - ' + tabName}
  1525.           width='90%'
  1526.           height='80%'
  1527.         >
  1528.           <ToolbarItem
  1529.             widget="dxButton"
  1530.             location="after"
  1531.             options={this.minimizeBtnOp}
  1532.           />
  1533.  
  1534.           <ToolbarItem
  1535.             toolbar="bottom"
  1536.             location="after">
  1537.               <div style={{padding: 4, width: "100%", fontSize: 16}} className="rect demo-dark">
  1538.                 <strong>{translate('ValueReceivable')}: {formatNumber(Number(this.state.valorReceber), consts.fmtCurrency)}</strong>
  1539.               </div>
  1540.           </ToolbarItem>
  1541.  
  1542.           <ToolbarItem
  1543.             widget="dxButton"
  1544.             toolbar="bottom"
  1545.             location="after"
  1546.             options={this.checkInBtnOp}
  1547.           />
  1548.  
  1549.           <ScrollView width='100%' height='100%'>
  1550.             <FormPopup labelLocation="top" formData={frmChekin}>
  1551.               <TabbedItem itemType="tabbed">
  1552.  
  1553.                 <TabPanelOptions selectedIndex={this.state.tabIndex} onTitleClick={(e) => this.changeTab(e.itemIndex)} />
  1554.                 {this.props.status == FREE ?
  1555.                   <Tab id="tabCheckin" colCount={3} colSpan={3} hint={translate('CheckIn')} icon="fas fa-door-open">
  1556.                     <Item colCount={2} colSpan={2} itemType="group">
  1557.                       <Item colCount={1} itemType="group" caption={translate('CheckIn')}>
  1558.                         <SimpleItem dataField="checkin_em" editorType="dxDateBox" editorOptions={{type: 'datetime', format: 'fullDate', displayFormat: 'dd/MM/yyyy HH:mm:ss', showClearButton: true, useMaskBehavior: true, adaptivityEnabled: true, disabled: true}}>
  1559.                           <Label text={translate('Inflow')} />
  1560.                         </SimpleItem>
  1561.  
  1562.                         <SimpleItem dataField="qtd_hospedes" editorType="dxNumberBox" editorOptions={{ format: consts.opInteger, min: 1, max: 99, showSpinButtons: true }}>
  1563.                           <Label text={translate('Guests')} />
  1564.                         </SimpleItem>
  1565.                       </Item>
  1566.  
  1567.                       <Item colCount={2} itemType="group" caption={translate('MainGuest')}>
  1568.                         <SimpleItem colSpan={2} dataField="nome_hospede" >
  1569.                           <StringLengthRule max={100} message={translate('ERROR_32') + " (100)"} />
  1570.                           <Label text={translate('ClientName')} />
  1571.                         </SimpleItem>
  1572.  
  1573.                         <SimpleItem colSpan={1} dataField="tipo" editorType="dxLookup" allowEditing={false} editorOptions={{ dataSource: consts.typeDocument, onValueChanged: null, displayExpr: "name", valueExpr: "id", closeOnOutsideClick: true }}>
  1574.                           <Label text={translate('Type')+' '+translate('Document')} />
  1575.                         </SimpleItem>
  1576.                              
  1577.                         <SimpleItem colSpan={1} dataField="numero" dataType='dxTextBox'>
  1578.                           <Label text={translate('DocumentNo')} />
  1579.                           <RequiredRule />
  1580.                           <StringLengthRule max={20} message={translate('ERROR_32')+" (20)"} />
  1581.                         </SimpleItem>
  1582.                       </Item>
  1583.  
  1584.                       <Item colCount={2} itemType="group" caption={translate('ModeTransport')}>
  1585.                         <SimpleItem dataField="tipo_transporte" editorType="dxLookup" allowEditing={false} editorOptions={{ dataSource: consts.typeTransport, onValueChanged: null, displayExpr: "name", valueExpr: "id", searchEnabled: true, showCancelButton: true, closeOnOutsideClick: true }}>
  1586.                           <Label text={translate('Type')} />
  1587.                         </SimpleItem>
  1588.  
  1589.                         <SimpleItem dataField="placa_transporte" >
  1590.                           <StringLengthRule max={8} message={translate('ERROR_32') + " (8)"} />
  1591.                           <Label text={translate('Plate')} />
  1592.                         </SimpleItem>
  1593.  
  1594.                         <SimpleItem dataField="modelo_transporte" >
  1595.                           <StringLengthRule max={20} message={translate('ERROR_32') + " (20)"} />
  1596.                           <Label text={translate('Model')} />
  1597.                         </SimpleItem>
  1598.  
  1599.                         <SimpleItem dataField="cor_transporte" editorType="dxLookup" allowEditing={false} editorOptions={{ dataSource: consts.colorsTransport, onValueChanged: null, displayExpr: "name", valueExpr: "id", searchEnabled: true, showCancelButton: true, closeOnOutsideClick: true }}>
  1600.                           <Label text={translate('PredominantColor')} />
  1601.                         </SimpleItem>
  1602.                       </Item>                      
  1603.  
  1604.                       <Item colCount={2} itemType="group" caption={translate('Notes')}>
  1605.                         <SimpleItem colSpan={2} dataField="observacoes" editorType="dxTextArea" editorOptions={{ height: 120 }}>
  1606.                           <StringLengthRule max={300} message={translate('ERROR_32') + " (300)"} />
  1607.                           <Label text=" " showColon={false} />
  1608.                         </SimpleItem>
  1609.                       </Item>
  1610.                     </Item>
  1611.  
  1612.                     <Item colCount={1} itemType="group">
  1613.                       <Item cssClass="col-12 row m-0 p-0 media-ck">
  1614.                         <div className="media-vd">
  1615.                           <div className="media-img" style={{ display: (this.state.camera || !this.state.isCam) ? 'block' : 'none' }}>
  1616.                             <Magnifier src={this.state.camera} mgShape='square' />
  1617.                             <div className="media-text" style={{ display: this.state.isCam ? 'none' : 'block' }}>
  1618.                               <h2>{translate('INF_41')}</h2>
  1619.                             </div>
  1620.                             <div className="group-btns">
  1621.                               <Button text={translate('Erase')} type="danger" icon="fa fa-eraser" onClick={this.clearSnapShot} />
  1622.                               <Button text={translate('Catch')} type="success" icon="fa fa-plus" onClick={this.catchSnapShot} />
  1623.                             </div>
  1624.                           </div>
  1625.                           <video autoPlay={true} id="web_camera" onClickCapture={this.takeSnapShot} style={{ display: (this.state.camera || !this.state.isCam) ? 'none' : 'block' }}></video>
  1626.                         </div>
  1627.                         <Carousel images={this.state.imagens} thumbsClick={this.thumbsClick} />
  1628.                       </Item>
  1629.                     </Item>
  1630.                   </Tab>
  1631.                   :
  1632.                   <Tab colCount={3} colSpan={3} hint={translate('CheckOut')} icon="fas fa-door-closed">
  1633.                     <Item colCount={2} colSpan={2} itemType="group">
  1634.                      
  1635.                     </Item>                  
  1636.  
  1637.                     <Item colCount={1} colSpan={1} itemType="group">
  1638.                       <div style={{backgroundColor: '#f3f3f3', padding: 6}}><strong>{translate('BillSummary')}</strong></div>
  1639.                       <br />
  1640.                       <div style={{backgroundColor: '#f3f3f3', padding: 6}}>
  1641.                         <center colSpan={2}><strong>{translate('Information')}</strong></center>
  1642.                         <Box
  1643.                           direction="row"
  1644.                           width="100%"
  1645.                           style={{padding: 4}}>                      
  1646.                           <Item ratio={0} baseSize={250}>
  1647.                             <div className="rect demo-dark">
  1648.                               {translate('AmountPeople')}
  1649.                             </div>
  1650.                           </Item>
  1651.                           <Item ratio={1}>
  1652.                             <div className="rect demo-dark">
  1653.                               {frmChekin.qtd_hospedes}
  1654.                             </div>
  1655.                           </Item>
  1656.                         </Box>
  1657.                         <Box
  1658.                           direction="row"
  1659.                           width="100%"
  1660.                           style={{padding: 4}}>                      
  1661.                           <Item ratio={0} baseSize={250}>
  1662.                             <div className="rect demo-dark">
  1663.                               {translate('CheckIn')}
  1664.                             </div>
  1665.                           </Item>
  1666.                           <Item ratio={0} baseSize={150}>
  1667.                             <div className="rect demo-dark">
  1668.                               {formatDate(new Date(this.state.checkin_em), 'dd/MM/yyyy HH:mm:ss')}
  1669.                             </div>
  1670.                           </Item>
  1671.                         </Box>
  1672.                         <Box
  1673.                           direction="row"
  1674.                           width="100%"
  1675.                           style={{padding: 4}}>                      
  1676.                           <Item ratio={0} baseSize={250}>
  1677.                             <div className="rect demo-dark">
  1678.                               {translate('CheckOut')}
  1679.                             </div>
  1680.                           </Item>
  1681.                           <Item ratio={0} baseSize={150}>
  1682.                             <div className="rect demo-dark">
  1683.                               {formatDate(new Date(checkout), 'dd/MM/yyyy HH:mm:ss')}
  1684.                             </div>
  1685.                           </Item>
  1686.                         </Box>
  1687.                         <Box
  1688.                           direction="row"
  1689.                           width="100%"
  1690.                           style={{padding: 4}}>                      
  1691.                           <Item ratio={0} baseSize={250}>
  1692.                             <div className="rect demo-dark">
  1693.                               {translate('Awakening')}
  1694.                             </div>
  1695.                           </Item>
  1696.                           <Item ratio={0} baseSize={150}>
  1697.                             <div className="rect demo-dark">
  1698.                             {
  1699.                               formatDate(new Date(awake), 'dd/MM/yyyy HH:mm:ss')
  1700.                             }
  1701.                             </div>
  1702.                           </Item>
  1703.                         </Box>
  1704.                         <Box
  1705.                           direction="row"
  1706.                           width="100%"
  1707.                           style={{padding: 4}}>                      
  1708.                           <Item ratio={0} baseSize={250}>
  1709.                             <div className="rect demo-dark">
  1710.                               {translate('Permanence')}
  1711.                             </div>
  1712.                           </Item>
  1713.                           <Item ratio={0} baseSize={150}>
  1714.                             <div className="rect demo-dark">
  1715.                               {simulateInfo ? simulateInfo[1].permanencia : null}
  1716.                             </div>
  1717.                           </Item>
  1718.                         </Box>
  1719.                       </div>
  1720.                       <br />
  1721.                       <div style={{backgroundColor: '#f3f3f3', padding: 6}}>
  1722.                         <center colSpan={2}><strong>{translate('Billing')}</strong></center>                            
  1723.                           {
  1724.                             simulateInfo ?
  1725.                             simulateInfo.map((item, index) =>
  1726.                               item.tabela_preco_id ?
  1727.                               [
  1728.                                 <Box
  1729.                                   key={index}
  1730.                                   direction="row"
  1731.                                   width="100%"
  1732.                                   style={{padding: 4}}>
  1733.                                   <Item ratio={0} baseSize={250}>
  1734.                                     <div className="rect demo-dark">
  1735.                                       {item.descricao}
  1736.                                     </div>
  1737.                                   </Item>
  1738.                                   <Item ratio={1}>
  1739.                                     <div className="rect demo-dark">
  1740.                                       {formatNumber(item.valor_cobrado, consts.fmtCurrency)}
  1741.                                     </div>
  1742.                                   </Item>
  1743.                                 </Box>
  1744.                               ] : null
  1745.                             ) : null
  1746.                           }
  1747.                        
  1748.                       </div>
  1749.                       <br />
  1750.                       <div style={{backgroundColor: '#f3f3f3', padding: 6}}>
  1751.                         <center colSpan={2}><strong>{translate('ProductsAndServices')}</strong></center>
  1752.                         <Box
  1753.                           direction="row"
  1754.                           width="100%"
  1755.                           style={{padding: 4}}>                      
  1756.                           <Item ratio={0} baseSize={250}>
  1757.                             <div className="rect demo-dark">
  1758.                               {translate('Services')}
  1759.                             </div>
  1760.                           </Item>
  1761.                           <Item ratio={1}>
  1762.                             <div className="rect demo-dark">
  1763.                               {formatNumber(Number(this.state.totalServicos), consts.fmtCurrency)}
  1764.                             </div>
  1765.                           </Item>
  1766.                         </Box>
  1767.                         <Box
  1768.                           direction="row"
  1769.                           width="100%"
  1770.                           style={{padding: 4}}>                      
  1771.                           <Item ratio={0} baseSize={250}>
  1772.                             <div className="rect demo-dark">
  1773.                               {translate('Consumption')}
  1774.                             </div>
  1775.                           </Item>
  1776.                           <Item ratio={1}>
  1777.                             <div className="rect demo-dark">
  1778.                               {formatNumber(Number(this.state.totalConsumo), consts.fmtCurrency)}
  1779.                             </div>
  1780.                           </Item>
  1781.                         </Box>
  1782.                       </div>
  1783.                       <br />
  1784.                       <div style={{backgroundColor: '#f3f3f3', padding: 6}}>
  1785.                         <center colSpan={2}><strong>{translate('Subtotal')}</strong></center>
  1786.                         <Box
  1787.                           direction="row"
  1788.                           width="100%"
  1789.                           style={{padding: 4}}>                      
  1790.                           <Item ratio={0} baseSize={250}>
  1791.                             <div className="rect demo-dark">
  1792.                               {translate('Advance')}
  1793.                             </div>
  1794.                           </Item>
  1795.                           <Item ratio={1}>
  1796.                             <div className="rect demo-dark">
  1797.                               {formatNumber(Number(this.state.totalAdiantamento), consts.fmtCurrency)}
  1798.                             </div>
  1799.                           </Item>
  1800.                         </Box>
  1801.                         <Box
  1802.                           direction="row"
  1803.                           width="100%"
  1804.                           style={{padding: 4}}>                      
  1805.                           <Item ratio={0} baseSize={250}>
  1806.                             <div className="rect demo-dark">
  1807.                               {translate('Additions')}
  1808.                             </div>
  1809.                           </Item>
  1810.                           <Item ratio={1}>
  1811.                             <div className="rect demo-dark">
  1812.                               {formatNumber(Number(this.state.totalAcrescimos), consts.fmtCurrency)}
  1813.                             </div>
  1814.                           </Item>
  1815.                         </Box>
  1816.                         <Box
  1817.                           direction="row"
  1818.                           width="100%"
  1819.                           style={{padding: 4}}>                      
  1820.                           <Item ratio={0} baseSize={250}>
  1821.                             <div className="rect demo-dark">
  1822.                               {translate('Discounts')}
  1823.                             </div>
  1824.                           </Item>
  1825.                           <Item ratio={1}>
  1826.                             <div className="rect demo-dark">
  1827.                               {formatNumber(Number(this.state.totalDescontos), consts.fmtCurrency)}
  1828.                             </div>
  1829.                           </Item>
  1830.                         </Box>
  1831.                       </div>
  1832.                       <div style={{border: "solid", borderWidth: 2, borderColor: "green", marginTop: 8}}>
  1833.                         <Box
  1834.                           direction="row"
  1835.                           width="100%"
  1836.                           style={{padding: 4}}>                      
  1837.                           <Item ratio={0} baseSize={250}>
  1838.                             <div className="rect demo-dark">
  1839.                               <strong>{translate('ValueReceivable')}</strong>
  1840.                             </div>
  1841.                           </Item>
  1842.                           <Item ratio={1}>
  1843.                             <div className="rect demo-dark">
  1844.                               <strong>{formatNumber(Number(this.state.valorReceber), consts.fmtCurrency)}</strong>
  1845.                             </div>
  1846.                           </Item>
  1847.                         </Box>
  1848.                       </div>
  1849.                       <div style={{border: "solid", borderWidth: 2, borderColor: "orange", marginTop: 8}}>
  1850.                         <Box
  1851.                           direction="row"
  1852.                           width="100%"
  1853.                           style={{padding: 4}}>                      
  1854.                           <Item ratio={0} baseSize={250}>
  1855.                             <div className="rect demo-dark">
  1856.                               <strong>{translate('ChangeMoney')}</strong>
  1857.                             </div>
  1858.                           </Item>
  1859.                           <Item ratio={1}>
  1860.                             <div className="rect demo-dark">
  1861.                               <strong>{formatNumber(Number(this.state.valorTroco), consts.fmtCurrency)}</strong>
  1862.                             </div>
  1863.                           </Item>
  1864.                         </Box>
  1865.                       </div>
  1866.                     </Item>
  1867.                   </Tab>
  1868.                 }
  1869.                
  1870.                 <Tab hint={translate('Billing')} icon="fas fa-money-bill-wave">                  
  1871.                   <Item colCount={2} colSpan={2} itemType="group">
  1872.                     <FormPopup labelLocation="top" colCount={3} colSpan={1} formData={frmSimulate}>
  1873.                       <SimpleItem dataField="categoria"
  1874.                         visible={false}
  1875.                         editorType="dxTextBox"
  1876.                         editorOptions={{value: this.props.windows[0].categoria_id}}>
  1877.                       </SimpleItem>
  1878.                       <SimpleItem dataField="checkin"
  1879.                         visible={false}
  1880.                         editorType="dxTextBox"
  1881.                         editorOptions={{value: frmChekin.checkin_em}}>
  1882.                       </SimpleItem>
  1883.                       {/* <SimpleItem dataField="tabela_preco"
  1884.                           editorType="dxLookup"
  1885.                           editorOptions={{
  1886.                           dataSource:tarifacoes,
  1887.                           valueExpr:"tabela_preco_id",
  1888.                           displayExpr:"descricao",
  1889.                           searchEnabled:false,
  1890.                           showClearButton: false,
  1891.                           closeOnOutsideClick: true}}>
  1892.                         <Label text={translate('PriceTable')}/>
  1893.                         <RequiredRule/>
  1894.                       </SimpleItem> */}
  1895.                     </FormPopup>
  1896.  
  1897.                     <DataGrid
  1898.                       id="gridTarifacao"
  1899.                       ref={this.dataGridTarifacaoRef}
  1900.                       dataSource={dsTarifacao}
  1901.                       repaintChangesOnly={true}
  1902.                       keyExpr="tarifacao_id"
  1903.                       allowColumnReordering={true}
  1904.                       allowColumnResizing={true}
  1905.                       showBorders={true}
  1906.                       onToolbarPreparing={this.onToolbarPreparingBill}
  1907.                       onRowRemoving={this.onRowRemovingBilling}
  1908.                       onRowRemoved={this.onRowRemovedBiling}
  1909.                       onInitNewRow={null}
  1910.                       onEditingStart={null}
  1911.                       columnHidingEnabled={true}>
  1912.                         <Editing
  1913.                           allowDeleting={true}
  1914.                           useIcons={true}>
  1915.                         </Editing>
  1916.  
  1917.                         <Scrolling mode="infinite" />
  1918.                         <Paging enabled={true} pageSize={10} />
  1919.                         <Pager showPageSizeSelector={true} allowedPageSizes={[10, 20, 30, 40, 50, 100]} showInfo={true} />
  1920.                         <Sorting mode="multiple" />
  1921.                        
  1922.                         <Column
  1923.                           dataField="tarifacao_id"
  1924.                           caption={translate('Code')}
  1925.                           dataType="string"
  1926.                         />
  1927.                         <Column
  1928.                           dataField="descricao"
  1929.                           caption={translate('Description')}
  1930.                           dataType="string"
  1931.                         />
  1932.                         <Column
  1933.                           dataField="duracao_tarifacao"
  1934.                           caption={translate('Duration')}
  1935.                           cellRender={this.durationColumn_customizeText}
  1936.                         />
  1937.                         <Column
  1938.                           dataField="valor_cobrado"
  1939.                           caption={translate('ValueTable')}
  1940.                           cellRender={this.valorCobrado_customizeText}
  1941.                         />
  1942.                         <Column
  1943.                           dataField="horario_lancamento"
  1944.                           caption={translate('LaunchTime')}
  1945.                           dataType="datetime"
  1946.                         />
  1947.                     </DataGrid>
  1948.                   </Item>
  1949.                 </Tab>
  1950.  
  1951.                 <Tab colCount={3} colSpan={3} hint={translate('FinancialMovement')} icon="fas fa-dollar-sign">
  1952.                   <Item colCount={2} colSpan={2} itemType="group">
  1953.                     <FormPopup labelLocation="top" colCount={2} className={"mb-10"} formData={fdPaymentMethod} visible={this.state.paymentMethodVisible}>
  1954.                       <SimpleItem dataField="forma_pagamento_id" editorType="dxLookup" editorOptions={{ dataSource: srcFormasPagamento, displayExpr: 'descricao', valueExpr: 'forma_pagamento_id', closeOnOutsideClick: true }}>
  1955.                         <RequiredRule />
  1956.                         <Label text={translate('PaymentMethods')} />
  1957.                       </SimpleItem>
  1958.                       <SimpleItem dataField="valor" editorType="dxNumberBox" editorOptions={Object.assign({ min: 0.1 }, consts.opCurrency)}>
  1959.                         <Label text={translate('Value')} />
  1960.                       </SimpleItem>
  1961.                     </FormPopup>
  1962.                     <FormPopup labelLocation="top" colCount={2} className={"mb-10"} formData={fdDiscount} visible={this.state.discountVisible}>
  1963.                       <SimpleItem dataField="tipo_desconto" editorType="dxLookup"
  1964.                         editorOptions={{
  1965.                           dataSource: consts.discountType,
  1966.                           displayExpr: 'name',
  1967.                           valueExpr: 'id',
  1968.                           closeOnOutsideClick: true
  1969.                         }}>
  1970.                         <RequiredRule />
  1971.                         <Label text={translate('Discount')} />
  1972.                       </SimpleItem>
  1973.                       <SimpleItem dataField="valor" editorType="dxNumberBox" editorOptions={Object.assign({ min: 0.1 }, consts.opCurrency)}>
  1974.                         <Label text={translate('Value')} />
  1975.                       </SimpleItem>
  1976.                     </FormPopup>
  1977.                     <DataGrid
  1978.                       ref={this.dataGridMovimentsRef}
  1979.                       width="100%"
  1980.                       dataSource={payments}
  1981.                       repaintChangesOnly={true}
  1982.                       allowColumnReordering={true}
  1983.                       allowColumnResizing={true}
  1984.                       showBorders={true}
  1985.                       onToolbarPreparing={this.onToolbarPreparingMoviments}
  1986.                       columnHidingEnabled={true}>
  1987.                       <Grouping autoExpandAll={this.state.expanded} />
  1988.                       <Selection mode="multiple" />
  1989.                       <Paging defaultPageSize={20} />
  1990.                       <Pager showPageSizeSelector={true} allowedPageSizes={[10, 20, 30, 40, 50, 100]} showInfo={true} />
  1991.                       <Sorting mode="multiple" />
  1992.                       <FilterRow visible={true} applyFilter="auto" />
  1993.                       <HeaderFilter visible={false} />
  1994.                       <SearchPanel visible={false} />
  1995.                       <Editing
  1996.                         allowDeleting={true}
  1997.                         useIcons={true}
  1998.                       />
  1999.                       <Column
  2000.                         dataField="cod_movimento"
  2001.                         caption="ID"
  2002.                         visible={false}>
  2003.                       </Column>
  2004.                       <Column
  2005.                         dataField="movimentacao"
  2006.                         caption={translate('Movements')}>
  2007.                       </Column>
  2008.                       <Column
  2009.                         dataField="valor"
  2010.                         caption={translate('Value')}
  2011.                         dataType="number"
  2012.                         format={consts.fmtCurrency}
  2013.                         width={100} />
  2014.                       <Column
  2015.                         dataField="data"
  2016.                         caption={translate('Date')}
  2017.                         dataType="datetime"
  2018.                         editorOptions={consts.fmtDatetime}
  2019.                         width={140} />
  2020.                     </DataGrid>
  2021.                   </Item>                  
  2022.  
  2023.                   <Item colCount={1} colSpan={1} itemType="group">
  2024.                     <div style={{backgroundColor: '#f3f3f3', padding: 6}}><strong>{translate('BillSummary')}</strong></div>
  2025.                     <br />
  2026.                     <div style={{backgroundColor: '#f3f3f3', padding: 6}}>
  2027.                       <center colSpan={2}><strong>{translate('Information')}</strong></center>
  2028.                       <Box
  2029.                         direction="row"
  2030.                         width="100%"
  2031.                         style={{padding: 4}}>                      
  2032.                         <Item ratio={0} baseSize={250}>
  2033.                           <div className="rect demo-dark">
  2034.                             {translate('AmountPeople')}
  2035.                           </div>
  2036.                         </Item>
  2037.                         <Item ratio={1}>
  2038.                           <div className="rect demo-dark">
  2039.                             {frmChekin.qtd_hospedes}
  2040.                           </div>
  2041.                         </Item>
  2042.                       </Box>
  2043.                       <Box
  2044.                         direction="row"
  2045.                         width="100%"
  2046.                         style={{padding: 4}}>                      
  2047.                         <Item ratio={0} baseSize={250}>
  2048.                           <div className="rect demo-dark">
  2049.                             {translate('CheckIn')}
  2050.                           </div>
  2051.                         </Item>
  2052.                         <Item ratio={0} baseSize={150}>
  2053.                           <div className="rect demo-dark">
  2054.                             {formatDate(new Date(this.state.checkin_em), 'dd/MM/yyyy HH:mm:ss')}
  2055.                           </div>
  2056.                         </Item>
  2057.                       </Box>
  2058.                       <Box
  2059.                         direction="row"
  2060.                         width="100%"
  2061.                         style={{padding: 4}}>                      
  2062.                         <Item ratio={0} baseSize={250}>
  2063.                           <div className="rect demo-dark">
  2064.                             {translate('CheckOut')}
  2065.                           </div>
  2066.                         </Item>
  2067.                         <Item ratio={0} baseSize={150}>
  2068.                           <div className="rect demo-dark">
  2069.                             {formatDate(new Date(checkout), 'dd/MM/yyyy HH:mm:ss')}
  2070.                           </div>
  2071.                         </Item>
  2072.                       </Box>
  2073.                       <Box
  2074.                         direction="row"
  2075.                         width="100%"
  2076.                         style={{padding: 4}}>                      
  2077.                         <Item ratio={0} baseSize={250}>
  2078.                           <div className="rect demo-dark">
  2079.                             {translate('Awakening')}
  2080.                           </div>
  2081.                         </Item>
  2082.                         <Item ratio={0} baseSize={150}>
  2083.                           <div className="rect demo-dark">
  2084.                           {
  2085.                             formatDate(new Date(awake), 'dd/MM/yyyy HH:mm:ss')
  2086.                           }
  2087.                           </div>
  2088.                         </Item>
  2089.                       </Box>
  2090.                       <Box
  2091.                         direction="row"
  2092.                         width="100%"
  2093.                         style={{padding: 4}}>                      
  2094.                         <Item ratio={0} baseSize={250}>
  2095.                           <div className="rect demo-dark">
  2096.                             {translate('Permanence')}
  2097.                           </div>
  2098.                         </Item>
  2099.                         <Item ratio={0} baseSize={150}>
  2100.                           <div className="rect demo-dark">
  2101.                             {simulateInfo ? simulateInfo[1].permanencia : null}
  2102.                           </div>
  2103.                         </Item>
  2104.                       </Box>
  2105.                     </div>
  2106.                     <br />
  2107.                     <div style={{backgroundColor: '#f3f3f3', padding: 6}}>
  2108.                       <center colSpan={2}><strong>{translate('Billing')}</strong></center>                            
  2109.                         {
  2110.                           simulateInfo ?
  2111.                           simulateInfo.map((item, index) =>
  2112.                             item.tabela_preco_id ?
  2113.                             [
  2114.                               <Box
  2115.                                 key={index}
  2116.                                 direction="row"
  2117.                                 width="100%"
  2118.                                 style={{padding: 4}}>
  2119.                                 <Item ratio={0} baseSize={250}>
  2120.                                   <div className="rect demo-dark">
  2121.                                     {item.descricao}
  2122.                                   </div>
  2123.                                 </Item>
  2124.                                 <Item ratio={1}>
  2125.                                   <div className="rect demo-dark">
  2126.                                     {formatNumber(item.valor_cobrado, consts.fmtCurrency)}
  2127.                                   </div>
  2128.                                 </Item>
  2129.                               </Box>
  2130.                             ] : null
  2131.                           ) : null
  2132.                         }
  2133.                      
  2134.                     </div>
  2135.                     <br />
  2136.                     <div style={{backgroundColor: '#f3f3f3', padding: 6}}>
  2137.                       <center colSpan={2}><strong>{translate('ProductsAndServices')}</strong></center>
  2138.                       <Box
  2139.                         direction="row"
  2140.                         width="100%"
  2141.                         style={{padding: 4}}>                      
  2142.                         <Item ratio={0} baseSize={250}>
  2143.                           <div className="rect demo-dark">
  2144.                             {translate('Services')}
  2145.                           </div>
  2146.                         </Item>
  2147.                         <Item ratio={1}>
  2148.                           <div className="rect demo-dark">
  2149.                             {formatNumber(Number(this.state.totalServicos), consts.fmtCurrency)}
  2150.                           </div>
  2151.                         </Item>
  2152.                       </Box>
  2153.                       <Box
  2154.                         direction="row"
  2155.                         width="100%"
  2156.                         style={{padding: 4}}>                      
  2157.                         <Item ratio={0} baseSize={250}>
  2158.                           <div className="rect demo-dark">
  2159.                             {translate('Consumption')}
  2160.                           </div>
  2161.                         </Item>
  2162.                         <Item ratio={1}>
  2163.                           <div className="rect demo-dark">
  2164.                             {formatNumber(Number(this.state.totalConsumo), consts.fmtCurrency)}
  2165.                           </div>
  2166.                         </Item>
  2167.                       </Box>
  2168.                     </div>
  2169.                     <br />
  2170.                     <div style={{backgroundColor: '#f3f3f3', padding: 6}}>
  2171.                       <center colSpan={2}><strong>{translate('Subtotal')}</strong></center>
  2172.                       <Box
  2173.                         direction="row"
  2174.                         width="100%"
  2175.                         style={{padding: 4}}>                      
  2176.                         <Item ratio={0} baseSize={250}>
  2177.                           <div className="rect demo-dark">
  2178.                             {translate('Advance')}
  2179.                           </div>
  2180.                         </Item>
  2181.                         <Item ratio={1}>
  2182.                           <div className="rect demo-dark">
  2183.                             {formatNumber(Number(this.state.totalAdiantamento), consts.fmtCurrency)}
  2184.                           </div>
  2185.                         </Item>
  2186.                       </Box>
  2187.                       <Box
  2188.                         direction="row"
  2189.                         width="100%"
  2190.                         style={{padding: 4}}>                      
  2191.                         <Item ratio={0} baseSize={250}>
  2192.                           <div className="rect demo-dark">
  2193.                             {translate('Additions')}
  2194.                           </div>
  2195.                         </Item>
  2196.                         <Item ratio={1}>
  2197.                           <div className="rect demo-dark">
  2198.                             {formatNumber(Number(this.state.totalAcrescimos), consts.fmtCurrency)}
  2199.                           </div>
  2200.                         </Item>
  2201.                       </Box>
  2202.                       <Box
  2203.                         direction="row"
  2204.                         width="100%"
  2205.                         style={{padding: 4}}>                      
  2206.                         <Item ratio={0} baseSize={250}>
  2207.                           <div className="rect demo-dark">
  2208.                             {translate('Discounts')}
  2209.                           </div>
  2210.                         </Item>
  2211.                         <Item ratio={1}>
  2212.                           <div className="rect demo-dark">
  2213.                             {formatNumber(Number(this.state.totalDescontos), consts.fmtCurrency)}
  2214.                           </div>
  2215.                         </Item>
  2216.                       </Box>
  2217.                     </div>
  2218.                     <div style={{border: "solid", borderWidth: 2, borderColor: "green", marginTop: 8}}>
  2219.                       <Box
  2220.                         direction="row"
  2221.                         width="100%"
  2222.                         style={{padding: 4}}>                      
  2223.                         <Item ratio={0} baseSize={250}>
  2224.                           <div className="rect demo-dark">
  2225.                             <strong>{translate('ValueReceivable')}</strong>
  2226.                           </div>
  2227.                         </Item>
  2228.                         <Item ratio={1}>
  2229.                           <div className="rect demo-dark">
  2230.                             <strong>{formatNumber(Number(this.state.valorReceber), consts.fmtCurrency)}</strong>
  2231.                           </div>
  2232.                         </Item>
  2233.                       </Box>
  2234.                     </div>
  2235.                     <div style={{border: "solid", borderWidth: 2, borderColor: "orange", marginTop: 8}}>
  2236.                       <Box
  2237.                         direction="row"
  2238.                         width="100%"
  2239.                         style={{padding: 4}}>                      
  2240.                         <Item ratio={0} baseSize={250}>
  2241.                           <div className="rect demo-dark">
  2242.                             <strong>{translate('ChangeMoney')}</strong>
  2243.                           </div>
  2244.                         </Item>
  2245.                         <Item ratio={1}>
  2246.                           <div className="rect demo-dark">
  2247.                             <strong>{formatNumber(Number(this.state.valorTroco), consts.fmtCurrency)}</strong>
  2248.                           </div>
  2249.                         </Item>
  2250.                       </Box>
  2251.                     </div>
  2252.                   </Item>
  2253.                 </Tab>
  2254.  
  2255.                 <Tab hint={translate('ProductsAndServices')} icon="fas fa-concierge-bell">
  2256.                   <FormPopup colCount={4} colSpan={4} labelLocation="top" ref={null} formData={null}>
  2257.                     <Item colSpan={3} isRequired={true}>
  2258.                       <DropDownBox
  2259.                           dataSource={srcProdutosservicos}
  2260.                           keyExpr="produto_id"
  2261.                           displayExpr={consts.displayCodigoDescricao}
  2262.                           placeholder={translate('Select')}
  2263.                           value={productServicesValues}>
  2264.                         <DataGrid
  2265.                           dataSource={srcProdutosservicos}
  2266.                           hoverStateEnabled={true}
  2267.                           selectedRowKeys={productServicesValues}
  2268.                           onSelectionChanged={this.onProductsTableSelectionChanged}
  2269.                           columnHidingEnabled={true}
  2270.                           height={255}
  2271.                           >
  2272.                           <Selection mode="single" />
  2273.                           <Scrolling mode="infinite" />
  2274.                           <FilterRow visible={true} />
  2275.                           <Paging enabled={false} pageSize={6}/>
  2276.                           <Column
  2277.                             dataField="codigo"
  2278.                             caption={translate('Code')}
  2279.                             width={80}
  2280.                             alignment="center"
  2281.                             allowEditing={false}
  2282.                           />
  2283.  
  2284.                           <Column
  2285.                             dataField="descricao"
  2286.                             caption={translate('Description')}
  2287.                             dataType="string"  
  2288.                           />
  2289.  
  2290.                           <Column
  2291.                             dataField="grupo_id"
  2292.                             caption={translate('Group')}>
  2293.                             <Lookup dataSource={groupsSource} valueExpr="produto_grupo_id" displayExpr="descricao"/>
  2294.                           </Column>
  2295.  
  2296.                           <Column
  2297.                             dataField="materia_prima"
  2298.                             caption={translate('Feedstock')}  
  2299.                             dataType="boolean"
  2300.                             cellRender={YesCell}
  2301.                             width={80}
  2302.                             falseText={translate('No')}
  2303.                             trueText={translate('Yes')}
  2304.                             alignment="center"
  2305.                           />
  2306.  
  2307.                           <Column
  2308.                             dataField="composto"
  2309.                             caption={translate('Compound')}  
  2310.                             dataType="boolean"
  2311.                             cellRender={YesCell}
  2312.                             width={80}
  2313.                             falseText={translate('No')}
  2314.                             trueText={translate('Yes')}
  2315.                             alignment="center"
  2316.                           />
  2317.  
  2318.                           <Column
  2319.                             dataField="exibe_cardapio"
  2320.                             caption={translate('ShowOnMenu')}  
  2321.                             dataType="boolean"
  2322.                             cellRender={YesCell}
  2323.                             width={80}
  2324.                             falseText={translate('No')}
  2325.                             trueText={translate('Yes')}
  2326.                             alignment="center"
  2327.                           />
  2328.  
  2329.                           <Column
  2330.                             dataField="valor"
  2331.                             caption={translate('Value')}  
  2332.                             dataType="number"
  2333.                             format={consts.fmtCurrency}
  2334.                             width={140}
  2335.                           />
  2336.  
  2337.                           <Column
  2338.                             dataField="un_medida_id"
  2339.                             caption={translate('UnitsMeasure')}>
  2340.                             <Lookup dataSource={measuresSource} valueExpr="un_medida_id" displayExpr="descricao"/>
  2341.                           </Column>
  2342.  
  2343.                         </DataGrid>
  2344.                       </DropDownBox>
  2345.                       <Label text={translate('ProductsAndServices')}/>
  2346.                     </Item>
  2347.                     <SimpleItem dataField="quantidade" isRequired={true} editorType="dxNumberBox" editorOptions={{format: consts.opInteger, min: 1, max: 999, showSpinButtons:true}}>
  2348.                                           <Label text={translate('Amount')}/>
  2349.                                         </SimpleItem>
  2350.                    
  2351.                     <SimpleItem dataField="tipo_alteracao" editorType="dxLookup" allowEditing={false} editorOptions={{ dataSource: consts.typeChange, onValueChanged: null, displayExpr: "name", valueExpr: "id", showCancelButton: true, closeOnOutsideClick: true }}>
  2352.                       <Label text={translate('Type')+' '+translate('Adjustment')} />
  2353.                     </SimpleItem>
  2354.  
  2355.                     <SimpleItem dataField="valor_alteracao" editorType="dxNumberBox" editorOptions={{format: consts.fmtCurrency, min: 0.0, max: 9999}}>
  2356.                                             <Label text={translate('Value')+' '+translate('Adjustment')}/>
  2357.                                         </SimpleItem>
  2358.  
  2359.                     <SimpleItem colSpan={2} dataField="variacao" editorType="dxTextArea" editorOptions={{height: 60}}>
  2360.                       <StringLengthRule max={150} message={translate('ERROR_32') + " (150)"} />
  2361.                       <Label text={translate('Variation')} showColon={false} />
  2362.                     </SimpleItem>
  2363.                    
  2364.                   </FormPopup>
  2365.                  
  2366.                   <DataGrid
  2367.                     id="gridContainer"
  2368.                     ref={this.dataGridProductsServicesRef}
  2369.                     dataSource={srcProdutosservicos}
  2370.                     repaintChangesOnly={true}
  2371.                     //keyExpr="produtos_servicos_id"
  2372.                     allowColumnReordering={true}
  2373.                     allowColumnResizing={true}
  2374.                     showBorders={true}
  2375.                     onSaving={null}
  2376.                     onEditingStart={null}
  2377.                     onToolbarPreparing={this.onToolbarPreparingProdutosServicos}
  2378.                     columnHidingEnabled={true}>
  2379.                     <Scrolling mode="infinite" />
  2380.                     <Paging enabled={true} pageSize={10} />
  2381.                     <Pager showPageSizeSelector={true} allowedPageSizes={[10, 20, 30, 40, 50, 100]} showInfo={true} />
  2382.                     <Sorting mode="multiple" />
  2383.                     <ColumnFixing enabled={true} />
  2384.                     <FilterRow visible={true} applyFilter="auto" />
  2385.                     <HeaderFilter visible={false} />
  2386.                     <GroupPanel visible={true} />
  2387.                     <Export enabled={true} allowExportSelectedData={true} fileName={document.title} />
  2388.                    
  2389.                     <Editing
  2390.                       mode="popup"
  2391.                       allowUpdating={true}
  2392.                       allowDeleting={true}
  2393.                       useIcons={true}>
  2394.                       <Popup title={translate('ProductsAndServices')} showTitle={true} width="90%" height={300} />
  2395.                         <FormPopup colCount={4} colSpan={4} labelLocation="top" ref={null} formData={null}>
  2396.                           <Item colSpan={4} isRequired={true}>
  2397.                             <DropDownBox
  2398.                                 dataSource={srcProdutosservicos}
  2399.                                 keyExpr="produto_id"
  2400.                                 displayExpr={consts.displayCodigoDescricao}
  2401.                                 placeholder={translate('Select')}
  2402.                                 value={productServicesValues}>
  2403.                               <DataGrid
  2404.                                 dataSource={srcProdutosservicos}
  2405.                                 hoverStateEnabled={true}
  2406.                                 selectedRowKeys={productServicesValues}
  2407.                                 onSelectionChanged={this.onProductsTableSelectionChanged}
  2408.                                 columnHidingEnabled={true}
  2409.                                 height={255}
  2410.                                 >
  2411.                                 <Selection mode="single" />
  2412.                                 <Scrolling mode="infinite" />
  2413.                                 <FilterRow visible={true} />
  2414.                                 <Paging enabled={false} pageSize={6}/>
  2415.                                 <Column
  2416.                                   dataField="codigo"
  2417.                                   caption={translate('Code')}
  2418.                                   width={80}
  2419.                                   alignment="center"
  2420.                                   allowEditing={false}
  2421.                                 />
  2422.  
  2423.                                 <Column
  2424.                                   dataField="descricao"
  2425.                                   caption={translate('Description')}
  2426.                                   dataType="string"  
  2427.                                 />
  2428.  
  2429.                                 <Column
  2430.                                   dataField="grupo_id"
  2431.                                   caption={translate('Group')}>
  2432.                                   <Lookup dataSource={groupsSource} valueExpr="produto_grupo_id" displayExpr="descricao"/>
  2433.                                 </Column>
  2434.  
  2435.                                 <Column
  2436.                                   dataField="materia_prima"
  2437.                                   caption={translate('Feedstock')}  
  2438.                                   dataType="boolean"
  2439.                                   cellRender={YesCell}
  2440.                                   width={80}
  2441.                                   falseText={translate('No')}
  2442.                                   trueText={translate('Yes')}
  2443.                                   alignment="center"
  2444.                                 />
  2445.  
  2446.                                 <Column
  2447.                                   dataField="composto"
  2448.                                   caption={translate('Compound')}  
  2449.                                   dataType="boolean"
  2450.                                   cellRender={YesCell}
  2451.                                   width={80}
  2452.                                   falseText={translate('No')}
  2453.                                   trueText={translate('Yes')}
  2454.                                   alignment="center"
  2455.                                 />
  2456.  
  2457.                                 <Column
  2458.                                   dataField="exibe_cardapio"
  2459.                                   caption={translate('ShowOnMenu')}  
  2460.                                   dataType="boolean"
  2461.                                   cellRender={YesCell}
  2462.                                   width={80}
  2463.                                   falseText={translate('No')}
  2464.                                   trueText={translate('Yes')}
  2465.                                   alignment="center"
  2466.                                 />
  2467.  
  2468.                                 <Column
  2469.                                   dataField="valor"
  2470.                                   caption={translate('Value')}  
  2471.                                   dataType="number"
  2472.                                   format={consts.fmtCurrency}
  2473.                                   width={140}
  2474.                                 />
  2475.  
  2476.                                 <Column
  2477.                                   dataField="un_medida_id"
  2478.                                   caption={translate('UnitsMeasure')}>
  2479.                                   <Lookup dataSource={measuresSource} valueExpr="un_medida_id" displayExpr="descricao"/>
  2480.                                 </Column>
  2481.                               </DataGrid>
  2482.                             </DropDownBox>
  2483.                             <Label text={translate('Product')}/>
  2484.                           </Item>
  2485.                          
  2486.                           <SimpleItem dataField="quantidade" isRequired={true} editorType="dxNumberBox" editorOptions={{format: consts.opInteger, min: 1, max: 999, showSpinButtons:true}}>
  2487.                             <Label text={translate('Amount')}/>
  2488.                           </SimpleItem>
  2489.                          
  2490.                           <SimpleItem dataField="tipo_alteracao" editorType="dxLookup" allowEditing={false} editorOptions={{ dataSource: consts.typeChange, onValueChanged: null, displayExpr: "name", valueExpr: "id", showCancelButton: true, closeOnOutsideClick: true }}>
  2491.                             <Label text={translate('Type')+' '+translate('Adjustment')} />
  2492.                           </SimpleItem>
  2493.  
  2494.                           <SimpleItem dataField="valor_alteracao" editorType="dxNumberBox" editorOptions={{format: consts.fmtCurrency, min: 0.0, max: 9999}}>
  2495.                             <Label text={translate('Value')+' '+translate('Adjustment')}/>
  2496.                           </SimpleItem>
  2497.  
  2498.                           <SimpleItem colSpan={2} dataField="variacao_pedido" editorType="dxTextArea" editorOptions={{height: 60}}>
  2499.                             <StringLengthRule max={150} message={translate('ERROR_32') + " (150)"} />
  2500.                             <Label text={translate('Variation')} showColon={false} />
  2501.                           </SimpleItem>
  2502.                         </FormPopup>
  2503.                     </Editing>
  2504.                    
  2505.                     <Column
  2506.                       dataField="codigo"
  2507.                       caption={translate('Code')}
  2508.                       width={80}
  2509.                       alignment="center"
  2510.                       allowEditing={false}
  2511.                     />
  2512.  
  2513.                     <Column
  2514.                       dataField="descricao"
  2515.                       caption={translate('Description')}
  2516.                       dataType="string"  
  2517.                     />
  2518.  
  2519.                     <Column
  2520.                       dataField="grupo_id"
  2521.                       caption={translate('Group')}>
  2522.                       <Lookup dataSource={groupsSource} valueExpr="produto_grupo_id" displayExpr="descricao"/>
  2523.                     </Column>
  2524.  
  2525.                     <Column
  2526.                       dataField="materia_prima"
  2527.                       caption={translate('Feedstock')}  
  2528.                       dataType="boolean"
  2529.                       cellRender={YesCell}
  2530.                       width={80}
  2531.                       falseText={translate('No')}
  2532.                       trueText={translate('Yes')}
  2533.                       alignment="center"
  2534.                     />
  2535.  
  2536.                     <Column
  2537.                       dataField="composto"
  2538.                       caption={translate('Compound')}  
  2539.                       dataType="boolean"
  2540.                       cellRender={YesCell}
  2541.                       width={80}
  2542.                       falseText={translate('No')}
  2543.                       trueText={translate('Yes')}
  2544.                       alignment="center"
  2545.                     />
  2546.  
  2547.                     <Column
  2548.                       dataField="exibe_cardapio"
  2549.                       caption={translate('ShowOnMenu')}  
  2550.                       dataType="boolean"
  2551.                       cellRender={YesCell}
  2552.                       width={80}
  2553.                       falseText={translate('No')}
  2554.                       trueText={translate('Yes')}
  2555.                       alignment="center"
  2556.                     />
  2557.  
  2558.                     <Column
  2559.                       dataField="valor"
  2560.                       caption={translate('Value')}  
  2561.                       dataType="number"
  2562.                       format={consts.fmtCurrency}
  2563.                       width={140}
  2564.                     />
  2565.  
  2566.                     <Column
  2567.                       dataField="un_medida_id"
  2568.                       caption={translate('UnitsMeasure')}>
  2569.                       <Lookup dataSource={measuresSource} valueExpr="un_medida_id" displayExpr="descricao"/>
  2570.                     </Column>
  2571.  
  2572.                     <Column
  2573.                       dataField="quantidade"
  2574.                       caption={translate('Amount')}
  2575.                       dataType="number"
  2576.                     />
  2577.  
  2578.                     <Column
  2579.                       dataField="tipo_alteracao"
  2580.                       caption={translate('Type')+' '+translate('Adjustment')}>
  2581.                       <Lookup dataSource={consts.typeChange} valueExpr="id" displayExpr="name"/>
  2582.                     </Column>
  2583.  
  2584.                     <Column
  2585.                       dataField="valor_alteracao"
  2586.                       caption={translate('Value')+' '+translate('Adjustment')}  
  2587.                       dataType="number"
  2588.                       format={consts.fmtCurrency}
  2589.                       width={140}
  2590.                     />
  2591.  
  2592.                     <Column
  2593.                       dataField="variacao_pedido"
  2594.                       caption={translate('Variation')}
  2595.                       dataType="string"  
  2596.                     />
  2597.  
  2598.                     <Summary>
  2599.                       <TotalItem
  2600.                         column="codigo"
  2601.                         summaryType="count"
  2602.                         displayFormat={"{0}"}/>
  2603.                     </Summary>
  2604.                   </DataGrid>
  2605.                 </Tab>
  2606.  
  2607.                 <Tab hint={translate('Guests')} icon="fas fa-suitcase-rolling">
  2608.                   <DataGrid
  2609.                     id="gridContainer"
  2610.                     ref={this.dataGridRef}
  2611.                     dataSource={dataSource}
  2612.                     repaintChangesOnly={true}
  2613.                     allowColumnReordering={true}
  2614.                     allowColumnResizing={true}
  2615.                     showBorders={true}
  2616.                     onSaving={this.onSaving}
  2617.                     onEditingStart={this.onEditingStartGuest}
  2618.                     onInitNewRow={this.onInitNewRow}
  2619.                     onToolbarPreparing={this.onToolbarPreparing}
  2620.                     columnHidingEnabled={true}>
  2621.  
  2622.                     <Grouping autoExpandAll={this.state.expanded} />
  2623.                     <Selection mode="multiple" />
  2624.                     <Editing
  2625.                       mode="popup"
  2626.                       refreshMode="reshape"
  2627.                       allowUpdating={true}
  2628.                       allowAdding={true}
  2629.                       allowDeleting={false}
  2630.                       useIcons={true}>
  2631.  
  2632.                       <Popup title={translate('Guests')} showTitle={true} width="90%"/>
  2633.                       <FormPopup labelLocation="top">
  2634.                         <TabbedItem colCount={2} colSpan={2} itemType="tabbed">
  2635.                           <Tab title={translate('Guest')}>
  2636.                             <FormPopup labelLocation="top" ref={this.fpGuest} colCount={2} colSpan={2} formData={frmGuest}>
  2637.                               <SimpleItem dataField="ativo" helpText={translate('INF_38')} editorType="dxCheckBox">
  2638.                                 <Label text={translate('Situation')}/>
  2639.                               </SimpleItem>
  2640.                               <SimpleItem dataField="tipo" editorType="dxLookup" allowEditing={false} editorOptions={{dataSource: consts.typePerson,  onValueChanged: this.typePersonChange, displayExpr: "name", valueExpr: "id", searchEnabled: false, showCancelButton: false, closeOnOutsideClick: true}} isRequired={true}>
  2641.                                 <Label text={translate('Person')}/>
  2642.                               </SimpleItem>
  2643.                               <SimpleItem dataField="nome" visible={isPhysical} isRequired={true}>
  2644.                                 <StringLengthRule max={30} message={translate('ERROR_32')+" (30)"} />
  2645.                                 <Label text={translate('Name')}/>
  2646.                               </SimpleItem>
  2647.                               <SimpleItem dataField="sobrenome" visible={isPhysical} isRequired={true}>
  2648.                                 <StringLengthRule max={70} message={translate('ERROR_32')+" (70)"} />
  2649.                                 <Label text={translate('LastName')}/>
  2650.                               </SimpleItem>
  2651.                               <SimpleItem dataField="razao_social" visible={!isPhysical} isRequired={true}>
  2652.                                 <StringLengthRule max={50} message={translate('ERROR_32')+" (50)"} />
  2653.                                 <Label text={translate('SocialReason')}/>
  2654.                               </SimpleItem>
  2655.                               <SimpleItem dataField="nome_fantasia" visible={!isPhysical} isRequired={true}>
  2656.                                 <StringLengthRule max={50} message={translate('ERROR_32')+" (50)"} />
  2657.                                 <Label text={translate('FantasyName')}/>
  2658.                               </SimpleItem>
  2659.                               <SimpleItem dataField="cpf_cnpj" dataType='dxTextBox' editorOptions={{ mask: frmGuest.tipo == 0 ? "000.000.000-00" : "00.000.000/0000-00", maskInvalidMessage: isPhysical ? translate('INF_60') : translate('INF_61')}}>
  2660.                                 <Label text={frmGuest.tipo == 0 ? translate('CPF_2') : translate('CNPJ_2')} isRequired={true}/>
  2661.                                 <AsyncRule message={translate('ERROR_45')} validationCallback={this.asyncCpfCnpjValidation} />
  2662.                               </SimpleItem>
  2663.                               <SimpleItem dataField="genero" editorType="dxLookup" editorOptions={{dataSource: consts.typeGenre, displayExpr: "name", valueExpr: "id", searchEnabled: false, showCancelButton: false, closeOnOutsideClick: true}} visible={isPhysical}>
  2664.                                 <Label text={translate('Genre')}/>
  2665.                               </SimpleItem>
  2666.                               <SimpleItem dataField="data_nasc" editorType="dxDateBox" visible={frmGuest.tipo == 0} editorOptions={consts.opDate}>
  2667.                                 <Label text={translate('DateOfBirth')}/>
  2668.                               </SimpleItem>
  2669.                               <SimpleItem dataField="estado_civil" editorType="dxLookup" editorOptions={{dataSource: consts.maritalStatus, displayExpr: 'name', valueExpr: 'id', showClearButton: true, closeOnOutsideClick: true}} visible={isPhysical}>
  2670.                                 <Label text={translate('MaritalStatus')}/>
  2671.                               </SimpleItem>
  2672.                               <SimpleItem dataField="nacionalidade" visible={frmGuest.tipo == 0}>
  2673.                                 <StringLengthRule max={50} message={translate('ERROR_32')+" (50)"} />
  2674.                                 <Label text={translate('Nationality')}/>
  2675.                               </SimpleItem>
  2676.                               <SimpleItem colSpan={2} dataField="observacao" editorType="dxTextArea">
  2677.                                 <Label text={translate('Notes')}/>
  2678.                               </SimpleItem>
  2679.                             </FormPopup>
  2680.                           </Tab>
  2681.                           <Tab title={translate('Addresses')}>
  2682.                             <div className="pb-3 dx-field-item-help-text">{translate('INF_5')}</div>
  2683.                             <DataGrid
  2684.                               id="gridAddressesContainer"
  2685.                               dataSource={addresses}
  2686.                               repaintChangesOnly={true}
  2687.                               allowColumnReordering={true}
  2688.                               allowColumnResizing={true}
  2689.                               showBorders={true}
  2690.                               onToolbarPreparing={this.onToolbarPreparingAddress}
  2691.                               columnHidingEnabled={true}>
  2692.            
  2693.                               <Grouping autoExpandAll={this.state.expandedAddress} />
  2694.                               <Selection mode="multiple" />
  2695.                               <Editing
  2696.                                 mode="popup"
  2697.                                 allowUpdating={true}
  2698.                                 allowAdding={true}
  2699.                                 allowDeleting={false}
  2700.                                 useIcons={true}>
  2701.  
  2702.                                 <Popup title={translate('Address')} showTitle={true} width="90%" height="400px"/>
  2703.  
  2704.                                 <Form labelLocation="top">
  2705.                                   <Item itemType="group" colCount={2} colSpan={2}>
  2706.                                     <Item dataField="principal" />
  2707.                                     <Item dataField="ativo" />
  2708.                                     <Item dataField="endereco" isRequired={true}/>
  2709.                                     <Item dataField="estado" isRequired={true}/>
  2710.                                     <Item dataField="cidade" isRequired={true}/>
  2711.                                     <Item dataField="bairro" isRequired={true}/>
  2712.                                     <Item dataField="numero" />
  2713.                                     <Item dataField="cep" isRequired={true}/>
  2714.                                     <Item dataField="complemento" />
  2715.                                   </Item>
  2716.                                 </Form>
  2717.  
  2718.                               </Editing>
  2719.  
  2720.                               <Paging defaultPageSize={20} />
  2721.                               <Pager showPageSizeSelector={true} allowedPageSizes={[10, 20, 30, 40, 50, 100]} showInfo={true} />
  2722.                               <Sorting mode="multiple" />
  2723.                               <ColumnChooser enabled={true} />
  2724.                               <ColumnFixing enabled={true} />
  2725.                               <FilterRow visible={true} applyFilter="auto" />
  2726.                               <HeaderFilter visible={false} />
  2727.                               <SearchPanel visible={true} />
  2728.                               <GroupPanel visible={true} />
  2729.            
  2730.                               <Export enabled={true} allowExportSelectedData={true} fileName={translate('Addresses')} />
  2731.            
  2732.                               <Column
  2733.                                 dataField="endereco"
  2734.                                 caption={translate('Address')}
  2735.                                 dataType="string">
  2736.                                 <StringLengthRule max={100} message={translate('ERROR_32')+" (100)"} />
  2737.                               </Column>
  2738.            
  2739.                               <Column
  2740.                                 dataField="estado"
  2741.                                 caption={translate('State')}
  2742.                                 width={80}>
  2743.                                 <Lookup dataSource={consts.sourceStates} displayExpr='name' valueExpr='id'/>
  2744.                               </Column>
  2745.                              
  2746.                               <Column
  2747.                                 dataField="cidade"
  2748.                                 caption={translate('City')}
  2749.                                 dataType="string">
  2750.                                 <StringLengthRule max={50} message={translate('ERROR_32')+" (50)"} />
  2751.                               </Column>
  2752.                              
  2753.                               <Column
  2754.                                 dataField="bairro"
  2755.                                 caption={translate('Neighborhood')}
  2756.                                 dataType="string">
  2757.                                 <StringLengthRule max={30} message={translate('ERROR_32')+" (30)"} />
  2758.                               </Column>
  2759.                              
  2760.                               <Column
  2761.                                 dataField="numero"
  2762.                                 caption={translate('Number')}
  2763.                                 dataType="string"
  2764.                                 width={80}>
  2765.                                 <StringLengthRule max={8} message={translate('ERROR_32')+" (8)"} />
  2766.                               </Column>
  2767.            
  2768.                               <Column
  2769.                                 dataField="cep"
  2770.                                 caption={translate('ZipCode')}
  2771.                                 dataType='dxTextBox'
  2772.                                 editorOptions={{ mask: "00.000-000", maskInvalidMessage: translate('INF_62')}}
  2773.                                 width={80}/>
  2774.            
  2775.                               <Column
  2776.                                 dataField="complemento"
  2777.                                 caption={translate('Complement')}  
  2778.                                 visible={false}
  2779.                                 width={140}>
  2780.                                 <StringLengthRule max={100} message={translate('ERROR_32')+" (100)"} />
  2781.                               </Column>
  2782.            
  2783.                               <Column
  2784.                                 dataField="principal"
  2785.                                 caption={translate('Main')}
  2786.                                 dataType="boolean"
  2787.                                 cellRender={YesCell}
  2788.                                 allowHeaderFiltering={false}
  2789.                                 width={80}
  2790.                                 falseText={translate('No')}
  2791.                                 trueText={translate('Yes')}
  2792.                                 alignment="center"
  2793.                               />
  2794.  
  2795.                               <Column
  2796.                                 dataField="ativo"
  2797.                                 caption={translate('Situation')}
  2798.                                 dataType="boolean"
  2799.                                 cellRender={ActiveCell}
  2800.                                 allowHeaderFiltering={false}
  2801.                                 width={80}
  2802.                                 falseText={translate('Inactive')}
  2803.                                 trueText={translate('Active')}
  2804.                                 alignment="center"
  2805.                               />
  2806.            
  2807.                               <Summary>
  2808.                                 <GroupItem
  2809.                                   column="endereco"
  2810.                                   summaryType="count"
  2811.                                   displayFormat={"{0}"}
  2812.                                   alignByColumn={true}
  2813.                                   showInGroupFooter={true}/>
  2814.                                 <GroupItem
  2815.                                   column="endereco"
  2816.                                   summaryType="count"
  2817.                                   displayFormat={"{0}"}
  2818.                                   alignByColumn={true} />
  2819.                                 <TotalItem
  2820.                                   column="endereco"
  2821.                                   summaryType="count"
  2822.                                   displayFormat={"{0}"}/>
  2823.                               </Summary>
  2824.                             </DataGrid>
  2825.                           </Tab>
  2826.                           <Tab title={translate('FormsContact')}>
  2827.                             <DataGrid
  2828.                               id="gridContactsContainer"
  2829.                               dataSource={contacts}
  2830.                               repaintChangesOnly={true}
  2831.                               allowColumnReordering={true}
  2832.                               allowColumnResizing={true}
  2833.                               showBorders={true}
  2834.                               onRowRemoved={this.onRowRemovedContact}
  2835.                               onToolbarPreparing={this.onToolbarPreparingContact}
  2836.                               columnHidingEnabled={true}>
  2837.            
  2838.                               <Grouping autoExpandAll={this.state.expandedContact} />
  2839.                               <Selection mode="multiple" />
  2840.                               <Editing
  2841.                                 mode="popup"
  2842.                                 allowUpdating={true}
  2843.                                 allowAdding={true}
  2844.                                 allowDeleting={true}
  2845.                                 useIcons={true}>
  2846.  
  2847.                                 <Popup title={translate('Contact')} showTitle={true} width="90%" height="300px"/>
  2848.                               </Editing>
  2849.  
  2850.                               <Paging defaultPageSize={20} />
  2851.                               <Pager showPageSizeSelector={true} allowedPageSizes={[10, 20, 30, 40, 50, 100]} showInfo={true} />
  2852.                               <Sorting mode="multiple" />
  2853.                               <ColumnChooser enabled={true} />
  2854.                               <ColumnFixing enabled={true} />
  2855.                               <FilterRow visible={true} applyFilter="auto" />
  2856.                               <HeaderFilter visible={false} />
  2857.                               <SearchPanel visible={true} />
  2858.                               <GroupPanel visible={true} />
  2859.            
  2860.                               <Export enabled={true} allowExportSelectedData={true} fileName={translate('Contacts')} />
  2861.            
  2862.                               <Column
  2863.                                 dataField="tipo"
  2864.                                 caption={translate('Type')}
  2865.                                 width={160}>
  2866.                                   <RequiredRule/>
  2867.                                   <Lookup dataSource={consts.typeContact}/>
  2868.                               </Column>
  2869.  
  2870.                               <Column
  2871.                                 dataField="descricao"
  2872.                                 caption={translate('Contact')}
  2873.                                 dataType="string">
  2874.                                 <RequiredRule/>
  2875.                                 <StringLengthRule max={120} message={translate('ERROR_32')+" (120)"} />
  2876.                               </Column>
  2877.  
  2878.                               <Column
  2879.                                 dataField="observacao"
  2880.                                 caption={translate('Note')}
  2881.                                 dataType="string">
  2882.                                 <StringLengthRule max={100} message={translate('ERROR_32')+" (120)"} />
  2883.                               </Column>
  2884.            
  2885.                               <Summary>                                        
  2886.                                 <GroupItem
  2887.                                   column="descricao"
  2888.                                   summaryType="count"
  2889.                                   displayFormat={"{0}"}
  2890.                                   alignByColumn={true}
  2891.                                   showInGroupFooter={true}/>
  2892.                                 <GroupItem
  2893.                                   column="descricao"
  2894.                                   summaryType="count"
  2895.                                   displayFormat={"{0}"}
  2896.                                   alignByColumn={true} />
  2897.                                 <TotalItem
  2898.                                   column="descricao"
  2899.                                   summaryType="count"
  2900.                                   displayFormat={"{0}"}/>
  2901.                               </Summary>
  2902.                             </DataGrid>
  2903.                           </Tab>
  2904.                           <Tab title={translate('Documents')}>
  2905.                             <DataGrid
  2906.                               ref={this.gridDocumentsContainer}
  2907.                               id="gridDocumentsContainer"
  2908.                               dataSource={documents}
  2909.                               repaintChangesOnly={true}
  2910.                               allowColumnReordering={true}
  2911.                               allowColumnResizing={true}
  2912.                               showBorders={true}
  2913.                               onSaving={this.onSavingDocuments}
  2914.                               onEditingStart={this.onEditingStartDocuments}
  2915.                               onEditCanceled={this.onEditCanceledDocuments}
  2916.                               onToolbarPreparing={this.onToolbarPreparingDocument}
  2917.                               columnHidingEnabled={true}>
  2918.            
  2919.                               <Grouping autoExpandAll={this.state.expandedDocument} />
  2920.                               <Selection mode="multiple" />
  2921.                               <Editing
  2922.                                 mode="popup"
  2923.                                 allowUpdating={true}
  2924.                                 allowAdding={true}
  2925.                                 allowDeleting={false}
  2926.                                 useIcons={true}>
  2927.  
  2928.                                 <Popup title={translate('Document')} showTitle={true} width="90%" />
  2929.                                
  2930.                                 <Form labelLocation="top">
  2931.                                   <Item itemType="group" colCount={2} colSpan={2}>
  2932.                                     <Item dataField="ativo" />
  2933.                                     <Item dataField="principal" />
  2934.                                     <Item dataField="tipo" />
  2935.                                     <Item dataField="numero" />
  2936.                                     <Item dataField="expedido_em" />
  2937.                                     <Item dataField="expedidor" />
  2938.                                     <Item dataField="estado" />
  2939.                                     <Item dataField="nome" helpText={translate('INF_43')}/>
  2940.                                     <Item dataField="observacao" colSpan={2} />
  2941.                                     <Item dataField="imagens" itemType="group" colSpan={2} caption={translate('AttachDocument')}>
  2942.                                       <div id="dropzone-external" className={`flex-box ${isDropZoneActive ? 'dx-theme-accent-as-border-color dropzone-active' : 'dx-theme-border-color'}`}>
  2943.                                         <div className="d-flex justify-content-between">
  2944.                                           {this.renderImgs()}
  2945.                                         </div>
  2946.                                         {textVisible &&
  2947.                                         <div id="dropzone-text" className="flex-box">
  2948.                                           <span>{translate('INF_56')}</span>
  2949.                                           <span>{translate('ERROR_18')+' 1MB'}</span>
  2950.                                         </div>}
  2951.                                       </div>
  2952.                                         {textVisible ? null : <Button
  2953.                                                                   width={120}
  2954.                                                                   text={translate('Clean')}
  2955.                                                                   type="danger"
  2956.                                                                   stylingMode="outlined"
  2957.                                                                   onClick={this.clearImages}
  2958.                                                                 />}
  2959.                                         {this.renderSavedImgs()}
  2960.                                       <FileUploader
  2961.                                         dialogTrigger="#dropzone-external"
  2962.                                         dropZone="#dropzone-external"
  2963.                                         multiple={true}
  2964.                                         chunkSize={200000}
  2965.                                         maxFileSize={1048576}
  2966.                                         visible={false}
  2967.                                         accept="image/png,image/jpg,image/jpeg"
  2968.                                         allowedFileExtensions={['.jpg', '.jpeg', '.png']}
  2969.                                         uploadMode='useButtons'
  2970.                                         onDropZoneEnter={this.onDropZoneEnter}
  2971.                                         onDropZoneLeave={this.onDropZoneLeave}
  2972.                                         onValueChanged={this.setImage} />
  2973.                                     </Item>
  2974.                                   </Item>
  2975.                                 </Form>
  2976.                               </Editing>
  2977.  
  2978.                               <Paging defaultPageSize={20} />
  2979.                               <Pager showPageSizeSelector={true} allowedPageSizes={[10, 20, 30, 40, 50, 100]} showInfo={true} />
  2980.                               <Sorting mode="multiple" />
  2981.                               <ColumnChooser enabled={true} />
  2982.                               <ColumnFixing enabled={true} />
  2983.                               <FilterRow visible={true} applyFilter="auto" />
  2984.                               <HeaderFilter visible={false} />
  2985.                               <SearchPanel visible={true} />
  2986.                               <GroupPanel visible={true} />
  2987.            
  2988.                               <Export enabled={true} allowExportSelectedData={true} fileName={translate('Documents')} />
  2989.            
  2990.                               <Column
  2991.                                 dataField="tipo"
  2992.                                 caption={translate('Type')}
  2993.                                 width={80}>
  2994.                                   <RequiredRule/>
  2995.                                   <Lookup dataSource={consts.typeDocument} displayExpr='name' valueExpr='id'/>
  2996.                               </Column>
  2997.  
  2998.                               <Column
  2999.                                 dataField="numero"
  3000.                                 caption={translate('DocumentNo')}
  3001.                                 dataType="string">
  3002.                                 <RequiredRule/>
  3003.                                 <StringLengthRule max={20} message={translate('ERROR_32')+" (20)"} />
  3004.                               </Column>
  3005.  
  3006.                               <Column
  3007.                                 dataField="expedido_em"
  3008.                                 caption={translate('IssuedOn')}
  3009.                                 dataType="date"
  3010.                                 editorOptions={consts.opDate}
  3011.                                 format='shortDate'
  3012.                                 visible={false} >
  3013.                               </Column>
  3014.  
  3015.                               <Column
  3016.                                 dataField="expedidor"
  3017.                                 caption={translate('IssuingAgency')}
  3018.                                 dataType="string"
  3019.                                 visible={false} >
  3020.                                 <RequiredRule/>
  3021.                                 <StringLengthRule max={60} message={translate('ERROR_32')+" (60)"} />
  3022.                               </Column>
  3023.            
  3024.                               <Column
  3025.                                 dataField="estado"
  3026.                                 caption={translate('State')}
  3027.                                 width={80}>
  3028.                                   <RequiredRule/>
  3029.                                   <Lookup dataSource={consts.sourceStates} displayExpr='name' valueExpr='id'/>
  3030.                               </Column>
  3031.  
  3032.                               <Column
  3033.                                 dataField="nome"
  3034.                                 caption={translate('DocumentName')}
  3035.                                 dataType="string"
  3036.                                 visible={false} >
  3037.                                 <StringLengthRule max={60} message={translate('ERROR_32')+" (60)"} />
  3038.                               </Column>
  3039.  
  3040.                               <Column
  3041.                                 dataField="observacao"
  3042.                                 caption={translate('Note')}
  3043.                                 dataType="string"
  3044.                                 visible={false} >
  3045.                                 <StringLengthRule max={150} message={translate('ERROR_32')+" (150)"} />
  3046.                               </Column>
  3047.  
  3048.                               <Column
  3049.                                 dataField="principal"
  3050.                                 caption={translate('Main')}
  3051.                                 dataType="boolean"
  3052.                                 cellRender={YesCell}
  3053.                                 allowHeaderFiltering={false}
  3054.                                 width={80}
  3055.                                 falseText={translate('No')}
  3056.                                 trueText={translate('Yes')}
  3057.                                 alignment="center"
  3058.                               />
  3059.  
  3060.                               <Column
  3061.                                 dataField="ativo"
  3062.                                 caption={translate('Situation')}
  3063.                                 dataType="boolean"
  3064.                                 cellRender={ActiveCell}
  3065.                                 allowHeaderFiltering={false}
  3066.                                 width={80}
  3067.                                 falseText={translate('Inactive')}
  3068.                                 trueText={translate('Active')}
  3069.                                 alignment="center"
  3070.                               />
  3071.  
  3072.                               <Column
  3073.                                 dataField="criado_em"
  3074.                                 caption={translate('CreatedAt')}
  3075.                                 dataType="datetime"
  3076.                                 editorOptions={consts.opDatetime}
  3077.                                 format="shortDateShortTime"
  3078.                                 visible={false}
  3079.                                 width={140}
  3080.                               />
  3081.  
  3082.                               <Column
  3083.                                 dataField="editado_em"
  3084.                                 caption={translate('UpdatedAt')}  
  3085.                                 dataType="datetime"
  3086.                                 editorOptions={consts.opDatetime}
  3087.                                 format="shortDateShortTime"
  3088.                                 visible={false}
  3089.                                 width={140}
  3090.                               />
  3091.            
  3092.                               <Summary>
  3093.                                 <GroupItem
  3094.                                   column="tipo"
  3095.                                   summaryType="count"
  3096.                                   displayFormat={"{0}"}
  3097.                                   alignByColumn={true}
  3098.                                   showInGroupFooter={true}/>
  3099.                                 <GroupItem
  3100.                                   column="tipo"
  3101.                                   summaryType="count"
  3102.                                   displayFormat={"{0}"}
  3103.                                   alignByColumn={true} />
  3104.                                 <TotalItem
  3105.                                   column="tipo"
  3106.                                   summaryType="count"
  3107.                                   displayFormat={"{0}"}/>
  3108.                               </Summary>
  3109.                             </DataGrid>
  3110.                           </Tab>
  3111.                         </TabbedItem>
  3112.                       </FormPopup>
  3113.                     </Editing>
  3114.                     <Paging defaultPageSize={20} />
  3115.                     <Pager showPageSizeSelector={true} allowedPageSizes={[10, 20, 30, 40, 50, 100]} showInfo={true} />
  3116.                     <Sorting mode="multiple" />
  3117.                     <ColumnChooser enabled={true} />
  3118.                     <ColumnFixing enabled={true} />
  3119.                     <FilterRow visible={true}   applyFilter="auto" />
  3120.                     <HeaderFilter visible={false} />
  3121.                     <SearchPanel visible={true} />
  3122.                     <GroupPanel visible={true} />
  3123.  
  3124.                     <Export enabled={true} allowExportSelectedData={true} fileName={document.title}/>
  3125.  
  3126.                     <Column
  3127.                       dataField="nome_padrao"
  3128.                       caption={translate('Nome')}
  3129.                       dataType="string"  
  3130.                       allowHeaderFiltering={false}>
  3131.                       <RequiredRule/>
  3132.                     </Column>
  3133.  
  3134.                     <Column
  3135.                       dataField="tipo"
  3136.                       caption={translate('Person')}
  3137.                       width={100}>
  3138.                       <Lookup dataSource={consts.typePerson} displayExpr="name" valueExpr="id"/>
  3139.                       <RequiredRule/>
  3140.                     </Column>
  3141.  
  3142.                     <Column
  3143.                       dataField="cpf_cnpj"
  3144.                       caption={translate('CPFCNPJ')}
  3145.                       width={140}
  3146.                       alignment="center"
  3147.                       allowEditing={!editRowKey}>
  3148.                       <RequiredRule/>
  3149.                     </Column>
  3150.  
  3151.                     <Column
  3152.                       dataField="data_nasc"
  3153.                       caption={translate('DateOfBirth')}
  3154.                       dataType="date"
  3155.                       editorOptions={consts.opDate}
  3156.                       format='shortDate'
  3157.                       visible={false}
  3158.                       width={80}
  3159.                     />
  3160.  
  3161.                     <Column
  3162.                       dataField="idade"
  3163.                       caption={translate('Age')}
  3164.                       visible={false}
  3165.                       alignment="center"
  3166.                       width={80}
  3167.                     />
  3168.  
  3169.                     <Column
  3170.                       dataField="genero"
  3171.                       caption={translate('Genre')}
  3172.                       visible={false}
  3173.                       width={80}>
  3174.                       <Lookup dataSource={consts.typeGenre} displayExpr="name" valueExpr="id"/>
  3175.                     </Column>
  3176.  
  3177.                     <Column
  3178.                       dataField="estado_civil"
  3179.                       caption={translate('MaritalStatus')}
  3180.                       visible={false}
  3181.                       width={80}>
  3182.                       <Lookup dataSource={consts.maritalStatus} displayExpr="name" valueExpr="id" />
  3183.                     </Column>
  3184.  
  3185.                     <Column
  3186.                       dataField="ativo"
  3187.                       caption={translate('Situation')}
  3188.                       dataType="boolean"
  3189.                       cellRender={ActiveCell}
  3190.                       allowHeaderFiltering={false}
  3191.                       width={80}
  3192.                       falseText={translate('Inactive')}
  3193.                       trueText={translate('Active')}
  3194.                       alignment="center"
  3195.                     />
  3196.  
  3197.                     <Column
  3198.                       dataField="criado_em"
  3199.                       caption={translate('CreatedAt')}
  3200.                       dataType="datetime"
  3201.                       editorOptions={consts.opDatetime}
  3202.                       format="shortDateShortTime"
  3203.                       visible={false}
  3204.                       width={140}
  3205.                     />
  3206.  
  3207.                     <Column
  3208.                       dataField="editado_em"
  3209.                       caption={translate('UpdatedAt')}  
  3210.                       dataType="datetime"
  3211.                       editorOptions={consts.opDatetime}
  3212.                       format="shortDateShortTime"
  3213.                       visible={false}
  3214.                       width={140}
  3215.                     />
  3216.  
  3217.                     <Summary>
  3218.                       <GroupItem
  3219.                         column="nome_padrao"
  3220.                         summaryType="count"
  3221.                         displayFormat={"{0}"}
  3222.                         alignByColumn={true}
  3223.                         showInGroupFooter={true}/>
  3224.                       <GroupItem
  3225.                         column="nome_padrao"
  3226.                         summaryType="count"
  3227.                         displayFormat={"{0}"}
  3228.                         alignByColumn={true} />
  3229.                       <TotalItem
  3230.                         column="nome_padrao"
  3231.                         summaryType="count"
  3232.                         displayFormat={"{0}"}/>
  3233.                     </Summary>
  3234.                   </DataGrid>    
  3235.                
  3236.                 </Tab>
  3237.  
  3238.                 <Tab hint={translate('ModeTransport')} icon="fas fa-car">
  3239.                   <FormPopup colCount={4} colSpan={4} labelLocation="top" ref={null} formData={null}>
  3240.                     <SimpleItem dataField="tipo_transporte" editorType="dxLookup" allowEditing={false} editorOptions={{ dataSource: consts.typeTransport, onValueChanged: null, displayExpr: "name", valueExpr: "id", searchEnabled: true, showCancelButton: true, closeOnOutsideClick: true }}>
  3241.                       <Label text={translate('Type')} />
  3242.                     </SimpleItem>
  3243.  
  3244.                     <SimpleItem dataField="placa_transporte" >
  3245.                       <StringLengthRule max={8} message={translate('ERROR_32') + " (8)"} />
  3246.                       <Label text={translate('Plate')} />
  3247.                     </SimpleItem>
  3248.  
  3249.                     <SimpleItem dataField="modelo_transporte" >
  3250.                       <StringLengthRule max={20} message={translate('ERROR_32') + " (20)"} />
  3251.                       <Label text={translate('Model')} />
  3252.                     </SimpleItem>
  3253.  
  3254.                     <SimpleItem dataField="cor_transporte" editorType="dxLookup" allowEditing={false} editorOptions={{ dataSource: consts.colorsTransport, onValueChanged: null, displayExpr: "name", valueExpr: "id", searchEnabled: true, showCancelButton: true, closeOnOutsideClick: true }}>
  3255.                       <Label text={translate('PredominantColor')} />
  3256.                     </SimpleItem>
  3257.                   </FormPopup>
  3258.                  
  3259.                   <DataGrid
  3260.                     id="gridContainer"
  3261.                     ref={this.dataGridTrasnportRef}
  3262.                     dataSource={transportes}
  3263.                     repaintChangesOnly={true}
  3264.                     //keyExpr="meio_trasnporte_id"
  3265.                     allowColumnReordering={true}
  3266.                     allowColumnResizing={true}
  3267.                     showBorders={true}
  3268.                     onSaving={null}
  3269.                     onEditingStart={null}
  3270.                     onToolbarPreparing={this.onToolbarPreparingTransport}
  3271.                     columnHidingEnabled={true}>
  3272.                     <Scrolling mode="infinite" />
  3273.                     <Paging enabled={true} pageSize={10} />
  3274.                     <Pager showPageSizeSelector={true} allowedPageSizes={[10, 20, 30, 40, 50, 100]} showInfo={true} />
  3275.                     <Sorting mode="multiple" />
  3276.                     <ColumnFixing enabled={true} />
  3277.                     <FilterRow visible={true} applyFilter="auto" />
  3278.                     <HeaderFilter visible={false} />
  3279.                     <GroupPanel visible={true} />
  3280.                     <Export enabled={true} allowExportSelectedData={true} fileName={document.title} />
  3281.                    
  3282.                     <Editing
  3283.                       mode="popup"
  3284.                       allowUpdating={true}
  3285.                       allowDeleting={true}
  3286.                       useIcons={true}>
  3287.                       <Popup title={translate('Transporte')} showTitle={true} width="90%" height={300} />
  3288.                         <FormPopup colCount={4} colSpan={4} labelLocation="top" ref={null} formData={null}>
  3289.                           <SimpleItem dataField="tipo_transporte" editorType="dxLookup" allowEditing={false} editorOptions={{ dataSource: consts.typeTransport, onValueChanged: null, displayExpr: "name", valueExpr: "id", searchEnabled: true, showCancelButton: true, closeOnOutsideClick: true }}>
  3290.                             <Label text={translate('Type')} />
  3291.                           </SimpleItem>
  3292.  
  3293.                           <SimpleItem dataField="placa_transporte" >
  3294.                             <StringLengthRule max={8} message={translate('ERROR_32') + " (8)"} />
  3295.                             <Label text={translate('Plate')} />
  3296.                           </SimpleItem>
  3297.  
  3298.                           <SimpleItem dataField="modelo_transporte" >
  3299.                             <StringLengthRule max={20} message={translate('ERROR_32') + " (20)"} />
  3300.                             <Label text={translate('Model')} />
  3301.                           </SimpleItem>
  3302.  
  3303.                           <SimpleItem dataField="cor_transporte" editorType="dxLookup" allowEditing={false} editorOptions={{ dataSource: consts.colorsTransport, onValueChanged: null, displayExpr: "name", valueExpr: "id", searchEnabled: true, showCancelButton: true, closeOnOutsideClick: true }}>
  3304.                             <Label text={translate('PredominantColor')} />
  3305.                           </SimpleItem>
  3306.                         </FormPopup>
  3307.                     </Editing>
  3308.                    
  3309.  
  3310.                     <Column
  3311.                       dataField="placa_transporte"
  3312.                       caption={translate('Plate')}
  3313.                       dataType="string"
  3314.                       width={120}
  3315.                     />
  3316.  
  3317.                     <Column
  3318.                       dataField="modelo_transporte"
  3319.                       caption={translate('Model')}
  3320.                       dataType="string"
  3321.                     />
  3322.  
  3323.                     <Column
  3324.                       dataField="tipo_transporte"
  3325.                       caption={translate('Type')} >
  3326.                       <Lookup dataSource={consts.typeTransport} valueExpr="id" displayExpr="name"
  3327.                       width={180}/>
  3328.                     </Column>
  3329.  
  3330.                     <Column
  3331.                       dataField="cor_transporte"
  3332.                       caption={translate('PredominatColor')}
  3333.                       width={140}>
  3334.                       <Lookup dataSource={consts.colorsTransport} valueExpr="id" displayExpr="name"/>
  3335.                     </Column>
  3336.  
  3337.                     <Summary>
  3338.                       <TotalItem
  3339.                         column="placa_transporte"
  3340.                         summaryType="count"
  3341.                         displayFormat={"{0}"}/>
  3342.                     </Summary>
  3343.                   </DataGrid>          
  3344.                 </Tab>
  3345.  
  3346.                 <Tab hint={translate('CustomerHistory')} icon="fas fa-clipboard-check">
  3347.                   <DataGrid
  3348.                     id="gridHistorico"
  3349.                     ref={this.dataGridHistoricoRef}
  3350.                     dataSource={vendas}
  3351.                     repaintChangesOnly={true}
  3352.                     keyExpr="venda_id"
  3353.                     allowColumnReordering={true}
  3354.                     allowColumnResizing={true}
  3355.                     showBorders={true}
  3356.                     onInitNewRow={null}
  3357.                     onEditingStart={null}
  3358.                     onToolbarPreparing={null}>
  3359.                       <Editing
  3360.                         mode="popup"
  3361.                         allowUpdating={false}
  3362.                         allowAdding={false}
  3363.                         allowDeleting={false}
  3364.                         useIcons={true}>
  3365.                           <Popup title={translate('CustomerHistory')} showTitle={true} width="50%" height={250} />
  3366.                           <Form labelLocation="top">
  3367.                             <Item itemType="group" colCount={2} colSpan={2}>
  3368.                               <FormPopup labelLocation="top" colCount={2} colSpan={2} formData={frmSimulate}>
  3369.                                 <SimpleItem dataField="categoria"
  3370.                                   visible={false}
  3371.                                   editorType="dxTextBox"
  3372.                                   editorOptions={{value: this.props.windows[0].categoria_id}}>
  3373.                                 </SimpleItem>
  3374.                                 <SimpleItem dataField="checkin"
  3375.                                   visible={false}
  3376.                                   editorType="dxTextBox"
  3377.                                   editorOptions={{value: frmChekin.checkin_em}}>
  3378.                                 </SimpleItem>
  3379.                                 <SimpleItem dataField="tabela_preco"
  3380.                                     editorType="dxLookup"
  3381.                                     editorOptions={{
  3382.                                     dataSource:tarifacoes,
  3383.                                     valueExpr:"tabela_preco_id",
  3384.                                     displayExpr:"descricao",
  3385.                                     searchEnabled:false,
  3386.                                     showClearButton: false,
  3387.                                     closeOnOutsideClick: true}}>
  3388.                                   <Label text={translate('PriceTable')}/>
  3389.                                   <RequiredRule/>
  3390.                                 </SimpleItem>
  3391.                               </FormPopup>
  3392.                             </Item>
  3393.                           </Form>
  3394.                       </Editing>
  3395.  
  3396.                       <Scrolling mode="infinite" />
  3397.                       <Paging enabled={true} pageSize={10} />
  3398.                       <Pager showPageSizeSelector={true} allowedPageSizes={[10, 20, 30, 40, 50, 100]} showInfo={true} />
  3399.                       <Sorting mode="multiple" />
  3400.  
  3401.                       <Column type="buttons">
  3402.                         <Button name="edit" />
  3403.                         <Button icon="fa-search" visible={true}
  3404.                                 onClick={(e) => {console.log('')}} />
  3405.                       </Column>
  3406.                      
  3407.                       <Column
  3408.                         dataField="venda_id"
  3409.                         caption={translate('Bill')}
  3410.                         cellRender={this.comanda_customizeText}
  3411.                         alignment="left"
  3412.                       />
  3413.                       <Column
  3414.                         dataField="checkin_em"
  3415.                         caption={translate('Inflow')}
  3416.                         cellRender={this.entrada_customizeText}
  3417.                       />
  3418.                       <Column
  3419.                         dataField="checkout_em"
  3420.                         caption={translate('Outflow')}
  3421.                         cellRender={this.saida_customizeText}
  3422.                       />
  3423.                       <Column
  3424.                         dataField="valor_hospedagem"
  3425.                         caption={translate('Lodging')}
  3426.                         cellRender={this.valorSuite_customizeText}
  3427.                       />
  3428.                       <Column
  3429.                         dataField="valor_consumos"
  3430.                         caption={translate('Consumptions')}
  3431.                         cellRender={this.valorConsumos_customizeText}
  3432.                       />
  3433.                       <Column
  3434.                         dataField="valor_liquido"
  3435.                         caption={translate('Subtotal')}
  3436.                         cellRender={this.valorLiquido_customizeText}
  3437.                       />
  3438.                       <Column
  3439.                         dataField="valor_bruto"
  3440.                         caption={translate('Total')}
  3441.                         cellRender={this.valorBruto_customizeText}
  3442.                       />
  3443.                     </DataGrid>
  3444.                 </Tab>
  3445.               </TabbedItem>
  3446.             </FormPopup>
  3447.           </ScrollView>
  3448.         </PopupForm>
  3449.       </React.Fragment>
  3450.     );
  3451.   }
  3452. }
  3453.  
  3454. export default connect(mapStateToProps, mapDispatchToProps)(WindowDialog);
Add Comment
Please, Sign In to add comment