<div class="content-wrapper" ng-if="!myAccess.utilityDiaryReport">
    <div class="container-fluid">
        <div class="row">
            <div class="col-sm-6 offset-sm-1 offset-md-2 offset-lg-3 mt-5">
                <div class="alert alert-warning alert-dismissible">
                    <h5><i class="icon fas fa-ban"></i> Warning!</h5>
                    Unauthorised Access.
                </div>
            </div>
        </div>
    </div>
</div>
<style>.customTooltip {
    padding: 0 20px;
}</style>
<div class="content-wrapper" ng-if="myAccess.utilityDiaryReport">
    <section class="content-header">
        <div class="container-fluid">
            <div class="row mb-2">
                <div class="col-sm-12 col-md-6">
                    <h1 class="text-olive">
                        <go-back/>
                        <i class="fas fa-book"></i> {{filter.pageName}}
                    </h1>
                </div>
                <div class="col-sm-12 col-md-6">
                    <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 id="filter-options" class="form-group row">
                        <div class="col-sm-2">
                            <label for="willActAs">Category </label>
                            <a class="btn btn-xs btn-outline-primary" ng-click="selectAllCategory()">Select All </a>
                            <ui-select id="willActAs" multiple ng-model="filter.logtype" theme="bootstrap" title="Select categories" class="">
                                <ui-select-match placeholder="Select or search a category in the list...">{{$item.lt_name}}</ui-select-match>
                                <ui-select-choices repeat="lt.mydiarylogtypeid as lt in logTypes | filter: $select.search">
                                    <span ng-bind-html="lt.lt_name | highlight: $select.search"></span>
                                </ui-select-choices>
                            </ui-select>
                        </div>
                        <div class="col-sm-2">
                            <label for="revenueCenters">Select Revenue Center(s) </label>
                            <a class="btn btn-xs btn-outline-primary" ng-click="selectAllrevenueCenters()">Select All </a>
                            <!-- ng-click="updateEmployeesinRevenueCenter()" -->
                            <ui-select id="revenueCenters" multiple ng-model="filter.revenueCenters"  theme="bootstrap" title="Select  Revenue Center" class="">
                                <ui-select-match placeholder="Select or search a Revenue Center in the list...">{{$item.rc_name}}</ui-select-match>
                                <ui-select-choices repeat="rc.revenuecenterid as rc in revenueCenters | filter: $select.search">
                                    <span ng-bind-html="rc.rc_name | highlight: $select.search"></span>
                                </ui-select-choices>
                            </ui-select>
                            <!--select  class="form-control custom-select" ng-model="filter.employee" ng-options="e.id as e.name for e in employee|filter:e.emp_status='active'"></select-->
                        </div>

                        <div class="col-sm-2">
                            <label>Month/Year* </label>
                            <input type=month class='form-control' ng-change="updateEmployeesForMonth()" ng-model='filter.date'/></div>

                        <div class="col-sm-4">
                            <label for="employee">Select Hero </label>
                            <a class="btn btn-xs btn-outline-primary" ng-click="selectAllEmployee()">Select All </a>
                            <div class="custom-control custom-switch custom-switch-off-danger custom-switch-on-success float-right">
                                <input type="checkbox" ng-model="emp_status" class="custom-control-input" id="emp_status" ng-click="selectActiveEmployee(emp_status,$scope.filter.emp_id)" >
                                <label class="custom-control-label no-select pointer" for="emp_status">{{emp_status==false?'All Employees':'Only Active'}}</label>
                            </div>
                            <ui-select id="employee" multiple ng-model="filter.emp_id" theme="bootstrap" title="Select a Hero" class="">
                                <ui-select-match placeholder="Select or search a Hero in the list...">{{$item.name}}</ui-select-match>
                                <ui-select-choices repeat="e.id as e in employee | filter: $select.search">
                                    <span ng-bind-html="e.name | highlight: $select.search"></span>
                                </ui-select-choices>
                            </ui-select>
                            <!--select  class="form-control custom-select" ng-model="filter.employee" ng-options="e.id as e.name for e in employee|filter:e.emp_status='active'"></select-->
                        </div>



                        <div class="col-sm-1">
                            <label title="Monthly Working Hours" for="monthlyWorkingHours">W.Hrs</label>
                            <input class="form form-control" id="monthlyWorkingHours" type="number" ng-model="filter.monthlyWorkingHours"/>
                        </div>
                        <div class="col-sm-1">
                            <label for="filterBtn">Filter</label>
                            <button class="btn btn-success form form-control" id="filterBtn" ng-click="dateChanged()"><i class="fa fa-filter"></i> Filter</button>
                        </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">
                        <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">
                                <span ng-repeat="(key,val) in tblheader">{{key ? key : 'Date'}} test</span>
                                <table class="myDiaryDataTableView table table-bordered table-striped table-sm" id="myDiaryDataTableView">
                                    <thead>
                                    <tr>
                                        <th>#</th>
                                        <th>Hero</th>
                                        <th>Emp Id</th>
                                        <th>Designation</th>
                                        <th>Email ID</th>
                                        <th class="bg-navy text-right">Actual Billed Hours(Total)</th>
                                        <th>Total Hours Logged(Totalhours/160)</th>
                                        <th>Leave / Holiday</th>
                                        <th>Diary Percentage</th>
                                        <!--<th>Manager</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><spa>{{d.emp_designation}}</spa></td>
                                        <td><span>{{d.emp_email}}</span></td>
                                        <td class="bg-navy text-right"><span>{{d.billingEfficiency.billingefficiencysum?d.billingEfficiency.billingefficiencysum:'0'}}</span></td>
                                        <td class="text-right"><span>{{d.logged_hours.monthly_sum?d.logged_hours.monthly_sum:'0'}}</span></td>
                                        <td><span>{{d.holidaysOrLeaves.count}}</span></td>
                                        <td class="text-right"><span>{{d.logged_hours && d.logged_hours.monthly_sum ? ((d.logged_hours.monthly_sum/(filter.monthlyWorkingHours)) * 100).toFixed(0): "0" }}</span></td>
                                        <!--<td><span class="">{{d.linemgr.emp_first_name +' '+d.linemgr.emp_last_name}}</span></td>
                               <td><span class="">{{d.projmgr.emp_first_name +' '+d.projmgr.emp_last_name}}</span></td>-->
                                        <!--<td ng-repeat="val in d.logged_hours_new">
                                            <span class="customTooltip nowrap font-weight-bold">{{val.val ? val.val : '0'}}</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>
