<button type="button" class="btn btn-info" ng-click="save()">
    <span class="glyphicon glyphicon-floppy-disk"></span> Speichern
</button>
<br/><br/>
<form role="form">
<table class="table table-bordered table-striped" style="width: auto;">
    <tr>
        <th style="width: 230px;">Kunde</th>
        <th style="width: 130px;">Aktiv</th>
        <th style="width: 180px;">System</th>
        <th style="width: 140px;">Start</th>
        <th style="width: 140px;">Ende</th>
        <th style="width: 190px;">Erster Bericht</th>
        <th style="width: 130px;">Arbeitstage</th>
        <th style="width: 250px;">Bundesland</th>
        <th style="width: 100px;">PLZ</th>
        <th style="width: 200px;">Ort</th>
        <th style="width: 220px;">Optionen</th>
    </tr>
    <tr>
        <td><input ng-model="Filter.kunde"/></td>
        <td>
            <div class="dropdown">
                <a class="btn dropdown-toggle" role="button" data-toggle="dropdown">{{domain.aktiv[Filter.aktiv]||'alle'}}&nbsp;<b class="caret"></b></a>
                <ul class="dropdown-menu" role="menu">
                    <li><a ng-click="Filter.aktiv=''">alle</a></li>
                    <li class="divider"></li>
                    <li ng-repeat="(key,val) in domain.aktiv"><a ng-click="Filter.aktiv=key">{{val}}</a></li>
                </ul>
            </div>
        </td>
        <td>
            <div class="dropdown">
                <a class="btn dropdown-toggle" role="button" data-toggle="dropdown">{{Filter.system||'alle'}}&nbsp;<b class="caret"></b></a>
                <ul class="dropdown-menu" role="menu">
                    <li><a ng-click="Filter.system=''">alle</a></li>
                    <li class="divider"></li>
                    <li ng-repeat="val in domain.system"><a ng-click="Filter.system=val">{{val}}</a></li>
                </ul>
            </div>
        </td>
        <td></td>
        <td></td>
        <td></td>
        <td>
            <div class="dropdown">
                <a class="btn dropdown-toggle" role="button" data-toggle="dropdown">{{Filter.woche||'alle'}}&nbsp;<b class="caret"></b></a>
                <ul class="dropdown-menu" role="menu">
                    <li><a ng-click="Filter.woche=''">alle</a></li>
                    <li class="divider"></li>
                    <li ng-repeat="val in domain.woche"><a ng-click="Filter.woche=val">{{val}}</a></li>
                </ul>
            </div>
        </td>
        <td>
            <div class="dropdown">
                <a class="btn dropdown-toggle" role="button" data-toggle="dropdown">{{domain.bundesland[Filter.bundesland]||'alle'}}&nbsp;<b class="caret"></b></a>
                <ul class="dropdown-menu" role="menu">
                    <li><a ng-click="Filter.bundesland=''">alle</a></li>
                    <li class="divider"></li>
                    <li ng-repeat="(key,val) in domain.bundesland"><a ng-click="Filter.bundesland=key">{{val}}</a></li>
                </ul>
            </div>
        </td>
        <td></td>
        <td></td>
        <td></td>
    </tr>

    <tr ng-repeat="zeile in kunden | filter:Filter">
        <td><strong>{{zeile.kunde}}</strong></td>
        <td><select class="form-control" ng-model="zeile.aktiv" ng-options="k as v for (k,v) in domain.aktiv"></select></td>
        <td>
            <div class="input-group">
                <div class="input-group-addon label-{{zeile.system}}">{{firstChar(zeile.system)}}</div>
                <select class="form-control" ng-model="zeile.system" ng-options="v for v in domain.system"></select>
            </div>
        </td>
        <td><input class="form-control" type="time" ng-model="zeile.start_soll"/></td>
        <td><input class="form-control" type="time" ng-model="zeile.ende_soll"/></td>
        <td><input class="form-control" type="date" ng-model="zeile.erster_status"/></td>
        <td><select class="form-control" ng-model="zeile.woche" ng-options="v for v in domain.woche"></select></td>
        <td>
            <div class="input-group">
                <div class="input-group-addon">{{zeile.bundesland}}</div>
                <select class="form-control" ng-model="zeile.bundesland" ng-options="k as v for (k,v) in domain.bundesland"></select>
            </div>
        </td>
        <td><input class="form-control" ng-model="zeile.plz"/></td>
        <td><input class="form-control" ng-model="zeile.ort"/></td>
        <td>
            <a ng-href="#/overview/{{zeile.kunde}}/all/all"><button type="button" class="btn btn-default" title="Fehlermeldungen"><span class="glyphicon glyphicon-exclamation-sign"></span></button></a>
            <a ng-href="#/stats/{{zeile.kunde}}"><button type="button" class="btn btn-default" title="Statistik"><span class="glyphicon glyphicon-stats"></span></button></a>
            <a ng-href="#/config/{{zeile.kunde}}/current"><button type="button" class="btn btn-default" title="Konfiguration"><span class="glyphicon glyphicon-list-alt"></span></button></a>
            <a><button type="button" class="btn btn-default" title="Kalender"><span class="glyphicon glyphicon-calendar"></span></button></a>
        </td>
    </tr>
