<html>
    <head></head>
    <body>
        <table width='100%'>
            <thead>
                 <tr>
                    <th colspan="15" style="font-weight:bold;font-size:20px;text-align:center;border:1px solid black;">{{header.collegeName}}</th>
                </tr>
                <tr>
                    <th colspan="15" style="font-weight:bold;font-size:17px;text-align:center;border:1px solid black;">{{header.collegeAddress1}},{{header.collegeAddress2}}</th>
                </tr>
                <tr>
                    <th colspan="15" style="font-weight:bold;font-size:16px;text-align:center;border:1px solid black;">{{header.collegeContact1}},{{header.collegeContact2}}</th>
                </tr>
                <tr>
                    <th colspan="15" style="font-weight:bold;font-size:16px;text-align:center;border:1px solid black;">{{report.name}}</th>
                </tr>
                <tr>
                    {# <th colspan="15" style="border:1px solid black;text-align:center;">Report Generated on {{ "now" | date('Y-m-d H:i:a') }}</th> #}
                    <th colspan="15" style="border:1px solid black;text-align:center;">Report Generated on {{ "now" | date('d-m-Y h:i:a') }}</th>
                </tr>
                {% if filterStringforReport %}
                    {% set lines = filterStringforReport|split("\n") %}
                    {% for line in lines %}
                        {% set trimmedLine = line|trim %}
                        {% if trimmedLine is not empty %}
                            <tr>
                                <th colspan="15" style="border: 1px solid black; text-align: center;">
                                    {{ trimmedLine |replace({'&amp;': '&'}) }}
                                </th>  
                            </tr>  
                        {% endif %}
                    {% endfor %}
                {% endif %}

                {% for index,headers in report.headerList %}
                <tr>
                    {% if index==0 %}
                    <th style="font-weight:bold;border:1px solid black;text-align:center;" rowspan="{{report.headerList | length}}">#</th>
                    {% endif %}
                 {% for header in headers %}
                    <th style="font-weight:bold;border:1px solid black;text-align:center;" colspan="{{header.colspan?header.colspan:1}}" rowspan="{{header.rowspan ? header.rowspan : 1}}">{{ header.label }}</th>
                 {% endfor %}
                </tr>
                 {% endfor %}
            </thead>
            <tbody>
                {% for index,record in report.data  %}
                    <tr>
                        <td style="border:1px solid black;text-align:center;"rowspan="{{record.rowspan ? record.rowspan : 1 }}">{{ index+1 }}</td>
                        {% for header in report.properties.components %}
                            {% if header.type == 'fw-markentry' and  header.showAs != 'COLUMN' %}
                                {% if attribute(record,'markDetails' ~ header.key).markDetails[0].markList | length <= 0  %}
                                <td style="border:1px solid black;">
                                    {{ attribute(record,'markDetails' ~ header.key).markDetails[0].subjectName }}
                                </td>
                                <td style="border:1px solid black;text-align:center;">
                                {{ attribute(record,'markDetails' ~ header.key).markDetails[0].markObtained }}
                                </td>
                                <td style="border:1px solid black;text-align:center;">
                                    {{ attribute(record,'markDetails' ~ header.key).markDetails[0].maxMark }}
                                </td>
                                {% for sem in range(1, header.numberOfTerms) %}
                                   <td style="border:1px solid black;">
                                   </td>
                                    <td style="border:1px solid black;text-align:center;">
                                    </td>
                                    <td style="border:1px solid black;text-align:center;">
                                    </td> 
                                {% endfor %}
                                {% else %}
                                    <td style="border:1px solid black;">
                                   </td>
                                    <td style="border:1px solid black;text-align:center;">
                                    </td>
                                    <td style="border:1px solid black;text-align:center;">
                                    </td> 
                                    {% for markDetails in attribute(record,'markDetails' ~ header.key).markDetails %}
                                        <td style="border:1px solid black;">
                                        {{ markDetails.markList[0].subjectName }}
                                        </td>
                                        <td style="border:1px solid black;text-align:center;">
                                        {{ markDetails.markList[0].marksObtained }}
                                        </td>
                                        <td style="border:1px solid black;text-align:center;">
                                            {{ markDetails.markList[0].maxMark }}
                                            </td>
                                    {% endfor %}
                                    {% for i in range(1, header.numberOfTerms - attribute(record,'markDetails' ~ header.key).markDetails | length) %}
                                        <td style="border:1px solid black;">
                                        </td>
                                        <td style="border:1px solid black;text-align:center;">
                                        </td>
                                        <td style="border:1px solid black;text-align:center;">
                                        </td> 
                                    {% endfor %}
                                {% endif %}
                            {% elseif header.type == 'fw-subject-group' %}
                                <td style="border:1px solid black;">
                                    {% set key = 'groupDatapercentage' ~ header.key | slice (12,(header.key | length))  %}
                                    {% if record.UGDATA  %}
                                        {{ attribute(record.UGDATA,key) }}
                                    {% else %}
                                        0
                                    {% endif %}
                                </td>
                            {% elseif header.key == 'parentFormApplicationNo' %}
                                <td style="border:1px solid black;">
                                    {{record.UGparentFormApplicationNo ? record.UGparentFormApplicationNo : (record.PGparentFormApplicationNo ? record.PGparentFormApplicationNo : '')}}
                                </td>
                            {% elseif header.type == 'fw-weightagequota' %}
                                <td style="border:1px solid black;" rowspan="{{record.rowspan ? record.rowspan : 1 }}">
                                    {% if record.weightageQuota and record.weightageQuota.id %}
                                        <span style="font-weight:bold;">{{record.weightageQuota.weightageName}}</span><br>
                                        {% for weightageDetails in record.weightageQuota.childList %}
                                            <span>{{weightageDetails.subDivisionName}} : {{weightageDetails.selected}}</span><br>
                                        {% endfor %}
                                    {% elseif (record.dataGridWeightageQuota | length)  %}
                                        {% for wghtQta in record.dataGridWeightageQuota %}
                                                <span style="font-weight:bold;">{{wghtQta.weightageQuota.weightageName}}</span><br>
                                                {% for weightageDetails in wghtQta.weightageQuota.childList %}
                                                    <span>{{weightageDetails.subDivisionName}} : {{weightageDetails.selected}}</span><br>
                                                {% endfor %}

                                        {% endfor %}
    
                                    {% endif %}

                                </td>
                            {% elseif header.key == 'extraPaymentInfo' %}
                                <td style="border:1px solid black;" rowspan="{{record.rowspan ? record.rowspan : 1 }}">
                                    {% if record.extraPaymentInfoPaymentMethod and record.extraPaymentInfoPaymentMethod == 'ONLINE' %}
                                        {% if record.extraPaymentInfoOnlineTransactionId %}
                                            <p>
                                                <span style='border:1px solid black;'>Transaction ID : </span>
                                                <span style='border:1px solid black;'> {{record.extraPaymentInfoOnlineTransactionId}}</span>
                                            </p>
                                        {% endif %}
                                    {% elseif record.extraPaymentInfoPaymentMethod == 'DD' %}
                                        {% if record.extraPaymentInfoOfflineDdNumber %}
                                            <p>
                                                <span>DD Number : </span>
                                                <span> {{record.extraPaymentInfoOfflineDdNumber}}</span>
                                            </p>
                                        {% endif %}
                                        {% if record.extraPaymentInfoOfflineDdDate %}
                                            <p>
                                                <span>DD Date : </span>
                                                <span>{{record.extraPaymentInfoOfflineDdDate}}</span>
                                            </p>
                                        {% endif %}
                                        {% if record.extraPaymentInfoOfflineBankName %}
                                            <p>
                                                <span>Bank Name : </span>
                                                <span> {{record.extraPaymentInfoOfflineBankName}}</span>
                                            </p>
                                        {% endif %}
                                        {% if record.extraPaymentInfoOfflineBankBranch %}
                                            <p>
                                                <span>Bank Branch : </span>
                                                <span> {{record.extraPaymentInfoOfflineBankBranch}}</span>
                                            </p>
                                        {% endif %}
                                    {% elseif record.extraPaymentInfoPaymentMethod == 'CHEQUE' %}
                                        {% if record.extraPaymentInfoOfflineCheckNo %}
                                            <p>
                                                <span>Cheque Number : </span>
                                                <span> {{record.extraPaymentInfoOfflineCheckNo}}</span>
                                            </p>
                                        {% endif %}
                                        {% if record.extraPaymentInfoOfflineChequeDate %}
                                            <p>
                                                <span>Cheque Date : </span>
                                                <span> {{record.extraPaymentInfoOfflineChequeDate}}</span>
                                            </p>
                                        {% endif %}
                                    {% elseif record.extraPaymentInfoPaymentMethod == 'NEFT' %}
                                        {% if record.extraPaymentInfoOfflineReceiptNo %}
                                            <p>
                                                <span>Receipt No : </span>
                                                <span>{{record.extraPaymentInfoOfflineReceiptNo}}</span>
                                            </p>
                                        {% endif %}
                                    {% endif %}
                                </td>

                             {% elseif header.type == 'fw-choices' and header.key != 'admittedChoice' %}
                                <td  style="border:1px solid black;"rowspan="{{record.rowspan ? record.rowspan : 1 }}">
                                    {% for pref in attribute(record,header.key) %}
                                        {{pref.prefNo}} {{pref.courseName}}<br>
                                    {% endfor %}
                                </td>
                            {% elseif header.type == 'fw-percentage' %}
                                <td style="border:1px solid black;text-align:center;" rowspan="{{record.rowspan ? record.rowspan : 1 }}">
                                    {{ attribute(record,header.key).percentage }}
                                </td>
                            {% elseif header.type == 'fw-maxmark' %}
                                <td style="border:1px solid black;text-align:center;" rowspan="{{record.rowspan ? record.rowspan : 1 }}">
                                    {{ attribute(record,header.key).totalMaxMark }}
                                </td>
                            {% elseif header.type == 'fw-obtainedmark' %}
                                <td style="border:1px solid black;text-align:center;" rowspan="{{record.rowspan ? record.rowspan : 1 }}">
                                    {{ attribute(record,header.key).totalMark }}
                                </td>

                            {% elseif header.type == 'fw-ugmaxmark' %}
                                <td style="border:1px solid black;text-align:center;" rowspan="{{record.rowspan ? record.rowspan : 1 }}">
                                {% set consolidateMarkList = record.UGMARKMARKDETAILS|first %}
                                {% if  consolidateMarkList.term==0 %}
                                    {% set semDetails = record.UGMARKPROCESSED.semMark|first %}
                                    {{ semDetails.markObtained > 0 ? semDetails.maxMark : '' }}
                                {% else %}
                                    {{ record.UGMARKPROCESSED.totalMark > 0 ? record.UGMARKPROCESSED.totalMaxMark : '' }}
                                {% endif %}
                                </td>
                            {% elseif header.type == 'fw-ugobtainedmark' %}
                                <td style="border:1px solid black;text-align:center;" rowspan="{{record.rowspan ? record.rowspan : 1 }}">
                                     {% set consolidateMarkList = record.UGMARKMARKDETAILS|first %}
                                    {% if  consolidateMarkList.term==0 %}
                                        {% set semDetails = record.UGMARKPROCESSED.semMark|first %}
                                        {{ semDetails.markObtained }}
                                    {% else %}
                                        {{ record.UGMARKPROCESSED.totalMark }}
                                    {% endif %}
                                </td>
                            {% elseif header.type == 'fw-ugtotalcgpa' %}
                                <td style="border:1px solid black;text-align:center;" rowspan="{{record.rowspan ? record.rowspan : 1 }}">
                                     {% set consolidateMarkList = record.UGMARKMARKDETAILS|first %}
                                     {{ consolidateMarkList.sgpa }}
                                </td>
                            {% elseif header.type == 'fw-ugtotalcredit' %}
                                <td style="border:1px solid black;text-align:center;" rowspan="{{record.rowspan ? record.rowspan : 1 }}">
                                     {% set consolidateMarkList = record.UGMARKMARKDETAILS|first %}
                                     {{ consolidateMarkList.totalCredit }}
                                </td>
                            {% elseif header.type == 'fw-ugtotalcreditpoint' %}
                                <td style="border:1px solid black;text-align:center;" rowspan="{{record.rowspan ? record.rowspan : 1 }}">
                                     {% set consolidateMarkList = record.UGMARKMARKDETAILS|first %}
                                     {{ consolidateMarkList.totalCreditPoint }}
                                </td>
                            {% elseif header.dataConst == 'CHOICE' %}
                                <td style="border:1px solid black;" rowspan="{{record.rowspan ? record.rowspan : 1 }}">
                                    {% set key = 'choiceName' ~ header.key | slice (6,(header.key | length))  %}
                                    {{ attribute(record,key) }}
                                </td>
                            {% elseif header.type == 'fw-markentry' and header.showAs == 'COLUMN' %}
                                {% if header.key=='UGCONSOLICATEDCOLUMNMARK' %}
                                    {% for semNo, headComponent in header.components %}
                                        {% for field in headComponent.components %}
                                            <td style="border:1px solid black;text-align:center;" v-if="row.UGMARKMARKDETAILS">
                                                {% if  field.key=='percentage' %}
                                                    {% set semDetails = consolidateMarkList.markList[semNo] %}
                                                    {% if semDetails|length > 0 %}
                                                    {% set precentage = (semDetails.marksObtained/semDetails.maxMarks)*100 %}
                                                    {{precentage|round(2, 'floor')}}
                                                    {% endif %}

                                                {% else %}
                                                    {% set consolidateMarkList = record.UGMARKMARKDETAILS|first %}
                                                    {% set semDetails = consolidateMarkList.markList[semNo] %}
                                                {{attribute(semDetails,field.key)}}
                                                {% endif %}
                                            </td>
                                        {% endfor %}
                                    {% endfor %}
                                {% elseif header.key=='UGDETAILEDCONSOLICATEDCOLUMNMARK' %}
                                    {% for semNo, headComponent in header.components %}
                                        {% for field in headComponent.components %}
                                            <td style="border:1px solid black;text-align:center;" v-if="row.UGMARKMARKDETAILS">
                                                {% if  field.key=='percentage' %}
                                                    {% set semDetails = consolidateMarkList.markList[semNo] %}
                                                    {% if semDetails|length > 0 %}
                                                    {% set precentage = (semDetails.marksObtained/semDetails.maxMarks)*100 %}
                                                    {{ semDetails.marksObtained >0 ? precentage|round(2, 'floor') : ''}}
                                                    {% endif %}

                                                {% else %}
                                                    {% set consolidateMarkList = record.UGMARKMARKDETAILS|first %}
                                                    {% set semDetails = consolidateMarkList.markList[semNo] %}
                                                {{attribute(semDetails,field.key)}}
                                                {% endif %}
                                            </td>
                                        {% endfor %}
                                    {% endfor %}
                                {% elseif header.key=='UGCONSOLICATEDCOLUMNSUBJECTGROUP' %}
                                    {% for semNo, headComponent in header.components %}
                                        {% for field in headComponent.components %}
                                            <td style="border:1px solid black;text-align:center;" v-if="row.UGMARKMARKDETAILS">
                                                {% if attribute(record,'UGMARKMARKDETAILS')[0].markList %}
                                                    {% for k, v in attribute(record,'UGMARKMARKDETAILS')[0].markList|filter((v, k) => v.subjectGroupId == headComponent.groupId) %}
                                                        {% if field.key == 'maxMarks' %}
                                                            {{v.marksObtained > 0 ? attribute(v,field.key) : ''}}
                                                        {% else %}
                                                            {{attribute(v,field.key)}}
                                                        {% endif %}
                                                    {% endfor %}
                                                {% endif %}
                                            </td>
                                        {% endfor %}
                                    {% endfor %}
                                {% else %}
                                    {% for subject in header.components %}
                                        <td style="border:1px solid black;" rowspan="{{record.rowspan ? record.rowspan : 1 }}">
                                            {% if attribute(record,'markDetails' ~ header.key).markDetails %}
                                                {% for k, v in attribute(record,'markDetails' ~ header.key).markDetails|filter((v, k) => v.subjectId == subject.key) %}
                                                    {% if (subject.keyToDisplay == 'markObtained') %}
                                                        {{ v.markObtained ?v.markObtained:0 }}
                                                    {% endif %}
                                                    {% if (subject.keyToDisplay == 'maxMark') %}
                                                        {{ v.maxMark ?v.maxMark:0 }}
                                                    {% endif %}
                                                {% endfor %}
                                            {% endif %}
                                        </td>
                                    {% endfor %}
                                {% endif %}
                            {% elseif header.type == 'fw-datagrid' %}
                                {% set fieldSetData = attribute(record.extraDetails,header.key) %}
                                {% if ( fieldSetData | length > 0 ) %}
                                    {% if header.showAs == '' %}
                                        {% for component in header.components %}
                                            <td rowspan="{{record.rowspan and (fieldSetData | length == 1) ? record.rowspan : 1 }}" style="border:1px solid black;">
                                                {{attribute(fieldSetData[0],component.key)}}
                                            </td>
                                        {% endfor %}
                                    {% else %}
                                        {% for i, datagridData in fieldSetData %}
                                            {% for component in header.primaryComponents %}
                                            <td rowspan="{{record.rowspan ? record.rowspan : 1 }}" style="border:1px solid black;">
                                                {{attribute(datagridData,component.key)}}
                                            </td>
                                        {% endfor %}
                                        {% endfor %}
                                        {% set k = (header.components | length) - ((fieldSetData | length) * header.componentsCount) %}
                                        {% if k > 0 %}
                                            {% for i in range(1, k) %}
                                                <td rowspan="{{record.rowspan ? record.rowspan : 1 }}" style="border:1px solid black;">
                                                </td>
                                            {% endfor %}
                                        {% endif %}
                                    {% endif %}
                                {% else %}  
                                    {% for component in header.components %}
                                        <td rowspan="{{record.rowspan ? record.rowspan : 1 }}" style="border:1px solid black;">
                                        </td>
                                    {% endfor %}                                  
                                {% endif %}
                            {% else %}

                            {% set uppercaseFields = ['studentFirstName','fatherName','motherName'] %}
                            <td style="border:1px solid black;height: 50px; text-align: left; " rowspan="{{record.rowspan ? record.rowspan : 1 }}">
                                {% if (header.multiple) %}
                                    {% set dataToDisplay = attribute(record.extraDetails,header.key) | replace({'[': ''}) | replace({']': ''}) | replace({'\"': ''}) %}
                                
                                    {{dataToDisplay}}
                                {% else %}  
                                    {% if header.key in uppercaseFields %}
                                        {{ attribute(record.extraDetails,"other" ~ header.key) ? attribute(record.extraDetails,"other" ~ header.key)|upper :(attribute(record,header.key)?attribute(record,header.key)|upper:attribute(record.extraDetails,header.key)|upper) }}
                                    {% elseif header.multipleRow %}
                                        {{ attribute(record,header.key)|raw}}
                                    {% else %}
                                        {{ attribute(record.extraDetails,"other" ~ header.key) ? attribute(record.extraDetails,"other" ~ header.key) :attribute(record,header.key)? attribute(record,header.key):attribute(record.extraDetails,header.key) }}
                                    {% endif %}
                                {% endif %}
                                </td>

                            {% endif %}
                        {% endfor %}
                    </tr>
                    {% if record.rowspan > 1 %}
                        {% for markEntryIndex in range(0,record.rowspan-1) %}
                             {% if markEntryIndex != 0 %}
                            <tr>
                                {% for header in report.properties.components %}
                                    {% if header.type == 'fw-markentry'  and header.showAs !=   'COLUMN'  %}
                                    
                                            {% if attribute(record,'markDetails' ~ header.key).markDetails[0].markList | length <= 0  %}
                                                <td style="border:1px solid black;">
                                                    {{ attribute(record,'markDetails' ~ header.key).markDetails[markEntryIndex].subjectName }}
                                                </td>
                                                <td style="border:1px solid black;text-align:center;">
                                                {{ attribute(record,'markDetails' ~ header.key).markDetails[markEntryIndex].markObtained }}
                                                </td>
                                                <td style="border:1px solid black;text-align:center;">
                                                    {{ attribute(record,'markDetails' ~ header.key).markDetails[markEntryIndex].maxMark }}
                                                    </td>
                                                {% for sem in range(1, header.numberOfTerms) %}
                                                <td style="border:1px solid black;">
                                                </td>
                                                    <td style="border:1px solid black;text-align:center;">
                                                    </td> 
                                                {% endfor %}
                                                {% else %}
                                                    <td style="border:1px solid black;">
                                                </td>
                                                    <td style="border:1px solid black;text-align:center;">
                                                    </td> 
                                                    <td style="border:1px solid black;text-align:center;">
                                                    </td> 
                                                    {% for markDetails in attribute(record,'markDetails' ~ header.key).markDetails %}
                                                        <td style="border:1px solid black;">
                                                        {{ markDetails.markList[markEntryIndex].subjectName }}
                                                        </td>
                                                        <td style="border:1px solid black;text-align:center;">
                                                        {{ markDetails.markList[markEntryIndex].marksObtained }}
                                                        </td>
                                                        <td style="border:1px solid black;text-align:center;">
                                                            {{ markDetails.markList[markEntryIndex].maxMark }}
                                                            </td>
                                                    {% endfor %}
                                                    {% for i in range(1, header.numberOfTerms - attribute(record,'markDetails' ~ header.key).markDetails | length) %}
                                                        <td style="border:1px solid black;">
                                                        </td>
                                                        <td style="border:1px solid black;text-align:center;">
                                                        </td> 
                                                        <td style="border:1px solid black;text-align:center;">
                                                        </td> 
                                                    {% endfor %}
                                                {% endif %}
                                            </td>
                                    {% elseif header.type == 'fw-datagrid' and header.showAs !='COLUMN'%}
                                        {% set fieldSetData = attribute(record.extraDetails,header.key) %}
                                        {% if ( fieldSetData | length > 1 ) and  markEntryIndex != 0 %}
                                            {% for component in header.components %}
                                                <td style="border:1px solid black;">
                                                    {{attribute(fieldSetData[markEntryIndex],component.key)}}
                                                </td>
                                            {% endfor %}                              
                                        {% endif %}
                                    {% endif %}
                                {% endfor %}
                            </tr>
                             {% endif %}
                        {% endfor %}
                    {% endif %}
                {% endfor %}
            </tbody>
        </table>
    </body>
    <footer>
    </footer>
</html>