<!DOCTYPE html>
<html lang="en">
  
<head>
    <%- include('./partials/head'); -%>
    
</head>
<body onload="startTime()">
    <%- include('./partials/header_sidebar'); -%>
    
    <!-- tap on top starts-->

        <!-- Page Sidebar Ends-->
        <div class="page-body">
          <div class="container-fluid">
            <div class="page-title">
              <div class="row">
                <div class="col-sm-6">
                    <h3><%= lan.faq %> <%= lan.list %></h3>
                </div>
                <div class="col-sm-6">
                    <ol class="breadcrumb">
                        <li class="breadcrumb-item"><a href="/index"><i data-feather="home"></i></a></li>
                        <li class="breadcrumb-item"><%= lan.dashboard %></li>
                        <li class="breadcrumb-item active"><%= lan.faq %> <%= lan.list %></li>
                    </ol>
                </div>
              </div>
            </div>
          </div>
          <!-- Container-fluid starts-->
          <div class="container-fluid">
            <div class="row">
                <div class="col-sm-12">
                    <div class="card">
                        <% let permiss = per != "1" ? per.faq_list[1] : "1" %>
                        <% if(permiss == "1"){ %>
                        <div class="card-header d-flex justify-content-end pb-0">
                            <button class="btn btn-square btn-primary b-r-10" type="button" data-bs-toggle="modal" data-bs-target="#add_faq"><%= lan.add %> <%= lan.faq %></button>
                        </div>
                        <% } %>
                        <div class="card-body">
                            <div class="table-responsive theme-scrollbar">
                                <table class="display" id="basic-1">
                                    <thead>
                                        <tr>
                                            <th>#</th>
                                            <th><%= lan.title %></th>
                                            <th><%= lan.description %></th>
                                            <th><%= lan.status %></th>
                                            <% let permissions = per != "1" ? per.faq_list[2] : "1" %>
                                            <% if(permissions == "1"){ %>
                                            <th><%= lan.action %></th>
                                            <% } %>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <% var i = 1 %>
                                        <% faq_list.forEach((data) => { %>
                                            <tr>
                                                <td><%= i %></td>
                                                <td><%= data.title %></td>
                                                <td><%= data.description %></td>
                                                <td>
                                                    <% if (data.status == '1') { %>
                                                        <span class="badge badge-success"><%= lan.active %></span>
                                                    <% } else { %>
                                                        <span class="badge badge-danger"><%= lan.deactive %></span>
                                                    <% } %>
                                                </td>
                                                <% if(permissions == "1"){ %>
                                                <td> 
                                                    <ul class="action"> 
                                                        <li class="edit"> <a data-bs-toggle="modal" data-bs-target="#edit_faq" id="edit_faq_data" data-id="<%= data.id %>" 
                                                            data-title="<%= data.title %>" data-description="<%= data.description %>" data-status="<%= data.status %>"><i class="icon-pencil-alt"></i></a></li>
                                                        <li class="delete"><a href="/settings/delete_faq/<%= data.id %>"><i class="icon-trash"></i></a></li>
                                                    </ul>
                                                </td>
                                                <% } %>
                                            </tr>
                                        <% i++ %>
                                        <% }) %>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
          </div>
          <!-- Container-fluid Ends-->
        </div>



        <div class="modal fade" id="add_faq" tabindex="-1" role="dialog" aria-labelledby="add_faq" aria-hidden="true">
            <div class="modal-dialog modal-dialog-centered" role="document">
                <div class="modal-content">
                    <div class="modal-header">
                        <h5 class="modal-title"><%= lan.add %>  <%= lan.review %> <%= lan.list %></h5>
                        <button class="btn-close" type="button" data-bs-dismiss="modal" aria-label="<%= lan.close %>"></button>
                    </div>
                    <form  class="needs-validation" novalidate="" action="/settings/add_faq" method="post">
                        <div class="modal-body">
                            <div class="row g-3">
                                <div class="col-12">
                                    <label class="form-label"><%= lan.title %></label>
                                    <input class="form-control" type="text" name="title" placeholder="<%= lan.enter %> <%= lan.title %>" required>
                                </div>
                                <div class="col-12">
                                    <label class="form-label"><%= lan.description %></label>
                                    <textarea class="form-control" name="description" rows="5" required></textarea>
                                </div>
                                <div class="col-12">
                                    <div class="d-flex" style="margin-top: 10px;">
                                        <div class="icon-state switch-outline">
                                            <label class="switch">
                                                <input type="checkbox" name="status"><span class="switch-state bg-success"></span>
                                            </label>
                                        </div>
                                        <label class="col-form-label m-l-10"><%= lan.status %></label>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="modal-footer">
                            <button class="btn btn-secondary" type="button" data-bs-dismiss="modal"><%= lan.close %></button>
                            <button class="btn btn-primary" type="submit"><%= lan.save %></button>
                        </div>
                    </form>
                </div>
            </div>
        </div>

        <div class="modal fade" id="edit_faq" tabindex="-1" role="dialog" aria-labelledby="edit_faq" aria-hidden="true">
            <div class="modal-dialog modal-dialog-centered" role="document">
                <div class="modal-content">
                    <div class="modal-header">
                        <h5 class="modal-title"><%= lan.edit %>  <%= lan.review %> <%= lan.list %></h5>
                        <button class="btn-close" type="button" data-bs-dismiss="modal" aria-label="<%= lan.close %>"></button>
                    </div>
                    <form  class="needs-validation" id="edit_faq_form" novalidate="" action="" method="post">
                        <div class="modal-body">
                            <div class="row g-3">
                                <div class="col-12">
                                    <label class="form-label"><%= lan.title %></label>
                                    <input class="form-control" id="faq_title" type="text" name="title" placeholder="<%= lan.enter %> <%= lan.title %>" required>
                                </div>
                                <div class="col-12">
                                    <label class="form-label"><%= lan.description %></label>
                                    <textarea class="form-control" id="faq_description" name="description" rows="5"></textarea>
                                </div>
                                <div class="col-12">
                                    <div class="d-flex" style="margin-top: 10px;">
                                        <div class="icon-state switch-outline">
                                            <label class="switch">
                                                <input type="checkbox" id="faq_status" name="status"><span class="switch-state bg-success"></span>
                                            </label>
                                        </div>
                                        <label class="col-form-label m-l-10"><%= lan.status %></label>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="modal-footer">
                            <button class="btn btn-secondary" type="button" data-bs-dismiss="modal"><%= lan.close %></button>
                            <button class="btn btn-primary" type="submit"><%= lan.save %></button>
                        </div>
                    </form>
                </div>
            </div>
        </div>

    <%- include('./partials/footer'); -%>
    <%- include('./partials/script'); -%>
    </body>
</html>