<?php

function template3($institutions, $branch, $students_array, $examination, $array, $result, $class_id, $section_id = null)
{
?>

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>
      Progress Report - <?php echo $institutions['institution_name']; ?>
    </title>
    <style>
      @import url("https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;600&display=swap");

      :root {
        --primary-color: #4a90e2;
        --secondary-color: #2c3e50;
        --background-color: #f0f4f8;
        --card-background: #ffffff;
        --border-color: #d1d9e6;
        --accent-color-1: #ff6b6b;
        --accent-color-2: #feca57;
        --accent-color-3: #54a0ff;
      }

      * {
        margin: 0;
        padding: 0;
        box-sizing: border-box;
        font-family: "Poppins", sans-serif;
      }

      body {
        line-height: 1.2; /* Reduced line height */
        color: var(--secondary-color);
        background-color: var(--background-color);
        display: flex;
        justify-content: center;
        align-items: center;
        min-height: 100vh;
        padding: 5px;
      }

      .container {
        background-color: var(--card-background);
        padding: 15px; /* Reduced padding */
        border-radius: 8px;
        box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
        width: 210mm;
        height: 297mm; /* Fixed A4 height */
        border: 1px solid var(--primary-color);
        position: relative;
        display: flex;
        flex-direction: column;
        overflow: hidden; /* Prevent content from overflowing */
      }

      .header {
        text-align: center;
        margin-bottom: 10px; /* Reduced margin */
        border-bottom: 2px solid var(--primary-color);
        padding-bottom: 8px; /* Reduced padding */
        background: linear-gradient(
          45deg,
          var(--accent-color-1),
          var(--accent-color-2),
          var(--accent-color-3)
        );
        color: white;
        padding: 10px 15px; /* Reduced padding */
        border-radius: 6px 6px 0 0;
      }

      .logo {
        max-width: 70px; /* Smaller logo */
        margin-bottom: 5px; /* Reduced margin */
        background-color: aliceblue;
        border: 2px solid white;
        border-radius: 4px;
      }

      h1 {
        color: white;
        margin-bottom: 3px; /* Reduced margin */
        font-size: 1.5em; /* Smaller font */
        font-weight: 600;
        text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
      }

      .school-info {
        font-size: 0.8em; /* Smaller font */
        color: white;
        opacity: 0.9;
        line-height: 1.1; /* Tighter line height */
      }

      .report-title {
        font-size: 1.3em; /* Slightly smaller */
        font-weight: 600;
        text-align: center;
        margin: 10px 0; /* Reduced margin */
        color: var(--primary-color);
        text-transform: uppercase;
        border-bottom: 2px solid var(--accent-color-2);
        padding-bottom: 3px; /* Reduced padding */
      }

      .academic-session {
        text-align: center;
        margin-bottom: 10px; /* Reduced margin */
        font-size: 0.85em; /* Smaller font */
        color: var(--accent-color-3);
      }

      .student-info-container {
        display: flex;
        justify-content: space-between;
        margin-bottom: 10px; /* Reduced margin */
        gap: 8px; /* Reduced gap */
        flex-wrap: wrap;
      }

      .student-info {
        flex: 1;
        min-width: 30%; /* Ensure they stay in one row */
        font-size: 0.85em; /* Smaller font */
        /* border: 2px solid var(--accent-color-3); */
        padding: 8px; /* Reduced padding */
        border-radius: 6px;
        background-color: #f8f9fa;
      }

      .student-info table {
        width: 100%;
        border-collapse: collapse;
      }

      .student-info td {
        padding: 3px 0; /* Reduced padding */
        vertical-align: top;
        font-size: 0.8em; /* Smaller font */
      }

      .assessment-tables {
        display: flex;
        justify-content: space-between;
        gap: 10px; /* Reduced gap */
        margin-bottom: 15px; /* Reduced margin */
        flex-grow: 1; /* Take available space */
        overflow: hidden; /* Prevent overflow */
      }

      .assessment-table {
        flex: 1;
        overflow: hidden; /* Prevent overflow */
        display: flex;
        flex-direction: column;
      }

      table {
        width: 100%;
        border-collapse: collapse;
        margin-bottom: 0;
        font-size: 0.75em; /* Smaller font */
        border: 2px solid var(--primary-color);
        table-layout: fixed; /* Consistent column widths */
      }

      th,
      td {
        padding: 6px; /* Reduced padding */
        text-align: left;
        border: 1px solid var(--border-color);
        word-wrap: break-word; /* Break long words */
      }

      th {
        background-color: var(--primary-color);
        color: white;
        font-weight: 600;
        font-size: 0.8em; /* Smaller font */
        padding: 6px; /* Reduced padding */
      }

      tr:nth-child(even) {
        background-color: #f2f6f9;
      }

      /* .color-red {
        color: var(--accent-color-1);
      } */

      .text-capitalise {
        text-transform: capitalize;
      }

      .aligncenter {
        text-align: center;
      }

      .signatures {
        display: flex;
        justify-content: space-between;
        margin-top: 15px; /* Reduced margin */
        flex-shrink: 0; /* Don't shrink */
      }

      .signature-line {
        border-top: 2px solid var(--primary-color);
        width: 120px; /* Narrower lines */
        margin-top: 15px; /* Reduced margin */
      }

      .footer {
        margin-top: 10px; /* Reduced margin */
        padding-top: 8px; /* Reduced padding */
        border-top: 2px solid var(--accent-color-2);
        font-size: 0.75em; /* Smaller font */
        color: var(--secondary-color);
        text-align: center;
        flex-shrink: 0; /* Don't shrink */
      }

      @media print {
        body {
          background-color: white;
          margin: 0;
          padding: 0;
        }
        .container {
          box-shadow: none;
          border: none;
          width: 210mm;
          height: 297mm;
          padding: 10mm; /* Standard print margins */
          page-break-after: avoid;
          page-break-inside: avoid;
        }
        @page {
          size: A4;
          margin: 10mm; /* Standard print margins */
        }
        .student-info-container,
        .assessment-tables {
          page-break-inside: avoid;
        }
      }
    </style>
  </head>
  <body>
    <div class="container">
      <header class="header">
        <img
          src="<?php echo $institutions['logo']; ?>"
          alt="School Logo"
          class="logo"
        />
        <h1><?php echo $institutions['institution_name']; ?></h1>
        <div class="school-info">
          <p>
            <?php echo $branch['branch_code']; ?>
            |
            <?php echo $branch['address']; 
                    if ($branch['pincode'] != "") {
                        echo " - " . $branch['pincode'];
                    } ?>
            |
            <?php echo $branch['contact_number']; 
                    if ($branch['email'] != "") {
                        echo " | " . strtolower($branch['email']);
                    } ?>
          </p>
        </div>
      </header>

      <div class="report-title">Progress Report</div>
      <div class="academic-session">
        Academic Session
        <?php echo $result; ?>
      </div>

      <div class="student-info-container">
        <div class="student-info">
          <table>
            <tr>
              <td style="width: 40%">Name</td>
              <td style="width: 5%">:</td>
              <td style="width: 55%">
                <?php echo $students_array[0]['name']; ?>
              </td>
            </tr>
            <tr>
              <td>Class</td>
              <td>:</td>
              <td><?php echo $class_id; ?></td>
            </tr>
            <tr>
              <td>Father's Name</td>
              <td>:</td>
              <td><?php echo $students_array[0]['fathername']; ?></td>
            </tr>
          </table>
        </div>
        <div class="student-info">
          <table>
            <tr>
              <td style="width: 40%">Admission No.</td>
              <td style="width: 5%">:</td>
              <td style="width: 55%">
                <?php echo $students_array[0]['admission_number']; ?>
              </td>
            </tr>
            <tr>
              <td>Section</td>
              <td>:</td>
              <td><?php echo $section_id; ?></td>
            </tr>
            <tr>
              <td>Mother's Name</td>
              <td>:</td>
              <td><?php echo $students_array[0]['mothername']; ?></td>
            </tr>
          </table>
        </div>
        <div class="student-info">
          <table>
            <tr>
              <td style="width: 40%">Height</td>
              <td style="width: 5%">:</td>
              <td style="width: 55%"><?php echo $array[0]; ?></td>
            </tr>
            <tr>
              <td>Weight</td>
              <td>:</td>
              <td><?php echo $array[1]; ?></td>
            </tr>
            <tr>
              <td>D.O.B.</td>
              <td>:</td>
              <td><?php echo $students_array[0]['dob']; ?></td>
            </tr>
          </table>
        </div>
      </div>

      <div class="assessment-tables">
        <div class="assessment-table">
          <table>
            <colgroup>
              <col style="width: 70%" />
              <col style="width: 30%" />
            </colgroup>
            <tr>
              <th>ASSESSMENTS</th>
              <th class="aligncenter">GRADE</th>
            </tr>

            <tr>
              <th class="color-red">ENGLISH</th>
              <th></th>
            </tr>
            <tr>
              <td>Can write nearly</td>
              <td><?php echo ucwords($array[2]); ?></td>
            </tr>
            <tr>
              <td>Can narrate stories effectively</td>
              <td><?php echo ucwords($array[3]); ?></td>
            </tr>
            <tr>
              <td>Can recite poems with expressions</td>
              <td><?php echo ucwords($array[4]); ?></td>
            </tr>
            <tr>
              <td>Can recognize and read properly</td>
              <td><?php echo ucwords($array[5]); ?></td>
            </tr>

            <tr>
              <th class="color-red">MATHEMATICS</th>
              <th></th>
            </tr>
            <tr>
              <td>Can identify the numbers correctly</td>
              <td><?php echo ucwords($array[6]); ?></td>
            </tr>
            <tr>
              <td>Can grasp the combination of numbers</td>
              <td><?php echo ucwords($array[7]); ?></td>
            </tr>
            <tr>
              <td>Can count and write in sequence</td>
              <td><?php echo ucwords($array[8]); ?></td>
            </tr>

            <tr>
              <th class="color-red">PUNJABI</th>
              <th></th>
            </tr>
            <tr>
              <td>Can express the word</td>
              <td><?php echo ucwords($array[9]); ?></td>
            </tr>
            <tr>
              <td>Can write properly</td>
              <td><?php echo ucwords($array[10]); ?></td>
            </tr>

            <tr>
              <th class="color-red">E.V.S. / GENERAL KNOWLEDGE</th>
              <th></th>
            </tr>
            <tr>
              <td>Can identify</td>
              <td><?php echo ucwords($array[11]); ?></td>
            </tr>
            <tr>
              <td>Can write properly</td>
              <td><?php echo ucwords($array[12]); ?></td>
            </tr>
            <tr>
              <td>Can express / understand the word / pictures</td>
              <td><?php echo ucwords($array[13]); ?></td>
            </tr>

            <tr>
              <th class="color-red">ART & CRAFT</th>
              <th></th>
            </tr>
            <tr>
              <td>Enjoys drawing, colouring & pasting</td>
              <td><?php echo ucwords($array[14]); ?></td>
            </tr>
            <tr>
              <td>Follows instructions carefully</td>
              <td><?php echo ucwords($array[15]); ?></td>
            </tr>

            <tr>
              <th>ATTENDANCE</th>
              <th><?php echo ucwords($array[16]) . ' %'; ?></th>
            </tr>
            <tr>
              <td colspan="2">
                <strong>GENERAL REMARKS:</strong>
                <?php echo ucwords(strtolower($array[17])); ?>
              </td>
            </tr>
          </table>
        </div>

        <div class="assessment-table">
          <table>
            <colgroup>
              <col style="width: 70%" />
              <col style="width: 30%" />
            </colgroup>
            <tr>
              <th>COMPETENCIES</th>
              <th class="aligncenter">GRADE</th>
            </tr>

            <tr>
              <th class="color-red">PHYSICAL DEVELOPMENT</th>
              <th></th>
            </tr>

            <tr>
              <th class="text-capitalise">PART-I (HEALTHY & SAFE HABITS)</th>
              <th></th>
            </tr>
            <tr>
              <td>
                Shows a liking for and understanding of nutritious food and does
                not waste food
              </td>
              <td><?php echo ucwords($array[18]); ?></td>
            </tr>
            <tr>
              <td>Practices basic self- care and hygiene</td>
              <td><?php echo ucwords($array[19]); ?></td>
            </tr>

            <tr>
              <th class="text-capitalise">PART-II (SENSORIAL PERCEPTIONS)</th>
              <th></th>
            </tr>
            <tr>
              <td>Differentiates between shapes, colours and their shades</td>
              <td><?php echo ucwords($array[20]); ?></td>
            </tr>
            <tr>
              <td>Differentiates multiple smells and tastes</td>
              <td><?php echo ucwords($array[21]); ?></td>
            </tr>
            <tr>
              <td>Develops discriminations in the sense of touch</td>
              <td><?php echo ucwords($array[22]); ?></td>
            </tr>

            <tr>
              <th class="text-capitalise">PART-III (PHYSICAL FITNESS)</th>
              <th></th>
            </tr>
            <tr>
              <td>
                Shows balance, coordination and flexibility in various physical
                activities
              </td>
              <td><?php echo ucwords($array[23]); ?></td>
            </tr>
            <tr>
              <td>
                Shows precision and control in working with their hands and
                fingers
              </td>
              <td><?php echo ucwords($array[24]); ?></td>
            </tr>
            <tr>
              <td>
                Shows strength and endurance in carrying, walking and running
              </td>
              <td><?php echo ucwords($array[25]); ?></td>
            </tr>

            <tr>
              <th class="color-red">SOCIO-EMOTIONAL & ETHICAL DEVELOPMENT</th>
              <th></th>
            </tr>

            <tr>
              <th class="text-capitalise">PART-I (EMOTIONAL INTELLIGENCE)</th>
              <th></th>
            </tr>
            <tr>
              <td>
                Recognises 'self' as an individual belong to a family and
                community
              </td>
              <td><?php echo ucwords($array[26]); ?></td>
            </tr>
            <tr>
              <td>
                Recognises different emotions and makes deliberate efforts to
                regulate them
              </td>
              <td><?php echo ucwords($array[27]); ?></td>
            </tr>
            <tr>
              <td>Interacts comfortably with other children and adults</td>
              <td><?php echo ucwords($array[28]); ?></td>
            </tr>
            <tr>
              <td>Shows kindness and helpfulness to others</td>
              <td><?php echo ucwords($array[29]); ?></td>
            </tr>
          </table>
        </div>
      </div>

      <div class="signatures">
        <div>
          <h3>Class Incharge</h3>
          <div class="signature-line"></div>
        </div>
        <div>
          <h3>Principal / Headmistress</h3>
          <div class="signature-line"></div>
        </div>
        <div>
          <h3>Parent</h3>
          <div class="signature-line"></div>
        </div>
      </div>

      <div class="footer">
        <p>
          * In case of any discrepancies in marksheet, please contact school
          administration.
        </p>
      </div>
    </div>
  </body>
</html>

<?php
}
?>
