{"id":534,"date":"2025-10-09T15:26:40","date_gmt":"2025-10-09T13:26:40","guid":{"rendered":"https:\/\/www.cofleon.es\/?page_id=534"},"modified":"2025-10-09T15:26:40","modified_gmt":"2025-10-09T13:26:40","slug":"acceso-privado","status":"publish","type":"page","link":"https:\/\/www.cofleon.es\/index.php\/acceso-privado\/","title":{"rendered":"Acceso Privado"},"content":{"rendered":"<!DOCTYPE html>\n<html lang=\"es\">\n<head>\n  <meta charset=\"utf-8\" \/>\n  <title>Login<\/title>\n  <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" \/>\n  <script src=\"https:\/\/code.jquery.com\/jquery-3.6.0.min.js\"><\/script>\n  <style>\n    body { font-family: Arial, Helvetica, sans-serif; }\n    .CabeceraLogo { display: none!important; }\n\n    #loginForm { margin: 10% auto!important; }\n\n    form {\n      border: none;\n      border-radius: 10px;\n      margin: 20% auto;\n      max-width: 400px;\n      padding: 10px;\n      text-align: center;\n    }\n\n    input[type=text], input[type=password] {\n      padding: 15px;\n      width: 100%;\n      margin: 4px 0;\n      display: inline-block;\n      border: none;\n      box-sizing: border-box;\n    }\n\n    button {\n      background-color: #4CAF50;\n      color: white;\n      padding: 14px 20px;\n      margin: 8px 0;\n      border: none;\n      cursor: pointer;\n      width: 100%;\n    }\n    button:hover { opacity: 0.8; }\n\n    #errorMsg { color: red; min-height: 1.2em; }\n  <\/style>\n<\/head>\n<body>\n\n  <form id=\"loginForm\" autocomplete=\"on\" novalidate>\n    <input type=\"text\" name=\"username\" placeholder=\"Ingrese su usuario\" required \/>\n    <input type=\"password\" name=\"password\" placeholder=\"Ingrese su contrase\u00f1a\" required \/>\n    <button type=\"submit\">Acceder<\/button>\n    <p id=\"errorMsg\"><\/p>\n  <\/form>\n\n  <script>\n    $(function () {\n      const $form = $('#loginForm');\n      const $btn  = $form.find('button[type=submit]');\n      const $err  = $('#errorMsg');\n\n      function showError(msg) {\n        $err.text(msg || 'No autorizado o error de servidor.');\n      }\n\n      $form.on('submit', function (e) {\n        e.preventDefault();\n        $err.text('');\n        $btn.prop('disabled', true).text('Conectando...');\n\n        $.ajax({\n          type: 'POST',\n          url: '..\/..\/loginErp.php',   \/\/ <-- AJUSTA esta ruta si tu PHP est\u00e1 en otra carpeta\n          data: $form.serialize(),\n          dataType: 'json'\n        })\n        .done(function (r) {\n          if (r && r.status === 'success' && r.redirect) {\n            \/\/ Navega exactamente a la URL GET con los hashes (igual que pegarla en la barra)\n            window.location.assign(r.redirect);\n          } else {\n            showError((r && r.message) || 'No autorizado o flujo no aceptado por el servidor.');\n          }\n        })\n        .fail(function () {\n          showError('Error de red o servidor. Int\u00e9ntalo de nuevo.');\n        })\n        .always(function () {\n          $btn.prop('disabled', false).text('Acceder');\n        });\n      });\n    });\n  <\/script>\n\n<\/body>\n<\/html>\n\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":2,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"page-full-width.php","meta":{"_acf_changed":false,"footnotes":""},"class_list":["post-534","page","type-page","status-publish","hentry"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.cofleon.es\/index.php\/wp-json\/wp\/v2\/pages\/534","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.cofleon.es\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.cofleon.es\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.cofleon.es\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.cofleon.es\/index.php\/wp-json\/wp\/v2\/comments?post=534"}],"version-history":[{"count":1,"href":"https:\/\/www.cofleon.es\/index.php\/wp-json\/wp\/v2\/pages\/534\/revisions"}],"predecessor-version":[{"id":535,"href":"https:\/\/www.cofleon.es\/index.php\/wp-json\/wp\/v2\/pages\/534\/revisions\/535"}],"wp:attachment":[{"href":"https:\/\/www.cofleon.es\/index.php\/wp-json\/wp\/v2\/media?parent=534"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}