{"id":50,"date":"2026-07-26T11:39:08","date_gmt":"2026-07-26T11:39:08","guid":{"rendered":"https:\/\/abhyashelp.com\/?page_id=50"},"modified":"2026-07-26T11:47:24","modified_gmt":"2026-07-26T11:47:24","slug":"teacher-registration","status":"publish","type":"page","link":"https:\/\/abhyashelp.com\/?page_id=50","title":{"rendered":"Teacher Registration"},"content":{"rendered":"\t\t<div data-elementor-type=\"wp-page\" data-elementor-id=\"50\" class=\"elementor elementor-50\">\n\t\t\t\t<div class=\"elementor-element elementor-element-e032270 e-flex e-con-boxed e-con e-parent\" data-id=\"e032270\" data-element_type=\"container\" data-e-type=\"container\">\n\t\t\t\t\t<div class=\"e-con-inner\">\n\t\t\t\t<div class=\"elementor-element elementor-element-d4ebdd2 elementor-widget elementor-widget-html\" data-id=\"d4ebdd2\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"html.default\">\n\t\t\t\t\t<style>\r\n\/* CSS Reset & Styling for Elementor *\/\r\n.tf-container * {\r\n    box-sizing: border-box;\r\n}\r\n\r\n.tf-container {\r\n    font-family: 'Noto Sans Gujarati', Arial, sans-serif;\r\n    max-width: 600px;\r\n    margin: 0 auto;\r\n    padding: 20px;\r\n    background: #ffffff;\r\n    border-radius: 10px;\r\n    box-shadow: 0 4px 12px rgba(0,0,0,0.1);\r\n}\r\n\r\n.tf-container h2 {\r\n    text-align: center;\r\n    color: #1976d2;\r\n    margin-bottom: 20px;\r\n}\r\n\r\n.tf-group {\r\n    margin-bottom: 15px;\r\n}\r\n\r\n.tf-group label {\r\n    display: block;\r\n    font-weight: bold;\r\n    margin-bottom: 5px;\r\n}\r\n\r\n.tf-group input {\r\n    width: 100%;\r\n    padding: 10px;\r\n    border: 1px solid #ccc;\r\n    border-radius: 5px;\r\n    font-size: 15px;\r\n}\r\n\r\n.tf-btn-group {\r\n    display: flex;\r\n    gap: 10px;\r\n    flex-wrap: wrap;\r\n    margin-top: 15px;\r\n}\r\n\r\n.tf-btn {\r\n    padding: 10px 18px;\r\n    border: none;\r\n    border-radius: 5px;\r\n    cursor: pointer;\r\n    font-weight: bold;\r\n    color: #fff;\r\n    transition: background 0.3s ease;\r\n}\r\n\r\n.btn-save { background: #28a745; }\r\n.btn-save:hover { background: #218838; }\r\n\r\n.btn-clear { background: #6c757d; }\r\n.btn-clear:hover { background: #5a6268; }\r\n\r\n.btn-search { background: #007bff; }\r\n.btn-search:hover { background: #0069d9; }\r\n\r\n.btn-edit { background: #ffc107; color: #000; }\r\n.btn-edit:hover { background: #e0a800; }\r\n\r\n.btn-delete { background: #dc3545; }\r\n.btn-delete:hover { background: #c82333; }\r\n\r\n\/* \u2705 Overlay Spinner Styling *\/\r\n#savingOverlay {\r\n    position: fixed;\r\n    top: 0;\r\n    left: 0;\r\n    width: 100%;\r\n    height: 100%;\r\n    background: rgba(0, 0, 0, 0.5);\r\n    display: none;\r\n    justify-content: center;\r\n    align-items: center;\r\n    z-index: 99999;\r\n}\r\n\r\n#savingBox {\r\n    background: #fff;\r\n    padding: 25px 40px;\r\n    border-radius: 8px;\r\n    font-size: 18px;\r\n    font-weight: bold;\r\n    color: #333;\r\n    box-shadow: 0 4px 15px rgba(0,0,0,0.2);\r\n}\r\n\r\n\/* \u2705 Hidden PDF Container *\/\r\n#pdfContainer {\r\n    position: absolute;\r\n    top: -9999px;\r\n    left: -9999px;\r\n    width: 600px;\r\n    background: #fff;\r\n    padding: 30px;\r\n    color: #000;\r\n}\r\n<\/style>\r\n\r\n<!-- Google Font Loader -->\r\n<link href=\"https:\/\/fonts.googleapis.com\/css2?family=Noto+Sans+Gujarati:wght@400;700&display=swap\" rel=\"stylesheet\">\r\n\r\n<!-- jsPDF & html2canvas -->\r\n<script src=\"https:\/\/cdnjs.cloudflare.com\/ajax\/libs\/jspdf\/2.5.1\/jspdf.umd.min.js\"><\/script>\r\n<script src=\"https:\/\/cdnjs.cloudflare.com\/ajax\/libs\/html2canvas\/1.4.1\/html2canvas.min.js\"><\/script>\r\n\r\n<div class=\"tf-container\">\r\n    <h2>Teacher Registration<\/h2>\r\n\r\n    <form id=\"teacherForm\" onsubmit=\"return false;\">\r\n        <div class=\"tf-group\">\r\n            <label>Teacher Code: <span id=\"codePreview\" style=\"color:#1976d2;\">\u2014<\/span><\/label>\r\n        <\/div>\r\n\r\n        <div class=\"tf-group\">\r\n            <label for=\"teacherName\">Teacher Name:<\/label>\r\n            <input id=\"teacherName\" type=\"text\" placeholder=\"\u0ab6\u0abf\u0a95\u0acd\u0ab7\u0a95\u0aa8\u0ac1\u0a82 \u0aa8\u0abe\u0aae \u0ab2\u0a96\u0acb\" \/>\r\n        <\/div>\r\n\r\n        <div class=\"tf-group\">\r\n            <label for=\"schoolName\">School Name:<\/label>\r\n            <input id=\"schoolName\" type=\"text\" placeholder=\"\u0ab6\u0abe\u0ab3\u0abe\u0aa8\u0ac1\u0a82 \u0aa8\u0abe\u0aae \u0ab2\u0a96\u0acb\" \/>\r\n        <\/div>\r\n\r\n        <div class=\"tf-btn-group\">\r\n            <button id=\"saveBtn\" class=\"tf-btn btn-save\" type=\"button\">Save Teacher<\/button>\r\n            <button id=\"clearBtn\" class=\"tf-btn btn-clear\" type=\"button\">Clear<\/button>\r\n        <\/div>\r\n\r\n        <hr style=\"margin: 20px 0; border: 0; border-top: 1px solid #eee;\" \/>\r\n\r\n        <div class=\"tf-group\">\r\n            <label for=\"searchCode\">Search Teacher:<\/label>\r\n            <div style=\"display: flex; gap: 8px;\">\r\n                <input id=\"searchCode\" placeholder=\"Enter Code\" type=\"text\" \/>\r\n                <button id=\"searchBtn\" class=\"tf-btn btn-search\" type=\"button\">Search<\/button>\r\n            <\/div>\r\n        <\/div>\r\n\r\n        <div class=\"tf-btn-group\">\r\n            <button id=\"editBtn\" class=\"tf-btn btn-edit\" style=\"display: none;\" type=\"button\">Edit Teacher<\/button>\r\n            <button id=\"deleteBtn\" class=\"tf-btn btn-delete\" style=\"display: none;\" type=\"button\">Delete Teacher<\/button>\r\n        <\/div>\r\n    <\/form>\r\n<\/div>\r\n\r\n<!-- Saving Overlay -->\r\n<div id=\"savingOverlay\">\r\n    <div id=\"savingBox\">\u0a95\u0ac3\u0aaa\u0abe \u0a95\u0ab0\u0ac0\u0aa8\u0ac7 \u0ab0\u0abe\u0ab9 \u0a9c\u0ac1\u0a93... \u0aa1\u0ac7\u0a9f\u0abe \u0aaa\u0acd\u0ab0\u0acb\u0ab8\u0ac7\u0ab8 \u0aa5\u0a88 \u0ab0\u0ab9\u0acd\u0aaf\u0acb \u0a9b\u0ac7...<\/div>\r\n<\/div>\r\n\r\n<!-- Hidden PDF Template -->\r\n<div id=\"pdfContainer\" aria-hidden=\"true\"><\/div>\r\n\r\n<script>\r\nconst API_URL = \"https:\/\/script.google.com\/macros\/s\/AKfycbyiT1pnGkEJ663t8S0g1cWe_iHKsPeevBAjCVDWLqtxY3EwFMYWBDlphQyhfUpk1untBA\/exec\"; \r\nlet currentEditCode = null;\r\n\r\nconst MSG_REGISTERED = \"\u0aa4\u0aae\u0abe\u0ab0\u0ac1\u0a82 \u0ab0\u0a9c\u0ac0\u0ab8\u0acd\u0a9f\u0acd\u0ab0\u0ac7\u0ab6\u0aa8 \u0ab8\u0aab\u0ab3\u0aa4\u0abe\u0aaa\u0ac2\u0ab0\u0acd\u0ab5\u0a95 \u0aa5\u0a88 \u0a97\u0aaf\u0ac1\u0a82 \u0a9b\u0ac7, \u0aa4\u0aae\u0abe\u0ab0\u0acb \u0ab6\u0abf\u0a95\u0acd\u0ab7\u0a95 \u0a95\u0acb\u0aa1: \";\r\n\r\nfunction apiCall(params){\r\n    return fetch(API_URL + '?' + new URLSearchParams(params))\r\n        .then(res => res.json())\r\n        .catch(err => {\r\n            hideSaving();\r\n            alert(\"\u0aad\u0ac2\u0ab2 \u0a86\u0ab5\u0ac0 \u0a9b\u0ac7! \u0a95\u0ac3\u0aaa\u0abe \u0a95\u0ab0\u0ac0\u0aa8\u0ac7 \u0aab\u0ab0\u0ac0 \u0aaa\u0acd\u0ab0\u0aaf\u0abe\u0ab8 \u0a95\u0ab0\u0acb.\");\r\n            console.error(err);\r\n        });\r\n}\r\n\r\nfunction showSaving(){\r\n    document.getElementById('savingOverlay').style.display = \"flex\";\r\n}\r\n\r\nfunction hideSaving(){\r\n    document.getElementById('savingOverlay').style.display = \"none\";\r\n}\r\n\r\nfunction showCode(){\r\n    apiCall({action: 'getNextTeacherCode'}).then(c => {\r\n        if(c) document.getElementById('codePreview').textContent = c;\r\n    });\r\n}\r\n\r\nfunction clearForm(){\r\n    document.getElementById('teacherName').value = '';\r\n    document.getElementById('schoolName').value = '';\r\n    document.getElementById('searchCode').value = '';\r\n    currentEditCode = null;\r\n    document.getElementById('codePreview').textContent = '\u2014';\r\n    document.getElementById('editBtn').style.display = \"none\";\r\n    document.getElementById('deleteBtn').style.display = \"none\";\r\n    showCode();\r\n}\r\n\r\nasync function generatePDF(teacher){\r\n    const {code, name, school} = teacher;\r\n    const c = document.getElementById(\"pdfContainer\");\r\n\r\n    c.innerHTML = `\r\n        <div style=\"text-align:center; border:2px solid #1976d2; padding:20px; font-family:'Noto Sans Gujarati', sans-serif;\">\r\n            <h2 style=\"color:#1976d2; margin-bottom:15px;\">\u0ab6\u0abf\u0a95\u0acd\u0ab7\u0a95 \u0aa8\u0acb\u0a82\u0aa7\u0aa3\u0ac0 \u0aaa\u0aa4\u0acd\u0ab0\u0a95<\/h2>\r\n            <hr><br>\r\n            <p style=\"font-size:18px; text-align:left;\"><b>\u0ab6\u0abf\u0a95\u0acd\u0ab7\u0a95 \u0a95\u0acb\u0aa1:<\/b> ${code}<\/p>\r\n            <p style=\"font-size:18px; text-align:left;\"><b>\u0ab6\u0abf\u0a95\u0acd\u0ab7\u0a95\u0aa8\u0ac1\u0a82 \u0aa8\u0abe\u0aae:<\/b> ${name}<\/p>\r\n            <p style=\"font-size:18px; text-align:left;\"><b>\u0ab6\u0abe\u0ab3\u0abe\u0aa8\u0ac1\u0a82 \u0aa8\u0abe\u0aae:<\/b> ${school}<\/p>\r\n        <\/div>\r\n    `;\r\n\r\n    await document.fonts.ready;\r\n    \r\n    html2canvas(c, { scale: 2 }).then(canvas => {\r\n        const { jsPDF } = window.jspdf;\r\n        const pdf = new jsPDF('p', 'pt', 'a4');\r\n        const img = canvas.toDataURL(\"image\/png\");\r\n        const pageWidth = pdf.internal.pageSize.getWidth();\r\n        const pageHeight = pdf.internal.pageSize.getHeight();\r\n        const ratio = Math.min(pageWidth \/ canvas.width, pageHeight \/ canvas.height);\r\n        \r\n        pdf.addImage(img, 'PNG', 20, 20, canvas.width * ratio, canvas.height * ratio);\r\n        pdf.save(`Teacher_${code}.pdf`);\r\n    });\r\n}\r\n\r\ndocument.getElementById('saveBtn').addEventListener('click', () => {\r\n    const name = document.getElementById('teacherName').value.trim();\r\n    const school = document.getElementById('schoolName').value.trim();\r\n    if(!name){ alert('\u0a95\u0ac3\u0aaa\u0abe \u0a95\u0ab0\u0ac0\u0aa8\u0ac7 \u0ab6\u0abf\u0a95\u0acd\u0ab7\u0a95\u0aa8\u0ac1\u0a82 \u0aa8\u0abe\u0aae \u0ab2\u0a96\u0acb'); return; }\r\n\r\n    showSaving();\r\n\r\n    if(currentEditCode){\r\n        apiCall({action: 'editTeacher', code: currentEditCode, name, school}).then(res => {\r\n            hideSaving();\r\n            alert('\u0a85\u0aaa\u0aa1\u0ac7\u0a9f \u0aa5\u0a88 \u0a97\u0aaf\u0ac1\u0a82: ' + res.code);\r\n            generatePDF(res);\r\n            clearForm();\r\n        });\r\n    } else {\r\n        apiCall({action: 'addTeacher', name, school}).then(res => {\r\n            hideSaving();\r\n            alert(MSG_REGISTERED + res.code);\r\n            generatePDF(res);\r\n            clearForm();\r\n        });\r\n    }\r\n});\r\n\r\ndocument.getElementById('clearBtn').addEventListener('click', clearForm);\r\n\r\ndocument.getElementById('searchBtn').addEventListener('click', () => {\r\n    const code = document.getElementById('searchCode').value.trim();\r\n    if(!code){ alert('\u0a95\u0acb\u0aa1 \u0aa6\u0abe\u0a96\u0ab2 \u0a95\u0ab0\u0acb'); return; }\r\n    \r\n    showSaving();\r\n    apiCall({action: 'getTeachers'}).then(rows => {\r\n        hideSaving();\r\n        const found = rows ? rows.find(r => r.code === code) : null;\r\n        if(found){\r\n            document.getElementById('teacherName').value = found.name;\r\n            document.getElementById('schoolName').value = found.school;\r\n            document.getElementById('codePreview').textContent = found.code;\r\n            currentEditCode = found.code;\r\n            document.getElementById('editBtn').style.display = \"inline-block\";\r\n            document.getElementById('deleteBtn').style.display = \"inline-block\";\r\n            alert('\u0ab6\u0abf\u0a95\u0acd\u0ab7\u0a95 \u0aae\u0ab3\u0ac0 \u0a97\u0aaf\u0abe: ' + found.code);\r\n        } else {\r\n            alert('\u0ab6\u0abf\u0a95\u0acd\u0ab7\u0a95 \u0aae\u0ab3\u0acd\u0aaf\u0abe \u0aa8\u0aa5\u0ac0');\r\n        }\r\n    });\r\n});\r\n\r\ndocument.getElementById('editBtn').addEventListener('click', () => {\r\n    if(currentEditCode){\r\n        const name = document.getElementById('teacherName').value.trim();\r\n        const school = document.getElementById('schoolName').value.trim();\r\n        showSaving();\r\n        apiCall({action: 'editTeacher', code: currentEditCode, name, school}).then(res => {\r\n            hideSaving();\r\n            alert('\u0ab8\u0ac1\u0aa7\u0abe\u0ab0\u0acb \u0aa5\u0a88 \u0a97\u0aaf\u0acb: ' + res.code);\r\n            generatePDF(res);\r\n            clearForm();\r\n        });\r\n    }\r\n});\r\n\r\ndocument.getElementById('deleteBtn').addEventListener('click', () => {\r\n    if(currentEditCode && confirm('\u0ab6\u0ac1\u0a82 \u0aa4\u0aae\u0ac7 \u0a86 \u0ab6\u0abf\u0a95\u0acd\u0ab7\u0a95\u0aa8\u0acb \u0aa1\u0ac7\u0a9f\u0abe \u0a95\u0abe\u0aa2\u0ac0 \u0aa8\u0abe\u0a96\u0ab5\u0abe \u0aae\u0abe\u0a97\u0acb \u0a9b\u0acb?')){\r\n        showSaving();\r\n        apiCall({action: 'deleteTeacher', code: currentEditCode}).then(res => {\r\n            hideSaving();\r\n            if(res && res.success){ \r\n                alert('\u0aa1\u0ac7\u0a9f\u0abe \u0aa1\u0abf\u0ab2\u0ac0\u0a9f \u0aa5\u0a88 \u0a97\u0aaf\u0acb: ' + currentEditCode); \r\n                clearForm();\r\n            } else {\r\n                alert('\u0aa1\u0abf\u0ab2\u0ac0\u0a9f \u0a95\u0ab0\u0ab5\u0abe\u0aae\u0abe\u0a82 \u0aad\u0ac2\u0ab2 \u0a86\u0ab5\u0ac0');\r\n            }\r\n        });\r\n    }\r\n});\r\n\r\n\/\/ Initial Load\r\nshowCode();\r\n<\/script>\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t","protected":false},"excerpt":{"rendered":"<p>Teacher Registration Teacher Code: \u2014 Teacher Name: School Name: Save Teacher Clear Search Teacher: Search Edit Teacher Delete<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-50","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/abhyashelp.com\/index.php?rest_route=\/wp\/v2\/pages\/50","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/abhyashelp.com\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/abhyashelp.com\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/abhyashelp.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/abhyashelp.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=50"}],"version-history":[{"count":7,"href":"https:\/\/abhyashelp.com\/index.php?rest_route=\/wp\/v2\/pages\/50\/revisions"}],"predecessor-version":[{"id":57,"href":"https:\/\/abhyashelp.com\/index.php?rest_route=\/wp\/v2\/pages\/50\/revisions\/57"}],"wp:attachment":[{"href":"https:\/\/abhyashelp.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=50"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}