<div class="content-wrapper" ng-if="myAccess.myDiaryReport">
    <section class="content-header">
        <div class="container-fluid">
            <div class="row mb-2">
                <div class="col-sm-3">
                    <h1 class="text-olive">
                        <go-back/>
                        <i class="fas fa-book"></i> {{filter.pageName}}

                    </h1>
                </div>
                <div class="col-sm-2 offset-2">
                    <button ng-click="goTo($event,'myDiaryReportHeroView')" type="button" class="btn btn-warning"><span class="d-none d-lg-inline-block">Go To Hero Wise Diary View</span></button>
                </div>
                <div class="col-sm-5">
                    <ol class="breadcrumb float-sm-right">
                        <li class="breadcrumb-item"><a ng-href="{{baseurl}}/dashboard">Home</a></li>
                        <li class="breadcrumb-item active">My Diary</li>
                    </ol>
                </div>
            </div>
        </div><!-- /.container-fluid -->
    </section>
    <section class="content">
        <div class="container-fluid">
            <div class="row">
                <div class="col-md-12">
                    <div class="form-group row">
                        <div class="col-sm-3"><input data-toggle="tooltip" title="From Date" type=text max-date="{{filter.toDate}}" date-picker placeholder='From Date (DD-MM-YYYY)' dateformat='dd-mm-yy' maxlength="10" ng-required='true' class='form-control' ng-model='filter.fromDate'/></div>
                        <div class="col-sm-3"><input data-toggle="tooltip" title="To Date" type=text min-date="{{filter.fromDate}}" date-picker placeholder='To Date (DD-MM-YYYY)' dateformat='dd-mm-yy' maxlength="10" ng-required='true' class='form-control' min ng-model='filter.toDate'/></div>
                        <div class="col-sm-4">
                            <ui-select id="project" ng-model="filter.project" theme="bootstrap" title="Select a Project" class="">
                                <ui-select-match placeholder="Select or search a Project in the list...">{{$select.selected.name}}</ui-select-match>
                                <ui-select-choices repeat="p in project | filter: $select.search">
                                    <span ng-bind-html="p.name | highlight: $select.search"></span>
                                </ui-select-choices>
                            </ui-select>
                            <!--<select  class="form-control custom-select" ng-model="filter.project" ng-options="p as p.name for p in project|filter:p.proj_status='active'"></select>-->
                        </div>
                        <div class="col-sm-1">
                            <button class="btn btn-success" ng-click="dateChanged()"> Filter</button>
                        </div>
                        <div class="col-sm-1"><select data-toggle="tooltip" title="View Type" id="viewType" class="form-control custom-select" ng-model="filter.selType" ng-options="p.val as p.val for p in filter.type"></select></div>
                    </div>

                </div>
                <div class="col-md-12" ng-if="showLockDiv && myAccess.myDiaryLock">
                    <div class="form-group row">
                        <div class="col-sm-2 offset-4">
                            Last Locked Date:
                            <strong>
                                <span ng-if="filter.project.proj_mydiaryLockDate" class="nowrap" ng-bind="formatDate(filter.project.proj_mydiaryLockDate) | date:'dd MMM yyyy'"></span>
                                <span ng-if="!filter.project.proj_mydiaryLockDate"> Not Available </span>
                            </strong>
                        </div>
                        <div class="col-sm-3"><input data-toggle="tooltip" title="Lock Till Date" type=text" date-picker placeholder='Lock Till  Date (DD-MM-YYYY)' dateformat='dd-mm-yy' maxlength="10" ng-required='true' class='form-control' ng-model='myDiaryLock.LockTillDate'/></div>
                        <div class="col-sm-1">
                            <button class="btn btn-success" ng-click="updateLockedDate()">Update Locked date</button>
                        </div>
                    </div>
                </div>
                <div class="col-md-12">
                    <div class="card card-primary card-outline" ng-show="filter.selType==='Default'">
                        <div class="card-header border-transparent  mb-1">
                            <h3 class="card-title">Report</h3>
                            <div class="card-tools">
                                <div class="btn-group">
                                    <button type="button" title="Fullscreen Toggle" class="btn btn-dark toggle-fullscreen"><i class="fas fa-expand"></i></button>
                                    <button type="button" class="btn btn-dark" data-widget="collapse"><i class="fas fa-minus"></i></button>
                                </div>
                            </div>
                        </div>
                        <div class="card-body p-0">
                            <div class="table table-responsive">
                                <table class="myDiaryDataTableView table table-bordered table-striped table-sm">
                                    <thead>
                                    <tr>
                                        <th>#</th>
                                        <th>Hero</th>
                                        <th>Hero Id</th>
                                        <th>Project</th>
                                        <th>Project Id</th>
                                        <th>Date</th>
                                        <th>Reference</th>
                                        <th>Description</th>
                                        <th>Type</th>
                                        <th>Hours</th>
                                        <th>Comments</th>
                                        <!--<th data-toggle="tooltip" title="Hours Per/day" ><small>Billable / Non Billable</small> <i class="fas fa-question-circle"></i></th>-->
                                    </tr>
                                    </thead>
                                    <tbody>
                                    <tr ng-repeat="d in myDiary.default">
                                        <td>{{$index+1}}</td>
                                        <td><span>{{d.emp_first_name +' '+d.emp_last_name}}</span></td>
                                        <td><span>{{d.emp_code}}</span></td>
                                        <td><span>{{d.proj_name}}</span></td>
                                        <td><span>{{d.projectid}}</span></td>
                                        <td><span class="nowrap" ng-bind="formatDate(d.date) | date:'dd MMM yyyy'"></span></td>
                                        <td><span class="">{{d.reference}}</span></td>
                                        <td><span class=""><div class="" ng-bind-html="d.description"></div></span></td>
                                        <td><span class="nowrap">{{d.lt_name | titlecase}}</span></td>
                                        <td><span class="nowrap">{{d.hours}}</span></td>
                                        <td><span class="">{{d.comments}}</span></td>
                                    </tr>
                                    <!-- <tr>
                                         <td>Total</td>
                                         <td></td>
                                         <td></td>
                                         <td></td>
                                         <td></td>
                                         <td></td>
                                         <td></td>
                                         <td>{{totalHours(myDiary.default,'hours',myDiary.default)}}</td>
                                         <td></td>
                                     </tr>-->
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>

                    <div class="card card-primary card-outline" ng-if="filter.selType==='Project'" ng-repeat="p in myDiary.project">
                        <div class="card-header border-transparent  mb-1">
                            <h3 class="card-title">{{p.name}}</h3>
                            <div class="card-tools">
                                <div class="btn-group">
                                    <button type="button" title="Fullscreen Toggle" class="btn btn-dark toggle-fullscreen"><i class="fas fa-expand"></i></button>
                                    <button type="button" class="btn btn-dark" data-widget="collapse"><i class="fas fa-minus"></i></button>
                                </div>
                            </div>
                        </div>
                        <div class="card-body p-0">
                            <div class="table table-responsive">
                                <table class="myDiaryDataTableView table table-bordered table-striped table-sm">
                                    <thead>
                                    <tr>
                                        <th>#</th>
                                        <th>Hero</th>
                                        <th>Date</th>
                                        <th>Reference</th>
                                        <th>Description</th>
                                        <th>Type</th>
                                        <th>Hours</th>
                                        <th>Comments</th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    <tr ng-repeat="d in p.data">
                                        <td>{{$index+1}}</td>
                                        <td><span>{{d.emp_first_name +' '+d.emp_last_name}}</span></td>
                                        <td><span class="nowrap" ng-bind="formatDate(d.date) | date:'dd MMM yyyy'"></span></td>
                                        <td><span class="">{{d.reference}}</span></td>
                                        <td><span class=""><div class="" ng-bind-html="d.description"></div></span></td>
                                        <td><span class="nowrap">{{d.lt_name | titlecase}}</span></td>
                                        <td><span class="nowrap">{{d.hours}}</span></td>
                                        <td><span class="">{{d.comments}}</span></td>
                                    </tr>
                                    <tr>
                                        <td>Total</td>
                                        <td></td>
                                        <td></td>
                                        <td></td>
                                        <td></td>
                                        <td></td>
                                        <td>{{totalHoursNew(myDiary.default,'hours',p.data)}}</td>
                                        <td></td>
                                    </tr>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>

                    <div class="card card-primary card-outline" ng-show="filter.selType==='Hero'" ng-repeat="p in myDiary.heroes">
                        <div class="card-header border-transparent  mb-1">
                            <h3 class="card-title">{{p.name}}</h3>
                            <div class="card-tools">
                                <div class="btn-group">
                                    <button type="button" title="Fullscreen Toggle" class="btn btn-dark toggle-fullscreen"><i class="fas fa-expand"></i></button>
                                    <button type="button" class="btn btn-dark" data-widget="collapse"><i class="fas fa-minus"></i></button>
                                </div>
                            </div>
                        </div>
                        <div class="card-body p-0">
                            <div class="table table-responsive">
                                <table class="myDiaryDataTableView table table-bordered table-striped table-sm">
                                    <thead>
                                    <tr>
                                        <th>#</th>
                                        <th>Project</th>
                                        <th>Date</th>
                                        <th>Reference</th>
                                        <th>Description</th>
                                        <th>Type</th>
                                        <th>Hours</th>
                                        <th>Comments</th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    <tr ng-repeat="d in p.data">
                                        <td>{{$index+1}}</td>
                                        <td><span>{{d.proj_name}}</span></td>
                                        <td><span class="nowrap" ng-bind="formatDate(d.date) | date:'dd MMM yyyy'"></span></td>
                                        <td><span class="">{{d.reference}}</span></td>
                                        <td><span class=""><div class="" ng-bind-html="d.description"></div></span></td>
                                        <td><span class="nowrap">{{d.lt_name | titlecase}}</span></td>
                                        <td><span class="nowrap">{{d.hours}}</span></td>
                                        <td><span class="">{{d.comments}}</span></td>
                                    </tr>
                                    <tr>
                                        <td>Total</td>
                                        <td></td>
                                        <td></td>
                                        <td></td>
                                        <td></td>
                                        <td></td>
                                        <td>{{totalHours(myDiary.default,'hours',p.data)}}</td>
                                        <td></td>
                                    </tr>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>
</div>
