1. Code.gs (Google Apps Script)

இந்தக் குறியீடு உங்கள் Spreadsheet இல் தரவுகளைச் சேமித்து, Admission Number ஐ உருவாக்கும்

function doGet() {

  return HtmlService.createHtmlOutputFromFile('Index')

      .setTitle('AS-SIRAJ MAHA VIDYALAYA - Admission 2026')

      .setXFrameOptionsMode(HtmlService.XFrameOptionsMode.ALLOWALL);

}


function processForm(formObject) {

  try {

    var ss = SpreadsheetApp.getActiveSpreadsheet();

    var sheet = ss.getSheetByName('Sheet1'); 

    var lastRow = sheet.getLastRow();

    

    // Admission Number உருவாக்கம்

    var appNo = "ASMV/ADM/2026/G" + (formObject.grade || "X") + "/" + (100 + lastRow);


    // பிழையைத் தவிர்க்க null செக் செய்த பின் UPPERCASE ஆக்குதல்

    var fName = formObject.fullName ? formObject.fullName.toUpperCase() : "";

    var iName = formObject.nameWithInitials ? formObject.nameWithInitials.toUpperCase() : "";


    sheet.appendRow([

      new Date(), 

      appNo, 

      formObject.grade,

      formObject.medium,

      fName,

      iName,

      formObject.address,

      formObject.gsDivision,

      formObject.gender,

      formObject.scholarshipMarks,

      formObject.fatherName,

      formObject.mobile,

      formObject.whatsapp,

      formObject.occupation

    ]);

    

    return {status: "Success", appNo: appNo};

  } catch (f) {

    return {status: "Error", message: f.toString()};

  }

}

2. Index.html (இருமொழிப் படிவம் & A4 PDF)

<!DOCTYPE html>

<html>

