{"id":894,"date":"2025-10-24T20:01:57","date_gmt":"2025-10-24T23:01:57","guid":{"rendered":"https:\/\/hztec.com.br\/?page_id=894"},"modified":"2025-10-25T00:39:49","modified_gmt":"2025-10-25T03:39:49","slug":"crm-hztec-colaboradores","status":"publish","type":"page","link":"http:\/\/hztec.com.br\/index.php\/crm-hztec-colaboradores\/","title":{"rendered":"CRM"},"content":{"rendered":"\n<!doctype html>\n<html lang=\"pt-BR\">\n <head>\n  <meta charset=\"UTF-8\">\n  <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n  <title>CRM Vendas HZTEC<\/title>\n  <script src=\"\/_sdk\/data_sdk.js\"><\/script>\n  <script src=\"\/_sdk\/element_sdk.js\"><\/script>\n  <script src=\"https:\/\/cdn.tailwindcss.com\"><\/script>\n  <style>\n        body {\n            box-sizing: border-box;\n        }\n        .loading {\n            opacity: 0.6;\n            pointer-events: none;\n        }\n        .toast {\n            position: fixed;\n            top: 20px;\n            right: 20px;\n            z-index: 1000;\n            transition: all 0.3s ease;\n        }\n        .modal-backdrop {\n            background-color: rgba(0, 0, 0, 0.5);\n        }\n    <\/style>\n  <style>@view-transition { navigation: auto; }<\/style>\n <\/head>\n <body class=\"min-h-full bg-gradient-to-br from-blue-50 to-indigo-100\">\n  <div id=\"toast-container\"><\/div><!-- Tela de Login -->\n  <div id=\"tela-login\" class=\"min-h-full flex items-center justify-center py-12 px-4 sm:px-6 lg:px-8\">\n   <div class=\"max-w-md w-full space-y-8\">\n    <div class=\"text-center\">\n     <div class=\"flex justify-center mb-6\">\n      <div class=\"w-16 h-16 bg-blue-600 rounded-xl flex items-center justify-center\"><img decoding=\"async\" id=\"logo-login\" src=\"\" alt=\"\" class=\"w-14 h-14 rounded-lg object-cover hidden\" onerror=\"this.style.display='none'; document.getElementById('logo-placeholder-login').style.display='flex';\">\n       <div id=\"logo-placeholder-login\" class=\"w-14 h-14 bg-blue-700 rounded-lg flex items-center justify-center text-white font-bold text-sm\">\n        HZTEC\n       <\/div>\n      <\/div>\n     <\/div>\n     <h2 id=\"titulo-login\" class=\"text-3xl font-bold text-gray-900\">CRM Vendas HZTec<\/h2>\n     <p class=\"mt-2 text-gray-600\">Fa\u00e7a login para acessar o sistema<\/p>\n    <\/div>\n    <form id=\"form-login\" class=\"mt-8 space-y-6\">\n     <div class=\"space-y-4\">\n      <div><label for=\"usuario-login\" class=\"block text-sm font-medium text-gray-700 mb-1\">Usu\u00e1rio<\/label> <input id=\"usuario-login\" name=\"usuario\" type=\"text\" required class=\"w-full px-3 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent\" placeholder=\"Digite seu usu\u00e1rio\">\n      <\/div>\n      <div><label for=\"senha-login\" class=\"block text-sm font-medium text-gray-700 mb-1\">Senha<\/label> <input id=\"senha-login\" name=\"senha\" type=\"password\" required class=\"w-full px-3 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent\" placeholder=\"Digite sua senha\">\n      <\/div>\n     <\/div>\n     <div id=\"erro-login\" class=\"hidden bg-red-50 border border-red-200 text-red-700 px-4 py-3 rounded-lg\">\n      Usu\u00e1rio ou senha incorretos\n     <\/div><button type=\"submit\" id=\"btn-login\" class=\"w-full bg-blue-600 hover:bg-blue-700 text-white font-semibold py-3 px-4 rounded-lg transition-colors focus:ring-2 focus:ring-blue-500 focus:ring-offset-2\"> Entrar <\/button>\n    <\/form>\n   <\/div>\n  <\/div><!-- Sistema CRM (oculto inicialmente) -->\n  <div id=\"sistema-crm\" class=\"hidden\">\n   <header class=\"bg-white shadow-lg border-b-4 border-blue-600\">\n    <div class=\"max-w-7xl mx-auto px-4 py-6\">\n     <div class=\"flex justify-between items-center\">\n      <div class=\"flex items-center space-x-4\">\n       <div class=\"w-12 h-12 bg-blue-600 rounded-lg flex items-center justify-center\"><img decoding=\"async\" id=\"logo-image\" src=\"\" alt=\"\" class=\"w-10 h-10 rounded-lg object-cover hidden\" onerror=\"this.style.display='none'; document.getElementById('logo-placeholder').style.display='flex';\">\n        <div id=\"logo-placeholder\" class=\"w-10 h-10 bg-blue-700 rounded-lg flex items-center justify-center text-white font-bold text-xs\">\n         HZTEC\n        <\/div>\n       <\/div>\n       <div>\n        <h1 id=\"titulo-crm\" class=\"text-3xl font-bold text-gray-900\">CRM Vendas HZTec<\/h1>\n        <p class=\"text-gray-600 mt-1\">Gerencie seus leads e vendas<\/p>\n       <\/div>\n      <\/div>\n      <div class=\"flex items-center space-x-4\"><button id=\"btn-novo-lead\" class=\"bg-blue-600 hover:bg-blue-700 text-white px-6 py-3 rounded-lg font-semibold shadow-lg transition-colors\"> + Novo Lead <\/button> <button id=\"btn-logout\" class=\"bg-gray-600 hover:bg-gray-700 text-white px-4 py-3 rounded-lg font-semibold transition-colors\"> Sair <\/button>\n      <\/div>\n     <\/div>\n    <\/div>\n   <\/header>\n   <main class=\"max-w-7xl mx-auto px-4 py-8\"><!-- Estat\u00edsticas -->\n    <div class=\"grid grid-cols-1 md:grid-cols-4 gap-6 mb-8\">\n     <div class=\"bg-white p-6 rounded-xl shadow-lg border-l-4 border-yellow-500\">\n      <h3 class=\"text-lg font-semibold text-gray-700\">Novos Leads<\/h3>\n      <p id=\"stat-novos\" class=\"text-3xl font-bold text-yellow-600\">0<\/p>\n     <\/div>\n     <div class=\"bg-white p-6 rounded-xl shadow-lg border-l-4 border-blue-500\">\n      <h3 class=\"text-lg font-semibold text-gray-700\">Em Contato<\/h3>\n      <p id=\"stat-contato\" class=\"text-3xl font-bold text-blue-600\">0<\/p>\n     <\/div>\n     <div class=\"bg-white p-6 rounded-xl shadow-lg border-l-4 border-orange-500\">\n      <h3 class=\"text-lg font-semibold text-gray-700\">Proposta<\/h3>\n      <p id=\"stat-proposta\" class=\"text-3xl font-bold text-orange-600\">0<\/p>\n     <\/div>\n     <div class=\"bg-white p-6 rounded-xl shadow-lg border-l-4 border-green-500\">\n      <h3 class=\"text-lg font-semibold text-gray-700\">Fechados<\/h3>\n      <p id=\"stat-fechados\" class=\"text-3xl font-bold text-green-600\">0<\/p>\n     <\/div>\n    <\/div><!-- Filtros -->\n    <div class=\"bg-white p-6 rounded-xl shadow-lg mb-8\">\n     <div class=\"grid grid-cols-1 md:grid-cols-3 gap-4\"><select id=\"filtro-vendedor\" class=\"border border-gray-300 rounded-lg px-4 py-2 focus:ring-2 focus:ring-blue-500 focus:border-transparent\"> <option value=\"\">Todos os Vendedores<\/option> <option value=\"Vendedor 1\">Vendedor 1<\/option> <option value=\"Vendedor 2\">Vendedor 2<\/option> <option value=\"Vendedor 3\">Vendedor 3<\/option> <option value=\"Vendedor 4\">Vendedor 4<\/option> <option value=\"Vendedor 5\">Vendedor 5<\/option> <option value=\"Vendedor 6\">Vendedor 6<\/option> <option value=\"Vendedor 7\">Vendedor 7<\/option> <option value=\"Vendedor 8\">Vendedor 8<\/option> <option value=\"Vendedor 9\">Vendedor 9<\/option> <\/select> <select id=\"filtro-estagio\" class=\"border border-gray-300 rounded-lg px-4 py-2 focus:ring-2 focus:ring-blue-500 focus:border-transparent\"> <option value=\"\">Todos os Est\u00e1gios<\/option> <option value=\"Novo Lead\">Novo Lead<\/option> <option value=\"Em Contato\">Em Contato<\/option> <option value=\"Proposta Enviada\">Proposta Enviada<\/option> <option value=\"Negocia\u00e7\u00e3o\">Negocia\u00e7\u00e3o<\/option> <option value=\"Fechado - Ganho\">Fechado &#8211; Ganho<\/option> <option value=\"Fechado - Perdido\">Fechado &#8211; Perdido<\/option> <\/select> <input id=\"filtro-busca\" type=\"text\" placeholder=\"Buscar por nome ou empresa...\" class=\"border border-gray-300 rounded-lg px-4 py-2 focus:ring-2 focus:ring-blue-500 focus:border-transparent\">\n     <\/div>\n    <\/div><!-- Lista de Leads -->\n    <div class=\"bg-white rounded-xl shadow-lg overflow-hidden\">\n     <div class=\"px-6 py-4 bg-gray-50 border-b\">\n      <h2 class=\"text-xl font-semibold text-gray-800\">Pipeline de Vendas<\/h2>\n     <\/div>\n     <div id=\"leads-container\" class=\"divide-y divide-gray-200\">\n      <div id=\"empty-state\" class=\"p-12 text-center text-gray-500\">\n       <div class=\"text-6xl mb-4\">\n        \ud83d\udcca\n       <\/div>\n       <h3 class=\"text-xl font-semibold mb-2\">Nenhum lead cadastrado<\/h3>\n       <p>Clique em &#8220;Novo Lead&#8221; para come\u00e7ar<\/p>\n      <\/div>\n     <\/div>\n    <\/div>\n   <\/main><!-- Modal Novo\/Editar Lead -->\n   <div id=\"modal-lead\" class=\"fixed inset-0 z-50 hidden\">\n    <div class=\"modal-backdrop fixed inset-0\" onclick=\"fecharModal()\"><\/div>\n    <div class=\"fixed inset-0 flex items-center justify-center p-4\">\n     <div class=\"bg-white rounded-xl shadow-2xl max-w-2xl w-full max-h-[90vh] overflow-y-auto\">\n      <div class=\"px-6 py-4 border-b bg-gray-50\">\n       <h2 id=\"modal-titulo\" class=\"text-xl font-semibold text-gray-800\">Novo Lead<\/h2>\n      <\/div>\n      <form id=\"form-lead\" class=\"p-6 space-y-4\">\n       <div class=\"grid grid-cols-1 md:grid-cols-2 gap-4\">\n        <div><label for=\"nome\" class=\"block text-sm font-medium text-gray-700 mb-1\">Nome *<\/label> <input type=\"text\" id=\"nome\" name=\"nome\" required class=\"w-full border border-gray-300 rounded-lg px-3 py-2 focus:ring-2 focus:ring-blue-500 focus:border-transparent\">\n        <\/div>\n        <div><label for=\"email\" class=\"block text-sm font-medium text-gray-700 mb-1\">Email *<\/label> <input type=\"email\" id=\"email\" name=\"email\" required class=\"w-full border border-gray-300 rounded-lg px-3 py-2 focus:ring-2 focus:ring-blue-500 focus:border-transparent\">\n        <\/div>\n        <div><label for=\"telefone\" class=\"block text-sm font-medium text-gray-700 mb-1\">Telefone *<\/label> <input type=\"tel\" id=\"telefone\" name=\"telefone\" required class=\"w-full border border-gray-300 rounded-lg px-3 py-2 focus:ring-2 focus:ring-blue-500 focus:border-transparent\">\n        <\/div>\n        <div><label for=\"empresa\" class=\"block text-sm font-medium text-gray-700 mb-1\">Empresa<\/label> <input type=\"text\" id=\"empresa\" name=\"empresa\" class=\"w-full border border-gray-300 rounded-lg px-3 py-2 focus:ring-2 focus:ring-blue-500 focus:border-transparent\">\n        <\/div>\n        <div><label for=\"vendedor\" class=\"block text-sm font-medium text-gray-700 mb-1\">Vendedor *<\/label> <select id=\"vendedor\" name=\"vendedor\" required class=\"w-full border border-gray-300 rounded-lg px-3 py-2 focus:ring-2 focus:ring-blue-500 focus:border-transparent\"> <option value=\"\">Selecione&#8230;<\/option> <option value=\"Vendedor 1\">Vendedor 1<\/option> <option value=\"Vendedor 2\">Vendedor 2<\/option> <option value=\"Vendedor 3\">Vendedor 3<\/option> <option value=\"Vendedor 4\">Vendedor 4<\/option> <option value=\"Vendedor 5\">Vendedor 5<\/option> <option value=\"Vendedor 6\">Vendedor 6<\/option> <option value=\"Vendedor 7\">Vendedor 7<\/option> <option value=\"Vendedor 8\">Vendedor 8<\/option> <option value=\"Vendedor 9\">Vendedor 9<\/option> <\/select>\n        <\/div>\n        <div><label for=\"estagio\" class=\"block text-sm font-medium text-gray-700 mb-1\">Est\u00e1gio *<\/label> <select id=\"estagio\" name=\"estagio\" required class=\"w-full border border-gray-300 rounded-lg px-3 py-2 focus:ring-2 focus:ring-blue-500 focus:border-transparent\"> <option value=\"Novo Lead\">Novo Lead<\/option> <option value=\"Em Contato\">Em Contato<\/option> <option value=\"Proposta Enviada\">Proposta Enviada<\/option> <option value=\"Negocia\u00e7\u00e3o\">Negocia\u00e7\u00e3o<\/option> <option value=\"Fechado - Ganho\">Fechado &#8211; Ganho<\/option> <option value=\"Fechado - Perdido\">Fechado &#8211; Perdido<\/option> <\/select>\n        <\/div>\n        <div class=\"md:col-span-2\"><label for=\"valor\" class=\"block text-sm font-medium text-gray-700 mb-1\">Valor Estimado (R$)<\/label> <input type=\"number\" id=\"valor\" name=\"valor\" min=\"0\" step=\"0.01\" class=\"w-full border border-gray-300 rounded-lg px-3 py-2 focus:ring-2 focus:ring-blue-500 focus:border-transparent\">\n        <\/div>\n        <div class=\"md:col-span-2\"><label for=\"observacoes\" class=\"block text-sm font-medium text-gray-700 mb-1\">Observa\u00e7\u00f5es<\/label> <textarea id=\"observacoes\" name=\"observacoes\" rows=\"3\" class=\"w-full border border-gray-300 rounded-lg px-3 py-2 focus:ring-2 focus:ring-blue-500 focus:border-transparent\"><\/textarea>\n        <\/div>\n       <\/div>\n       <div class=\"flex justify-end space-x-3 pt-4 border-t\"><button type=\"button\" onclick=\"fecharModal()\" class=\"px-4 py-2 text-gray-600 hover:text-gray-800 transition-colors\">Cancelar<\/button> <button type=\"submit\" id=\"btn-salvar\" class=\"bg-blue-600 hover:bg-blue-700 text-white px-6 py-2 rounded-lg font-semibold transition-colors\">Salvar<\/button>\n       <\/div>\n      <\/form>\n     <\/div>\n    <\/div>\n   <\/div>\n  <\/div>\n  <script>\n        let leads = [];\n        let leadEditando = null;\n        let config = {};\n\n        const defaultConfig = {\n            titulo_crm: \"CRM Vendas HZTec\",\n            logo_url: \"\",\n            usuario_admin: \"admin\",\n            senha_admin: \"123456\",\n            email_empresa: \"webmail.hztec.com.br\",\n            telefone_empresa: \"11-42684286\"\n        };\n\n        \/\/ Configura\u00e7\u00e3o do Element SDK\n        const elementConfig = {\n            defaultConfig: defaultConfig,\n            onConfigChange: async (newConfig) => {\n                config = { ...defaultConfig, ...newConfig };\n                document.getElementById('titulo-crm').textContent = config.titulo_crm || defaultConfig.titulo_crm;\n                document.getElementById('titulo-login').textContent = config.titulo_crm || defaultConfig.titulo_crm;\n                \n                \/\/ Atualizar logo no cabe\u00e7alho\n                const logoUrl = config.logo_url || defaultConfig.logo_url;\n                const logoImage = document.getElementById('logo-image');\n                const logoPlaceholder = document.getElementById('logo-placeholder');\n                \n                if (logoUrl && logoUrl.trim() !== '') {\n                    logoImage.src = logoUrl;\n                    logoImage.style.display = 'block';\n                    logoPlaceholder.style.display = 'none';\n                } else {\n                    logoImage.style.display = 'none';\n                    logoPlaceholder.style.display = 'flex';\n                }\n                \n                \/\/ Atualizar logo no login\n                const logoLogin = document.getElementById('logo-login');\n                const logoPlaceholderLogin = document.getElementById('logo-placeholder-login');\n                \n                if (logoUrl && logoUrl.trim() !== '') {\n                    logoLogin.src = logoUrl;\n                    logoLogin.style.display = 'block';\n                    logoPlaceholderLogin.style.display = 'none';\n                } else {\n                    logoLogin.style.display = 'none';\n                    logoPlaceholderLogin.style.display = 'flex';\n                }\n            },\n            mapToCapabilities: (config) => ({\n                recolorables: [\n                    {\n                        get: () => config.cor_primaria || \"#2563eb\",\n                        set: (value) => {\n                            config.cor_primaria = value;\n                            window.elementSdk.setConfig({ cor_primaria: value });\n                        }\n                    }\n                ],\n                borderables: [],\n                fontEditable: undefined,\n                fontSizeable: undefined\n            }),\n            mapToEditPanelValues: (config) => new Map([\n                [\"titulo_crm\", config.titulo_crm || defaultConfig.titulo_crm],\n                [\"logo_url\", config.logo_url || defaultConfig.logo_url],\n                [\"usuario_admin\", config.usuario_admin || defaultConfig.usuario_admin],\n                [\"senha_admin\", config.senha_admin || defaultConfig.senha_admin],\n                [\"email_empresa\", config.email_empresa || defaultConfig.email_empresa],\n                [\"telefone_empresa\", config.telefone_empresa || defaultConfig.telefone_empresa]\n            ])\n        };\n\n        \/\/ Data Handler\n        const dataHandler = {\n            onDataChanged(data) {\n                leads = data;\n                renderLeads();\n                atualizarEstatisticas();\n            }\n        };\n\n        \/\/ Inicializa\u00e7\u00e3o\n        document.addEventListener('DOMContentLoaded', async () => {\n            \/\/ Inicializar config com valores padr\u00e3o primeiro\n            config = { ...defaultConfig };\n            \n            if (window.elementSdk) {\n                try {\n                    await window.elementSdk.init(elementConfig);\n                    config = { ...defaultConfig, ...window.elementSdk.config };\n                } catch (error) {\n                    console.log('Element SDK n\u00e3o dispon\u00edvel, usando configura\u00e7\u00e3o padr\u00e3o');\n                }\n            }\n\n            if (window.dataSdk) {\n                try {\n                    const result = await window.dataSdk.init(dataHandler);\n                    if (!result.isOk) {\n                        mostrarToast('Erro ao inicializar sistema', 'error');\n                    }\n                } catch (error) {\n                    console.log('Data SDK n\u00e3o dispon\u00edvel');\n                }\n            }\n\n            configurarEventos();\n            \n            \/\/ Aplicar configura\u00e7\u00e3o inicial\n            aplicarConfiguracaoInicial();\n        });\n\n        function configurarEventos() {\n            document.getElementById('form-login').addEventListener('submit', fazerLogin);\n            document.getElementById('btn-logout').addEventListener('click', fazerLogout);\n            document.getElementById('btn-novo-lead').addEventListener('click', abrirModalNovoLead);\n            document.getElementById('form-lead').addEventListener('submit', salvarLead);\n            document.getElementById('filtro-vendedor').addEventListener('change', aplicarFiltros);\n            document.getElementById('filtro-estagio').addEventListener('change', aplicarFiltros);\n            document.getElementById('filtro-busca').addEventListener('input', aplicarFiltros);\n        }\n\n        function aplicarConfiguracaoInicial() {\n            \/\/ Aplicar t\u00edtulo\n            document.getElementById('titulo-crm').textContent = config.titulo_crm || defaultConfig.titulo_crm;\n            document.getElementById('titulo-login').textContent = config.titulo_crm || defaultConfig.titulo_crm;\n            \n            \/\/ Aplicar logo\n            const logoUrl = config.logo_url || defaultConfig.logo_url;\n            const logoImage = document.getElementById('logo-image');\n            const logoPlaceholder = document.getElementById('logo-placeholder');\n            const logoLogin = document.getElementById('logo-login');\n            const logoPlaceholderLogin = document.getElementById('logo-placeholder-login');\n            \n            if (logoUrl && logoUrl.trim() !== '') {\n                logoImage.src = logoUrl;\n                logoImage.style.display = 'block';\n                logoPlaceholder.style.display = 'none';\n                logoLogin.src = logoUrl;\n                logoLogin.style.display = 'block';\n                logoPlaceholderLogin.style.display = 'none';\n            } else {\n                logoImage.style.display = 'none';\n                logoPlaceholder.style.display = 'flex';\n                logoLogin.style.display = 'none';\n                logoPlaceholderLogin.style.display = 'flex';\n            }\n        }\n\n        function fazerLogin(e) {\n            e.preventDefault();\n            \n            const usuario = document.getElementById('usuario-login').value.trim();\n            const senha = document.getElementById('senha-login').value.trim();\n            \n            \/\/ Usar credenciais padr\u00e3o se config n\u00e3o estiver dispon\u00edvel\n            const usuarioCorreto = (config && config.usuario_admin) ? config.usuario_admin : \"admin\";\n            const senhaCorreta = (config && config.senha_admin) ? config.senha_admin : \"123456\";\n            \n            console.log('Tentativa de login:', { usuario, senha, usuarioCorreto, senhaCorreta });\n            \n            if (usuario === usuarioCorreto && senha === senhaCorreta) {\n                document.getElementById('tela-login').style.display = 'none';\n                document.getElementById('sistema-crm').style.display = 'block';\n                document.getElementById('erro-login').classList.add('hidden');\n                mostrarToast('Login realizado com sucesso!', 'success');\n            } else {\n                document.getElementById('erro-login').classList.remove('hidden');\n                document.getElementById('senha-login').value = '';\n                mostrarToast('Usu\u00e1rio ou senha incorretos', 'error');\n            }\n        }\n\n        function fazerLogout() {\n            document.getElementById('sistema-crm').style.display = 'none';\n            document.getElementById('tela-login').style.display = 'flex';\n            document.getElementById('form-login').reset();\n            document.getElementById('erro-login').classList.add('hidden');\n            mostrarToast('Logout realizado com sucesso!', 'success');\n        }\n\n        function abrirModalNovoLead() {\n            leadEditando = null;\n            document.getElementById('modal-titulo').textContent = 'Novo Lead';\n            document.getElementById('form-lead').reset();\n            document.getElementById('modal-lead').classList.remove('hidden');\n        }\n\n        function editarLead(lead) {\n            leadEditando = lead;\n            document.getElementById('modal-titulo').textContent = 'Editar Lead';\n            \n            document.getElementById('nome').value = lead.nome;\n            document.getElementById('email').value = lead.email;\n            document.getElementById('telefone').value = lead.telefone;\n            document.getElementById('empresa').value = lead.empresa || '';\n            document.getElementById('vendedor').value = lead.vendedor;\n            document.getElementById('estagio').value = lead.estagio;\n            document.getElementById('valor').value = lead.valor || '';\n            document.getElementById('observacoes').value = lead.observacoes || '';\n            \n            document.getElementById('modal-lead').classList.remove('hidden');\n        }\n\n        function fecharModal() {\n            document.getElementById('modal-lead').classList.add('hidden');\n            leadEditando = null;\n        }\n\n        async function salvarLead(e) {\n            e.preventDefault();\n            \n            if (leads.length >= 999 && !leadEditando) {\n                mostrarToast('Limite m\u00e1ximo de 999 leads atingido. Exclua alguns leads primeiro.', 'error');\n                return;\n            }\n\n            const btnSalvar = document.getElementById('btn-salvar');\n            btnSalvar.classList.add('loading');\n            btnSalvar.textContent = 'Salvando...';\n\n            const formData = new FormData(e.target);\n            const leadData = {\n                nome: formData.get('nome'),\n                email: formData.get('email'),\n                telefone: formData.get('telefone'),\n                empresa: formData.get('empresa') || '',\n                vendedor: formData.get('vendedor'),\n                estagio: formData.get('estagio'),\n                valor: parseFloat(formData.get('valor')) || 0,\n                observacoes: formData.get('observacoes') || '',\n                data_atualizacao: new Date().toISOString()\n            };\n\n            let result;\n            if (leadEditando) {\n                const leadAtualizado = { ...leadEditando, ...leadData };\n                result = await window.dataSdk.update(leadAtualizado);\n            } else {\n                leadData.id = 'lead_' + Date.now();\n                leadData.data_criacao = new Date().toISOString();\n                result = await window.dataSdk.create(leadData);\n                \n                if (result.isOk) {\n                    enviarNotificacoes(leadData);\n                }\n            }\n\n            btnSalvar.classList.remove('loading');\n            btnSalvar.textContent = 'Salvar';\n\n            if (result.isOk) {\n                mostrarToast(leadEditando ? 'Lead atualizado com sucesso!' : 'Lead cadastrado com sucesso!', 'success');\n                fecharModal();\n            } else {\n                mostrarToast('Erro ao salvar lead. Tente novamente.', 'error');\n            }\n        }\n\n        async function excluirLead(lead) {\n            const confirmacao = document.createElement('div');\n            confirmacao.className = 'fixed inset-0 z-50 flex items-center justify-center p-4';\n            confirmacao.innerHTML = `\n                <div class=\"modal-backdrop fixed inset-0\"><\/div>\n                <div class=\"bg-white rounded-xl shadow-2xl p-6 max-w-md w-full relative z-10\">\n                    <h3 class=\"text-lg font-semibold text-gray-900 mb-4\">Confirmar Exclus\u00e3o<\/h3>\n                    <p class=\"text-gray-600 mb-6\">Tem certeza que deseja excluir o lead \"${lead.nome}\"?<\/p>\n                    <div class=\"flex justify-end space-x-3\">\n                        <button onclick=\"this.closest('.fixed').remove()\" class=\"px-4 py-2 text-gray-600 hover:text-gray-800 transition-colors\">Cancelar<\/button>\n                        <button onclick=\"confirmarExclusao('${lead.__backendId}')\" class=\"bg-red-600 hover:bg-red-700 text-white px-4 py-2 rounded-lg transition-colors\">Excluir<\/button>\n                    <\/div>\n                <\/div>\n            `;\n            document.body.appendChild(confirmacao);\n        }\n\n        async function confirmarExclusao(backendId) {\n            const lead = leads.find(l => l.__backendId === backendId);\n            if (lead) {\n                const result = await window.dataSdk.delete(lead);\n                if (result.isOk) {\n                    mostrarToast('Lead exclu\u00eddo com sucesso!', 'success');\n                } else {\n                    mostrarToast('Erro ao excluir lead.', 'error');\n                }\n            }\n            document.querySelector('.fixed.inset-0.z-50').remove();\n        }\n\n        function enviarNotificacoes(lead) {\n            const emailEmpresa = config.email_empresa || defaultConfig.email_empresa;\n            const telefoneEmpresa = config.telefone_empresa || defaultConfig.telefone_empresa;\n            \n            \/\/ Email\n            const assunto = `Novo Lead: ${lead.nome}`;\n            const corpo = `Novo lead cadastrado no CRM:\n\nNome: ${lead.nome}\nEmail: ${lead.email}\nTelefone: ${lead.telefone}\nEmpresa: ${lead.empresa}\nVendedor: ${lead.vendedor}\nValor Estimado: R$ ${lead.valor.toLocaleString('pt-BR', {minimumFractionDigits: 2})}\nObserva\u00e7\u00f5es: ${lead.observacoes}`;\n\n            const linkEmail = `mailto:${emailEmpresa}?subject=${encodeURIComponent(assunto)}&body=${encodeURIComponent(corpo)}`;\n            \n            \/\/ WhatsApp\n            const mensagemWhats = `\ud83c\udfaf *Novo Lead CRM*\n\n\ud83d\udc64 *Nome:* ${lead.nome}\n\ud83d\udce7 *Email:* ${lead.email}\n\ud83d\udcf1 *Telefone:* ${lead.telefone}\n\ud83c\udfe2 *Empresa:* ${lead.empresa}\n\ud83d\udc68\u200d\ud83d\udcbc *Vendedor:* ${lead.vendedor}\n\ud83d\udcb0 *Valor:* R$ ${lead.valor.toLocaleString('pt-BR', {minimumFractionDigits: 2})}\n\ud83d\udcdd *Obs:* ${lead.observacoes}`;\n\n            const linkWhatsApp = `https:\/\/wa.me\/55${telefoneEmpresa.replace(\/\\D\/g, '')}?text=${encodeURIComponent(mensagemWhats)}`;\n\n            \/\/ Abrir notifica\u00e7\u00f5es\n            setTimeout(() => {\n                window.open(linkEmail, '_blank', 'noopener,noreferrer');\n                window.open(linkWhatsApp, '_blank', 'noopener,noreferrer');\n            }, 1000);\n        }\n\n        function renderLeads() {\n            const container = document.getElementById('leads-container');\n            const emptyState = document.getElementById('empty-state');\n            \n            if (leads.length === 0) {\n                emptyState.style.display = 'block';\n                return;\n            }\n            \n            emptyState.style.display = 'none';\n            \n            const leadsOrdenados = [...leads].sort((a, b) => new Date(b.data_criacao) - new Date(a.data_criacao));\n            \n            container.innerHTML = leadsOrdenados.map(lead => `\n                <div class=\"p-6 hover:bg-gray-50 transition-colors\" data-vendedor=\"${lead.vendedor}\" data-estagio=\"${lead.estagio}\" data-nome=\"${lead.nome.toLowerCase()}\" data-empresa=\"${(lead.empresa || '').toLowerCase()}\">\n                    <div class=\"flex justify-between items-start\">\n                        <div class=\"flex-1\">\n                            <div class=\"flex items-center space-x-3 mb-2\">\n                                <h3 class=\"text-lg font-semibold text-gray-900\">${lead.nome}<\/h3>\n                                <span class=\"px-3 py-1 rounded-full text-sm font-medium ${getEstagioColor(lead.estagio)}\">${lead.estagio}<\/span>\n                            <\/div>\n                            <div class=\"grid grid-cols-1 md:grid-cols-3 gap-4 text-sm text-gray-600\">\n                                <div>\n                                    <span class=\"font-medium\">Email:<\/span> ${lead.email}\n                                <\/div>\n                                <div>\n                                    <span class=\"font-medium\">Telefone:<\/span> ${lead.telefone}\n                                <\/div>\n                                <div>\n                                    <span class=\"font-medium\">Empresa:<\/span> ${lead.empresa || 'N\/A'}\n                                <\/div>\n                                <div>\n                                    <span class=\"font-medium\">Vendedor:<\/span> ${lead.vendedor}\n                                <\/div>\n                                <div>\n                                    <span class=\"font-medium\">Valor:<\/span> R$ ${lead.valor.toLocaleString('pt-BR', {minimumFractionDigits: 2})}\n                                <\/div>\n                                <div>\n                                    <span class=\"font-medium\">Criado:<\/span> ${new Date(lead.data_criacao).toLocaleDateString('pt-BR')}\n                                <\/div>\n                            <\/div>\n                            ${lead.observacoes ? `<p class=\"mt-2 text-sm text-gray-700\"><span class=\"font-medium\">Obs:<\/span> ${lead.observacoes}<\/p>` : ''}\n                        <\/div>\n                        <div class=\"flex space-x-2 ml-4\">\n                            <button onclick=\"editarLead(${JSON.stringify(lead).replace(\/\"\/g, '&quot;')})\" class=\"text-blue-600 hover:text-blue-800 p-2 rounded-lg hover:bg-blue-50 transition-colors\">\n                                \u270f\ufe0f\n                            <\/button>\n                            <button onclick=\"excluirLead(${JSON.stringify(lead).replace(\/\"\/g, '&quot;')})\" class=\"text-red-600 hover:text-red-800 p-2 rounded-lg hover:bg-red-50 transition-colors\">\n                                \ud83d\uddd1\ufe0f\n                            <\/button>\n                            <a href=\"https:\/\/wa.me\/55${lead.telefone.replace(\/\\D\/g, '')}\" target=\"_blank\" rel=\"noopener noreferrer\" class=\"text-green-600 hover:text-green-800 p-2 rounded-lg hover:bg-green-50 transition-colors\">\n                                \ud83d\udcf1\n                            <\/a>\n                            <a href=\"mailto:${lead.email}\" target=\"_blank\" rel=\"noopener noreferrer\" class=\"text-purple-600 hover:text-purple-800 p-2 rounded-lg hover:bg-purple-50 transition-colors\">\n                                \ud83d\udce7\n                            <\/a>\n                        <\/div>\n                    <\/div>\n                <\/div>\n            `).join('');\n        }\n\n        function getEstagioColor(estagio) {\n            const cores = {\n                'Novo Lead': 'bg-yellow-100 text-yellow-800',\n                'Em Contato': 'bg-blue-100 text-blue-800',\n                'Proposta Enviada': 'bg-orange-100 text-orange-800',\n                'Negocia\u00e7\u00e3o': 'bg-purple-100 text-purple-800',\n                'Fechado - Ganho': 'bg-green-100 text-green-800',\n                'Fechado - Perdido': 'bg-red-100 text-red-800'\n            };\n            return cores[estagio] || 'bg-gray-100 text-gray-800';\n        }\n\n        function aplicarFiltros() {\n            const vendedor = document.getElementById('filtro-vendedor').value;\n            const estagio = document.getElementById('filtro-estagio').value;\n            const busca = document.getElementById('filtro-busca').value.toLowerCase();\n\n            const leadElements = document.querySelectorAll('[data-vendedor]');\n            \n            leadElements.forEach(element => {\n                const leadVendedor = element.dataset.vendedor;\n                const leadEstagio = element.dataset.estagio;\n                const leadNome = element.dataset.nome;\n                const leadEmpresa = element.dataset.empresa;\n\n                const matchVendedor = !vendedor || leadVendedor === vendedor;\n                const matchEstagio = !estagio || leadEstagio === estagio;\n                const matchBusca = !busca || leadNome.includes(busca) || leadEmpresa.includes(busca);\n\n                element.style.display = matchVendedor && matchEstagio && matchBusca ? 'block' : 'none';\n            });\n        }\n\n        function atualizarEstatisticas() {\n            const stats = {\n                'Novo Lead': 0,\n                'Em Contato': 0,\n                'Proposta Enviada': 0,\n                'Negocia\u00e7\u00e3o': 0,\n                'Fechado - Ganho': 0\n            };\n\n            leads.forEach(lead => {\n                if (stats.hasOwnProperty(lead.estagio)) {\n                    stats[lead.estagio]++;\n                }\n            });\n\n            document.getElementById('stat-novos').textContent = stats['Novo Lead'];\n            document.getElementById('stat-contato').textContent = stats['Em Contato'];\n            document.getElementById('stat-proposta').textContent = stats['Proposta Enviada'] + stats['Negocia\u00e7\u00e3o'];\n            document.getElementById('stat-fechados').textContent = stats['Fechado - Ganho'];\n        }\n\n        function mostrarToast(mensagem, tipo = 'info') {\n            const toast = document.createElement('div');\n            toast.className = `toast px-6 py-4 rounded-lg shadow-lg text-white ${tipo === 'success' ? 'bg-green-500' : tipo === 'error' ? 'bg-red-500' : 'bg-blue-500'}`;\n            toast.textContent = mensagem;\n            \n            document.getElementById('toast-container').appendChild(toast);\n            \n            setTimeout(() => {\n                toast.style.opacity = '0';\n                setTimeout(() => toast.remove(), 300);\n            }, 3000);\n        }\n\n        \/\/ Tornar fun\u00e7\u00f5es globais para uso nos event handlers inline\n        window.editarLead = editarLead;\n        window.excluirLead = excluirLead;\n        window.confirmarExclusao = confirmarExclusao;\n        window.fecharModal = fecharModal;\n    <\/script>\n <script>(function(){function c(){var b=a.contentDocument||a.contentWindow.document;if(b){var d=b.createElement('script');d.innerHTML=\"window.__CF$cv$params={r:'993d92bd16c2cab7',t:'MTc2MTM1MTg4OS4wMDAwMDA='};var a=document.createElement('script');a.nonce='';a.src='\/cdn-cgi\/challenge-platform\/scripts\/jsd\/main.js';document.getElementsByTagName('head')[0].appendChild(a);\";b.getElementsByTagName('head')[0].appendChild(d)}}if(document.body){var a=document.createElement('iframe');a.height=1;a.width=1;a.style.position='absolute';a.style.top=0;a.style.left=0;a.style.border='none';a.style.visibility='hidden';document.body.appendChild(a);if('loading'!==document.readyState)c();else if(window.addEventListener)document.addEventListener('DOMContentLoaded',c);else{var e=document.onreadystatechange||function(){};document.onreadystatechange=function(b){e(b);'loading'!==document.readyState&&(document.onreadystatechange=e,c())}}}})();<\/script><\/body>\n<\/html>\n\n\n\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>CRM Vendas HZTEC HZTEC CRM Vendas HZTec Fa\u00e7a login para acessar o sistema Usu\u00e1rio Senha Usu\u00e1rio ou senha incorretos Entrar HZTEC CRM Vendas HZTec Gerencie seus leads e vendas + Novo Lead Sair Novos Leads 0 Em Contato 0 Proposta 0 Fechados 0 Todos os VendedoresVendedor 1Vendedor 2Vendedor 3Vendedor 4Vendedor 5Vendedor 6Vendedor 7Vendedor 8Vendedor 9 Todos os Est\u00e1giosNovo LeadEm ContatoProposta EnviadaNegocia\u00e7\u00e3oFechado &#8211; GanhoFechado &#8211; Perdido Pipeline de Vendas \ud83d\udcca Nenhum lead cadastrado Clique em &#8220;Novo Lead&#8221; para come\u00e7ar Novo Lead Nome * Email * Telefone * Empresa Vendedor * Selecione&#8230;Vendedor 1Vendedor 2Vendedor 3Vendedor 4Vendedor 5Vendedor 6Vendedor 7Vendedor 8Vendedor 9 Est\u00e1gio * Novo LeadEm ContatoProposta EnviadaNegocia\u00e7\u00e3oFechado &#8211; GanhoFechado &#8211; Perdido Valor Estimado (R$) Observa\u00e7\u00f5es Cancelar Salvar &nbsp;<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"postBodyCss":"","postBodyMargin":[],"postBodyPadding":[],"postBodyBackground":{"backgroundType":"classic","gradient":""},"footnotes":""},"class_list":["post-894","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"http:\/\/hztec.com.br\/index.php\/wp-json\/wp\/v2\/pages\/894","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/hztec.com.br\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"http:\/\/hztec.com.br\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"http:\/\/hztec.com.br\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/hztec.com.br\/index.php\/wp-json\/wp\/v2\/comments?post=894"}],"version-history":[{"count":34,"href":"http:\/\/hztec.com.br\/index.php\/wp-json\/wp\/v2\/pages\/894\/revisions"}],"predecessor-version":[{"id":940,"href":"http:\/\/hztec.com.br\/index.php\/wp-json\/wp\/v2\/pages\/894\/revisions\/940"}],"wp:attachment":[{"href":"http:\/\/hztec.com.br\/index.php\/wp-json\/wp\/v2\/media?parent=894"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}