{# Template For PG Students In MES VIMALA STJOSEPH Collagees  #}
<style>
     td, th { padding: 5px; }
     body{
        font-family: \"Times New Roman\", Times, serif;
    }
    .primary-table {
		border-collapse: collapse !important;
		page-break-inside: auto;
		width: 100% !important;
	}

	.primary-table th {
		text-align: center;
		background: none !important;
		height: 4mm !important;
		border: 1px solid #000 !important;
		padding: 1mm !important;
	}
	.primary-table td {
		padding: 3px;
		line-height: 20px !important;
		height: 4mm !important;
		border: 1px solid #000;
		text-align: center;
		vertical-align: middle !important;
	}
	#subjectHeader {
		width: 100% !important;
	}
	#subjectHeader td {
		padding: 2mm;
		line-height: 15px !important;
		height: 4mm !important;
		vertical-align: middle !important;
		text-align: center !important;
	}
    .header-details-table {
        width: 100% !important;
        border-collapse: collapse;
        table-layout: auto;
    }
    .header-details-table td {
        padding: 2px !important;
        text-align: left !important;
        vertical-align: top;
        font-size: 22px;
    }
    .header-details-label {
        width: 1%;
        font-weight: bold;
        white-space: nowrap;
    }
    .header-details-colon {
        width: 1%;
        font-weight: bold;
        text-align: left !important;
        padding-left: 0 !important;
        padding-right: 4px !important;
    }
    .header-details-value {
        width: auto;
        padding-left: 0 !important;
        font-weight: bold;
    }
    .subject-meta-table td {
        border: none;
        padding: 0;
        font-size: 15px;
        line-height: 14px !important;
    }
	.no-border {
		border-left: 1px solid #fff !important;
		border-right: 1px solid #fff !important;
		border-top: 1px solid #fff !important;
        border-bottom: 1px solid #fff !important;
	}
    .college-header {
		height: 35mm;
		width: auto;
		margin: 0 10%;
	}
    .outer-border {
        border: 1px solid black;
        border-collapse: collapse;
    }
    .center {
        margin-left: auto;
        margin-right: auto;
    }
    .abbr-table td{
        padding: 2mm 10mm 2mm 10mm;
		line-height: 14px !important;
		margin-top:5mm;
    }

    .border-0{
        border:1px solid #fff !important;
    }
    .border-trl-0{
        border-top:1px solid #fff !important;
        border-left:1px solid #fff !important;
        border-right:1px solid #fff !important;
    }
    .border-rl-0{
        border-left:1px solid #fff !important;
        border-right:1px solid #fff !important;
    }
    .border-b-0{
        border-bottom:1px solid #fff !important;
        border-top:1px solid #000 !important;
    }
    .border-t-0{
        border-top:1px solid #fff !important;
        border-bottom:1px solid #000 !important;
    }
    .noborder-r-0{
       border-right-style: none;
    }
    .border-bt-0{
        border-bottom:1px solid #fff !important;
        border-top:1px solid #fff !important;
    }
    .markTab{
        width:100%;
        margin:20px auto;
        font-size: 18px;
        padding:0;
        text-align:center;
        border-collapse: collapse;
    }
    .markTab td{
        margin: 0;
        font-size: 18px;
        padding:11px 5px;
        height: 45px;
        color: #000;
        text-align: center;
        border-collapse: collapse;
    }
    .rotate{
        transform: rotate(270deg);
        text-align:center;
        line-height: 13px;
        height: 70px;
        width: 70px;
        margin: 0px -43px 0px 5px;
        text-align: center;
    }
    .failed{
		background-color:#c0c0c0 !important;
	}
    