</table>
</form>

<!-- Modal -->
<div class="modal fade" id="fehler-modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                <h4 class="modal-title" id="myModalLabel">Fehlerbericht {{current.kunde}} - {{current.datum}}</h4>
            </div>
            <div class="modal-body">
                <pre>
                    {{current.fehler.logdatei}}
                </pre>

                <div class="logdatei" ng-repeat="e in current.fehler.fehlerbericht">
                    <p class="modell" ng-class="{'rot':e.ErrorLevel < 3}">{{e.Type}}: {{e.Name}}</p>
                    <p class="dateiname">
                        Dateiname: {{e.Filename}}<br />
                        Stand: {{dateFormat(e.Modified)}} ({{e.LastChangedDays}} Tage)
                    </p>

                    <div ng-show="e.Errors.length > 0">

                        <ul class="fehler" ng-show="e.Type=='Modell'">
                            <li ng-repeat="error in e.Errors"><a href="http://wiki.global-cube.de/{{error.Number}}">{{error.Number}}</a>:
                                ({{error.Level}}) {{error.Message}}</li>
                        </ul>
                        <ul class="fehler" ng-show="e.Type=='WebCreator'">
                            <li ng-repeat="error in e.Errors"><a href="http://wiki.global-cube.de/{{error.Number}}">{{error.Number}}</a>:
                                ({{error.Level}}) {{error.Message}}</li>
                        </ul>
                        <table class="ft" ng-show="e.Type=='Portal'||e.Type=='Versand'">
                            <tbody ng-repeat="error in e.Errors">
                                <tr>
                                    <td rowspan="5" class="number">{{$index+1}}
                                    <td>Datei:</td>
                                    <td>{{error.Filename}}</td>
                                </tr>
                                <tr>
                                    <td>Stand:</td>
                                    <td>{{error.Modified}}</td>
                                </tr>
                                <tr>
                                    <td>Benutzer:</td>
                                    <td>{{error.User}}</td>
                                </tr>
                                <tr>
                                    <td>Bericht:</td>
                                    <td>{{error.Report}} (Schicht {{error.Layer}})</td>
                                </tr>
                                <tr class="strich">
                                    <td>Empfänger:</td>
                                    <td>{{error.MailTo}}</td>
                                </tr>
                            </tbody>
                        </table>

                    </div>
                </div>


                <table class="table table-hover table-bordered">
                    <tr>
                        <th>Benutzer</th>
                        <td>
                            <input type="text" ng-model="current.fehler.benutzer" />
                        </td>
                    </tr>
                    <tr>
                        <th>Kommentar</th>
                        <td>
                            <label>
                                <textarea cols="40" rows="5">{{current.fehler.kommentar}}</textarea>
                            </label>
                        </td>
                    </tr>
                    <tr>
                        <th>Anzahl Fehler</th>
                        <td>
                            <label>
                                <input type="text" ng-model="current.fehler.anzahl"/>
                            </label>
                        </td>
                    </tr>
                    <tr>
                        <th>Bearbeitungsstand</th>
                        <td>
                            <label>
                                <select ng-model="current.fehler.bearbeitet" ng-options="k as v for (k,v) in domain.bearbeitet"></select>
                            </label>
                        </td>
                    </tr>
                </table>

            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary" ng-click="saveComments()" data-dismiss="modal">Speichern</button>
            </div>
        </div>
    </div>
</div>



<style>
.table tbody tr td {
    vertical-align: middle;
}

.label-0 {
    background-color: #aaaaaa;
}

.label-1 {
    background-color: #bbbb00;
}

.label-2 {
    background-color: #bb8800;
}

.label-3 {
    background-color: #bb0000;
}


table.ft {
    border: 1px solid #888;
}

table.ft td {
    padding: 3px 5px;
    margin: 2px;
    background-color: #ddd;
}

.logdatei {
    margin: 10px 5px 20px 5px;
    padding: 0 20px 10px 20px;
    background-color: #eee;
    border: 1px solid #888;
}

.modell {
    font-weight: bold;
    background-color: #ccc;
    padding: 10px;
    margin: 0 -20px;
}

.rot {
    background-color: #e88;
}

.number {
    font-weight: bold;
    background-color: #ccc;
    border: 1px solid #888888;
}

.strich {
    border-bottom: 1px solid #888888;
}

</style>