<div class="content-wrapper" ng-if="myAccess.accountView">
    <section class="content-header">
        <div class="container-fluid">
            <div class="row mb-2">
                <div class="col-sm-6">
                    <h1 class="text-olive">
                        <go-back/>
                        <i class="fas fa-book"></i> Project diary
                    </h1>
                </div>
                <div class="col-sm-6">
                    <ol class="breadcrumb float-sm-right">
                        <li class="breadcrumb-item"><a ng-href="{{baseurl}}/dashboard">Home</a></li>
                        <li class="breadcrumb-item active">Project 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">
                        <label class="col-sm-1">From</label>
                        <div class="col-md-3"><input type=text date-picker
                                    placeholder='Date (DD-MM-YYYY)'
                                    dateformat='dd-mm-yy'
                                    maxlength="10"
                                    ng-required='true'
                                    class='form-control '
                                    ng-model='filter.fromDate'/></div>
                        <label class="col-sm-1">To</label>
                        <div class="col-md-3"> <input type=text date-picker
                                    placeholder='Date (DD-MM-YYYY)'
                                    dateformat='dd-mm-yy'
                                    maxlength="10"
                                    ng-required='true'
                                    class='form-control'
                                    ng-model='filter.toDate'/></div>
                        <div class="col-sm-1">
                            <button class="btn btn-success" ng-click="dateChanged()"> Filter</button>
                        </div>
                    </div>

                </div>
                <div class="col-md-12">
                    <div class="card card-primary card-outline" ng-repeat="md in projectdiary">
                        <div class="card-header border-transparent  mb-1">
                            <h3 class="card-title">{{md.proj_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 id="projectdiaryList" class="table table-bordered table-striped">
                                    <thead>
                                    <tr>
                                        <th>Date</th>
                                        <th>Project Status</th>
                                        <th>Any Current Escalation</th>
                                        <th>Any Current Challenge</th>
                                        <th>Putting extra hours in weekend</th>
                                        <th>Brief on Issue</th>
                                        <th>Plan to handle Escalation/Challenge/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 md.data | orderBy:'-date'">
                                        <!--<td><span>{"projectdiaryid":"3","proj_id":"91","emp_id":"22","date":"2006-02-22 00:00:00+05:30","reference":"Dolor illum quos ea","description":"Eu quia dicta fugiat","logtype":"1","hours":82,"comments":"Accusamus non placea","status":"active"}	</span></td>-->
                                        <td>
                                            <div class="nowrap" ng-bind="formatDate(d.pd_date) | date:'dd MMM yyyy'"></div>
                                        </td>
                                        <td>
                                            <div class="">{{d.pd_project_status}}</div>
                                        </td>
                                        <td>
                                            <div class="">{{d.pd_is_escalation?'Yes':'No'}}</div>
                                        </td>
                                        <td>
                                            <div class="nowrap">{{d.pd_is_challange?'Yes':'No'}}</div>
                                        </td>
                                        <td>
                                            <div class="nowrap">{{d.pd_is_extra_hours?'Yes':'No'}}</div>
                                        </td>
                                        <td>
                                            <div class="">{{d.pd_issue_brief}}</div>
                                        </td>
                                        <td>
                                            <div class="">{{d.pd_handling_plan}}</div>
                                        </td>
                                        <td>
                                            <button class="btn btn-success" ng-click="openEditProjectdiaryEntry(d)"><i class="fas fa-pen"></i></button>
                                        </td>
                                    </tr>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>

</div>
<script type="text/ng-template" id="EditProjectdiaryEntry.html">
    <div class="">
        <div class="modal-header bg-olive">
            <h4 class="modal-title" id="modal-title">Edit</h4>
        </div>
        <div class="modal-body" id="modal-body">
            <div class="form-group"><label>Project Name: </label> <strong class="text-olive">{{data.diary.proj_name}}</strong></div>

            <div class="form-group">
                <label>Date</label>
                <input type=text date-picker
                       placeholder='Date (DD-MM-YYYY)'
                       dateformat='dd-mm-yy'
                       maxlength="10"
                       ng-required='true'
                       class='form-control'
                       ng-model='data.diary.pd_date'/>
            </div>
            <div class="form-group">
                <label for="pd_project_status">Project Status</label>
                <select id="pd_project_status" required class="form-control custom-select"
                        ng-model="data.diary.pd_project_status" ng-options="ps.value as ps.label for ps in pd_project_status_options">
                </select>
            </div>
            <div class="form-group">
                <label for="pd_is_escalation">Any Current Escalation</label>
                <select id="pd_is_escalation" required class="form-control custom-select"
                        ng-model="data.diary.pd_is_escalation" ng-options="ps.value as ps.label for ps in boolean_options">
                </select>
            </div>
            <div class="form-group">
                <label for="pd_is_challange">Any Current Challenge</label>
                <select id="pd_is_challange" required class="form-control custom-select"
                        ng-model="data.diary.pd_is_challange" ng-options="ps.value as ps.label for ps in boolean_options">
                </select>
            </div>
            <div class="form-group">
                <label for="pd_is_extra_hours">Putting extra hours in weekend</label>
                <select id="pd_is_extra_hours" required class="form-control custom-select"
                        ng-model="data.diary.pd_is_extra_hours" ng-options="ps.value as ps.label for ps in boolean_options">
                </select>
            </div>
            <div class="form-group" ng-if="data.diary.pd_is_escalation===true">
                <label>Provide Brief on Issue</label>
                <textarea class="form-control" ng-model="data.diary.pd_issue_brief" placeholder="Provide Brief on Issue" rows="2" maxlength="1000"></textarea>
            </div>
            <div class="form-group" ng-if="data.diary.pd_is_challange===true">
                <label>Plan to handle Escalation/Challenge/Comments</label><textarea class="form-control" ng-model="data.diary.pd_handling_plan" placeholder="Plan to handle Escalation/Challenge/Comments" rows="2" maxlength="500"></textarea>
            </div>
        </div>
        <div class="modal-footer bg-olive">
            <button class="btn btn-default" type="button" ng-click="change(data)">Change</button>
            <button class="btn btn-primary" type="button" ng-click="cancel()">Cancel</button>
        </div>
    </div>
</script>
