{"id":1624,"date":"2024-08-14T01:00:01","date_gmt":"2024-08-14T04:00:01","guid":{"rendered":"https:\/\/gleztin.com.ar\/?page_id=1624"},"modified":"2024-08-15T05:02:12","modified_gmt":"2024-08-15T08:02:12","slug":"1624-2","status":"publish","type":"page","link":"https:\/\/gleztin.com.ar\/index.php\/1624-2\/","title":{"rendered":"test"},"content":{"rendered":"\n<!DOCTYPE html>\n<html lang=\"es\">\n<head>\n    <meta charset=\"UTF-8\">\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n    <title>Generador de Cupones<\/title>\n    <style>\n        body {\n            font-family: Arial, sans-serif;\n            margin: 20px;\n            padding: 20px;\n        }\n        .container {\n            max-width: 600px;\n            margin: 0 auto;\n        }\n        select, button {\n            display: block;\n            width: 100%;\n            padding: 10px;\n            margin-bottom: 10px;\n            font-size: 16px;\n        }\n        button {\n            background-color: #007bff;\n            color: white;\n            border: none;\n            cursor: pointer;\n        }\n        button:hover {\n            background-color: #0056b3;\n        }\n        #result {\n            margin-top: 20px;\n        }\n    <\/style>\n<\/head>\n<body>\n    <div class=\"container\">\n        <h1>Generador de Cupones<\/h1>\n        <form id=\"couponForm\">\n            <label for=\"clientSelect\">Selecciona un Cliente:<\/label>\n            <select id=\"clientSelect\" name=\"clientSelect\" required><\/select>\n\n            <button type=\"submit\">Generar C\u00f3digo<\/button>\n        <\/form>\n        <div id=\"result\"><\/div>\n    <\/div>\n\n    <script>\n        const clientSelect = document.getElementById('clientSelect');\n\n        \/\/ Fetch the list of clients from Google Sheets\n        fetch('https:\/\/sheets.googleapis.com\/v4\/spreadsheets\/YOUR_SHEET_ID\/values\/Clientes?key=YOUR_API_KEY')\n            .then(response => response.json())\n            .then(data => {\n                const clients = data.values;\n                clients.forEach(client => {\n                    const option = document.createElement('option');\n                    option.value = client[0];\n                    option.textContent = client[0];\n                    clientSelect.appendChild(option);\n                });\n            })\n            .catch(error => console.error('Error fetching clients:', error));\n\n        document.getElementById('couponForm').addEventListener('submit', function(e) {\n            e.preventDefault();\n\n            const selectedClient = clientSelect.value;\n            const couponCode = generateCouponCode();\n            const expirationDate = new Date();\n            expirationDate.setMonth(expirationDate.getMonth() + 1); \/\/ Set expiration date to 1 month from now\n\n            const formData = new FormData();\n            formData.append('entry.1234567890', selectedClient); \/\/ Reemplaza con el ID del campo para el cliente\n            formData.append('entry.0987654321', couponCode); \/\/ Reemplaza con el ID del campo para el c\u00f3digo\n            formData.append('entry.1122334455', expirationDate.toISOString().split('T')[0]); \/\/ Reemplaza con el ID del campo para la fecha de expiraci\u00f3n\n\n            fetch('https:\/\/docs.google.com\/forms\/d\/e\/13oV3Uhp2xfftc-VbSCaxOhAHezwQ_F0YzvElPCZag_c\/formResponse', {\n                method: 'POST',\n                body: formData\n            })\n            .then(response => response.text())\n            .then(data => {\n                document.getElementById('result').innerHTML = '\u00a1Cup\u00f3n generado con \u00e9xito! C\u00f3digo: ' + couponCode;\n            })\n            .catch(error => {\n                console.error('Error:', error);\n                document.getElementById('result').innerHTML = 'Hubo un error al generar el cup\u00f3n.';\n            });\n        });\n\n        function generateCouponCode() {\n            return 'COUPON-' + Math.random().toString(36).substr(2, 8).toUpperCase();\n        }\n    <\/script>\n<\/body>\n<\/html>\n\n","protected":false},"excerpt":{"rendered":"<p>Generador de Cupones Generador de Cupones Selecciona un Cliente: Generar C\u00f3digo<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_acf_changed":false,"_joinchat":[],"footnotes":""},"class_list":["post-1624","page","type-page","status-publish","hentry"],"blocksy_meta":[],"acf":[],"_links":{"self":[{"href":"https:\/\/gleztin.com.ar\/index.php\/wp-json\/wp\/v2\/pages\/1624","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gleztin.com.ar\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/gleztin.com.ar\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/gleztin.com.ar\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/gleztin.com.ar\/index.php\/wp-json\/wp\/v2\/comments?post=1624"}],"version-history":[{"count":9,"href":"https:\/\/gleztin.com.ar\/index.php\/wp-json\/wp\/v2\/pages\/1624\/revisions"}],"predecessor-version":[{"id":1633,"href":"https:\/\/gleztin.com.ar\/index.php\/wp-json\/wp\/v2\/pages\/1624\/revisions\/1633"}],"wp:attachment":[{"href":"https:\/\/gleztin.com.ar\/index.php\/wp-json\/wp\/v2\/media?parent=1624"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}