'); $('#form-upload input[name=\'file\']').trigger('click'); timer = setInterval(function () { if ($('#form-upload input[name=\'file\']').val() != '') { clearInterval(timer); $.ajax({ url: 'index.php?route=tool/upload&upload-option-id=' + node.data('upload-option-id'), type: 'post', dataType: 'json', data: new FormData($('#form-upload')[0]), cache: false, contentType: false, processData: false, beforeSend: function () { $(node).button('loading'); }, success: function (json) { $('.text-danger').remove(); $('.alert-success').remove(); if (json['error']) { $(node).button('reset'); $(node).parent().find('input').after('
' + json['error'] + '
'); } if (json['success']) { var str = json.filename; var res = str.slice(-4); var res2 = str.slice(0, (str.length / 2)); $(node).html(res2 + '(...)' + res).addClass('btn btn-success').removeClass('disabled').removeAttr('disabled'); $(node).parent().find('input').attr('value', json['code']); } }, error: function (xhr, ajaxOptions, thrownError) { console.log(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText); } }); } }, 500); }); var data = new Date(); $('.mask-date').mask('99/99/9999'); $('.mask-datetime').mask('99/99/9999 00:00'); $('.mask-time').mask('00:00'); $('#input-postcode').mask('99999-999'); $(function () { $('#date').datetimepicker({ pickTime: false, format:'DD/MM/YYYY', defaultDate: data, }); }); $(function () { $('#time').datetimepicker({ pickDate: false, defaultDate: data.getHours() + ':' + data.getMinutes(), format:'HH:mm', minuteStep: 15, autoclose: true, minView: 0, maxView: 1, startView: 1, icons : { time: "mdi mdi-schedule", date: "mdi mdi-date-range", up: "mdi mdi-keyboard-arrow-up", down: "mdi mdi-keyboard-arrow-down" } }); }); $(function () { $('#datetime').datetimepicker({ defaultDate: data, format:'DD/MM/YYYY HH:mm', minuteStep: 15, autoclose: true, minView: 0, maxView: 1, startView: 1, icons : { time: "mdi mdi-schedule", date: "mdi mdi-date-range", up: "mdi mdi-keyboard-arrow-up", down: "mdi mdi-keyboard-arrow-down" } }); }); $('textarea[id^="input-custom-field"], input[id^="input-custom-field"]').on("keyup", function (e) { $(this).val($(this).val().replace(/[^a-zA-Z0-9-./\//-záàâãéèêíïóôõöúçñÁÀÂÃÉÈÍÏÓÔÕÖÚÇÑ ]/gm, '')); }); $('select[name=\'country_id\']').on('change', function() { $.ajax({ url: 'index.php?route=account/account/country&country_id=' + this.value, dataType: 'json', beforeSend: function() { $('select[name=\'country_id\']').after(''); }, complete: function() { $('.mdi-spin').remove(); }, success: function(json) { if (json['postcode_required'] != '1') { $('#label-postcode').append('(opcional)'); } else { $('#label-postcode .optional').remove(); } html = ''; if (json['zone'] != '') { for (i = 0; i < json['zone'].length; i++) { html += ''; } } else { html += ''; } $('select[name=\'zone_id\']').html(html); }, error: function(xhr, ajaxOptions, thrownError) { alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText); } }); }); function pessoaFisica(discount_physical_person,discount_legal_person,display_message_physical){ $('#field-rg_ie').parent().css('display','none'); $('#label-cpf_cnpj').html('CPF'); $('#input-cpf_cnpj').removeAttr("maxlength"); $('#input-cpf_cnpj').mask("999.999.999-99"); $('#input-rg_ie').mask('AAAAAAAAAAAAAAA'); $('#label-firstname').html('Nome Completo'); $('#field-lastname').parent().css('display','none'); $('#ie_checked').css('display','none'); $('#final_customer').css('display','none'); $('#field-cnpj_contact').parent().css('display', 'none'); $('.gender-group').parent().removeAttr('style'); $('.register-column-type').removeClass('col-md-12').addClass('col-md-6'); if(screen.width < 768){ $('#label-cellphone').html('Celular / WhatsApp'); } else { $('#label-cellphone').html('Celular'); } $('#label-birthday .optional').remove(); $('#label-telephone').html('Telefone (opcional)'); $('#buy-wholesale-field').hide(); if (discount_physical_person){ $('#buy-wholesale-field').show(); } if(display_message_physical === undefined) { display_message_physical = 0; } if(display_message_physical) { $('#info-analysis').show(); }else{ $('#info-analysis').hide(); } } function searchAddressCustomerInternational(postcode, checkout_name) { $('#text_cep_obs + .text-danger').remove(); if(postcode.length == 5){ if($('.second-step-address').length){ $('.osc-address-load').show(); } if (String(typeof (checkout_name)) != 'undefined') { var address_1 = $('input[name="' + checkout_name + '[address_1]"]'); var neighborhood = $('input[name="' + checkout_name + '[neighborhood]"]'); var city = $('input[name="' + checkout_name + '[city]"]'); var zone_id = $('select[name="' + checkout_name + '[zone_id]"]'); var country_id = $('select[name="' + checkout_name + '[country_id]"]'); var number_home = $('input[name="' + checkout_name + '[number_home]"]'); var local = checkout_name; } else { var address_1 = $('input[name=address_1]'); var neighborhood = $('input[name=neighborhood]'); var city = $('input[name=city]'); var zone_id = $('select[name=zone_id]'); var country_id = $('select[name=country_id]'); var number_home = $('input[name=number_home]'); var local = 'other'; } address_1.val(''); address_1.removeAttr('readonly'); neighborhood.val(''); neighborhood.removeAttr('readonly'); city.val(''); city.removeAttr('readonly'); zone_id.val(''); $.ajax({ url: 'index.php?route=account/correios/correiosJson', type: 'POST', data: 'postcode=' + postcode + '&local=' + local, dataType: 'json', beforeSend: function () { $('.text_cep_obs').html('Carregando...'); $('#btn-ok-cep').html(''); if($('.register-address-column').length){ $('.register-address-column .form-group:not(.fixed-focus) .form-label').removeClass('focus not-empty'); $('.register-address-column').hide(); $('.register-address-column').before('Carregando...
'); } }, complete: function () { if($('.register-address-column').length){ $('.register-address-column').show(); $('.register-load-address').remove(); } }, success: function (json) { $('#btn-ok-cep').html('OK'); $('#input-postcode').removeClass('select-disabled'); $('#input-zone').removeClass('select-disabled'); $('#include_address_content > .text-center > .btn-primary').show(); if($('.second-step-address .osc-error').length){ $('.second-step-address .osc-error').remove(); } if (json.return_ok) { if (String(typeof (json.address)) == 'string' && json.address != '') { address_1.val(json.address); if(json.address && json.address != " " && $('.second-step-address').length && $('.onestepcheckout-checkout').length){ address_1.parent().addClass('is-valid').removeClass('has-error').find('.form-label').addClass('focus not-empty'); } else if(json.address && json.address != " " && $('.account-register').length){ address_1.siblings('.form-label').addClass('focus not-empty'); } number_home.focus(); } else { address_1.focus(); } if (String(typeof (json.neighborhood)) == 'string' && json.address != '') { neighborhood.val(json.neighborhood); if(json.neighborhood && $('.second-step-address').length && $('.onestepcheckout-checkout').length){ neighborhood.parent().addClass('is-valid').removeClass('has-error').find('.form-label').addClass('focus not-empty'); } else if(json.neighborhood && $('.account-register').length){ neighborhood.siblings('.form-label').addClass('focus not-empty'); } } if (String(typeof (json.city)) == 'string') { city.val(json.city); if(json.city && $('.second-step-address').length && $('.onestepcheckout-checkout').length){ city.parent().addClass('is-valid').removeClass('has-error').find('.form-label').addClass('focus not-empty'); }else if(json.city && $('.account-register').length){ city.siblings('.form-label').addClass('focus not-empty'); } } if (json.zone_id != '') { zone_id.val(json.zone_id); if(zone_id.hasClass('empty')){ zone_id.removeClass('empty').siblings('label').removeClass('empty'); } } if ($('.second-step-address').length && $('.onestepcheckout-checkout').length) { $('.input-postcode').removeAttr('disabled'); } if(json.return_all){ $('.field-complete').hide(); $('.return_all').show(); $('.return_all_content').html(json.address + ' - change
'+json.neighborhood +' - '+ json.city + ' - ' + json.zone); if($('.second-step-address').length && $('.onestepcheckout-checkout').length){ $('.osc-address-load').hide(); /* update_three_block(); */ $('.btn-open-payment').removeClass('disabled').html('Continue'); } $('.edit_address').click(function(){ $('.return_all').hide(); $('.return_all_content').html(''); $('.field-complete').show(); }); }else{ if(json.notify_cep) { $('.text_cep_obs').html('
City code not found in our database
'); } else { $('#input-zone').addClass('select-disabled'); } if(json.notify_cep && json.block_cep) { $('#include_address_content > .text-center > .btn-primary').hide(); $('.osc-address-load').hide(); return; } $('.return_all').hide(); $('.return_all_content').html(''); $('.field-complete').show(); $('.osc-address-load').hide(); if($('.second-step-address').length && $('.onestepcheckout-checkout').length){ $('.osc-address-load').hide(); /* update_three_block(); */ $('.btn-open-payment').removeClass('disabled').html('Continue'); } } }else{ $('.second-step-address').fadeOut(); $('
City code not found in our database
').insertAfter('#text_cep_obs'); } $('.second-step-address').fadeIn(function(){ if($('.second-step-address').length && $('.onestepcheckout-checkout').length){ if (String(typeof (json.address)) == 'string' && json.address != '' && json.address != ' ') { $(`input[name="${checkout_name}[number_home]"]`).get(0).focus(); } else { $(`input[name="${checkout_name}[address_1]"]`).get(0).focus(); } } }); }, error: function (XMLHttpRequest, textStatus, errorThrown) { console.log(XMLHttpRequest.responseText); } }); } else { $('.second-step-address').fadeOut(); $('
City Code invalid! Verify that it was typed correctly
').insertAfter('#text_cep_obs'); } } function pessoaJuridica(discount_physical_person,discount_legal_person,display_message_legal){ $('#label-cpf_cnpj').html('CNPJ'); $('#input-cpf_cnpj').removeAttr("maxlength"); $('#input-cpf_cnpj').mask("99.999.999/9999-99"); $('#label-firstname').html('Razão Social'); $('#input-rg_ie').mask('99999999999999999999'); $('#label-rg_ie').parent().removeAttr('style'); $('#label-rg_ie').html('Inscrição Estadual'); $('input[name=rg_ie]').attr('onKeyUp','this.value=this.value.replace(\/[^\\d]*\/gi,"");'); $('#field-rg_ie').parent().css('display','block'); $('#field-lastname').parent().removeAttr('style'); $('#field-cnpj_contact').parent().css('display', 'block'); $('#ie_checked').css('display','block'); $('#final_customer').css('display','block'); $('.gender-group').parent().css('display', 'none'); $('#label-cellphone').html('Telefone / Celular'); $('#label-telephone').html('Telefone Adicional (opcional)'); $('#label-birthday').append(' (opcional)'); $('.register-column-type').addClass('col-md-12').removeClass('col-md-6'); $('#buy-wholesale-field').hide(); if (discount_legal_person){ $('#buy-wholesale-field').show(); } if(display_message_legal === undefined) { display_message_legal = 0; } if(display_message_legal){ $('#info-analysis').show(); }else { $('#info-analysis').hide(); } } pessoaFisica('',''); $('select[name=\'country_id\']').trigger('change'); $('#input-ie_checked').on('click',function(){ if($(this).is(':checked')){ $('input[name=rg_ie]').val('ISENTO').attr('readonly', true).siblings('.form-label').addClass('focus not-empty'); }else{ $('input[name=rg_ie]').val('').removeAttr('readonly').siblings('.form-label').removeClass('focus not-empty'); } }); zipCode = $('#input-postcode').val(); zipCodeInterval = 2500; $('#input-postcode').on('keypress click', function() { zipCodeInterval = 2500; }); setInterval(() => { if (zipCode != $('#input-postcode').val()) { zipCode = $('#input-postcode').val(); if (zipCode.replace(/\D/g, "").length == 8) { searchAddressCustomer(zipCode.replace(/\D/g, "")); } } }, zipCodeInterval);