<head>

    <base target="_top">

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.5.1/jspdf.umd.min.js"></script>

    <script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf-autotable/3.5.25/jspdf.plugin.autotable.min.js"></script>

    <style>

        :root { --main: #00264d; }

        body { font-family: 'Segoe UI', Arial, sans-serif; background: #f4f7f6; padding: 10px; }

        .container { max-width: 800px; background: #fff; padding: 25px; border-radius: 8px; margin: auto; border-top: 8px solid var(--main); box-shadow: 0 4px 15px rgba(0,0,0,0.1); }

        .header { text-align: center; border-bottom: 2px solid var(--main); margin-bottom: 20px; padding-bottom: 10px; }

        .deadline { color: #d9534f; font-weight: bold; font-size: 14px; border: 1px dashed #d9534f; padding: 5px; display: inline-block; margin-top: 10px; }

        .section-title { background: #f4f4f4; padding: 8px; font-weight: bold; margin: 15px 0 10px 0; border-left: 4px solid var(--main); font-size: 13px; color: var(--main); }

        .grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }

        label { display: block; font-weight: 600; font-size: 12px; margin-bottom: 4px; color: #333; }

        input, select, textarea { width: 100%; padding: 10px; border: 1px solid #ccc; border-radius: 4px; font-size: 13px; box-sizing: border-box; }

        .btn { width: 100%; background: var(--main); color: #fff; padding: 15px; border: none; border-radius: 4px; font-size: 16px; font-weight: bold; cursor: pointer; margin-top: 20px; transition: 0.3s; }

        .btn:hover { background: #001a33; }

        #status { text-align: center; margin-top: 15px; font-weight: bold; }

        @media (max-width: 600px) { .grid { grid-template-columns: 1fr; } }

    </style>

</head>

<body>


<div class="container">

    <div class="header">

        <h1>KM/AK/AS-SIRAJ MAHA VIDYALAYA</h1>

        <p>Akkaraipattu - 01 | Academic Year 2026</p>

        <div class="deadline">விண்ணப்பம் முடியும் திகதி (Closing Date): 2026.01.31</div>

    </div>


    <form id="admissionForm" onsubmit="submitForm(event)">

        <div class="section-title">1.0 விண்ணப்பதாரியின் விபரங்கள் (Student Information)</div>

        <div class="grid">

            <div>

                <label>விண்ணப்பிக்கும் தரம் (Grade Applied) *</label>

                <select name="grade" id="grade" required>

                    <option value="6">6</option><option value="7">7</option><option value="8">8</option><option value="9">9</option><option value="10">10</option>

                </select>

            </div>

            <div>

                <label>மொழிமூலம் (Medium) *</label>

                <select name="medium" id="medium">

                    <option value="Tamil">Tamil</option><option value="English">English</option>

                </select>

            </div>

        </div>

        

        <div style="margin-top:10px;">

            <label>முழுப் பெயர் - ஆங்கிலத்தில் (Full Name in English - As per Birth Certificate) *</label>

            <input type="text" name="fullName" id="fullName" required placeholder="E.g. AAZIK HAFZI AHAMED">

        </div>

        

        <div style="margin-top:10px;">

            <label>பெயர் சுருக்கத்துடன் (Name with Initials in English) *</label>

            <input type="text" name="nameWithInitials" id="nameInitials" required placeholder="E.g. A. HAFZI AHAMED">

        </div>


        <div class="grid" style="margin-top:10px;">

            <div><label>G.S. பிரிவு (G.S. Division) *</label><input type="text" name="gsDivision" id="gsDiv" required></div>

            <div>

                <label>பாலினம் (Gender)</label>

                <select name="gender" id="gender">

                    <option value="Male">Male</option><option value="Female">Female</option>

                </select>

            </div>

        </div>


        <div style="margin-top:10px;"><label>வீட்டு முகவரி (Address) *</label><textarea name="address" id="address" rows="2" required></textarea></div>

        

        <div style="margin-top:10px;">

            <label>புலமைப்பரிசில் புள்ளிகள் (Scholarship Marks - For Grade 6 only)</label>

            <input type="number" name="scholarshipMarks" id="marks">

        </div>


        <div class="section-title">2.0 பெற்றோர் / பாதுகாவலர் விபரம் (Parent Details)</div>

        <div><label>தந்தையின் பெயர் - ஆங்கிலத்தில் (Father's Name in English) *</label><input type="text" name="fatherName" id="father" required></div>

        

        <div class="grid" style="margin-top:10px;">

            <div><label>தொலைபேசி இலக்கம் (Mobile No) *</label><input type="tel" name="mobile" id="mobile" required></div>

            <div><label>வாட்ஸ்அப் இலக்கம் (WhatsApp No)</label><input type="tel" name="whatsapp" id="whatsapp"></div>

        </div>

        

        <div style="margin-top:10px;"><label>தொழில் (Occupation)</label><input type="text" name="occupation" id="job"></div>


        <button type="submit" class="btn" id="sBtn">சமர்ப்பித்து PDF-ஐப் பெறுக (SUBMIT & DOWNLOAD PDF)</button>

    </form>

    <div id="status"></div>

</div>


<script>

    function submitForm(e) {

        e.preventDefault();

        const btn = document.getElementById('sBtn');

        btn.disabled = true; btn.innerText = "Processing...";


        google.script.run.withSuccessHandler(function(res) {

            if(res.status === "Success") {

                generateA4PDF(res.appNo);

                document.getElementById('status').innerHTML = "<span style='color:green;'>வெற்றி! விண்ணப்ப இலக்கம்: " + res.appNo + "</span>";

                document.getElementById('admissionForm').reset();

            } else {

                alert("Error: " + res.message);

            }

            btn.disabled = false; btn.innerText = "SUBMIT & DOWNLOAD PDF";

        }).processForm(document.getElementById('admissionForm'));

    }


    function generateA4PDF(appNo) {

        const { jsPDF } = window.jspdf;

        const doc = new jsPDF('p', 'mm', 'a4');


        // A4 Border

        doc.setLineWidth(0.3); doc.rect(8, 8, 194, 281);


        // Header

        doc.setFont("times", "bold"); doc.setFontSize(14);

        doc.text("KM/AK/AS-SIRAJ MAHA VIDYALAYA - AKKARAIPATTU", 105, 18, { align: "center" });

        doc.setFontSize(10);

        doc.text("APPLICATION FOR ENROLMENT - ACADEMIC YEAR 2026", 105, 24, { align: "center" });

        doc.setTextColor(200, 0, 0);

        doc.text("Closing Date: 2026.01.31", 105, 30, { align: "center" });

        doc.setTextColor(0);


        // Admission Info & Photo Box

        doc.setFontSize(9);

        doc.rect(12, 38, 75, 10); doc.text("ADMISSION NO: " + appNo, 15, 44.5);

        doc.rect(160, 15, 30, 35); doc.text("Affix Photo", 168, 32);


        // Information Table

        doc.autoTable({

            startY: 52,

            head: [['Description', 'Information']],

            body: [

                ['Grade Applied', document.getElementById('grade').value],

                ['Medium', document.getElementById('medium').value],

                ['Full Name', document.getElementById('fullName').value.toUpperCase()],

                ['Name with Initials', document.getElementById('nameInitials').value.toUpperCase()],

                ['G.S. Division', document.getElementById('gsDiv').value],

                ['Gender', document.getElementById('gender').value],

                ['Address', document.getElementById('address').value],

                ['Scholarship Marks', document.getElementById('marks').value || '-'],

                ['Father\'s Name', document.getElementById('father').value],

                ['Mobile No', document.getElementById('mobile').value],

                ['WhatsApp No', document.getElementById('whatsapp').value || '-'],

                ['Occupation', document.getElementById('job').value]

            ],

            theme: 'grid',

            headStyles: { fillColor: [0, 38, 77] },

            styles: { fontSize: 8.5, cellPadding: 3.5 },

            columnStyles: { 0: { cellWidth: 55, fontStyle: 'bold' } }

        });


        // Office Use Section

        let y = doc.lastAutoTable.finalY + 12;

        doc.setFont("times", "bold"); doc.text("FOR OFFICE USE ONLY", 105, y, { align: "center" });

        doc.rect(12, y + 4, 186, 30);

        doc.setFont("times", "normal"); doc.setFontSize(8);

        doc.text("Date Received: ...........................", 18, y + 12);

        doc.text("Verified By: ...................................", 18, y + 20);

        doc.text("Principal's Signature: ...................................", 120, y + 28);


        // Declaration & Signature

        doc.text("I certify that the above info is true and correct. (தகவல்கள் உண்மையானவை என உறுதிப்படுத்துகின்றேன்)", 12, 275);

        doc.text("Parent Signature: .........................", 12, 282);

        doc.text("Date: .........................", 160, 282);


        doc.save("ASMV_Application_" + appNo + ".pdf");

    }

</script>

</body>

</html>