<?xml version="1.0" encoding="utf-8" ?>
<odoo>
    <data>
        <template id="report_hash_integrity">
            <t t-call="web.html_container">
                <t t-foreach="docs" t-as="company">
                    <t t-call="web.external_layout">
                        <div class="page">
                            <div class="row" id="hash_header">
                                <div class="col-12">
                                    <br/>
                                    <h2>Data Inalterability Check Report - <span t-out="data['printing_date']"/></h2>
                                    <br/>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-12" id="hash_config_review">
                                    <br/>
                                    <h3>Configuration review</h3>
                                    <br/>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-12">
                                    <table class="table table-borderless" id="hash_config_table">
                                        <thead style="display: table-row-group">
                                            <tr>
                                                <th style="width: 30%" scope="col">Journal (Sequence Prefix)</th>
                                                <th class="text-center text-nowrap" style="width: 20%" scope="col">Restricted</th>
                                                <th style="width: 50%" scope="col">Check</th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                            <t t-foreach="data['results']" t-as="result">
                                                <tr>
                                                    <td>
                                                        <span t-out="result['journal_name']"/>
                                                    </td>
                                                    <td class="text-center"><span t-out="result['restricted_by_hash_table']"/></td>
                                                    <td><span t-out="result['msg_cover']"/></td>
                                                </tr>
                                            </t>
                                        </tbody>
                                    </table>
                                </div>
                            </div>
                            <t t-if="any(result['status'] == 'verified' for result in data['results'])">
                                <div class="row" style="page-break-before:always;">
                                    <div class="col-12" id="hash_data_consistency">
                                        <br/>
                                        <h3>Data consistency check</h3>
                                        <br/>
                                    </div>
                                </div>
                                <div class="row">
                                    <div class="col-12" id="hash_data_consistency_table">
                                        <table class="table table-borderless">
                                            <thead style="display: table-row-group; border-bottom: 1px solid black;">
                                                <tr>
                                                    <th class="text-start fw-bold" style="width: 20%" scope="col">Journal</th>
                                                    <th class="text-start fw-bold" style="width: 20%" scope="col">First Hash</th>
                                                    <th class="text-start fw-bold" style="width: 20%" scope="col">First Entry</th>
                                                    <th class="text-start fw-bold" style="width: 20%" scope="col">Last Hash</th>
                                                    <th class="text-start fw-bold" style="width: 20%" scope="col">Last Entry</th>
                                                </tr>
                                            </thead>
                                            <tbody>
                                                <t t-foreach="data['results']" t-as="result">
                                                    <t t-if="result['status'] == 'verified'">
                                                        <tr style="border-bottom: 1px solid lightgrey;">
                                                            <td class="align-top"><span t-out="result['journal_name']"/></td>
                                                            <td class="align-top text-break"><span t-out="result['first_hash']"/></td>
                                                            <td class="align-top">
                                                                <span t-out="result['first_move_name']"/> <br/>
                                                                <span t-out="result['first_move_date']"/>
                                                            </td>
                                                            <td class="align-top text-break"><span t-out="result['last_hash']"/></td>
                                                            <td class="align-top">
                                                                <span t-out="result['last_move_name']"/> <br/>
                                                                <span t-out="result['last_move_date']"/>
                                                            </td>
                                                        </tr>
                                                    </t>
                                                </t>
                                            </tbody>
                                        </table>
                                    </div>
                                </div>
                                <div class="row" id="hash_last_div">
                                    <div class="col-12" id="hash_chain_compliant">
                                        <br/>
                                        <h6>
                                            The hash chain is compliant: it is not possible to alter the
                                            data without breaking the hash chain for subsequent parts.
                                        </h6>
                                        <br/>
                                    </div>
                                </div>
                            </t>
                        </div>
                    </t>
                </t>
            </t>
        </template>
    </data>
</odoo>
