<!-- <div class="content-wrapper" ng-if="!myAccess.emailNotificationConf">
    <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> 	!</h5>
                    Unauthorised Access.
                </div>
            </div>
        </div>
    </div>
</div> -->
<!--  ng-if="myAccess.emailNotificationConf" -->
<div class="content-wrapper" class="modal-demo">
    <section class="content-header">
        <div class="container-fluid">
            <div class="row mb-2">
                <div class="col-sm-6">
                    <h1 class="text-{{page.color}}">
                        <go-back/>
                        <i class="fas {{page.icon}}"></i> Manage Requisition Dashboard
                    </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 text-blue">Manage Requisition Dashboard</li>
                    </ol>
                </div>
            </div>
        </div>
    </section>
    <section class="content">
        <div class="row">
                <div class="col-sm-12 col-md-12 col-lg-12">
                    <div class="card card-outline card-success">
                        <div class="card-header border-transparent">
                            <h3 class="card-title">Requisitions List</h3>
                            <div class="row">
                                <div class="col-sm-2"></div>
                                <div class="col-sm-3">
                                    Filter By Status
                                    <select ng-change="filterByStatus(status_id)" 
                                    data-toggle="tooltip" 
                                    title="Filter By Status" 
                                    class="form-control custom-select" 
                                    ng-model="status_id" 
                                    ng-options="st.id as st.status_name for st in statusList">
                                </select>
                                </div>
                                <div class="col-sm-3">
                                    Raised By
                                    <select ng-change="filterByRequirement(raised_by)" 
                                    data-toggle="tooltip" 
                                    title="Filter Raised By" 
                                    class="form-control custom-select" 
                                    ng-model="raised_by" 
                                    ng-options="st.on_behalf_of as st.fullname for st in heroesList">
                                </select>
                                </div>
                            </div>
                            <div class="card-tools">
                                <div class="btn-group">

                                    <a ng-if="currentUser.is_admin" ng-href="{{baseurl}}/requisitionadd"><button type="button" class="btn bg-indigo"><i class="fas fa-plus"></i> <span class="d-none d-lg-inline-block">Create Requisition</span></button></a>
                                    <!-- <button ng-click="goTo($event,'newslettersAdd')" type="button" class="btn bg-indigo"><i class="fas fa-plus"></i> <span class="d-none d-lg-inline-block">Create Newsletter</span></button> -->
                                    <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">
                                    <div class="table-responsive">
                                        <table id="" class="table table-bordered table-sm requisitionList">
                                            <thead>
                                            <tr>
                                                <th>SN</th>
                                                <th>Account Name</th>
                                                <th>Project Name</th>
                                                <th>Designation</th>
                                                <th>Allocation Hours</th>
                                                <th>Min / Max Experience</th>
                                                <th>Billing Status</th>
                                                <th>Billing Hours</th>
                                                <!-- <th>Raised On</th>
                                                <th>Position Closed On</th> -->
                                                <th>Needed By</th>
                                                <th>Raised On</th>
                                                <th>Engagement Duration (Weeks)</th>
                                                
                                                <th>Sourcing Status</th>
                                                <th>Requirement Raised By</th>
                                                
                                                <th ng-if="myself_id!=566">Action</th>
                                                <th ng-if="myself_id==566">Action</th>
                                                <th>Status</th>
                                                <th ng-if="myself_id!=566">Clone/Heroes </th>
                                            </tr>
                                            </thead>
                                            <tbody>
                                                <!-- ng-if="req.sopc_hero==myself_id || req.on_behalf_of==myself_id || myself_id=='1' || myself_id=='400' || myself_id=='566' || myself_id=='22' || myself_id=='163' || myself_id=='182'" -->
                                            <tr ng-repeat="req in requisitionList">
                                                <td>{{$index+1}}</td>
                                                <td>{{req.acc_company_name}}</td>
                                                <td>{{req.proj_name}}</td>
                                                <td>{{req.desg_name}}</td>
                                                <td>{{req.allocation_hours}}</td>
                                                <td>{{req.min_exp}} - {{req.max_exp}}</td>
                                                <td>{{req.billing_hours}}</td>
                                                <td>{{req.billing_type}}</td>
                                                <!-- <td>{{req.raised_on | datetz:'DD MMM YYYY'}}</td>
                                                <td>{{req.position_closed_on | datetz:'DD MMM YYYY'}}</td> -->
                                                <td>{{req.needed_by | datetz:'DD MMM YYYY'}}</td>
                                                <td>{{req.raised_on | datetz:'DD MMM YYYY'}}</td>
                                                <td>{{req.eng_duration}}</td>
                                                
                                                <td>{{req.sourcing_status | capitalize}}</td>
                                                <td>{{req.createdByfName }} {{req.createdBylName }}</td>

                                                <td ng-if="myself_id!=566">
                                                    <!-- This is For Project Manager -->
                                                    <button ng-if="req.req_status==1 && req.req_auth.length==0" type="button" class="btn btn-xs bg-cyan" 
                                                    ng-click="goToSelf('assignRequisitionForm',{requisition_id:req.id})"></i>Send For Approval</button>
                                                    <!-- <b class="text-info" ng-if="req.req_status==1 && req.req_auth.length>0">Approval Awaited</b> -->
                                                    <!-- <button ng-if="req.req_status==1 && req.spoc_hero==myself_id" type="button" class="btn btn-xs bg-cyan" ng-click="goToSelf('assignRequisitionForm',{requisition_id:req.id})"></i>Send For Approval</button> -->
                                                    
                                                    <!-- This is For Aproval Manager -->
                                                    <button ng-repeat="reqq in req.req_auth" ng-if="reqq.hero_id==myself_id && req.req_status==1 && (myself_id==22 || myself_id==163 || myself_id==182) " type="button" class="btn btn-xs bg-cyan" ng-click="clickToApprove(req.id)">Approve</button>
                                                    <!-- This is For All Manager -->
                                                    <b ng-if="req.req_status!=1" class="text text-xs text-success"> Approved
                                                        <!-- <span>{{req.emp_first_name}} {{req.emp_last_name}} On {{req.approved_on | datetz:'DD MMM YYYY'}} </span> -->
                                                    </b>
                                                    <!-- This is For Pool Manager -->
                                                    <br>
                                                    <button ng-if="myself_id==400 && req.req_status==2" class="btn btn-xs bg-cyan"  ng-click="openHeroLookup(req)">Lookup Hero</button> 
                                                    <br>
                                                    <button ng-if="req.req_status!=4 && req.req_status!=1" class="btn btn-xs bg-warning"  ng-click="statusChangeByPool(req)">Change Status</button>
                                                </td>
                                                <td>{{req.status_name }} <br> 
                                                    <span ng-if="req.req_status==4" class="text-danger">{{req.closing_date | datetz:'DD MMM YYYY'}}</span>
                                                </td>
                                                <td ng-if="myself_id==566">
                                                    <button class="btn btn-xs bg-warning" style="width: 90px;margin-bottom:5px" ng-if="req.sourcing_status=='external' && (req.req_status==2 || req.req_status==3 || req.req_status==5) " ng-click="changeExternalStatus(req)">Change Status</button>
                                                    <div ng-if="req.sourcing_status=='external' && req.status_name!='Closed'" class="btn-group">
                                                            <!-- <button class="btn btn-xs bg-info" title="Clone" ng-click="cloneRequisition(req)"><i class="fa fa-copy" aria-hidden="true"></i></button> -->
                                                            <button class="btn btn-xs bg-info" title="Clone" ng-click="cloneReq(req.id)"><i class="fa fa-copy" aria-hidden="true"></i></button>
                                                            <button class="btn btn-xs bg-success" title="Heroes List" ng-disabled="req.sourcing_status=='external'" ng-click="goToSelf('requisitionHeroDetails',{requisition_id:req.id})"><i class="fa fa-users" aria-hidden="true"></i></button>
                                                            <button ng-disabled="req.req_status==4" class="btn btn-xs bg-primary" title="Edit"  ng-click="goToSelf('requisitionEdit',{requisition_id:req.id})"><i class="fa fa-pen" aria-hidden="true"></i></button>
                                                            <button ng-if="myself_id==1" class="btn btn-xs bg-danger" title="Delete"  ng-click="goToSelf('requisitionEdit',{requisition_id:req.id})"><i class="fa fa-trash" aria-hidden="true"></i></button>
                                                    </div>
                                                </td>
                                                <td ng-if="myself_id!=566">
                                                    <div class="btn-group">
                                                        <!-- <button class="btn btn-xs bg-info" title="Clone" ng-click="cloneRequisition(req)"><i class="fa fa-copy" aria-hidden="true"></i></button> -->
                                                        <button class="btn btn-xs bg-info" title="Clone" ng-click="cloneReq(req.id)"><i class="fa fa-copy" aria-hidden="true"></i></button>
                                                        <button class="btn btn-xs bg-success" title="Heroes List" ng-disabled="req.sourcing_status=='external'" ng-click="goToSelf('requisitionHeroDetails',{requisition_id:req.id})"><i class="fa fa-users" aria-hidden="true"></i></button>
                                                        <button ng-disabled="req.req_status==4" class="btn btn-xs bg-primary" title="Edit"  ng-click="goToSelf('requisitionEdit',{requisition_id:req.id})"><i class="fa fa-pen" aria-hidden="true"></i></button>
                                                        <button ng-if="myself_id==1" class="btn btn-xs bg-danger" title="Delete"  ng-click="deleteRequisition(req.id)"><i class="fa fa-trash" aria-hidden="true"></i></button>
                                                    <!-- </div>ng-disabled="req.sourcing_status=='external'" -->
                                                    <!-- <button ng-if="myself_id==400 && req.req_status==2" class="btn btn-xs bg-cyan"  ng-click="openHeroLookupList(req)">Heros List</button> -->
                                                </td>
                                            </tr>
                                            </tbody>
                                        </table>
                                    </div>
                        </div>
                    </div>
                </div>

                <div class="col-sm-12 col-md-12 col-lg-12 ">
                    <div class="card card-outline card-success collapsed-card">
                        <div class="card-header border-transparent">
                            <h3 class="card-title">Closed/Hold Requisitions</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-plus"></i></button>
                                </div>
                            </div>
                        </div>
                        <div class="card-body">
                                    <div class="table-responsive">
                                        <table id="" class="table table-bordered table-sm inactiveRequisitions">
                                            <thead>
                                            <tr>
                                                <th>SN</th>
                                                <th>Account Name</th>
                                                <th>Project Name</th>
                                                <th>Designation</th>
                                                <th>Allocation Hours</th>
                                                <th>Min / Max Experience</th>
                                                <th>Billing Status</th>
                                                <th>Billing Hours</th>
                                                <!-- <th>Raised On</th>
                                                <th>Position Closed On</th> -->
                                                <th>Needed By</th>
                                                <th>Raised On</th>
                                                <th>Engagement Duration (Weeks)</th>
                                                
                                                <th>Sourcing Status</th>
                                                <th>Requirement Raised By</th>
                                                
                                                <th ng-if="myself_id!=566">Action</th>
                                                <th ng-if="myself_id==566">Action</th>
                                                <th>Status</th>
                                                <th ng-if="myself_id!=566">Clone/Heroes </th>
                                            </tr>
                                            </thead>
                                            <tbody>
                                                <!-- ng-if="req.sopc_hero==myself_id || req.on_behalf_of==myself_id || myself_id=='1' || myself_id=='400' || myself_id=='566' || myself_id=='22' || myself_id=='163' || myself_id=='182'" -->
                                            <tr ng-repeat="req in inactiveRequisitions">
                                                <td>{{$index+1}}</td>
                                                <td>{{req.acc_company_name}}</td>
                                                <td>{{req.proj_name}}</td>
                                                <td>{{req.desg_name}}</td>
                                                <td>{{req.allocation_hours}}</td>
                                                <td>{{req.min_exp}} - {{req.max_exp}}</td>
                                                <td>{{req.billing_hours}}</td>
                                                <td>{{req.billing_type}}</td>
                                                <!-- <td>{{req.raised_on | datetz:'DD MMM YYYY'}}</td>
                                                <td>{{req.position_closed_on | datetz:'DD MMM YYYY'}}</td> -->
                                                <td>{{req.needed_by | datetz:'DD MMM YYYY'}}</td>
                                                <td>{{req.raised_on | datetz:'DD MMM YYYY'}}</td>
                                                <td>{{req.eng_duration}}</td>
                                                
                                                <td>{{req.sourcing_status | capitalize}}</td>
                                                <td>{{req.createdByfName }} {{req.createdBylName }}</td>

                                                <td ng-if="myself_id!=566">
                                                    <!-- This is For Project Manager -->
                                                    <button ng-if="req.req_status==1 && req.req_auth.length==0" type="button" class="btn btn-xs bg-cyan" 
                                                    ng-click="goToSelf('assignRequisitionForm',{requisition_id:req.id})"></i>Send For Approval</button>
                                                    <!-- <b class="text-info" ng-if="req.req_status==1 && req.req_auth.length>0">Approval Awaited</b> -->
                                                    <!-- <button ng-if="req.req_status==1 && req.spoc_hero==myself_id" type="button" class="btn btn-xs bg-cyan" ng-click="goToSelf('assignRequisitionForm',{requisition_id:req.id})"></i>Send For Approval</button> -->
                                                    
                                                    <!-- This is For Aproval Manager -->
                                                    <button ng-repeat="reqq in req.req_auth" ng-if="reqq.hero_id==myself_id && req.req_status==1 && (myself_id==22 || myself_id==163 || myself_id==182) " type="button" class="btn btn-xs bg-cyan" ng-click="clickToApprove(req.id)">Approve</button>
                                                    <!-- This is For All Manager -->
                                                    <b ng-if="req.req_status!=1" class="text text-xs text-success"> Approved
                                                        <!-- <span>{{req.emp_first_name}} {{req.emp_last_name}} On {{req.approved_on | datetz:'DD MMM YYYY'}} </span> -->
                                                    </b>
                                                    <!-- This is For Pool Manager -->
                                                    <br>
                                                    <button ng-if="myself_id==400 && req.req_status==2" class="btn btn-xs bg-cyan"  ng-click="openHeroLookup(req)">Lookup Hero</button> 
                                                    <br>
                                                    <button ng-if="req.req_status!=4 && req.req_status!=1" class="btn btn-xs bg-warning"  ng-click="statusChangeByPool(req)">Change Status</button>
                                                </td>
                                                <td>{{req.status_name }} <br> 
                                                    <span ng-if="req.req_status==4" class="text-danger">{{req.closing_date | datetz:'DD MMM YYYY'}}</span>
                                                </td>
                                                <td ng-if="myself_id==566">
                                                    <button class="btn btn-xs bg-warning" style="width: 90px;margin-bottom:5px" ng-if="req.sourcing_status=='external' && (req.req_status==2 || req.req_status==3 || req.req_status==5) " ng-click="changeExternalStatus(req)">Change Status</button>
                                                    <div ng-if="req.sourcing_status=='external' && req.status_name!='Closed'" class="btn-group">
                                                            <!-- <button class="btn btn-xs bg-info" title="Clone" ng-click="cloneRequisition(req)"><i class="fa fa-copy" aria-hidden="true"></i></button> -->
                                                            <button class="btn btn-xs bg-info" title="Clone" ng-click="cloneReq(req.id)"><i class="fa fa-copy" aria-hidden="true"></i></button>
                                                            <button class="btn btn-xs bg-success" title="Heroes List" ng-disabled="req.sourcing_status=='external'" ng-click="goToSelf('requisitionHeroDetails',{requisition_id:req.id})"><i class="fa fa-users" aria-hidden="true"></i></button>
                                                            <button ng-disabled="req.req_status==4" class="btn btn-xs bg-primary" title="Edit"  ng-click="goToSelf('requisitionEdit',{requisition_id:req.id})"><i class="fa fa-pen" aria-hidden="true"></i></button>
                                                            <button ng-if="myself_id==1" class="btn btn-xs bg-danger" title="Delete"  ng-click="goToSelf('requisitionEdit',{requisition_id:req.id})"><i class="fa fa-trash" aria-hidden="true"></i></button>
                                                    </div>
                                                </td>
                                                <td ng-if="myself_id!=566">
                                                    <div class="btn-group">
                                                        <!-- <button class="btn btn-xs bg-info" title="Clone" ng-click="cloneRequisition(req)"><i class="fa fa-copy" aria-hidden="true"></i></button> -->
                                                        <button class="btn btn-xs bg-info" title="Clone" ng-click="cloneReq(req.id)"><i class="fa fa-copy" aria-hidden="true"></i></button>
                                                        <button class="btn btn-xs bg-success" title="Heroes List" ng-disabled="req.sourcing_status=='external'" ng-click="goToSelf('requisitionHeroDetails',{requisition_id:req.id})"><i class="fa fa-users" aria-hidden="true"></i></button>
                                                        <button ng-disabled="req.req_status==4" class="btn btn-xs bg-primary" title="Edit"  ng-click="goToSelf('requisitionEdit',{requisition_id:req.id})"><i class="fa fa-pen" aria-hidden="true"></i></button>
                                                        <button ng-if="myself_id==1" class="btn btn-xs bg-danger" title="Delete"  ng-click="deleteRequisition(req.id)"><i class="fa fa-trash" aria-hidden="true"></i></button>
                                                    <!-- </div>ng-disabled="req.sourcing_status=='external'" -->
                                                    <!-- <button ng-if="myself_id==400 && req.req_status==2" class="btn btn-xs bg-cyan"  ng-click="openHeroLookupList(req)">Heros List</button> -->
                                                </td>
                                            </tr>
                                            </tbody>
                                        </table>
                                    </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- =Script=================- -->
    <script type="text/ng-template" id="HeroLookup.html">
        <div class="" style="width:100%">
            <div class="modal-header bg-primary">
                <h3 class="modal-title" id="modal-title">Lookup Hero</h3>
            </div>
            <div class="modal-body" id="modal-body">
                <!-- <p>Are you sure to remove <strong>{{data.hero.emp_first_name +' '+ data.hero.emp_last_name }} </string> ?</p> -->
                    <div class="form-group">
                        <label for="sourcing_status">Sourcing Source</label>
                        <select id="sourcing_status" class="form-control" ng-model="req.sourcing_status">
                            <option value="internal">Internal</option>
                            <option value="external">External</option>
                        </select>
                    </div>
                    <div class="form-group" ng-if="req.sourcing_status=='internal'">
                        <label for="emp_acl_profile">Select Heroes</label>
                        <ui-select multiple on-select="onHeroSelect($model)" on-remove="onHeroSelect($model)" ng-model="req.heroes" id="selectHero" theme="bootstrap" title="Select Hero" style="width: 100%">
                            <ui-select-match placeholder="Select or search a hero in the list...">{{$item.emp_first_name +' '+$item.emp_last_name + ' ' + $item.emp_code}}</ui-select-match>
                            <ui-select-choices repeat="hero.id as hero in heroes | filter: $select.search">
                                <span ng-bind-html="hero.emp_first_name +' '+hero.emp_last_name + ' ' + hero.emp_code | highlight: $select.search"></span>
                            </ui-select-choices>
                        </ui-select>
                    </div>
                    <div class="form-group">
                    <label for="req_status">Requirement Status</label>
                        <select id="req_status"  class="form-control custom-select" ng-model="req.req_status"
                        ng-options="ps.id as ps.status_name for ps in statusList">
                       </select>
                    </select>
                    </div>

            </div>
            <div class="modal-footer bg-primary">
                <div class="col-12">
                    <button class="btn btn-danger float-left" type="button" ng-click="cancel()">Cancel</button>
                    <button class="btn btn-success float-right" type="button" ng-click="clickToChangeHeroLookup(req)">Done</button>
                </div>
            </div>
        </div>
    </script>
    <!-- =End Script=================- -->

    <!-- =Script For Change Status From Pool=================- -->
    <script type="text/ng-template" id="statusChangeByPool.html">
        <div class="" style="width:100%">
            <div class="modal-header bg-primary">
                <h3 class="modal-title" id="modal-title">Change Status</h3>
            </div>
            <div class="modal-body" id="modal-body">
                <!-- <p>Are you sure to remove <strong>{{data.hero.emp_first_name +' '+ data.hero.emp_last_name }} </string> ?</p> -->
                    <div class="form-group">
                        <label for="sourcing_status">Sourcing Source</label>
                        <select id="sourcing_status" class="form-control" ng-model="req.sourcing_status">
                            <option value="internal">Internal</option>
                            <option value="external">External</option>
                        </select>
                    </div>
                    <!-- ng-if="req.sourcing_status=='internal'" -->
                    <div class="form-group" >
                        <label for="req_status">Requirement Status</label>
                        <select id="req_status" class="form-control custom-select" ng-model="req.req_status"
                            ng-options="ps.id as ps.status_name for ps in statusList">
                        </select>
                    </div>
                    <div class="form-group" ng-if="req.req_status==4">
                        <label for="req_status">Closing Date</label>
                        <input type="date" class="form-control" ng-model="req.closing_date">
                    </div>

            </div>
            <div class="modal-footer bg-primary">
                <div class="col-12">
                    <button class="btn btn-danger float-left" type="button" ng-click="cancel()">Cancel</button>
                    <button class="btn btn-success float-right" type="button" ng-click="clickToChangeStatusByPool(req)">Done</button>
                </div>
            </div>
        </div>
    </script>
    <!-- =Script For Change Status From Pool=================- -->


        <!-- =Script=================- -->
        <script type="text/ng-template" id="changeExternalStatus.html">
            <div class="" style="width:100%">
                <div class="modal-header bg-primary">
                    <h3 class="modal-title" id="modal-title">Requirement Status</h3>
                </div>
                <div class="modal-body" id="modal-body">
                        <div class="form-group">
                            <label for="req_status">Requirement Status</label>
                                <select id="req_status"  class="form-control custom-select" ng-model="req.req_status"
                                ng-options="ps.id as ps.status_name for ps in statusList">
                            </select>
                        </div>
                        <div class="form-group">
                            <label for="req_status">Comment</label>
                                <textarea class="form-control" ng-model="req.comment"></textarea>
                        </div>
                        <div class="form-group" ng-if="req.req_status==4">
                            <label for="req_status">Closing Date</label>
                            <input type="date" class="form-control" ng-model="req.closing_date">
                        </div>
                </div>
                <div class="modal-footer bg-primary">
                    <div class="col-12">
                        <button class="btn btn-danger float-left" type="button" ng-click="cancel()">Cancel</button>
                        <button class="btn btn-success float-right" type="button" ng-click="changeExtStatus(req)">Done</button>
                    </div>
                </div>
            </div>
        </script>
        <!-- =End Script=================- -->
</div>
