function msg_dados_salvos( xdiv, msg, func ){ var r = trim(document.getElementById(xdiv).innerHTML); var resp = r.split('#'); //if( msg == undefined || msg == '' ) if( msg == '' ) msg = "Dados Salvos"; if( resp[0] == 'ok' ) { //dhtmlx.message({ text: "


", expire: 1000 }) msg_ok( msg ) if( func != '' ) eval( func ); }else{ mostra_avisos_erros( 'erro', r ) //msg_erro( r ) //dhtmlx.alert({ title:"ERRO", type:"alert-error", top:'10', text: r }); } } function box_msg_alerta( texto ){ dhtmlx.alert({ title:"ERRO", type:"alert-error", top:'10', text: texto }); } function box_msg_aviso( texto ){ dhtmlx.alert({ title:"AVISO", type:"alert-warning", top:'60', text: texto }); } function box_msg_dados_salvos_ant( xdiv, msg, func ){ var r = trim(document.getElementById(xdiv).innerHTML); var resp = r.split('#'); if( msg == '' ) msg = "Dados Salvos"; if( resp[0] == 'ok' ) { msg_ok( msg ) if( func != '' ) eval( func ); }else{ dhtmlx.alert({ title:"ERRO", type:"alert-error", top:'200', text: r }); } } function box_msg_dados_salvos( xdiv, msg, func ){ var r = trim(document.getElementById(xdiv).innerHTML); var resp = r.split('#'); if( msg == '' ) msg = "Dados Salvos"; if( resp[0] == 'ok' ) { msg_ok( msg ) if( func != '' ) eval( func ); }else{ box_mostra_erro( r ); //dhtmlx.alert({ title:"ERRO", type:"alert-error", top:'200', text: r }); } } function box_msg_salvar_dados( xdiv, msg, func ){ var r = trim(document.getElementById(xdiv).innerHTML); var resp = r.split('#'); if( msg == '' ) msg = "Dados Salvos"; if( resp[0] == 'ok' ) { box_msg_ok( 'DADOS SALVOS' ); //window.notificationService.notify({ // title: 'OK', // text: 'DADOS SALVOS', // type: 'success', // position: 'top-right', // autoClose: true, // duration: 1000, //}) if( func != '' ) eval( func ); }else{ box_msg_erro( r ); } } function box_msg_erro( txt ){ //document.getElementById('div_box_erros').style.display=''; //return; dhxWins = new dhtmlXWindows(); //dhxWins.attachViewportTo("winVP"); w1 = dhxWins.createWindow("w1", 20, 30, 720, 550); w1.button("minmax").disable(); w1.button("park").disable(); w1.setText( " ERRO: " ) w1.centerOnScreen(); w1.setModal(true); w1.attachHTMLString('
'+ '
   HOUVE UM ERRO:



'+ ''+txt+''+ '
'+ '
'); return; window.notificationService.notify({ title: 'Ocorreu um erro', text: txt, type: 'error', position: 'top-left', //autoClose: true, autoClose: false, duration: 0, //duration: 5000, showRemoveButton: true }) } function msg_alerta( titulo, txt ){ window.notificationService.notify({ title: " "+titulo, text: txt, type: 'warning', position: 'top-right', autoClose: false, duration: 1000, showRemoveButton: true }) } function box_msg_ok( txt ){ window.notificationService.notify({ title: 'OK', text: ''+txt+'', type: 'success', position: 'top-right', autoClose: true, duration: 1000, }) } function box_mostra_erro( txt ){ var nLeft = 0; var nTop = 2; var nWidth = window.innerWidth*50/100; var nHeight = window.innerHeight*60/100; var dhxWins = new dhtmlXWindows(); wnd_erro = dhxWins.createWindow( 'window_erro', nLeft, nTop, nWidth, nHeight ); wnd_erro.button('minmax').hide(); wnd_erro.button('park').hide(); wnd_erro.setText( 'ERRO' ); wnd_erro.centerOnScreen(); wnd_erro.setModal(true); //wnd_erro.attachHTMLString( '
'+ wnd_erro.attachHTMLString( '
ERRO
'+ '
'+txt+'
' ); } function trim(str) { return str.replace(/^\s+|\s+$/g,""); } function msg_ok( msg ){ if ( msg == '' ) msg = 'Salvo'; $(document).ready(function() { $.toast({ heading: '', text: '
'+msg+'
', icon: 'success', loader: false, hideAfter: 1000, position: 'top-right' }) }) } function mensagem_dados_salvos( xdiv, msg, func ){ var r = trim(document.getElementById(xdiv).innerHTML); var resp = r.split('#'); if( msg == '' ) msg = "Dados Salvos"; if( resp[0] == 'ok' ) { msg_ok( msg ) if( func != '' ) eval( func ); }else{ dhtmlx.alert({ title:"ERRO", type:"alert-error", top:'10', text: r }); } } function msg_erro( txt ){ txt = txt.replace("ok#", ""); //dhtmlx.alert({ title:"ERRO", type:"alert-error", top:'10', text: txt }); $(document).ready(function() { $.toast({ heading: 'ERRO', text: txt, showHideTransition: 'fade', icon: 'error', position: 'mid-center', loader: false, hideAfter: false, allowToastClose: true }) }) } function msg_erro2( txt ){ txt = txt.replace("ok#", ""); dhtmlx.alert({ title:"ERRO", type:"alert-error", top:'10', text: txt }); //*$(document).ready(function() { // $.toast({ // heading: 'ERRO', // text: txt, // showHideTransition: 'fade', // icon: 'error', // position: 'mid-center', // loader: false, // hideAfter: false, // allowToastClose: true // }) //}) } function msg_aviso( txt ){ mostra_avisos_erros( 'aviso', txt ) //$(document).ready(function() { // $.toast({ // heading: 'AVISO', // text: txt, // showHideTransition: 'plain', // icon: 'warning', // loader: false, // hideAfter: 12000, // allowToastClose: true // }) //}) } function mensagem( div, msg, func, tipo ){ if( msg == undefined || msg == '' ) msg = "DADOS SALVOS"; if( div != '' ){ var r = trim(document.getElementById(div).innerHTML); var resp = r.split('#'); if( resp[0] == 'ok' || resp[0] == 'okok' ) { $.messager.show({ title:'Mensagem', msg: "
   "+msg+"", showType: 'fade', timeout:1000, style:{ left:'', right:0, top:document.body.scrollTop+document.documentElement.scrollTop, bottom:'', backgroundColor: '#000000', boxShadow: '1px 1px 3px #292929' } }); //$(this).tooltip('tip').css({ backgroundColor: '#fafafa', borderColor: '#fafafa', boxShadow: '1px 1px 3px #292929' }); if( func != '' ) eval( func ); }else{ $.messager.alert( 'ERROR','
' ,'error'); } }else{ if( tipo == 'ERRO' ) $.messager.alert( 'ERROR','
' ,'error'); } } function refresh_grid( cGrid ){ $('#'+cGrid).datagrid('reload'); } function refresh_jsgrid( xGrid ){ $( '#'+xGrid ).jsGrid("reset"); $( '#'+xGrid ).jsGrid("refresh"); $( '#'+xGrid ).jsGrid("loadData"); } function fechar_window( id, w ){ id.window( w ).close(); } function mask_( id, mask ){ if( mask == 'valor' ) VMasker( document.getElementById(id)).maskMoney({ precision: 2, separator: ',', delimiter: '.', unit: '', suffixUnit: '', zeroCents: false }); else if( mask == 'uf' ) VMasker( document.getElementById(id)).maskPattern('AA'); else if( mask == 'cep' ) VMasker( document.getElementById(id)).maskPattern('99999-999'); else if( mask == 'cod_nat_juridica' ) VMasker( document.getElementById(id)).maskPattern('999-9'); else if( mask == 'cpf' ) VMasker( document.getElementById(id)).maskPattern('999.999.999-99'); else if( mask == 'cnpj' ) VMasker( document.getElementById(id)).maskPattern('99.999.999/9999-99'); else if( mask == 'nire' ) VMasker( document.getElementById(id)).maskPattern('999.9999999-9'); else if( mask == 'data' ) VMasker( document.getElementById(id)).maskPattern('99/99/9999'); else if( mask == 'mes_referencia' ) VMasker( document.getElementById(id)).maskPattern('99/9999'); else if( mask == 'nat_jur' ) VMasker( document.getElementById(id)).maskPattern('999-9'); else if( mask == 'cnae' ) VMasker( document.getElementById(id)).maskPattern('99.99.9/99'); else if( mask == 'ddd' ) VMasker( document.getElementById(id)).maskPattern('99'); else if( mask == 'telefone' ) VMasker( document.getElementById(id)).maskPattern('9999-9999'); } function get_selected_ids_table( tb ){ var tabela = document.getElementById( tb ); var rows = tabela.getElementsByTagName("tr"); var cells = tabela.getElementsByTagName("td"); var ret_selects_id = ''; var id_; for( j=0; j < rows.length; j++){ id_ = rows[j].cells[0].id; if( id_ != '' ){ if( document.getElementById( tb+"_"+id_).checked ) ret_selects_id += id_+","; } } return ret_selects_id; } function get_selected_ids_table2( tb ){ var tabela = document.getElementById( tb ); var rows = tabela.getElementsByTagName("tr"); var cells = tabela.getElementsByTagName("td"); var ret_selects_id = ''; var id_; for( j=0; j < rows.length; j++){ id_ = rows[j].cells[0].id; if( id_ != '' ){ //if( document.getElementById( tb+"_"+id_).checked ) if( $('#'+tb+"_"+id_).checkbox('options').checked ) ret_selects_id += id_+","; } } return ret_selects_id; } function atualiza_combobox( cbx, val ){ var combo = document.getElementById( cbx ); for (var i = 0; i < combo.options.length; i++){ if ( trim(combo.options[i].value) == trim(val)){ combo.options[i].selected = "true"; break; }else{ combo.options[i].selected = "false"; } } } function getRadioValor( name ){ var rads = document.getElementsByName(name); for(var i = 0; i < rads.length; i++){ if(rads[i].checked){ return rads[i].id; } } return null; } function validar_cpf(strCPF) { var Soma; var Resto; Soma = 0; //if (strCPF == "00000000000") return false; for (i=1; i<=9; i++) Soma = Soma + parseInt(strCPF.substring(i-1, i)) * (11 - i); Resto = (Soma * 10) % 11; if ((Resto == 10) || (Resto == 11)) Resto = 0; if (Resto != parseInt(strCPF.substring(9, 10)) ) return false; Soma = 0; for (i = 1; i <= 10; i++) Soma = Soma + parseInt(strCPF.substring(i-1, i)) * (12 - i); Resto = (Soma * 10) % 11; if ((Resto == 10) || (Resto == 11)) Resto = 0; if (Resto != parseInt(strCPF.substring(10, 11) ) ) return false; return true; } function pesquisar_cep( valor, aCampos, func_callback ) { //Nova variável "cep" somente com dígitos. var cep = valor.replace(/\D/g, ''); //Verifica se campo cep possui valor informado. if (cep != "") { var validacep = /^[0-9]{8}$/; if(validacep.test(cep)) { for( j=0; j < aCampos.length; j++){ document.getElementById( aCampos[j] ).value = "..."; } //Cria um elemento javascript. var script = document.createElement('script'); //Sincroniza com o callback. script.src = 'https://viacep.com.br/ws/'+ cep + '/json/?callback='+func_callback; document.body.appendChild(script); } else { //cep é inválido. //limpa_formulario_cep( aCampos ); for( j=0; j < aCampos.length; j++){ document.getElementById( aCampos[j] ).value = ""; } alert("Formato de CEP inválido."); } } else { for( j=0; j < aCampos.length; j++){ document.getElementById( aCampos[j] ).value = ""; } //limpa_formulario_cep(); } }; function msg_confirma( titulo, msg, func ){ $.messager.confirm( titulo, msg, function(r){ if(r){ eval(func) } }); } function box_msg_confirma( titulo, msg, func ){ dhtmlx.confirm({ title: titulo, ok: "Sim", cancel:"Não", text: msg, callback:function( result ){ if( result ) eval(func) } }); } function btn_tooltip( id, texto, cor_fundo, cor_borda, cor_shadow, cor_texto, position ){ $( '#'+id ).tooltip({ position: 'bottom', content: '
'+texto+'
', onShow: function(){ $(this).tooltip('tip').css({ backgroundColor: cor_fundo, borderColor: cor_borda, boxShadow: '1px 1px 3px #292929' }); }, onPosition: function(){ $(this).tooltip('tip').css('left', $(this).offset().left); $(this).tooltip('arrow').css('left', 20); } }); } function box_tooltip( id, background, cor_borda, cor_borda2, width, header, href ){ $(function(){ $('#'+id).tooltip({ content: $('
'), showEvent: 'click', onUpdate: function(content){ content.panel({ width: width, border: false, title: header, href: href }); }, onShow: function(){ var t = $(this); t.tooltip('tip').unbind().bind('mouseenter', function(){ t.tooltip('show'); }).bind('mouseleave', function(){ t.tooltip('hide'); }); $(this).tooltip('tip').css({ backgroundColor: cor_borda2, borderColor: cor_borda, boxShadow: '1px 1px 3px #292929' }); } }); }); } function get_logradouro( s ){ var logr = ""; var end1; var end2; end1 = s; end2 = end1.split(' '); for( j=1; j < end2.length; j++){ logr += end2[ j ]+' '; } var logradouro = [ end2[0], logr ]; return logradouro; } function login_docbox(){ var ajax_login_docbox = new sack(); ajax_login_docbox.setVar( "login", document.getElementById('login').value ); ajax_login_docbox.setVar( "senha", document.getElementById('senha').value ); ajax_login_docbox.requestFile = "./login/check_login.php"; ajax_login_docbox.element = 'retorno-ajax'; ajax_login_docbox.onCompletion = function(){ check_login() }; //ajax_login_docbox.onCompletion = eval(ajax_login_docbox.response); ajax_login_docbox.runAJAX(); } function login_docbox2(){ var ajax_login_docbox = new sack(); ajax_login_docbox.setVar( "login", document.getElementById('login').value ); ajax_login_docbox.setVar( "senha", document.getElementById('senha').value ); ajax_login_docbox.requestFile = "./login/check_login.php"; ajax_login_docbox.element = 'retorno-ajax'; ajax_login_docbox.onCompletion = function(){ check_login2() }; //ajax_login_docbox.onCompletion = eval(ajax_login_docbox.response); ajax_login_docbox.runAJAX(); } function login_docbox3(){ var ajax_login_docbox = new sack(); ajax_login_docbox.setVar( "login", document.getElementById('login').value ); ajax_login_docbox.setVar( "senha", document.getElementById('senha').value ); ajax_login_docbox.requestFile = "./login/check_login.php"; ajax_login_docbox.element = 'retorno-ajax'; ajax_login_docbox.onCompletion = function(){ check_login3() }; //ajax_login_docbox.onCompletion = eval(ajax_login_docbox.response); ajax_login_docbox.runAJAX(); } function login_central_app_ANT(){ var ajax_login_docbox = new sack(); ajax_login_docbox.setVar( "login", document.getElementById('login').value ); ajax_login_docbox.setVar( "senha", document.getElementById('senha').value ); ajax_login_docbox.requestFile = "./login/check_login.php"; ajax_login_docbox.element = 'retorno-ajax'; ajax_login_docbox.onCompletion = function(){ check_login_central() }; //ajax_login_docbox.onCompletion = eval(ajax_login_docbox.response); ajax_login_docbox.runAJAX(); } function login_central_app(){ var ajax_login_docbox = new sack(); ajax_login_docbox.setVar( "login", document.getElementById('login').value ); ajax_login_docbox.setVar( "senha", document.getElementById('password').value ); ajax_login_docbox.requestFile = "./login/check_login.php"; ajax_login_docbox.element = 'retorno-ajax'; ajax_login_docbox.onCompletion = function(){ check_login_central() }; //ajax_login_docbox.onCompletion = eval(ajax_login_docbox.response); ajax_login_docbox.runAJAX(); } function check_login_central(){ var r = document.getElementById('retorno-ajax').innerHTML; var rr = r.substr(0,8); if( r == 'ok'){ //window.location='../kolizeo3/index_ANT.php'; window.location='./aplicativos.php'; }else if ( rr == 'Desculpe' ) { document.getElementById('erro_login').innerHTML = r; }else if ( r.substr(0,9) == 'cancelado' ) { document.getElementById('erro_login').innerHTML = 'Seu acesso está com restrição ou cancelado'; }else{ document.getElementById('erro_login').innerHTML = 'Dados incorretos !' } } function check_login(){ var r = document.getElementById('retorno-ajax').innerHTML; var rr = r.substr(0,8); if( r == 'ok'){ //window.location='../kolizeo3/index_ANT.php'; //window.location='index_ANT.php'; window.location='./doc-box/index.php'; }else if ( rr == 'Desculpe' ) { document.getElementById('erro_login').innerHTML = r; }else{ document.getElementById('erro_login').innerHTML = 'Dados incorretos !' } } function check_login2(){ var r = document.getElementById('retorno-ajax').innerHTML; var rr = r.substr(0,8); if( r == 'ok'){ window.location='index.php'; }else if ( rr == 'Desculpe' ) { document.getElementById('erro_login').innerHTML = r; }else{ document.getElementById('erro_login').innerHTML = 'Dados incorretos !' } } function check_login3(){ var r = document.getElementById('retorno-ajax').innerHTML; var rr = r.substr(0,8); if( r == 'ok'){ window.location='novo_index.php'; }else if ( rr == 'Desculpe' ) { document.getElementById('erro_login').innerHTML = r; }else{ document.getElementById('erro_login').innerHTML = 'Dados incorretos !' } } function mostra_avisos_erros( tipo, msg ){ var titulo_ = '' if( tipo == 'erro' ) titulo_ = 'ERRO' else titulo_ = 'AVISO' $('#DLG_BOX_AVISOS_ERROS').dialog({ title: titulo_, closed: false, cache: false, method: 'POST', modal: true, cls: 'box_main', border: 'thin', left:1, top:330, queryParams: { tipo:tipo, msg:msg }, href: './msg_avisos_erros.php' }); } function xdownload(filename, text) { var text_out; var element = document.createElement('a'); //resultado = exemplo.replace("JavaScript", "PHP"); //text_out = text.replace( "&", "&" ); //element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text_out)); element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text)); element.setAttribute('download', filename); element.style.display = 'none'; document.body.appendChild(element); element.click(); document.body.removeChild(element); } function box_selecionar_empresas( func, id_usuario ){ //dhxWins = new dhtmlXWindows(); //w1 = dhxWins.createWindow("w1", 20, 30, 720, 550); //w1.button("minmax").hide(); //w1.button("park").hide(); //w1.setText( " SELECIONAR EMPRESA / CLIENTE:" ) //w1.centerOnScreen(); //w1.setModal(true); var nLeft = 0; //window.innerWidth * 55/100; var nTop = 0; var nWidth = window.innerWidth * 80/100; var nHeight = window.innerHeight* 90/100; var dhxWins = new dhtmlXWindows(); wnd_sel_cliente = dhxWins.createWindow( 'w_sel_cliente', nLeft, nTop, nWidth, nHeight ); wnd_sel_cliente.button('minmax').hide(); wnd_sel_cliente.button('park').hide(); wnd_sel_cliente.setText( 'SELECIONAR EMPRESA / CLIENTE:' ); wnd_sel_cliente.centerOnScreen(); wnd_sel_cliente.setModal(true); wnd_sel_cliente.attachURL("../select_clientes/select_clientes.php", true, { funcao:func, id_usuario:id_usuario } ); } function msg_save_ok( obj, msg, func ){ var r = document.getElementById(obj).innerHTML; var resp = r.split('#'); var options = { showTop: true, timeout: 1000 } if( msg == "" ) msg = "
 DADOS SALVOS

"; else msg = "
 "+msg+"

"; if( resp[0] == 'ok' ){ if( func != '' ){ Metro.createToast( msg, func, null, "success", options ); }else{ Metro.createToast( msg, null, null, "success", options ); } }else{ var html_content = '

ERRO:

' + '

Houve um erro ao salvar os dados:
'+r+'.

'; Metro.infobox.create(html_content, 'alert'); } }