</style>
    <div class="page" style="width:100%;">


    {% if data.displayContentOptions.rules.showFirstPageForPg %}
            <table id="subjectHeader">
        <tr style="padding-top:300px!important">
			<td><img src="{{data.collegeData.collegeHeader}}" class="college-header"></td>
		</tr>
        <tr>
            <td><b style="font-size: 22px;">{{data.examRegistrationData.name}}</br></td>
		</tr>
        <tr>
            <td><b style="font-size: 22px;">TABULATION REGISTER</br></td>
		</tr>
    </table>
    <table style="width:100%!important; table-layout:fixed;">
        <tr style="vertical-align: top;">
            <td style="width:70%; padding: 2px !important; vertical-align: top;">
                <table class="header-details-table">
                    <tr>
                        <td class="header-details-label">Programme</td>
                        <td class="header-details-colon">:</td>
                        <td class="header-details-value">{{data.examRegistrationData.programName| raw}}</td>
                    </tr>
                    <tr>
                        <td class="header-details-label">Month & Year</td>
                        <td class="header-details-colon">:</td>
                        <td class="header-details-value">{{data.examRegistrationData.examMonthName}} {{data.examRegistrationData.examYear}}</td>
                    </tr>
                    <tr>
                        <td class="header-details-label">Board Meeting Held on</td>
                        <td class="header-details-colon">:</td>
                        <td class="header-details-value">{{data.examRegistrationData.boardMeatingDate| raw}}</td>
                    </tr>
                    <tr>
                        <td class="header-details-label">Moderation</td>
                        <td class="header-details-colon">:</td>
                        <td class="header-details-value">{{data.examRegistrationData.moderation}}</td>
                    </tr>
                    <tr>
                        <td class="header-details-label">Date of Publication of Result</td>
                        <td class="header-details-colon">:</td>
                        <td class="header-details-value">{{data.examRegistrationData.resultPublishDate}}</td>
                    </tr>
                </table>
            </td>
            <td style="width:30%; padding: 2px !important; vertical-align: top;">
                <table class="markTab" border="1" cellpadding="0" cellspacing="0" style="width:100%; margin:0;">
                    <tr>
                        <th style="text-align:center !important" class="tabular-table-border">Credit Point Calculation</th>
                        <th style="text-align:center !important" class="tabular-table-border">Abbreviations</th>
                    </tr>
                    <tr>
                        <th style="text-align:left !important" class="tabular-table-border">EWGPA = EWGP/30</th>
                        <th style="text-align:left !important" class="tabular-table-border">IWGPA = Internal Grade Point Average</th>
                    </tr>
                    <tr>
                        <th style="text-align:left !important" class="tabular-table-border">WGPA = (EWGPA*4 + IWGPA)/5</th>
                        <th style="text-align:left !important" class="tabular-table-border">IGrade = Internal Grade</th>
                    </tr>
                    <tr>
                        <th style="text-align:left !important" class="tabular-table-border">Cr:Pt = WGPA * Credit</th>
                        <th style="text-align:left !important" class="tabular-table-border">EWGP = External Weighted Grade Point</th>
                    </tr>
                    <tr>
                        <th style="text-align:left !important" class="tabular-table-border">Minimum WGPA for pass = 2.00</th>
                        <th style="text-align:left !important" class="tabular-table-border">EWGPA = External Weighted Grade Point Avg</th>
                    </tr>
                    <tr>
                        <th style="text-align:left !important" class="tabular-table-border">Minimum SGPA for pass = 2.00</th>
                        <th style="text-align:left !important" class="tabular-table-border">WGPA = Weighted Grade Point Average</th>
                    </tr>
                    <tr>
                        <th style="text-align:left !important" class="tabular-table-border"></th>
                        <th style="text-align:left !important" class="tabular-table-border">Cr Pt = Credit Point</th>
                    </tr>
                    <tr>
                        <th style="text-align:left !important" class="tabular-table-border"></th>
                        <th style="text-align:left !important" class="tabular-table-border">SGPA = Semester Grade Point Average</th>
                    </tr>
                    <tr>
                        <th style="text-align:left !important" class="tabular-table-border"></th>
                        <th style="text-align:left !important" class="tabular-table-border">CGPA = Cumulative Grade Point Average</th>
                    </tr>
                </table>
            </td>
        </tr>
    </table>
    {% endif %}
    
    {# Group elective baskets like the UG template: collapse each basket to one column. #}
    {% set subjectGroupList = [] %}
    {% for grpChunk in data.examRegistrationData.subjectGroups %}
        {% set subjectGroupList = subjectGroupList|merge(grpChunk) %}
    {% endfor %}
    {% if subjectGroupList is empty %}
        {% set subjectGroupList = data.examRegistrationData.subjects %}
    {% endif %}
    {% set subjectColSpan =   subjectLen * 5 %}
    {% set trcolSpan =  subjectColSpan + 5  %}
    {% set colspan =  7  %}
    {% set subjectLen =  subjectGroupList|length   %}
    {% set colspan = colspan + subjectLen * 8  %}
    {% set widthtr =  80 / subjectLen %}
    {% set extraColspan =  colspan - 4 %}
    {% if not data.displayContentOptions.rules.showFirstPageForPg %}
    <table class="markTab" border="0" cellpadding="0" cellspacing="0">
        <tr align = 'center'>
            <td style = "text-align:center">
                <div style="text-align:center;">
                    <img style='height:40mm !important; width:auto;' src="{{data.collegeData.collegeHeader}}" class="college-header">
                </div>
            </td>
        </tr>
    </table>
    {% endif %}
    
    {% set chunkPageBreak = data.displayContentOptions.rules.showFirstPageForPg %}
    {% for chunk in data.studentDataChunks %}
    <div style="{{ not loop.first ? 'page-break-before: always;' : '' }}">
    <table class="markTab" border="1" cellpadding="0" cellspacing="0" style = "">
        <thead>
            <tr>
                {% if data.isPrint == false and data.displayContentOptions.printForSelectedStudents == 1 %}
                    <th data-f-bold='true' data-exclude="true" class="tabular-table-border sticky-column sticky-column-1 sticky-header" style="width:2%" rowspan="3">Select</th>
                {% endif %}
                <th rowspan="3" class='text-center bold ' data-a-h='center' data-a-v='middle'>Sl.No</th>
                <th rowspan="3"class='text-center bold' data-a-h='center' data-a-v='middle'>Reg. No & Name</th>
                {% set subHeadColspan = 9 %}
                {% if data.displayContentOptions.rules.showModerationMark %}
                {% set subHeadColspan = subHeadColspan + 1 %}
                {% endif %}
                {% if data.displayContentOptions.rules.showGraceMark %}
                {% set subHeadColspan = subHeadColspan + 1 %}
                {% endif %}
                {% for subject in subjectGroupList %}
                    <th colspan="{{subHeadColspan}}" width='{{widthtr}}'  class='text-center' data-a-h='center' data-a-v='middle'>{% if subject.isGrouped is defined and subject.isGrouped %}{{subject.name|raw}}{% else %}{{subject.code}} <br> {{subject.name}}{% endif %}</th>
                {% endfor %}
                <th rowspan="3"class='text-center bold' data-a-h='center' data-a-v='middle'>Total</br> Credit</br>Points</th>
                <th rowspan="3"class='text-center bold' data-a-h='center' data-a-v='middle'>SGPA</th>
                <th rowspan="3"class='text-center bold ' data-a-h='center' data-a-v='middle'>Grade</th>
            </tr>
            <tr>
                {% for subject in subjectGroupList %}
                    <th colspan="{{subHeadColspan}}" class='text-center ' data-a-h='center' data-a-v='middle'>
                        <table class="subject-meta-table" style="width:100%; margin:0;">
                            <tr>
                                <td style="text-align:left; width:70%;">
                                    IWGPA max: {{subject.internalMaxMark}}<br>
                                    EWGP max: {{subject.externalMaxMark}}
                                </td>
                                <td style="text-align:right; width:30%; vertical-align: top;">Credit : {{subject.credit}}</td>
                            </tr>
                        </table>
                    </th>
                {% endfor %} 
            </tr>
            <tr>
                {% for subject in subjectGroupList %}
                {% if data.displayContentOptions.rules.showModerationMark %}
                <th class='text-center ' data-a-h='center' data-a-v='middle'>
                    <svg width='5mm' height='30mm'>
                        <text transform='rotate(180)' y='-50%' x='-50%' style='writing-mode: tb;text-anchor: middle;'>MDN</text>
                    </svg>
                </th>
                {% endif %}
                {% if data.displayContentOptions.rules.showGraceMark %}
                <th class='text-center ' data-a-h='center' data-a-v='middle'>
                    <svg width='5mm' height='30mm'>
                        <text transform='rotate(180)' y='-50%' x='-50%' style='writing-mode: tb;text-anchor: middle;'>GRM</text>
                    </svg>
                </th>
                {% endif %}
                    <th class='text-center ' data-a-h='center' data-a-v='middle'>
                        <svg width='5mm' height='30mm'>
                            <text transform='rotate(180)' y='-50%' x='-50%' style='writing-mode: tb;text-anchor: middle;'>IWGPA</text>
                        </svg>
                    </th>
                    <th class='text-center ' data-a-h='center' data-a-v='middle'>
                        <svg width='5mm' height='30mm'>
                            <text transform='rotate(180)' y='-50%' x='-50%' style='writing-mode: tb;text-anchor: middle;'>IGrade</text>
                        </svg>
                    </th>
                    <th class='text-center ' data-a-h='center' data-a-v='middle'>
                        <svg width='5mm' height='30mm'>
                            <text transform='rotate(180)' y='-50%' x='-50%' style='writing-mode: tb;text-anchor: middle;'>EWGP</text>
                        </svg>
                    </th>
                     <th class='text-center ' data-a-h='center' data-a-v='middle'>
                        <svg width='5mm' height='30mm'>
                            <text transform='rotate(180)' y='-50%' x='-50%' style='writing-mode: tb;text-anchor: middle;'>EWGPA</text>
                        </svg>
                    </th>
                    <th class='text-center ' data-a-h='center' data-a-v='middle'>
                        <svg width='5mm' height='30mm'>
                            <text transform='rotate(180)' y='-50%' x='-50%' style='writing-mode: tb;text-anchor: middle;'>EGrade</text>
                        </svg>
                    </th>
                    <th class='text-center ' data-a-h='center' data-a-v='middle'>
                        <svg width='5mm' height='30mm'>
                            <text transform='rotate(180)' y='-50%' x='-50%' style='writing-mode: tb;text-anchor: middle;'>WGPA</text>
                        </svg>
                    </th>
                    <th class='text-center ' data-a-h='center' data-a-v='middle'>
                        <svg width='5mm' height='30mm'>
                            <text transform='rotate(180)' y='-50%' x='-50%' style='writing-mode: tb;text-anchor: middle;'>Grade</text>
                        </svg>
                    </th>
                    <th class='text-center ' data-a-h='center' data-a-v='middle'>
                        <svg width='5mm' height='30mm'>
                            <text transform='rotate(180)' y='-50%' x='-50%' style='writing-mode: tb;text-anchor: middle;'>Cr Pt</text>
                        </svg>
                    </th>
                    <th class='text-center ' data-a-h='center' data-a-v='middle'>
                        <svg width='5mm' height='30mm'>
                            <text transform='rotate(180)' y='-50%' x='-50%' style='writing-mode: tb;text-anchor: middle;'>Status</text>
                        </svg>
                    </th>
                {% endfor %} 
            </tr>
        </thead>
        <tbody>
            {% set slno = loop.first ? 0 : ((data.firstPageCount|default(15)) + (loop.index0 - 1) * (data.otherPageCount|default(15))) %}
            {% for student in chunk %}
            {% for academicTerm in student.academicTerms %}
                {% set slno = slno + 1 %}
                <tr>
                    {% if data.isPrint == false and data.displayContentOptions.printForSelectedStudents == 1%}
                        <td data-exclude="true" rowspan="2" class="text-center tabular-table-border text-center tabular-table-border sticky-column sticky-column-1"><input type="checkbox" class="studentName" value='{{student.id}}'/></td>
                    {% endif %}
                    <td class="align-middle text-center " rowspan="2">{{slno}}</td>
                    <td style="text-align:left;padding: 4px; " rowspan="2">{{student.registerNo}}</br>{{student.name}} </td>
                        {# Row 1: the subject the student actually took in each (possibly grouped) column #}
                        {% for subject in subjectGroupList %}
                            {% set isEnteredCode = false %}
                            {% for studentSubject in academicTerm.subjects %}
                                {% set matchedCode = (subject.academicPaperSubjectIds is defined and studentSubject.id in subject.academicPaperSubjectIds) or (subject.academicPaperSubjectIds is not defined and studentSubject.id == subject.id) %}
                                {% if matchedCode and isEnteredCode == false %}
                                    {% set isEnteredCode = true %}
                                    <td class="text-center {{ studentSubject.failedStatus == "PASSED" ? '' : 'failed'}}" colspan="{{subHeadColspan}}">{{studentSubject.code}}</td>
                                {% endif %}
                            {% endfor %}
                            {% if isEnteredCode == false %}
                                <td class="text-center" colspan="{{subHeadColspan}}"></td>
                            {% endif %}
                        {% endfor %}
                    {% if academicTerm.failedStatus == 'PASSED' %}
                        <td class="align-middle text-center" rowspan="2">{{academicTerm.semesterCreditGradePoint}}</td>
                        <td class="align-middle text-center" rowspan="2">{{academicTerm.semesterSgpa}}</td>
                        <td class="align-middle text-center" rowspan="2">{{academicTerm.semesterGrade}}</td>
                    {% else %}
                        <td rowspan="2">-</td>
                        <td rowspan="2">-</td>
                        <td rowspan="2">-</td>
                    {% endif %}
                </tr>
                <tr>
                        {# Row 2: marks for the subject the student took #}
                        {% for subject in subjectGroupList %}
                            {% set isEntered = false %}
                            {% set isEnteredGroup = false %}
                            {% for studentSubject in academicTerm.subjects %}
                                {% set matched = (subject.academicPaperSubjectIds is defined and studentSubject.id in subject.academicPaperSubjectIds) or (subject.academicPaperSubjectIds is not defined and studentSubject.id == subject.id) %}
                                {% if matched and isEnteredGroup == false %}
                                    {% set isEnteredGroup = true %}
                                    {% if data.displayContentOptions.rules.showModerationMark %}
                                        <td class="text-center">{{studentSubject.moderationMark ? studentSubject.moderationMark | round:'0' }}</td>
                                    {% endif %}
                                    {% if data.displayContentOptions.rules.showGraceMark %}
                                        <td class="text-center">{{studentSubject.graceMark ? studentSubject.graceMark | round:'0'}}</td>
                                    {% endif %}
                                    {% if studentSubject.isInternal %}
                                        <td class="text-center {{ studentSubject.failedStatus == "PASSED" ? '' : 'failed'}}">{{ studentSubject.percentageObtainedInternal == 0 ? '-' : (studentSubject.percentageObtainedInternal|number_format(2, '.')) }}</td>
                                        <td class="text-center {{ studentSubject.failedStatus == "PASSED" ? '' : 'failed'}}">{{ studentSubject.internalGrade }}</td>
                                    {% else %}
                                        <td class="text-center {{ studentSubject.failedStatus == "PASSED" ? '' : 'failed'}}">-</td>
                                        <td class="text-center {{ studentSubject.failedStatus == "PASSED" ? '' : 'failed'}}">-</td>
                                    {% endif %}
                                    {% if studentSubject.isExternal %}
                                        <td class="text-center {{ studentSubject.failedStatus == "PASSED" ? '' : 'failed'}} noborder-r-0">
                                            {% if studentSubject.attendanceStatus == "PRESENT" %}
                                                {{  studentSubject.percentageObtainedExternal == 0 ? '-' : (studentSubject.percentageObtainedExternal|number_format(2, '.')) }}
                                            {% elseif studentSubject.attendanceStatus == "MALPRACTICE" %}
                                                <span style="color:red;">MAL </span> 
                                            {% else %}
                                                <span style="color:red;"> AB </span> 
                                            {% endif %}
                                        </td>
                                        <td class="text-center {{ studentSubject.failedStatus == "PASSED" ? '' : 'failed'}} noborder-r-0">
                                            {% if studentSubject.attendanceStatus == "PRESENT" %}
                                                {{  studentSubject.externalMark == 0 ? '-' : (studentSubject.externalMark|round(2)) }}
                                            {% elseif studentSubject.attendanceStatus == "MALPRACTICE" %}
                                                <span style="color:red;">MAL </span> 
                                            {% else %}
                                                <span style="color:red;"> AB </span> 
                                            {% endif %}
                                        </td>
                                        <td class="text-center {{ studentSubject.failedStatus == "PASSED" ? '' : 'failed'}} noborder-r-0">{{ studentSubject.externalGrade }}</td>
                                    {% else %}
                                        <td class="text-center {{ studentSubject.failedStatus == "PASSED" ? '' : 'failed'}}">-</td>
                                        <td class="text-center {{ studentSubject.failedStatus == "PASSED" ? '' : 'failed'}}">-</td>
                                        <td class="text-center {{ studentSubject.failedStatus == "PASSED" ? '' : 'failed'}}">-</td>
                                    {% endif %}
                                    <td class="text-center {{ studentSubject.failedStatus == "PASSED" ? '' : 'failed'}} ">{{ studentSubject.wgpa|number_format(2, '.') }}</td>
                                    <td class="text-center {{ studentSubject.failedStatus == "PASSED" ? '' : 'failed'}} ">{{ studentSubject.grade }}</td>
                                    <td class="text-center {{ studentSubject.failedStatus == "PASSED" ? '' : 'failed'}}">{{ studentSubject.creditGradePoint }}</td>
                                    {% if studentSubject.failedStatus == 'PASSED' %}
                                        <td class="text-center {{ studentSubject.failedStatus == "PASSED" ? '' : 'failed'}}">P</td>
                                    {% else %}
                                        <td class="text-center {{ studentSubject.failedStatus == "PASSED" ? '' : 'failed'}}">F</td>
                                    {% endif %}
                                    {% set isEntered = true %}
                                {% endif %}
                            {% endfor %}
                            {% if isEntered == false %}
                                {% if data.displayContentOptions.rules.showModerationMark %}
                                    <td class="text-center"></td>
                                {% endif %}
                                {% if data.displayContentOptions.rules.showGraceMark %}
                                    <td class="text-center"></td>
                                {% endif %}
                                <td class="text-center"> * </td>
                                <td class="text-center"> * </td>
                                <td class="text-center"> * </td>
                                <td class="text-center"> * </td>
                                <td class="text-center"> * </td>
                                <td class="text-center"> * </td>
                                <td class="text-center"> * </td>
                                <td class="text-center"> * </td>
                                <td class="text-center"> * </td>
                            {% endif %}
                        {% endfor %}
                </tr>
            {% endfor %}
            {% endfor %}
        </tbody>
    </table>
    </div>
    {% endfor %}
    <div style="margin: 100px 0 0 0; width: 100%; font-size: 16px">
        <div style = "width:16%;margin:0 auto; text-align:center;float:left;"><b>Clerk</b></div>
        <div style = "width:16%;margin:0 auto; text-align:center;float:left;"><b>Chairman</b></div>
        <div style = "width:16%;margin:0 auto; text-align:center;float:left;"><b>Seal</b></div>
        <div style = "width:16%;margin:0 auto; text-align:center;float:left;"><b>ACE</b></div>
        <div style = "width:16%;margin:0 auto; text-align:center;float:left;"><b>CE</b></div>
        <div style = "width:16%;margin:0 auto; text-align:center;float:left;"><b>Principal</b></div>
    </div>
</div>
