<div id="coach_output_gbu_mittelwerte_{{outputId}}">
{% if isKAdmin%}

    {% for company in tableKAdmin.companies %}
        <div class="coach_output_gbu_mittelwerte_container_kadmin" id="coach_output_gbu_mittelwerte_{{outputId}}_kadmin_{{loop.index0}}">
            <div class="mr-auto coach_output_gbu_mittelwerte_company_button">
                <button class="btn btn-link ts-list-button px-0" data-toggle="collapse" {%set randCompany = random()%} data-target="#gbu_mittelwerte_kadmin_companies_{{randCompany}}" aria-expanded="false">
                    <p class="h4 primary-color">
                        <i class="fas fa-plus ts-accordion-plus"></i>{{company.companyname}}
                    </p>
                </button>
            </div>
            <div id="gbu_mittelwerte_kadmin_companies_{{randCompany}}" class="collapse mt-2 coach_output_gbu_mittelwerte_groups">
                
                {% if showScales %}
                    {% if company.scale_table.group_information | length > 2 %}
                    <table class="table table-bordered coach_output_gbu_mittelwerte_table">
                        <thead>
                            <tr>
                                <th></th>
                                <th>gesamt {% set inputCountTotal_min = null %}{% set inputCountTotal_max = null %}{% for scale in company.scale_table.scales%}{% if inputCountTotal_min is null %}{% set inputCountTotal_min = scale.gesamt.scale_input_count_min %}{% else %}{% if inputCountTotal_min > scale.gesamt.scale_input_count_min %}{% set inputCountTotal_min = scale.gesamt.scale_input_count_min %}{% endif %}{% endif %}{% if inputCountTotal_max is null %}{% set inputCountTotal_max = scale.gesamt.scale_input_count_max %}{% else %}{% if inputCountTotal_max < scale.gesamt.scale_input_count_max %}{% set inputCountTotal_max = scale.gesamt.scale_input_count_max %}{% endif %}{% endif %}{% endfor %}{% if inputCountTotal_min == inputCountTotal_max %}({{inputCountTotal_min}} Person{% if inputCountTotal_min != 1%}en{% endif %}){% else %}({{inputCountTotal_min}}-{{inputCountTotal_max}} Personen){% endif %}</th>
                                <th>
                                    <select class="form-control gbu-mittelwerte-select">
                                        {% for groupID, group in company.scale_table.group_information %}
                                        <option value="{{groupID}}" {% if loop.index0 == 1 %}disabled{% endif %}>{{group.groupname}} {% set inputCountGroup_min = null %}{% set inputCountGroup_max = null %}{% for scale in company.scale_table.scales%}{% if inputCountGroup_min is null %}{% set inputCountGroup_min = scale.groups[groupID].scale_input_count_min %}{% else %}{% if inputCountGroup_min > scale.groups[groupID].scale_input_count_min %}{% set inputCountGroup_min = scale.groups[groupID].scale_input_count_min %}{% endif %}{% endif %}{% if inputCountGroup_max is null %}{% set inputCountGroup_max = scale.groups[groupID].scale_input_count_max %}{% else %}{% if inputCountGroup_max < scale.groups[groupID].scale_input_count_max %}{% set inputCountGroup_max = scale.groups[groupID].scale_input_count_max %}{% endif %}{% endif %}{% endfor %}{% if inputCountGroup_min == inputCountGroup_max %}({{inputCountGroup_min}} Person{% if inputCountGroup_min != 1%}en{% endif %}){% else %}({{inputCountGroup_min}}-{{inputCountGroup_max}} Personen){% endif %}</option>
                                        {% endfor %}
                                    </select>
                                </th>
                                <th>
                                    <select class="form-control gbu-mittelwerte-select">
                                        {% for groupID, group in company.scale_table.group_information %}
                                        <option value="{{groupID}}" {% if loop.index0 == 0 %}disabled{% endif %}>{{group.groupname}} {% set inputCountGroup_min = null %}{% set inputCountGroup_max = null %}{% for scale in company.scale_table.scales%}{% if inputCountGroup_min is null %}{% set inputCountGroup_min = scale.groups[groupID].scale_input_count_min %}{% else %}{% if inputCountGroup_min > scale.groups[groupID].scale_input_count_min %}{% set inputCountGroup_min = scale.groups[groupID].scale_input_count_min %}{% endif %}{% endif %}{% if inputCountGroup_max is null %}{% set inputCountGroup_max = scale.groups[groupID].scale_input_count_max %}{% else %}{% if inputCountGroup_max < scale.groups[groupID].scale_input_count_max %}{% set inputCountGroup_max = scale.groups[groupID].scale_input_count_max %}{% endif %}{% endif %}{% endfor %}{% if inputCountGroup_min == inputCountGroup_max %}({{inputCountGroup_min}} Person{% if inputCountGroup_min != 1%}en{% endif %}){% else %}({{inputCountGroup_min}}-{{inputCountGroup_max}} Personen){% endif %}</option>
                                        {% endfor %}
                                    </select>
                                </th>
                            </tr>
                        </thead>
                        <tbody>
                            {% for scalename, scale in company.scale_table.scales %}
                            <tr>
                                <td style="background-color: #ffffff;">{{scalename}}</td>
                                <td style="background-color: #{{scale.gesamt.val_color}};">{{scale.gesamt.scale_mean}}</td>
                                {% for groupID, group in scale.groups %}
                                <td opt="0" groupid="{{groupID}}" {% if loop.index0 != 0%}class="d-none"{% endif%} style="background-color: #{{group.val_color}};">{{group.scale_mean}}</td>
                                {% endfor %}
                                {% for groupID, group in scale.groups %}
                                <td opt="1" groupid="{{groupID}}" {% if loop.index0 != 1%}class="d-none"{% endif%} style="background-color: #{{group.val_color}};">{{group.scale_mean}}</td>
                                {% endfor %}
                            </tr>
                            {% endfor %}
                        </tbody>
                    </table>
                    <p>(-) Benötigte Anzahl von {{MINTEILNEHMER}} {% if MINTEILNEHMER == 1%}Person{% else %}Personen{% endif %} nicht erreicht</p>
                    {% else %}
                    <table class="table table-bordered coach_output_gbu_mittelwerte_table">
                        <thead>
                            <tr>
                                <th></th>
                                <th>gesamt {% set inputCountTotal_min = null %}{% set inputCountTotal_max = null %}{% for scale in company.scale_table.scales%}{% if inputCountTotal_min is null %}{% set inputCountTotal_min = scale.gesamt.scale_input_count_min %}{% else %}{% if inputCountTotal_min > scale.gesamt.scale_input_count_min %}{% set inputCountTotal_min = scale.gesamt.scale_input_count_min %}{% endif %}{% endif %}{% if inputCountTotal_max is null %}{% set inputCountTotal_max = scale.gesamt.scale_input_count_max %}{% else %}{% if inputCountTotal_max < scale.gesamt.scale_input_count_max %}{% set inputCountTotal_max = scale.gesamt.scale_input_count_max %}{% endif %}{% endif %}{% endfor %}{% if inputCountTotal_min == inputCountTotal_max %}({{inputCountTotal_min}} Person{% if inputCountTotal_min != 1%}en{% endif %}){% else %}({{inputCountTotal_min}}-{{inputCountTotal_max}} Personen){% endif %}</th>
                                {% for groupID, group in company.scale_table.group_information %}
                                    <th>{{group.groupname}} {% set inputCountGroup_min = null %}{% set inputCountGroup_max = null %}{% for scale in company.scale_table.scales%}{% if inputCountGroup_min is null %}{% set inputCountGroup_min = scale.groups[groupID].scale_input_count_min %}{% else %}{% if inputCountGroup_min > scale.groups[groupID].scale_input_count_min %}{% set inputCountGroup_min = scale.groups[groupID].scale_input_count_min %}{% endif %}{% endif %}{% if inputCountGroup_max is null %}{% set inputCountGroup_max = scale.groups[groupID].scale_input_count_max %}{% else %}{% if inputCountGroup_max < scale.groups[groupID].scale_input_count_max %}{% set inputCountGroup_max = scale.groups[groupID].scale_input_count_max %}{% endif %}{% endif %}{% endfor %}{% if inputCountGroup_min == inputCountGroup_max %}({{inputCountGroup_min}} Person{% if inputCountGroup_min != 1%}en{% endif %}){% else %}({{inputCountGroup_min}}-{{inputCountGroup_max}} Personen){% endif %}</th>
                                {% endfor %}
                            </tr>
                        </thead>
                        <tbody>
                            {% for scalename, scale in company.scale_table.scales %}
                                <tr>
                                    <td style="background-color: #ffffff;">{{scalename}}</td>
                                    <td style="background-color: #{{scale.gesamt.val_color}};">{{scale.gesamt.scale_mean}}</td>
                                    {% for groupID, group in scale.groups %}
                                    <td style="background-color: #{{group.val_color}};">{{group.scale_mean}}</td>
                                    {% endfor %}
                                </tr>
                            {% endfor %}
                        </tbody>
                    </table>
                    <p>(-) Benötigte Anzahl von {{MINTEILNEHMER}} {% if MINTEILNEHMER == 1%}Person{% else %}Personen{% endif %} nicht erreicht</p>
                    {% endif %}
                {% endif %}

                {% if showSubscales %}
                    {% if company.subscale_table.group_information | length > 2 %}
                    <table class="table table-bordered coach_output_gbu_mittelwerte_table">
                        <thead>
                            <tr>
                                <th></th>
                                <th>gesamt {% set inputCountTotal_min = null %}{% set inputCountTotal_max = null %}{% for scale in company.scale_table.scales%}{% if inputCountTotal_min is null %}{% set inputCountTotal_min = scale.gesamt.scale_input_count_min %}{% else %}{% if inputCountTotal_min > scale.gesamt.scale_input_count_min %}{% set inputCountTotal_min = scale.gesamt.scale_input_count_min %}{% endif %}{% endif %}{% if inputCountTotal_max is null %}{% set inputCountTotal_max = scale.gesamt.scale_input_count_max %}{% else %}{% if inputCountTotal_max < scale.gesamt.scale_input_count_max %}{% set inputCountTotal_max = scale.gesamt.scale_input_count_max %}{% endif %}{% endif %}{% endfor %}{% if inputCountTotal_min == inputCountTotal_max %}({{inputCountTotal_min}} Person{% if inputCountTotal_min != 1%}en{% endif %}){% else %}({{inputCountTotal_min}}-{{inputCountTotal_max}} Personen){% endif %}</th>
                                <th>
                                    <select class="form-control gbu-mittelwerte-select">
                                        {% for groupID, group in company.subscale_table.group_information %}
                                        <option value="{{groupID}}" {% if loop.index0 == 1 %}disabled{% endif %}>{{group.groupname}} {% set inputCountGroup_min = null %}{% set inputCountGroup_max = null %}{% for scale in company.scale_table.scales%}{% if inputCountGroup_min is null %}{% set inputCountGroup_min = scale.groups[groupID].scale_input_count_min %}{% else %}{% if inputCountGroup_min > scale.groups[groupID].scale_input_count_min %}{% set inputCountGroup_min = scale.groups[groupID].scale_input_count_min %}{% endif %}{% endif %}{% if inputCountGroup_max is null %}{% set inputCountGroup_max = scale.groups[groupID].scale_input_count_max %}{% else %}{% if inputCountGroup_max < scale.groups[groupID].scale_input_count_max %}{% set inputCountGroup_max = scale.groups[groupID].scale_input_count_max %}{% endif %}{% endif %}{% endfor %}{% if inputCountGroup_min == inputCountGroup_max %}({{inputCountGroup_min}} Person{% if inputCountGroup_min != 1%}en{% endif %}){% else %}({{inputCountGroup_min}}-{{inputCountGroup_max}} Personen){% endif %}</option>
                                        {% endfor %}
                                    </select>
                                </th>
                                <th>
                                    <select class="form-control gbu-mittelwerte-select">
                                        {% for groupID, group in company.subscale_table.group_information %}
                                        <option value="{{groupID}}" {% if loop.index0 == 0 %}disabled{% endif %}>{{group.groupname}} {% set inputCountGroup_min = null %}{% set inputCountGroup_max = null %}{% for scale in company.scale_table.scales%}{% if inputCountGroup_min is null %}{% set inputCountGroup_min = scale.groups[groupID].scale_input_count_min %}{% else %}{% if inputCountGroup_min > scale.groups[groupID].scale_input_count_min %}{% set inputCountGroup_min = scale.groups[groupID].scale_input_count_min %}{% endif %}{% endif %}{% if inputCountGroup_max is null %}{% set inputCountGroup_max = scale.groups[groupID].scale_input_count_max %}{% else %}{% if inputCountGroup_max < scale.groups[groupID].scale_input_count_max %}{% set inputCountGroup_max = scale.groups[groupID].scale_input_count_max %}{% endif %}{% endif %}{% endfor %}{% if inputCountGroup_min == inputCountGroup_max %}({{inputCountGroup_min}} Person{% if inputCountGroup_min != 1%}en{% endif %}){% else %}({{inputCountGroup_min}}-{{inputCountGroup_max}} Personen){% endif %}</option>
                                        {% endfor %}
                                    </select>
                                </th>
                            </tr>
                        </thead>
                        <tbody>
                            {% for scalename, scale in company.subscale_table.scales %}
                            <tr>
                                <td style="background-color: #ffffff;" colspan="4"><b>{{scalename}}</b></td>
                            </tr>
                                {% for subscalename, subscale in scale.subscales %}
                                <tr>
                                    <td style="background-color: #ffffff;">{{subscalename}}</td>
                                    <td style="background-color: #{{subscale.gesamt.val_color}};">{{subscale.gesamt.subscale_mean}}</td>
                                    {% for groupID, group in subscale.groups %}
                                    <td opt="0" groupid="{{groupID}}" {% if loop.index0 != 0%}class="d-none"{% endif%} style="background-color: #{{group.val_color}};">{{group.subscale_mean}}</td>
                                    {% endfor %}
                                    {% for groupID, group in subscale.groups %}
                                    <td opt="1" groupid="{{groupID}}" {% if loop.index0 != 1%}class="d-none"{% endif%} style="background-color: #{{group.val_color}};">{{group.subscale_mean}}</td>
                                    {% endfor %}
                                </tr>
                                {% endfor %}
                            {% endfor %}
                        </tbody>
                    </table>
                    <p>(-) Benötigte Anzahl von {{MINTEILNEHMER}} {% if MINTEILNEHMER == 1%}Person{% else %}Personen{% endif %} nicht erreicht</p>
                    {% else %}
                    <table class="table table-bordered coach_output_gbu_mittelwerte_table">
                        <thead>
                            <tr>
                                <th></th>
                                <th>gesamt {% set inputCountTotal_min = null %}{% set inputCountTotal_max = null %}{% for scale in company.scale_table.scales%}{% if inputCountTotal_min is null %}{% set inputCountTotal_min = scale.gesamt.scale_input_count_min %}{% else %}{% if inputCountTotal_min > scale.gesamt.scale_input_count_min %}{% set inputCountTotal_min = scale.gesamt.scale_input_count_min %}{% endif %}{% endif %}{% if inputCountTotal_max is null %}{% set inputCountTotal_max = scale.gesamt.scale_input_count_max %}{% else %}{% if inputCountTotal_max < scale.gesamt.scale_input_count_max %}{% set inputCountTotal_max = scale.gesamt.scale_input_count_max %}{% endif %}{% endif %}{% endfor %}{% if inputCountTotal_min == inputCountTotal_max %}({{inputCountTotal_min}} Person{% if inputCountTotal_min != 1%}en{% endif %}){% else %}({{inputCountTotal_min}} - {{inputCountTotal_max}} Personen){% endif %}</th>
                                {% for groupID, group in company.subscale_table.group_information %}
                                    <th>{{group.groupname}}{% set inputCountGroup_min = null %}{% set inputCountGroup_max = null %}{% for scale in company.scale_table.scales%}{% if inputCountGroup_min is null %}{% set inputCountGroup_min = scale.groups[groupID].scale_input_count_min %}{% else %}{% if inputCountGroup_min > scale.groups[groupID].scale_input_count_min %}{% set inputCountGroup_min = scale.groups[groupID].scale_input_count_min %}{% endif %}{% endif %}{% if inputCountGroup_max is null %}{% set inputCountGroup_max = scale.groups[groupID].scale_input_count_max %}{% else %}{% if inputCountGroup_max < scale.groups[groupID].scale_input_count_max %}{% set inputCountGroup_max = scale.groups[groupID].scale_input_count_max %}{% endif %}{% endif %}{% endfor %}{% if inputCountGroup_min == inputCountGroup_max %}({{inputCountGroup_min}} Person{% if inputCountGroup_min != 1%}en{% endif %}){% else %}({{inputCountGroup_min}} - {{inputCountGroup_max}} Personen){% endif %}</th>
                                {% endfor %}
                            </tr>
                        </thead>
                        <tbody>
                            {% for scalename, scale in company.subscale_table.scales %}
                            <tr>
                                <td style="background-color: #ffffff;" colspan="{% if company.subscale_table.group_information | length == 2 %}4{% elseif company.subscale_table.group_information | length == 1 %}3{% endif %}"><b>{{scalename}}</b></td>
                            </tr>
                                {% for subscalename, subscale in scale.subscales %}
                                <tr>
                                    <td style="background-color: #ffffff;">{{subscalename}}</td>
                                    <td style="background-color: #{{subscale.gesamt.val_color}};">{{subscale.gesamt.subscale_mean}}</td>
                                    {% for groupID, group in subscale.groups %}
                                    <td style="background-color: #{{group.val_color}};">{{group.subscale_mean}}</td>
                                    {% endfor %}
                                </tr>
                                {% endfor %}
                            {% endfor %}
                        </tbody>
                    </table>
                    <p>(-) Benötigte Anzahl von {{MINTEILNEHMER}} {% if MINTEILNEHMER == 1%}Person{% else %}Personen{% endif %} nicht erreicht</p>
                    {% endif%}
                {% endif %}

                {% if showItems %}
                    {% if company.item_table.group_information | length > 2%}
                        {% for scalename, scale in company.item_table.scales %}
                        <div class="mr-auto coach_output_gbu_mittelwerte_button">
                            <button type="button" class="btn btn-link ts-list-button px-0" data-toggle="collapse" {%set rand = random()%} data-target="#gbu_mittelwerte_kadmin_items_{{rand}}" aria-expanded="false">
                                <p class="h6">
                                    <i class="fas fa-plus ts-accordion-plus"></i>{{scalename}}
                                </p>
                            </button>
                        </div>
                        <div id="gbu_mittelwerte_kadmin_items_{{rand}}" class="collapse mt-2 coach_output_gbu_mittelwerte_items coach_output_gbu_mittelwerte_accordion">
                            <table class="table table-bordered coach_output_gbu_mittelwerte_table">
                                <thead>
                                    <th></th>
                                    <th>gesamt {% if company.scale_table.scales[scalename].gesamt.scale_input_count_min == company.scale_table.scales[scalename].gesamt.scale_input_count_max %}({{company.scale_table.scales[scalename].gesamt.scale_input_count_min}} Person{% if company.scale_table.scales[scalename].gesamt.scale_input_count_min != 1 %}en{% endif %}){% else %}({{company.scale_table.scales[scalename].gesamt.scale_input_count_min}}-{{company.scale_table.scales[scalename].gesamt.scale_input_count_max}} Personen){% endif %}</th>
                                    <th>
                                        <select class="form-control gbu-mittelwerte-select">
                                            {% for groupID, group in company.item_table.group_information %}
                                            <option value="{{groupID}}" {% if loop.index0 == 1 %}disabled{% endif %}>{{group.groupname}} {% if company.scale_table.scales[scalename].groups[groupID].scale_input_count_min == company.scale_table.scales[scalename].groups[groupID].scale_input_count_max %}({{company.scale_table.scales[scalename].groups[groupID].scale_input_count_min}} Person{% if company.scale_table.scales[scalename].groups[groupID].scale_input_count_min != 1 %}en{% endif %}){% else %}({{company.scale_table.scales[scalename].groups[groupID].scale_input_count_min}}-{{company.scale_table.scales[scalename].groups[groupID].scale_input_count_max}} Personen){% endif %}</option>
                                            {% endfor %}
                                        </select>
                                    </th>
                                    <th>
                                        <select class="form-control gbu-mittelwerte-select">
                                            {% for groupID, group in company.item_table.group_information %}
                                            <option value="{{groupID}}" {% if loop.index0 == 0 %}disabled{% endif %}>{{group.groupname}} {% if company.scale_table.scales[scalename].groups[groupID].scale_input_count_min == company.scale_table.scales[scalename].groups[groupID].scale_input_count_max %}({{company.scale_table.scales[scalename].groups[groupID].scale_input_count_min}} Person{% if company.scale_table.scales[scalename].groups[groupID].scale_input_count_min != 1 %}en{% endif %}){% else %}({{company.scale_table.scales[scalename].groups[groupID].scale_input_count_min}}-{{company.scale_table.scales[scalename].groups[groupID].scale_input_count_max}} Personen){% endif %}</option>
                                            {% endfor %}
                                        </select>
                                    </th>
                                </thead>
                                <tbody>
                                    {% for subscalename, subscale in scale.subscales %}
                                        <tr>
                                            <td style="background-color: #ffffff;" colspan="4"><b>{{subscalename}}</b></td>
                                        </tr>
                                        {% for itemname, item in subscale.items %}
                                            <tr>
                                                <td style="background-color: #ffffff;">{{itemname}}</td>
                                                <td style="background-color: #{{item.gesamt.val_color}};">{{item.gesamt.item_mean}}</td>
                                                {% for groupID, group in item.groups %}
                                                <td opt="0" groupid="{{groupID}}" {% if loop.index0 != 0 %}class="d-none"{% endif %} style="background-color: #{{group.val_color}};">{{group.item_mean}}</td>
                                                {% endfor %}
                                                {% for groupID, group in item.groups %}
                                                <td opt="1" groupid="{{groupID}}" {% if loop.index0 != 1 %}class="d-none"{% endif %} style="background-color: #{{group.val_color}};">{{group.item_mean}}</td>
                                                {% endfor %}
                                            </tr>
                                        {% endfor %}
                                        <tr>
                                            <td style="background-color: lightgray;"><b>Insgesamt</b></td>
                                            <td style="background-color: #{{company.subscale_table.scales[scalename].subscales[subscalename].gesamt.val_color}};">{{company.subscale_table.scales[scalename].subscales[subscalename].gesamt.subscale_mean}}</td>
                                            {% for groupID, group in company.item_table.group_information %}
                                            <td opt="0" groupid="{{groupID}}" {% if loop.index0 != 0 %}class="d-none"{% endif %} style="background-color: #{{company.subscale_table.scales[scalename].subscales[subscalename].groups[groupID].val_color}};">{{company.subscale_table.scales[scalename].subscales[subscalename].groups[groupID].subscale_mean}}</td>
                                            {% endfor %}
                                            {% for groupID, group in company.item_table.group_information %}
                                            <td opt="1" groupid="{{groupID}}" {% if loop.index0 != 1 %}class="d-none"{% endif %} style="background-color: #{{company.subscale_table.scales[scalename].subscales[subscalename].groups[groupID].val_color}};">{{company.subscale_table.scales[scalename].subscales[subscalename].groups[groupID].subscale_mean}}</td>
                                            {% endfor %}
                                        </tr>
                                    {% endfor %}
                                </tbody>
                            </table>
                            <p>(-) Benötigte Anzahl von {{MINTEILNEHMER}} {% if MINTEILNEHMER == 1%}Person{% else %}Personen{% endif %} nicht erreicht</p>
                        </div>
                        {% endfor %}
                    {% else %}
                        {% for scalename, scale in company.item_table.scales %}
                        <div class="mr-auto coach_output_gbu_mittelwerte_button">
                            <button type="button" class="btn btn-link ts-list-button px-0" data-toggle="collapse" {%set rand = random()%} data-target="#gbu_mittelwerte_kadmin_items_{{rand}}" aria-expanded="false">
                                <p class="h6">
                                    <i class="fas fa-plus ts-accordion-plus"></i>
                                    {{scalename}}
                                </p>
                            </button>
                        </div>
                        <div id="gbu_mittelwerte_kadmin_items_{{rand}}" class="collapse mt-2 coach_output_gbu_mittelwerte_items coach_output_gbu_mittelwerte_accordion">
                            <table class="table table-bordered coach_output_gbu_mittelwerte_table">
                                <thead>
                                    <th></th>
                                    <th>gesamt {% if company.scale_table.scales[scalename].gesamt.scale_input_count_min == company.scale_table.scales[scalename].gesamt.scale_input_count_max %}({{company.scale_table.scales[scalename].gesamt.scale_input_count_min}} Person{% if company.scale_table.scales[scalename].gesamt.scale_input_count_min != 1 %}en{% endif %}){% else %}({{company.scale_table.scales[scalename].gesamt.scale_input_count_min}}-{{company.scale_table.scales[scalename].gesamt.scale_input_count_max}} Personen){% endif %}</th>
                                    {% for groupID, group in company.item_table.group_information %}
                                        <th>{{group.groupname}} {% if company.scale_table.scales[scalename].groups[groupID].scale_input_count_min == company.scale_table.scales[scalename].groups[groupID].scale_input_count_max %}({{company.scale_table.scales[scalename].groups[groupID].scale_input_count_min}} Person{% if company.scale_table.scales[scalename].groups[groupID].scale_input_count_min != 1 %}en{% endif %}){% else %}({{company.scale_table.scales[scalename].groups[groupID].scale_input_count_min}}-{{company.scale_table.scales[scalename].groups[groupID].scale_input_count_max}} Personen){% endif %}</th>
                                    {% endfor %}
                                </thead>
                                <tbody>
                                    {% for subscalename, subscale in scale.subscales %}
                                        <tr>
                                            <td style="background-color: #ffffff;" colspan="{% if company.item_table.group_information | length == 2 %}4{% elseif company.item_table.group_information | length == 1 %}3{% endif %}"><b>{{subscalename}}</b></td>
                                        </tr>
                                        {% for itemname, item in subscale.items %}
                                            <tr>
                                                <td style="background-color: #ffffff;">{{itemname}}</td>
                                                <td style="background-color: #{{item.gesamt.val_color}};">{{item.gesamt.item_mean}}</td>
                                                {% for groupID, group in item.groups %}
                                                <td style="background-color: #{{group.val_color}};">{{group.item_mean}}</td>
                                                {% endfor %}
                                            </tr>
                                        {% endfor %}
                                        <tr>
                                            <td style="background-color: lightgray;"><b>Insgesamt</b></td>
                                            <td style="background-color: #{{company.subscale_table.scales[scalename].subscales[subscalename].gesamt.val_color}};">{{company.subscale_table.scales[scalename].subscales[subscalename].gesamt.subscale_mean}}</td>
                                            {% for groupID, group in company.item_table.group_information %}
                                            <td style="background-color: #{{company.subscale_table.scales[scalename].subscales[subscalename].groups[groupID].val_color}};">{{company.subscale_table.scales[scalename].subscales[subscalename].groups[groupID].subscale_mean}}</td>
                                            {% endfor %}
                                        </tr>
                                    {% endfor %}
                                </tbody>
                            </table>
                            <p>(-) Benötigte Anzahl von {{MINTEILNEHMER}} {% if MINTEILNEHMER == 1%}Person{% else %}Personen{% endif %} nicht erreicht</p>
                        </div>
                        {% endfor %}
                    {% endif %}
                {% endif %}
                {% if showPDFDownload %}
                <div class="info-radio link">
                    <i class='fas fa-external-link-alt'></i>
                    <p><a id="" href="javascript:generateGBUMittelwertePDF('gbu_mittelwerte_kadmin_companies_{{randCompany}}', '{{company.companyname}}')">{{pdfDownloadTitle}}</a></p>
                </div>
                {% endif %}
            </div>
        </div>
    {% endfor %}
{% elseif isBoss %}
    <div class="coach_output_gbu_mittelwerte_container_boss" id="coach_output_gbu_mittelwerte_{{outputId}}_boss">
        {% if showScales %}
        {% if tableBoss.scale_table.group_information | length > 2 %}
            <table class="table table-bordered coach_output_gbu_mittelwerte_table">
                <thead>
                    <tr>
                        <th></th>
                        <th>gesamt {% set inputCountTotal_min = null %}{% set inputCountTotal_max = null %}{% for scale in tableBoss.scale_table.scales%}{% if inputCountTotal_min is null %}{% set inputCountTotal_min = scale.gesamt.scale_input_count_min %}{% else %}{% if inputCountTotal_min > scale.gesamt.scale_input_count_min %}{% set inputCountTotal_min = scale.gesamt.scale_input_count_min %}{% endif %}{% endif %}{% if inputCountTotal_max is null %}{% set inputCountTotal_max = scale.gesamt.scale_input_count_max %}{% else %}{% if inputCountTotal_max < scale.gesamt.scale_input_count_max %}{% set inputCountTotal_max = scale.gesamt.scale_input_count_max %}{% endif %}{% endif %}{% endfor %}{% if inputCountTotal_min == inputCountTotal_max %}({{inputCountTotal_min}} Person{% if inputCountTotal_min != 1%}en{% endif %}){% else %}({{inputCountTotal_min}}-{{inputCountTotal_max}} Personen){% endif %}</th>
                        <th>
                            <select class="form-control gbu-mittelwerte-select">
                                {% for groupID, group in tableBoss.scale_table.group_information %}
                                <option value="{{groupID}}" {% if loop.index0 == 1%}disabled{% endif %}>{{group.groupname}} {% set inputCountGroup_min = null %}{% set inputCountGroup_max = null %}{% for scale in tableBoss.scale_table.scales%}{% if inputCountGroup_min is null %}{% set inputCountGroup_min = scale.groups[groupID].scale_input_count_min %}{% else %}{% if inputCountGroup_min > scale.groups[groupID].scale_input_count_min %}{% set inputCountGroup_min = scale.groups[groupID].scale_input_count_min %}{% endif %}{% endif %}{% if inputCountGroup_max is null %}{% set inputCountGroup_max = scale.groups[groupID].scale_input_count_max %}{% else %}{% if inputCountGroup_max < scale.groups[groupID].scale_input_count_max %}{% set inputCountGroup_max = scale.groups[groupID].scale_input_count_max %}{% endif %}{% endif %}{% endfor %}{% if inputCountGroup_min == inputCountGroup_max %}({{inputCountGroup_min}} Person{% if inputCountGroup_min != 1%}en{% endif %}){% else %}({{inputCountGroup_min}}-{{inputCountGroup_max}} Personen){% endif %}</option>
                                {% endfor %}
                            </select>
                        </th>
                        <th>
                            <select class="form-control gbu-mittelwerte-select">
                                {% for groupID, group in tableBoss.scale_table.group_information %}
                                <option value="{{groupID}}" {% if loop.index0 == 0%}disabled{% endif %}>{{group.groupname}} {% set inputCountGroup_min = null %}{% set inputCountGroup_max = null %}{% for scale in tableBoss.scale_table.scales%}{% if inputCountGroup_min is null %}{% set inputCountGroup_min = scale.groups[groupID].scale_input_count_min %}{% else %}{% if inputCountGroup_min > scale.groups[groupID].scale_input_count_min %}{% set inputCountGroup_min = scale.groups[groupID].scale_input_count_min %}{% endif %}{% endif %}{% if inputCountGroup_max is null %}{% set inputCountGroup_max = scale.groups[groupID].scale_input_count_max %}{% else %}{% if inputCountGroup_max < scale.groups[groupID].scale_input_count_max %}{% set inputCountGroup_max = scale.groups[groupID].scale_input_count_max %}{% endif %}{% endif %}{% endfor %}{% if inputCountGroup_min == inputCountGroup_max %}({{inputCountGroup_min}} Person{% if inputCountGroup_min != 1%}en{% endif %}){% else %}({{inputCountGroup_min}}-{{inputCountGroup_max}} Personen){% endif %}</option>
                                {% endfor %}
                            </select>
                        </th>
                    </tr>
                </thead>
                <tbody>
                    {% for scalename, scale in tableBoss.scale_table.scales %}
                    <tr>
                        <td style="background-color: #ffffff;">{{scalename}}</td>
                        <td style="background-color: #{{scale.gesamt.val_color}};">{{scale.gesamt.scale_mean}}</td>
                        {% for groupID, group in scale.groups %}
                        <td opt="0" groupid="{{groupID}}" {% if loop.index0 != 0%}class="d-none"{% endif%} style="background-color: #{{group.val_color}};">{{group.scale_mean}}</td>
                        {% endfor %}
                        {% for groupID, group in scale.groups %}
                        <td opt="1" groupid="{{groupID}}" {% if loop.index0 != 1%}class="d-none"{% endif%} style="background-color: #{{group.val_color}};">{{group.scale_mean}}</td>
                        {% endfor %}
                    </tr>
                    {% endfor %}
                </tbody>
            </table>
            <p>(-) Benötigte Anzahl von {{MINTEILNEHMER}} {% if MINTEILNEHMER == 1%}Person{% else %}Personen{% endif %} nicht erreicht</p>
        {% else %}
        <table class="table table-bordered coach_output_gbu_mittelwerte_table">
            <thead>
                <tr>
                    <th></th>
                    <th>gesamt {% set inputCountTotal_min = null %}{% set inputCountTotal_max = null %}{% for scale in tableBoss.scale_table.scales%}{% if inputCountTotal_min is null %}{% set inputCountTotal_min = scale.gesamt.scale_input_count_min %}{% else %}{% if inputCountTotal_min > scale.gesamt.scale_input_count_min %}{% set inputCountTotal_min = scale.gesamt.scale_input_count_min %}{% endif %}{% endif %}{% if inputCountTotal_max is null %}{% set inputCountTotal_max = scale.gesamt.scale_input_count_max %}{% else %}{% if inputCountTotal_max < scale.gesamt.scale_input_count_max %}{% set inputCountTotal_max = scale.gesamt.scale_input_count_max %}{% endif %}{% endif %}{% endfor %}{% if inputCountTotal_min == inputCountTotal_max %}({{inputCountTotal_min}} Person{% if inputCountTotal_min != 1%}en{% endif %}){% else %}({{inputCountTotal_min}}-{{inputCountTotal_max}} Personen){% endif %}</th>
                    {% for groupID, group in tableBoss.scale_table.group_information %}
                        <th>{{group.groupname}} {% set inputCountGroup_min = null %}{% set inputCountGroup_max = null %}{% for scale in tableBoss.scale_table.scales%}{% if inputCountGroup_min is null %}{% set inputCountGroup_min = scale.groups[groupID].scale_input_count_min %}{% else %}{% if inputCountGroup_min > scale.groups[groupID].scale_input_count_min %}{% set inputCountGroup_min = scale.groups[groupID].scale_input_count_min %}{% endif %}{% endif %}{% if inputCountGroup_max is null %}{% set inputCountGroup_max = scale.groups[groupID].scale_input_count_max %}{% else %}{% if inputCountGroup_max < scale.groups[groupID].scale_input_count_max %}{% set inputCountGroup_max = scale.groups[groupID].scale_input_count_max %}{% endif %}{% endif %}{% endfor %}{% if inputCountGroup_min == inputCountGroup_max %}({{inputCountGroup_min}} Person{% if inputCountGroup_min != 1%}en{% endif %}){% else %}({{inputCountGroup_min}}-{{inputCountGroup_max}} Personen){% endif %}</th>
                    {% endfor %}
                </tr>
            </thead>
            <tbody>
                {% for scalename, scale in tableBoss.scale_table.scales %}
                    <tr>
                        <td style="background-color: #ffffff;">{{scalename}}</td>
                        <td style="background-color: #{{scale.gesamt.val_color}};">{{scale.gesamt.scale_mean}}</td>
                        {% for groupID, group in scale.groups %}
                        <td style="background-color: #{{group.val_color}};">{{group.scale_mean}}</td>
                        {% endfor %}
                    </tr>
                {% endfor %}
            </tbody>
        </table>
        <p>(-) Benötigte Anzahl von {{MINTEILNEHMER}} {% if MINTEILNEHMER == 1%}Person{% else %}Personen{% endif %} nicht erreicht</p>
        {% endif %}
    {% endif %}

    {% if showSubscales %}
        {% if tableBoss.subscale_table.group_information | length > 2 %}
            <table class="table table-bordered coach_output_gbu_mittelwerte_table">
                <thead>
                    <tr>
                        <th></th>
                        <th>gesamt {% set inputCountTotal_min = null %}{% set inputCountTotal_max = null %}{% for scale in tableBoss.scale_table.scales%}{% if inputCountTotal_min is null %}{% set inputCountTotal_min = scale.gesamt.scale_input_count_min %}{% else %}{% if inputCountTotal_min > scale.gesamt.scale_input_count_min %}{% set inputCountTotal_min = scale.gesamt.scale_input_count_min %}{% endif %}{% endif %}{% if inputCountTotal_max is null %}{% set inputCountTotal_max = scale.gesamt.scale_input_count_max %}{% else %}{% if inputCountTotal_max < scale.gesamt.scale_input_count_max %}{% set inputCountTotal_max = scale.gesamt.scale_input_count_max %}{% endif %}{% endif %}{% endfor %}{% if inputCountTotal_min == inputCountTotal_max %}({{inputCountTotal_min}} Person{% if inputCountTotal_min != 1%}en{% endif %}){% else %}({{inputCountTotal_min}}-{{inputCountTotal_max}} Personen){% endif %}</th>
                        <th>
                            <select class="form-control gbu-mittelwerte-select">
                                {% for groupID, group in tableBoss.subscale_table.group_information %}
                                <option value="{{groupID}}" {% if loop.index0 == 1%}disabled{% endif %}>{{group.groupname}} {% set inputCountGroup_min = null %}{% set inputCountGroup_max = null %}{% for scale in tableBoss.scale_table.scales%}{% if inputCountGroup_min is null %}{% set inputCountGroup_min = scale.groups[groupID].scale_input_count_min %}{% else %}{% if inputCountGroup_min > scale.groups[groupID].scale_input_count_min %}{% set inputCountGroup_min = scale.groups[groupID].scale_input_count_min %}{% endif %}{% endif %}{% if inputCountGroup_max is null %}{% set inputCountGroup_max = scale.groups[groupID].scale_input_count_max %}{% else %}{% if inputCountGroup_max < scale.groups[groupID].scale_input_count_max %}{% set inputCountGroup_max = scale.groups[groupID].scale_input_count_max %}{% endif %}{% endif %}{% endfor %}{% if inputCountGroup_min == inputCountGroup_max %}({{inputCountGroup_min}} Person{% if inputCountGroup_min != 1%}en{% endif %}){% else %}({{inputCountGroup_min}}-{{inputCountGroup_max}} Personen){% endif %}</option>
                                {% endfor %}
                            </select>
                        </th>
                        <th>
                            <select class="form-control gbu-mittelwerte-select">
                                {% for groupID, group in tableBoss.subscale_table.group_information %}
                                <option value="{{groupID}}" {% if loop.index0 == 0%}disabled{% endif %}>{{group.groupname}} {% set inputCountGroup_min = null %}{% set inputCountGroup_max = null %}{% for scale in tableBoss.scale_table.scales%}{% if inputCountGroup_min is null %}{% set inputCountGroup_min = scale.groups[groupID].scale_input_count_min %}{% else %}{% if inputCountGroup_min > scale.groups[groupID].scale_input_count_min %}{% set inputCountGroup_min = scale.groups[groupID].scale_input_count_min %}{% endif %}{% endif %}{% if inputCountGroup_max is null %}{% set inputCountGroup_max = scale.groups[groupID].scale_input_count_max %}{% else %}{% if inputCountGroup_max < scale.groups[groupID].scale_input_count_max %}{% set inputCountGroup_max = scale.groups[groupID].scale_input_count_max %}{% endif %}{% endif %}{% endfor %}{% if inputCountGroup_min == inputCountGroup_max %}({{inputCountGroup_min}} Person{% if inputCountGroup_min != 1%}en{% endif %}){% else %}({{inputCountGroup_min}}-{{inputCountGroup_max}} Personen){% endif %}</option>
                                {% endfor %}
                            </select>
                        </th>
                    </tr>
                </thead>
                <tbody>
                    {% for scalename, scale in tableBoss.subscale_table.scales %}
                    <tr>
                        <td style="background-color: #ffffff;" colspan="4"><b>{{scalename}}</b></td>
                    </tr>
                        {% for subscalename, subscale in scale.subscales%}
                        <tr>
                            <td style="background-color: #ffffff;">{{subscalename}}</td>
                            <td style="background-color: #{{subscale.gesamt.val_color}};">{{subscale.gesamt.subscale_mean}}</td>
                            {% for groupID, group in subscale.groups %}
                            <td opt="0" groupid="{{groupID}}" {% if loop.index0 != 0%}class="d-none"{% endif%} style="background-color: #{{group.val_color}};">{{group.subscale_mean}}</td>
                            {% endfor %}
                            {% for groupID, group in subscale.groups %}
                            <td opt="1" groupid="{{groupID}}" {% if loop.index0 != 1%}class="d-none"{% endif%} style="background-color: #{{group.val_color}};">{{group.subscale_mean}}</td>
                            {% endfor %}
                        </tr>
                        {% endfor %}
                    {% endfor %}
                </tbody>
            </table>
            <p>(-) Benötigte Anzahl von {{MINTEILNEHMER}} {% if MINTEILNEHMER == 1%}Person{% else %}Personen{% endif %} nicht erreicht</p>
        {% else %}
            <table class="table table-bordered coach_output_gbu_mittelwerte_table">
                <thead>
                    <th></th>
                    <th>gesamt {% set inputCountTotal_min = null %}{% set inputCountTotal_max = null %}{% for scale in tableBoss.scale_table.scales%}{% if inputCountTotal_min is null %}{% set inputCountTotal_min = scale.gesamt.scale_input_count_min %}{% else %}{% if inputCountTotal_min > scale.gesamt.scale_input_count_min %}{% set inputCountTotal_min = scale.gesamt.scale_input_count_min %}{% endif %}{% endif %}{% if inputCountTotal_max is null %}{% set inputCountTotal_max = scale.gesamt.scale_input_count_max %}{% else %}{% if inputCountTotal_max < scale.gesamt.scale_input_count_max %}{% set inputCountTotal_max = scale.gesamt.scale_input_count_max %}{% endif %}{% endif %}{% endfor %}{% if inputCountTotal_min == inputCountTotal_max %}({{inputCountTotal_min}} Person{% if inputCountTotal_min != 1%}en{% endif %}){% else %}({{inputCountTotal_min}} - {{inputCountTotal_max}} Personen){% endif %}</th>
                    {% for groupID, group in tableBoss.subscale_table.group_information %}
                        <th>{{group.groupname}} {% set inputCountGroup_min = null %}{% set inputCountGroup_max = null %}{% for scale in tableBoss.scale_table.scales%}{% if inputCountGroup_min is null %}{% set inputCountGroup_min = scale.groups[groupID].scale_input_count_min %}{% else %}{% if inputCountGroup_min > scale.groups[groupID].scale_input_count_min %}{% set inputCountGroup_min = scale.groups[groupID].scale_input_count_min %}{% endif %}{% endif %}{% if inputCountGroup_max is null %}{% set inputCountGroup_max = scale.groups[groupID].scale_input_count_max %}{% else %}{% if inputCountGroup_max < scale.groups[groupID].scale_input_count_max %}{% set inputCountGroup_max = scale.groups[groupID].scale_input_count_max %}{% endif %}{% endif %}{% endfor %}{% if inputCountGroup_min == inputCountGroup_max %}({{inputCountGroup_min}} Person{% if inputCountGroup_min != 1%}en{% endif %}){% else %}({{inputCountGroup_min}} - {{inputCountGroup_max}} Personen){% endif %}</th>
                    {% endfor %}
                </thead>
                <tbody>
                    {% for scalename, scale in tableBoss.subscale_table.scales %}
                    <tr>
                        <td style="background-color: #ffffff;" colspan="{% if tableBoss.subscale_table.group_information | length == 2 %}4{% elseif tableBoss.subscale_table.group_information | length == 1%}3{% endif %}"><b>{{scalename}}</b></td>
                    </tr>
                        {% for subscalename, subscale in scale.subscales%}
                        <tr>
                            <td style="background-color: #ffffff;">{{subscalename}}</td>
                            <td style="background-color: #{{subscale.gesamt.val_color}};">{{subscale.gesamt.subscale_mean}}</td>
                            {% for groupID, group in subscale.groups %}
                            <td style="background-color: #{{group.val_color}};">{{group.subscale_mean}}</td>
                            {% endfor %}
                        </tr>
                        {% endfor %}
                    {% endfor %}
                </tbody>
            </table>
            <p>(-) Benötigte Anzahl von {{MINTEILNEHMER}} {% if MINTEILNEHMER == 1%}Person{% else %}Personen{% endif %} nicht erreicht</p>
        {% endif %}
    {% endif %}

    {% if showItems %}
            {% if tableBoss.item_table.group_information | length > 2 %}

                {% for scalename, scale in tableBoss.item_table.scales %}

                <div class="mr-auto coach_output_gbu_mittelwerte_button">
                    <button type="button" class="btn btn-link ts-list-button px-0" data-toggle="collapse" {%set rand = random()%} data-target="#gbu_mittelwerte_boss_items_{{rand}}" aria-expanded="false">
                        <p class="h6">
                            <i class="fas fa-plus ts-accordion-plus"></i>
                            {{scalename}}
                        </p>
                    </button>
                </div>
                <div id="gbu_mittelwerte_boss_items_{{rand}}" class="collapse mt-2 coach_output_gbu_mittelwerte_items coach_output_gbu_mittelwerte_accordion">
                    <table class="table table-bordered coach_output_gbu_mittelwerte_table">
                        <thead>
                            <tr>
                                <th></th>
                                <th>gesamt {% if tableBoss.scale_table.scales[scalename].gesamt.scale_input_count_min == tableBoss.scale_table.scales[scalename].gesamt.scale_input_count_max %}({{tableBoss.scale_table.scales[scalename].gesamt.scale_input_count_min}} Person{% if tableBoss.scale_table.scales[scalename].gesamt.scale_input_count_min != 1 %}en{% endif %}){% else %}({{tableBoss.scale_table.scales[scalename].gesamt.scale_input_count_min}}-{{tableBoss.scale_table.scales[scalename].gesamt.scale_input_count_max}} Personen){% endif %}</th>
                                <th>
                                    <select class="form-control gbu-mittelwerte-select">
                                        {% for groupID, group in tableBoss.item_table.group_information %}
                                        <option value="{{groupID}}" {% if loop.index0 == 1%}disabled{% endif %}>{{group.groupname}} {% if tableBoss.scale_table.scales[scalename].groups[groupID].scale_input_count_min == tableBoss.scale_table.scales[scalename].groups[groupID].scale_input_count_max %}({{tableBoss.scale_table.scales[scalename].groups[groupID].scale_input_count_min}} Person{% if tableBoss.scale_table.scales[scalename].groups[groupID].scale_input_count_min != 1 %}en{% endif %}){% else %}({{tableBoss.scale_table.scales[scalename].groups[groupID].scale_input_count_min}}-{{tableBoss.scale_table.scales[scalename].groups[groupID].scale_input_count_max}} Personen){% endif %}</option>
                                        {% endfor %}
                                    </select>
                                </th>
                                <th>
                                    <select class="form-control sgbu-mittelwerte-select">
                                        {% for groupID, group in tableBoss.item_table.group_information %}
                                        <option value="{{groupID}}" {% if loop.index0 == 0%}disabled{% endif %}>{{group.groupname}} {% if tableBoss.scale_table.scales[scalename].groups[groupID].scale_input_count_min == tableBoss.scale_table.scales[scalename].groups[groupID].scale_input_count_max %}({{tableBoss.scale_table.scales[scalename].groups[groupID].scale_input_count_min}} Person{% if tableBoss.scale_table.scales[scalename].groups[groupID].scale_input_count_min != 1 %}en{% endif %}){% else %}({{tableBoss.scale_table.scales[scalename].groups[groupID].scale_input_count_min}}-{{tableBoss.scale_table.scales[scalename].groups[groupID].scale_input_count_max}} Personen){% endif %}</option>
                                        {% endfor %}
                                    </select>
                                </th>
                            </tr>
                        </thead>
                        <tbody>
                            {% for subscalename, subscale in scale.subscales %}
                                <tr>
                                    <td style="background-color: #ffffff;" colspan="4"><b>{{subscalename}}</b></td>
                                </tr>
                                {% for itemname, item in subscale.items %}
                                    <tr>
                                        <td style="background-color: #ffffff;">{{itemname}}</td>
                                        <td style="background-color: #{{item.gesamt.val_color}};">{{item.gesamt.item_mean}}</td>
                                        {% for groupID, group in item.groups %}
                                        <td opt="0" groupid="{{groupID}}" {% if loop.index0 != 0%}class="d-none"{% endif%} style="background-color: #{{group.val_color}};">{{group.item_mean}}</td>
                                        {% endfor %}
                                        {% for groupID, group in item.groups %}
                                        <td opt="1" groupid="{{groupID}}" {% if loop.index0 != 1%}class="d-none"{% endif%} style="background-color: #{{group.val_color}};">{{group.item_mean}}</td>
                                        {% endfor %}
                                    </tr>
                                {% endfor %}
                                <tr>
                                    <td style="background-color: lightgray;"><b>Insgesamt</b></td>
                                    <td style="background-color: #{{tableBoss.subscale_table.scales[scalename].subscales[subscalename].gesamt.val_color}};">{{tableBoss.subscale_table.scales[scalename].subscales[subscalename].gesamt.subscale_mean}}</td>
                                    {% for groupID, group in tableBoss.item_table.group_information %}
                                    <td opt="0" groupid="{{groupID}}" {% if loop.index0 != 0%}class="d-none"{% endif%} style="background-color: #{{tableBoss.subscale_table.scales[scalename].subscales[subscalename].groups[groupID].val_color}};">{{tableBoss.subscale_table.scales[scalename].subscales[subscalename].groups[groupID].subscale_mean}}</td>
                                    {% endfor %}
                                    {% for groupID, group in tableBoss.item_table.group_information %}
                                    <td opt="1" groupid="{{groupID}}" {% if loop.index0 != 1%}class="d-none"{% endif%} style="background-color: #{{tableBoss.subscale_table.scales[scalename].subscales[subscalename].groups[groupID].val_color}};">{{tableBoss.subscale_table.scales[scalename].subscales[subscalename].groups[groupID].subscale_mean}}</td>
                                    {% endfor %}
                                </tr>
                            {% endfor %}
                        </tbody>
                    </table>
                    <p>(-) Benötigte Anzahl von {{MINTEILNEHMER}} {% if MINTEILNEHMER == 1%}Person{% else %}Personen{% endif %} nicht erreicht</p>
                </div>
                {% endfor %}

            {% else %}
                {% for scalename, scale in tableBoss.item_table.scales %}
                <div class="mr-auto coach_output_gbu_mittelwerte_button">
                    <button type="button" class="btn btn-link ts-list-button px-0" data-toggle="collapse" {%set rand = random()%} data-target="#gbu_mittelwerte_boss_items_{{rand}}" aria-expanded="false">
                        <p class="h6">
                            <i class="fas fa-plus ts-accordion-plus"></i>
                            {{scalename}}
                        </p>
                    </button>
                </div>
                <div id="gbu_mittelwerte_boss_items_{{rand}}" class="collapse mt-2 coach_output_gbu_mittelwerte_items coach_output_gbu_mittelwerte_accordion">
                    <table class="table table-bordered coach_output_gbu_mittelwerte_table">
                        <thead>
                            <th></th>
                            <th>gesamt {% if tableBoss.scale_table.scales[scalename].gesamt.scale_input_count_min == tableBoss.scale_table.scales[scalename].gesamt.scale_input_count_max %}({{tableBoss.scale_table.scales[scalename].gesamt.scale_input_count_min}} Person{% if tableBoss.scale_table.scales[scalename].gesamt.scale_input_count_min != 1 %}en{% endif %}){% else %}({{tableBoss.scale_table.scales[scalename].gesamt.scale_input_count_min}}-{{tableBoss.scale_table.scales[scalename].gesamt.scale_input_count_max}} Personen){% endif %}</th>
                            {% for groupID, group in tableBoss.item_table.group_information %}
                                <th>{{group.groupname}} {% if tableBoss.scale_table.scales[scalename].groups[groupID].scale_input_count_min == tableBoss.scale_table.scales[scalename].groups[groupID].scale_input_count_max %}({{tableBoss.scale_table.scales[scalename].groups[groupID].scale_input_count_min}} Person{% if tableBoss.scale_table.scales[scalename].groups[groupID].scale_input_count_min != 1 %}en{% endif %}){% else %}({{tableBoss.scale_table.scales[scalename].groups[groupID].scale_input_count_min}}-{{tableBoss.scale_table.scales[scalename].groups[groupID].scale_input_count_max}} Personen){% endif %}</th>
                            {% endfor %}
                        </thead>
                        <tbody>
                            {% for subscalename, subscale in scale.subscales %}
                                <tr>
                                    <td style="background-color: #ffffff;" colspan="{% if tableBoss.item_table.group_information | length == 2 %}4{% elseif tableBoss.item_table.group_information | length == 1 %}3{% endif %}"><b>{{subscalename}}</b></td>
                                </tr>
                                {% for itemname, item in subscale.items %}
                                    <tr>
                                        <td style="background-color: #ffffff;">{{itemname}}</td>
                                        <td style="background-color: #{{item.gesamt.val_color}};">{{item.gesamt.item_mean}}</td>
                                        {% for groupID, group in item.groups %}
                                        <td style="background-color: #{{group.val_color}};">{{group.item_mean}}</td>
                                        {% endfor %}
                                    </tr>
                                {% endfor %}
                                <tr>
                                    <td style="background-color: lightgray;"><b>Insgesamt</b></td>
                                    <td style="background-color: #{{tableBoss.subscale_table.scales[scalename].subscales[subscalename].gesamt.val_color}};">{{tableBoss.subscale_table.scales[scalename].subscales[subscalename].gesamt.subscale_mean}}</td>
                                    {% for groupID, group in tableBoss.item_table.group_information %}
                                    <td style="background-color: #{{tableBoss.subscale_table.scales[scalename].subscales[subscalename].groups[groupID].val_color}};">{{tableBoss.subscale_table.scales[scalename].subscales[subscalename].groups[groupID].subscale_mean}}</td>
                                    {% endfor %}
                                </tr>
                            {% endfor %}
                        </tbody>
                    </table>
                    <p>(-) Benötigte Anzahl von {{MINTEILNEHMER}} {% if MINTEILNEHMER == 1%}Person{% else %}Personen{% endif %} nicht erreicht</p>
                </div>
                {% endfor %}

            {% endif %}  
    {% endif %}
    {% if showPDFDownload %}
        <div class="info-radio link">
            <i class='fas fa-external-link-alt'></i>
            <p><a id="" href="javascript:generateGBUMittelwertePDF('coach_output_gbu_mittelwerte_{{outputId}}_boss', '')">{{pdfDownloadTitle}}</a></p>
        </div>
    {% endif %}
    </div>
{% elseif isTeamleader %}
    <div class="coach_output_gbu_mittelwerte_container_teamleader" id="coach_output_gbu_mittelwerte_{{outputId}}_teamleader">
        {% if showScales %}
        <table class="table table-bordered coach_output_gbu_mittelwerte_table">
            <thead>
                <tr>
                    <th></th>
                    <th>{{tableTeamleader.scale_table.group_information.groupname}} {% set inputCountGroup_min = null %}{% set inputCountGroup_max = null %}{% for scale in tableTeamleader.scale_table.scales%}{% if inputCountGroup_min is null %}{% set inputCountGroup_min = scale.scale_input_count_min %}{% else %}{% if inputCountGroup_min > scale.scale_input_count_min %}{% set inputCountGroup_min = scale.scale_input_count_min %}{% endif %}{% endif %}{% if inputCountGroup_max is null %}{% set inputCountGroup_max = scale.scale_input_count_max %}{% else %}{% if inputCountGroup_max < scale.scale_input_count_max %}{% set inputCountGroup_max = scale.scale_input_count_max %}{% endif %}{% endif %}{% endfor %}{% if inputCountGroup_min == inputCountGroup_max %}({{inputCountGroup_min}} Person{% if inputCountGroup_min != 1%}en{% endif %}){% else %}({{inputCountGroup_min}}-{{inputCountGroup_max}} Personen){% endif %}</th>
                </tr>
            </thead>
            <tbody>
                {% for scalename, scale in tableTeamleader.scale_table.scales %}
                <tr>
                    <td style="background-color: #ffffff;">{{scalename}}</td>
                    <td style="background-color: #{{scale.val_color}};">{{scale.scale_mean}}</td>
                </tr>
                {% endfor %}
            </tbody>
        </table>
        <p>(-) Benötigte Anzahl von {{MINTEILNEHMER}} {% if MINTEILNEHMER == 1%}Person{% else %}Personen{% endif %} nicht erreicht</p>
    {% endif %}

    {% if showSubscales %}
        <table class="table table-bordered coach_output_gbu_mittelwerte_table">
            <thead>
                <th></th>
                <th>{{tableTeamleader.subscale_table.group_information.groupname}} {% set inputCountGroup_min = null %}{% set inputCountGroup_max = null %}{% for scale in tableTeamleader.scale_table.scales%}{% if inputCountGroup_min is null %}{% set inputCountGroup_min = scale.scale_input_count_min %}{% else %}{% if inputCountGroup_min > scale.scale_input_count_min %}{% set inputCountGroup_min = scale.scale_input_count_min %}{% endif %}{% endif %}{% if inputCountGroup_max is null %}{% set inputCountGroup_max = scale.scale_input_count_max %}{% else %}{% if inputCountGroup_max < scale.scale_input_count_max %}{% set inputCountGroup_max = scale.scale_input_count_max %}{% endif %}{% endif %}{% endfor %}{% if inputCountGroup_min == inputCountGroup_max %}({{inputCountGroup_min}} Person{% if inputCountGroup_min != 1%}en{% endif %}){% else %}({{inputCountGroup_min}} - {{inputCountGroup_max}} Personen){% endif %}</th>
            </thead>
            <tbody>
                {% for scalename, scale in tableTeamleader.subscale_table.scales %}
                <tr>
                    <td style="background-color: #ffffff;" colspan="3"><b>{{scalename}}</b></td>
                </tr>
                    {% for subscalename, subscale in scale.subscales %}
                    <tr>
                        <td style="background-color: #ffffff;">{{subscalename}}</td>
                        <td style="background-color: #{{subscale.val_color}};">{{subscale.subscale_mean}}</td>
                    </tr>
                    {% endfor %}
                {% endfor %}
            </tbody>
        </table>
        <p>(-) Benötigte Anzahl von {{MINTEILNEHMER}} {% if MINTEILNEHMER == 1%}Person{% else %}Personen{% endif %} nicht erreicht</p>
    {% endif %}

    {% if showItems %}
        {% for scalename, scale in tableTeamleader.item_table.scales %}
        <div class="mr-auto coach_output_gbu_mittelwerte_button">
            <button type="button" class="btn btn-link ts-list-button px-0" data-toggle="collapse" {%set rand = random()%} data-target="#gbu_mittelwerte_teamleader_items_{{rand}}" aria-expanded="false">
                <p class="h6">
                    <i class="fas fa-plus ts-accordion-plus"></i>
                    {{scalename}}
                </p>
            </button>
        </div>
        <div id="gbu_mittelwerte_teamleader_items_{{rand}}" class="collapse mt-2 coach_output_gbu_mittelwerte_items coach_output_gbu_mittelwerte_accordion">
            <table class="table table-bordered coach_output_gbu_mittelwerte_table">
                <thead>
                    <th></th>
                    <th>{{tableTeamleader.item_table.group_information.groupname}} {% if tableTeamleader.scale_table.scales[scalename].scale_input_count_min == tableTeamleader.scale_table.scales[scalename].scale_input_count_max %}({{tableTeamleader.scale_table.scales[scalename].scale_input_count_min}} Person{% if tableTeamleader.scale_table.scales[scalename].scale_input_count_min != 1 %}en{% endif %}){% else %}({{tableTeamleader.scale_table.scales[scalename].scale_input_count_min}}-{{tableTeamleader.scale_table.scales[scalename].scale_input_count_max}} Personen){% endif %}</th>
                </thead>
                <tbody>
                    {% for subscalename, subscale in scale.subscales %}
                        <tr>
                            <td style="background-color: #ffffff;" colspan="3"><b>{{subscalename}}</b></td>
                        </tr>
                        {% for itemname, item in subscale.items %}
                            <tr>
                                <td style="background-color: #ffffff;">{{itemname}}</td>
                                <td style="background-color: #{{item.val_color}};">{{item.item_mean}}</td>
                        </tr>
                        {% endfor %}
                        <tr>
                            <td style="background-color: lightgray;"><b>Insgesamt</b></td>
                            <td style="background-color: #{{tableTeamleader.subscale_table.scales[scalename].subscales[subscalename].val_color}};">{{tableTeamleader.subscale_table.scales[scalename].subscales[subscalename].subscale_mean}}</td>
                        </tr>
                    {% endfor %}
                </tbody>
            </table>
            <p>(-) Benötigte Anzahl von {{MINTEILNEHMER}} {% if MINTEILNEHMER == 1%}Person{% else %}Personen{% endif %} nicht erreicht</p>
        </div>
        {% endfor %}
    {% endif %}
    {% if showPDFDownload %}
        <div class="info-radio link">
            <i class='fas fa-external-link-alt'></i>
            <p><a id="" href="javascript:generateGBUMittelwertePDF('coach_output_gbu_mittelwerte_{{outputId}}_teamleader', '')">{{pdfDownloadTitle}}</a></p>
        </div>
    {% endif %}
    </div>
{% else %}
    <div class="alert alert-info" role="alert">
        <h5><i class="fas fa-info-circle"></i>&nbsp;Hinweis</h5>
        <p>
            Es wird nichts angezeigt, da Sie nicht die notwendigen Berechtigungen für diesen Inhalt haben.
        </p>
    </div>
{% endif %}
</div>

