<div class="dialog">

    <div class="dialogBody statistics">
        <table class="dialogInfoTable groupContainer">
            <tr>
                <td class="dialogTitleInfo">{{model.Event.Designation}}</td>
                <td>
                    <div class="buttonContainer">
                        {{#if showReportButton}}
                        {{crystal-report-chooser context='Anlass' keys=model.Event.Id}}
                        {{/if}}
                    </div>
                </td>
            </tr>
            <tr>
                <td>{{subscriptionCount}} {{translate 'subscriptions'}}</td>
            </tr>
        </table>

        <div>
            <!-- to calculate invalidated rows we need to run this-->
            {{#each model.GradingItems as |item|}}
            <span style="display:none">
                {{grading-item allSubscriptionDetails=model.SubscriptionDetails model=item scale=model.Event.Scale isReadOnly=true validated='gradingItemValidated' hideControlColumns=true}}
            </span>
            {{/each}}
        </div>

        {{#if model.hasNothingToShow}}
            <div class="validationErrorMessage">
                {{translate 'gradingNothingToShow'}}
            </div>
        {{/if}}

        {{#if showStudentsTable}}
            <div class="divWrapper groupContainer">
                <div class="mobile table-options__buttons">
                    {{#each availableColumns as |item|}}
                        <button {{action 'setSelectedColumn' item.id}} class="{{if (eq selectedColumn item.id) 'active' ''}} option-button">{{item.label}}</button>
                    {{/each}}
                </div>

                <table class="dialogAccordionTable editTable gradigTable">
                    <thead>
                        <tr>
                            <th>{{translate 'name'}}</th>
                            <th class="{{unless (eq selectedColumn 'grade')   'hide-column' ''}}">{{translate 'grade'}}</th>
                            <th class="{{unless (eq selectedColumn 'comment') 'hide-column' ''}}">{{translate 'comment'}}</th>
                            {{#each columnDetails as |columnDetail|}} 
                                <th class="{{unless (eq selectedColumn columnDetail.VssId) 'hide-column' ''}}">
                                    {{columnDetail.VssBezeichnung}}
                                </th>
                            {{/each}}
                        </tr>
                    </thead>
                    <tbody>
                        {{#each gradingItemsPrepared as |item|}}
                            <tr>
                                <td style="white-space: nowrap;">{{item.name}}</td>
                                <td class="{{unless (eq selectedColumn 'grade')   'hide-column' ''}}">{{item.grade}}</td>
                                <td class="{{unless (eq selectedColumn 'comment') 'hide-column' ''}}">{{item.comment}}</td>
                                {{#each item.details as |detail|}} 
                                    <td class="{{unless (eq selectedColumn detail.VssId) 'hide-column' ''}}">
                                        {{subscription-detail 
                                            model=detail
                                            showLabel=false
                                            setReadOnly=true
                                        }}
                                    </td>
                                {{/each}}
                            </tr>
                        {{/each}}
                        {{#if model.IsUnregisteredStudentsEnabled}}
                            <th colspan="99">
                                {{translate 'unregisteredStudentsTitle'}}
                            </th>
                            {{#each unregisteredStudentsPrepared as |item|}}
                                <tr>
                                    <td style="white-space: nowrap;">{{item.name}}</td>
                                    <td class="{{unless (eq selectedColumn 'grade')  'hide-column' ''}}">{{item.grade}}</td>
                                    <td class="{{unless (eq selectedColumn 'comment') 'hide-column' ''}}">{{item.comment}}</td>
                                    {{#each item.details as |detail|}} 
                                        <td class="{{unless (eq selectedColumn detail.VssId) 'hide-column' ''}}">
                                            {{subscription-detail 
                                                model=detail
                                                showLabel=false
                                                setReadOnly=true
                                            }}
                                        </td>
                                    {{/each}}
                                </tr>
                            {{/each}}
                        {{/if}}
                    </tbody>
                </table>
            </div>
        {{/if}}

        <h4>{{translate 'statisticTitle'}}</h4>
        <div class="divWrapper">
            <div class="infoTable">
                <table>
                    <tr><td>{{translate 'average'}}</td><td>{{averageGrade}}</td></tr>
                    <tr><td>{{translate 'standardDeviation'}}</td><td>{{standardDeviation}}</td></tr>
                    <tr><td>{{translate 'numberOfGrades'}}</td><td>{{gradeCount}}</td></tr>
                    <tr><td>{{translate 'bestGrade'}}</td><td>{{bestGrade}}</td></tr>
                    <tr><td>{{translate 'worstGrade'}}</td><td>{{worstGrade}}</td></tr>
                    <tr><td>{{translate 'unsufficient'}}</td><td>{{unsufficientCount}}</td></tr>
                </table>
            </div>
            <div class="graph-info">
                <div id="flot-legend" class="flotLegend"></div>
                <div class="not-mobile">
                    {{flot-graphic series=flotSeries id="graphicNotForMobile" clickable=true ticks=flotTicks legendSelector='#flot-legend' xAxisLabel=(translate 'grade') yAxisLabel=(translate 'count')}}
                </div>
                <div class="mobile mobileFlot">
                    {{flot-graphic series=flotSeries id="graphicForMobile" clickable=false ticks=flotTicks legendSelector='#flot-legend' xAxisLabel=(translate 'grade') yAxisLabel=(translate 'count')}}
                </div>
            </div>
        </div>
    </div>
    
    <div class="dialogFooter">
        {{#if showValidationMessage}}
            <div class="footerValidation dialogContextMenu">{{validationMessage}}</div>
        {{/if}}
        {{#if canProceed}}
            <div class="buttonDiv">
                <button type="button" class="textButton" {{action 'finish'}}>
                    <span class="material-icons">arrow_right_alt</span>
                    <div>{{finishButtonText}}</div>
                </button>
            </div>
        {{else}}
            <div class="buttonDiv"></div>
        {{/if}}
        <div class="buttonDiv">
            <button type="button" class="textButton" {{action 'back'}}>
                <span class="material-icons reverse">arrow_right_alt</span>
                <div>{{translate 'backToGrading'}}</div>
            </button>
        </div>
    </div>
</div>