123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927 |
- <%
- /**** Pagina de login do site ****/
- Local cLCodLogin := ""
- if type ("cCodLogin") <> "U"
- cLCodLogin := cCodLogin
- Endif
- %>
- <!DOCTYPE html>
- <html class="fixed sidebar-left-collapsed">
- <head>
- <!-- Basic -->
- <meta charset="iso-8859-1">
- <link rel="shortcut icon" href="images/favicon.png" type="image/x-icon" />
-
- <title><%=cTitle%></title>
-
- <meta name="keywords" content="<%=cTitle%>" />
- <meta name="description" content="<%=cTitle%>">
- <meta name="author" content="SMSTI">
-
- <!-- Mobile Metas -->
- <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
-
- <!-- Web Fonts -->
- <link href="https://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700,800|Shadows+Into+Light" rel="stylesheet" type="text/css">
-
- <!-- Vendor CSS -->
- <link rel="stylesheet" href="assets/vendor/bootstrap/css/bootstrap.css" />
- <link rel="stylesheet" href="assets/vendor/font-awesome/css/font-awesome.css" />
- <link rel="stylesheet" href="assets/vendor/magnific-popup/magnific-popup.css" />
- <link rel="stylesheet" href="assets/vendor/bootstrap-datepicker/css/bootstrap-datepicker3.css" />
-
- <!-- Specific Page Vendor CSS -->
- <link rel="stylesheet" href="assets/vendor/select2/css/select2.css" />
- <link rel="stylesheet" href="assets/vendor/select2-bootstrap-theme/select2-bootstrap.min.css" />
- <link rel="stylesheet" href="assets/vendor/jquery-datatables-bs3/assets/css/datatables.css" />
- <link rel="stylesheet" href="assets/vendor/bootstrap-fileupload/bootstrap-fileupload.min.css" />
- <link rel="stylesheet" href="assets/vendor/pnotify/pnotify.custom.css" />
-
- <!-- Theme CSS -->
- <link rel="stylesheet" href="assets/stylesheets/theme.css" />
-
- <!-- Skin CSS -->
- <link rel="stylesheet" href="assets/stylesheets/skins/default.css" />
-
- <!-- Theme Custom CSS -->
- <link rel="stylesheet" href="assets/stylesheets/theme-custom.css">
-
- <!-- Head Libs -->
- <script src="assets/vendor/modernizr/modernizr.js"></script>
- <script src="assets/vendor/style-switcher/style.switcher.localstorage.js"></script>
- </head>
- <body>
- <section class="body">
-
- <!-- start: header -->
- <header class="header">
- <%=cHeader%>
- </header>
- <!-- end: header -->
-
- <div class="inner-wrapper">
- <!-- start: sidebar -->
- <aside id="sidebar-left" class="sidebar-left">
-
- <div class="sidebar-header">
- <div class="sidebar-title">
- Menu
- </div>
- <div class="sidebar-toggle hidden-xs" data-toggle-class="sidebar-left-collapsed" data-target="html" data-fire-event="sidebar-left-toggle">
- <i class="fa fa-bars" aria-label="Toggle sidebar"></i>
- </div>
- </div>
-
- <div class="nano">
- <div class="nano-content">
- <nav id="menu" class="nav-main" role="navigation">
-
- <ul class="nav nav-main">
- <%=cMenus%>
- </ul>
- </nav>
- </div>
-
- <script>
- // Maintain Scroll Position
- if (typeof localStorage !== 'undefined') {
- if (localStorage.getItem('sidebar-left-position') !== null) {
- var initialPosition = localStorage.getItem('sidebar-left-position'),
- sidebarLeft = document.querySelector('#sidebar-left .nano-content');
-
- sidebarLeft.scrollTop = initialPosition;
- }
- }
- </script>
- </div>
-
- </aside>
- <!-- end: sidebar -->
-
- <section role="main" class="content-body">
- <header class="page-header">
- <h2><%=cPagina%></h2>
-
- <div class="right-wrapper pull-right">
- </div>
- </header>
-
- <!-- start: page -->
- <section class="panel">
- <!-- <header class="panel-heading">
- </header> -->
- <div class="panel-body">
- <div class="row">
- <div class="col-lg-12">
- <section class="panel form-wizard" id="w9">
- <form action = "" method="post" class="form-horizontal" id="formCliente">
- <div class="tabs">
- <ul class="nav nav-tabs nav-justify">
- <li class="active">
- <a href="#cli-cadastro" data-toggle="tab" class="text-center">Cadastro</a>
- </li>
- <!--
- <li class="">
- <a href="#susp-contato" data-toggle="tab" class="text-center">Cliente</a>
- </li>
- -->
- </ul>
-
- <div class="tab-content">
- <div id="cli-cadastro" class="tab-pane active">
-
- <!-- linha 1: dados da empresa -->
- <div class="row form-group">
- <div class="col-lg-4">
- <label class="control-label">Tipo</label>
- <%=cTipo%>
- </div>
- <div class="col-lg-4">
- <label class="control-label">CPF/CNPJ</label>
- <input type="text" id="A1_CGC" name="A1_CGC" onchange="javascript:vldCGC();" placeholder="CPF/CNPJ" maxlength="18" class="form-control" value="" disabled>
- </div>
- <div class="col-lg-4">
- <label class="control-label">Inscrição Estadual</label>
- <input type="text" id="A1_INSCR" name="A1_INSCR" placeholder="Inscrição Estadual" maxlength="18" class="form-control only-numbers" value="" disabled>
- </div>
- </div>
-
- <div class="mb-md hidden-lg hidden-xl"></div>
- <div class="mb-md hidden-lg hidden-xl"></div>
-
- <!-- linha 2: Nome -->
- <div class="row form-group">
- <div class="col-lg-6">
- <label class="control-label">Razão Social</label>
- <input type="text" id="A1_NOME" name="A1_NOME" placeholder="Razão Social" class="form-control" style="text-transform:uppercase" value="" maxlength="60" required disabled>
- </div>
- <div class="col-lg-4">
- <label class="control-label">Nome Fantasia</label>
- <input type="text" id="A1_NREDUZ" name="A1_NREDUZ" placeholder="Nome Fantasia" class="form-control" style="text-transform:uppercase" value="" maxlength="40" required disabled>
- </div>
- </div>
-
- <div class="mb-md hidden-lg hidden-xl"></div>
- <div class="mb-md hidden-lg hidden-xl"></div>
-
- <!-- linha 3: Estado -->
- <div class="row form-group">
- <div class="col-lg-2">
- <label class="control-label">CEP</label>
- <input type="text" id="A1_CEP" name="A1_CEP" placeholder="99999-999" class="form-control" value="" maxlength="9" required disabled onchange="javascript:buscaCEP()">
- </div>
- <div class="col-lg-2">
- <label class="control-label">Estado</label>
- <%=cEstado%>
- </div>
- <div class="col-lg-6">
- <label class="control-label">Cidade</label>
-
- <select data-plugin-selectTwo class="form-control populate mb-md" name="A1_COD_MUN" id="A1_COD_MUN" required="" aria-required="true" onchange="javascript:vldMun()" disabled>
- <option value=""></option>
- </select>
- </div>
-
- </div>
-
- <!-- linha 4: Endereço -->
- <div class="row form-group">
- <div class="col-lg-6">
- <label class="control-label">Endereço</label>
- <input type="text" id="A1_END" name="A1_END" placeholder="Endereço" class="form-control" style="text-transform:uppercase" value="" maxlength="40" required disabled>
- </div>
- <div class="col-lg-3">
- <label class="control-label">Número</label>
- <input type="text" id="A1_NR_END" name="A1_NR_END" placeholder="Número" class="form-control only-numbers" style="text-transform:uppercase" value="" maxlength="6" disabled>
- </div>
- </div>
- <!-- linha 5: Complemento -->
- <div class="row form-group">
- <div class="col-lg-6">
- <label class="control-label">Complemento</label>
- <input type="text" id="A1_COMPLEM" name="A1_COMPLEM" placeholder="Complemento" class="form-control" style="text-transform:uppercase" value="" maxlength="50" disabled>
- </div>
- <div class="col-lg-4">
- <label class="control-label">Bairro</label>
- <input type="text" id="A1_BAIRRO" name="A1_BAIRRO" placeholder="Bairro" class="form-control" style="text-transform:uppercase" value="" maxlength="30" required disabled>
- </div>
- </div>
-
- <div class="mb-md hidden-lg hidden-xl"></div>
- <div class="mb-md hidden-lg hidden-xl"></div>
- <!-- linha 5: Contato -->
- <div class="row form-group">
-
- <div class="col-lg-4">
- <label class="control-label">Telefone 1</label>
- <input type="text" id="A1_TEL" name="A1_TEL" placeholder="Informe o telefone com DDD" maxlength="15" class="form-control" value="" required disabled>
- </div>
- <div class="col-lg-4">
- <label class="control-label">Telefone 2</label>
- <input type="text" id="A1_TELEX" name="A1_TELEX" placeholder="Informe o telefone com DDD" maxlength="15" class="form-control" value="" disabled>
- </div>
-
- </div>
-
- <!-- linha 6: Email -->
- <div class="row form-group">
- <div class="col-lg-6">
- <label class="control-label">E-mail</label>
- <input type="email" id="A1_EMAIL" name="A1_EMAIL" placeholder="E-mail" class="form-control" value="" maxlength="60" disabled>
- </div>
- <div class="col-lg-4">
- <label class="control-label">Contato</label>
- <input type="contato" id="A1_CONTATO" name="A1_CONTATO" placeholder="Contato" class="form-control" value="" maxlength="15" disabled>
- </div>
- </div>
-
- <div class="mb-md hidden-lg hidden-xl"></div>
- <div class="mb-md hidden-lg hidden-xl"></div>
-
- <br>
- <br>
-
- <div class="row form-group" align="center">
- <%=cBotoes%>
- </div>
- </div>
- </div>
- </div>
- </form>
- </section>
- </div>
- </div>
- </div>
- </section>
-
- <footer class="panel-footer text-right">
- Desenvolvido por <img src="images/sms.png" />
- </footer>
- </div>
- </section>
- <!-- end: page -->
-
- <!-- Vendor -->
- <script src="assets/vendor/jquery/jquery.js"></script>
- <script src="assets/vendor/jquery-browser-mobile/jquery.browser.mobile.js"></script>
- <script src="assets/vendor/bootstrap/js/bootstrap.js"></script>
- <script src="assets/vendor/nanoscroller/nanoscroller.js"></script>
- <script src="assets/vendor/bootstrap-datepicker/js/bootstrap-datepicker.js"></script>
- <script src="assets/vendor/bootstrap-datepicker/locales/bootstrap-datepicker.pt-BR.min.js"></script>
- <script src="assets/vendor/magnific-popup/jquery.magnific-popup.js"></script>
- <script src="assets/vendor/jquery-placeholder/jquery-placeholder.js"></script>
-
- <!-- Custom -->
- <script src="custom/js/bootbox.js"></script>
-
- <!-- Specific Page Vendor -->
- <script src="assets/vendor/select2/js/select2.js"></script>
- <script src="assets/vendor/jquery-datatables/media/js/jquery.dataTables.js"></script>
- <script src="assets/vendor/jquery-datatables/extras/TableTools/js/dataTables.tableTools.min.js"></script>
- <script src="assets/vendor/jquery-datatables-bs3/assets/js/datatables.js"></script>
- <script src="assets/vendor/jquery-datatables/media/js/jquery.dataTables.js"></script>
- <script src="assets/vendor/bootstrap-maxlength/bootstrap-maxlength.js"></script>
- <script src="assets/vendor/autosize/autosize.js"></script>
- <script src="assets/vendor/bootstrap-fileupload/bootstrap-fileupload.min.js"></script>
- <script src="assets/vendor/pnotify/pnotify.custom.js"></script>
- <script src="assets/vendor/bootstrap-select/bootstrap-select.min.js"></script>
- <!-- Theme Base, Components and Settings -->
- <script src="assets/javascripts/theme.js"></script>
-
- <!-- Theme Initialization Files -->
- <script src="assets/javascripts/theme.init.js"></script>
-
-
- <!-- Theme Custom -->
- <script src="assets/javascripts/theme.custom.js"></script>
- <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js" type="text/javascript"></script>
- <script src="custom/js/jquery.maskMoney.js"></script>
- <script src="custom/js/portalMask.js"></script>
-
- <script type="text/javascript">
- var optModal = '<%=cOptMun%>';
- function mascara(o,f){
- v_obj=o
- v_fun=f
- setTimeout("execmascara()",1)
- }
- function execmascara(){
- v_obj.value=v_fun(v_obj.value)
- }
- function id( el ){
- return document.getElementById( el );
- }
- function mtel(v){
- v=v.replace(/\D/g,""); //Remove tudo o que não é dígito
- v=v.replace(/^(\d{2})(\d)/g,"($1) $2"); //Coloca parênteses em volta dos dois primeiros dígitos
- v=v.replace(/(\d)(\d{4})$/,"$1-$2"); //Coloca hífen entre o quarto e o quinto dígitos
- return v;
- }
- function mcep(v){
- v=v.replace(/\D/g,""); //Remove tudo o que não é dígito
- v=v.replace(/(\d)(\d{3})$/,"$1-$2"); //Coloca hífen entre o quarto e o quinto dígitos
- return v;
- }
- function mnum(v){
- v=v.replace(/\D/g,""); //Remove tudo o que não é dígito
- return v;
- }
- function mcpfcnpj(v){
- v=v.replace(/\D/g,"") //Remove tudo o que não é dígito
- if (v.length > 11) {
- v=v.replace(/^(\d{2})(\d)/,"$1.$2") //Coloca ponto entre o segundo e o terceiro dígitos
- v=v.replace(/^(\d{2})\.(\d{3})(\d)/,"$1.$2.$3") //Coloca ponto entre o quinto e o sexto dígitos
- v=v.replace(/\.(\d{3})(\d)/,".$1/$2") //Coloca uma barra entre o oitavo e o nono dígitos
- v=v.replace(/(\d{4})(\d)/,"$1-$2") //Coloca um hífen depois do bloco de quatro dígitos
- } else {
- v=v.replace(/(\d{3})(\d)/,"$1.$2") //Coloca um ponto entre o terceiro e o quarto dígitos
- v=v.replace(/(\d{3})(\d)/,"$1.$2") //Coloca um ponto entre o terceiro e o quarto dígitos
- //de novo (para o segundo bloco de números)
- v=v.replace(/(\d{3})(\d{1,2})$/,"$1-$2") //Coloca um hífen entre o terceiro e o quarto dígitos
- }
- return v
- }
-
- window.onload = function(){
- id('A1_TEL').onkeyup = function(){
- mascara( this, mtel );
- }
- id('A1_TELEX').onkeyup = function(){
- mascara( this, mtel );
- }
- id('A1_CGC').onkeyup = function(){
- mascara( this, mcpfcnpj );
- }
- id('A1_CEP').onkeyup = function(){
- mascara( this, mcep );
- }
- id('A1_NR_END').onkeyup = function(){
- mascara( this, mnum );
- }
- id('A1_INSCR').onkeyup = function(){
- mascara( this, mnum );
- }
- }
- /**
- Valida o preenchimento do campo
- **/
- function vldTipo(){
- if ($("#A1_TIPO") !=""){
- $("#A1_CGC").removeAttr('disabled');
- } else {
- $("#A1_CGC").attr("disabled","");
- }
- }
- /**
- Verifica se o CPF/CNPJ existe
- **/
- function vldCGC(){
- var cCgc = $("#A1_CGC").val();
- var tipo = $("#A1_TIPO").val();
- var dialogTab = bootbox.dialog({
- message: '<p class="text-center"><i class="fa fa-spin fa-spinner"></i> Verificando o CPF/CNPJ... Aguarde...</p>',
- closeButton: false
- });
- $.ajax({
- url: "U_fVldCGC.apw?PR=<%=cLCodLogin%>",
- data: 'cgc='+cCgc+'&tipo='+tipo,
- type: "POST",
- async: false,
- success:
- function(retorno) {
- if (retorno.indexOf('<META HTTP-EQUIV') >= 0 ) {
- $("html").html(retorno);
- return;
- }
-
- if ( retorno != "" && retorno.indexOf("Expires") == -1 ) {
- bootbox.alert('CPF/CNPJ já cadastrado no cliente código '+retorno+'.');
- }
- else {
- //Bloqueia o campo CGC para edição
- //$("#A1_CGC").attr("disabled","");
- //Libera os demais campos
- $("#A1_INSCR").removeAttr('disabled');
- $("#A1_CONTRIB").removeAttr('disabled');
- $("#A1_XCLASS").removeAttr('disabled');
- $("#A1_GRPCLI").removeAttr('disabled');
- $("#A1_GRPTRIB").removeAttr('disabled');
- $("#A1_NOME").removeAttr('disabled');
- $("#A1_NREDUZ").removeAttr('disabled');
- $("#A1_CEP").removeAttr('disabled');
- }
- }
- });
- dialogTab.modal('hide');
- }
- /**
- Busca o endereço com o CEP
- **/
- function buscaCEP(){
- var cep = $("#A1_CEP").val();
- var dialogTab = bootbox.dialog({
- message: '<p class="text-center"><i class="fa fa-spin fa-spinner"></i> Localizando o endereço... Aguarde...</p>',
- closeButton: false
- });
- $.ajax({
- url: "U_fCEPEnd.apw?PR=<%=cLCodLogin%>",
- data: 'cep='+cep,
- type: "POST",
- async: false,
- success:
- function(retorno) {
- if (retorno.indexOf('<META HTTP-EQUIV') >= 0 ) {
- $("html").html(retorno);
- return;
- }
-
- if ( retorno == "" && retorno.indexOf("Expires") == -1 ) {
- bootbox.alert('Falha ao localizar CEP.');
- }
- else {
- aCEP = retorno.substr(2).split('#');
- //falha na busca
- if (retorno.substr(0, 1) == "F") {
- bootbox.alert(aCEP[0]);
- } else {
- //estado
- var select = document.getElementById('A1_EST');
- $("#A1_EST").val(aCEP[0]);
- $("#A1_EST").removeAttr('disabled');
- $("#A1_EST").change();//executar onchange
- text = select.options[select.selectedIndex].text;
- $("#select2-A1_EST-container").text(text);
- //cidade
- var codmun = document.getElementById('A1_COD_MUN');
- $("#A1_COD_MUN").val(aCEP[1]);
- $("#A1_COD_MUN").removeAttr('disabled');
- $("#A1_COD_MUN").change();
- text = codmun.options[codmun.selectedIndex].text;
- $("#select2-A1_COD_MUN-container").text(text);
- //endereço
- $("#A1_END").val(aCEP[2]);
- $("#A1_END").removeAttr('disabled');
- $("#A1_NR_END").removeAttr('disabled');
- //bairro
- $("#A1_BAIRRO").val(aCEP[3]);
- $("#A1_BAIRRO").removeAttr('disabled');
- }
-
-
- }
- }
- });
- dialogTab.modal('hide');
- }
- /**
- Busca as cidades de acordo com o estado
- **/
- function SetCidade(){
- var estado = $("#A1_EST").val();
- var dialogTab = bootbox.dialog({
- message: '<p class="text-center"><i class="fa fa-spin fa-spinner"></i> Localizando os municípios... Aguarde...</p>',
- closeButton: false
- });
- $.ajax({
- url: "U_fSetCidade.apw?PR=<%=cLCodLogin%>",
- data: 'estado='+estado,
- type: "POST",
- async: false,
- success:
- function(retorno) {
- if (retorno.indexOf('<META HTTP-EQUIV') >= 0 ) {
- $("html").html(retorno);
- return;
- }
-
- if ( retorno == "" && retorno.indexOf("Expires") == -1 ) {
- bootbox.alert('Falha ao localizar os municípios do estado '+estado+'.');
- }
- else {
-
- //Preenche o select das cidades
- document.getElementById('A1_COD_MUN').innerText = null;
- $("#A1_COD_MUN").append(retorno);
- optMun = retorno;
-
- $("#A1_COD_MUN").removeAttr('disabled');
- }
- }
- });
- dialogTab.modal('hide');
- }
- /**
- Valida o preenchimento do campo município
- **/
- function vldMun(){
- if ($("#A1_COD_MUN") !=""){
- $("#A1_CEP").removeAttr('disabled');
- $("#A1_END").removeAttr('disabled');
- $("#A1_NR_END").removeAttr('disabled');
- $("#A1_COMPLEM").removeAttr('disabled');
- $("#A1_BAIRRO").removeAttr('disabled');
- $("#A1_TEL").removeAttr('disabled');
- $("#A1_TELEX").removeAttr('disabled');
- $("#A1_EMAIL").removeAttr('disabled');
- $("#A1_CONTATO").removeAttr('disabled');
- }
- }
- /**
- Validação dos campos obrigatorios para salvar
- **/
- $('#btSalvar').click(function() {
- var lRet = true;
- var btnSlv = $(this);
-
- //Desabilita o botão
- btnSlv.attr({ 'disabled': 'disabled' });
-
- $.ajax({
- url: "U_VerSessao.apw?PR=<%=cLCodLogin%>",
- type: "POST",
- async: false,
- success:
- function(retorno) {
- if (retorno.indexOf('<META HTTP-EQUIV') >= 0 ) {
- $("html").html(retorno);
- return;
- }
- if (retorno == "nok"||retorno == ''||retorno.indexOf("Expires") != -1){
- $("#cli-cadastro").html();
- bootbox.alert('Não foi possível realizar a operação pois a sessão foi fechada. Faça login novamente.');
- lRet = false;
- btnSlv.removeAttr('disabled');
- }
- }
- });
- //Valida os campos obrigatorios
-
- //CNPJ
- if ($("#A1_CGC").val() == "") {
- lRet = false;
-
- $("#cli-cadastro").html();
- new PNotify({
- title: 'Campo obrigatório',
- text: 'Preencha o campo CPF/CNPJ!',
- type: 'error',
- });
- btnSlv.removeAttr('disabled');
- $("#A1_CGC").focus();
- }
- //Contribuinte
- if ($("#A1_CONTRIB").val() == "") {
- lRet = false;
-
- $("#cli-cadastro").html();
- new PNotify({
- title: 'Campo obrigatório',
- text: 'Preencha o campo Contribuinte!',
- type: 'error',
- });
- btnSlv.removeAttr('disabled');
- $("#A1_CONTRIB").focus();
- }
- //Grupo cliente
- if ($("#A1_GRPCLI").val() == "") {
- lRet = false;
-
- $("#cli-cadastro").html();
- new PNotify({
- title: 'Campo obrigatório',
- text: 'Preencha o campo Grupo!',
- type: 'error',
- });
- btnSlv.removeAttr('disabled');
- $("#A1_GRPCLI").focus();
- }
- //Classificação
- if ($("#A1_XCLASS").val() == "") {
- lRet = false;
-
- $("#cli-cadastro").html();
- new PNotify({
- title: 'Campo obrigatório',
- text: 'Preencha o campo Classificação!',
- type: 'error',
- });
- btnSlv.removeAttr('disabled');
- $("#A1_XCLASS").focus();
- }
- //Grupo tributação
- if ($("#A1_GRPTRIB").val() == "") {
- lRet = false;
-
- $("#cli-cadastro").html();
- new PNotify({
- title: 'Campo obrigatório',
- text: 'Preencha o campo Grupo de Cliente!',
- type: 'error',
- });
- btnSlv.removeAttr('disabled');
- $("#A1_GRPTRIB").focus();
- } else {
- //grupo consumidor final com IE
- if ($.trim($("#A1_GRPTRIB").val()) == "004" && $("#A1_INSCR").val() == "" ){
- lRet = false;
-
- $("#cli-cadastro").html();
- new PNotify({
- title: 'Campo obrigatório',
- text: 'Preencha o campo Inscrição Estadual!',
- type: 'error',
- });
- btnSlv.removeAttr('disabled');
- $("#A1_INSCR").focus();
- }
- }
- //Estado
- if ($("#A1_EST").val() == "") {
- lRet = false;
-
- $("#cli-cadastro").html();
- new PNotify({
- title: 'Campo obrigatório',
- text: 'Preencha o campo Estado!',
- type: 'error',
- });
- btnSlv.removeAttr('disabled');
- $("#A1_EST").focus();
- }
- //Município
- if ($("#A1_COD_MUN").val() == "") {
- lRet = false;
-
- $("#cli-cadastro").html();
- new PNotify({
- title: 'Campo obrigatório',
- text: 'Preencha o campo Cidade!',
- type: 'error',
- });
- btnSlv.removeAttr('disabled');
- $("#A1_COD_MUN").focus();
- }
- //Endereco
- if ($("#A1_END").val() == "") {
- lRet = false;
-
- $("#cli-cadastro").html();
- new PNotify({
- title: 'Campo obrigatório',
- text: 'Preencha o campo Endereço!',
- type: 'error',
- });
- btnSlv.removeAttr('disabled');
- $("#A1_END").focus();
- }
- //Número endereço
- if ($("#A1_NR_END").val() == "") {
- lRet = false;
-
- $("#cli-cadastro").html();
- new PNotify({
- title: 'Campo obrigatório',
- text: 'Preencha o campo Número!',
- type: 'error',
- });
- btnSlv.removeAttr('disabled');
- $("#A1_NR_END").focus();
- }
- //CEP
- if ($("#A1_CEP").val() == "") {
- lRet = false;
-
- $("#cli-cadastro").html();
- new PNotify({
- title: 'Campo obrigatório',
- text: 'Preencha o campo CEP!',
- type: 'error',
- });
- btnSlv.removeAttr('disabled');
- $("#A1_CEP").focus();
- }
- //Bairro
- if ($("#A1_BAIRRO").val() == "") {
- lRet = false;
-
- $("#cli-cadastro").html();
- new PNotify({
- title: 'Campo obrigatório',
- text: 'Preencha o campo Bairro!',
- type: 'error',
- });
- btnSlv.removeAttr('disabled');
- $("#A1_BAIRRO").focus();
- }
- //E-mail
- if ($("#A1_EMAIL").val() == "") {
- lRet = false;
-
- $("#cli-cadastro").html();
- new PNotify({
- title: 'Campo obrigatório',
- text: 'Preencha o campo E-mail!',
- type: 'error',
- });
- btnSlv.removeAttr('disabled');
- $("#A1_EMAIL").focus();
- } else {
- if ( $("#A1_EMAIL").val().includes('@') == false || $("#A1_EMAIL").val().includes('.') == false) {
- lRet = false;
-
- $("#cli-cadastro").html();
- new PNotify({
- title: 'Campo obrigatório',
- text: 'Informe um e-mail válido!',
- type: 'error',
- });
- btnSlv.removeAttr('disabled');
- $("#A1_EMAIL").focus();
- }
- }
- //Razão
- if ($("#A1_NOME").val() == "") {
- lRet = false;
-
- $("#cli-cadastro").html();
- new PNotify({
- title: 'Campo obrigatório',
- text: 'Preencha o campo Razão Social!',
- type: 'error',
- });
- btnSlv.removeAttr('disabled');
- $("#A1_NOME").focus();
- }
- //Nome fantasia
- if ($("#A1_NREDUZ").val() == "") {
- if ( $.trim($("#A1_GRPTRIB").val()) == '003' && $("#A1_NOME").val != ""){
- $("#A1_NREDUZ").val($("#A1_NOME").val());
- } else {
- lRet = false;
-
- $("#cli-cadastro").html();
- new PNotify({
- title: 'Campo obrigatório',
- text: 'Preencha o campo Nome Fantasia!',
- type: 'error',
- });
- btnSlv.removeAttr('disabled');
- $("#A1_NREDUZ").focus();
- }
- }
- //Telefone
- if ($("#A1_TEL").val() == "" && $("#A1_TELEX").val() == "" ) {
- lRet = false;
-
- $("#cli-cadastro").html();
- new PNotify({
- title: 'Campo obrigatório',
- text: 'Informe pelo menos um telefone!',
- type: 'error',
- });
- btnSlv.removeAttr('disabled');
- $("#A1_TEL").focus();
- }
-
- if (lRet == true){
- salvarCli(btnSlv);
- }
- });
- //Salva o cadastro
- function salvarCli(btnSlv){
- var titulo = "Cadastro de cliente";
- var dialogSlv = bootbox.dialog({
- message: '<p class="text-center"><i class="fa fa-spin fa-spinner"></i> Salvando o cliente... Aguarde...</p>',
- closeButton: false
- });
-
- //Atualiza as variáveis
- objDados = {
- A1_TIPO: $('#A1_TIPO').val(),
- A1_CGC: $('#A1_CGC').val(),
- A1_INSCR: $('#A1_INSCR').val(),
- A1_CONTRIB: $('#A1_CONTRIB').val(),
- A1_NOME: $('#A1_NOME').val().normalize("NFD").replace(/[\u0300-\u036f]/g, ''),
- A1_NREDUZ: $('#A1_NREDUZ').val().normalize("NFD").replace(/[\u0300-\u036f]/g, ''),
- A1_EST: $('#A1_EST').val(),
- A1_COD_MUN: $('#A1_COD_MUN').val(),
- A1_END: $('#A1_END').val().normalize("NFD").replace(/[\u0300-\u036f]/g, ''),
- A1_NR_END: $('#A1_NR_END').val(),
- A1_COMPLEM: $('#A1_COMPLEM').val().normalize("NFD").replace(/[\u0300-\u036f]/g, ''),
- A1_BAIRRO: $('#A1_BAIRRO').val().normalize("NFD").replace(/[\u0300-\u036f]/g, ''),
- A1_CEP: $('#A1_CEP').val(),
- A1_TEL: $('#A1_TEL').val(),
- A1_TELEX: $('#A1_TELEX').val(),
- A1_EMAIL: $('#A1_EMAIL').val().normalize("NFD").replace(/[\u0300-\u036f]/g, ''),
- A1_CONTATO: $('#A1_CONTATO').val(),
- A1_GRPCLI: $('#A1_GRPCLI').val(),
- A1_GRPTRIB: $('#A1_GRPTRIB').val(),
- A1_XCLASS: $('#A1_XCLASS').val(),
- };
- $.ajax({
- type: "POST",
- url: "U_SlvCliente.apw?PR=<%=cLCodLogin%>",
- async: false,
- data: objDados
-
- }).fail(function(){
- bootbox.alert({
- title: titulo,
- message: "Não foi possível salvar o cadastro do cliente.",
- backdrop: true,
- callback: function (result) {
- btnSlv.removeAttr('disabled');
- dialogSlv.modal('hide');
- }
- });
- }).done(function(strXml) {
- if (strXml.indexOf('<META HTTP-EQUIV') >= 0 ) {
- $("html").html(strXml);
- return;
- }
- if (strXml == 'erro'||strXml == ''||strXml.indexOf("Expires") != -1||strXml.indexOf("invalid") != -1){
- if (strXml == ''){
- bootbox.alert({
- title: titulo,
- message: "Aguarde o prazo de 3 minutos para incluir um novo cadastro.",
- backdrop: true,
- callback: function (result) {
- btnSlv.removeAttr('disabled');
- dialogSlv.modal('hide');
- }
- });
- }else{
- bootbox.alert({
- title: titulo,
- message: "Falha ao incluir o cadastro de cliente.",
- backdrop: true,
- callback: function (result) {
- btnSlv.removeAttr('disabled');
- dialogSlv.modal('hide');
- }
- });
- }
- }
- else {
-
- bootbox.alert({
- title: titulo,
- message: strXml,
- backdrop: true,
- callback: function (result) {
- document.location.href = "U_LimiteCredito.apw?PR=<%=cLCodLogin%>";
- dialogSlv.modal('hide');
- }
- });
-
- }
- });
- }
- </script>
- </body>
- </html>
|