<style>
.coach_output_gbu_mittelwerte_table thead tr th:not(:first-child){
    text-align: center;
}
.coach_output_gbu_mittelwerte_table tbody tr td:not(:first-child){
    text-align: center;
}
</style>

<script>
    function generateGBUMittelwertePDF(divid, company){
        // Angaben zur PDF
        var pdfOrientation = "p";
        var pdfFormat = "a4";
        // Font
        var pdfFont = "helvetica";
        var currentFontSize = 12;
        var currentFontStyle = "normal";
        // Seitenränder (Werte jeweils in mm)
        var pdfMarginTop = 25;
        var pdfMarginLeft = 25;
        var pdfMarginRight = 25;
        var pdfMarginBottom = 20;
        // Erstellen der PDF-Instanz
        var doc = new jspdf.jsPDF({orientation: pdfOrientation, format: pdfFormat});
        // Höhe/Breite/Mitte der PDF (Werte jeweils in mm)
        var maxHeight = doc.internal.pageSize.height;
        var maxWidth = doc.internal.pageSize.width;
        var pdfCenter = maxWidth/2;
        // Seitenzahl
        doc.page = 1;
        var pageNumberFontSize = 11;
        var pageNumberFontStyle = "normal";
        // Schreiben der Seitenzahl auf der ersten Seite
        doc = gbuMittelwertePDFWritePageNumber(doc, pdfFont, currentFontSize, currentFontStyle, pageNumberFontSize, pageNumberFontStyle, pdfCenter, pdfMarginBottom, maxHeight);
        
        // Maximal erlaubte Breite für Inhtalt in der PDF (Wert in mm)
        var maxContentWidth = maxWidth - pdfMarginLeft - pdfMarginRight;
        // Aktuelle Position in y-Richtung im Dokument
        var currentHeightPosition = pdfMarginTop;

        // Schreibe Namen von Unternehmen als Überschrift ins Dokument (nur Sicht für Krankenkassenadmin)
        if(company != ""){
            var docHeadline = company;

            // Schriftgröße der Überschrift für das Dokument festlegen
            var docHeadlineFontSize = 22;
            // Zwischenspeichern der aktuellen Schriftgröße
            var currentFontSize = doc.getFontSize();
            doc.setFontSize(docHeadlineFontSize);

            docHeadline = gbuMittelwertePDFReplaceSpecialCharacters(docHeadline);
            var docHeadlineArray = doc.splitTextToSize(docHeadline, maxContentWidth);
            for(var docH=0; docH < docHeadlineArray.length; docH++){
                // Zeile passt nicht mehr auf Seite
                if(currentHeightPosition + pdfMarginBottom > maxHeight){
                    var docFontSize = doc.getFontSize();
                    var docFontStyle = "normal";
                    var result = gbuMittelwertePDFAddNewPage(doc, pdfFormat, pdfOrientation, pdfFont, docFontSize, docFontStyle, pageNumberFontSize, pageNumberFontStyle, pdfCenter, pdfMarginTop, pdfMarginBottom, maxHeight);
                    doc = result[0]; 
                    currentHeightPosition = result[1];
                }
                var writeResult = gbuMittelwertePDFWriteContent(doc, docHeadlineArray[docH], pdfMarginLeft, currentHeightPosition);
                doc = writeResult[0];
                currentHeightPosition = writeResult[1];
            }
        }

        // Zurücksetzen der Schriftgröße
        doc.setFontSize(currentFontSize);
        currentHeightPosition += 3;

        var divContainer = jQuery('#'+divid).contents();
        for(var divCons=0; divCons < divContainer.length; divCons++){

            if(jQuery(divContainer[divCons]).is("p")){
                var contentText = jQuery(divContainer[divCons]).text();
                contentText = gbuMittelwertePDFReplaceSpecialCharacters(contentText);
                var contentTextArray = doc.splitTextToSize(contentText, maxContentWidth);
                for(var cText=0; cText < contentTextArray.length; cText++){
                    // Zeile passt nicht mehr auf Seite
                    if(currentHeightPosition + pdfMarginBottom > maxHeight){
                        var docFontSize = doc.getFontSize();
                        var docFontStyle = "normal";
                        var result = gbuMittelwertePDFAddNewPage(doc, pdfFormat, pdfOrientation, pdfFont, docFontSize, docFontStyle, pageNumberFontSize, pageNumberFontStyle, pdfCenter, pdfMarginTop, pdfMarginBottom, maxHeight);
                        doc = result[0];
                        currentHeightPosition = result[1];
                    }
                    var writeResult = gbuMittelwertePDFWriteContent(doc, contentTextArray[cText], pdfMarginLeft, currentHeightPosition);
                    doc = writeResult[0];
                    currentHeightPosition = writeResult[1];
                }
                currentHeightPosition += 4.5;
            }
            else if(jQuery(divContainer[divCons]).is("table")){
                var tableHead = jQuery(divContainer[divCons]).find("thead");
                var tableHeadTh = jQuery(tableHead).find("tr th");
                var tableHeadContent = [];
                for(var tableHeadThIndex = 0; tableHeadThIndex < tableHeadTh.length; tableHeadThIndex++){
                    if(jQuery(tableHeadTh[tableHeadThIndex]).find("select").length){
                        var tabelSelectElement = jQuery(tableHeadTh[tableHeadThIndex]).find("select");
                        tableHeadContent.push(jQuery(tabelSelectElement).find("option:selected").text());
                    }
                    else{
                        tableHeadContent.push(jQuery(tableHeadTh[tableHeadThIndex]).text());
                    }
                }
                // Bestimme maximale Breite für eine Cell
                var cellWidth = gbuMittelwertePDFGetMaxTableCellWidth(maxContentWidth, tableHeadContent);
                // Abstand (in x-Richtung) zwischen (linken/rechten) 'Rand' des Feldes zum Inhalt des Feldes
                var fieldMarginX = 5;
                // Abstand (in y-Richtung) zwischen (oberen/unteren) 'Rand' des Feldes zum Inhalt des Feldes
                var fieldMarginY = doc.getFontSize()*0.352778+doc.getLineHeightFactor()*0.352778;
                // Maximale Breite für den Inhalt eines Feldes
                var maxFieldContentWidth = cellWidth - 2*fieldMarginX;

                // Zwischenspeichern der aktuellen Position des Texts
                var tempCurrentHeightPosition = currentHeightPosition;
                // Höchste Position des Texts nach Zeichnen und Schreiben der aktuellen Zeile (zunächst die aktuelle Position)
                var maxCurrentHeightPosition = currentHeightPosition;
                // Offset zwischen einzelnen Feldern in Y-Richtung
                var offsetYDir = 1.5;
                // Zwischenspeichern der aktuellen Seite(nzahl)
                var tempPage = doc.page;
                // Höchste Seite nach Zeichnen und Schreiben der aktuellen Zeile (zunächst die aktuelle Seite)
                var maxPage = doc.page;

                // Aktuelle Position des Rahmens
                var currentRectPosition = currentHeightPosition;
                // Zwischenspeichern der aktuellen Position des Rahmens
                var tempRectPosition = currentRectPosition;

                // Bestimme höchste Anzahl an Zeilen des Inhalts aller Zeilen dieser Reihe
                var maxLinesThisRow = 0;
                for(var cellIndex1 = 0; cellIndex1 < tableHeadContent.length; cellIndex1++){
                    var thisCellContent = gbuMittelwertePDFReplaceSpecialCharacters(tableHeadContent[cellIndex1]);
                    var thisCellContentArray = doc.splitTextToSize(thisCellContent, maxFieldContentWidth);

                    if(thisCellContentArray.length > maxLinesThisRow){
                        maxLinesThisRow = thisCellContentArray.length;
                    }
                }
                for(var cellIndex2 = 0; cellIndex2 < tableHeadContent.length; cellIndex2++){
                    // Zurücksetzen der Position
                    currentHeightPosition = tempCurrentHeightPosition;
                    doc.page = tempPage;
                    doc.setPage(tempPage);
                    // Position für Rahmen zurücksetzen
                    currentRectPosition = tempRectPosition;

                    var thisCellContent = gbuMittelwertePDFReplaceSpecialCharacters(tableHeadContent[cellIndex2]);
                    var thisCellContentArray = doc.splitTextToSize(thisCellContent, maxFieldContentWidth);
                    // Zählvariable für Schleife
                    var linesToDraw = maxLinesThisRow;
                    // Drucke Rahmen und Inhalt
                    while(linesToDraw > 0){
                        // Berechne übrigens Platz auf Seite
                        var remainingSpace = maxHeight - pdfMarginBottom - currentRectPosition;
                        // Anzahl an freien Zeilen für Inhalt auf Seite
                        var linesAvailable = Math.floor((remainingSpace - 2*fieldMarginY)/(doc.getFontSize()*0.352778+doc.getLineHeightFactor()*0.352778));
                        // Es kann mindestens eine Zeile gezeichnet werden
                        if(linesAvailable > 0){
                            // Zeilen, die auf dieser Seite gezeichnet werden können
                            var linesThisPage = 0
                            if(linesAvailable >= linesToDraw){
                                linesThisPage = linesToDraw;
                            }
                            else{
                                linesThisPage = linesAvailable;
                            }
                            // Zeichne Rahmen
                            var heightThisRect = linesThisPage*(doc.getFontSize()*0.352778+doc.getLineHeightFactor()*0.352778);
                            doc = gbuMittelwertePDFDrawRectangle(doc, pdfMarginLeft+cellWidth*cellIndex2, currentRectPosition, cellWidth, heightThisRect+2*fieldMarginY, "rgb(255,255,255)");
                            currentRectPosition += heightThisRect+2*fieldMarginY;

                            while(linesThisPage > 0){
                                // Inhalt schreiben, sofern vorhanden
                                if(thisCellContentArray.length > 0){
                                    doc.setFont(pdfFont, "normal");
                                    var result = gbuMittelwertePDFWriteContent(doc, thisCellContentArray[0], pdfMarginLeft+cellIndex2*cellWidth+fieldMarginX, currentHeightPosition+2*fieldMarginY);
                                    doc = result[0];
                                    currentHeightPosition += doc.getFontSize()*0.352778+doc.getLineHeightFactor()*0.352778;
                                    thisCellContentArray.shift();
                                    doc.setFont(pdfFont, "normal");
                                }
                                // Zählvariable innere Schleife anpassen
                                linesThisPage--;
                                // Zählvariable äußere Schleife anpassen
                                linesToDraw--;
                            }
                        }
                        // Es ist nicht genügend Platz auf der Seite für mindestens eine Zeile
                        else{
                            var docFontSize = doc.getFontSize();
                            var docFontStyle = "normal";
                            var result = gbuMittelwertePDFAddNewPageTables(doc, pdfFormat, pdfOrientation, pdfFont, docFontSize, docFontStyle, pageNumberFontSize, pageNumberFontStyle, pdfCenter, pdfMarginTop, pdfMarginBottom, maxHeight, maxPage);
                            doc = result[0];
                            currentHeightPosition = result[1];
                            maxPage = result[2];
                            currentRectPosition = currentHeightPosition;
                        }
                    }
                }
                currentHeightPosition = currentRectPosition;
                var tableBodyRows = jQuery(divContainer[divCons]).find("tbody tr");
                for(var tableBodyRow = 0; tableBodyRow < tableBodyRows.length; tableBodyRow++){
                    var tableRowTd = jQuery(tableBodyRows[tableBodyRow]).find("td:not(.d-none)");
                    var tableRowTdContent = [];
                    for(var tableRowTdIndex = 0; tableRowTdIndex < tableRowTd.length; tableRowTdIndex++){
                        tableRowTdContent.push(jQuery(tableRowTd[tableRowTdIndex]).text());
                    }

                    // Bestimme maximale Breite für eine Cell
                    var cellWidth = gbuMittelwertePDFGetMaxTableCellWidth(maxContentWidth, tableRowTdContent);
                    // Abstand (in x-Richtung) zwischen (linken/rechten) 'Rand' des Feldes zum Inhalt des Feldes
                    var fieldMarginX = 5;
                    // Abstand (in y-Richtung) zwischen (oberen/unteren) 'Rand' des Feldes zum Inhalt des Feldes
                    var fieldMarginY = doc.getFontSize()*0.352778+doc.getLineHeightFactor()*0.352778;
                    // Maximale Breite für den Inhalt eines Feldes
                    var maxFieldContentWidth = cellWidth - 2*fieldMarginX;

                    // Zwischenspeichern der aktuellen Position des Texts
                    var tempCurrentHeightPosition = currentHeightPosition;
                    // Höchste Position des Texts nach Zeichnen und Schreiben der aktuellen Zeile (zunächst die aktuelle Position)
                    var maxCurrentHeightPosition = currentHeightPosition;
                    // Offset zwischen einzelnen Feldern in Y-Richtung
                    var offsetYDir = 1.5;
                    // Zwischenspeichern der aktuellen Seite(nzahl)
                    var tempPage = doc.page;
                    // Höchste Seite nach Zeichnen und Schreiben der aktuellen Zeile (zunächst die aktuelle Seite)
                    var maxPage = doc.page;

                    // Aktuelle Position des Rahmens
                    var currentRectPosition = currentHeightPosition;
                    // Zwischenspeichern der aktuellen Position des Rahmens
                    var tempRectPosition = currentRectPosition;

                    // Bestimme höchste Anzahl an Zeilen des Inhalts aller Zeilen dieser Reihe
                    var maxLinesThisRow = 0;
                    for(var cellIndex1 = 0; cellIndex1 < tableRowTdContent.length; cellIndex1++){
                        var thisCellContent = gbuMittelwertePDFReplaceSpecialCharacters(tableRowTdContent[cellIndex1]);
                        var thisCellContentArray = doc.splitTextToSize(thisCellContent, maxFieldContentWidth);

                        if(thisCellContentArray.length > maxLinesThisRow){
                            maxLinesThisRow = thisCellContentArray.length;
                        }
                    }

                    for(var cellIndex2 = 0; cellIndex2 < tableRowTdContent.length; cellIndex2++){
                        // Zurücksetzen der Position
                        currentHeightPosition = tempCurrentHeightPosition;
                        doc.page = tempPage;
                        doc.setPage(tempPage);
                        // Position für Rahmen zurücksetzen
                        currentRectPosition = tempRectPosition;

                        var thisCellContent = gbuMittelwertePDFReplaceSpecialCharacters(tableRowTdContent[cellIndex2]);
                        var thisCellContentArray = doc.splitTextToSize(thisCellContent, maxFieldContentWidth);
                        var thisCellColor = jQuery(tableRowTd[cellIndex2]).css('background-color');

                        // Zählvariable für Schleife
                        var linesToDraw = maxLinesThisRow;
                        // Drucke Rahmen und Inhalt
                        while(linesToDraw > 0){
                            // Berechne übrigens Platz auf Seite
                            var remainingSpace = maxHeight - pdfMarginBottom - currentRectPosition;
                            // Anzahl an freien Zeilen für Inhalt auf Seite
                            var linesAvailable = Math.floor((remainingSpace - 2*fieldMarginY)/(doc.getFontSize()*0.352778+doc.getLineHeightFactor()*0.352778));
                            // Es kann mindestens eine Zeile gezeichnet werden
                            if(linesAvailable > 0){
                                // Zeilen, die auf dieser Seite gezeichnet werden können
                                var linesThisPage = 0
                                if(linesAvailable >= linesToDraw){
                                    linesThisPage = linesToDraw;
                                }
                                else{
                                    linesThisPage = linesAvailable;
                                }
                                // Zeichne Rahmen
                                var heightThisRect = linesThisPage*(doc.getFontSize()*0.352778+doc.getLineHeightFactor()*0.352778);
                                doc = gbuMittelwertePDFDrawRectangle(doc, pdfMarginLeft+cellWidth*cellIndex2, currentRectPosition, cellWidth, heightThisRect+2*fieldMarginY, thisCellColor);
                                currentRectPosition += heightThisRect+2*fieldMarginY;
                                    
                                while(linesThisPage > 0){
                                    // Inhalt schreiben, sofern vorhanden
                                    if(thisCellContentArray.length > 0){
                                        doc.setFont(pdfFont, "normal");
                                        var result = gbuMittelwertePDFWriteContent(doc, thisCellContentArray[0], pdfMarginLeft+cellIndex2*cellWidth+fieldMarginX, currentHeightPosition+2*fieldMarginY);
                                        doc = result[0];
                                        currentHeightPosition += doc.getFontSize()*0.352778+doc.getLineHeightFactor()*0.352778;
                                        thisCellContentArray.shift();
                                        doc.setFont(pdfFont, "normal");
                                    }
                                    // Zählvariable innere Schleife anpassen
                                    linesThisPage--;
                                    // Zählvariable äußere Schleife anpassen
                                    linesToDraw--;
                                }
                            }
                            // Es ist nicht genügend Platz auf der Seite für mindestens eine Zeile
                            else{
                                var docFontSize = doc.getFontSize();
                                var docFontStyle = "normal";
                                var result = gbuMittelwertePDFAddNewPageTables(doc, pdfFormat, pdfOrientation, pdfFont, docFontSize, docFontStyle, pageNumberFontSize, pageNumberFontStyle, pdfCenter, pdfMarginTop, pdfMarginBottom, maxHeight, maxPage);
                                doc = result[0];
                                currentHeightPosition = result[1];
                                maxPage = result[2];
                                currentRectPosition = currentHeightPosition;
                            }
                        }
                    }
                    currentHeightPosition = currentRectPosition;
                }
                currentHeightPosition += 7.5;
            }
            else if(jQuery(divContainer[divCons]).is("div.coach_output_gbu_mittelwerte_button")){
                var buttonText = jQuery(divContainer[divCons]).find("button").text();
                var headlineTextColor = jQuery(divContainer[divCons]).find("button p").css("color");
                var headlineFontSize = 16;
                buttonText = buttonText.trim();
                // Zwischenspeichern der aktuellen Schriftfarbe und -größe
                var currentTextColor = doc.getTextColor();
                var currentFontSize =  doc.getFontSize();
                // Schriftfarbe für Überschrift setzen
                doc.setTextColor(headlineTextColor);
                doc.setFontSize(headlineFontSize);
                buttonText = gbuMittelwertePDFReplaceSpecialCharacters(buttonText);
                var buttonTextArray = doc.splitTextToSize(buttonText, maxContentWidth);
                for(var buttonIndex = 0; buttonIndex < buttonTextArray.length; buttonIndex++){
                    // Zeile passt nicht mehr auf Seite
                    if(currentHeightPosition + pdfMarginBottom > maxHeight){
                        var docFontSize = doc.getFontSize();
                        var docFontStyle = "normal";
                        var result = gbuMittelwertePDFAddNewPage(doc, pdfFormat, pdfOrientation, pdfFont, docFontSize, docFontStyle, pageNumberFontSize, pageNumberFontStyle, pdfCenter, pdfMarginTop, pdfMarginBottom, maxHeight);
                        doc = result[0]; 
                        currentHeightPosition = result[1];
                    }
                    var writeResult = gbuMittelwertePDFWriteContent(doc, buttonTextArray[buttonIndex], pdfMarginLeft, currentHeightPosition);
                    doc = writeResult[0];
                    currentHeightPosition = writeResult[1];
                }
                // Zurücksetzen der Schriftfarbe und -größe
                doc.setTextColor(currentTextColor);
                doc.setFontSize(currentFontSize);
            }
            else if(jQuery(divContainer[divCons]).is("div.coach_output_gbu_mittelwerte_items")){
                var gbuMittelwerteGroupItemsDivContent = jQuery(divContainer[divCons]).contents();
                for(var gbuMittelwerteGroupItemsDivCons = 0; gbuMittelwerteGroupItemsDivCons < gbuMittelwerteGroupItemsDivContent.length; gbuMittelwerteGroupItemsDivCons++){
                    if(jQuery(gbuMittelwerteGroupItemsDivContent[gbuMittelwerteGroupItemsDivCons]).is("p")){
                        var contentText = jQuery(gbuMittelwerteGroupItemsDivContent[gbuMittelwerteGroupItemsDivCons]).text();
                        contentText = gbuMittelwertePDFReplaceSpecialCharacters(contentText);
                        var contentTextArray = doc.splitTextToSize(contentText, maxContentWidth);
                        for(var cText=0; cText < contentTextArray.length; cText++){
                            // Zeile passt nicht mehr auf Seite
                            if(currentHeightPosition + pdfMarginBottom > maxHeight){
                                var docFontSize = doc.getFontSize();
                                var docFontStyle = "normal";
                                var result = gbuMittelwertePDFAddNewPage(doc, pdfFormat, pdfOrientation, pdfFont, docFontSize, docFontStyle, pageNumberFontSize, pageNumberFontStyle, pdfCenter, pdfMarginTop, pdfMarginBottom, maxHeight);
                                doc = result[0];
                                currentHeightPosition = result[1];
                            }
                            var writeResult = gbuMittelwertePDFWriteContent(doc, contentTextArray[cText], pdfMarginLeft, currentHeightPosition);
                            doc = writeResult[0];
                            currentHeightPosition = writeResult[1];
                        }
                        currentHeightPosition += 4.5;
                    }
                    else if(jQuery(gbuMittelwerteGroupItemsDivContent[gbuMittelwerteGroupItemsDivCons]).is("table")){
                        var tableHead = jQuery(gbuMittelwerteGroupItemsDivContent[gbuMittelwerteGroupItemsDivCons]).find("thead");
                        var tableHeadTh = jQuery(tableHead).find("tr th");
                        var tableHeadContent = [];
                        for(var tableHeadThIndex = 0; tableHeadThIndex < tableHeadTh.length; tableHeadThIndex++){
                            if(jQuery(tableHeadTh[tableHeadThIndex]).find("select").length){
                                var tabelSelectElement = jQuery(tableHeadTh[tableHeadThIndex]).find("select");
                                tableHeadContent.push(jQuery(tabelSelectElement).find("option:selected").text());
                            }
                            else{
                                tableHeadContent.push(jQuery(tableHeadTh[tableHeadThIndex]).text());
                            }
                        }
                        // Bestimme maximale Breite für eine Cell
                        var cellWidth = gbuMittelwertePDFGetMaxTableCellWidth(maxContentWidth, tableHeadContent);
                        // Abstand (in x-Richtung) zwischen (linken/rechten) 'Rand' des Feldes zum Inhalt des Feldes
                        var fieldMarginX = 5;
                        // Abstand (in y-Richtung) zwischen (oberen/unteren) 'Rand' des Feldes zum Inhalt des Feldes
                        var fieldMarginY = doc.getFontSize()*0.352778+doc.getLineHeightFactor()*0.352778;
                        // Maximale Breite für den Inhalt eines Feldes
                        var maxFieldContentWidth = cellWidth - 2*fieldMarginX;

                        // Zwischenspeichern der aktuellen Position des Texts
                        var tempCurrentHeightPosition = currentHeightPosition;
                        // Höchste Position des Texts nach Zeichnen und Schreiben der aktuellen Zeile (zunächst die aktuelle Position)
                        var maxCurrentHeightPosition = currentHeightPosition;
                        // Offset zwischen einzelnen Feldern in Y-Richtung
                        var offsetYDir = 1.5;
                        // Zwischenspeichern der aktuellen Seite(nzahl)
                        var tempPage = doc.page;
                        // Höchste Seite nach Zeichnen und Schreiben der aktuellen Zeile (zunächst die aktuelle Seite)
                        var maxPage = doc.page;

                        // Aktuelle Position des Rahmens
                        var currentRectPosition = currentHeightPosition;
                        // Zwischenspeichern der aktuellen Position des Rahmens
                        var tempRectPosition = currentRectPosition;

                        // Bestimme höchste Anzahl an Zeilen des Inhalts aller Zeilen dieser Reihe
                        var maxLinesThisRow = 0;
                        for(var cellIndex1 = 0; cellIndex1 < tableHeadContent.length; cellIndex1++){
                            var thisCellContent = gbuMittelwertePDFReplaceSpecialCharacters(tableHeadContent[cellIndex1]);
                            var thisCellContentArray = doc.splitTextToSize(thisCellContent, maxFieldContentWidth);

                            if(thisCellContentArray.length > maxLinesThisRow){
                                maxLinesThisRow = thisCellContentArray.length;
                            }
                        }

                        for(var cellIndex2 = 0; cellIndex2 < tableHeadContent.length; cellIndex2++){

                            // Zurücksetzen der Position
                            currentHeightPosition = tempCurrentHeightPosition;
                            doc.page = tempPage;
                            doc.setPage(tempPage);
                            // Position für Rahmen zurücksetzen
                            currentRectPosition = tempRectPosition;

                            var thisCellContent = gbuMittelwertePDFReplaceSpecialCharacters(tableHeadContent[cellIndex2]);
                            var thisCellContentArray = doc.splitTextToSize(thisCellContent, maxFieldContentWidth);
                            // Zählvariable für Schleife
                            var linesToDraw = maxLinesThisRow;
                            // Drucke Rahmen und Inhalt
                            while(linesToDraw > 0){
                                // Berechne übrigen Platz auf Seite
                                var remainingSpace = maxHeight - pdfMarginBottom - currentRectPosition;
                                // Anzahl an freien Zeilen für Inhalt auf Seite
                                var linesAvailable = Math.floor((remainingSpace - 2*fieldMarginY)/(doc.getFontSize()*0.352778+doc.getLineHeightFactor()*0.352778));
                                // Es kann mindestens eine Zeile gezeichnet werden
                                if(linesAvailable > 0){
                                    // Zeilen, die auf dieser Seite gezeichnet werden können
                                    var linesThisPage = 0
                                    if(linesAvailable >= linesToDraw){
                                        linesThisPage = linesToDraw;
                                    }
                                    else{
                                        linesThisPage = linesAvailable;
                                    }
                                    // Zeichne Rahmen
                                    var heightThisRect = linesThisPage*(doc.getFontSize()*0.352778+doc.getLineHeightFactor()*0.352778);
                                    doc = gbuMittelwertePDFDrawRectangle(doc, pdfMarginLeft+cellWidth*cellIndex2, currentRectPosition, cellWidth, heightThisRect+2*fieldMarginY, "rgb(255,255,255)");
                                    currentRectPosition += heightThisRect+2*fieldMarginY;
                                    
                                    while(linesThisPage > 0){
                                        // Inhalt schreiben, sofern vorhanden
                                        if(thisCellContentArray.length > 0){
                                            doc.setFont(pdfFont, "normal");
                                            var result = gbuMittelwertePDFWriteContent(doc, thisCellContentArray[0], pdfMarginLeft+cellIndex2*cellWidth+fieldMarginX, currentHeightPosition+2*fieldMarginY);
                                            doc = result[0];
                                            currentHeightPosition += doc.getFontSize()*0.352778+doc.getLineHeightFactor()*0.352778;
                                            thisCellContentArray.shift();
                                            doc.setFont(pdfFont, "normal");
                                        }
                                        // Zählvariable innere Schleife anpassen
                                        linesThisPage--;
                                        // Zählvariable äußere Schleife anpassen
                                        linesToDraw--;
                                    }
                                }
                                // Es ist nicht genügend Platz auf der Seite für mindestens eine Zeile
                                else{
                                    var docFontSize = doc.getFontSize();
                                    var docFontStyle = "normal";
                                    var result = gbuMittelwertePDFAddNewPageTables(doc, pdfFormat, pdfOrientation, pdfFont, docFontSize, docFontStyle, pageNumberFontSize, pageNumberFontStyle, pdfCenter, pdfMarginTop, pdfMarginBottom, maxHeight, maxPage);
                                    doc = result[0];
                                    currentHeightPosition = result[1];
                                    maxPage = result[2];
                                    currentRectPosition = currentHeightPosition;
                                }
                            }
                        }
                        currentHeightPosition = currentRectPosition;

                        var tableBodyRows = jQuery(gbuMittelwerteGroupItemsDivContent[gbuMittelwerteGroupItemsDivCons]).find("tbody tr");
                        for(var tableBodyRow = 0; tableBodyRow < tableBodyRows.length; tableBodyRow++){
                            var tableRowTd = jQuery(tableBodyRows[tableBodyRow]).find("td:not(.d-none)");
                            var tableRowTdContent = [];
                            for(var tableRowTdIndex = 0; tableRowTdIndex < tableRowTd.length; tableRowTdIndex++){
                                tableRowTdContent.push(jQuery(tableRowTd[tableRowTdIndex]).text());
                            }

                            // Bestimme maximale Breite für eine Cell
                            var cellWidth = gbuMittelwertePDFGetMaxTableCellWidth(maxContentWidth, tableRowTdContent);
                            // Abstand (in x-Richtung) zwischen (linken/rechten) 'Rand' des Feldes zum Inhalt des Feldes
                            var fieldMarginX = 5;
                            // Abstand (in y-Richtung) zwischen (oberen/unteren) 'Rand' des Feldes zum Inhalt des Feldes
                            var fieldMarginY = doc.getFontSize()*0.352778+doc.getLineHeightFactor()*0.352778;
                            // Maximale Breite für den Inhalt eines Feldes
                            var maxFieldContentWidth = cellWidth - 2*fieldMarginX;

                            // Zwischenspeichern der aktuellen Position des Texts
                            var tempCurrentHeightPosition = currentHeightPosition;
                            // Höchste Position des Texts nach Zeichnen und Schreiben der aktuellen Zeile (zunächst die aktuelle Position)
                            var maxCurrentHeightPosition = currentHeightPosition;
                            // Offset zwischen einzelnen Feldern in Y-Richtung
                            var offsetYDir = 1.5;
                            // Zwischenspeichern der aktuellen Seite(nzahl)
                            var tempPage = doc.page;
                            // Höchste Seite nach Zeichnen und Schreiben der aktuellen Zeile (zunächst die aktuelle Seite)
                            var maxPage = doc.page;

                            // Aktuelle Position des Rahmens
                            var currentRectPosition = currentHeightPosition;
                            // Zwischenspeichern der aktuellen Position des Rahmens
                            var tempRectPosition = currentRectPosition;

                            // Bestimme höchste Anzahl an Zeilen des Inhalts aller Zeilen dieser Reihe
                            var maxLinesThisRow = 0;
                            for(var cellIndex1 = 0; cellIndex1 < tableRowTdContent.length; cellIndex1++){
                                var thisCellContent = gbuMittelwertePDFReplaceSpecialCharacters(tableRowTdContent[cellIndex1]);
                                var thisCellContentArray = doc.splitTextToSize(thisCellContent, maxFieldContentWidth);

                                if(thisCellContentArray.length > maxLinesThisRow){
                                    maxLinesThisRow = thisCellContentArray.length;
                                }
                            }

                            for(var cellIndex2 = 0; cellIndex2 < tableRowTdContent.length; cellIndex2++){
                                // Zurücksetzen der Position
                                currentHeightPosition = tempCurrentHeightPosition;
                                doc.page = tempPage;
                                doc.setPage(tempPage);
                                // Position für Rahmen zurücksetzen
                                currentRectPosition = tempRectPosition;

                                var thisCellContent = gbuMittelwertePDFReplaceSpecialCharacters(tableRowTdContent[cellIndex2]);
                                var thisCellContentArray = doc.splitTextToSize(thisCellContent, maxFieldContentWidth);
                                var thisCellColor = jQuery(tableRowTd[cellIndex2]).css('background-color');

                                // Zählvariable für Schleife
                                var linesToDraw = maxLinesThisRow;
                                // Drucke Rahmen und Inhalt
                                while(linesToDraw > 0){
                                    // Berechne übrigen Platz auf Seite
                                    var remainingSpace = maxHeight - pdfMarginBottom - currentRectPosition;
                                    // Anzahl an freien Zeilen für Inhalt auf Seite
                                    var linesAvailable = Math.floor((remainingSpace - 2*fieldMarginY)/(doc.getFontSize()*0.352778+doc.getLineHeightFactor()*0.352778));
                                    // Es kann mindestens eine Zeile gezeichnet werden
                                    if(linesAvailable > 0){
                                        // Zeilen, die auf dieser Seite gezeichnet werden können
                                        var linesThisPage = 0
                                        if(linesAvailable >= linesToDraw){
                                            linesThisPage = linesToDraw;
                                        }
                                        else{
                                            linesThisPage = linesAvailable;
                                        }
                                        // Zeichne Rahmen
                                        var heightThisRect = linesThisPage*(doc.getFontSize()*0.352778+doc.getLineHeightFactor()*0.352778);
                                        doc = gbuMittelwertePDFDrawRectangle(doc, pdfMarginLeft+cellWidth*cellIndex2, currentRectPosition, cellWidth, heightThisRect+2*fieldMarginY, thisCellColor);
                                        currentRectPosition += heightThisRect+2*fieldMarginY;
                                    
                                        while(linesThisPage > 0){
                                            // Inhalt schreiben, sofern vorhanden
                                            if(thisCellContentArray.length > 0){
                                                doc.setFont(pdfFont, "normal");
                                                var result = gbuMittelwertePDFWriteContent(doc, thisCellContentArray[0], pdfMarginLeft+cellIndex2*cellWidth+fieldMarginX, currentHeightPosition+2*fieldMarginY);
                                                doc = result[0];
                                                currentHeightPosition += doc.getFontSize()*0.352778+doc.getLineHeightFactor()*0.352778;
                                                thisCellContentArray.shift();
                                                doc.setFont(pdfFont, "normal");
                                            }
                                            // Zählvariable innere Schleife anpassen
                                            linesThisPage--;
                                            // Zählvariable äußere Schleife anpassen
                                            linesToDraw--;
                                        }
                                    }
                                    // Es ist nicht genügend Platz auf der Seite für mindestens eine Zeile
                                    else{
                                        var docFontSize = doc.getFontSize();
                                        var docFontStyle = "normal";
                                        var result = gbuMittelwertePDFAddNewPageTables(doc, pdfFormat, pdfOrientation, pdfFont, docFontSize, docFontStyle, pageNumberFontSize, pageNumberFontStyle, pdfCenter, pdfMarginTop, pdfMarginBottom, maxHeight, maxPage);
                                        doc = result[0];
                                        currentHeightPosition = result[1];
                                        maxPage = result[2];
                                        currentRectPosition = currentHeightPosition;
                                    }
                                }
                            }
                            currentHeightPosition = currentRectPosition;
                        }

                        currentHeightPosition += 7.5;
                    }
                }
            }
        }

        doc.save("Auswertung");
    }

    function gbuMittelwertePDFWritePageNumber(doc, pdfFont, docFontSize, docFontStyle, pageNumberFontSize, pageNumberFontStyle, center, marginBottom, maxHeight){        
        doc.setFontSize(pageNumberFontSize);
        doc.setFont(pdfFont, pageNumberFontStyle);
        var currentTextColor = doc.getTextColor();
        doc.setTextColor(0,0,0);
        doc.text("-"+doc.page+"-", center, maxHeight-(marginBottom/2),{align:'center'});
        doc.setFontSize(docFontSize);
        doc.setFont(pdfFont, docFontStyle);
        doc.setTextColor(currentTextColor);
        return doc;
    }

    function gbuMittelwertePDFReplaceSpecialCharacters(content){
        var changedContent = content.replace(/–/g,"-").replace(/…/g,"...").replace(/➔/g,"->").replace(/„/g, '"').replace(/“/g, '"').replace(/″/g, '"').replace(/’/g, "'");
        return changedContent;
    }

    function gbuMittelwertePDFAddNewPage(doc, pdfFormat, pdfOrientation, pdfFont, docFontSize, docFontStyle, pageNumberFontSize, pageNumberFontStyle, center, marginTop, marginBottom, maxHeight){
        doc.addPage(pdfFormat, pdfOrientation);
        var currentHeightPosition = marginTop;
        doc.page++;
        doc = gbuMittelwertePDFWritePageNumber(doc, pdfFont, docFontSize, docFontStyle, pageNumberFontSize, pageNumberFontStyle, center, marginBottom, maxHeight);
        return [doc, currentHeightPosition];
    }

    function gbuMittelwertePDFWriteContent(doc, content, marginLeft, currentHeightPosition){
        doc.text(content, marginLeft, currentHeightPosition);
        currentHeightPosition += doc.getFontSize()*0.352778+doc.getLineHeightFactor()*0.352778;
        return [doc, currentHeightPosition];
    }

    function gbuMittelwertePDFGetMaxTableCellWidth(width, elements){
        if(elements.length > 0){
            var tableCellWidth = width/elements.length;
            return tableCellWidth;
        }
        else{
            return 0;
        }
    }

    function gbuMittelwertePDFDrawRectangle(doc, x, y, w, h, color){
        doc.setFillColor(color);
        doc.rect(x, y, w, h, 'DF');
        doc.setFillColor(255,255,255);
        return doc;
    }

    function gbuMittelwertePDFAddNewPageTables(doc, pdfFormat, pdfOrientation, pdfFont, docFontSize, docFontStyle, pageNumberFontSize, pageNumberFontStyle, center, marginTop, marginBottom, maxHeight, maxPage){

        var currentHeightPosition = marginTop;
        // Die aktuelle Seite ist die höchste Seite -> Es muss eine neue Seite angelegt werden
        if(doc.page == maxPage){
            doc.addPage(pdfFormat, pdfOrientation);
            doc.page++;
            doc = gbuMittelwertePDFWritePageNumber(doc, pdfFont, docFontSize, docFontStyle, pageNumberFontSize, pageNumberFontStyle, center, marginBottom, maxHeight);
            maxPage++;
        }
        // Die aktuelle Seite ist nicht die höchste Seite -> Es muss zur nächsten Seite gewechselt werden
        else if(doc.page < maxPage){
            doc.setPage(doc.page+1);
            doc.page++;
        }

        return [doc, currentHeightPosition, maxPage];
    }

</script>