<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>

<div class="content-wrapper" class="modal-demo" ng-if="myAccess.emailNotificationConf">
    <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> Email Notification Configuration
                    </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">Email Notification Configuration</li>
                    </ol>
                </div>
            </div>
        </div>
    </section>
    <section class="content">
        <div class="row">
            <div class="col-md-12">
                <div class="card card-outline card-success sticky-top top-100">
                    <div class="card-body" id="formCard">
                        <div class="row">
                            <div class="col-sm-6">
                                <div class="form-group ol-sm-6">
                                    <label for="notification_type">Notification Type</label>
                                    <select class="form-control" id="notification_type" ng-model="data.notification_type" required>
                                        <option value="" disabled>Select</option>
                                        <option ng-repeat="x in notificationType" value="{{x.id}}">{{x.value}}</option>
                                    </select>
                                    <!-- <input type="text" id="name" class="form-control" ng-model="data.notification_type" placeholder="Notification Type"> -->
                                </div>
                            </div>
                            <div class="col-sm-5">
                                <div class="form-group">
                                    <label for="frequency">Frequency</label>
                                    <select id="frequency" class="form-control"  ng-model="data.frequency" ng-change="changeOncustomSelect(data.frequency)" required>
                                        <option value="" disabled>Select</option>
                                        <option value="daily">Daily</option>
                                        <option value="monthly">Monthly</option>
                                        <option value="custom">Custom</option>
                                    </select>
                                </div>
                            </div>
                            <div class="col-sm-1" ng-if="data.frequency=='custom'">
                                <div class="form-group">
                                    <label for="days_interval">Days</label>
                                    <input type="number" id="days_interval" class="form-control" ng-model="data.days_interval" value="0" placeholder="Days" min="1" required>
                                </div>
                            </div>
                        </div>

                        <div class="row">
                            <div class="col-sm-6">
                            <div class="form-group">
                                <label for="location">Location</label>
                                <select class="form-control" id="location" ng-model="data.cty_location" required>
                                    <option value="0">Select</option>
                                    <option ng-repeat="x in countryList" value="{{x.id}}">{{x.country_name}}</option>
                                </select>
                            </div>
                            </div>
                            <div class="col-sm-6">
                            <div class="form-group">
                                <label for="emailTemp">Email Template</label>
                                <select class="form-control" id="emailTemp" ng-model="data.email_template_id" required>
                                    <option value="0">Select</option>
                                    <option ng-repeat="x in emailTempList" value="{{x.id}}">{{x.subject}}</option>
                                </select>
                            </div>
                            </div>
                            </div>
                            <div class="form-group">
                                <label for="notification">Notifications Email</label>
                                <textarea  id="notification" class="form-control" ng-model="data.notifications_email" required></textarea>
                            </div>
                            <div class="row">
                                <div class="col-12">
                                    <button type="button" class="btn btn-success float-right" ng-click="add(data)"><i class="fas fa-save"></i> Add ENC</button>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

                <!--  -->
                <div class="col-12 col-md-12 col-lg-12">
                <div class="card card-outline card-success">
                    <div class="card-body">
                                <h5>Email Notification Configuration List</h5>
                                <div class="table-responsive">
                                    <table id="masterList" class="table table-bordered table-sm">
                                        <thead>
                                        <tr>
                                            <th>Notification Type</th>
                                            <th>Frequency</th>
                                            <th>Location</th>
                                            <th>Email</th>
                                            <th>Email Templates</th>
                                            <th>Action</th>
                                        </tr>
                                        </thead>
                                        <tbody>
                                        <tr ng-repeat="dl in dataList">
                                            <td><strong>{{dl.notification_type|capitalize}}</strong></td>
                                            <td>
                                                <strong>{{dl.frequency |capitalize}} 
                                                <span ng-if="dl.frequency=='custom'">({{dl.days_interval}}-Days)</span>
                                                </strong>
                                            </td>
                                            <td><strong>{{dl.country_name}}</strong></td>
                                            <td><strong>{{dl.notifications_email}}</strong></td>
                                            <td><strong>{{dl.subject}}</strong></td>
                                            <td>
                                                <div class="btn-group btn-group-sm">
                                                    <button type="button" class="btn btn-xs bg-cyan" ng-click="edit(dl)"><i class="fas fa-pen-square" title="Edit"></i></button>
                                                  
                                                    <!-- <button type="button" class="btn btn-xs {{dl.status==false?'bg-danger':'bg-success'}}" ng-click="{{dl.status==true?'delete(dl)':'edit(dl)'}}"> -->
                                                    <button type="button" class="btn btn-xs {{dl.status==false?'bg-danger':'bg-success'}}" ng-click="changeStatus(dl)">
                                                        <i class="fas fa-{{dl.status==true?'trash':'redo'}}" title="{{dl.status==false?'Inactive':'Active'}}"></i> {{dl.status==0?'Inactive':'Active'}}</button>
                                                </div>
                                            </td>
                                        </tr>
                                        </tbody>
                                    </table>
                                </div>
                    </div>
                </div>
                </div>
                <!--  -->
            </div>
        </div>
    </section>
    <!-- <section class="content">
        <div class="row">
            <div class="col-md-12">
           
            </div>
        </div>
    </section> -->
</div>
